[haiku-commits] BRANCH jessicah-github.efi.merge [5a70dd7f18df] src/tests/kits/interface/flatten_picture src/system/boot/loader src/system/boot/platform/efi data/catalogs/add-ons/network_settings data/catalogs/apps

  • From: jessicah-github.efi.merge <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 Sep 2015 02:32:00 +0200 (CEST)

added 6 changesets to branch 'refs/remotes/jessicah-github/efi.merge'
old head: 1529a56833a6d7836ce26aa719909ceb4d735765
new head: 5a70dd7f18df11dc8796b7444cfc25898ba7eb85
overview: https://github.com/jessicah/haiku/compare/1529a56833a6...5a70dd7f18df

----------------------------------------------------------------------------

c60fa5fa9114: Merge branch 'master' of ssh://git.haiku-os.org/haiku into
efi.merge

b0d541e97a1a: UEFI: cleanup of src/system/boot/loader

955bf1ac782b: Fix line endings.

f336d3b6bb11: UEFI: cleanup of src/system/kernel.

Still need to work on fs/vfs_boot.cpp

ddd918870c68: UEFI: update platform function names for converting addresses

5a70dd7f18df: booting: support identifying disks & partitions by UUID.

This adds a UUID field for partition_data, and updates the
GPT partitioning system to add the UUIDs for both the
partitioning system and each child partition.

The VFS boot code has been updated to detect whether disks
and partitions should be identified by UUID, skipping the
fallback mechanisms used for other platforms.

These changes will allow the UEFI boot loader to correctly
pass the boot device and partition to the kernel.

[ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]

----------------------------------------------------------------------------

47 files changed, 461 insertions(+), 141 deletions(-)
build/jam/repositories/HaikuPorts/x86_gcc2 | 6 +-
.../inbound_filters/match_header/ro.catkeys | 3 +-
.../inbound_filters/spam_filter/ro.catkeys | 3 +-
.../inbound_protocols/imap/ro.catkeys | 5 +-
.../add-ons/network_settings/ftpd/hu.catkeys | 3 +
.../add-ons/network_settings/sshd/hu.catkeys | 3 +
.../add-ons/network_settings/telnetd/hu.catkeys | 3 +
data/catalogs/apps/haikudepot/de.catkeys | 3 +-
data/catalogs/apps/haikudepot/hu.catkeys | 3 +-
data/catalogs/apps/mail/de.catkeys | 4 +-
data/catalogs/apps/mail/hu.catkeys | 4 +-
data/catalogs/apps/terminal/de.catkeys | 5 +-
data/catalogs/apps/terminal/hu.catkeys | 4 +-
data/catalogs/preferences/media/de.catkeys | 3 +-
data/catalogs/preferences/media/hu.catkeys | 4 +-
data/catalogs/preferences/screen/hu.catkeys | 3 +-
data/catalogs/servers/mail/ro.catkeys | 3 +-
data/catalogs/servers/syslog_daemon/ro.catkeys | 4 +-
headers/os/drivers/disk_device_manager.h | 1 +
headers/private/kernel/boot/disk_identifier.h | 2 +
headers/private/kernel/boot/kernel_args.h | 1 +
headers/private/kernel/boot/platform.h | 4 +-
.../kernel/busses/scsi/ahci/ahci_port.cpp | 11 +-
.../kernel/partitioning_systems/gpt/Header.h | 2 +
.../kernel/partitioning_systems/gpt/efi_gpt.cpp | 2 +
src/bin/df.cpp | 3 +
src/bin/keymap/main.cpp | 2 +-
src/data/ids/pci.ids | 5 +-
src/system/boot/loader/elf.cpp | 7 +-
src/system/boot/loader/kernel_args.cpp | 4 +-
src/system/boot/loader/main.cpp | 6 +-
src/system/boot/loader/net/RemoteDisk.cpp | 3 +-
src/system/boot/loader/vfs.cpp | 24 +-
src/system/boot/platform/efi/mmu.cpp | 8 +-
src/system/boot/platform/efi/mmu.h | 4 +-
src/system/boot/platform/efi/smp.cpp | 4 +-
src/system/boot/platform/efi/start.cpp | 4 +-
src/system/kernel/arch/x86/arch_platform.cpp | 88 +++---
src/system/kernel/device_manager/devfs.cpp | 4 -
.../kernel/device_manager/device_manager.cpp | 5 +-
.../kernel/device_manager/legacy_drivers.cpp | 6 +-
src/system/kernel/fs/vfs_boot.cpp | 23 ++
src/system/kernel/main.cpp | 4 +-
src/system/libroot/posix/glibc/arch/ppc/Jamfile | 2 +
src/system/libroot/posix/glibc/math/Jamfile | 21 +-
src/system/libroot/posix/glibc/math/complex.h | 2 +-
.../flatten_picture/PictureTestCases.cpp | 284 ++++++++++++++++++-

