summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kernel.c76
-rw-r--r--kernel/kernel.h3
-rw-r--r--kernel/mem.c1
-rw-r--r--kernel/timer.c16
-rw-r--r--kernel/timer.h1
5 files changed, 35 insertions, 62 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 79acf18..5d19e11 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -20,99 +20,65 @@
#include "terminal/terminal.h"
#include "driver/screen.h"
-
/* F00L 0S Entry point (called directly from asm/multiboot.asm */
void kernel_main(uint32_t eax,uint32_t ebx)
{
+ // SERIAL PORT
+ serial_init();
+
+ // PR
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%s - compiled on %s at %s",KERNEL_VERSION,__DATE__,__TIME__);
+
+ // PIT TIMER
+ timer_init();
- //
- // STDIN & STDOUT
- //
+ // STREAMS
uint32_t sstdin = syscall_open("stdin",0,0); // stdin 0
uint32_t sstdout = syscall_open("term",0,0); // stdout 1
uint32_t sstderr = syscall_open("stderr",0,0); // stderr 2
- //
- // PR
- //
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%s - compiled on %s at %s",KERNEL_VERSION,__DATE__,__TIME__);
-
- //
- // Setup Keyboard Driver
- //
+ // KEYBOARD DRIVER
keyboard_init(sstdin);
- //
- // Configuring the PIT timer.
- //
- timer_init();
+ // MOUSE DRIVER
+ mouse_init(sstdin);
- //
// GDT
- //
gdt_setup();
- //
- // Setup Interrupts (code segment: 0x08)
- //
+ // INTERRUPTS (code segment: 0x08)
int_init(0x08);
- //
- // Process Multiboot Header
- //
+ // MULTIBOOT HEADER
multiboot_information *info=get_multiboot(eax, ebx);
- //
- // Gather Info about other processors. (APs = application processors)
- // ACPI or MP
- //
+ // Gather Info about other processors. (APs = application processors) // 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!");
- //
- // Memory Init
- //
- // after this is set up we will be able to allocate and deallocate
- // blocks of physical memory :)
- //
+ // MEMORY INIT (allows allocating and deaclloating physical memory)
uint32_t kernel_blocks=mem_init(info);
- //
// Mount Root EXT2 ramimage (needs to be done before other processors started, because of /boot/mp.bin)
- //
fs_mount(info);
- //
// Start the other Processors (before paging because apic addr etc..?)
- //
//TODO: !!! Check commented out sleep ()!!!
smp_log_procdata(&procdata);
smp_start_aps(&procdata,"/boot/mp.bin"); //will be copied over mbr
- //
- // Activate Virtual Memory (paging)
- //
+ // VIRTUAL MEMORY (paging)
pdirectory *dir=vmem_init(kernel_blocks);
- //
- // Scan the PCI Bus
- //
- // We are interested in the E1000 Network Adapter in particular
- // Its driver will be hopefully implemented one day ;) TODO
- //
- //pci_init();
- //
+ // PCI Bus
+ pci_init();
- //
- // Initialize Multitasking
- //
+ // INIT MULTITASKING (and switch to usermode)
task_init(dir);
- //
- // Abvoe should never returon
- //
+ // we should never reach this
panic(FOOLOS_MODULE_NAME,"reached end of kernel.c !!");
}
diff --git a/kernel/kernel.h b/kernel/kernel.h
index 44b9b2d..8d2bce9 100644
--- a/kernel/kernel.h
+++ b/kernel/kernel.h
@@ -23,7 +23,7 @@
#define FOOLSOS_SHOW_VESAMODES
#define MEM_PRINT_MEMORYMAP
#define LOG_BUF_SIZE 4069
-//#define LOG_SYSCALLS
+#define LOG_SYSCALLS
#define BIN_INIT "/bin/init"
@@ -31,4 +31,3 @@
#define NUMBER_SPINLOCKS 16
#endif
-
diff --git a/kernel/mem.c b/kernel/mem.c
index 029ea10..a167d8b 100644
--- a/kernel/mem.c
+++ b/kernel/mem.c
@@ -17,7 +17,6 @@ extern uint32_t kernel_end[];
extern uint32_t stack_top[];
extern uint32_t stack_bottom[];
-
//memory map bit array. Each bit represents a 4KB memory block,
//so uint32_t represents 8*4 blocks
static uint32_t _mmngr_memory_map[PMMNGR_MAP_SIZE];
diff --git a/kernel/timer.c b/kernel/timer.c
index a339d70..3f7ab0f 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -38,6 +38,7 @@
// TODO: use mutex? do we need volatile at all!??
// abstract atomic variable set,get,increment
static volatile uint64_t task_system_clock=0;
+static volatile uint64_t task_system_clock_start=0;
//called by interrupt
void timer_tick()
@@ -52,12 +53,18 @@ uint64_t timer_get_ticks()
}
///
+
uint64_t timer_get_ms()
{
uint64_t t=timer_get_ticks();
uint64_t s=t/25;
- uint64_t ms=0; // TODO ms
- return s*1000;
+ uint64_t ms=t*1000/25-s*1000;
+ return s*1000+ms;
+}
+
+uint64_t timer_get_uptime_ms()
+{
+ return timer_get_ms()-task_system_clock_start*1000;
}
// CMOS RTC
@@ -213,8 +220,9 @@ uint64_t get_rtc_time()
void timer_init()
{
uint64_t epoch_time=get_rtc_time();
- epoch_time*=25;
- task_system_clock=epoch_time;
+
+ task_system_clock_start=epoch_time;
+ task_system_clock=epoch_time*25;
// config out timer on channel 0 : mode 2 (sys timer)
// http://en.wikipedia.org/wiki/Intel_8253#Control_Word_Register
diff --git a/kernel/timer.h b/kernel/timer.h
index 57ea21e..a39d433 100644
--- a/kernel/timer.h
+++ b/kernel/timer.h
@@ -3,3 +3,4 @@
void timer_init();
void timer_tick();
uint64_t timer_get_ticks();
+uint64_t timer_get_uptime_ms();