From 5ea23bb0a3c0abdd8494122942c1327e5734d959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 14 Oct 2005 21:22:19 +0000 Subject: [PATCH] Removed platform_boot_device_is_image() again; it's now replaced by a field "booted_from_image" in the kernel_args' boot_disk structure. Also, added fields "cd" and "user_selected". A CHOICE_MENU menu can now have a choice text - this is automatically updated as entries in the menu get selected. The boot volume menu now has the initial choice text "CD-ROM or hard drive" in case the boot loader was loaded from an image. The "Rescan volumes" item is no longer selected by default (only if there was no boot volume found) - but it's still functionless anyway. The TAR fs will now appear as "Boot from CD-ROM" in the boot volume menu. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14388 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/kernel_args.h | 3 +++ headers/private/kernel/boot/menu.h | 4 +++ headers/private/kernel/boot/platform.h | 1 - .../boot/loader/file_systems/tarfs/tarfs.cpp | 2 +- src/system/boot/loader/loader.cpp | 2 +- src/system/boot/loader/menu.cpp | 26 ++++++++++++++++--- src/system/boot/loader/partitions.cpp | 5 ++-- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/headers/private/kernel/boot/kernel_args.h b/headers/private/kernel/boot/kernel_args.h index dce0e38dea..5a9a11f550 100644 --- a/headers/private/kernel/boot/kernel_args.h +++ b/headers/private/kernel/boot/kernel_args.h @@ -47,6 +47,9 @@ typedef struct kernel_args { struct { disk_identifier identifier; off_t partition_offset; + bool user_selected; + bool booted_from_image; + bool cd; } boot_disk; struct driver_settings_file *driver_settings; diff --git a/headers/private/kernel/boot/menu.h b/headers/private/kernel/boot/menu.h index 0d5cfe8eac..49e7b37253 100644 --- a/headers/private/kernel/boot/menu.h +++ b/headers/private/kernel/boot/menu.h @@ -108,6 +108,9 @@ class Menu { const char *Title() const { return fTitle; } + void SetChoiceText(const char *text) { fChoiceText = text; } + const char *ChoiceText() const { return fChoiceText; } + void Run(); private: @@ -115,6 +118,7 @@ class Menu { void Draw(MenuItem *item); const char *fTitle; + const char *fChoiceText; int32 fCount; bool fIsHidden; MenuItemList fItems; diff --git a/headers/private/kernel/boot/platform.h b/headers/private/kernel/boot/platform.h index 729802bea5..3725cf2348 100644 --- a/headers/private/kernel/boot/platform.h +++ b/headers/private/kernel/boot/platform.h @@ -58,7 +58,6 @@ extern status_t platform_add_block_devices(struct stage2_args *args, NodeList *d extern status_t platform_get_boot_partition(struct stage2_args *args, Node *bootDevice, NodeList *partitions, boot::Partition **_partition); extern status_t platform_register_boot_device(Node *device); -extern bool platform_boot_device_is_image(); /* menu functions */ diff --git a/src/system/boot/loader/file_systems/tarfs/tarfs.cpp b/src/system/boot/loader/file_systems/tarfs/tarfs.cpp index ebe452a449..c3020cacf7 100644 --- a/src/system/boot/loader/file_systems/tarfs/tarfs.cpp +++ b/src/system/boot/loader/file_systems/tarfs/tarfs.cpp @@ -484,7 +484,7 @@ TarFS::Directory::Inode() const TarFS::Volume::Volume() - : TarFS::Directory("CD/Floppy Boot Disk") + : TarFS::Directory("Boot from CD-ROM") { } diff --git a/src/system/boot/loader/loader.cpp b/src/system/boot/loader/loader.cpp index 4ef15c19bd..afb7ba10d9 100644 --- a/src/system/boot/loader/loader.cpp +++ b/src/system/boot/loader/loader.cpp @@ -187,7 +187,7 @@ load_modules(stage2_args *args, Directory *volume) // and now load all partitioning and file system modules // needed to identify the boot volume - if (!platform_boot_device_is_image()) { + if (!gKernelArgs.boot_disk.booted_from_image) { // iterate over the mounted volumes and load their file system Partition *partition; if (gRoot->GetPartitionFor(volume, &partition) == B_OK) { diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 6be14e3227..46a731be37 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -76,12 +76,24 @@ MenuItem::SetMarked(bool marked) } -void MenuItem::Select(bool selected) { if (fIsSelected == selected) return; +void +MenuItem::Select(bool selected) +{ + if (selected && fMenu != NULL) { + // always set choice text of parent if we were selected + if (fMenu->Type() == CHOICE_MENU && Type() != MENU_ITEM_NO_CHOICE) + fMenu->SetChoiceText(Label()); + } + + if (fIsSelected == selected) + return; if (selected && fMenu != NULL) { // unselect previous item - MenuItem *selectedItem = fMenu->FindSelected(); if (selectedItem != - NULL) selectedItem->Select(false); } + MenuItem *selectedItem = fMenu->FindSelected(); + if (selectedItem != NULL) + selectedItem->Select(false); + } fIsSelected = selected; @@ -144,6 +156,7 @@ MenuItem::SetMenu(Menu *menu) Menu::Menu(menu_type type, const char *title) : fTitle(title), + fChoiceText(NULL), fCount(0), fIsHidden(true), fType(type), @@ -342,6 +355,7 @@ user_menu_boot_volume(Menu *menu, MenuItem *item) bootItem->Select(true); bootItem->SetData(item->Data()); + gKernelArgs.boot_disk.user_selected = true; return true; } @@ -390,11 +404,15 @@ add_boot_volume_menu(Directory *bootVolume) menu->AddItem(item = new MenuItem("Rescan volumes")); item->SetHelpText("Please insert a Haiku CD-ROM or attach a USB disk - depending on your system, you can then boot from them."); item->SetType(MENU_ITEM_NO_CHOICE); - item->Select(true); + if (count == 0) + item->Select(true); menu->AddItem(item = new MenuItem("Return to main menu")); item->SetType(MENU_ITEM_NO_CHOICE); + if (gKernelArgs.boot_disk.booted_from_image) + menu->SetChoiceText("CD-ROM or hard drive"); + return menu; } diff --git a/src/system/boot/loader/partitions.cpp b/src/system/boot/loader/partitions.cpp index 58dd4693b0..fa539e753d 100644 --- a/src/system/boot/loader/partitions.cpp +++ b/src/system/boot/loader/partitions.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -206,7 +207,7 @@ Partition::_Mount(file_system_module_info *module, Directory **_fileSystem) status_t Partition::Mount(Directory **_fileSystem, bool isBootDevice) { - if (isBootDevice && platform_boot_device_is_image()) + if (isBootDevice && gKernelArgs.boot_disk.booted_from_image) return _Mount(&gTarFileSystemModule, _fileSystem); for (int32 i = 0; i < sNumFileSystemModules; i++) { @@ -229,7 +230,7 @@ Partition::Scan(bool mountFileSystems, bool isBootDevice) // if we were not booted from the real boot device, we won't scan // the device we were booted from (which is likely to be a slow // floppy or CD) - if (isBootDevice && platform_boot_device_is_image()) + if (isBootDevice && gKernelArgs.boot_disk.booted_from_image) return B_ENTRY_NOT_FOUND; const partition_module_info *bestModule = NULL;