Author: kallisti5 Date: 2011-07-20 22:31:32 +0200 (Wed, 20 Jul 2011) New Revision: 42459 Changeset: https://dev.haiku-os.org/changeset/42459 Modified: haiku/trunk/src/system/boot/platform/openfirmware/machine.h haiku/trunk/src/system/boot/platform/openfirmware/start.cpp Log: * Clean up OpenFirmware machine detections * Detect OpenBIOS used in QEMU and set machine flag (OpenBIOS isn't 1:1 Apple OpenFirmware) * Show at boot which machine type is detected Modified: haiku/trunk/src/system/boot/platform/openfirmware/machine.h =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/machine.h 2011-07-20 17:06:13 UTC (rev 42458) +++ haiku/trunk/src/system/boot/platform/openfirmware/machine.h 2011-07-20 20:31:32 UTC (rev 42459) @@ -9,12 +9,15 @@ #include <SupportDefs.h> +// Possible gMachine OpenFirmware platforms #define MACHINE_UNKNOWN 0x0000 #define MACHINE_CHRP 0x0001 #define MACHINE_MAC 0x0002 #define MACHINE_PEGASOS 0x0100 +#define MACHINE_QEMU 0x0200 +#define MACHINE_SPARC 0x0300 extern uint32 gMachine; Modified: haiku/trunk/src/system/boot/platform/openfirmware/start.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/start.cpp 2011-07-20 17:06:13 UTC (rev 42458) +++ haiku/trunk/src/system/boot/platform/openfirmware/start.cpp 2011-07-20 20:31:32 UTC (rev 42459) @@ -1,5 +1,6 @@ /* * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2011, Alexander von Gluck, kallisti5@xxxxxxxxxxx * Distributed under the terms of the MIT License. */ @@ -61,26 +62,28 @@ int root = of_finddevice("/"); char buffer[64]; - int length; - if ((length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 1)) - == OF_FAILED) - return; + + // TODO : Probe other OpenFirmware platforms and set gMachine as needed + + int length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 1); buffer[length] = '\0'; - // ToDo: add more, and be as generic as possible - if (!strcasecmp("chrp", buffer)) gMachine = MACHINE_CHRP; - else if (!strcasecmp("bootrom", buffer)) + else //(bootrom) + QEMU gMachine = MACHINE_MAC; - - if ((length = of_getprop(root, "model", buffer, sizeof(buffer) - 1)) - == OF_FAILED) - return; + + length = of_getprop(root, "model", buffer, sizeof(buffer) - 1); buffer[length] = '\0'; if (!strcasecmp("pegasos", buffer)) gMachine |= MACHINE_PEGASOS; + + length = of_getprop(root, "name", buffer, sizeof(buffer) - 1); + buffer[length] = '\0'; + + if (!strcasecmp("openbiosteam,openbios", buffer)) + gMachine |= MACHINE_QEMU; } @@ -156,6 +159,13 @@ determine_machine(); console_init(); + if (gMachine & MACHINE_QEMU) + dprintf("OpenBIOS (QEMU?) OpenFirmware machine detected\n"); + else if (gMachine & MACHINE_PEGASOS) + dprintf("Pegasos PowerPC machine detected\n"); + else + dprintf("Apple PowerPC machine assumed\n"); + // Initialize and take over MMU and set the OpenFirmware callbacks - it // will ask us for memory after that instead of maintaining it itself // (the kernel will need to adjust the callback later on as well)