diff --git a/headers/private/kernel/platform/openfirmware/openfirmware.h b/headers/private/kernel/platform/openfirmware/openfirmware.h index 7510425db8..3fe2c30d84 100644 --- a/headers/private/kernel/platform/openfirmware/openfirmware.h +++ b/headers/private/kernel/platform/openfirmware/openfirmware.h @@ -11,13 +11,14 @@ #define OF_FAILED (-1) + /* global device tree/properties access */ extern int gChosen; -template +template struct of_region { - addressSize base; + AddressSize base; uint32 size; }; diff --git a/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp b/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp index b3111e8176..345a45e0cf 100644 --- a/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp +++ b/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp @@ -1,6 +1,11 @@ /* * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. - * Distributed under the terms of the MIT License. + * Copyright 2010-2011, Haiku, Inc. All Rights Reserved. + * All rights reserved. Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de. + * Alexander von Gluck, kallisti5@unixzen.com */ @@ -19,6 +24,7 @@ #include "of_support.h" + // set protection to WIMGNPP: -----PP // PP: 00 - no access // 01 - read only @@ -78,28 +84,28 @@ find_physical_memory_ranges(size_t &total) total = 0; - /* Memory base addresses are provided in 32 or 64 bit flavors - #address-cells and #size-cells matches the number of 32-bit 'cells' - representing the length of the base address and size fields - */ + // Memory base addresses are provided in 32 or 64 bit flavors + // #address-cells and #size-cells matches the number of 32-bit 'cells' + // representing the length of the base address and size fields int root = of_finddevice("/"); - int regAddressCount = of_address_cells(root); - int regSizeCount = of_size_cells(root); - if (regAddressCount == OF_FAILED || regSizeCount == OF_FAILED) { + int32 regAddressCells = of_address_cells(root); + int32 regSizeCells = of_size_cells(root); + if (regAddressCells == OF_FAILED || regSizeCells == OF_FAILED) { dprintf("finding base/size length counts failed, assume 32-bit.\n"); - regAddressCount = 1; - regSizeCount = 1; + regAddressCells = 1; + regSizeCells = 1; } - dprintf("memory range address cells: %d; size cells: %d;\n", - regAddressCount, regSizeCount); - if (regAddressCount > 2 || regSizeCount > 1) { - dprintf("Unsupported cell size detected. (machine is > 64bit?).\n"); + // NOTE : Size Cells of 2 is possible in theory... but I haven't seen it yet. + if (regAddressCells > 2 || regSizeCells > 1) { + panic("%s: Unsupported OpenFirmware cell count detected.\n" + "Address Cells: %" B_PRId32 "; Size Cells: %" B_PRId32 + " (CPU > 64bit?).\n", __func__, regAddressCells, regSizeCells); return B_ERROR; } // On 64-bit PowerPC systems (G5), our mem base range address is larger - if (regAddressCount == 2) { + if (regAddressCells == 2) { struct of_region regions[64]; int count = of_getprop(package, "reg", regions, sizeof(regions)); if (count == OF_FAILED) diff --git a/src/system/boot/platform/openfirmware/of_support.cpp b/src/system/boot/platform/openfirmware/of_support.cpp index 545e952f3f..6c6d033b88 100644 --- a/src/system/boot/platform/openfirmware/of_support.cpp +++ b/src/system/boot/platform/openfirmware/of_support.cpp @@ -25,7 +25,7 @@ system_time(void) + in the reg property + */ -uint32 +int32 of_address_cells(int package) { uint32 address_cells; if (of_getprop(package, "#address-cells", @@ -36,7 +36,7 @@ of_address_cells(int package) { } -uint32 +int32 of_size_cells(int package) { uint32 size_cells; if (of_getprop(package, "#size-cells", diff --git a/src/system/boot/platform/openfirmware/of_support.h b/src/system/boot/platform/openfirmware/of_support.h index a7667ec396..d7e0c66d27 100644 --- a/src/system/boot/platform/openfirmware/of_support.h +++ b/src/system/boot/platform/openfirmware/of_support.h @@ -13,7 +13,7 @@ bigtime_t system_time(void); -uint32 of_address_cells(int package); -uint32 of_size_cells(int package); +int32 of_address_cells(int package); +int32 of_size_cells(int package); #endif