Mercurial > lcfOS
comparison cos/kernel/kernel.c @ 17:f3e3e0e9c4bc
First attempt IDT loader 64 bits. INT13 occurs
author | windel |
---|---|
date | Sat, 19 Nov 2011 20:01:28 +0100 |
parents | a58904747019 |
children | 6129643f5c34 |
comparison
equal
deleted
inserted
replaced
16:ddefe6d97cd7 | 17:f3e3e0e9c4bc |
---|---|
1 #include "kernel.h" | 1 #include "kernel.h" |
2 | 2 |
3 static int shiftstate = 0; | 3 static int shiftstate = 0; |
4 static volatile unsigned char charAvail = 0; | 4 static volatile uint8_t charAvail = 0; |
5 static volatile char kbdchar = ' '; | 5 static volatile char kbdchar = ' '; |
6 | 6 |
7 static char keymap[128] = { | 7 static char keymap[128] = { |
8 '?','?','1','2', '3', '4', '5','6', '7', '8','9', '0', '-','=', 0xe, '?', | 8 '?','?','1','2', '3', '4', '5','6', '7', '8','9', '0', '-','=', 0xe, '?', |
9 'q','w','e','r', 't', 'y', 'u','i', 'o', 'p','[', ']', '\n','?', 'a', 's', | 9 'q','w','e','r', 't', 'y', 'u','i', 'o', 'p','[', ']', '\n','?', 'a', 's', |
25 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', | 25 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', |
26 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', | 26 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', |
27 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', | 27 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?', |
28 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?' | 28 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?' |
29 }; | 29 }; |
30 | |
31 // IO port helpers: | |
32 void outb(uint16_t port, uint8_t value) | |
33 { | |
34 asm volatile ("outb %1, %0" : : "dN" (port), "a" (value)); | |
35 } | |
36 | |
37 uint8_t inb(uint16_t port) | |
38 { | |
39 uint8_t ret; | |
40 asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port)); | |
41 return ret; | |
42 } | |
43 | |
44 uint16_t inw(uint16_t port) | |
45 { | |
46 uint16_t ret; | |
47 asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port)); | |
48 return ret; | |
49 } | |
50 | |
30 | 51 |
31 static uint64_t ticks = 0; | 52 static uint64_t ticks = 0; |
32 void timerDriverUpdate() | 53 void timerDriverUpdate() |
33 { | 54 { |
34 ticks++; | 55 ticks++; |
112 */ | 133 */ |
113 static void* kernel_heap = (void*) 0xD0000000; | 134 static void* kernel_heap = (void*) 0xD0000000; |
114 /* Allocates 'size' bytes and returns the pointer if succesfull. | 135 /* Allocates 'size' bytes and returns the pointer if succesfull. |
115 Kernelpanic in case of failure.. | 136 Kernelpanic in case of failure.. |
116 */ | 137 */ |
117 void* malloc(size_t size) { | 138 void* malloc(uint64_t size) { |
118 printf("Malloc %d bytes\n", size); | 139 printf("Malloc %d bytes\n", size); |
119 return kernel_heap; | 140 return kernel_heap; |
120 } | 141 } |
121 | 142 |
122 void free(void* ptr) { | 143 void free(void* ptr) { |
125 | 146 |
126 void kmain() | 147 void kmain() |
127 { | 148 { |
128 init_screen(); | 149 init_screen(); |
129 clear_screen(); | 150 clear_screen(); |
130 printf("Welcome!\n"); | 151 printf("Welcome! .. "); |
131 printf("sizeof(uint32_t)=%u, sizeof(uint64_t)=%u\n", sizeof(uint32_t), sizeof(uint64_t)); | |
132 | 152 |
133 printf("Enabling interrupts\n"); | 153 printf("Enabling interrupts .. "); |
134 setupIDT(); | 154 setupIDT(); |
135 printf("Entering mainloop!\n"); | 155 printf("Entering mainloop!\n"); |
136 | 156 |
137 while (1==1) | 157 while (1==1) |
138 { | 158 { |