Author: kallisti5 Date: 2011-07-26 17:09:18 +0200 (Tue, 26 Jul 2011) New Revision: 42497 Changeset: https://dev.haiku-os.org/changeset/42497 Modified: haiku/trunk/headers/private/kernel/platform/openfirmware/openfirmware.h haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp haiku/trunk/src/system/boot/platform/openfirmware/of_support.cpp haiku/trunk/src/system/boot/platform/openfirmware/of_support.h Log: * Fix a few style issues as per Axel * Rename a few variables to make more sense * OF_FAILED is a signed int.. fix return of of_address_cells * OF_FAILED is a signed int.. fix return of of_size_cells Modified: haiku/trunk/headers/private/kernel/platform/openfirmware/openfirmware.h =================================================================== --- haiku/trunk/headers/private/kernel/platform/openfirmware/openfirmware.h 2011-07-26 06:49:16 UTC (rev 42496) +++ haiku/trunk/headers/private/kernel/platform/openfirmware/openfirmware.h 2011-07-26 15:09:18 UTC (rev 42497) @@ -11,13 +11,14 @@ #define OF_FAILED (-1) + /* global device tree/properties access */ extern int gChosen; -template<typename addressSize> +template<typename AddressSize> struct of_region { - addressSize base; + AddressSize base; uint32 size; }; Modified: haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp 2011-07-26 06:49:16 UTC (rev 42496) +++ haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp 2011-07-26 15:09:18 UTC (rev 42497) @@ -1,6 +1,11 @@ /* * Copyright 2003-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx - * 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@xxxxxxxxxxxxxxxxx + * Alexander von Gluck, kallisti5@xxxxxxxxxxx */ @@ -19,6 +24,7 @@ #include "of_support.h" + // set protection to WIMGNPP: -----PP // PP: 00 - no access // 01 - read only @@ -78,28 +84,28 @@ 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<uint64> regions[64]; int count = of_getprop(package, "reg", regions, sizeof(regions)); if (count == OF_FAILED) Modified: haiku/trunk/src/system/boot/platform/openfirmware/of_support.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/of_support.cpp 2011-07-26 06:49:16 UTC (rev 42496) +++ haiku/trunk/src/system/boot/platform/openfirmware/of_support.cpp 2011-07-26 15:09:18 UTC (rev 42497) @@ -25,7 +25,7 @@ + in the reg property + */ -uint32 +int32 of_address_cells(int package) { uint32 address_cells; if (of_getprop(package, "#address-cells", @@ -36,7 +36,7 @@ } -uint32 +int32 of_size_cells(int package) { uint32 size_cells; if (of_getprop(package, "#size-cells", Modified: haiku/trunk/src/system/boot/platform/openfirmware/of_support.h =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/of_support.h 2011-07-26 06:49:16 UTC (rev 42496) +++ haiku/trunk/src/system/boot/platform/openfirmware/of_support.h 2011-07-26 15:09:18 UTC (rev 42497) @@ -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