############################################################################

Commit: c60fa5fa91143035e44d5b24292a15c51dfa255c
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sat Sep 19 08:00:23 2015 UTC

Merge branch 'master' of ssh://git.haiku-os.org/haiku into efi.merge

----------------------------------------------------------------------------

############################################################################

Commit: b0d541e97a1ae3328f635fd7908d32ed956af77b
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sun Sep 20 23:31:38 2015 UTC

UEFI: cleanup of src/system/boot/loader

----------------------------------------------------------------------------

diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp
index 69b6d23..7011a70 100644
--- a/src/system/boot/loader/elf.cpp
+++ b/src/system/boot/loader/elf.cpp
@@ -134,7 +134,7 @@ struct ELF64Class {
return status;

*_mappedAddress = address;
- platform_bootloader_address_to_kernel_address(address,
_address);
+ platform_convert_to_kernel_address(address, _address);
return B_OK;
}

@@ -142,7 +142,7 @@ struct ELF64Class {
Map(AddrType address)
{
void *result;
- if (platform_kernel_address_to_bootloader_address(address,
&result) != B_OK) {
+ if (platform_convert_to_loader_address(address, &result) !=
B_OK) {
panic("Couldn't convert address %#lx", address);
}
return result;
@@ -261,7 +261,8 @@ ELFLoader<Class>::Load(int fd, preloaded_image* _image)
// known but unused type
continue;
default:
- dprintf("unhandled pheader type 0x%" B_PRIx32
"\n", header.p_type);
+ dprintf("unhandled pheader type 0x%" B_PRIx32
"\n",
+ header.p_type);
continue;
}

diff --git a/src/system/boot/loader/kernel_args.cpp
b/src/system/boot/loader/kernel_args.cpp
index f0d1b63..c1be342 100644
--- a/src/system/boot/loader/kernel_args.cpp
+++ b/src/system/boot/loader/kernel_args.cpp
@@ -372,7 +372,7 @@ kernel_args_malloc(size_t size)

#ifdef _BOOT_PLATFORM_efi
uint64 translated_block;
- platform_bootloader_address_to_kernel_address(block,
&translated_block);
+ platform_convert_to_kernel_address(block, &translated_block);
if (add_kernel_args_range((void *)translated_block, size) !=
B_OK)
panic("kernel_args max range too low!\n");
#else
@@ -394,7 +394,7 @@ kernel_args_malloc(size_t size)
sFree = kChunkSize - size;
#ifdef _BOOT_PLATFORM_efi
uint64 translated_block;
- platform_bootloader_address_to_kernel_address(block, &translated_block);
+ platform_convert_to_kernel_address(block, &translated_block);
if (add_kernel_args_range((void *)translated_block, kChunkSize) != B_OK)
panic("kernel_args max range too low!\n");
#else
diff --git a/src/system/boot/loader/main.cpp b/src/system/boot/loader/main.cpp
index 3784fe2..bb7a063 100644
--- a/src/system/boot/loader/main.cpp
+++ b/src/system/boot/loader/main.cpp
@@ -66,19 +66,17 @@ main(stage2_args *args)
if (get_boot_file_system(args, bootVolume) != B_OK
|| (platform_boot_options() & BOOT_OPTION_MENU) != 0) {
if (!bootVolume.IsValid())
- dprintf("\tno boot path found, scan for all
partitions...\n");
+ puts("\tno boot path found, scan for all
partitions...\n");

if (mount_file_systems(args) < B_OK) {
// That's unfortunate, but we still give the user the
possibility
// to insert a CD-ROM or just rescan the available
devices
- dprintf("Could not locate any supported boot
devices!\n");
+ puts("Could not locate any supported boot devices!\n");
}

// ToDo: check if there is only one bootable volume!

mountedAllVolumes = true;
-
- dprintf("entering user menu to select a boot volume...\n");

if (user_menu(bootVolume, pathBlacklist) < B_OK) {
// user requested to quit the loader
diff --git a/src/system/boot/loader/net/RemoteDisk.cpp
b/src/system/boot/loader/net/RemoteDisk.cpp
index 3bcbbb4..c2c9fb7 100644
--- a/src/system/boot/loader/net/RemoteDisk.cpp
+++ b/src/system/boot/loader/net/RemoteDisk.cpp
@@ -165,7 +165,8 @@ RemoteDisk::GetName(char *nameBuffer, size_t bufferSize)
const
if (!nameBuffer)
return B_BAD_VALUE;

- snprintf(nameBuffer, bufferSize, "RemoteDisk:%" B_PRId32 ".%" B_PRId32
".%" B_PRId32 ".%" B_PRId32 ":%" B_PRId16 "",
+ snprintf(nameBuffer, bufferSize, "RemoteDisk:" \
+ "%" B_PRId32 ".%" B_PRId32 ".%" B_PRId32 ".%" B_PRId32 ":%"
B_PRId16 "",
(fServerAddress >> 24) & 0xff, (fServerAddress >> 16) & 0xff,
(fServerAddress >> 8) & 0xff, fServerAddress & 0xff,
fServerPort);

diff --git a/src/system/boot/loader/vfs.cpp b/src/system/boot/loader/vfs.cpp
index f911c1f..20aaa28 100644
--- a/src/system/boot/loader/vfs.cpp
+++ b/src/system/boot/loader/vfs.cpp
@@ -693,49 +693,34 @@ status_t
mount_file_systems(stage2_args *args)
{
// mount other partitions on boot device (if any)
- dprintf("mount_file_systems...\n");
NodeIterator iterator = gPartitions.GetIterator();
- dprintf("1.");

Partition *partition = NULL;
while ((partition = (Partition *)iterator.Next()) != NULL) {
- dprintf("2.");
// don't scan known partitions again
if (partition->IsFileSystem())
continue;

- dprintf("3.");
// remove the partition if it doesn't contain a (known) file
system
if (partition->Scan(true) != B_OK &&
!partition->IsFileSystem()) {
- dprintf("4.");
gPartitions.Remove(partition);
- dprintf("5.");
delete partition;
}
- dprintf("6.");
}

// add all block devices the platform has for us
- dprintf("7.");
status_t status = platform_add_block_devices(args, &gBootDevices);
- dprintf("8.");
- if (status < B_OK) {
- dprintf("exit\n");
+ if (status < B_OK)
return status;
- }

iterator = gBootDevices.GetIterator();
- dprintf("9.");
Node *device = NULL, *last = NULL;
while ((device = iterator.Next()) != NULL) {
- dprintf("10.");
// don't scan former boot device again
if (device == sBootDevice)
continue;

- dprintf("11.");
if (add_partitions_for(device, true) == B_OK) {
- dprintf("12.");
// ToDo: we can't delete the object here, because it
must
// be removed from the list before we know that it
was
// deleted.
@@ -748,15 +733,11 @@ mount_file_systems(stage2_args *args)
*/
(void)last;
}
- dprintf("13.");
last = device;
}

- dprintf("14.");
- if (gPartitions.IsEmpty()) {
- dprintf("exit2\n");
+ if (gPartitions.IsEmpty())
return B_ENTRY_NOT_FOUND;
- }

#if 0
void *cookie;
@@ -779,7 +760,6 @@ mount_file_systems(stage2_args *args)
}
#endif

- dprintf("finished\n");
return B_OK;
}


############################################################################

Commit: 955bf1ac782b26e5686c09910f2ca55f549e0d93
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sun Sep 20 23:41:57 2015 UTC

Fix line endings.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/x86/arch_platform.cpp
b/src/system/kernel/arch/x86/arch_platform.cpp
index 07dda73..ef37e71 100644
--- a/src/system/kernel/arch/x86/arch_platform.cpp
+++ b/src/system/kernel/arch/x86/arch_platform.cpp
@@ -1,44 +1,44 @@
-/*
- * Copyright 2006, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
- * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
- */
-
-
-#include <arch/platform.h>
-#include <apm.h>
-#include <boot_item.h>
-#include <boot/stage2.h>
-
-
-status_t
-arch_platform_init(struct kernel_args *args)
-{
- return B_OK;
-}
-
-
-status_t
-arch_platform_init_post_vm(struct kernel_args *args)
-{
- // Now we can add boot items; pass on the ACPI root pointer
- add_boot_item("ACPI_ROOT_POINTER",
- args->platform_args.acpi_root.Pointer(), sizeof(void*));
-
- return B_OK;
-}
-
-
-status_t
-arch_platform_init_post_thread(struct kernel_args *args)
-{
- // APM is not supported on x86_64.
-#ifndef __x86_64__
- apm_init(args);
-#endif
- return B_OK;
-}
-
+/*
+ * Copyright 2006, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
+ * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ */
+
+
+#include <arch/platform.h>
+#include <apm.h>
+#include <boot_item.h>
+#include <boot/stage2.h>
+
+
+status_t
+arch_platform_init(struct kernel_args *args)
+{
+ return B_OK;
+}
+
+
+status_t
+arch_platform_init_post_vm(struct kernel_args *args)
+{
+ // Now we can add boot items; pass on the ACPI root pointer
+ add_boot_item("ACPI_ROOT_POINTER",
+ args->platform_args.acpi_root.Pointer(), sizeof(void*));
+
+ return B_OK;
+}
+
+
+status_t
+arch_platform_init_post_thread(struct kernel_args *args)
+{
+ // APM is not supported on x86_64.
+#ifndef __x86_64__
+ apm_init(args);
+#endif
+ return B_OK;
+}
+

############################################################################

Commit: f336d3b6bb115295254747ea2276c430afa15548
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sun Sep 20 23:46:54 2015 UTC

UEFI: cleanup of src/system/kernel.

Still need to work on fs/vfs_boot.cpp

----------------------------------------------------------------------------

diff --git a/src/system/kernel/device_manager/devfs.cpp
b/src/system/kernel/device_manager/devfs.cpp
index d8e776c..5185125 100644
--- a/src/system/kernel/device_manager/devfs.cpp
+++ b/src/system/kernel/device_manager/devfs.cpp
@@ -200,10 +200,6 @@ scan_mode(void)
// We may scan every device twice:
// - once before there is a boot device,
// - and once when there is one
- if (gBootDevice >= 0)
- dprintf("devfs: scan_mode = normal\n");
- else
- dprintf("devfs: scan_mode = boot\n");

return gBootDevice >= 0 ? kNormalScan : kBootScan;
}
diff --git a/src/system/kernel/device_manager/device_manager.cpp
b/src/system/kernel/device_manager/device_manager.cpp
index b48ebab..5537aa0 100644
--- a/src/system/kernel/device_manager/device_manager.cpp
+++ b/src/system/kernel/device_manager/device_manager.cpp
@@ -35,7 +35,7 @@
#include "IOSchedulerRoster.h"


-#define TRACE_DEVICE_MANAGER
+//#define TRACE_DEVICE_MANAGER
#ifdef TRACE_DEVICE_MANAGER
# define TRACE(a) dprintf a
#else
@@ -384,10 +384,8 @@ static void
publish_directories(const char* subPath)
{
if (gBootDevice < 0) {
- TRACE(("publish_directories: no boot device, publishing\n"));
if (subPath[0]) {
// we only support the top-level directory for modules
- TRACE(("exiting, only support top-level directory for
modules\n"));
return;
}

@@ -418,7 +416,6 @@ publish_directories(const char* subPath)
}
close_module_list(list);
} else {
- TRACE(("publish_directories: have boot device, skipping, is
TODO\n"));
// TODO: implement module directory traversal!
}
}
diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp
b/src/system/kernel/device_manager/legacy_drivers.cpp
index ac6a34f..85e787d 100644
--- a/src/system/kernel/device_manager/legacy_drivers.cpp
+++ b/src/system/kernel/device_manager/legacy_drivers.cpp
@@ -1183,12 +1183,8 @@ probe_for_drivers(const char *type)
{
TRACE(("probe_for_drivers(type = %s)\n", type));

- if (gBootDevice < 0) {
- TRACE(("legacy probe_for_drivers: no boot device, exiting\n"));
+ if (gBootDevice < 0)
return B_OK;
- } else {
- TRACE(("legacy probe_for_drivers: boot device found\n"));
- }

DriverEntryList drivers;

diff --git a/src/system/kernel/main.cpp b/src/system/kernel/main.cpp
index 47372bc..f3a0a9b 100644
--- a/src/system/kernel/main.cpp
+++ b/src/system/kernel/main.cpp
@@ -59,7 +59,7 @@
#include "vm/VMAnonymousCache.h"


-#define TRACE_BOOT
+//#define TRACE_BOOT
#ifdef TRACE_BOOT
# define TRACE(x...) dprintf("INIT: " x)
#else
@@ -310,9 +310,7 @@ main2(void* /*unused*/)
/* bootstrap all the filesystems */
TRACE("Bootstrap file systems\n");
boot_splash_set_stage(BOOT_SPLASH_STAGE_2_BOOTSTRAP_FS);
- gBootDevice = -1;
vfs_bootstrap_file_systems();
- gBootDevice = -1;

TRACE("Init Device Manager\n");
boot_splash_set_stage(BOOT_SPLASH_STAGE_3_INIT_DEVICES);

############################################################################

Commit: ddd918870c68a10538bccc1a398b055312ed0d96
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sun Sep 20 23:50:53 2015 UTC

UEFI: update platform function names for converting addresses

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/boot/platform.h
b/headers/private/kernel/boot/platform.h
index 7d3afda..d96c9b1 100644
--- a/headers/private/kernel/boot/platform.h
+++ b/headers/private/kernel/boot/platform.h
@@ -28,8 +28,8 @@ extern status_t platform_init_heap(struct stage2_args *args,
void **_base, void
extern status_t platform_allocate_region(void **_virtualAddress, size_t size,
uint8 protection, bool exactAddress);
extern status_t platform_free_region(void *address, size_t size);
-extern status_t platform_bootloader_address_to_kernel_address(void *address,
uint64_t *_result);
-extern status_t platform_kernel_address_to_bootloader_address(uint64_t
address, void **_result);
+extern status_t platform_convert_to_kernel_address(void *address, uint64_t
*_result);
+extern status_t platform_convert_to_loader_address(uint64_t address, void
**_result);

/* boot options */
#define BOOT_OPTION_MENU 1
diff --git a/src/system/boot/platform/efi/mmu.cpp
b/src/system/boot/platform/efi/mmu.cpp
index 24d68ae..84bb9e0 100644
--- a/src/system/boot/platform/efi/mmu.cpp
+++ b/src/system/boot/platform/efi/mmu.cpp
@@ -51,7 +51,7 @@ mmu_generate_post_efi_page_tables(UINTN memory_map_size,
EFI_MEMORY_DESCRIPTOR *
panic("Failed to allocate PML4.");
gKernelArgs.arch_args.phys_pgdir = (uint32_t)(addr_t)pml4;
memset(pml4, 0, B_PAGE_SIZE);
- platform_bootloader_address_to_kernel_address(pml4,
&gKernelArgs.arch_args.vir_pgdir);
+ platform_convert_to_kernel_address(pml4,
&gKernelArgs.arch_args.vir_pgdir);

// Store the virtual memory usage information.
gKernelArgs.virtual_allocated_range[0].start = KERNEL_LOAD_BASE_64_BIT;
@@ -123,7 +123,7 @@ mmu_generate_post_efi_page_tables(UINTN memory_map_size,
EFI_MEMORY_DESCRIPTOR *

// Get the physical address to map.
void *phys;
- if
(platform_kernel_address_to_bootloader_address(KERNEL_LOAD_BASE_64_BIT + (i *
B_PAGE_SIZE),
+ if (platform_convert_to_loader_address(KERNEL_LOAD_BASE_64_BIT
+ (i * B_PAGE_SIZE),
&phys) !=
B_OK)
continue;

@@ -379,7 +379,7 @@ get_region(void *address, size_t size)
}

extern "C" status_t
-platform_bootloader_address_to_kernel_address(void *address, uint64_t *_result)
+platform_convert_to_kernel_address(void *address, uint64_t *_result)
{
uint64_t addr = (uint64_t)address;

@@ -401,7 +401,7 @@ platform_bootloader_address_to_kernel_address(void
*address, uint64_t *_result)
}

extern "C" status_t
-platform_kernel_address_to_bootloader_address(uint64_t address, void **_result)
+platform_convert_to_loader_address(uint64_t address, void **_result)
{
for (allocated_memory_region *region = allocated_memory_regions;
region; region = region->next) {
if (region->vaddr != 0 && region->vaddr <= address && address <
region->vaddr + region->size) {
diff --git a/src/system/boot/platform/efi/mmu.h
b/src/system/boot/platform/efi/mmu.h
index ed5bb27..08809a6 100644
--- a/src/system/boot/platform/efi/mmu.h
+++ b/src/system/boot/platform/efi/mmu.h
@@ -34,9 +34,9 @@ mmu_post_efi_setup(UINTN memory_map_size,
EFI_MEMORY_DESCRIPTOR *memory_map, UIN
extern uint64_t
mmu_generate_post_efi_page_tables(UINTN memory_map_size, EFI_MEMORY_DESCRIPTOR
*memory_map, UINTN descriptor_size, UINTN descriptor_version);
extern status_t
-platform_kernel_address_to_bootloader_address(uint64_t address, void
**_result);
+platform_convert_to_loader_address(uint64_t address, void **_result);
extern status_t
-platform_bootloader_address_to_kernel_address(void *address, uint64_t
*_result);
+platform_convert_to_kernel_address(void *address, uint64_t *_result);

#ifdef __cplusplus
}
diff --git a/src/system/boot/platform/efi/smp.cpp
b/src/system/boot/platform/efi/smp.cpp
index 2096c6b..d904950 100644
--- a/src/system/boot/platform/efi/smp.cpp
+++ b/src/system/boot/platform/efi/smp.cpp
@@ -206,14 +206,14 @@ calculate_apic_timer_conversion_factor(void)


extern "C" status_t
-platform_bootloader_address_to_kernel_address(void *address, uint64_t
*_result);
+platform_convert_to_kernel_address(void *address, uint64_t *_result);

/*! Convert a 32-bit address to a 64-bit address. */
static inline uint64
fix_address(uint64 address)
{
uint64 result;
- if (platform_bootloader_address_to_kernel_address((void *)address,
&result) != B_OK)
+ if (platform_convert_to_kernel_address((void *)address, &result) !=
B_OK)
return address;
else
return result;
diff --git a/src/system/boot/platform/efi/start.cpp
b/src/system/boot/platform/efi/start.cpp
index ccb469a..1e1ef18 100644
--- a/src/system/boot/platform/efi/start.cpp
+++ b/src/system/boot/platform/efi/start.cpp
@@ -69,14 +69,14 @@ platform_boot_options(void)
}

extern "C" status_t
-platform_bootloader_address_to_kernel_address(void *address, uint64_t
*_result);
+platform_convert_to_kernel_address(void *address, uint64_t *_result);

/*! Convert a 32-bit address to a 64-bit address. */
static inline uint64
fix_address(uint64 address)
{
uint64 result;
- if (platform_bootloader_address_to_kernel_address((void *)address,
&result) != B_OK)
+ if (platform_convert_to_kernel_address((void *)address, &result) !=
B_OK)
return address;
else
return result;

############################################################################

Commit: 5a70dd7f18df11dc8796b7444cfc25898ba7eb85
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Tue Sep 22 00:02:48 2015 UTC

booting: support identifying disks & partitions by UUID.

This adds a UUID field for partition_data, and updates the
GPT partitioning system to add the UUIDs for both the
partitioning system and each child partition.

The VFS boot code has been updated to detect whether disks
and partitions should be identified by UUID, skipping the
fallback mechanisms used for other platforms.

These changes will allow the UEFI boot loader to correctly
pass the boot device and partition to the kernel.

----------------------------------------------------------------------------

diff --git a/headers/os/drivers/disk_device_manager.h
b/headers/os/drivers/disk_device_manager.h
index 17c1b78..34b1fcc 100644
--- a/headers/os/drivers/disk_device_manager.h
+++ b/headers/os/drivers/disk_device_manager.h
@@ -39,6 +39,7 @@ typedef struct partition_data {
char *content_parameters;
void *cookie;
void *content_cookie;
+ uint8 uuid[16];
} partition_data;

// C API disk device representation
diff --git a/headers/private/kernel/boot/disk_identifier.h
b/headers/private/kernel/boot/disk_identifier.h
index b1c64e9..055e98e 100644
--- a/headers/private/kernel/boot/disk_identifier.h
+++ b/headers/private/kernel/boot/disk_identifier.h
@@ -63,6 +63,8 @@ typedef struct disk_identifier {
} _PACKED fibre;
struct {
off_t size;
+ uint8 uuid[16];
+ bool use_uuid;
struct {
off_t offset;
uint32 sum;
diff --git a/headers/private/kernel/boot/kernel_args.h
b/headers/private/kernel/boot/kernel_args.h
index 9a6a455..438b801 100644
--- a/headers/private/kernel/boot/kernel_args.h
+++ b/headers/private/kernel/boot/kernel_args.h
@@ -32,6 +32,7 @@
#define BOOT_VOLUME_PACKAGES_STATE "packages state"
#define BOOT_VOLUME_PARTITION_OFFSET "partition offset"
#define BOOT_VOLUME_DISK_IDENTIFIER "disk identifier"
+#define BOOT_VOLUME_PARTITION_UUID "partition uuid"

// boot methods
enum {
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/Header.h
b/src/add-ons/kernel/partitioning_systems/gpt/Header.h
index 64566d0..04a4ca2 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/Header.h
+++ b/src/add-ons/kernel/partitioning_systems/gpt/Header.h
@@ -30,6 +30,8 @@ public:
{
return fHeader.FirstUsableBlock(); }
uint64 LastUsableBlock() const
{
return fHeader.LastUsableBlock(); }
+ const guid_t& UUID() const
+ {
return fHeader.disk_guid; }

uint32 EntryCount() const
{
return fHeader.EntryCount(); }
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
index 5fc66f2..bba63a3 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
+++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
@@ -97,6 +97,7 @@ efi_gpt_scan_partition(int fd, partition_data* partition,
void* _cookie)
partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
partition->content_size = partition->size;
partition->content_cookie = header;
+ memcpy(partition->uuid, &header->UUID(), sizeof(guid_t));

// scan all children

@@ -135,6 +136,7 @@ efi_gpt_scan_partition(int fd, partition_data* partition,
void* _cookie)
child->type = strdup(get_partition_type(entry.partition_type));
child->block_size = partition->block_size;
child->cookie = (void*)(addr_t)i;
+ memcpy(child->uuid, &entry.unique_guid, sizeof(guid_t));
}

return B_OK;
diff --git a/src/system/kernel/fs/vfs_boot.cpp
b/src/system/kernel/fs/vfs_boot.cpp
index 0347bd7..3adf2b4 100644
--- a/src/system/kernel/fs/vfs_boot.cpp
+++ b/src/system/kernel/fs/vfs_boot.cpp
@@ -40,6 +40,8 @@
# define TRACE(x) ;
#endif

+#define UUID_LEN 16
+

typedef Stack<KPartition *> PartitionStack;

@@ -219,6 +221,11 @@ DiskBootMethod::IsBootDevice(KDiskDevice* device, bool
strict)

switch (disk->device_type) {
case UNKNOWN_DEVICE:
+ if (strict && disk->device.unknown.use_uuid) {
+ TRACE(("IsBootDevice: matching via uuid
only\n"));
+ return memcmp(disk->device.unknown.uuid,
device->PartitionData()->uuid, UUID_LEN) == 0;
+ }
+
// test if the size of the device matches
// (the BIOS might have given us the wrong value here,
though)
if (strict && device->Size() !=
disk->device.unknown.size)
@@ -256,9 +263,25 @@ DiskBootMethod::IsBootDevice(KDiskDevice* device, bool
strict)
}


+typedef struct {
+ uint8 uuid[UUID_LEN];
+} uuid_t;
+
+
bool
DiskBootMethod::IsBootPartition(KPartition* partition, bool& foundForSure)
{
+ uuid_t *uuid;
+ int32 uuidSize;
+ if (fBootVolume.FindData(BOOT_VOLUME_PARTITION_UUID, B_RAW_TYPE,
+ (const void**)&uuid, &uuidSize) == B_OK) {
+ // We have a UUID, so it must be a match to be the
+ // boot partition
+ TRACE(("IsBootPartition: matching via uuid only\n"));
+ foundForSure = memcmp(uuid->uuid,
partition->PartitionData()->uuid, UUID_LEN) == 0;
+ return foundForSure;
+ }
+
off_t bootPartitionOffset = fBootVolume.GetInt64(
BOOT_VOLUME_PARTITION_OFFSET, 0);



Other related posts: