summaryrefslogtreecommitdiff
path: root/Source/Kernel/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/Core')
-rw-r--r--Source/Kernel/Core/Sys.ns.cpp25
-rw-r--r--Source/Kernel/Core/Sys.ns.h14
-rw-r--r--Source/Kernel/Core/common.wtf.h11
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp8
4 files changed, 43 insertions, 15 deletions
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...");