mirror of
https://git.stationery.faith/corn/corn.git
synced 2024-11-09 23:22:08 +00:00
create bindings.h
This commit is contained in:
parent
05cf015382
commit
89ecedfceb
1 changed files with 53 additions and 0 deletions
53
src/arch/amd64/bindings.h
Normal file
53
src/arch/amd64/bindings.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
__asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val) {
|
||||
__asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint16_t inw(uint16_t port) {
|
||||
uint16_t ret;
|
||||
__asm__ volatile ("inw %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void outw(uint16_t port, uint16_t val) {
|
||||
__asm__ volatile ("outw %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint32_t inl(uint16_t port) {
|
||||
uint32_t ret;
|
||||
__asm__ volatile ("inl %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void outl(uint16_t port, uint32_t val) {
|
||||
__asm__ volatile ("outl %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline void io_wait(void) {
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
static inline void sti(void) {
|
||||
__asm__ volatile ("sti");
|
||||
}
|
||||
|
||||
static inline void cli(void) {
|
||||
__asm__ volatile ("cli");
|
||||
}
|
||||
|
||||
static inline void int_wait(void) {
|
||||
__asm__ volatile ("sti; hlt");
|
||||
}
|
||||
|
||||
static inline void halt(void) {
|
||||
__asm__ volatile ("cli; hlt");
|
||||
}
|
Loading…
Reference in a new issue