7 /* Reads and returns a byte from PORT. */
11 /* See [IA32-v2a] "IN". */
13 asm volatile ("inb %w1, %b0" : "=a" (data) : "Nd" (port));
17 /* Reads CNT bytes from PORT, one after another, and stores them
18 into the buffer starting at ADDR. */
20 insb (uint16_t port, void *addr, size_t cnt)
22 /* See [IA32-v2a] "INS". */
23 asm volatile ("rep insb" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
26 /* Reads and returns 16 bits from PORT. */
27 static inline uint16_t
31 /* See [IA32-v2a] "IN". */
32 asm volatile ("inw %w1, %w0" : "=a" (data) : "Nd" (port));
36 /* Reads CNT 16-bit (halfword) units from PORT, one after
37 another, and stores them into the buffer starting at ADDR. */
39 insw (uint16_t port, void *addr, size_t cnt)
41 /* See [IA32-v2a] "INS". */
42 asm volatile ("rep insw" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
45 /* Reads and returns 32 bits from PORT. */
46 static inline uint32_t
49 /* See [IA32-v2a] "IN". */
51 asm volatile ("inl %w1, %0" : "=a" (data) : "Nd" (port));
55 /* Reads CNT 32-bit (word) units from PORT, one after another,
56 and stores them into the buffer starting at ADDR. */
58 insl (uint16_t port, void *addr, size_t cnt)
60 /* See [IA32-v2a] "INS". */
61 asm volatile ("rep insl" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
64 /* Writes byte DATA to PORT. */
66 outb (uint16_t port, uint8_t data)
68 /* See [IA32-v2b] "OUT". */
69 asm volatile ("outb %b0, %w1" : : "a" (data), "Nd" (port));
72 /* Writes to PORT each byte of data in the CNT-byte buffer
75 outsb (uint16_t port, const void *addr, size_t cnt)
77 /* See [IA32-v2b] "OUTS". */
78 asm volatile ("rep outsb" : "+S" (addr), "+c" (cnt) : "d" (port));
81 /* Writes the 16-bit DATA to PORT. */
83 outw (uint16_t port, uint16_t data)
85 /* See [IA32-v2b] "OUT". */
86 asm volatile ("outw %w0, %w1" : : "a" (data), "Nd" (port));
89 /* Writes to PORT each 16-bit unit (halfword) of data in the
90 CNT-halfword buffer starting at ADDR. */
92 outsw (uint16_t port, const void *addr, size_t cnt)
94 /* See [IA32-v2b] "OUTS". */
95 asm volatile ("rep outsw" : "+S" (addr), "+c" (cnt) : "d" (port));
98 /* Writes the 32-bit DATA to PORT. */
100 outl (uint16_t port, uint32_t data)
102 /* See [IA32-v2b] "OUT". */
103 asm volatile ("outl %0, %w1" : : "a" (data), "Nd" (port));
106 /* Writes to PORT each 32-bit unit (word) of data in the CNT-word
107 buffer starting at ADDR. */
109 outsl (uint16_t port, const void *addr, size_t cnt)
111 /* See [IA32-v2b] "OUTS". */
112 asm volatile ("rep outsl" : "+S" (addr), "+c" (cnt) : "d" (port));
115 #endif /* threads/io.h */