Added driver_settings support.
It will now load all settings in the kernel driver settings directory and pass them over to the kernel (unparsed). Additionally, it allows other parts of the boot loader to access driver_settings just like in the kernel. Moved the switch to the logo in the boot loader much further to the end of the boot loader's life cycle. This is done so that the boot loader can directly use the video mode as configured in Haiku, without a jumping logo. Since the delay will be noticeable on a real system, we might want to introduce a second different boot logo, though. We'll see. stdio.cpp now also exports errno (and _errnop). Might be changed to a different approach later as well (it's now done this way so that strtol.o can be taken over unchanged from libroot.so). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10634 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -36,6 +36,10 @@ KernelStaticLibrary boot_loader :
|
||||
menu.cpp
|
||||
loader.cpp
|
||||
kernel_args.cpp
|
||||
load_driver_settings.cpp
|
||||
|
||||
# libroot
|
||||
driver_settings.c
|
||||
|
||||
# utils
|
||||
list.c
|
||||
@@ -60,6 +64,9 @@ KernelStaticLibrary boot_partitions :
|
||||
SEARCH on [ FGristFiles kernel_cpp.cpp list.c ]
|
||||
= [ FDirName $(OBOS_TOP) src kernel core util ] ;
|
||||
|
||||
SEARCH on [ FGristFiles driver_settings.c ]
|
||||
= [ FDirName $(OBOS_TOP) src kernel libroot os ] ;
|
||||
|
||||
SEARCH on [ FGristFiles amiga_rdb.cpp ]
|
||||
= [ FDirName $(OBOS_TOP) src add-ons kernel partitioning_systems amiga ] ;
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "load_driver_settings.h"
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <boot/driver_settings.h>
|
||||
#include <boot/kernel_args.h>
|
||||
#include <boot/stage2.h>
|
||||
#include <boot/platform.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static status_t
|
||||
load_driver_settings_file(Directory *directory, const char *name)
|
||||
{
|
||||
int fd = open_from(directory, name, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
struct stat stat;
|
||||
fstat(fd, &stat);
|
||||
|
||||
char *buffer = (char *)kernel_args_malloc(stat.st_size + 1);
|
||||
if (buffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (read(fd, buffer, stat.st_size) != stat.st_size)
|
||||
return B_IO_ERROR;
|
||||
|
||||
driver_settings_file *file = (driver_settings_file *)kernel_args_malloc(sizeof(driver_settings_file));
|
||||
if (file == NULL) {
|
||||
kernel_args_free(buffer);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
buffer[stat.st_size] = '\0';
|
||||
// null terminate the buffer
|
||||
|
||||
strlcpy(file->name, name, sizeof(file->name));
|
||||
file->buffer = buffer;
|
||||
file->size = stat.st_size;
|
||||
|
||||
// add it to the list
|
||||
file->next = gKernelArgs.driver_settings;
|
||||
gKernelArgs.driver_settings = file;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
load_driver_settings(stage2_args */*args*/, Directory *volume)
|
||||
{
|
||||
int fd = open_from(volume, "home/config/settings/kernel/drivers", O_RDONLY);
|
||||
if (fd < B_OK)
|
||||
return fd;
|
||||
|
||||
Directory *settings = (Directory *)get_node_from(fd);
|
||||
if (settings == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
void *cookie;
|
||||
if (settings->Open(&cookie, O_RDONLY) == B_OK) {
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
while (settings->GetNextEntry(cookie, name, sizeof(name)) == B_OK) {
|
||||
if (!strcmp(name, ".") || !strcmp(name, ".."))
|
||||
continue;
|
||||
|
||||
status_t status = load_driver_settings_file(settings, name);
|
||||
if (status != B_OK)
|
||||
dprintf("Could not load \"%s\" error %ld\n", name, status);
|
||||
}
|
||||
|
||||
settings->Close(cookie);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef LOAD_DRIVER_SETTINGS_H
|
||||
#define LOAD_DRIVER_SETTINGS_H
|
||||
|
||||
|
||||
#include <boot/vfs.h>
|
||||
|
||||
|
||||
extern status_t load_driver_settings(stage2_args *args, Directory *volume);
|
||||
|
||||
#endif /* LOAD_DRIVER_SETTINGS_H */
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the Haiku License.
|
||||
*/
|
||||
* Copyright 2003-2005, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "menu.h"
|
||||
#include "loader.h"
|
||||
#include "load_driver_settings.h"
|
||||
|
||||
#include <boot/stage2.h>
|
||||
#include <boot/vfs.h>
|
||||
@@ -35,8 +36,6 @@ main(stage2_args *args)
|
||||
TRACE(("boot(): heap initialized...\n"));
|
||||
|
||||
platform_init_video();
|
||||
if ((platform_boot_options() & (BOOT_OPTION_DEBUG_OUTPUT | BOOT_OPTION_MENU)) == 0)
|
||||
platform_switch_to_logo();
|
||||
|
||||
// the main platform dependent initialisation
|
||||
// has already taken place at this point.
|
||||
@@ -97,7 +96,12 @@ main(stage2_args *args)
|
||||
// know our boot volume, too
|
||||
if (status == B_OK) {
|
||||
register_boot_file_system(volume);
|
||||
|
||||
if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) == 0)
|
||||
platform_switch_to_logo();
|
||||
|
||||
load_modules(args, volume);
|
||||
load_driver_settings(args, volume);
|
||||
|
||||
// set up kernel args version info
|
||||
gKernelArgs.kernel_args_size = sizeof(kernel_args);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2003-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <boot/vfs.h>
|
||||
@@ -16,6 +16,9 @@
|
||||
//extern FILE *stdout;
|
||||
//extern FILE *stdin;
|
||||
|
||||
int errno;
|
||||
int *_errnop = &errno;
|
||||
|
||||
|
||||
int
|
||||
vfprintf(FILE *file, const char *format, va_list list)
|
||||
|
||||
Reference in New Issue
Block a user