Apple does not comply with the Open Firmware device-tree root /address-
cell and /size-cell size for G5 ppc64 /memory/available, resulting in
bad data from grub_machine_mmap_iterate when 64 bit offset is assumed.
Apple G4 ppc32 have no problem because /address-cell and /size-cell
are both 32 bit.
Other info from a later model Apple G5 PowerMac 8 slots with fitted
RAM 8GB also confirmed 32 bit offset and size in /memory/available.
Patch tested for both Apple G5 ppc64 and Apple iBook G4 ppc (32bit).
I now have burg -r 1788 with gfx menu themes running on G5 and G4, but
with some menu problems (keyboard, png background).
pxw@g5:~/src/burg$ bzr diff -r 1788
-----------------------------------
=== modified file 'kern/ieee1275/mmap.c'
--- kern/ieee1275/mmap.c 2009-11-21 19:42:31 +0000
+++ kern/ieee1275/mmap.c 2009-12-18 13:05:20 +0000
@@ -19,6 +19,7 @@
#include <grub/machine/memory.h>
#include <grub/ieee1275/ieee1275.h>
#include <grub/types.h>
+#include <grub/misc.h>
GRUB_EXPORT(grub_machine_mmap_iterate);
@@ -31,6 +32,7 @@
grub_ssize_t available_size;
grub_uint32_t address_cells = 1;
grub_uint32_t size_cells = 1;
+ char copyright[128];
int i;
/* Determine the format of each entry in `available'. */
@@ -39,8 +41,15 @@
sizeof address_cells, 0);
grub_ieee1275_get_integer_property (root, "#size-cells",
&size_cells,
sizeof size_cells, 0);
-
- if (size_cells > address_cells)
+ grub_ieee1275_get_property (root, "copyright",copyright,
+ sizeof copyright, 0);
+
+ if ( size_cells > address_cells )
+ address_cells = size_cells;
+
+/* Apple ppc g4, g5 /memory/available[] uses 32bit offset and size,
including for >4GB fitted RAM,
+ and does not use root cell sizes. Maybe some other ieee1275 Apple
uses 64bit offset and size? */
+ if ( grub_strstr(copyright,"Apple") )
address_cells = size_cells;
/* Load `/memory/available'. */
----------------------------------------
Here is the Open Firmware Device Tree information for the G5, with
fitted RAM 2 x 1 GB + 2 x 128 MB in 4 slots, The <available 00003000
7fbf9000> is at restart.
0 > dev / .properties
model PowerMac7,2
compatible PowerMac7,2
MacRISC4
Power Macintosh
serial-number PGA
YM413PDG
customer-sw-config
pid# 000021c2
scb# 00000002
name device-tree
copyright Copyright 1983-2003 Apple Computer, Inc. All
Rights Reserved
device_type bootrom
system-id 0000000000000
#address-cells 00000002
#size-cells 00000001
clock-frequency 2faf0800
AAPL,add-fcode-file ff865308
ok
0 > dev memory .properties
name memory
device_type memory
reg 00000000 00000000 40000000
00000000 40000000 40000000
00000001 00000000 10000000
00000000 00000000 00000000
00000000 00000000 00000000
00000000 00000000 00000000
00000000 00000000 00000000
00000000 00000000 00000000
slot-names 0000000f
DIMM0/J11
DIMM1/J12
DIMM2/J13
DIMM3/J14
available 00003000 7fbf9000
bank-names 0000000f
64 bit Bank0/J11/J12/front
64 bit Bank1/J11/J12/back
64 bit Bank2/J13/J14/front
64 bit Bank3/J13/J14/back
bank-sizes 40000000 40000000 10000000 00000000
dimm-info 8008070d 0b024000 04506500 82080001 0e041801
0220c060
7000003c 283c2880 60604040 00000000 00374620
28500000
00000000 00000000 00000000 000010b7 00000000
00000000
00000000 00000000 00000000 00000000 00000000
00000000
00000000 00000000 00000000 00000000 00000000
00000000
00000000 00000000 8008070d 0b024000 04506500
82080001
0e041801 0220c060 7000003c 283c2880 60604040
00000000
00374620 28500000 00000000 00000000 00000000
000010b7
00000000 00000000 00000000 00000000 00000000
00000000
00000000 00000000 00000000 00000000 00000000
00000000
00000000 00000000 00000000 00000000
... 00000200 bytes total
dimm-types DDR SDRAM
DDR SDRAM
DDR SDRAM
DDR SDRAM
dimm-speeds PC3200U-30330
PC3200U-30330
PC3200U-30330
PC3200U-30330
ram-layout-architecture 00000001
0 > dev .. ok
0 > pwd / ok
0 > boot sd1:5,\grub\grub.of load-size=45a50 adler32=3aa3532c
Loading ELF
-----------------
After boot by grub - Debian /proc/device-tree info
pxw@g5:~$ cat /proc/device-tree/copyright;echo
Copyright 1983-2003 Apple Computer, Inc. All Rights Reserved
pxw@g5:~$ hexdump -x /proc/device-tree/memory@0\,0/available;echo
0000000 0040 0000 0100 0000 022e 0300 0000
0d00
0000010 023e 1000 7d81
b000
0000018
pxw@g5:~$ hexdump -x /proc/device-tree/#address-cells
0000000 0000
0002
0000004
pxw@g5:~$ hexdump -x /proc/device-tree/#size-cells
0000000 0000
0001
0000004
--------------------
Thanks a lot pxw, committed as r1791.
--
Bean
Project: https://launchpad.net/burg
Document: https://help.ubuntu.com/community/Burg
Mailing list: http://groups.google.com/group/burg-devel