From 74e721676ddd5d996ccf2e1d35da57320f658609 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 21 Aug 2009 23:59:19 +0200 Subject: Kernel now loads in higher half, and uses a VT for output. --- Source/Kernel/Core/.kmain.wtf.cpp.swp | Bin 12288 -> 12288 bytes Source/Kernel/Core/CMem.ns.o | Bin 991 -> 0 bytes Source/Kernel/Core/Sys.ns.cpp | 15 +++++++++++---- Source/Kernel/Core/Sys.ns.o | Bin 1676 -> 0 bytes Source/Kernel/Core/common.wtf.h | 13 +++++++++++++ Source/Kernel/Core/cppsupport.wtf.o | Bin 741 -> 0 bytes Source/Kernel/Core/kmain.wtf.cpp | 14 ++++++++++++-- Source/Kernel/Core/kmain.wtf.o | Bin 2948 -> 0 bytes Source/Kernel/Core/loader.wtf.asm | 28 +++++++++++++++++++++++++++- Source/Kernel/Core/loader.wtf.o | Bin 1312 -> 0 bytes 10 files changed, 63 insertions(+), 7 deletions(-) delete mode 100644 Source/Kernel/Core/CMem.ns.o delete mode 100644 Source/Kernel/Core/Sys.ns.o delete mode 100644 Source/Kernel/Core/cppsupport.wtf.o delete mode 100644 Source/Kernel/Core/kmain.wtf.o delete mode 100644 Source/Kernel/Core/loader.wtf.o (limited to 'Source/Kernel/Core') diff --git a/Source/Kernel/Core/.kmain.wtf.cpp.swp b/Source/Kernel/Core/.kmain.wtf.cpp.swp index bc7a8c6..bf1668b 100644 Binary files a/Source/Kernel/Core/.kmain.wtf.cpp.swp and b/Source/Kernel/Core/.kmain.wtf.cpp.swp differ diff --git a/Source/Kernel/Core/CMem.ns.o b/Source/Kernel/Core/CMem.ns.o deleted file mode 100644 index b8b6dbb..0000000 Binary files a/Source/Kernel/Core/CMem.ns.o and /dev/null differ diff --git a/Source/Kernel/Core/Sys.ns.cpp b/Source/Kernel/Core/Sys.ns.cpp index eca826f..361dda6 100644 --- a/Source/Kernel/Core/Sys.ns.cpp +++ b/Source/Kernel/Core/Sys.ns.cpp @@ -1,5 +1,8 @@ //This automatically includes Sys.ns.h #include +#include + +#define DEBUGVT(x) VirtualTerminal *x = new VirtualTerminal(5, 46, 0, 15); x->map(); x->put('\n'); using namespace CMem; @@ -43,20 +46,24 @@ void bochs_output(char *message, char *file, u32int line) { void panic(char *message, char *file, u32int line) { asm volatile("cli"); - bochs_output("PANIC : ", file, 0); + DEBUGVT(vt); + bochs_output("PANIC : ", file, line); bochs_output(message, file, 0); + *vt << " PANIC : " << message << "\n In " << file << ":" << (s32int)line << "\n"; - while (1); //Enter infinite loop for halt + while (1) asm volatile("hlt"); //Enter infinite loop for halt } //Used by ASSERT() macro (see common.wtf.h) void panic_assert(char *file, u32int line, char *desc) { asm volatile("cli"); - bochs_output("ASSERTION FAILED : ", file, 0); + DEBUGVT(vt); + bochs_output("ASSERTION FAILED : ", file, line); bochs_output(desc, file, 0); + *vt << " ASSERTION FAILED : " << desc << "\n In " << file << ":" << (s32int)line << "\n"; - while (1); //Enter infinite loop for halt + while (1) asm volatile("hlt"); //Enter infinite loop for halt } void reboot() { diff --git a/Source/Kernel/Core/Sys.ns.o b/Source/Kernel/Core/Sys.ns.o deleted file mode 100644 index 58f3dc8..0000000 Binary files a/Source/Kernel/Core/Sys.ns.o and /dev/null differ diff --git a/Source/Kernel/Core/common.wtf.h b/Source/Kernel/Core/common.wtf.h index 9b1bc7e..617a73c 100644 --- a/Source/Kernel/Core/common.wtf.h +++ b/Source/Kernel/Core/common.wtf.h @@ -24,4 +24,17 @@ typedef char s8int; #define DEBUG(m) #endif +#include + +//Standard implemenations of operator new/delete +inline void* operator new(u32int, void *p) { return p; } +inline void* operator new[](u32int, void *p) { return p; } +inline void operator delete(void*, void*) { } +inline void operator delete[](void*, void*) { } + +inline void* operator new(u32int sz) { return Mem::kalloc(sz); } +inline void* operator new[](u32int sz) { return Mem::kalloc(sz); } +inline void operator delete(void *ptr) { Mem::kfree(ptr); } +inline void operator delete[](void *ptr) { Mem::kfree(ptr); } + #endif diff --git a/Source/Kernel/Core/cppsupport.wtf.o b/Source/Kernel/Core/cppsupport.wtf.o deleted file mode 100644 index 4088bfb..0000000 Binary files a/Source/Kernel/Core/cppsupport.wtf.o and /dev/null differ diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index 59fa45a..e201a07 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -13,9 +14,11 @@ extern "C" void kmain(multiboot_info_t* mbd, u32int magic); void kmain(multiboot_info_t* mbd, u32int magic) { DEBUG("Entering kmain."); - VGATextOutput vgaout; + Mem::placementAddress = (u32int)&end; - Disp::setDisplay(&vgaout); + VGATextOutput *vgaout = new VGATextOutput(); + + Disp::setDisplay(vgaout); for (int i = 0; i < melonLogoLines; i++) { int startCol = (Disp::textCols() / 2) - (melonLogoCols / 2); @@ -24,6 +27,13 @@ void kmain(multiboot_info_t* mbd, u32int magic) { } } + VirtualTerminal *kvt = new VirtualTerminal(12, 40, 0, 2); + kvt->map(melonLogoLines + 4); + + *kvt << "Kernel initializing in HIGHER HALF!\n"; + + *kvt << "Lower ram : " << (s32int)mbd->mem_lower << "k, upper : " << (s32int)mbd->mem_upper << "k.\n"; + if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { PANIC("Error with multiboot header."); } diff --git a/Source/Kernel/Core/kmain.wtf.o b/Source/Kernel/Core/kmain.wtf.o deleted file mode 100644 index 19a82cf..0000000 Binary files a/Source/Kernel/Core/kmain.wtf.o and /dev/null differ diff --git a/Source/Kernel/Core/loader.wtf.asm b/Source/Kernel/Core/loader.wtf.asm index e5f5839..c5248e9 100644 --- a/Source/Kernel/Core/loader.wtf.asm +++ b/Source/Kernel/Core/loader.wtf.asm @@ -21,8 +21,21 @@ STACKSIZE equ 0x4000 ; that's 16k. extern start_ctors, end_ctors, start_dtors, end_dtors loader: + lgdt [trickgdt] + mov cx, 0x10; + mov ds, cx; + mov es, cx; + mov fs, cx; + mov gs, cx; + mov ss, cx; + + jmp 0x08:higherhalf + + +higherhalf: mov esp, stack+STACKSIZE ; set up the stack push eax ; pass Multiboot magic number + add ebx, 0xC0000000 ; update the MB info structure so that it is in the new seg. push ebx ; pass Multiboot info structure static_ctors_loop: @@ -52,8 +65,21 @@ static_dtors_loop: ; useless, kernel should never return hang: hlt ; halt machine should kernel return jmp hang + +[section .setup] + +trickgdt: + dw gdt_end - gdt - 1 + dd gdt + +gdt: + dd 0, 0 + db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40 + db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40 + +gdt_end: -section .bss +[section .bss] align 32 stack: resb STACKSIZE ; reserve 16k stack on a quadword boundary diff --git a/Source/Kernel/Core/loader.wtf.o b/Source/Kernel/Core/loader.wtf.o deleted file mode 100644 index caed8f0..0000000 Binary files a/Source/Kernel/Core/loader.wtf.o and /dev/null differ -- cgit v1.2.3