Slight Changes, mostly fixing CPU error reporting
authorJohn Hodge <[email protected]>
Sat, 6 Mar 2010 14:45:11 +0000 (22:45 +0800)
committerJohn Hodge <[email protected]>
Sat, 6 Mar 2010 14:45:11 +0000 (22:45 +0800)
- Also attempted to fix the Qemu kb bug
- Added a todo to the FDD driver

Kernel/Makefile.BuildNum
Kernel/arch/x86/errors.c
Kernel/drv/kb.c
Modules/Storage/FDD/fdd.c

index 332e1aa..55c6592 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 1511
+BUILD_NUM = 1513
index 8b518f8..cfc7075 100644 (file)
@@ -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);
index aa807b5..92f00a7 100644 (file)
@@ -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");
index 6b55f17..58fb824 100644 (file)
@@ -408,7 +408,8 @@ Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk)
 \r
 /**\r
  * \fn int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer)\r
- * \fn Read a sector from disk\r
+ * \brief Read a sector from disk\r
+ * \todo Make real-hardware safe (account for read errors)\r
 */\r
 int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer)\r
 {\r

UCC git Repository :: git.ucc.asn.au