* 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 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42497 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,13 +11,14 @@
|
|||||||
|
|
||||||
#define OF_FAILED (-1)
|
#define OF_FAILED (-1)
|
||||||
|
|
||||||
|
|
||||||
/* global device tree/properties access */
|
/* global device tree/properties access */
|
||||||
extern int gChosen;
|
extern int gChosen;
|
||||||
|
|
||||||
|
|
||||||
template<typename addressSize>
|
template<typename AddressSize>
|
||||||
struct of_region {
|
struct of_region {
|
||||||
addressSize base;
|
AddressSize base;
|
||||||
uint32 size;
|
uint32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009, Axel Dörfler, [email protected].
|
* Copyright 2003-2009, Axel Dörfler, [email protected].
|
||||||
* 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, [email protected].
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +24,7 @@
|
|||||||
|
|
||||||
#include "of_support.h"
|
#include "of_support.h"
|
||||||
|
|
||||||
|
|
||||||
// set protection to WIMGNPP: -----PP
|
// set protection to WIMGNPP: -----PP
|
||||||
// PP: 00 - no access
|
// PP: 00 - no access
|
||||||
// 01 - read only
|
// 01 - read only
|
||||||
@@ -78,28 +84,28 @@ find_physical_memory_ranges(size_t &total)
|
|||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
|
|
||||||
/* Memory base addresses are provided in 32 or 64 bit flavors
|
// Memory base addresses are provided in 32 or 64 bit flavors
|
||||||
#address-cells and #size-cells matches the number of 32-bit 'cells'
|
// #address-cells and #size-cells matches the number of 32-bit 'cells'
|
||||||
representing the length of the base address and size fields
|
// representing the length of the base address and size fields
|
||||||
*/
|
|
||||||
int root = of_finddevice("/");
|
int root = of_finddevice("/");
|
||||||
int regAddressCount = of_address_cells(root);
|
int32 regAddressCells = of_address_cells(root);
|
||||||
int regSizeCount = of_size_cells(root);
|
int32 regSizeCells = of_size_cells(root);
|
||||||
if (regAddressCount == OF_FAILED || regSizeCount == OF_FAILED) {
|
if (regAddressCells == OF_FAILED || regSizeCells == OF_FAILED) {
|
||||||
dprintf("finding base/size length counts failed, assume 32-bit.\n");
|
dprintf("finding base/size length counts failed, assume 32-bit.\n");
|
||||||
regAddressCount = 1;
|
regAddressCells = 1;
|
||||||
regSizeCount = 1;
|
regSizeCells = 1;
|
||||||
}
|
}
|
||||||
dprintf("memory range address cells: %d; size cells: %d;\n",
|
|
||||||
regAddressCount, regSizeCount);
|
|
||||||
|
|
||||||
if (regAddressCount > 2 || regSizeCount > 1) {
|
// NOTE : Size Cells of 2 is possible in theory... but I haven't seen it yet.
|
||||||
dprintf("Unsupported cell size detected. (machine is > 64bit?).\n");
|
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;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On 64-bit PowerPC systems (G5), our mem base range address is larger
|
// 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];
|
struct of_region<uint64> regions[64];
|
||||||
int count = of_getprop(package, "reg", regions, sizeof(regions));
|
int count = of_getprop(package, "reg", regions, sizeof(regions));
|
||||||
if (count == OF_FAILED)
|
if (count == OF_FAILED)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ system_time(void)
|
|||||||
+ in the reg property
|
+ in the reg property
|
||||||
+ */
|
+ */
|
||||||
|
|
||||||
uint32
|
int32
|
||||||
of_address_cells(int package) {
|
of_address_cells(int package) {
|
||||||
uint32 address_cells;
|
uint32 address_cells;
|
||||||
if (of_getprop(package, "#address-cells",
|
if (of_getprop(package, "#address-cells",
|
||||||
@@ -36,7 +36,7 @@ of_address_cells(int package) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
int32
|
||||||
of_size_cells(int package) {
|
of_size_cells(int package) {
|
||||||
uint32 size_cells;
|
uint32 size_cells;
|
||||||
if (of_getprop(package, "#size-cells",
|
if (of_getprop(package, "#size-cells",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
bigtime_t system_time(void);
|
bigtime_t system_time(void);
|
||||||
uint32 of_address_cells(int package);
|
int32 of_address_cells(int package);
|
||||||
uint32 of_size_cells(int package);
|
int32 of_size_cells(int package);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user