33 lines
874 B
C
33 lines
874 B
C
#pragma once
|
|
|
|
#include "util/number.h"
|
|
|
|
inline uint8_t port_read_8(uint16_t port) {
|
|
uint8_t value = 0;
|
|
__asm__ volatile("inb %1, %0" : "=a"(value) : "Nd"(port));
|
|
return value;
|
|
}
|
|
|
|
inline uint16_t port_read_16(uint16_t port) {
|
|
uint16_t value = 0;
|
|
__asm__ volatile("inw %1, %0" : "=a"(value) : "Nd"(port));
|
|
return value;
|
|
}
|
|
|
|
inline uint32_t port_read_32(uint16_t port) {
|
|
uint32_t value = 0;
|
|
__asm__ volatile("inl %1, %0" : "=a"(value) : "Nd"(port));
|
|
return value;
|
|
}
|
|
|
|
inline void port_write_8(uint16_t port, uint8_t value) {
|
|
__asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|
|
|
|
inline void port_write_16(uint16_t port, uint16_t value) {
|
|
__asm__ volatile("outw %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|
|
|
|
inline void port_write_32(uint16_t port, uint32_t value) {
|
|
__asm__ volatile("outl %0, %1" : : "a"(value), "Nd"(port));
|
|
}
|