diff --git a/src/kernel/boot/platform/openfirmware/devices.cpp b/src/kernel/boot/platform/openfirmware/devices.cpp index aa3c7fb2c4..5bfa6c3165 100644 --- a/src/kernel/boot/platform/openfirmware/devices.cpp +++ b/src/kernel/boot/platform/openfirmware/devices.cpp @@ -6,6 +6,7 @@ #include "Handle.h" #include "openfirmware.h" +#include "machine.h" #include #include @@ -95,9 +96,22 @@ platform_get_boot_device(struct stage2_args *args, Node **_device) char type[16]; of_getprop(node, "device_type", type, sizeof(type)); printf("boot type = %s\n", type); + if (strcmp("block", type)) { + printf("boot device is not a block device!\n"); + return B_ENTRY_NOT_FOUND; + } } else printf("could not open boot path.\n"); +/* char name[256]; + strcpy(name, sBootPath); + strcat(name, ":kernel_ppc"); + int kernel = of_open(name); + if (kernel == OF_FAILED) { + puts("open kernel failed"); + } else + puts("open kernel succeeded"); +*/ int handle = of_open(sBootPath); if (handle == OF_FAILED) { puts("\t\t(open failed)"); @@ -129,6 +143,44 @@ platform_get_boot_partition(struct stage2_args *args, NodeList *list, } +#define DUMPED_BLOCK_SIZE 16 + +void +dumpBlock(const char *buffer, int size, const char *prefix) +{ + int i; + + for (i = 0; i < size;) { + int start = i; + + printf(prefix); + for (; i < start+DUMPED_BLOCK_SIZE; i++) { + if (!(i % 4)) + printf(" "); + + if (i >= size) + printf(" "); + else + printf("%02x", *(unsigned char *)(buffer + i)); + } + printf(" "); + + for (i = start; i < start + DUMPED_BLOCK_SIZE; i++) { + if (i < size) { + char c = buffer[i]; + + if (c < 30) + printf("."); + else + printf("%c", c); + } else + break; + } + printf("\n"); + } +} + + status_t platform_add_block_devices(stage2_args *args, NodeList *devicesList) { @@ -143,7 +195,19 @@ platform_add_block_devices(stage2_args *args, NodeList *devicesList) continue; } + // Adjust the arguments passed to the open command so that + // the disk-label package is by-passed - unfortunately, + // this is implementation specific (and I found no docs + // for the Apple OF disk-label usage, of course) + + // SUN's OpenBoot: + //strcpy(path + strlen(path), ":nolabel"); + // Apple: + if (gMachine & MACHINE_MAC) + strcpy(path + strlen(path), ":0"); + printf("\t%s\n", path); + int handle = of_open(path); if (handle == OF_FAILED) { puts("\t\t(failed)");