quinn-os/io.c
2021-12-09 15:13:01 +10:00

37 lines
986 B
C

void outportb(unsigned short _port, unsigned char _data) {
__asm__ __volatile__ ("outb %0, %1" : : "a" (_data), "Nd" (_port));
}
unsigned char inportb(unsigned short _port) {
unsigned char ret;
__asm__ __volatile__ ("inb %1, %0" : "=a"(ret) : "Nd" (_port));
return ret;
}
void outportl(unsigned short _port, unsigned long _data) {
__asm__ __volatile__ ("outl %0, %1" : : "a" (_data), "Nd" (_port));
}
unsigned short inportw(unsigned short _port) {
unsigned short ret;
__asm__ __volatile__ ("inw %1, %0" : "=a" (ret) : "Nd" (_port));
return ret;
}
unsigned long inportl(unsigned short _port) {
unsigned long ret;
__asm__ __volatile__ ("inl %%dx, %%eax" : "=a" (ret) : "d" (_port));
return ret;
}
void outportw (unsigned short _port, unsigned short _data)
{
__asm__ __volatile__ ("outw %1, %0" : : "dN" (_port), "a" (_data));
}
void inportsl(unsigned short _port, unsigned int *buffer, int count) {
int i;
for (i=0;i<count;i++) {
*(buffer + i) = inportl(_port);
}
}