10#ifndef KERNEL_ARCH_X86_64_IO_H
11#define KERNEL_ARCH_X86_64_IO_H
22inline void outb(uint16_t port, uint8_t value) {
23 asm volatile (
"out %1, %0" : :
"d"(port),
"a"(value) :
"memory");
31inline uint8_t
inb(uint16_t port) {
33 asm volatile (
"in %1, %0" :
"=a"(value) :
"d"(port) :
"memory");
43inline void outw(uint32_t port, uint16_t value) {
44 asm volatile (
"out %1, %0" : :
"d"(port),
"a"(value) :
"memory");
52inline uint16_t
inw(uint32_t port) {
54 asm volatile (
"in %1, %0" :
"=a"(value) :
"d"(port) :
"memory");
65inline void outl(uint32_t port, uint32_t value) {
66 asm volatile (
"out %1, %0" : :
"d"(port),
"a"(value) :
"memory");
74inline uint32_t
inl(uint32_t port) {
76 asm volatile (
"in %1, %0" :
"=a"(value) :
"d"(port) :
"memory");
88static inline uint64_t rdmsr(uint32_t msr)
91 __asm__
volatile(
"rdmsr" :
"=a"(lo),
"=d"(hi) :
"c"(msr));
92 return ((uint64_t)hi << 32) | lo;
95static inline void wrmsr(uint32_t msr, uint64_t value)
97 uint32_t lo = (uint32_t)value;
98 uint32_t hi = (uint32_t)(value >> 32);
99 __asm__
volatile(
"wrmsr" ::
"c"(msr),
"a"(lo),
"d"(hi) :
"memory");
uint32_t inl(uint32_t port)
Inputs 4 bytes from the specified port.
uint16_t inw(uint32_t port)
Inputs 2 bytes from the specified port.
void outw(uint32_t port, uint16_t value)
Outputs 2 bytes to the specified port.
uint8_t inb(uint16_t port)
Inputs a byte from the specified port.
void outb(uint16_t port, uint8_t value)
Outputs a byte to the specified port.
void outl(uint32_t port, uint32_t value)
Outputs 4 bytes to the specified port.
void io_wait(void)
Write 0 to unused port 0x80 to perform a short pause.