Move IO Port Function to a separate file

This commit is contained in:
Drew Galbraith 2023-05-17 20:26:51 -07:00
parent a164d9d67c
commit 91b52f1872
2 changed files with 15 additions and 4 deletions

13
zion/common/port.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <stdint.h>
static inline uint8_t inb(uint16_t port) {
uint8_t result;
asm volatile("inb %1, %0" : "=a"(result) : "Nd"(port));
return result;
}
static inline void outb(uint16_t port, uint8_t value) {
asm volatile("outb %0, %1" ::"a"(value), "Nd"(port));
}

View File

@ -1,10 +1,8 @@
#include <stdint.h>
#define COM1 0x3f8
#include "common/port.h"
void outb(uint16_t port, uint8_t value) {
asm volatile("outb %0, %1" ::"a"(value), "Nd"(port));
}
#define COM1 0x3f8
extern "C" void zion() {
outb(COM1, 'a');