diff --git a/headers/private/kernel/debug.h b/headers/private/kernel/debug.h index e0b4533494..3a7c3aa199 100644 --- a/headers/private/kernel/debug.h +++ b/headers/private/kernel/debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de + * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de * Distributed under the terms of the Haiku License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -34,6 +34,7 @@ extern status_t debug_init_post_modules(struct kernel_args *args); extern void debug_early_boot_message(const char *string); extern void debug_puts(const char *s); extern bool debug_debugger_running(void); +extern void debug_stop_screen_debug_output(void); extern void _user_debug_output(const char *userString); diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 438bb189b0..0c75e69bdd 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -446,6 +446,10 @@ add_safe_mode_menu() platform_add_menus(safeMenu); + safeMenu->AddItem(item = new MenuItem("Enable on screen debug output")); + item->SetData("debug_screen"); + item->SetType(MENU_ITEM_MARKABLE); + safeMenu->AddSeparatorItem(); safeMenu->AddItem(item = new MenuItem("Return to main menu")); diff --git a/src/system/kernel/debug/blue_screen.cpp b/src/system/kernel/debug/blue_screen.cpp index 9bb24c5883..5f10ccd06a 100644 --- a/src/system/kernel/debug/blue_screen.cpp +++ b/src/system/kernel/debug/blue_screen.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -487,9 +487,10 @@ blue_screen_init(void) void -blue_screen_enter(void) +blue_screen_enter(bool debugOutput) { - sScreen.attr = 0x0f; // black on white + sScreen.attr = debugOutput ? 0xf0 : 0x0f; + // black on white for KDL, white on black for debug output sScreen.x = sScreen.y = 0; sScreen.state = CONSOLE_STATE_NORMAL; diff --git a/src/system/kernel/debug/blue_screen.h b/src/system/kernel/debug/blue_screen.h index 28e1338a8c..c0bc906996 100644 --- a/src/system/kernel/debug/blue_screen.h +++ b/src/system/kernel/debug/blue_screen.h @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef BLUE_SCREEN_H @@ -14,7 +14,7 @@ extern "C" { #endif status_t blue_screen_init(void); -void blue_screen_enter(void); +void blue_screen_enter(bool debugOutput); char blue_screen_getchar(void); void blue_screen_putchar(char c); diff --git a/src/system/kernel/debug/debug.c b/src/system/kernel/debug/debug.c index 7722e6bd7f..512b9c2008 100644 --- a/src/system/kernel/debug/debug.c +++ b/src/system/kernel/debug/debug.c @@ -45,6 +45,7 @@ int dbg_register_file[B_MAX_CPU_COUNT][14]; static bool sSerialDebugEnabled = false; static bool sSyslogOutputEnabled = false; static bool sBlueScreenEnabled = false; +static bool sDebugScreenEnabled = false; static bool sBlueScreenOutput = true; static spinlock sSpinlock = 0; static int32 sDebuggerOnCPU = -1; @@ -482,6 +483,9 @@ syslog_write(const char *text, int32 length) static status_t syslog_init_post_threads(void) { + if (!sSyslogOutputEnabled) + return B_OK; + sSyslogNotify = create_sem(0, "syslog data"); if (sSyslogNotify >= B_OK) { thread_id thread = spawn_kernel_thread(syslog_sender, "syslog sender", @@ -543,6 +547,13 @@ err1: // #pragma mark - private kernel API +void +debug_stop_screen_debug_output(void) +{ + sDebugScreenEnabled = false; +} + + bool debug_debugger_running(void) { @@ -606,8 +617,20 @@ debug_init_post_vm(kernel_args *args) unload_driver_settings(handle); } - if (sBlueScreenOutput && blue_screen_init() != B_OK) - sBlueScreenOutput = false; + handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS); + if (handle != NULL) { + sDebugScreenEnabled = get_driver_boolean_parameter(handle, + "debug_screen", false, false); + + unload_driver_settings(handle); + } + + if ((sBlueScreenOutput || sDebugScreenEnabled) + && blue_screen_init() != B_OK) + sBlueScreenOutput = sDebugScreenEnabled = false; + + if (sDebugScreenEnabled) + blue_screen_enter(true); syslog_init(); @@ -734,7 +757,7 @@ kernel_debugger(const char *message) if (sBlueScreenOutput) { sBlueScreenEnabled = true; - blue_screen_enter(); + blue_screen_enter(false); } if (message) @@ -784,7 +807,7 @@ dprintf(const char *format, ...) arch_debug_serial_puts(sOutputBuffer); if (sSyslogOutputEnabled) syslog_write(sOutputBuffer, length); - if (sBlueScreenEnabled) + if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_puts(sOutputBuffer); release_spinlock(&sSpinlock); diff --git a/src/system/kernel/debug/frame_buffer_console.cpp b/src/system/kernel/debug/frame_buffer_console.cpp index e20c18fcdd..016cbd6594 100644 --- a/src/system/kernel/debug/frame_buffer_console.cpp +++ b/src/system/kernel/debug/frame_buffer_console.cpp @@ -1,8 +1,9 @@ /* - * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ + #include #include #include @@ -448,6 +449,8 @@ status_t _user_frame_buffer_update(addr_t baseAddress, int32 width, int32 height, int32 depth, int32 bytesPerRow) { + debug_stop_screen_debug_output(); + if (geteuid() != 0) return B_NOT_ALLOWED; if (IS_USER_ADDRESS(baseAddress) && baseAddress != NULL)