diff --git a/src/system/boot/platform/bios_ia32/devices.cpp b/src/system/boot/platform/bios_ia32/devices.cpp index cbbc2303e3..cdf70b93b5 100644 --- a/src/system/boot/platform/bios_ia32/devices.cpp +++ b/src/system/boot/platform/bios_ia32/devices.cpp @@ -4,6 +4,7 @@ */ +#include "devices.h" #include "bios.h" #include @@ -22,7 +23,7 @@ // exported from shell.S -extern uint8 gCDFloppyBoot; +extern uint8 gBootedFromImage; extern uint8 gBootDriveID; extern uint32 gBootPartitionOffset; @@ -114,6 +115,16 @@ struct device_table { uint8 lba_enabled : 1; } _PACKED; +struct specification_packet { + uint8 size; + uint8 media_type; + uint8 drive_number; + uint8 controller_index; + uint32 start_emulation; + uint16 device_specification; + uint8 _more_[9]; +} _PACKED; + class BIOSDrive : public Node { public: BIOSDrive(uint8 driveID); @@ -479,6 +490,45 @@ BIOSDrive::Size() const // #pragma mark - +extern "C" void +devices_check_cd_boot(void) +{ + gKernelArgs.boot_disk.cd = false; + + if (gBootDriveID != 0) + return; + + struct bios_regs regs; + regs.eax = 0x4b00; + regs.edx = 0; + regs.esi = kDataSegmentScratch; + call_bios(0x13, ®s); + + if ((regs.flags & CARRY_FLAG) != 0) + return; + + // we obviously were booted from CD! + + specification_packet *packet = (specification_packet *)kDataSegmentScratch; + + if (packet->media_type != 0) + gKernelArgs.boot_disk.cd = false; + +#if 0 + dprintf("got CD boot spec:\n"); + dprintf(" size: %#x\n", packet->size); + dprintf(" media type: %u\n", packet->media_type); + dprintf(" drive_number: %u\n", packet->drive_number); + dprintf(" controller index: %u\n", packet->controller_index); + dprintf(" start emulation: %lu\n", packet->start_emulation); + dprintf(" device_specification: %u\n", packet->device_specification); +#endif +} + + +// #pragma mark - + + status_t platform_get_boot_device(struct stage2_args *args, Node **_device) { @@ -491,6 +541,7 @@ platform_get_boot_device(struct stage2_args *args, Node **_device) } TRACE(("drive size: %Ld bytes\n", drive->Size())); + gKernelArgs.boot_disk.booted_from_image = gBootedFromImage; *_device = drive; return B_OK; @@ -571,9 +622,3 @@ platform_register_boot_device(Node *device) return B_OK; } - -bool -platform_boot_device_is_image() -{ - return gCDFloppyBoot; -} diff --git a/src/system/boot/platform/bios_ia32/devices.h b/src/system/boot/platform/bios_ia32/devices.h new file mode 100644 index 0000000000..8fee811051 --- /dev/null +++ b/src/system/boot/platform/bios_ia32/devices.h @@ -0,0 +1,22 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef DEVICES_H +#define DEVICES_H + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void devices_check_cd_boot(void); + +#ifdef __cplusplus +} +#endif + +#endif /* DEVICES_H */ diff --git a/src/system/boot/platform/bios_ia32/menu.cpp b/src/system/boot/platform/bios_ia32/menu.cpp index ff93e86022..d916daf890 100644 --- a/src/system/boot/platform/bios_ia32/menu.cpp +++ b/src/system/boot/platform/bios_ia32/menu.cpp @@ -104,20 +104,15 @@ print_item_at(int32 line, MenuItem *item, bool clearHelp = true) if (item->Submenu() && item->Submenu()->Type() == CHOICE_MENU) { // show the current choice (if any) - Menu *subMenu = item->Submenu(); - MenuItem *subItem = NULL; - - for (int32 i = subMenu->CountItems(); i-- > 0; ) { - subItem = subMenu->ItemAt(i); - if (subItem != NULL && subItem->IsMarked()) - break; - } - const char *text = " (Current: "; printf(text); length += strlen(text); - text = subItem != NULL ? subItem->Label() : "None"; + Menu *subMenu = item->Submenu(); + if (subMenu->ChoiceText() != NULL) + text = subMenu->ChoiceText(); + else + text = "None"; length += strlen(text); console_set_color(selected ? DARK_GRAY : WHITE, background); @@ -207,7 +202,7 @@ draw_menu(Menu *menu) print_centered(2, "Haiku Boot Loader"); console_set_color(kCopyrightColor, kBackgroundColor); - print_centered(4, "Copyright 2004 Haiku Inc."); + print_centered(4, "Copyright 2004-2005 Haiku Inc."); if (menu->Title()) { console_set_cursor(kOffsetX, kFirstLine - 2); diff --git a/src/system/boot/platform/bios_ia32/shell.S b/src/system/boot/platform/bios_ia32/shell.S index 7c18088063..ff3130fb69 100644 --- a/src/system/boot/platform/bios_ia32/shell.S +++ b/src/system/boot/platform/bios_ia32/shell.S @@ -72,10 +72,10 @@ floppy_start: #endif start_loader: - // indicate that we were booted from CD/floppy + // indicate that we were booted from CD/floppy/whatever .code32 .byte 0x67 - movb $1, gCDFloppyBoot - 0x7c00 + movb $1, gBootedFromImage - 0x7c00 // %ds is 0x7c0 right now, but the symbol were loaded // to offset 0x10000 .code16 @@ -364,7 +364,7 @@ gdt_descriptor: .word 0x2f // 6 entries in the GDT (8 bytes each) .long gdt -GLOBAL(gCDFloppyBoot): +GLOBAL(gBootedFromImage): .byte 0 GLOBAL(gBootDriveID): diff --git a/src/system/boot/platform/bios_ia32/start.c b/src/system/boot/platform/bios_ia32/start.c index 18a4b0783b..707406ff2c 100644 --- a/src/system/boot/platform/bios_ia32/start.c +++ b/src/system/boot/platform/bios_ia32/start.c @@ -11,6 +11,7 @@ #include "smp.h" #include "keyboard.h" #include "bios.h" +#include "devices.h" #include #include @@ -74,6 +75,7 @@ platform_start_kernel(void) // or I don't see something important... addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; + devices_check_cd_boot(); mmu_init_for_kernel(); smp_boot_other_cpus();