From 9c8cfc2e52b0446f7cab14325028075760869b45 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 26 Nov 2014 17:42:33 +0100 Subject: further cleanup --- kernel/kernel.c | 27 ++++++++------------------- kernel/keyboard.c | 12 +++--------- kernel/keyboard.h | 1 - kernel/mem.c | 41 +++++++++++++++++++++++++++-------------- kernel/mem.h | 2 +- kernel/spinlock.c | 20 ++++++++++---------- kernel/spinlock.h | 9 ++++++--- kernel/timer.c | 4 +--- kernel/timer.h | 2 +- 9 files changed, 57 insertions(+), 61 deletions(-) (limited to 'kernel') diff --git a/kernel/kernel.c b/kernel/kernel.c index 0c14e56..ecb42eb 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -29,7 +29,6 @@ #include #include - // CODE FOR Stack Smashing Protector, TODO: MOVE / and do not duplicate // with sys.c // http://wiki.osdev.org/Stack_Smashing_Protector @@ -47,10 +46,16 @@ void __stack_chk_fail(void) { panic(FOOLOS_MODULE_NAME,"Stack smashing detected"); } +// // mp informs us if this if this is the main processor void kernel_main(uint32_t initial_stack, int mp) { + // + // Configuring the PIT timer. + // + timer_init(); + // // Memory Init // @@ -62,11 +67,6 @@ void kernel_main(uint32_t initial_stack, int mp) // mem_init(0xa001,*((uint16_t *)(0xa000))); - // - // Configuring the PIT timer. - // - timer_init(); - // // Activate Virtual Memory (paging) // @@ -84,19 +84,14 @@ void kernel_main(uint32_t initial_stack, int mp) // // Setup PIC (interrupts) - // + // TODO: log! pic_setup(); - - // mouse and kb driver init (before interrupts) - // mouse_init(); - keyboard_init(); - - // // Setup Interrupts (code segment: 0x08) // int_init(0x08); + // // Gather Info about other processors. (APs) @@ -112,12 +107,6 @@ void kernel_main(uint32_t initial_stack, int mp) panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); */ - // init spinlocks - init_spinlocks(); - - - // ringbuffer for stdin! - ringbuffer_init(); // load and run foolshell // we will come back into the kernel only on interrupts... diff --git a/kernel/keyboard.c b/kernel/keyboard.c index 074c495..32f28f0 100644 --- a/kernel/keyboard.c +++ b/kernel/keyboard.c @@ -11,15 +11,9 @@ /// keyboard driver //// // http://www.computer-engineering.org/ps2keyboard/scancodes1.html -static bool shift_l; -static bool shift_r; -static bool capslock; - -void keyboard_init() -{ - shift_l=shift_r=capslock=false; //!! -} - +static bool shift_l=false; +static bool shift_r=false; +static bool capslock=false; void keyboard_handle(uint8_t in) { diff --git a/kernel/keyboard.h b/kernel/keyboard.h index 0b3bf28..8b13789 100644 --- a/kernel/keyboard.h +++ b/kernel/keyboard.h @@ -1,2 +1 @@ -void keyboard_init(); diff --git a/kernel/mem.c b/kernel/mem.c index b2ab6ad..cf0c673 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -1,7 +1,8 @@ #define FOOLOS_MODULE_NAME "mem" +#include + #include "config.h" -#include "lib/int/stdint.h" #include "lib/logger/log.h" // logger facilities //! 8 blocks per byte @@ -13,12 +14,20 @@ //! block alignment ??? TODO: what is this!? #define PMMNGR_BLOCK_ALIGN PMMNGR_BLOCK_SIZE + //memory map bit array. Each bit represents a 4KB memory block static uint32_t *_mmngr_memory_map; - static uint32_t mem_free_blocks; static uint32_t mem_array_size; +char *memmap_type_to_string[]= + { + "Usable", + "Reserved", + "ACPI reclaimable", + "ACPI NVS", + "Bad Memory" + }; // bit funcs! void mmap_set(int bit) { @@ -34,10 +43,13 @@ int mmap_test(int bit) { return _mmngr_memory_map[bit / 32] & (1 << (bit % 32)); } +// +// By default, Set all of memory is in use void pmmngr_init () { - // By default, all of memory is in use + mem_free_blocks=0; + for(int i=0;i + +typedef uint8_t spinlock; + +volatile void lock_spin(spinlock); +void lock_release(spinlock); #endif diff --git a/kernel/timer.c b/kernel/timer.c index 956195b..676be48 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -33,11 +33,9 @@ #define FOOLOS_MODULE_NAME "timer" #include "timer.h" -#include "x86.h" -#include "../lib/logger/log.h" // logger facilities +#include "lib/logger/log.h" // logger facilities -//static volatile static uint64_t task_system_clock=0; void timer_init() diff --git a/kernel/timer.h b/kernel/timer.h index 3b9ecdf..57ea21e 100644 --- a/kernel/timer.h +++ b/kernel/timer.h @@ -1,4 +1,4 @@ -#include "lib/int/stdint.h" +#include void timer_init(); void timer_tick(); -- cgit v1.2.3