00001 #ifndef THREADS_IO_H
00002
00003 #define THREADS_IO_H
00004
00005 #include <stddef.h>
00006 #include <stdint.h>
00007
00008
00009 static inline uint8_t
00010 inb (uint16_t port)
00011 {
00012
00013 uint8_t data;
00014 asm volatile ("inb %w1, %b0" : "=a" (data) : "Nd" (port));
00015 return data;
00016 }
00017
00018
00019
00020 static inline void
00021 insb (uint16_t port, void *addr, size_t cnt)
00022 {
00023
00024 asm volatile ("rep insb" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
00025 }
00026
00027
00028 static inline uint16_t
00029 inw (uint16_t port)
00030 {
00031 uint16_t data;
00032
00033 asm volatile ("inw %w1, %w0" : "=a" (data) : "Nd" (port));
00034 return data;
00035 }
00036
00037
00038
00039 static inline void
00040 insw (uint16_t port, void *addr, size_t cnt)
00041 {
00042
00043 asm volatile ("rep insw" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
00044 }
00045
00046
00047 static inline uint32_t
00048 inl (uint16_t port)
00049 {
00050
00051 uint32_t data;
00052 asm volatile ("inl %w1, %0" : "=a" (data) : "Nd" (port));
00053 return data;
00054 }
00055
00056
00057
00058 static inline void
00059 insl (uint16_t port, void *addr, size_t cnt)
00060 {
00061
00062 asm volatile ("rep insl" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
00063 }
00064
00065
00066 static inline void
00067 outb (uint16_t port, uint8_t data)
00068 {
00069
00070 asm volatile ("outb %b0, %w1" : : "a" (data), "Nd" (port));
00071 }
00072
00073
00074
00075 static inline void
00076 outsb (uint16_t port, const void *addr, size_t cnt)
00077 {
00078
00079 asm volatile ("rep outsb" : "+S" (addr), "+c" (cnt) : "d" (port));
00080 }
00081
00082
00083 static inline void
00084 outw (uint16_t port, uint16_t data)
00085 {
00086
00087 asm volatile ("outw %w0, %w1" : : "a" (data), "Nd" (port));
00088 }
00089
00090
00091
00092 static inline void
00093 outsw (uint16_t port, const void *addr, size_t cnt)
00094 {
00095
00096 asm volatile ("rep outsw" : "+S" (addr), "+c" (cnt) : "d" (port));
00097 }
00098
00099
00100 static inline void
00101 outl (uint16_t port, uint32_t data)
00102 {
00103
00104 asm volatile ("outl %0, %w1" : : "a" (data), "Nd" (port));
00105 }
00106
00107
00108
00109 static inline void
00110 outsl (uint16_t port, const void *addr, size_t cnt)
00111 {
00112
00113 asm volatile ("rep outsl" : "+S" (addr), "+c" (cnt) : "d" (port));
00114 }
00115
00116 #endif