annotate cos/include/kernel.h @ 12:fcdae30b2782

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