Decouple I/O from HAL
This commit is contained in:
@ -17,7 +17,6 @@ int32_t hal_randnum(void);
|
||||
#include "x86_64/switch.h"
|
||||
#include "x86_64/paging.h"
|
||||
#include "x86_64/intr.h"
|
||||
#include "x86_64/io.h"
|
||||
#include "x86_64/gdt.h"
|
||||
|
||||
#endif // KERNEL_HAL_HAL_H_
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "intr.h"
|
||||
#include "io.h"
|
||||
#include "io/io.h"
|
||||
#include "gdt.h"
|
||||
#include "hal/hal.h"
|
||||
#include "kprintf.h"
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t io_in8(uint16_t port) {
|
||||
uint8_t r;
|
||||
asm volatile("inb %1, %0" : "=a"(r) : "dN"(port));
|
||||
return r;
|
||||
}
|
||||
void io_out8(uint16_t port, uint8_t value) {
|
||||
asm volatile("outb %1, %0" :: "dN"(port), "a"(value));
|
||||
}
|
||||
|
||||
uint16_t io_in16(uint16_t port) {
|
||||
uint16_t r;
|
||||
asm volatile("in %%dx, %%ax" : "=a"(r) : "d"(port));
|
||||
return r;
|
||||
}
|
||||
void io_out16(uint16_t port, uint16_t value) {
|
||||
asm volatile("out %%ax, %%dx" :: "a"(value), "d"(port));
|
||||
}
|
||||
|
||||
uint32_t io_in32(uint16_t port) {
|
||||
uint32_t r;
|
||||
asm volatile("inl %%dx, %%eax" : "=a"(r) : "d"(port));
|
||||
return r;
|
||||
}
|
||||
void io_out32(uint16_t port, uint32_t value) {
|
||||
asm volatile("outl %%eax, %%dx" :: "d"(port), "a"(value));
|
||||
}
|
||||
|
||||
void io_ins16(uint16_t port, void *addr, int cnt) {
|
||||
asm volatile(
|
||||
"cld; rep insw"
|
||||
: "+D"(addr), "+c"(cnt)
|
||||
: "d"(port)
|
||||
: "memory", "cc"
|
||||
);
|
||||
}
|
||||
|
||||
void io_outs16(uint16_t port, const void *addr, int cnt) {
|
||||
asm volatile(
|
||||
"cld; rep outsw"
|
||||
: "+S"(addr), "+c"(cnt)
|
||||
: "d"(port)
|
||||
: "memory", "cc"
|
||||
);
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
#ifndef HAL_IO_H_
|
||||
#define HAL_IO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t io_in8(uint16_t port);
|
||||
void io_out8(uint16_t port, uint8_t value);
|
||||
|
||||
uint16_t io_in16(uint16_t port);
|
||||
void io_out16(uint16_t port, uint16_t value);
|
||||
|
||||
uint32_t io_in32(uint16_t port);
|
||||
void io_out32(uint16_t port, uint32_t value);
|
||||
|
||||
void io_ins16(uint16_t port, void *addr, int cnt);
|
||||
void io_outs16(uint16_t port, const void *addr, int cnt);
|
||||
|
||||
#endif // HAL_IO_H_
|
||||
@ -1,7 +1,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "pic.h"
|
||||
#include "io.h"
|
||||
#include "io/io.h"
|
||||
#include "intr.h"
|
||||
|
||||
void pic_init(void) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include "pit.h"
|
||||
#include "io.h"
|
||||
#include "io/io.h"
|
||||
|
||||
#define PIT_COUNTER0 0x40
|
||||
#define PIT_CMD 0x43
|
||||
|
||||
Reference in New Issue
Block a user