From c9593d22533995d0f928b07afe2cecf3195e759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Oct 2003 21:24:28 +0000 Subject: [PATCH] Now uses the OF root node properties "model" and "device_type" to get and idea about the underlying hardware (needed at other places). Calls arch_set_callback() right after MMU takeover. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5204 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../boot/platform/openfirmware/machine.h | 23 +++++++++++ src/kernel/boot/platform/openfirmware/start.c | 38 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/kernel/boot/platform/openfirmware/machine.h diff --git a/src/kernel/boot/platform/openfirmware/machine.h b/src/kernel/boot/platform/openfirmware/machine.h new file mode 100644 index 0000000000..c0fbd6b023 --- /dev/null +++ b/src/kernel/boot/platform/openfirmware/machine.h @@ -0,0 +1,23 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef MACHINE_H +#define MACHINE_H + + +#include + + +#define MACHINE_UNKNOWN 0x0000 + +#define MACHINE_CHRP 0x0001 +#define MACHINE_MAC 0x0002 + +#define MACHINE_PEGASOS 0x0100 + + +extern uint32 gMachine; + // stores the machine type + +#endif /* MACHINE_H */ diff --git a/src/kernel/boot/platform/openfirmware/start.c b/src/kernel/boot/platform/openfirmware/start.c index 751df8db1e..ac7e312945 100644 --- a/src/kernel/boot/platform/openfirmware/start.c +++ b/src/kernel/boot/platform/openfirmware/start.c @@ -13,6 +13,7 @@ #include "openfirmware.h" #include "console.h" +#include "machine.h" #define HEAP_SIZE 32768 @@ -27,6 +28,8 @@ extern void (*__ctor_end)(void); extern uint8 __bss_start; extern uint8 _end; +uint32 gMachine; + static void call_ctors(void) @@ -46,6 +49,34 @@ clear_bss(void) } +static void +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 + + gMachine = MACHINE_UNKNOWN; + + if (!strcasecmp("chrp", buffer)) + gMachine = MACHINE_CHRP; + else if (!strcasecmp("bootrom", buffer)) + gMachine = MACHINE_MAC; + + if ((length = of_getprop(root, "model", buffer, sizeof(buffer) - 1)) == OF_FAILED) + return; + buffer[length] = '\0'; + + if (!strcasecmp("pegasos", buffer)) + gMachine |= MACHINE_PEGASOS; +} + + void _start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry) { @@ -68,8 +99,15 @@ start(void *openFirmwareEntry) args.heap_size = HEAP_SIZE; of_init(openFirmwareEntry); + + determine_machine(); console_init(); + + // 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) arch_mmu_init(); + arch_set_callback(); main(&args); // if everything wents fine, main() never returns