From 3ae3b04bce8c481442bd3ff42c6d57d1417374c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 27 Nov 2007 12:59:34 +0000 Subject: [PATCH] * The boot loader (bios_ia32 only) now duplicates everything that goes to the serial output, and puts it into the new kernel_args::debug_output field. * syslog_init() will now check if there is anything in kernel_args::debug_output and will put that into the syslog buffer. * dump_block() now also prints an offset. * Fixed warning in mmu.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23003 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/kernel_args.h | 5 +++- src/system/boot/platform/bios_ia32/debug.c | 7 +++--- src/system/boot/platform/bios_ia32/mmu.cpp | 2 +- src/system/boot/platform/bios_ia32/serial.cpp | 24 ++++++++++++++++++- src/system/boot/platform/bios_ia32/serial.h | 7 +++--- src/system/boot/platform/bios_ia32/start.c | 1 + src/system/kernel/debug/debug.c | 11 +++++---- 7 files changed, 43 insertions(+), 14 deletions(-) diff --git a/headers/private/kernel/boot/kernel_args.h b/headers/private/kernel/boot/kernel_args.h index 0b3a67eab9..e636cf7c82 100644 --- a/headers/private/kernel/boot/kernel_args.h +++ b/headers/private/kernel/boot/kernel_args.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -70,6 +70,9 @@ typedef struct kernel_args { addr_range physical_buffer; } frame_buffer; + void *debug_output; + uint32 debug_size; + platform_kernel_args platform_args; arch_kernel_args arch_args; } kernel_args; diff --git a/src/system/boot/platform/bios_ia32/debug.c b/src/system/boot/platform/bios_ia32/debug.c index a4093f7162..79c8cc3e8c 100644 --- a/src/system/boot/platform/bios_ia32/debug.c +++ b/src/system/boot/platform/bios_ia32/debug.c @@ -1,5 +1,5 @@ /* - * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -12,9 +12,8 @@ #include -/** This works only after console_init() was called. - */ - +/*! This works only after console_init() was called. +*/ void panic(const char *format, ...) { diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index 028de3af28..2cb865cbb9 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -393,7 +393,7 @@ mmu_free(void *virtualAddress, size_t size) if (address < KERNEL_BASE || address + size >= KERNEL_BASE + kMaxKernelSize) { panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n", - address, size); + (void *)address, size); } // unmap all pages within the range diff --git a/src/system/boot/platform/bios_ia32/serial.cpp b/src/system/boot/platform/bios_ia32/serial.cpp index c56897c009..621b2f3d5f 100644 --- a/src/system/boot/platform/bios_ia32/serial.cpp +++ b/src/system/boot/platform/bios_ia32/serial.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -34,6 +34,9 @@ static const uint32 kSerialBaudRate = 115200; static int32 sSerialEnabled = 0; static uint16 sSerialBasePort = 0x3f8; +static char sBuffer[4096]; +static uint32 sBufferPosition; + static void serial_putc(char c) @@ -52,6 +55,11 @@ serial_puts(const char *string, size_t size) if (sSerialEnabled <= 0) return; + if (sBufferPosition + size < sizeof(sBuffer)) { + memcpy(sBuffer + sBufferPosition, string, size); + sBufferPosition += size; + } + while (size-- != 0) { char c = string[0]; @@ -84,6 +92,20 @@ serial_enable(void) } +extern "C" void +serial_cleanup(void) +{ + if (sSerialEnabled <= 0) + return; + + gKernelArgs.debug_output = kernel_args_malloc(sBufferPosition); + if (gKernelArgs.debug_output != NULL) { + memcpy(gKernelArgs.debug_output, sBuffer, sBufferPosition); + gKernelArgs.debug_size = sBufferPosition; + } +} + + extern "C" void serial_init(void) { diff --git a/src/system/boot/platform/bios_ia32/serial.h b/src/system/boot/platform/bios_ia32/serial.h index 9ae022c468..5db0789eda 100644 --- a/src/system/boot/platform/bios_ia32/serial.h +++ b/src/system/boot/platform/bios_ia32/serial.h @@ -1,7 +1,7 @@ /* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef SERIAL_H #define SERIAL_H @@ -14,6 +14,7 @@ extern "C" { #endif extern void serial_init(void); +extern void serial_cleanup(void); extern void serial_puts(const char *string, size_t size); diff --git a/src/system/boot/platform/bios_ia32/start.c b/src/system/boot/platform/bios_ia32/start.c index e9b9d30249..09c78411d2 100644 --- a/src/system/boot/platform/bios_ia32/start.c +++ b/src/system/boot/platform/bios_ia32/start.c @@ -75,6 +75,7 @@ platform_start_kernel(void) // or I don't see something important... addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; + serial_cleanup(); mmu_init_for_kernel(); smp_boot_other_cpus(); diff --git a/src/system/kernel/debug/debug.c b/src/system/kernel/debug/debug.c index dabb27adde..3ac76c600a 100644 --- a/src/system/kernel/debug/debug.c +++ b/src/system/kernel/debug/debug.c @@ -6,7 +6,7 @@ * Distributed under the terms of the NewOS License. */ -/* This file contains the debugger */ +/*! This file contains the debugger and debug output facilities */ #include "blue_screen.h" #include "gdb.h" @@ -602,7 +602,7 @@ syslog_init_post_threads(void) static status_t -syslog_init(void) +syslog_init(struct kernel_args *args) { status_t status; @@ -628,6 +628,9 @@ syslog_init(void) sSyslogMessage->ident[0] = '\0'; //strcpy(sSyslogMessage->ident, "KERNEL"); + if (args->debug_output != NULL) + syslog_write(args->debug_output, args->debug_size); + return B_OK; err3: @@ -748,7 +751,7 @@ debug_init_post_vm(kernel_args *args) if (sDebugScreenEnabled) blue_screen_enter(true); - syslog_init(); + syslog_init(args); return arch_debug_init(args); } @@ -1101,7 +1104,7 @@ dump_block(const char *buffer, int size, const char *prefix) for (i = 0; i < size;) { int start = i; - dprintf(prefix); + dprintf("%s%04x ", prefix, i); for (; i < start + DUMPED_BLOCK_SIZE; i++) { if (!(i % 4)) dprintf(" ");