1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Make IO helpers inline and use immediate-encoded ports when possible.

This commit is contained in:
Andreas Kling 2018-11-02 09:49:10 +01:00
parent 812e7940e2
commit 05565bad58
3 changed files with 35 additions and 50 deletions

View file

@ -4,12 +4,39 @@
namespace IO {
BYTE in8(WORD port);
WORD in16(WORD port);
DWORD in32(WORD port);
void out8(WORD port, BYTE data);
void out16(WORD port, WORD data);
void out32(WORD port, DWORD data);
inline byte in8(word port)
{
byte value;
asm volatile("inb %1, %0":"=a"(value):"Nd"(port));
return value;
}
inline word in16(word port)
{
word value;
asm volatile("inw %1, %0":"=a"(value):"Nd"(port));
return value;
}
inline dword in32(dword port)
{
dword value;
asm volatile("inl %1, %0":"=a"(value):"Nd"(port));
return value;
}
inline void out8(word port, byte value)
{
asm volatile("outb %0, %1"::"a"(value), "Nd"(port));
}
inline void out16(word port, word value)
{
asm volatile("outw %0, %1"::"a"(value), "Nd"(port));
}
inline void out32(word port, dword value)
{
asm volatile("outl %0, %1"::"a"(value), "Nd"(port));
}
}