SprinkleOS/io.c

41 lines
994 B
C
Raw Permalink Normal View History

#include "io.h"
UINT8 mapped_io_read(UINT16 addr) {
UINT8 data;
asm volatile("inb %1,%0" : "=a"(data) : "d"(addr));
return data;
}
void mapped_io_write(UINT16 addr, UINT8 data) {
asm volatile("outb %0,%1" ::"a"(data), "d"(addr));
}
2021-04-09 18:13:55 +09:00
UINT16 mapped_io_read_word(UINT16 addr) {
UINT16 data;
asm volatile("inw %1,%0" : "=a"(data) : "d"(addr));
return data;
}
void mapped_io_write_word(UINT16 addr, UINT16 data) {
asm volatile("outw %0,%1" ::"a"(data), "d"(addr));
}
UINT32 mapped_io_read_dword(UINT16 addr) {
UINT32 data;
asm volatile("inl %1,%0" : "=a"(data) : "d"(addr));
return data;
}
void mapped_io_write_dword(UINT16 addr, UINT32 data) {
asm volatile("outl %0,%1" ::"a"(data), "d"(addr));
}
UINT64 mapped_io_read_qword(UINT16 addr) {
UINT64 data;
asm volatile("inq %1,%0" : "=a"(data) : "d"(addr));
return data;
}
void mapped_io_write_qword(UINT16 addr, UINT64 data) {
asm volatile("outq %0,%1" ::"a"(data), "d"(addr));
}