diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-10-29 11:26:44 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-10-29 11:26:44 +0300 |
commit | c4fcc92183c55db868d0d6ae53e6009fb2e53ee5 (patch) | |
tree | ad5ef50aa07465e11f779c4482e20e6071182e9c /i686/sys/io.h | |
parent | makefile: add libk target (diff) | |
download | kernel-c4fcc92183c55db868d0d6ae53e6009fb2e53ee5.tar.xz |
makefile: add i686/arch.a target
Diffstat (limited to 'i686/sys/io.h')
-rw-r--r-- | i686/sys/io.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/i686/sys/io.h b/i686/sys/io.h new file mode 100644 index 0000000..74d4950 --- /dev/null +++ b/i686/sys/io.h @@ -0,0 +1,79 @@ +#pragma once + +static inline void +outb(unsigned char val, unsigned short port) +{ + asm volatile("outb %0,%1" : : "a"(val), "dN"(port)); +} + +static inline void +outw(unsigned short val, unsigned short port) +{ + asm volatile("outw %0,%1" : : "a"(val), "dN"(port)); +} + +static inline void +outl(unsigned int val, unsigned short port) +{ + asm volatile("outl %0,%1" : : "a"(val), "dN"(port)); +} + +static inline unsigned char +inb(unsigned short port) +{ + unsigned char val; + asm volatile("inb %1,%0" : "=a"(val) : "dN"(port)); + return val; +} + +static inline unsigned short +inw(unsigned short port) +{ + unsigned short val; + asm volatile("inw %1,%0" : "=a"(val) : "dN"(port)); + return val; +} + +static inline unsigned int +inl(unsigned short port) +{ + unsigned int val; + asm volatile("inl %1,%0" : "=a"(val) : "dN"(port)); + return val; +} + +static inline void +outsb(unsigned short port, const void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(port)); +} + +static inline void +outsw(unsigned short port, const void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(port)); +} + +static inline void +outsl(unsigned short port, const void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(port)); +} + +static inline void +insb(unsigned short port, void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(port)); +} + +static inline void +insw(unsigned short port, void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(port)); +} + +static inline void +insl(unsigned short port, void *__buf, unsigned long __n) +{ + asm volatile("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(port)); +} |