Newer
Older
tree-os / src / kernel / util / ports.c
@lukas lukas on 4 Jan 2022 565 bytes pci: discover devices
#include <ports.h>
#include <stdint.h>

void outb(uint16_t port, uint8_t val) {
    asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
}

uint8_t inb(uint16_t port) {
    uint8_t result;
    __asm__("in %%dx, %%al" : "=a"(result) : "d"(port));
    return result;
}

void outi(uint16_t port, uint32_t val) {
    asm volatile("outl %0, %1" : : "a"(val), "Nd"(port));
}

uint32_t ini(uint16_t port) {
    uint32_t result;
    __asm__("in %%dx, %%eax" : "=a"(result) : "d"(port));
    return result;
}

void ioWait() { asm volatile("outb %%al, $0x80" : : "a"(0)); }