From 3734bee77d956e4198888b9ea6d454ca993bca77 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 11 Aug 2008 23:03:36 +0000 Subject: [PATCH] When the boot loader goes to load its settings files, it will now also prepend the "kernel" settings file to the safe mode settings if it exists. This allows settings from kernel/drivers/kernel to be respected early in the boot process as well, which allows us to do things like disable_smp permanently instead of having to pick from the safe mode menu every single boot. Review welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26937 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- data/settings/kernel/drivers/kernel | 3 ++ .../boot/loader/load_driver_settings.cpp | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/data/settings/kernel/drivers/kernel b/data/settings/kernel/drivers/kernel index 8505c5076d..e3c5c457d0 100644 --- a/data/settings/kernel/drivers/kernel +++ b/data/settings/kernel/drivers/kernel @@ -1,3 +1,6 @@ +#disable_smp true + # disables multiprocessor support, default is enabled + #serial_debug_output false # disables serial debug output, default is enabled diff --git a/src/system/boot/loader/load_driver_settings.cpp b/src/system/boot/loader/load_driver_settings.cpp index 3595eea5a9..f5cca2d9d3 100644 --- a/src/system/boot/loader/load_driver_settings.cpp +++ b/src/system/boot/loader/load_driver_settings.cpp @@ -1,5 +1,6 @@ /* * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2008, Rene Gollent, rene@gollent.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -17,6 +18,16 @@ #include #include +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) @@ -82,6 +93,34 @@ 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 *kern_file = find_driver_settings_file("kernel"); + if (kern_file != NULL) { + driver_settings_file *safemode_file = + find_driver_settings_file(B_SAFEMODE_DRIVER_SETTINGS); + if (safemode_file != NULL) { + char *tmp_buffer = (char *)kernel_args_malloc( + safemode_file->size + kern_file->size + 1); + if (tmp_buffer != NULL) { + memcpy(tmp_buffer, kern_file->buffer, + kern_file->size); + memcpy(tmp_buffer + kern_file->size, + safemode_file->buffer, + safemode_file->size); + tmp_buffer[safemode_file->size + + kern_file->size] = '\0'; + kernel_args_free(safemode_file->buffer); + safemode_file->buffer = tmp_buffer; + } + } else + add_safe_mode_settings(kern_file->buffer); + } + return B_OK; }