Mercurial > lcfOS
comparison cos/kernel/kernel.h @ 32:3a6a9b929db0
Added initial ramdisk and some virtual file system functions
author | windel |
---|---|
date | Fri, 13 Jan 2012 18:18:17 +0100 |
parents | 0148f55bfe24 |
children | 8012221dd740 |
comparison
equal
deleted
inserted
replaced
31:88590c42320f | 32:3a6a9b929db0 |
---|---|
32 struct multiboot_aout_symbol_table { | 32 struct multiboot_aout_symbol_table { |
33 uint32_t tabsize; | 33 uint32_t tabsize; |
34 uint32_t strsize, addr, reserved; | 34 uint32_t strsize, addr, reserved; |
35 }; | 35 }; |
36 | 36 |
37 struct multiboot_info { | 37 typedef struct multiboot_info_tag |
38 { | |
38 uint32_t flags; // Multiboot flags / version | 39 uint32_t flags; // Multiboot flags / version |
39 uint32_t mem_lower; // available memory from BIOS | 40 uint32_t mem_lower; // available memory from BIOS |
40 uint32_t mem_upper; | 41 uint32_t mem_upper; |
41 uint32_t boot_device; | 42 uint32_t boot_device; |
42 uint32_t cmdline; // COmmand line | 43 uint32_t cmdline; // COmmand line |
46 struct multiboot_aout_symbol_table aout_sym; | 47 struct multiboot_aout_symbol_table aout_sym; |
47 } u; | 48 } u; |
48 | 49 |
49 uint32_t mmap_length; | 50 uint32_t mmap_length; |
50 uint32_t mmap_addr; | 51 uint32_t mmap_addr; |
51 }; | 52 } multiboot_info_t; |
52 | 53 |
53 struct memory_map { | 54 typedef struct memory_map_tag |
55 { | |
54 uint32_t size; | 56 uint32_t size; |
55 uint32_t baselow, basehigh; | 57 uint64_t base; |
56 uint32_t lenlow, lenhigh; | 58 uint64_t length; |
57 uint32_t type; | 59 uint32_t type; |
58 }; | 60 } __attribute__((packed)) multiboot_memory_map_t; |
61 | |
62 typedef struct | |
63 { | |
64 uint32_t mod_start; | |
65 uint32_t mod_end; | |
66 uint32_t cmdline; | |
67 uint32_t pad; | |
68 } multiboot_module_t; | |
59 | 69 |
60 // Memory manager structures: | 70 // Memory manager structures: |
61 typedef struct | 71 typedef struct |
62 { | 72 { |
63 uint64_t present : 1; | 73 uint64_t present : 1; |
193 char naam[32]; | 203 char naam[32]; |
194 | 204 |
195 console_t *console; | 205 console_t *console; |
196 } task_t; | 206 } task_t; |
197 | 207 |
208 /* Filesystem related types: */ | |
209 struct fs_node_tag; | |
210 struct fs_dirent_tag; | |
211 | |
212 typedef uint64_t (*read_type_t)(struct fs_node_tag*, uint64_t, uint64_t, uint8_t*); | |
213 typedef uint64_t (*write_type_t)(struct fs_node_tag*, uint64_t, uint64_t, uint8_t*); | |
214 typedef void (*open_type_t)(struct fs_node_tag*); | |
215 typedef void (*close_type_t)(struct fs_node_tag*); | |
216 typedef struct fs_dirent_tag* (*readdir_type_t)(struct fs_node_tag*, int); | |
217 | |
218 typedef struct fs_node_tag | |
219 { | |
220 char name[129]; | |
221 uint64_t flags; | |
222 uint64_t length; | |
223 uint64_t inode; | |
224 // Accessor functions: | |
225 read_type_t read; | |
226 write_type_t write; | |
227 open_type_t open; | |
228 close_type_t close; | |
229 readdir_type_t readdir; | |
230 } fs_node_t; | |
231 | |
232 typedef struct fs_dirent_tag | |
233 { | |
234 char name[65]; | |
235 uint64_t inode; | |
236 } fs_dirent_t; | |
237 | |
238 #define FS_FILE 0x1 | |
239 #define FS_DIRECTORY 0x2 | |
240 | |
241 uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); | |
242 uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); | |
243 void open_fs(fs_node_t *node); | |
244 void close_fs(fs_node_t *node); | |
245 fs_dirent_t* readdir_fs(fs_node_t *node, int i); | |
246 | |
247 // Initial ramdisk functions: | |
248 fs_node_t* initialize_initrd(uint64_t location); | |
249 | |
198 // Variable argument list things: | 250 // Variable argument list things: |
199 #define va_start(v,l) __builtin_va_start(v,l) | 251 #define va_start(v,l) __builtin_va_start(v,l) |
200 #define va_end(v) __builtin_va_end(v) | 252 #define va_end(v) __builtin_va_end(v) |
201 #define va_arg(v,l) __builtin_va_arg(v,l) | 253 #define va_arg(v,l) __builtin_va_arg(v,l) |
202 typedef __builtin_va_list va_list; | 254 typedef __builtin_va_list va_list; |
259 void reboot(void); | 311 void reboot(void); |
260 void magicBochsBreak(); | 312 void magicBochsBreak(); |
261 void doCPUID(int eax, int *ebx, int *ecx, int *edx); | 313 void doCPUID(int eax, int *ebx, int *ecx, int *edx); |
262 | 314 |
263 // Keyboard driver: | 315 // Keyboard driver: |
264 void keyboardDriverUpdate(unsigned char scancode); | 316 void keyboardDriverUpdate(void); |
265 void getline(char *buffer, int len); | 317 void getline(char *buffer, int len); |
266 | 318 |
267 // Timer: | 319 // Timer: |
268 void timerDriverUpdate(void); | 320 void timerDriverUpdate(void); |
269 uint64_t getTimeMS(); | 321 uint64_t getTimeMS(); |