2019-03-11 09:32:55 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
uint8_t port_byte_in(uint16_t port) {
|
|
|
|
uint8_t result;
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("in %%dx, %%al":"=a"(result):"d"(port));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-03-11 09:32:55 -05:00
|
|
|
void port_byte_out(uint16_t port,uint8_t data) {
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("out %%al, %%dx":: "a"(data),"d"(port));
|
|
|
|
}
|
|
|
|
|
2019-03-11 09:32:55 -05:00
|
|
|
uint16_t port_word_in(uint16_t port) {
|
|
|
|
uint16_t result;
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("in %%dx, %%ax":"=a"(result):"d"(port));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-03-11 09:32:55 -05:00
|
|
|
void port_word_out(uint16_t port,uint16_t data) {
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("out %%ax, %%dx":: "a" (data), "d" (port));
|
|
|
|
}
|
|
|
|
|
2019-03-11 09:32:55 -05:00
|
|
|
uint32_t port_long_in(uint16_t port) {
|
|
|
|
uint32_t result;
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("inl %%dx, %%eax":"=a"(result):"d"(port));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-03-11 09:32:55 -05:00
|
|
|
void port_long_out(uint16_t port,uint32_t data) {
|
2019-02-09 12:52:45 -06:00
|
|
|
asm("outl %%eax, %%dx":: "a" (data), "d" (port));
|
|
|
|
}
|