summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/config.h3
-rw-r--r--kernel/kernel.c26
-rw-r--r--kernel/task.c5
-rw-r--r--kernel/time.h3
-rw-r--r--kernel/timer.c20
-rw-r--r--kernel/timer.h4
-rw-r--r--kernel/x86.c5
7 files changed, 35 insertions, 31 deletions
diff --git a/kernel/config.h b/kernel/config.h
index 14a6eee..05c4bcb 100644
--- a/kernel/config.h
+++ b/kernel/config.h
@@ -6,7 +6,8 @@
//#define FOOLOS_COMPILE_FLOPPY // compile floppy drivers
#define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line
-//#define FOOLOS_LOG_OFF // do not log anything
+#define FOOLOS_LOG_OFF // do not log anything
#define FOOLOS_CONSOLE // otherwise VESA will be used!
#define MEM_PRINT_MEMORYMAP
+#define LOG_BUF_SIZE 4069
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 5628e84..b45703a 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -8,7 +8,6 @@
#include "lib/buffer/ringbuffer.h"
#include "smp.h"
-#include "time.h"
#include "timer.h"
#include "spinlock.h"
#include "syscalls.h"
@@ -80,22 +79,22 @@ void kernel_main(uint32_t initial_stack, int mp)
/////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP
//
- // init system log ringbugger
- //
- log_init();
+ // Print initial address of the esp stack pointer
+ //
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial esp: 0x%08X",initial_stack);
- //
- // The System Time
//
- task_system_clock=0;
-
+ // Configuring the PIT timer.
+ //
+ timer_init();
+
//
// Memory Init
//
// after this is set up we will be able to allocate and deallocate
// blocks of physical memory :)
//
- // we know that here, the bootloader placed the mamory map and
+ // we know that here, the bootloader placed the memory map and
// the number of entries.
//
mem_init(0x7c00+1,*((uint16_t *)(0x7c00)));
@@ -109,20 +108,11 @@ void kernel_main(uint32_t initial_stack, int mp)
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
//
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC.");
pic_setup();
- //
- // Configuring the PIT timer.
- //
- timer_init();
// mouse and kb driver init (before interrupts)
// mouse_init();
diff --git a/kernel/task.c b/kernel/task.c
index 29ccaa4..6d571cb 100644
--- a/kernel/task.c
+++ b/kernel/task.c
@@ -5,6 +5,7 @@
#include "lib/logger/log.h" // logger facilities
#include "lib/int/stdint.h"
#include "mem.h"
+#include "timer.h"
#include "syscalls.h"
#include "fs/fs.h"
@@ -12,7 +13,6 @@
#define FOOLOS_MODULE_NAME "task"
int started;
-uint64_t task_system_clock;
static uint32_t c1,c2,c3;
@@ -99,8 +99,7 @@ void task_create(int pid,void(*thread)())
uint32_t task_switch_next(uint32_t oldesp)
{
- task_system_clock++;
-
+ timer_tick();
if(started!=0xabcde) return oldesp;
if(CurrentTask!=-1)Threads[CurrentTask].esp0=oldesp;
diff --git a/kernel/time.h b/kernel/time.h
deleted file mode 100644
index 1c581c1..0000000
--- a/kernel/time.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "lib/int/stdint.h"
-volatile uint64_t task_system_clock; // from task.c
-
diff --git a/kernel/timer.c b/kernel/timer.c
index da9e6bd..956195b 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -30,12 +30,15 @@
*/
-#include "kernel.h"
+#define FOOLOS_MODULE_NAME "timer"
+
+#include "timer.h"
#include "x86.h"
#include "../lib/logger/log.h" // logger facilities
-#define FOOLOS_MODULE_NAME "timer"
+//static volatile
+static uint64_t task_system_clock=0;
void timer_init()
{
@@ -43,7 +46,7 @@ void timer_init()
// http://en.wikipedia.org/wiki/Intel_8253#Control_Word_Register
// http://www.brokenthorn.com/Resources/OSDevPit.html
// int0 will be triggered ~25 times a second.
-
+
__asm__("pusha");
__asm__("mov %0, %%dx"::"X" (1193180 / 25));
@@ -60,4 +63,15 @@ void timer_init()
__asm__("popa");
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Configured PIT Channel 0 : Mode 2 : 1/25 s.");
+
+}
+
+void timer_tick()
+{
+ task_system_clock++;
+}
+
+uint64_t timer_get_ticks()
+{
+ return task_system_clock;
}
diff --git a/kernel/timer.h b/kernel/timer.h
index 4859925..3b9ecdf 100644
--- a/kernel/timer.h
+++ b/kernel/timer.h
@@ -1 +1,5 @@
+#include "lib/int/stdint.h"
+
void timer_init();
+void timer_tick();
+uint64_t timer_get_ticks();
diff --git a/kernel/x86.c b/kernel/x86.c
index 15236a3..725c50d 100644
--- a/kernel/x86.c
+++ b/kernel/x86.c
@@ -1,6 +1,7 @@
#define FOOLOS_MODULE_NAME "x86"
#include "x86.h"
+#include "timer.h"
#include "lib/int/stdint.h"
#include "lib/logger/log.h"
@@ -8,11 +9,9 @@
// suffix (b, w, l, q for byte, word, dword, and qword).
//
-extern volatile uint64_t task_system_clock; // from task.c
-
void sleep(int i)
{
- volatile uint64_t clock=task_system_clock;
+ volatile uint64_t clock=timer_get_ticks();
// while(clock+i>task_system_clock)
// {