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;