summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/config.h3
-rw-r--r--kernel/kernel.c31
-rw-r--r--kernel/mem.c11
-rw-r--r--kernel/task.c27
-rw-r--r--kernel/task.h1
5 files changed, 41 insertions, 32 deletions
diff --git a/kernel/config.h b/kernel/config.h
index 39b7b90..14a6eee 100644
--- a/kernel/config.h
+++ b/kernel/config.h
@@ -5,7 +5,8 @@
********************************************/
//#define FOOLOS_COMPILE_FLOPPY // compile floppy drivers
-//#define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line
+#define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line
//#define FOOLOS_LOG_OFF // do not log anything
#define FOOLOS_CONSOLE // otherwise VESA will be used!
+#define MEM_PRINT_MEMORYMAP
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 6cc4500..5628e84 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -22,6 +22,8 @@
#include "fs/fs.h"
#include "fs/ext2.h"
+#include "task.h"
+
#ifdef FOOLOS_COMPILE_FLOPPY
#include "floppy.h"
@@ -77,6 +79,11 @@ void kernel_main(uint32_t initial_stack, int mp)
/////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP
+ //
+ // init system log ringbugger
+ //
+ log_init();
+
//
// The System Time
//
@@ -94,16 +101,11 @@ void kernel_main(uint32_t initial_stack, int mp)
mem_init(0x7c00+1,*((uint16_t *)(0x7c00)));
//
- // init system log ringbugger
- //
- log_init();
-
- //
// init output to screen
//
console_init();
- // self-log message of logger :P
+ // log buffered messages to console
log_log();
//
@@ -135,11 +137,15 @@ void kernel_main(uint32_t initial_stack, int mp)
// Gather Info about other processors. (APs)
// ACPI or MP
//
+ //
+
+ /*
smp_processors procdata;
if(!acpi_find(&procdata))
if(!mp_find(&procdata))
panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!");
+ */
// init spinlocks
init_spinlocks();
@@ -153,14 +159,14 @@ void kernel_main(uint32_t initial_stack, int mp)
//smp_log_procdata(&procdata);
//smp_start_aps(&procdata,0x80000); // starts at 0x80000
// but it will be copied over mbr
-
+
//
// Activate Virtual Memory (paging)
//
// paging (pass the vesa physbase address for identity mapping)
// TODO: we will work on this later (not needed so urgently yet)
//
- // vmem_init(vesa_physbase);
+ //vmem_init(vesa_physbase);
//
// Scan the PCI Bus
@@ -184,20 +190,15 @@ void kernel_main(uint32_t initial_stack, int mp)
// For now this starts three "tasks" which are scheduled
// round robin style.
//
- //task_init();
+ task_init();
//
//vesa_init_doublebuff();
- ext2_check(EXT2_RAM_ADDRESS);
- syscall_execve(15,0,0);
// Just hang around here, if its reached.
// we do our tasks anyway. on the next clock tick.
- while(1)
- {
-
- }
+ while(1);
}
diff --git a/kernel/mem.c b/kernel/mem.c
index 00b6a90..d89ecc7 100644
--- a/kernel/mem.c
+++ b/kernel/mem.c
@@ -1,22 +1,21 @@
#define FOOLOS_MODULE_NAME "mem"
-#define MEM_PRINT_MEMORYMAP
+#include "config.h"
#include "lib/int/stdint.h"
#include "lib/logger/log.h" // logger facilities
-
//! 8 blocks per byte
#define PMMNGR_BLOCKS_PER_BYTE 8
//! block size (4k)
#define PMMNGR_BLOCK_SIZE 4096
-//! block alignment
+//! 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;
@@ -224,8 +223,8 @@ void mem_init(uint16_t *memmap,uint16_t entries)
memmap+=12;
}
- // here is somewhere our kernel stuff ;) // todo!! better.
- pmmngr_deinit_region(0x0,0x300000);
+ // here is somewhere our kernel stuff ;) // TODO!! better.
+ pmmngr_deinit_region(0x0,0x1000000);
// and here is the memory map that we JUST created!
pmmngr_deinit_region(_mmngr_memory_map,mem_array_size*4);
diff --git a/kernel/task.c b/kernel/task.c
index 1e94b26..094c74d 100644
--- a/kernel/task.c
+++ b/kernel/task.c
@@ -5,16 +5,21 @@
#include "lib/logger/log.h" // logger facilities
#include "lib/int/stdint.h"
#include "mem.h"
+
+#include "syscalls.h"
+#include "fs/fs.h"
+#include "fs/ext2.h"
#define FOOLOS_MODULE_NAME "task"
int started;
uint64_t task_system_clock;
-uint32_t c1,c2,c3;
+static uint32_t c1,c2,c3;
void task_test1()
{
-
+ // ext2_check(EXT2_RAM_ADDRESS);
+ // syscall_execve(15,0,0);
while(1)
{
c1++;
@@ -24,8 +29,6 @@ void task_test1()
void task_test2()
{
- uint32_t c;
-
while(1)
{
c2++;
@@ -36,8 +39,6 @@ void task_test2()
void task_test3()
{
- uint32_t c;
-
while(1)
{
c3++;
@@ -63,7 +64,7 @@ void task_create(int pid,void(*thread)())
Threads[pid].esp0 = pmmngr_alloc_block();
stack = (unsigned int*)Threads[pid].esp0+4095; //This makes a pointer to the stack for us
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"new task : stack: 0x%08X ", stack);
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"new task : stack: 0x%08X thread: 0x%08X", stack, thread);
//First, this stuff is pushed by the processor
*--stack = 0x0202; //This is EFLAGS
@@ -81,7 +82,6 @@ void task_create(int pid,void(*thread)())
*--stack = 0; //EAX
//Now these are the data segments pushed by the IRQ handler
-
/*
*--stack = 0x10; //DS
*--stack = 0x10; //ES
@@ -90,6 +90,7 @@ void task_create(int pid,void(*thread)())
*/
+log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"new task : stack: 0x%08X ", stack);
Threads[pid].esp0 = (uint32_t)stack; //Update the stack pointer
@@ -97,8 +98,8 @@ void task_create(int pid,void(*thread)())
uint32_t task_switch_next(uint32_t oldesp)
{
- task_system_clock++;
+ task_system_clock++;
if(started!=0xabcde) return oldesp;
if(CurrentTask!=-1)Threads[CurrentTask].esp0=oldesp;
@@ -106,7 +107,13 @@ uint32_t task_switch_next(uint32_t oldesp)
CurrentTask++;
if(CurrentTask>2)CurrentTask=0;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"oldesp: 0x%08X saved / next task: %d (esp: 0x%08X) ",oldesp, CurrentTask,Threads[CurrentTask].esp0);
+ log(
+ FOOLOS_MODULE_NAME,
+ FOOLOS_LOG_INFO,
+ "oldesp: 0x%08X saved / next task: %d (esp: 0x%08X) ",
+ oldesp,
+ CurrentTask,
+ Threads[CurrentTask].esp0);
return Threads[CurrentTask].esp0; //Return new stack pointer to ASM
}
diff --git a/kernel/task.h b/kernel/task.h
new file mode 100644
index 0000000..27e0484
--- /dev/null
+++ b/kernel/task.h
@@ -0,0 +1 @@
+void task_init();