swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 1 | #include "mem.h" |
| 2 | |
| 3 | |
| 4 | void outb(ushort port, uchar val) |
| 5 | { |
| 6 | asm volatile("outb %1, %0" : : "dN" (port), "a" (val)); |
| 7 | } |
| 8 | |
| 9 | uchar inb(ushort port) |
| 10 | { |
| 11 | uchar ret; |
| 12 | asm volatile("inb %1, %0" : "=a" (ret) : "dN" (port)); |
| 13 | return ret; |
| 14 | } |
| 15 | |
| 16 | ushort inw(ushort port) |
| 17 | { |
| 18 | ushort ret; |
| 19 | asm volatile("inw %1, %0" : "=a" (ret) : "dN" (port)); |
| 20 | return ret; |
| 21 | } |
| 22 | |
| 23 | void *memset(void *s, int c, size_t n) |
| 24 | { |
| 25 | for (size_t i = 0; i < n; i++) |
| 26 | { |
| 27 | ((uchar *)s)[i] = c; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | void *memcpy(void *dest, const void *src, size_t n) |
| 32 | { |
| 33 | for (size_t i = 0; i < n; i++) |
| 34 | { |
| 35 | ((uchar *)dest)[i] = ((uchar *)src)[i]; |
| 36 | } |
| 37 | } |