basickernel/kernel/ports.c
Nicolás Ortega Froysa ad43ca56b1
Buggy screen driver.
2018-02-26 15:02:25 +01:00

24 lines
639 B
C

unsigned char port_byte_in(unsigned short port) {
unsigned char res;
/*
* `"=a" (res)' means: put result of `al' into `res' variable
* `"d" (port)' means: load `port' into `dx'.
*/
__asm__("in %%dx, %%al" : "=a" (res) : "d" (port));
return res;
}
void port_byte_out(unsigned short port, unsigned char data) {
__asm__("out %%al, %%dx" : : "a" (data), "d" (port));
}
unsigned short port_word_in(unsigned short port) {
unsigned short res;
__asm__("in %%dx, %%ax" : "=a" (res) : "d" (port));
return res;
}
void port_word_out(unsigned short port, unsigned short data) {
__asm__("out %%ax, %%dx" : : "a" (data), "d" (port));
}