Mercurial > lcfOS
diff cos/kernel/kernel.h @ 17:f3e3e0e9c4bc
First attempt IDT loader 64 bits. INT13 occurs
author | windel |
---|---|
date | Sat, 19 Nov 2011 20:01:28 +0100 |
parents | a58904747019 |
children | b1fed2171e1a |
line wrap: on
line diff
--- a/cos/kernel/kernel.h Fri Nov 18 14:41:53 2011 +0100 +++ b/cos/kernel/kernel.h Sat Nov 19 20:01:28 2011 +0100 @@ -5,45 +5,60 @@ #define NULL ((void*)0) // Type defs: +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned short ushort_t; -typedef unsigned char uchar_t; -typedef unsigned int uint_t; -typedef unsigned long ulong_t; -typedef unsigned long long ulonglong_t; -typedef unsigned long off_t; -typedef unsigned long size_t; +typedef unsigned long int uint64_t; +// IDT related structures: +typedef struct { + uint16_t baseLow; + uint16_t selector; + uint8_t reserved1; + uint8_t flags; + uint16_t baseMid; + uint32_t baseHigh; + uint32_t reserved2; +} __attribute__((packed)) IDT_entry; + +typedef struct { + uint16_t limit; + uint64_t base; +} __attribute__((packed)) idtPointer; + +// memory alloc functions: +void* malloc(uint64_t size); +void free(void* ptr); + +// STDout funcs: void printf(const char* fmt, ... ); void memset(void* ptr, uint32_t value, uint32_t num); void memcpy(void* dst, void* src, uint32_t num); -struct IDT_entry { - unsigned char b[8]; -}; - -// memory alloc functions: -void* malloc(size_t size); -void free(void* ptr); - +// Screen related: void clear_screen(); void init_screen(); void print_string(const char *); // For IO ports: -unsigned char inb(unsigned short); -void outb(unsigned short, unsigned char); +uint8_t inb(uint16_t); +uint16_t inw(uint16_t); +void outb(uint16_t, uint8_t); + +// Interrupt functions: +void setupIDT(void); +void PICremap(void); // ASM helper: -int loadIDT(struct IDT_entry *table, unsigned short size); +void loadIDT(void); + +// Panic exit: void halt(void); -void setupIDT(void); -void PICremap(void); +// Bochs xchg bx,bx breakpoint: +void magicBochsBreak(); + // Assembler util functions: -void enableinterrupts(void); -void callint49(void); void doCPUID(int eax, int *ebx, int *ecx, int *edx); // Keyboard driver: @@ -51,7 +66,7 @@ void timerDriverUpdate(void); // Memory functions: -void mappage(uint32_t address); +void mappage(uint64_t address); int querymode(void); int getcs(void);