* Added option for enabling serial debug output.

* Moved device_manager/settings.cpp to debug/safemode_settings.cpp.
* Removed the somewhat hacky concatenation of kernel settings and safemode
  settings in the boot loader. Instead, get_safemode_option() will now fall
  back to the kernel settings, if it couldn't spot a setting in the safemode
  settings. This allows for more control, and also makes enabling serial
  debug output actually work (ie. overriding the kernel settings via safemode
  options).
* Adjusted debug_init_post_vm(), and smp_init_other_cpus() to use
  get_safemode_boolean().
* Therefore, I added safemode_settings.cpp to the boot loader as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32685 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-26 08:47:54 +00:00
parent e17f8de82d
commit 89294b5084
8 changed files with 82 additions and 106 deletions

View File

@ -69,6 +69,7 @@ KernelStaticLibrary boot_loader :
kernel_cpp.cpp
KMessage.cpp
list.c
safemode_settings.cpp
: -fno-pic
;
@ -94,6 +95,9 @@ SEARCH on [ FGristFiles kernel_cpp.cpp list.c ]
SEARCH on [ FGristFiles KMessage.cpp ]
= [ FDirName $(HAIKU_TOP) src system kernel messaging ] ;
SEARCH on [ FGristFiles safemode_settings.cpp ]
= [ FDirName $(HAIKU_TOP) src system kernel debug ] ;
SEARCH on [ FGristFiles driver_settings.c ]
= [ FDirName $(HAIKU_TOP) src system libroot os ] ;

View File

