From 372fe617b28c085efad6964dcb144f2f97ef840e Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Wed, 20 Jul 2011 20:31:32 +0000 Subject: [PATCH] * 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 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42459 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../boot/platform/openfirmware/machine.h | 3 ++ .../boot/platform/openfirmware/start.cpp | 32 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/system/boot/platform/openfirmware/machine.h b/src/system/boot/platform/openfirmware/machine.h index 3aca3fad6c..662f52d89d 100644 --- a/src/system/boot/platform/openfirmware/machine.h +++ b/src/system/boot/platform/openfirmware/machine.h @@ -9,12 +9,15 @@ #include +// 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; diff --git a/src/system/boot/platform/openfirmware/start.cpp b/src/system/boot/platform/openfirmware/start.cpp index b159023b87..1a4a14f4d8 100644 --- a/src/system/boot/platform/openfirmware/start.cpp +++ b/src/system/boot/platform/openfirmware/start.cpp @@ -1,5 +1,6 @@ /* * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2011, Alexander von Gluck, kallisti5@unixzen.com * Distributed under the terms of the MIT License. */ @@ -61,26 +62,28 @@ determine_machine(void) int root = of_finddevice("/"); char buffer[64]; - int length; - if ((length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 1)) - == OF_FAILED) - return; - buffer[length] = '\0'; - // ToDo: add more, and be as generic as possible + // TODO : Probe other OpenFirmware platforms and set gMachine as needed + + int length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 1); + buffer[length] = '\0'; 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 @@ start(void *openFirmwareEntry) 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)