From 63167f223e1f54910f6b80e698390ee60aec79ee Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 11 Aug 2020 11:33:21 -0400 Subject: lots of progress currently, BAR fields of IDE drives are all returning zero, and the ATA read function isn't working. i'm not sure why. i'm going to work on VESA next, and come back to the IDE driver later --- src/kernel/util.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'src/kernel/util.h') diff --git a/src/kernel/util.h b/src/kernel/util.h index e02c819..243541c 100644 --- a/src/kernel/util.h +++ b/src/kernel/util.h @@ -1,13 +1,54 @@ +#ifndef UTIL_H +#define UTIL_H + #include +#include "drive.h" + +static inline void outb(uint16_t port, uint8_t value) { + asm ( + "outb %0, %1" + : : "a"(value), "Nd"(port)); +} +static inline uint8_t inb(uint16_t port) { + uint8_t value; + asm volatile ( + "inb %1, %0" + : "=a"(value) : "Nd"(port)); + return value; +} +static inline void outw(uint16_t port, uint16_t value) { + asm ( + "outw %0, %1" + : : "a"(value), "Nd"(port)); +} +static inline uint16_t inw(uint16_t port) { + uint16_t value; + asm volatile ( + "inw %1, %0" + : "=a"(value) : "Nd"(port)); + return value; +} +static inline void outd(uint16_t port, uint32_t value) { + asm ( + "outl %0, %1" + : : "a"(value), "Nd"(port)); +} +static inline uint32_t ind(uint16_t port) { + uint32_t value; + asm volatile ( + "inl %1, %0" + : "=a"(value) : "Nd"(port)); + return value; +} void memcpy(void *to, void *from, uint32_t n); -void outb(uint16_t port, uint8_t value); -uint8_t inb(uint16_t port); -void outw(uint16_t port, uint16_t value); -uint16_t inw(uint16_t port); -void u32_dec(uint32_t n, uint8_t *b); -void u16_dec(uint16_t n, uint8_t *b); -void u8_dec(uint8_t n, uint8_t *b); -void u32_hex(uint32_t n, uint8_t *b); -void u16_hex(uint16_t n, uint8_t *b); -void u8_hex(uint8_t n, uint8_t *b); \ No newline at end of file +void fmcpy(void *to, struct drive *d, drive_file_id_t f, uint32_t from, uint32_t n); + +void u32_dec(uint32_t n, char *b); +void u16_dec(uint16_t n, char *b); +void u8_dec(uint8_t n, char *b); +void u32_hex(uint32_t n, char *b); +void u16_hex(uint16_t n, char *b); +void u8_hex(uint8_t n, char *b); + +#endif \ No newline at end of file -- cgit v1.2.3