From 6e543445fc2d7a4e820d8f58c6a1df9635e2a2be Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 31 Aug 2014 20:39:16 +0200 Subject: Started adding APIC/multiprocessor support. --- kernel/kernel.c | 49 ++++++------------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) (limited to 'kernel/kernel.c') diff --git a/kernel/kernel.c b/kernel/kernel.c index ce22b84..69da50a 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -57,19 +57,6 @@ void int_irq16(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Coprocessor error"); void int_irq17(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Alignment Check"); X86_IRQ_END } void int_irq18(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Machine Check"); X86_IRQ_END } -// enable A20 -// http://www.brokenthorn.com/Resources/OSDev9.html -// Method 3.1: Enables A20 through keyboard controller -/* -void enable_a20() -{ -// Not all keyboard controllers support this - asm("mov $0xdd, %al");// ; command 0xdd: enable a20 -// asm("mov $0xdf, %al");// ; command 0xdd: disable a20 - asm("outb %al, $0x64");// ; send command to controller -} -*/ - /* void test_a20() { @@ -79,10 +66,8 @@ void test_a20() // test=0x8abcd; log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"A20 test: 0x%02X ",*test); - } */ - ////////// KERNEL MAIN///// ///// // this is the very heart of our operating system! void kernel_main(uint32_t initial_stack) @@ -113,7 +98,11 @@ void kernel_main(uint32_t initial_stack) // initial stack 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_"); + // pic log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setup PIC"); pic_setup(); @@ -126,14 +115,13 @@ void kernel_main(uint32_t initial_stack) // paging (pass the vesa physbase address for identity mapping) vmem_init(vesa_physbase); - // - // init and interrupt decriptor table int_init(0x08); + // set default interrupts int_install(); - // setup custom interrupts + // setup some custom interrupts // remember that we shifted all interrupts with the pic by 32 // so clock = 32 (irq 0) // keyboard = 33 (irq 1) @@ -148,7 +136,6 @@ void kernel_main(uint32_t initial_stack) // install floppy interrupt handler int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); - // exceptions int_install_ir(0, 0b10001110, 0x08,&int_irq0); @@ -174,8 +161,6 @@ void kernel_main(uint32_t initial_stack) // now we can enable interrupts back again int_enable(); -// int x=10/0; - // pci pci_init(); @@ -188,28 +173,6 @@ void kernel_main(uint32_t initial_stack) // multitasking task_init(); - /* - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"test mem"); - - // test a20 disabled / wrap - uint8_t *memtest=0x0; - uint8_t *memtest2=0b10000000000000000000; - - *memtest=0xaf; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"test mem %x",*(memtest2-1)); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"test mem %x",*memtest2); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"test mem %x",*(memtest2+1)); - */ - - /* stack pointer test? - uint32_t *esp=0x90000; - for(int i=0;i<10;i++) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"esp: %x",*esp); - esp--; - } - */ while(1) { -- cgit v1.2.3