diff --git a/src/system/boot/platform/bios_ia32/devices.cpp b/src/system/boot/platform/bios_ia32/devices.cpp index cdf70b93b5..8c62527a0b 100644 --- a/src/system/boot/platform/bios_ia32/devices.cpp +++ b/src/system/boot/platform/bios_ia32/devices.cpp @@ -4,7 +4,6 @@ */ -#include "devices.h" #include "bios.h" #include @@ -33,6 +32,7 @@ extern uint32 gBootPartitionOffset; #define BIOS_IS_EXT_PRESENT 0x4100 #define BIOS_EXT_READ 0x4200 #define BIOS_GET_EXT_DRIVE_PARAMETERS 0x4800 +#define BIOS_BOOT_CD_GET_STATUS 0x4b01 struct real_addr { uint16 offset; @@ -152,6 +152,42 @@ class BIOSDrive : public Node { }; +static void +check_cd_boot(void) +{ + gKernelArgs.boot_disk.cd = false; + + if (gBootDriveID != 0) + return; + + struct bios_regs regs; + regs.eax = BIOS_BOOT_CD_GET_STATUS; + 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 +} + + static status_t get_ext_drive_parameters(uint8 drive, drive_parameters *targetParameters) { @@ -490,45 +526,6 @@ 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) { @@ -593,6 +590,7 @@ platform_register_boot_device(Node *device) BIOSDrive *drive = (BIOSDrive *)device; gKernelArgs.platform_args.boot_drive_number = gBootDriveID; + check_cd_boot(); if (drive->HasParameters()) { const drive_parameters ¶meters = drive->Parameters(); diff --git a/src/system/boot/platform/bios_ia32/devices.h b/src/system/boot/platform/bios_ia32/devices.h deleted file mode 100644 index 8fee811051..0000000000 --- a/src/system/boot/platform/bios_ia32/devices.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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/start.c b/src/system/boot/platform/bios_ia32/start.c index 707406ff2c..18a4b0783b 100644 --- a/src/system/boot/platform/bios_ia32/start.c +++ b/src/system/boot/platform/bios_ia32/start.c @@ -11,7 +11,6 @@ #include "smp.h" #include "keyboard.h" #include "bios.h" -#include "devices.h" #include #include @@ -75,7 +74,6 @@ 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();