mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Make IO helpers inline and use immediate-encoded ports when possible.
This commit is contained in:
parent
812e7940e2
commit
05565bad58
Notes:
sideshowbarker
2024-07-19 18:34:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/05565bad580
3 changed files with 35 additions and 50 deletions
|
@ -1,41 +0,0 @@
|
|||
#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));
|
||||
}
|
||||
|
||||
}
|
43
Kernel/IO.h
43
Kernel/IO.h
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ KERNEL_OBJS = \
|
|||
i8253.o \
|
||||
Keyboard.o \
|
||||
CMOS.o \
|
||||
IO.o \
|
||||
PIC.o \
|
||||
Syscall.o \
|
||||
Disk.o \
|
||||
|
|
Loading…
Add table
Reference in a new issue