diff options
author | Alexis211 <alexis211@gmail.com> | 2009-09-12 19:31:53 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-09-12 19:31:53 +0200 |
commit | 267bda33af7c2f4efa107496a9cbd6726b53a101 (patch) | |
tree | 1fc9cc78017c98e58ee539dad45f78ea97419684 | |
parent | 7b0d6ac9f903296c7537cec9ac606d49cb364049 (diff) | |
download | Melon-267bda33af7c2f4efa107496a9cbd6726b53a101.tar.gz Melon-267bda33af7c2f4efa107496a9cbd6726b53a101.zip |
Fixed some bugs
-rw-r--r-- | Media/Screenshots/2009-09-11-162624_728x426_scrot.png | bin | 0 -> 21058 bytes | |||
-rw-r--r-- | Source/Kernel/Core/Sys.ns.cpp | 25 | ||||
-rw-r--r-- | Source/Kernel/Core/Sys.ns.h | 14 | ||||
-rw-r--r-- | Source/Kernel/Core/common.wtf.h | 11 | ||||
-rw-r--r-- | Source/Kernel/Core/kmain.wtf.cpp | 8 | ||||
-rwxr-xr-x | Source/Kernel/Melon.ke | bin | 118822 -> 118873 bytes | |||
-rw-r--r-- | Source/Kernel/MemoryManager/Mem.ns.cpp | 2 | ||||
-rw-r--r-- | Source/Kernel/SyscallManager/IDT.ns.cpp | 2 |
8 files changed, 45 insertions, 17 deletions
diff --git a/Media/Screenshots/2009-09-11-162624_728x426_scrot.png b/Media/Screenshots/2009-09-11-162624_728x426_scrot.png Binary files differnew file mode 100644 index 0000000..19d6ec8 --- /dev/null +++ b/Media/Screenshots/2009-09-11-162624_728x426_scrot.png diff --git a/Source/Kernel/Core/Sys.ns.cpp b/Source/Kernel/Core/Sys.ns.cpp index faec43a..ab57589 100644 --- a/Source/Kernel/Core/Sys.ns.cpp +++ b/Source/Kernel/Core/Sys.ns.cpp @@ -1,6 +1,7 @@ //This automatically includes Sys.ns.h #include <Core/common.wtf.h> #include <VTManager/VirtualTerminal.class.h> +#include <SyscallManager/IDT.ns.h> #define DEBUGVT(x) VirtualTerminal *x = new VirtualTerminal(4, 56, 0, 15); x->map(); x->put('\n'); @@ -77,6 +78,30 @@ void panic(char *message, char *file, u32int line) { while (1) asm volatile("hlt"); //Enter infinite loop for halt } +void panic(char *message, registers_t *regs, char *file, u32int line) { + asm volatile("cli"); + + VirtualTerminal vt(20, 70, 7, 1); + vt.map(); + + vt << "PANIC : " << message << "\n => in " << file << " at " << (s32int)line << "\n\n"; + vt << "ds=" << (u32int)regs->ds << ", eip=" << (u32int)regs->eip << ", cs=" << (u32int)regs->cs << "\n"; + vt << "edi=" << (u32int)regs->edi << ", esi=" << (u32int)regs->esi << ", ebp=" << (u32int)regs->ebp << + ", esp=" << (u32int)regs->esp << "\n"; + vt << "eax=" << (u32int)regs->eax << ", ebx=" << (u32int)regs->ebx << ", ecx=" << (u32int)regs->ecx << + ", edx=" << (u32int)regs->edx << "\n"; + vt << "int_no=" << (s32int)regs->int_no << ", err_code=" << (u32int)regs->err_code << "\n"; + vt << "eflags=" << (u32int)regs->eflags << ", useresp=" << (u32int)regs->useresp << ", ss=" << (u32int)regs->ss << "\n\n"; + + u32int *v = (u32int*)regs->ebp; + for (int i = 0; i < 10; i++) { + vt << "ebp=" << (u32int)v << ", value=" << (u32int)(v[1]) << "\n"; + v = (u32int*)(*v); + } + + while (1) asm volatile("hlt"); +} + //Used by ASSERT() macro (see common.wtf.h) void panic_assert(char *file, u32int line, char *desc) { asm volatile("cli"); diff --git a/Source/Kernel/Core/Sys.ns.h b/Source/Kernel/Core/Sys.ns.h index 825b68c..a205892 100644 --- a/Source/Kernel/Core/Sys.ns.h +++ b/Source/Kernel/Core/Sys.ns.h @@ -4,14 +4,28 @@ #ifndef DEF_SYS_NS_H #define DEF_SYS_NS_H +#define PANIC(msg) Sys::panic(msg, __FILE__, __LINE__) +#define PANIC_DUMP(msg, regs) Sys::panic(msg, regs, __FILE__, __LINE__) +#define ASSERT(b) ((b) ? (void)0 : Sys::panic_assert(__FILE__, __LINE__, #b)) + +#ifdef OPT_DEBUG +#define DEBUG(m) Sys::bochs_output(m, __FILE__, __LINE__) +#define DEBUG_HEX(m) Sys::bochs_output_hex(m); +#else +#define DEBUG(m) +#define DEBUG_HEX(m) +#endif + //This file contains system-relative functions class String; +struct registers_t; namespace Sys { void outb(u16int port, u8int value); u8int inb(u16int port); u16int inw(u16int port); void panic(char* message, char *file, u32int line); + void panic(char* message, registers_t *regs, char *file, u32int line); void panic_assert(char* file, u32int line, char *desc); void bochs_output(char* message, char *file, u32int line); void bochs_output(String message, char *file, u32int line); diff --git a/Source/Kernel/Core/common.wtf.h b/Source/Kernel/Core/common.wtf.h index ac541d6..5fb67b4 100644 --- a/Source/Kernel/Core/common.wtf.h +++ b/Source/Kernel/Core/common.wtf.h @@ -12,17 +12,6 @@ #include <Core/CMem.ns.h> #include <Core/Sys.ns.h> -#define PANIC(msg) Sys::panic(msg, __FILE__, __LINE__) -#define ASSERT(b) ((b) ? (void)0 : Sys::panic_assert(__FILE__, __LINE__, #b)) - -#ifdef OPT_DEBUG -#define DEBUG(m) Sys::bochs_output(m, __FILE__, __LINE__) -#define DEBUG_HEX(m) Sys::bochs_output_hex(m); -#else -#define DEBUG(m) -#define DEBUG_HEX(m) -#endif - #include <MemoryManager/Mem.ns.h> //Standard implemenations of operator new/delete diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index 8188e91..a7bb6e0 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -80,16 +80,16 @@ void kmain(multiboot_info_t* mbd, u32int magic) { u32int totalRam = ((mbd->mem_upper + 1024) * 1024); PhysMem::initPaging(totalRam); OK(kvt); - INFO(kvt); *kvt << "Total ram : " << (s32int)(totalRam / 1024) << "k.\n"; - PROCESSING(kvt, "Initializing GDT and cleaning page directory..."); + INFO(kvt); *kvt << "Total ram : " << (s32int)(totalRam / 1024) << "k (" << (s32int)(totalRam / (1024 * 1024)) << "M).\n"; + PROCESSING(kvt, "Initializing real GDT and cleaning page directory..."); GDT::init(); PhysMem::removeTemporaryPages(); OK(kvt); - PROCESSING(kvt, "Creating heap..."); + PROCESSING(kvt, "Creating kernel heap..."); Mem::createHeap(); OK(kvt); INFO(kvt); *kvt << "Free frames : " << (s32int)PhysMem::free() << "/" << (s32int)PhysMem::total() << "\n"; - PROCESSING(kvt, "Registering vgaout..."); + PROCESSING(kvt, "Registering textual VGA output..."); Dev::registerDevice(vgaout); OK(kvt); PROCESSING(kvt,"Initializing PIT..."); diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke Binary files differindex 996e1b4..552d00c 100755 --- a/Source/Kernel/Melon.ke +++ b/Source/Kernel/Melon.ke diff --git a/Source/Kernel/MemoryManager/Mem.ns.cpp b/Source/Kernel/MemoryManager/Mem.ns.cpp index 5d30f5f..fa407d6 100644 --- a/Source/Kernel/MemoryManager/Mem.ns.cpp +++ b/Source/Kernel/MemoryManager/Mem.ns.cpp @@ -78,7 +78,7 @@ void removeFromHeapIndex(heap_header_t *e) { //*************************************************************************** void createHeap() { u32int heapIndexSize = PhysMem::total() * 64 + 0x10000; - heapStart = placementAddress + 0x10000; //Set initial heap start + heapStart = (placementAddress & 0xFFFFF000) + 0x10000; //Set initial heap start heapEnd = heapStart + HEAP_MIN_SIZE + heapIndexSize; //Set heap end //Alocate frames for the heap diff --git a/Source/Kernel/SyscallManager/IDT.ns.cpp b/Source/Kernel/SyscallManager/IDT.ns.cpp index f31c789..a27dfa9 100644 --- a/Source/Kernel/SyscallManager/IDT.ns.cpp +++ b/Source/Kernel/SyscallManager/IDT.ns.cpp @@ -64,7 +64,7 @@ extern "C" void interrupt_handler(registers_t regs) { bool doSwitch = (regs.int_no == 32 or regs.int_no >= 65); //SYSCALLS >= 65 are task-managing-related if (regs.int_no < 32) { if ((u32int)Task::currentThread == 0xFFFFFFFF or Task::currentThread == 0) - PANIC("Exception cannot be handled."); + PANIC_DUMP("Exception cannot be handled.", ®s); Task::currentThread->handleException(regs, regs.int_no); } else if (regs.int_no < 48) { if (regs.int_no >= 40) |