diff options
Diffstat (limited to 'kernel/kernel.c')
| -rw-r--r-- | kernel/kernel.c | 77 |
1 files changed, 55 insertions, 22 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c index 373eea1..bf4daac 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,8 +1,9 @@ #define FOOLOS_MODULE_NAME "kernel" -#include "x86.h" -#include "console.h" -#include "../lib/logger/log.h" // logger facilities +#include "lib/logger/log.h" // logger facilities +#include "lib/int/stdint.h" +#include "lib/bool/bool.h" +#include "smp.h" // TODO: WHHYY can i compile it without the includes!??? @@ -11,31 +12,44 @@ // todo: move somewhere else!? void int_clock_handler(); void int_kb_handler(); -void int_floppy_handler(); +//void int_floppy_handler(); uint32_t read_eip(); - +void kernel_ap() +{ + uint32_t cpu_counter=0; + uint32_t ebp; + asm volatile("mov %%ebp,%0":"=r"(ebp)); +// log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial ebp: 0x%08X",ebp); + int proc=ebp-0xffffff; + proc/=-0x400; + while(1)PutString("%d", proc*100,580,0b1111100000000000, (cpu_counter++)); +} // // KERNEL MAIN -// + // this is the very heart of our operating system! // +volatile uint8_t proc; + void kernel_main(uint32_t initial_stack, int mp) { - - // catch the APs (Application Processors) if(mp==1) { - volatile static uint16_t proc=1; + uint32_t ebp=0xffffff-proc*0x400; + proc++; - int p=proc; - uint32_t cpu_counter=0; - while(1)PutString("mp: %d", 200,580,0b1111100000000000, (cpu_counter++)); + asm volatile("mov %0, %%ebp"::"r"(ebp)); + asm volatile("mov %ebp, %esp"); + asm volatile("jmp kernel_ap"); + } + proc=0; + // // We want to get output to the screen as fast as possible! // @@ -56,7 +70,7 @@ void kernel_main(uint32_t initial_stack, int mp) // our video memory // - uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x7200); + uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x7600); // @@ -71,8 +85,31 @@ void kernel_main(uint32_t initial_stack, int mp) // This currently uses the MP Floating Pointer Struct. // Should support APCI in future too. // + + smp_processors procdata1; + smp_processors procdata2; + smp_processors procdata; + - if(!init_mp()) panic(FOOLOS_MODULE_NAME,"Can not Find _MP_"); + // try to find acpi tables + bool succ_acpi=acpi_find(&procdata1); + + // fallback to mp tables + bool succ_mp=mp_find(&procdata2); + + if(!succ_acpi&&!succ_mp) + panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); + + if(succ_acpi)procdata=procdata1; + else procdata=procdata2; + + // multiprocessing! + + smp_log_procdata(&procdata1); + smp_log_procdata(&procdata2); + smp_start_aps(&procdata); + + // // Setup PIC @@ -118,11 +155,12 @@ void kernel_main(uint32_t initial_stack, int mp) int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); // install floppy interrupt handler (irq 6 => 38) - int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); + //int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); // now we can enable interrupts back again int_enable(); + // // Scan the PCI Bus // @@ -148,7 +186,6 @@ void kernel_main(uint32_t initial_stack, int mp) shell_init(); - // // Initialize Multitasking // @@ -156,6 +193,7 @@ void kernel_main(uint32_t initial_stack, int mp) // round robin style. // +// smp_log_procdata(&procdata1); task_init(); @@ -163,12 +201,7 @@ void kernel_main(uint32_t initial_stack, int mp) // Just hang here. // - while(1) - { - static uint32_t cpu1_counter=0; - PutString("cpu1counter: %d", 10,560,0b1111100000000000, (cpu1_counter++)); - cpu1_counter++; - } + while(1) ; } |
