From: John Hodge Date: Sat, 6 Mar 2010 14:45:11 +0000 (+0800) Subject: Slight Changes, mostly fixing CPU error reporting X-Git-Tag: rel0.06~285 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a0f4dde15a97a206bf88109fecde52576b373109;p=tpg%2Facess2.git Slight Changes, mostly fixing CPU error reporting - Also attempted to fix the Qemu kb bug - Added a todo to the FDD driver --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index 332e1aa5..55c6592d 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1511 +BUILD_NUM = 1513 diff --git a/Kernel/arch/x86/errors.c b/Kernel/arch/x86/errors.c index 8b518f87..cfc70753 100644 --- a/Kernel/arch/x86/errors.c +++ b/Kernel/arch/x86/errors.c @@ -16,6 +16,18 @@ extern void Threads_Dump(); // === PROTOTYPES === void Error_Backtrace(Uint eip, Uint ebp); +// === GLOBALS === +const char *csaERROR_NAMES[] = { + "Divide By Zero", "Debug", "NMI Exception", "INT3", + "INTO", "Out of Bounds", "Invalid Opcode", "Coprocessor not avaliable", + "Double Fault", "Coprocessor Segment Overrun", "Bad TSS", "Segment Not Present", + "Stack Fault Exception", "GPF", "#PF", "Reserved", + "Floating Point Exception", "Alignment Check Exception", "Machine Check Exception", "Reserved", + "Reserved", "Reserved", "Reserved", "Reserved", + "Reserved", "Reserved", "Reserved", "Reserved", + "Reserved", "Reserved", "Reserved", "Reserved" + }; + // === CODE === void __stack_chk_fail() { @@ -39,24 +51,34 @@ void ErrorHandler(tRegs *Regs) return ; } - Warning("CPU Error %i, Code: 0x%x", Regs->int_num, Regs->err_code); + Warning("CPU Error %i - %s, Code: 0x%x", + Regs->int_num, csaERROR_NAMES[Regs->int_num], Regs->err_code); Warning(" CS:EIP = 0x%04x:%08x", Regs->cs, Regs->eip); Warning(" SS:ESP = 0x%04x:%08x", Regs->ss, Regs->esp); Warning(" EFLAGS = 0x%08x", Regs->eflags); - Warning(" EAX %08x EBX %08x", Regs->eax, Regs->ebx); - Warning(" ECX %08x EDX %08x", Regs->ecx, Regs->edx); - Warning(" ESP %08x EBP %08x", Regs->esp, Regs->ebp); - Warning(" ESI %08x EDI %08x", Regs->esi, Regs->edi); - Warning(" DS %04x ES %04x", Regs->ds, Regs->es); - Warning(" FS %04x GS %04x", Regs->fs, Regs->gs); + Warning(" EAX %08x ECX %08x EDX %08x EBX %08x", + Regs->eax, Regs->ecx, Regs->edx, Regs->ebx); + Warning(" ESP %08x EBP %08x ESI %08x EDI %08x", + Regs->esp, Regs->ebp, Regs->esi, Regs->edi); + Warning(" DS %04x ES %04x FS %04x GS %04x", + Regs->ds, Regs->es, Regs->fs, Regs->gs); // Control Registers __asm__ __volatile__ ("mov %%cr0, %0":"=r"(cr)); - Warning(" CR0: 0x%08x", cr); + Warning(" CR0 0x%08x", cr); __asm__ __volatile__ ("mov %%cr2, %0":"=r"(cr)); - Warning(" CR2: 0x%08x", cr); + Warning(" CR2 0x%08x", cr); __asm__ __volatile__ ("mov %%cr3, %0":"=r"(cr)); - Warning(" CR3: 0x%08x", cr); + Warning(" CR3 0x%08x", cr); + + switch( Regs->int_num ) + { + case 6: + Warning(" Offending bytes: %02x %02x %02x %02x", + *(Uint8*)Regs->eip+0, *(Uint8*)Regs->eip+1, + *(Uint8*)Regs->eip+2, *(Uint8*)Regs->eip+3); + break; + } // Print Stack Backtrace Error_Backtrace(Regs->eip, Regs->ebp); diff --git a/Kernel/drv/kb.c b/Kernel/drv/kb.c index aa807b53..92f00a72 100644 --- a/Kernel/drv/kb.c +++ b/Kernel/drv/kb.c @@ -56,6 +56,14 @@ Uint8 gbaKB_States[3][256]; */ int KB_Install(char **Arguments) { + Uint8 temp; + + // Attempt to get around a strange bug in Bochs/Qemu by toggling + // the controller on and off + temp = inb(0x61); + outb(0x61, temp | 0x80); + outb(0x61, temp & 0x7F); + IRQ_AddHandler(1, KB_IRQHandler); DevFS_AddDevice( &gKB_DevInfo ); //Log("KB_Install: Installed"); diff --git a/Modules/Storage/FDD/fdd.c b/Modules/Storage/FDD/fdd.c index 6b55f17b..58fb8246 100644 --- a/Modules/Storage/FDD/fdd.c +++ b/Modules/Storage/FDD/fdd.c @@ -408,7 +408,8 @@ Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk) /** * \fn int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer) - * \fn Read a sector from disk + * \brief Read a sector from disk + * \todo Make real-hardware safe (account for read errors) */ int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer) {