quinn-os/io.c
2015-08-25 13:30:49 +10:00

31 lines
836 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 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);
}
}