@ -7,6 +7,9 @@
#include "load_driver_settings.h"
#include <string.h>
#include <unistd.h>
#include <OS.h>
#include <drivers/driver_settings.h>
@ -15,22 +18,6 @@
#include <boot/stage2.h>
#include <boot/platform.h>
#include <string.h>
#include <unistd.h>
static driver_settings_file*
find_driver_settings_file(const char* name)
{
for (driver_settings_file* file = gKernelArgs.driver_settings; file != NULL;
file = file->next) {
if (!strcmp(file->name, name))
return file;
}
return NULL;
}
static status_t
load_driver_settings_file(Directory* directory, const char* name)
@ -100,38 +87,6 @@ load_driver_settings(stage2_args* /*args*/, Directory* volume)
settings->Close(cookie);
}
// Check if a kernel settings file exists
// if it does, prepend it to the safe mode settings. This allows the
// settings from the kernel file to take effect while still allowing
// overrides by safe mode since the settings are searched
// in reverse order. This allows us to permanently set things like
// disable_smp
driver_settings_file* kernelFile = find_driver_settings_file("kernel");
if (kernelFile != NULL) {
driver_settings_file* safemodeFile
= find_driver_settings_file(B_SAFEMODE_DRIVER_SETTINGS);
if (safemodeFile != NULL) {
char* buffer = (char*)kernel_args_malloc(
safemodeFile->size + kernelFile->size + 2);
if (buffer != NULL) {
memcpy(buffer, kernelFile->buffer, kernelFile->size);
// insert a newline just in case the kernel settings file
// doesn't end with one
buffer[kernelFile->size] = '\n';
memcpy(buffer + kernelFile->size + 1, safemodeFile->buffer,
safemodeFile->size);
kernel_args_free(safemodeFile->buffer);
safemodeFile->buffer = buffer;
safemodeFile->size = safemodeFile->size + kernelFile->size + 1;
buffer[safemodeFile->size] = '\0';
}
} else
add_safe_mode_settings(kernelFile->buffer);
}
return B_OK;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@ -21,6 +21,7 @@
#include <string.h>
#define TRACE_MENU
#ifdef TRACE_MENU
# define TRACE(x) dprintf x
@ -28,6 +29,7 @@
# define TRACE(x) ;
#endif
MenuItem::MenuItem(const char *label, Menu *subMenu)
:
fLabel(strdup(label)),
@ -154,7 +156,7 @@ MenuItem::SetHelpText(const char *text)
}
void
void
MenuItem::SetMenu(Menu *menu)
{
fMenu = menu;
@ -206,7 +208,7 @@ Menu::ItemAt(int32 index)
}
int32
int32
Menu::IndexOf(MenuItem *searchedItem)
{
MenuItemIterator iterator = ItemIterator();
@ -452,10 +454,18 @@ add_safe_mode_menu()
item->SetType(MENU_ITEM_MARKABLE);
item->SetHelpText("Disables IDE DMA, increasing IDE compatibilty "
"at the expense of performance.");
platform_add_menus(safeMenu);
safeMenu->AddItem(item = new(nothrow) MenuItem("Enable on screen debug output"));
safeMenu->AddItem(item
= new(nothrow) MenuItem("Enable serial debug output"));
item->SetData("serial_debug_output");
item->SetType(MENU_ITEM_MARKABLE);
item->SetHelpText("Turns on forwarding the syslog output to the serial "
"interface.");
safeMenu->AddItem(item
= new(nothrow) MenuItem("Enable on screen debug output"));
item->SetData("debug_screen");
item->SetType(MENU_ITEM_MARKABLE);
item->SetHelpText("Displays debug output on screen while the system "

View File

@ -9,9 +9,8 @@
#include "smp.h"
#include "mmu.h"
#include "acpi.h"
#include "hpet.h"
#include <string.h>
#include <KernelExport.h>
@ -23,7 +22,10 @@
#include <arch/x86/arch_apic.h>
#include <arch/x86/arch_system_info.h>
#include <string.h>
#include "mmu.h"
#include "acpi.h"
#include "hpet.h"
#define NO_SMP 0
@ -386,15 +388,10 @@ calculate_apic_timer_conversion_factor(void)
void
smp_init_other_cpus(void)
{
void *handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
if (handle != NULL) {
if (get_driver_boolean_parameter(handle, B_SAFEMODE_DISABLE_SMP, false,
false)) {
// SMP has been disabled!
TRACE(("smp disabled per safemode setting\n"));
gKernelArgs.num_cpus = 1;
}
unload_driver_settings(handle);
if (get_safemode_boolean(B_SAFEMODE_DISABLE_SMP, false)) {
// SMP has been disabled!
TRACE(("smp disabled per safemode setting\n"));
gKernelArgs.num_cpus = 1;
}
if (gKernelArgs.arch_args.apic_phys == 0)
@ -573,7 +570,6 @@ dprintf("wait for delivery\n");
void
smp_add_safemode_menus(Menu *menu)
{
if (gKernelArgs.num_cpus < 2)
return;

View File

@ -17,6 +17,7 @@ KernelMergeObject kernel_debug.o :
debug_variables.cpp
frame_buffer_console.cpp
gdb.cpp
safemode_settings.cpp
system_profiler.cpp
tracing.cpp
user_debugger.cpp

View File

@ -22,6 +22,7 @@
#include <int.h>
#include <kernel.h>
#include <ksystem_info.h>
#include <safemode.h>
#include <smp.h>
#include <thread.h>
#include <tracing.h>
@ -1299,27 +1300,15 @@ debug_init_post_vm(kernel_args* args)
tracing_init();
// get debug settings
void* handle = load_driver_settings("kernel");
if (handle != NULL) {
sSerialDebugEnabled = get_driver_boolean_parameter(handle,
"serial_debug_output", sSerialDebugEnabled, sSerialDebugEnabled);
sSyslogOutputEnabled = get_driver_boolean_parameter(handle,
"syslog_debug_output", sSyslogOutputEnabled, sSyslogOutputEnabled);
sBlueScreenOutput = get_driver_boolean_parameter(handle,
"bluescreen", true, true);
sEmergencyKeysEnabled = get_driver_boolean_parameter(handle,
"emergency_keys", sEmergencyKeysEnabled, sEmergencyKeysEnabled);
unload_driver_settings(handle);
}
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);
}
sSerialDebugEnabled = get_safemode_boolean("serial_debug_output",
sSerialDebugEnabled);
sSyslogOutputEnabled = get_safemode_boolean("syslog_debug_output",
sSyslogOutputEnabled);
sBlueScreenOutput = get_safemode_boolean("bluescreen", true);
sEmergencyKeysEnabled = get_safemode_boolean("emergency_keys",
sEmergencyKeysEnabled);
sDebugScreenEnabled = get_safemode_boolean("debug_screen", false);
if ((sBlueScreenOutput || sDebugScreenEnabled)
&& blue_screen_init() != B_OK)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@ -14,27 +14,44 @@
extern "C" status_t
get_safemode_option(const char *parameter, char *buffer, size_t *_bufferSize)
get_safemode_option(const char* parameter, char* buffer, size_t* _bufferSize)
{
void *handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
if (handle == NULL)
return B_ENTRY_NOT_FOUND;
status_t status = B_ENTRY_NOT_FOUND;
const char *value = get_driver_parameter(handle, parameter, NULL, NULL);
if (value != NULL) {
*_bufferSize = strlcpy(buffer, value, *_bufferSize);
status = B_OK;
void* handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
if (handle != NULL) {
status = B_NAME_NOT_FOUND;
const char* value = get_driver_parameter(handle, parameter, NULL, NULL);
if (value != NULL) {
*_bufferSize = strlcpy(buffer, value, *_bufferSize);
status = B_OK;
}
unload_driver_settings(handle);
}
if (status != B_OK) {
// Try kernel settings file as a fall back
handle = load_driver_settings("kernel");
if (handle != NULL) {
const char* value = get_driver_parameter(handle, parameter, NULL,
NULL);
if (value != NULL) {
*_bufferSize = strlcpy(buffer, value, *_bufferSize);
status = B_OK;
}
unload_driver_settings(handle);
}
}
unload_driver_settings(handle);
return status;
}
extern "C" bool
get_safemode_boolean(const char *parameter, bool defaultValue)
get_safemode_boolean(const char* parameter, bool defaultValue)
{
char value[16];
size_t length = sizeof(value);
@ -48,12 +65,15 @@ get_safemode_boolean(const char *parameter, bool defaultValue)
}
// #pragma mark -
// #pragma mark - syscalls
#ifndef _BOOT_MODE
extern "C" status_t
_user_get_safemode_option(const char *userParameter, char *userBuffer,
size_t *_userBufferSize)
_user_get_safemode_option(const char* userParameter, char* userBuffer,
size_t* _userBufferSize)
{
char parameter[B_FILE_NAME_LENGTH];
char buffer[B_PATH_NAME_LENGTH];
@ -61,7 +81,7 @@ _user_get_safemode_option(const char *userParameter, char *userBuffer,
if (!IS_USER_ADDRESS(userParameter) || !IS_USER_ADDRESS(userBuffer)
|| !IS_USER_ADDRESS(_userBufferSize)
|| user_memcpy(&bufferSize, _userBufferSize, sizeof(size_t)) < B_OK
|| user_memcpy(&bufferSize, _userBufferSize, sizeof(size_t)) != B_OK
|| user_strlcpy(parameter, userParameter, B_FILE_NAME_LENGTH) < B_OK)
return B_BAD_ADDRESS;
@ -74,8 +94,11 @@ _user_get_safemode_option(const char *userParameter, char *userBuffer,
if (status == B_OK
&& (user_strlcpy(userBuffer, buffer, originalBufferSize) < B_OK
|| user_memcpy(_userBufferSize, &bufferSize, sizeof(size_t))
< B_OK))
!= B_OK))
return B_BAD_ADDRESS;
return status;
}
#endif // !_BOOT_MODE

View File

@ -11,8 +11,6 @@ KernelMergeObject kernel_device_manager.o :
io_resources.cpp
IOScheduler.cpp
legacy_drivers.cpp
# probe.cpp
settings.cpp
dma_resources.cpp
io_requests.cpp