Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / arch / i386 / lib / exception.c
index 5f0c4e0563e64fa152cd3142250961b368a6a5e3..20917b6f4047a58cac6db63b7fc8afe2d92e18cd 100644 (file)
@@ -1,10 +1,10 @@
 #include <console/console.h>
 #include <string.h>
 
-#if CONFIG_GDB_STUB == 1
+#if defined(CONFIG_GDB_STUB) && CONFIG_GDB_STUB == 1
 
 /* BUFMAX defines the maximum number of characters in inbound/outbound buffers.
- * At least NUM_REGBYTES*2 are needed for register packets 
+ * At least NUM_REGBYTES*2 are needed for register packets
  */
 #define BUFMAX 400
 enum regnames {
@@ -62,7 +62,7 @@ static uint32_t gdb_stub_registers[NUM_REGS];
 #define GDB_SIGSOUND     42    /* Sound completed */
 #define GDB_SIGSAK       43    /* Secure attention */
 #define GDB_SIGPRIO      44    /* SIGPRIO */
-                       
+
 #define GDB_SIG33        45    /* Real-time event 33 */
 #define GDB_SIG34        46    /* Real-time event 34 */
 #define GDB_SIG35        47    /* Real-time event 35 */
@@ -359,14 +359,9 @@ static void put_packet(char *buffer)
 }
 #endif /* CONFIG_GDB_STUB */
 
-struct eregs {
-       uint32_t eax, ecx, edx, ebx, esp, ebp, esi, edi;
-       uint32_t vector;
-       uint32_t error_code;
-       uint32_t eip;
-       uint32_t cs;
-       uint32_t eflags;
-};
+#include <arch/registers.h>
+
+void x86_exception(struct eregs *info);
 
 void x86_exception(struct eregs *info)
 {
@@ -377,10 +372,10 @@ void x86_exception(struct eregs *info)
        gdb_stub_registers[CS] = info->cs;
        gdb_stub_registers[PS] = info->eflags;
        signo = GDB_UNKNOWN;
-       if (info->vector < sizeof(exception_to_signal)/sizeof(exception_to_signal[0])) {
+       if (info->vector < ARRAY_SIZE(exception_to_signal)) {
                signo = exception_to_signal[info->vector];
        }
-       
+
        /* reply to the host that an exception has occured */
        out_buffer[0] = 'S';
        out_buffer[1] = hexchars[(signo>>4) & 0xf];
@@ -417,7 +412,7 @@ void x86_exception(struct eregs *info)
                case 'm':
                        /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
                        ptr = &in_buffer[1];
-                       if (    parse_ulong(&ptr, &addr) && 
+                       if (    parse_ulong(&ptr, &addr) &&
                                (*ptr++ == ',') &&
                                parse_ulong(&ptr, &length)) {
                                copy_to_hex(out_buffer, (void *)addr, length);
@@ -428,7 +423,7 @@ void x86_exception(struct eregs *info)
                case 'M':
                        /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
                        ptr = &in_buffer[1];
-                       if (    parse_ulong(&ptr, &addr) && 
+                       if (    parse_ulong(&ptr, &addr) &&
                                (*(ptr++) == ',') &&
                                parse_ulong(&ptr, &length) &&
                                (*(ptr++) == ':')) {
@@ -480,11 +475,11 @@ void x86_exception(struct eregs *info)
                put_packet(out_buffer);
        }
 #else /* !CONFIG_GDB_STUB */
-       printk_emerg(
-               "Unexpected Exception: %d @ %02x:%08lx - Halting\n"
-               "Code: %d eflags: %08lx\n"
-               "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n"
-               "edi: %08lx esi: %08lx ebp: %08lx esp: %08lx\n",
+       printk(BIOS_EMERG,
+               "Unexpected Exception: %d @ %02x:%08x - Halting\n"
+               "Code: %d eflags: %08x\n"
+               "eax: %08x ebx: %08x ecx: %08x edx: %08x\n"
+               "edi: %08x esi: %08x ebp: %08x esp: %08x\n",
                info->vector, info->cs, info->eip,
                info->error_code, info->eflags,
                info->eax, info->ebx, info->ecx, info->edx,