From b193fcc7165ddd6fef10e48c8b19a4b23e7908d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Nov 2004 17:59:15 +0000 Subject: [PATCH] Some work on the boot disk identification: the kernel_args structure has now fields that carry information about the boot disk and partition. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9956 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/disk_identifier.h | 72 +++++++++++++++++++ headers/private/kernel/boot/kernel_args.h | 18 +++-- headers/private/kernel/boot/platform.h | 7 +- .../boot/platform/bios_ia32/bios_drive.h | 18 +++++ .../platform/bios_ia32/platform_kernel_args.h | 14 ++-- headers/private/kernel/boot/vfs.h | 10 +-- 6 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 headers/private/kernel/boot/disk_identifier.h create mode 100644 headers/private/kernel/boot/platform/bios_ia32/bios_drive.h diff --git a/headers/private/kernel/boot/disk_identifier.h b/headers/private/kernel/boot/disk_identifier.h new file mode 100644 index 0000000000..0319db5633 --- /dev/null +++ b/headers/private/kernel/boot/disk_identifier.h @@ -0,0 +1,72 @@ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ +#ifndef KERNEL_BOOT_DISK_IDENTIFIER_H +#define KERNEL_BOOT_DISK_IDENTIFIER_H + + +#include + + +enum bus_types { + UNKNOWN_BUS, + LEGACY_BUS, + PCI_BUS, +}; + +enum device_types { + UNKNOWN_DEVICE, + ATA_DEVICE, + ATAPI_DEVICE, + SCSI_DEVICE, + USB_DEVICE, + FIREWIRE_DEVICE, + FIBRE_DEVICE, +}; + +typedef struct disk_identifier { + int32 bus_type; + int32 device_type; + + union { + struct { + uint16 base_address; + } legacy; + struct { + uint8 bus; + uint8 slot; + uint8 function; + } pci; + } bus; + union { + struct { + bool master; + } ata; + struct { + bool master; + uint8 logical_unit; + } atapi; + struct { + uint8 logical_unit; + } scsi; + struct { + uint8 tbd; + } usb; + struct { + uint64 guid; + } firewire; + struct { + uint64 wwd; + } fibre; + struct { + off_t size; + struct { + off_t offset; + uint32 sum; + } check_sums[5]; + } unknown; + } device; +} disk_identifier; + +#endif /* KERNEL_BOOT_DISK_IDENTIFIER_H */ diff --git a/headers/private/kernel/boot/kernel_args.h b/headers/private/kernel/boot/kernel_args.h index 8f566e3b2e..11738327f4 100644 --- a/headers/private/kernel/boot/kernel_args.h +++ b/headers/private/kernel/boot/kernel_args.h @@ -1,10 +1,10 @@ /* -** Copyright 2002-2004, The Haiku Team. All rights reserved. -** Distributed under the terms of the Haiku License. -** -** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ + * Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ #ifndef KERNEL_BOOT_KERNEL_ARGS_H #define KERNEL_BOOT_KERNEL_ARGS_H @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -41,6 +42,11 @@ typedef struct kernel_args { uint32 num_cpus; addr_range cpu_kstack[MAX_BOOT_CPUS]; + struct { + disk_identifier identifier; + off_t partition_offset; + } boot_disk; + struct { bool enabled; int32 width; diff --git a/headers/private/kernel/boot/platform.h b/headers/private/kernel/boot/platform.h index c5fd7cf959..e11b95ee96 100644 --- a/headers/private/kernel/boot/platform.h +++ b/headers/private/kernel/boot/platform.h @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ + * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #ifndef KERNEL_BOOT_PLATFORM_H #define KERNEL_BOOT_PLATFORM_H @@ -57,6 +57,7 @@ extern status_t platform_get_boot_device(struct stage2_args *args, Node **_devic 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, NodeList *partitions, boot::Partition **_partition); +extern status_t platform_register_boot_device(Node *device); /* menu functions */ diff --git a/headers/private/kernel/boot/platform/bios_ia32/bios_drive.h b/headers/private/kernel/boot/platform/bios_ia32/bios_drive.h new file mode 100644 index 0000000000..bfd2cec572 --- /dev/null +++ b/headers/private/kernel/boot/platform/bios_ia32/bios_drive.h @@ -0,0 +1,18 @@ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ +#ifndef KERNEL_BOOT_PLATFORM_BIOS_IA32_BIOS_DRIVE_H +#define KERNEL_BOOT_PLATFORM_BIOS_IA32_BIOS_DRIVE_H + + +#include + + +typedef struct bios_drive { + struct bios_drive *next; + uint16 drive_number; + disk_identifier identifier; +} bios_drive; + +#endif /* KERNEL_BOOT_PLATFORM_BIOS_IA32_BIOS_DRIVE_H */ diff --git a/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h b/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h index fdd026cfff..d0875e72c3 100644 --- a/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h +++ b/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h @@ -1,7 +1,7 @@ /* -** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ + * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #ifndef KERNEL_BOOT_PLATFORM_BIOS_IA32_KERNEL_ARGS_H #define KERNEL_BOOT_PLATFORM_BIOS_IA32_KERNEL_ARGS_H @@ -9,6 +9,9 @@ # error This file is included from only #endif +#include + + // must match SMP_MAX_CPUS in arch_smp.h #define MAX_BOOT_CPUS 4 #define MAX_PHYSICAL_MEMORY_RANGE 4 @@ -18,7 +21,10 @@ #define MAX_SERIAL_PORTS 4 typedef struct { - uint16 serial_base_ports[MAX_SERIAL_PORTS]; + uint16 serial_base_ports[MAX_SERIAL_PORTS]; + + uint16 boot_drive_number; + bios_drive *drives; // this does not contain the boot drive } platform_kernel_args; #endif /* KERNEL_BOOT_PLATFORM_BIOS_IA32_KERNEL_ARGS_H */ diff --git a/headers/private/kernel/boot/vfs.h b/headers/private/kernel/boot/vfs.h index a885f19ef9..6f66d5e814 100644 --- a/headers/private/kernel/boot/vfs.h +++ b/headers/private/kernel/boot/vfs.h @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #ifndef KERNEL_BOOT_VFS_H #define KERNEL_BOOT_VFS_H @@ -78,12 +78,14 @@ class ConsoleNode : public Node { /* function prototypes */ extern status_t vfs_init(stage2_args *args); -extern void register_boot_file_system(Directory *directory); +extern status_t register_boot_file_system(Directory *directory); extern Directory *get_boot_file_system(stage2_args *args); extern status_t mount_file_systems(stage2_args *args); extern int open_node(Node *node, int mode); extern int open_from(Directory *directory, const char *path, int mode); +extern Node *get_node_from(int fd); + extern status_t add_partitions_for(int fd, bool mountFileSystems); extern status_t add_partitions_for(Node *device, bool mountFileSystems);