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