42 lines
827 B
C++
42 lines
827 B
C++
|
#include "io/IO.h"
|
||
|
|
||
|
uint8_t IO::inb(uint16_t port)
|
||
|
{
|
||
|
uint8_t result;
|
||
|
asm volatile("inb %1, %0" : "=a"(result) : "Nd"(port));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
void IO::outb(uint16_t port, uint8_t value)
|
||
|
{
|
||
|
asm volatile("outb %0, %1" : : "a"(value), "Nd"(port));
|
||
|
}
|
||
|
|
||
|
uint16_t IO::inw(uint16_t port)
|
||
|
{
|
||
|
uint16_t result;
|
||
|
asm volatile("inw %1, %0" : "=a"(result) : "Nd"(port));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
void IO::outw(uint16_t port, uint16_t value)
|
||
|
{
|
||
|
asm volatile("outw %0, %1" : : "a"(value), "Nd"(port));
|
||
|
}
|
||
|
|
||
|
uint32_t IO::inl(uint16_t port)
|
||
|
{
|
||
|
uint32_t result;
|
||
|
asm volatile("inl %1, %0" : "=a"(result) : "Nd"(port));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
void IO::outl(uint16_t port, uint32_t value)
|
||
|
{
|
||
|
asm volatile("outl %0, %1" : : "a"(value), "Nd"(port));
|
||
|
}
|
||
|
|
||
|
void IO::delay()
|
||
|
{
|
||
|
asm volatile("outb %%al, $0x80" : : "a"(0));
|
||
|
}
|