26 lines
772 B
C
Raw Normal View History

2022-11-14 00:23:42 +03:00
#pragma once
2022-11-20 19:48:55 +03:00
static inline unsigned char port_byte_in(unsigned short port) {
2022-11-14 00:23:42 +03:00
unsigned char result;
__asm__("in %%dx, %%al" : "=a" (result) : "d" (port));
return result;
}
2022-11-20 19:48:55 +03:00
static inline unsigned short port_word_in(unsigned short port) {
2022-11-17 23:16:57 +03:00
unsigned short result;
__asm__("in %%dx, %%ax" : "=a" (result) : "d" (port));
return result;
}
2022-11-20 19:48:55 +03:00
static inline void port_byte_out(unsigned short port, unsigned char data) {
2022-11-18 22:58:49 +03:00
__asm__("outb %%al, %%dx" : : "a" (data), "d" (port));
}
2022-11-20 19:48:55 +03:00
static inline void port_word_out(unsigned short port, unsigned short data) {
2022-11-18 22:58:49 +03:00
__asm__("outw %%ax, %%dx" : : "a" (data), "d" (port));
2022-11-14 00:23:42 +03:00
}
2022-11-17 23:16:57 +03:00
2022-11-20 19:48:55 +03:00
static inline void port_long_out(unsigned short port, unsigned int data) {
2022-11-18 22:58:49 +03:00
__asm__("outl %%eax, %%dx" : : "a" (data), "d" (port));
2022-11-17 23:16:57 +03:00
}