summaryrefslogtreecommitdiff
path: root/src/stem
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-02-05 21:35:38 +0100
committerAlexis211 <alexis211@gmail.com>2010-02-05 21:35:38 +0100
commit3558f18daf50281ee1cd68cca96cd967dbac04ba (patch)
treecbe73621cdd2f481ed6f985aeb532ca1f7a7ad77 /src/stem
parent893244c8b5272df86da5d333332eec26ae8f15f2 (diff)
downloadTCE-3558f18daf50281ee1cd68cca96cd967dbac04ba.tar.gz
TCE-3558f18daf50281ee1cd68cca96cd967dbac04ba.zip
Everything seems to work : loading a module that displays a message.
Diffstat (limited to 'src/stem')
-rw-r--r--src/stem/core/kmain.c2
-rw-r--r--src/stem/core/sys.c2
-rw-r--r--src/stem/lib/bitset.c1
-rw-r--r--src/stem/lib/stdlib.c2
-rw-r--r--src/stem/mem/mem.c2
-rw-r--r--src/stem/mem/paging.c14
-rw-r--r--src/stem/mem/seg.c2
-rw-r--r--src/stem/task/syscall.c3
-rw-r--r--src/stem/task/task.c12
9 files changed, 22 insertions, 18 deletions
diff --git a/src/stem/core/kmain.c b/src/stem/core/kmain.c
index 5b6c06e..d6233db 100644
--- a/src/stem/core/kmain.c
+++ b/src/stem/core/kmain.c
@@ -57,7 +57,7 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) {
}
}
- monitor_write("Passing conroll to loaded modules...\n");
+ monitor_write("Passing controll to loaded modules...\n");
sti();
tasking_switch();
}
diff --git a/src/stem/core/sys.c b/src/stem/core/sys.c
index 36ed6d0..d31c20e 100644
--- a/src/stem/core/sys.c
+++ b/src/stem/core/sys.c
@@ -22,7 +22,7 @@ uint16_t inw(uint16_t port) {
}
void panic(char* message, char* file, int line) {
- monitor_write(">> PANIC: >>");
+ monitor_write("\n>> PANIC: >>");
monitor_write(message); monitor_write("<< in file "); monitor_write(file);
monitor_write("\nSystem halted T_T");
asm volatile("cli; hlt");
diff --git a/src/stem/lib/bitset.c b/src/stem/lib/bitset.c
index c13a24d..a6d334b 100644
--- a/src/stem/lib/bitset.c
+++ b/src/stem/lib/bitset.c
@@ -30,5 +30,6 @@ uint32_t bitset_firstFree(struct bitset* t) {
}
}
}
+ return (uint32_t) - 1;
}
diff --git a/src/stem/lib/stdlib.c b/src/stem/lib/stdlib.c
index f4ebd33..c5245e7 100644
--- a/src/stem/lib/stdlib.c
+++ b/src/stem/lib/stdlib.c
@@ -1,7 +1,7 @@
#include "stdlib.h"
void *memcpy(void *vd, const void *vs, int count) {
- uint8_t *dest = vd, *src = vs;
+ uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
uint32_t f = count % 4, n = count / 4, i;
const uint32_t* s = (uint32_t*)src;
uint32_t* d = (uint32_t*)dest;
diff --git a/src/stem/mem/mem.c b/src/stem/mem/mem.c
index c96a29d..2f7e1c8 100644
--- a/src/stem/mem/mem.c
+++ b/src/stem/mem/mem.c
@@ -34,7 +34,7 @@ static void get_free_pages() {
}
freepages[freepagecount].virt = i;
freepages[freepagecount].phys = frame_alloc() * 0x1000;
- page_map(pagedir_getPage(kernel_pagedir, i, 0), i, 0, 0);
+ page_map(pagedir_getPage(kernel_pagedir, i, 0), freepages[freepagecount].phys / 0x1000, 0, 0);
freepagecount++;
} else {
if (mem_placementAddr & 0xFFFFF000) {
diff --git a/src/stem/mem/paging.c b/src/stem/mem/paging.c
index 9b9c989..27ce043 100644
--- a/src/stem/mem/paging.c
+++ b/src/stem/mem/paging.c
@@ -54,7 +54,7 @@ void paging_init(size_t totalRam) {
void paging_cleanup() {
uint32_t i;
for (i = 0; i < (mem_placementAddr - 0xE0000000) / 0x100000; i++) {
- kernel_pagedir->tablesPhysical[i] = 9;
+ kernel_pagedir->tablesPhysical[i] = 0;
kernel_pagedir->tables[i] = 0;
}
monitor_write("Pages cleaned up\n");
@@ -80,7 +80,7 @@ struct page_directory *pagedir_new() {
pd->tables[i] = 0; pd->tablesPhysical[i] = 0;
}
- for (i = 768; i < 1024; i++) {
+ for (i = 896; i < 1024; i++) {
pd->tables[i] = kernel_pagedir->tables[i];
pd->tablesPhysical[i] = kernel_pagedir->tablesPhysical[i];
}
@@ -93,7 +93,7 @@ void pagedir_delete(struct page_directory *pd) {
//Unmap segments
while (pd->mappedSegs != 0) seg_unmap(pd->mappedSegs);
//Cleanup page tables
- for (i = 0; i < 768; i++) {
+ for (i = 0; i < 896; i++) {
kfree_page(pd->tables[i]);
}
kfree_page(pd->tablesPhysical);
@@ -107,16 +107,16 @@ uint32_t paging_fault(struct registers *regs) {
seg = current_pagedir->mappedSegs;
while (seg) {
- if (seg->start >= addr && seg->start + seg->len < addr) break;
+ if (seg->start <= addr && seg->start + seg->len > addr) break;
seg = seg->next;
}
if (seg != 0) {
- if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2)) != 0) seg = 0;
+ if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2) && (regs->eip < 0xE0000000)) != 0) seg = 0;
}
if (seg == 0) {
- monitor_write("PageFault ");
+ monitor_write("(paging.c:119) Unhandled Page Fault ");
if (regs->err_code & 0x1) monitor_write("present ");
if (regs->err_code & 0x2) monitor_write("write ");
if (regs->err_code & 0x4) monitor_write("user ");
@@ -136,7 +136,7 @@ struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int ma
return &pd->tables[table_idx]->pages[address % 1024];
} else if (make) {
pd->tables[table_idx] = kmalloc_page(pd->tablesPhysical + table_idx);
- if (table_idx >= 768)
+ if (table_idx >= 896)
tasking_updateKernelPagetable(table_idx, pd->tables[table_idx], pd->tablesPhysical[table_idx]);
memset((uint8_t*)pd->tables[table_idx], 0, 0x1000);
pd->tablesPhysical[table_idx] |= 0x07;
diff --git a/src/stem/mem/seg.c b/src/stem/mem/seg.c
index f340c63..1452d61 100644
--- a/src/stem/mem/seg.c
+++ b/src/stem/mem/seg.c
@@ -8,7 +8,7 @@ struct segment_map *seg_map(struct segment* seg, struct page_directory *pagedir)
sm->seg = seg;
sm->pagedir = pagedir;
sm->next = pagedir->mappedSegs;
- pagedir->mappedSegs = sm->next;
+ pagedir->mappedSegs = sm;
return sm;
}
diff --git a/src/stem/task/syscall.c b/src/stem/task/syscall.c
index 0878b30..5aab011 100644
--- a/src/stem/task/syscall.c
+++ b/src/stem/task/syscall.c
@@ -8,13 +8,14 @@
CALL0(thread_exit, thread_exit_sc);
CALL0(tasking_switch, schedule_sc);
+CALL1(thread_sleep, thread_sleep_sc);
CALL1(process_exit, process_exit_sc);
CALL1(monitor_write, printk_sc);
int_callback syscalls[] = {
thread_exit_sc,
schedule_sc,
- 0, //Syscall 2 will be thread_sleep
+ thread_sleep_sc,
process_exit_sc,
printk_sc,
0 };
diff --git a/src/stem/task/task.c b/src/stem/task/task.c
index 0352308..804adc2 100644
--- a/src/stem/task/task.c
+++ b/src/stem/task/task.c
@@ -85,6 +85,7 @@ void tasking_switch() {
}
void tasking_updateKernelPagetable(uint32_t idx, struct page_table *table, uint32_t tablephysical) {
+ if (idx < 896) return;
struct process* it = processes;
while (it != 0) {
it->pagedir->tables[idx] = table;
@@ -94,16 +95,17 @@ void tasking_updateKernelPagetable(uint32_t idx, struct page_table *table, uint3
}
uint32_t tasking_handleException(struct registers *regs) {
- if (threads == 0) return 0; //No tasking yet
- monitor_write("\nUnhandled exception : ");
+ if (current_thread == 0) return 0; //No tasking yet
+ monitor_write("\n(task.c:99) Unhandled exception : ");
char *exception_messages[] = {"Division By Zero","Debug","Non Maskable Interrupt","Breakpoint",
"Into Detected Overflow","Out of Bounds","Invalid Opcode","No Coprocessor", "Double Fault",
"Coprocessor Segment Overrun","Bad TSS","Segment Not Present","Stack Fault","General Protection Fault",
"Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"};
monitor_write(exception_messages[regs->int_no]);
- monitor_write("\nThread exiting.\n");
+ monitor_write(" at "); monitor_writeHex(regs->eip);
+ monitor_write(" >>> Thread exiting.\n");
thread_exit_stackJmp(EX_TH_EXCEPTION);
- return 0;
+ PANIC("This should never have happened. Please report this.");
}
void thread_sleep(uint32_t msecs) {
@@ -225,7 +227,7 @@ static void thread_delete(struct thread *th) {
static void process_delete(struct process *pr) {
struct thread *it;
- while (threads->process == pr) thread_delete(threads);
+ while (threads != 0 && threads->process == pr) thread_delete(threads);
it = threads;
while (it != 0) {
while (it->next->process == pr) thread_delete(it->next);