summaryrefslogtreecommitdiff
path: root/kernel/kernel.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-09-04 15:16:13 +0200
committerMichal Idziorek <m.i@gmx.at>2014-09-04 15:16:13 +0200
commit06e382afcbf199e5e4ec92574a3872ab04fb6e9e (patch)
tree08bb57d147d31cd4eefc26567849b1c6a2dbbe7f /kernel/kernel.c
parent706d8edc5abf15960ff8bebf9a2a6dc76b23eeac (diff)
Improved physical memory manager and cleaning up.
Diffstat (limited to 'kernel/kernel.c')
-rw-r--r--kernel/kernel.c105
1 files changed, 29 insertions, 76 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 0b87b64..1688017 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -11,18 +11,10 @@
#include "floppy.h"
#endif
-///////
-// interrupt handler prototypes
-// todo: move somewhere else!?
-void int_clock_handler();
-void int_kb_handler();
-
-uint32_t read_eip();
+// some multiprocessor shit that should move away
uint32_t c1,c2,c3;
-
volatile uint8_t proc;
-
uint32_t cpu_counter[SMP_MAX_PROC];
void kernel_ap()
@@ -31,6 +23,7 @@ void kernel_ap()
uint8_t p=proc;
while(1)cpu_counter[p]++;
}
+
//
// KERNEL MAIN
@@ -52,29 +45,18 @@ void kernel_main(uint32_t initial_stack, int mp)
proc=c1=c2=c3=0;
for(int i=0;i<SMP_MAX_PROC;i++)cpu_counter[i]=0;
+
+/////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP
+ //
+ // system time
+ //
task_system_clock=0;
-
- // move the foolfont and aps code before it gets overwritten!
- uint8_t *source=0x16600;
- uint8_t *dest=0x80000;
-
- for(int i=0;i<2*512;i++)
- {
- dest[i]=source[i];
- }
-
- source=0x16400;
- dest=0x9000;
- for(int i=0;i<1*512;i++)
- {
- dest[i]=source[i];
- }
-
-
- /////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP
-
+ //
+ // init system log ringbugger
+ //
+ log_init();
//
// We want to get output to the screen as fast as possible!
@@ -86,7 +68,7 @@ void kernel_main(uint32_t initial_stack, int mp)
//
// * the addresses of the vbeinfo struct
// * the address of the vbemodeinfo struct (for selected mode).
- // * the address of our Fool-Font binary data.
+ // * Fool Font loaded inside ramimage
//
// The first two paramters are hardcoded in [boot/mbr.asm],
// while the last one is set in the Makefile. The font binary
@@ -96,26 +78,20 @@ void kernel_main(uint32_t initial_stack, int mp)
// our video memory
//
- //uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x7600);
- uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x80000);
-
+ uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x90000);
- char *ramdisk=0x80400;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"ramdisk: %s",ramdisk);
+ // self-log message of logger :P
+ log_log();
//
// Print initial address of the esp stack pointer
//
-
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial esp: 0x%08X",initial_stack);
//
// Setup PIC
//
- // Do we nee this when using APIC?
- //
-
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC.");
pic_setup();
@@ -123,42 +99,23 @@ void kernel_main(uint32_t initial_stack, int mp)
//
// Configuring the PIT timer.
//
-
timer_init();
-
//
- // Interrupts
+ // Setup Interrupts (code segment: 0x08)
//
-
- // init and interrupt decriptor table
int_init(0x08);
- // set default interrupts
- int_install();
-
- // setup some custom interrupts
- // remember that we shifted all interrupts with the pic by 32
-
- // install PIT interrupt handler (irq 0 => 32)
- int_install_ir(32, 0b10001110, 0x08,&int_clock_handler);
-
- // install keyboard interrupt handler (irq 1 => 33)
- int_install_ir(33, 0b10001110, 0x08,&int_kb_handler);
-
-#ifdef FOOLOS_COMPILE_FLOPPY
- // install floppy interrupt handler (irq 6 => 38)
- int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler);
-#endif
-
- // now we can enable interrupts back again
- x86_int_enable();
//
// Memory Init
//
+ // after this is set up we can allocate and deallocate blocks
+ // of physical memory :)
+ //
- // we know that here, the bootloader placed the mamory map!
+ // we know that here, the bootloader placed the mamory map and
+ // number of entries.
mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600)));
@@ -174,13 +131,13 @@ void kernel_main(uint32_t initial_stack, int mp)
panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!");
// Start the other Processors (also before paging !)
- smp_start_aps(&procdata);
+ //smp_start_aps(&procdata);
/////////////////////
// paging (pass the vesa physbase address for identity mapping)
- //vmem_init(vesa_physbase);
+ // vmem_init(vesa_physbase);
//////////////////////
@@ -190,17 +147,15 @@ void kernel_main(uint32_t initial_stack, int mp)
// We are interested in the E1000 Network Adapter in particular
// Its driver will be hopefully implemented one day ;)
//
-
- pci_init();
+ // pci_init();
//
- // Initialize Floppy Disk
- //
-
- #ifdef FOOLOS_COMPILE_FLOPPY
- floppy_init();
- #endif
+ // Initialize Floppy Disk if activated in config.h
+ //
+ //#ifdef FOOLOS_COMPILE_FLOPPY
+ //floppy_init();
+ //#endif
//
@@ -209,7 +164,6 @@ void kernel_main(uint32_t initial_stack, int mp)
// Will process input from the keyboard but will be completely
// redesigned soon.
//
-
shell_init();
@@ -219,7 +173,6 @@ void kernel_main(uint32_t initial_stack, int mp)
// For now this starts two tasks which are scheduled
// round robin style.
//
-
task_init();