41 lines
804 B
C++
41 lines
804 B
C++
#include "arch/x86_64/IO.h"
|
|
|
|
namespace IO
|
|
{
|
|
u8 inb(u16 port)
|
|
{
|
|
u8 result;
|
|
asm volatile("inb %1, %0" : "=a"(result) : "Nd"(port));
|
|
return result;
|
|
}
|
|
|
|
void outb(u16 port, u8 value)
|
|
{
|
|
asm volatile("outb %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|
|
|
|
u16 inw(u16 port)
|
|
{
|
|
u16 result;
|
|
asm volatile("inw %1, %0" : "=a"(result) : "Nd"(port));
|
|
return result;
|
|
}
|
|
|
|
void outw(u16 port, u16 value)
|
|
{
|
|
asm volatile("outw %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|
|
|
|
u32 inl(u16 port)
|
|
{
|
|
u32 result;
|
|
asm volatile("inl %1, %0" : "=a"(result) : "Nd"(port));
|
|
return result;
|
|
}
|
|
|
|
void outl(u16 port, u32 value)
|
|
{
|
|
asm volatile("outl %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|
|
}
|