* The boot loader now adds all block devices in case the BIOS doesn't give enough
information to identify the boot volume - if we want to be able to map all BIOS drive IDs to the disks in the system, we need to do this always, though. * Forgot to commit the updated disk_identifier.h in the last commit... * Removed the unused dumpBlock() function from devices.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16892 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1bcbbd6a72
commit
ecdaf9dea8
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef KERNEL_BOOT_DISK_IDENTIFIER_H
|
#ifndef KERNEL_BOOT_DISK_IDENTIFIER_H
|
||||||
@ -25,6 +25,8 @@ enum device_types {
|
|||||||
FIBRE_DEVICE,
|
FIBRE_DEVICE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NUM_DISK_CHECK_SUMS 5
|
||||||
|
|
||||||
typedef struct disk_identifier {
|
typedef struct disk_identifier {
|
||||||
int32 bus_type;
|
int32 bus_type;
|
||||||
int32 device_type;
|
int32 device_type;
|
||||||
@ -64,7 +66,7 @@ typedef struct disk_identifier {
|
|||||||
struct {
|
struct {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
uint32 sum;
|
uint32 sum;
|
||||||
} check_sums[5];
|
} check_sums[NUM_DISK_CHECK_SUMS];
|
||||||
} unknown;
|
} unknown;
|
||||||
} device;
|
} device;
|
||||||
} disk_identifier;
|
} disk_identifier;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef KERNEL_BOOT_PLATFORM_H
|
#ifndef KERNEL_BOOT_PLATFORM_H
|
||||||
@ -54,7 +54,7 @@ namespace boot {
|
|||||||
class Partition;
|
class Partition;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern status_t platform_get_boot_device(struct stage2_args *args, Node **_device);
|
extern status_t platform_add_boot_device(struct stage2_args *args, NodeList *devicesList);
|
||||||
extern status_t platform_add_block_devices(struct stage2_args *args, NodeList *devicesList);
|
extern status_t platform_add_block_devices(struct stage2_args *args, NodeList *devicesList);
|
||||||
extern status_t platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
|
extern status_t platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
|
||||||
NodeList *partitions, boot::Partition **_partition);
|
NodeList *partitions, boot::Partition **_partition);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -328,11 +328,11 @@ Directory *
|
|||||||
get_boot_file_system(stage2_args *args)
|
get_boot_file_system(stage2_args *args)
|
||||||
{
|
{
|
||||||
Node *device;
|
Node *device;
|
||||||
if (platform_get_boot_device(args, &device) < B_OK)
|
if (platform_add_boot_device(args, &gBootDevices) < B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// add the boot device to the list of devices
|
// the boot device must be the first device in the list
|
||||||
gBootDevices.Add(device);
|
device = gBootDevices.First();
|
||||||
|
|
||||||
if (add_partitions_for(device, false, true) < B_OK)
|
if (add_partitions_for(device, false, true) < B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -160,6 +160,9 @@ class BIOSDrive : public Node {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static bool sBlockDevicesAdded = false;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_cd_boot(BIOSDrive *drive)
|
check_cd_boot(BIOSDrive *drive)
|
||||||
{
|
{
|
||||||
@ -473,41 +476,44 @@ find_unique_check_sums(NodeList *devices)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DUMPED_BLOCK_SIZE 16
|
static status_t
|
||||||
|
add_block_devices(NodeList *devicesList, bool identifierMissing)
|
||||||
void
|
|
||||||
dumpBlock(const char *buffer, int size, const char *prefix)
|
|
||||||
{
|
{
|
||||||
int i;
|
if (sBlockDevicesAdded)
|
||||||
|
return B_OK;
|
||||||
for (i = 0; i < size;) {
|
|
||||||
int start = i;
|
|
||||||
|
|
||||||
dprintf(prefix);
|
uint8 driveCount;
|
||||||
for (; i < start+DUMPED_BLOCK_SIZE; i++) {
|
if (get_number_of_drives(&driveCount) != B_OK)
|
||||||
if (!(i % 4))
|
return B_ERROR;
|
||||||
dprintf(" ");
|
|
||||||
|
|
||||||
if (i >= size)
|
dprintf("number of drives: %d\n", driveCount);
|
||||||
dprintf(" ");
|
|
||||||
else
|
for (int32 i = 0; i < driveCount; i++) {
|
||||||
dprintf("%02x", *(unsigned char *)(buffer + i));
|
uint8 driveID = i + 0x80;
|
||||||
|
if (driveID == gBootDriveID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
BIOSDrive *drive = new BIOSDrive(driveID);
|
||||||
|
if (drive->InitCheck() != B_OK) {
|
||||||
|
dprintf("could not add drive %u\n", driveID);
|
||||||
|
delete drive;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
dprintf(" ");
|
|
||||||
|
|
||||||
for (i = start; i < start + DUMPED_BLOCK_SIZE; i++) {
|
devicesList->Add(drive);
|
||||||
if (i < size) {
|
|
||||||
char c = buffer[i];
|
|
||||||
|
|
||||||
if (c < 30)
|
if (drive->FillIdentifier() != B_OK)
|
||||||
dprintf(".");
|
identifierMissing = true;
|
||||||
else
|
|
||||||
dprintf("%c", c);
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dprintf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (identifierMissing) {
|
||||||
|
// we cannot distinguish between all drives by identifier, we need
|
||||||
|
// compute checksums for them
|
||||||
|
find_unique_check_sums(devicesList);
|
||||||
|
}
|
||||||
|
|
||||||
|
sBlockDevicesAdded = true;
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -720,7 +726,7 @@ BIOSDrive::FillIdentifier()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
platform_get_boot_device(struct stage2_args *args, Node **_device)
|
platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
|
||||||
{
|
{
|
||||||
TRACE(("boot drive ID: %x\n", gBootDriveID));
|
TRACE(("boot drive ID: %x\n", gBootDriveID));
|
||||||
|
|
||||||
@ -730,14 +736,17 @@ platform_get_boot_device(struct stage2_args *args, Node **_device)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devicesList->Add(drive);
|
||||||
|
|
||||||
if (drive->FillIdentifier() != B_OK) {
|
if (drive->FillIdentifier() != B_OK) {
|
||||||
// TODO: we need to add all block devices!
|
// We need to add all block devices to give the kernel the possibility
|
||||||
|
// to find the right boot volume
|
||||||
|
add_block_devices(devicesList, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("drive size: %Ld bytes\n", drive->Size()));
|
TRACE(("boot drive size: %Ld bytes\n", drive->Size()));
|
||||||
gKernelArgs.boot_disk.booted_from_image = gBootedFromImage;
|
gKernelArgs.boot_disk.booted_from_image = gBootedFromImage;
|
||||||
|
|
||||||
*_device = drive;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,39 +780,7 @@ platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
|
|||||||
status_t
|
status_t
|
||||||
platform_add_block_devices(stage2_args *args, NodeList *devicesList)
|
platform_add_block_devices(stage2_args *args, NodeList *devicesList)
|
||||||
{
|
{
|
||||||
uint8 driveCount;
|
return add_block_devices(devicesList, false);
|
||||||
if (get_number_of_drives(&driveCount) != B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
dprintf("number of drives: %d\n", driveCount);
|
|
||||||
|
|
||||||
bool identifierMissing = false;
|
|
||||||
|
|
||||||
for (int32 i = 0; i < driveCount; i++) {
|
|
||||||
uint8 driveID = i + 0x80;
|
|
||||||
if (driveID == gBootDriveID)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BIOSDrive *drive = new BIOSDrive(driveID);
|
|
||||||
if (drive->InitCheck() != B_OK) {
|
|
||||||
dprintf("could not add drive %u\n", driveID);
|
|
||||||
delete drive;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
devicesList->Add(drive);
|
|
||||||
|
|
||||||
if (drive->FillIdentifier() != B_OK)
|
|
||||||
identifierMissing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (identifierMissing) {
|
|
||||||
// we cannot distinguish between all drives by identifier, we need
|
|
||||||
// compute checksums for them
|
|
||||||
find_unique_check_sums(devicesList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user