Mercurial > lcfOS
view cos/kernel/kernel.h @ 26:dcce92b1efbc
Added mm.c
author | windel |
---|---|
date | Tue, 27 Dec 2011 17:36:52 +0100 |
parents | d3c4bf3720a3 |
children | 47b7df514243 |
line wrap: on
line source
#ifndef KERNEL_H #define KERNEL_H // Include common functions, available to all! #define NULL ((void*)0) // Type defs: typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_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 init_heap(); void* kmalloc(uint64_t size); void kfree(void* ptr); // task related functions: void initialize_tasking(); void new_task(); void task_scheduler(); // 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); int strncmp(const char* s1, const char* s2, int size); // Screen related: void clear_screen(); void init_screen(); void print_string(const char *); void set_cursor(int newrow, int newcol); void get_cursor(int *therow, int *thecol); void set_color(int forecolor, int backcolor); // For IO ports: 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: void loadIDT(void); uint64_t read_rip(); // Panic exit: void halt(void); void panic(char *msg); void reboot(void); // Bochs xchg bx,bx breakpoint: void magicBochsBreak(); // Assembler util functions: void doCPUID(int eax, int *ebx, int *ecx, int *edx); // Keyboard driver: void keyboardDriverUpdate(unsigned char scancode); void getline(char *buffer, int len); // Timer: void timerDriverUpdate(void); uint64_t getTimeMS(); // Memory functions: void mappage(uint64_t address); void loadPageTable(void* tableAddress); // Variable argument list things: #define va_start(v,l) __builtin_va_start(v,l) #define va_end(v) __builtin_va_end(v) #define va_arg(v,l) __builtin_va_arg(v,l) typedef __builtin_va_list va_list; // Multiboot structs: struct multiboot_aout_symbol_table { uint32_t tabsize; uint32_t strsize, addr, reserved; }; struct multiboot_info { uint32_t flags; // Multiboot flags / version uint32_t mem_lower; // available memory from BIOS uint32_t mem_upper; uint32_t boot_device; uint32_t cmdline; // COmmand line uint32_t mods_count; uint32_t mods_addr; union { struct multiboot_aout_symbol_table aout_sym; } u; uint32_t mmap_length; uint32_t mmap_addr; }; struct memory_map { uint32_t size; uint32_t baselow, basehigh; uint32_t lenlow, lenhigh; uint32_t type; }; typedef struct { char name[32]; // Name of the console unsigned char screendata[80*25]; // All chars in the console! } console_t; typedef struct task_t { struct task_t* next; uint32_t kstack; uint32_t ustack; uint64_t cr3; uint64_t rip; uint64_t rsp; uint64_t rbp; uint32_t pid; uint32_t parent; uint32_t owner; uint32_t groups; uint32_t timetorun; uint32_t sleep; uint32_t priority; uint32_t filehandle; char naam[32]; console_t *console; } task_t; #endif