summaryrefslogtreecommitdiff
path: root/src/kernel/core
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-01 12:20:45 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-01 12:20:45 +0200
commit5cac9acd3aedc8043d4272d93c56805c46ff6214 (patch)
treeba9eb5ef86f7cf7afd4f7ab02de1d6bb86715632 /src/kernel/core
parent66b32658d2e5aa99493dcb3abcb73cdb2cc6f0b5 (diff)
downloadTCE-5cac9acd3aedc8043d4272d93c56805c46ff6214.tar.gz
TCE-5cac9acd3aedc8043d4272d93c56805c46ff6214.zip
Some cleanup ; relocated the kernel at 0xC0000000
Diffstat (limited to 'src/kernel/core')
-rw-r--r--src/kernel/core/kmain.c10
-rw-r--r--src/kernel/core/loader_.asm8
-rw-r--r--src/kernel/core/monitor.c4
-rw-r--r--src/kernel/core/sys.c4
4 files changed, 15 insertions, 11 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 8f14843..86db4ff 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -27,12 +27,12 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) {
uint32_t i;
mem_placementAddr = ((size_t)&end & 0xFFFFF000) + 0x1000;
- mbd->cmdline += 0xE0000000; mbd->mods_addr += 0xE0000000;
+ mbd->cmdline += K_HIGHHALF_ADDR; mbd->mods_addr += K_HIGHHALF_ADDR;
struct module_t *mods = (struct module_t*)mbd->mods_addr;
for (i = 0; i < mbd->mods_count; i++) {
- mods[i].mod_start += 0xE0000000;
- mods[i].mod_end += 0xE0000000;
- mods[i].string += 0xE0000000;
+ mods[i].mod_start += K_HIGHHALF_ADDR;
+ mods[i].mod_end += K_HIGHHALF_ADDR;
+ mods[i].string += K_HIGHHALF_ADDR;
if (mods[i].mod_end > mem_placementAddr)
mem_placementAddr = (mods[i].mod_end & 0xFFFFF000) + 0x1000;
}
@@ -68,7 +68,7 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) {
if (pr == 0) {
monitor_write(" : Error loading\n");
} else {
- monitor_write(" : OK pid:"); monitor_writeDec(pr->pid); monitor_write("\n");
+ monitor_write(" : OK, pid="); monitor_writeDec(pr->pid); monitor_write("\n");
}
}
}
diff --git a/src/kernel/core/loader_.asm b/src/kernel/core/loader_.asm
index 5ee998a..07de52c 100644
--- a/src/kernel/core/loader_.asm
+++ b/src/kernel/core/loader_.asm
@@ -1,3 +1,4 @@
+[EXTERN k_highhalf_addr]
[GLOBAL loader] ; making entry point visible to linker
[EXTERN kmain] ; kmain is defined in kmain.c
[EXTERN tasking_tmpStack] ; a temporary 4k stack used by tasking, and used when setting up kernel stuff
@@ -30,10 +31,9 @@ loader: ;here, we load our false GDT, used for having the kernel in higher half
section .text
higherhalf: ; now we're running in higher half
-
mov esp, tasking_tmpStack+0x8000 ; set up the stack
push eax ; pass Multiboot magic number
- add ebx, 0xE0000000 ; update the MB info structure so that it is in the new seg
+ add ebx, k_highhalf_addr ; update the MB info structure so that it is in the new seg
push ebx ; pass Multiboot info structure
call kmain ; call kernel proper
@@ -51,7 +51,7 @@ trickgdt: ; our false GDT
gdt:
dd 0, 0 ; null GDT entry
- db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x20 ; kernel code segment
- db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x20 ; kernel data segment
+ db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40 ; kernel code segment
+ db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40 ; kernel data segment
gdt_end:
diff --git a/src/kernel/core/monitor.c b/src/kernel/core/monitor.c
index 0d0f5eb..ba2a6df 100644
--- a/src/kernel/core/monitor.c
+++ b/src/kernel/core/monitor.c
@@ -1,8 +1,10 @@
#include "monitor.h"
#include "sys.h"
+#include "mem/mem.h"
+
static int cursor_x = 0, cursor_y = 0;
-static uint16_t *video_memory = (uint16_t*)0xE00B8000;
+static uint16_t *video_memory = (uint16_t*)((size_t)K_HIGHHALF_ADDR + 0xB8000);
static uint8_t attribute = 0x07; // 0 = background = black, 7 = foreground = white
diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c
index 05a7bc5..4c53d58 100644
--- a/src/kernel/core/sys.c
+++ b/src/kernel/core/sys.c
@@ -1,6 +1,8 @@
#include "sys.h"
#include "monitor.h"
+#include "mem/mem.h"
+
/* These four functions are wrappers around ASM operations.
These functions are used when comunicating with the system hardware. */
@@ -27,7 +29,7 @@ uint16_t inw(uint16_t port) {
//////
void stack_trace(size_t bp) {
uint32_t *stack = (uint32_t*)bp, i;
- for (i = 0; i < 5 && stack > 0xE0000000 && stack < (bp + 0x8000); i++) {
+ for (i = 0; i < 5 && stack > K_HIGHHALF_ADDR && stack < (bp + 0x8000); i++) {
monitor_write("| "); monitor_writeHex(stack);
monitor_write("\tnext:"); monitor_writeHex(stack[0]); monitor_write("\t\tret:"); monitor_writeHex(stack[1]);
monitor_write("\n");