mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-06 13:35:03 +00:00
Import the "gerbert" kernel I worked on earlier this year.
It's a lot crappier than I remembered it. It's gonna need a lot of work.
This commit is contained in:
41
Kernel/IO.cpp
Normal file
41
Kernel/IO.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "IO.h"
|
||||
|
||||
namespace IO {
|
||||
|
||||
BYTE in8(WORD port)
|
||||
{
|
||||
BYTE value;
|
||||
asm("inb %%dx, %%al":"=a"(value):"d"(port));
|
||||
return value;
|
||||
}
|
||||
|
||||
WORD in16(WORD port)
|
||||
{
|
||||
WORD value;
|
||||
asm("inw %%dx, %%ax":"=a"(value):"d"(port));
|
||||
return value;
|
||||
}
|
||||
|
||||
DWORD in32(DWORD port)
|
||||
{
|
||||
DWORD value;
|
||||
asm("inl %%dx, %%eax":"=a"(value):"d"(port));
|
||||
return value;
|
||||
}
|
||||
|
||||
void out8(WORD port, BYTE value)
|
||||
{
|
||||
asm("outb %%al, %%dx"::"d"(port), "a"(value));
|
||||
}
|
||||
|
||||
void out16(WORD port, WORD value)
|
||||
{
|
||||
asm("outw %%ax, %%dx"::"d"(port), "a"(value));
|
||||
}
|
||||
|
||||
void out32(WORD port, WORD value)
|
||||
{
|
||||
asm("outl %%eax, %%dx"::"d"(port), "a"(value));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user