set prefix on PPC
Updated patch which uses devaliases.
-Hollis
2005-04-17 Hollis Blanchard <[email protected]>
* include/grub/powerpc/ieee1275/ieee1275.h (grub_ieee1275_encode_devname): New prototype. (grub_ieee1275_get_filename): Likewise. * kern/powerpc/ieee1275/init.c (grub_translate_ieee175_path): New function. (grub_set_prefix): Likewise. (grub_machine_init): Call grub_set_prefix. * kern/powerpc/ieee1275/openfw.c: Fix typos. (grub_parse_type): New enum. (grub_ieee1275_get_devargs): New function. (grub_ieee1275_get_devname): Likewise. (grub_ieee1275_parse_args): Likewise. (grub_ieee1275_get_filename): Likewise. (grub_ieee1275_encode_devname): Likewise.
Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.15
grub/powerpc/ieee1275/ieee1275.h +2 -0
@@ -134,5 +134,7 @@ void EXPORT_FUNC(abort) (void);void EXPORT_FUNC (grub_reboot ) (void );void EXPORT_FUNC (grub_halt ) (void ); +char *EXPORT_FUNC (grub_ieee1275_encode_devname ) (const char *path); +char *EXPORT_FUNC (grub_ieee1275_get_filename ) (const char *path);#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.15
powerpc/ieee1275/init.c +64 -1
77 lines not on this page · raw message
Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v retrieving revision 1.8
powerpc/ieee1275/openfw.c +157 -2
183 lines not on this page · raw message
Quoted 1 line · Hollis Blanchard
Updated patch which uses devaliases.
On my pegasos the devalias is looked up perfectly for both ethernet and the harddisk. :)
powerpc/ieee1275/openfw.c grub_claimmap (grub_addr_t addr, grub_si · line 340
Quoted 4 lines
powerpc/ieee1275/openfw.c +4
-0+if (partition) + { +unsigned int partno =grub_strtoul (partition,0 ,0 ); + partno--;/* GRUB partition numbering is 0-based. */
On my pegasos the partition numbering is 0-based as well. So when I run boot hd:4 grub2', I get prefix=(hd,3)'. This should be `prefix=(hd,4)'. So my pegasos has proven me right already about what I said about firmware. :-/
Thanks,
Marco
Quoted 7 lines · Marco Gerards
Quoted 1 line · Hollis Blanchard
Updated patch which uses devaliases.
On my pegasos the devalias is looked up perfectly for both ethernet and the harddisk. :)
Quoted 6 lines
powerpc/ieee1275/openfw.c grub_claimmap (grub_addr_t addr, grub_si · line 340
Quoted 4 lines
powerpc/ieee1275/openfw.c +4
-0+if (partition) + { +unsigned int partno =grub_strtoul (partition,0 ,0 ); + partno--;/* GRUB partition numbering is 0-based. */ On my pegasos the partition numbering is 0-based as well.
Are you sure? This behavior is not CHRP-compliant. The spec is quite clear in that regard:
11.1.2. Open Method Algorithm
...
If the partition component is present, it selects the desired
partition, where
partition 0 refers to the entire disk, partition 1 refers to the first
partition,
partition 2 to the second, and so forth.
Instead, perhaps our MS-DOS partition map enumeration differs from the firmware's. In that case, firmware would not be "0-based", but simply different.
This deserves further investigation. I will see what my briQ does, but not tonight. I think that this failure on Pegasos does not warrant delaying the prefix patch further, since the patch does not break any existing functionality and adds important functionality on Macs. Can Pegasos be fixed later?
Quoted 3 lines
So when I run
boot hd:4 grub2', I getprefix=(hd,3)'. This should be `prefix=(hd,4)'. So my pegasos has proven me right already about what I said about firmware. :-/
If this is the case we will need another flag for grub_ieee1275_flags.
-Hollis
Re: [patch] set prefix on PPC - briQ results
I've tested the patch on briQ. As far as I can tell, CodeGen's "SmartFirmware" is crap, frequently suffering mysterious failures that require unplugging and waiting (unplugging and replugging rapidly isn't enough). It also suffers frequent ATA failures, where the disk or controller simply stop responding.
1. (major) Firmware does not properly set /chosen/bootpath to include the partition number.
2. (major) Partition numbering *seems* to be 0-based. I had a lot of problems booting, but I'm pretty sure it is.
3. (minor) /chosen/bootpath is this:
/pci@FF500000/isa@6/ide@i1F0/disk@0,0 but the "hd" devalias is this: /pci@FF500000/isa@6/ide@i1f0/disk@0,0
Note the differing case of "f". This prevents the devalias matching from succeeding. I've fixed this by using strncasecmp instead of strncmp.
There are various other problems, such as ignoring arguments to the "boot" command and instead always using boot-device and boot-file. Also I get unexplained errors like these:
ok boot hda:0,/grubof.chrp
error: error while trying to load or boot
but this works:
ok " hda:0" " /grubof.chrp" (load) go
Problem 1 could be worked around by taking the yaboot approach: iterate over all disk partitions looking for a file named "/grub/grub.cfg" (i.e. /boot/grub/grub.cfg). This fallback can be used if we do not find a grub.cfg in prefix.
Problem 2 could be worked around by blacklisting firmwares based on the /openprom properties. Here is the briQ's output:
ok dev /openprom
ok .properties
relative-addressing
model "BRIQ,1.0.2.60"
SmartFirmware-version "1.1"
CodeGen-copyright "SmartFirmware(tm) Copyright 1996-2000 by
CodeGen, Inc. All Rights Reserved."
name "openprom"
Does the Pegasos have a SmartFirmware-version property?
-Hollis
Re: [patch] set prefix on PPC - briQ results
Quoted 8 lines · Hollis Blanchard
I've tested the patch on briQ. As far as I can tell, CodeGen's "SmartFirmware" is crap, frequently suffering mysterious failures that require unplugging and waiting (unplugging and replugging rapidly isn't enough). It also suffers frequent ATA failures, where the disk or controller simply stop responding.
1. (major) Firmware does not properly set /chosen/bootpath to include the partition number.
What happens? Is it something I could try to reproduce on the PegasosII?
Quoted 2 lines
2. (major) Partition numbering *seems* to be 0-based. I had a lot of problems booting, but I'm pretty sure it is.
Same on the pegasos... :/
Quoted 7 lines
3. (minor) /chosen/bootpath is this:
/pci@FF500000/isa@6/ide@i1F0/disk@0,0 but the "hd" devalias is this: /pci@FF500000/isa@6/ide@i1f0/disk@0,0Note the differing case of "f". This prevents the devalias matching from succeeding. I've fixed this by using strncasecmp instead of strncmp.
That seems the right way to solve this problem.
Quoted 4 lines
Problem 1 could be worked around by taking the yaboot approach:
iterate over all disk partitions looking for a file named "/grub/grub.cfg" (i.e./boot/grub/grub.cfg). This fallback can be used if we do not find a grub.cfg in prefix.
Right...
Quoted 2 lines
Problem 2 could be worked around by blacklisting firmwares based on the /openprom properties. Here is the briQ's output:
With blacklist you mean setting some additional flags that describe which bugs the firmware has?
Quoted 10 lines
ok dev /openprom
ok .properties
relative-addressing
model "BRIQ,1.0.2.60"
SmartFirmware-version "1.1"
CodeGen-copyright "SmartFirmware(tm) Copyright 1996-2000
by CodeGen, Inc. All Rights Reserved."
name "openprom"Does the Pegasos have a SmartFirmware-version property?
It does. It has both a CodeGen and bplan copyright property. The SmartFirmware-version is 1.2 here. The model is "Pegasos2,1.2". It seems to me that this SmartFirmware-version is not interesting because it looks like this version is not changed for every build.
The most interesting property is "built-on", which we can use to detect if a specific version has the bug or not.
Thanks,
Marco
Re: [patch] set prefix on PPC - briQ results
Quoted 8 lines · Marco Gerards
Quoted 6 lines · Hollis Blanchard
I've tested the patch on briQ. As far as I can tell, CodeGen's "SmartFirmware" is crap, frequently suffering mysterious failures that require unplugging and waiting (unplugging and replugging rapidly isn't enough). It also suffers frequent ATA failures, where the disk or controller simply stop responding.
Quoted 4 lines
Quoted 2 lines
1. (major) Firmware does not properly set /chosen/bootpath to include the partition number.
What happens? Is it something I could try to reproduce on the PegasosII?
Boot GRUB, run suspend, "dev /chosen .properties". You'll notice the device arguments are missing from bootpath.
Quoted 5 lines
Quoted 4 lines
Problem 1 could be worked around by taking the yaboot approach:
iterate over all disk partitions looking for a file named "/grub/grub.cfg" (i.e./boot/grub/grub.cfg). This fallback can be used if we do not find a grub.cfg in prefix.
Quoted 7 lines
Right...
Quoted 2 lines
Problem 2 could be worked around by blacklisting firmwares based on the /openprom properties. Here is the briQ's output:
With blacklist you mean setting some additional flags that describe which bugs the firmware has?
Yes.
Quoted 11 lines
Quoted 10 lines
ok dev /openprom
ok .properties
relative-addressing
model "BRIQ,1.0.2.60"
SmartFirmware-version "1.1"
CodeGen-copyright "SmartFirmware(tm) Copyright 1996-2000
by CodeGen, Inc. All Rights Reserved."
name "openprom"Does the Pegasos have a SmartFirmware-version property?
Quoted 7 lines
It does. It has both a CodeGen and bplan copyright property. The SmartFirmware-version is 1.2 here. The model is "Pegasos2,1.2". It seems to me that this SmartFirmware-version is not interesting because it looks like this version is not changed for every build.
The most interesting property is "built-on", which we can use to detect if a specific version has the bug or not.
Right now I'm inclined to set a "0_BASED_PARTITION" flag if the SmartFirmware-version property exists. Later on if bplan fixes it then they will need to provide some other property we can examine.
After I check in my patch I will work on these workarounds.
-Hollis
Re: [patch] set prefix on PPC - briQ results
Quoted 7 lines · Hollis Blanchard
Quoted 7 lines
Quoted 1 line
Does the Pegasos have a SmartFirmware-version property?
It does. It has both a CodeGen and bplan copyright property. The SmartFirmware-version is 1.2 here. The model is "Pegasos2,1.2". It seems to me that this SmartFirmware-version is not interesting because it looks like this version is not changed for every build.
Quoted 6 lines
Quoted 2 lines
The most interesting property is "built-on", which we can use to detect if a specific version has the bug or not.
Right now I'm inclined to set a "0_BASED_PARTITION" flag if the SmartFirmware-version property exists. Later on if bplan fixes it then they will need to provide some other property we can examine.
Agreed.
Quoted 1 line
After I check in my patch I will work on these workarounds.
Fine for me.
Thanks,
Marco