add: inb, outb

This commit is contained in:
starnakin 2024-09-07 13:06:54 +02:00
parent 907eb7cf7d
commit 0ad16863ba
3 changed files with 18 additions and 0 deletions

4
headers/sys/io.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
inline uint8_t inb(uint16_t port);
inline void outb(uint16_t port, uint8_t val);

10
src/sys/io/inb.c Normal file
View File

@ -0,0 +1,10 @@
inline uint8_t inb(uint16_t port)
{
uint8_t ret;
__asm__ volatile ( "inb %w1, %b0"
: "=a"(ret)
: "Nd"(port)
: "memory");
return ret;
}

4
src/sys/io/outb.c Normal file
View File

@ -0,0 +1,4 @@
inline void outb(uint16_t port, uint8_t val)
{
__asm__ volatile ( "outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory");
}