Mercurial > lcfOS
comparison cos/kernel/kernel.h @ 16:ddefe6d97cd7
Merged
author | windel-eee |
---|---|
date | Fri, 18 Nov 2011 14:41:53 +0100 |
parents | a58904747019 |
children | f3e3e0e9c4bc |
comparison
equal
deleted
inserted
replaced
15:de004f808e56 | 16:ddefe6d97cd7 |
---|---|
1 #ifndef KERNEL_H | |
2 #define KERNEL_H | |
3 | |
4 // Include common functions, available to all! | |
5 #define NULL ((void*)0) | |
6 | |
7 // Type defs: | |
8 typedef unsigned int uint32_t; | |
9 typedef unsigned long long uint64_t; | |
10 typedef unsigned short ushort_t; | |
11 typedef unsigned char uchar_t; | |
12 typedef unsigned int uint_t; | |
13 typedef unsigned long ulong_t; | |
14 typedef unsigned long long ulonglong_t; | |
15 typedef unsigned long off_t; | |
16 typedef unsigned long size_t; | |
17 | |
18 void printf(const char* fmt, ... ); | |
19 void memset(void* ptr, uint32_t value, uint32_t num); | |
20 void memcpy(void* dst, void* src, uint32_t num); | |
21 | |
22 struct IDT_entry { | |
23 unsigned char b[8]; | |
24 }; | |
25 | |
26 // memory alloc functions: | |
27 void* malloc(size_t size); | |
28 void free(void* ptr); | |
29 | |
30 void clear_screen(); | |
31 void init_screen(); | |
32 void print_string(const char *); | |
33 | |
34 // For IO ports: | |
35 unsigned char inb(unsigned short); | |
36 void outb(unsigned short, unsigned char); | |
37 | |
38 // ASM helper: | |
39 int loadIDT(struct IDT_entry *table, unsigned short size); | |
40 void halt(void); | |
41 | |
42 void setupIDT(void); | |
43 void PICremap(void); | |
44 // Assembler util functions: | |
45 void enableinterrupts(void); | |
46 void callint49(void); | |
47 void doCPUID(int eax, int *ebx, int *ecx, int *edx); | |
48 | |
49 // Keyboard driver: | |
50 void keyboardDriverUpdate(unsigned char scancode); | |
51 void timerDriverUpdate(void); | |
52 | |
53 // Memory functions: | |
54 void mappage(uint32_t address); | |
55 | |
56 int querymode(void); | |
57 int getcs(void); | |
58 void loadPageTable(void* tableAddress); | |
59 void enablePaging(void); | |
60 | |
61 // Variable argument list things: | |
62 #define va_start(v,l) __builtin_va_start(v,l) | |
63 #define va_end(v) __builtin_va_end(v) | |
64 #define va_arg(v,l) __builtin_va_arg(v,l) | |
65 typedef __builtin_va_list va_list; | |
66 | |
67 struct multiboot_aout_symbol_table { | |
68 uint32_t tabsize; | |
69 uint32_t strsize, addr, reserved; | |
70 }; | |
71 | |
72 struct multiboot_info { | |
73 uint32_t flags; // Multiboot flags / version | |
74 uint32_t mem_lower; // available memory from BIOS | |
75 uint32_t mem_upper; | |
76 uint32_t boot_device; | |
77 uint32_t cmdline; // COmmand line | |
78 uint32_t mods_count; | |
79 uint32_t mods_addr; | |
80 union { | |
81 struct multiboot_aout_symbol_table aout_sym; | |
82 } u; | |
83 | |
84 uint32_t mmap_length; | |
85 uint32_t mmap_addr; | |
86 }; | |
87 | |
88 struct memory_map { | |
89 uint32_t size; | |
90 uint32_t baselow, basehigh; | |
91 uint32_t lenlow, lenhigh; | |
92 uint32_t type; | |
93 }; | |
94 | |
95 typedef struct { | |
96 char name[32]; // Name of the console | |
97 unsigned char screendata[80*25]; // All chars in the console! | |
98 } console_t; | |
99 | |
100 typedef struct { | |
101 uint32_t esp; | |
102 uint32_t ss; | |
103 uint32_t kstack; | |
104 uint32_t ustack; | |
105 uint32_t cr3; | |
106 | |
107 uint32_t number; | |
108 uint32_t parent; | |
109 uint32_t owner; | |
110 uint32_t groups; | |
111 uint32_t timetorun; | |
112 uint32_t sleep; | |
113 uint32_t priority; | |
114 uint32_t filehandle; | |
115 char naam[32]; | |
116 | |
117 console_t *console; | |
118 } programma_t; | |
119 | |
120 #endif | |
121 |