summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kernel.c115
-rw-r--r--kernel/mp.c4
-rw-r--r--kernel/xxx.c15
3 files changed, 97 insertions, 37 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 35a1321..5a32c95 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -2,6 +2,7 @@
#include "x86.h"
#include "../lib/logger/log.h" // logger facilities
+
// TODO: WHHYY can i compile it without the includes!???
///////
@@ -13,19 +14,13 @@ void int_floppy_handler();
uint32_t read_eip();
-/*
-void test_a20()
-{
- uint16_t *test=0x7dfe;
- test+=1024*1024;
-// *test=0x69;
-// test=0x8abcd;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"A20 test: 0x%02X ",*test);
-}
-*/
-////////// KERNEL MAIN///// /////
+//
+// KERNEL MAIN
+//
// this is the very heart of our operating system!
+//
+
void kernel_main(uint32_t initial_stack)
{
@@ -51,26 +46,55 @@ void kernel_main(uint32_t initial_stack)
uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x7200);
- // initial stack
+
+ //
+ // Print initial address of the esp stack pointer
+ //
+
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial esp: 0x%08X",initial_stack);
- // multiprocessing / apic stuff
- if(!find_mp())
- panic(FOOLOS_MODULE_NAME,"Can not Find _MP_");
+ //
+ // Initialize other processors
+ //
+ // This currently uses the MP Floating Pointer Struct.
+ // Should support APCI in future too.
+ //
+
+ if(!init_mp()) panic(FOOLOS_MODULE_NAME,"Can not Find _MP_");
+
- // pic
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setup PIC");
+ //
+ // Setup PIC
+ //
+ // Do we nee this when using APIC?
+ //
+
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC.");
pic_setup();
- // PIT config (timer)
+
+ //
+ // Configuring the PIT timer.
+ //
+
timer_init();
+
+ //
+ // Memory Init
+ //
+
// we know that here, the bootloader placed the mamory map!
mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600)));
// paging (pass the vesa physbase address for identity mapping)
vmem_init(vesa_physbase);
+
+ //
+ // Interrupts
+ //
+
// init and interrupt decriptor table
int_init(0x08);
@@ -79,40 +103,61 @@ void kernel_main(uint32_t initial_stack)
// setup some custom interrupts
// remember that we shifted all interrupts with the pic by 32
- // so clock = 32 (irq 0)
- // keyboard = 33 (irq 1)
- // floppy = 38 (irq 6)
- // etc..
- // install PIT interrupt handler
+ // install PIT interrupt handler (irq 0 => 32)
int_install_ir(32, 0b10001110, 0x08,&int_clock_handler);
- // install keyboard interrupt handler
+ // install keyboard interrupt handler (irq 1 => 33)
int_install_ir(33, 0b10001110, 0x08,&int_kb_handler);
- // install floppy interrupt handler
+ // install floppy interrupt handler (irq 6 => 38)
int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler);
-
// now we can enable interrupts back again
int_enable();
- // pci
+
+ //
+ // Scan the PCI Bus
+ //
+ // We are interested in the E1000 Network Adapter in particular
+ // Its driver will be hopefully implemented one day ;)
+ //
+
pci_init();
- // floppy
- // floppy_init();
+ //
+ // Initialize Floppy Disk
+ //
+
+ floppy_init();
+
- //init shell
+ //
+ // "Shell"
+ //
+ // Will process input from the keyboard but will be completely
+ // redesigned soon.
+ //
+
shell_init();
- // multitasking
+
+ //
+ // Initialize Multitasking
+ //
+ // For now this starts two tasks which are scheduled
+ // round robin style.
+ //
+
task_init();
- while(1)
- {
-
- }
+
+ //
+ // Just hang here.
+ //
+
+ while(1);
}
diff --git a/kernel/mp.c b/kernel/mp.c
index fc6288c..d0b247d 100644
--- a/kernel/mp.c
+++ b/kernel/mp.c
@@ -104,7 +104,7 @@ void show_mp_conf(mp_config *addr)
processors=0;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mp_config tabel addr: %08X",addr);
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mp_config table addr: %08X",addr);
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mp_config signature: %s",buf);
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mp_config version: %02X",addr->version);
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mp_config # of entries: %d",addr->entries);
@@ -181,7 +181,7 @@ bool check_mp(uint8_t *addr)
// todo: check checksum,version etc. and narrow down search
-bool find_mp()
+bool init_mp()
{
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Looking for Mp Floating Ponter Struct...");
diff --git a/kernel/xxx.c b/kernel/xxx.c
new file mode 100644
index 0000000..19ddb4c
--- /dev/null
+++ b/kernel/xxx.c
@@ -0,0 +1,15 @@
+
+// some code snipplets I might use someday
+
+/*
+void test_a20()
+{
+ uint16_t *test=0x7dfe;
+ test+=1024*1024;
+// *test=0x69;
+// test=0x8abcd;
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"A20 test: 0x%02X ",*test);
+
+}
+
+*/