Author: mcayland Date: Tue Jun 15 18:31:54 2010 New Revision: 794 URL: http://tracker.coreboot.org/trac/openbios/changeset/794
Log: Fix the HFSP probe function, plus also resolve an off-by-one error in the mac-parts partition code. This should fix PPC boot once again.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/fs/hfsplus/volume.c trunk/openbios-devel/packages/mac-parts.c
Modified: trunk/openbios-devel/fs/hfsplus/volume.c ============================================================================== --- trunk/openbios-devel/fs/hfsplus/volume.c Thu Jun 10 20:35:25 2010 (r793) +++ trunk/openbios-devel/fs/hfsplus/volume.c Tue Jun 15 18:31:54 2010 (r794) @@ -294,17 +294,21 @@ int volume_probe(int fd, llong offset) { - struct hfsp_vh *vol; + UInt16 *vol; + int ret = 0;
- vol = (struct hfsp_vh*)malloc(2 * 1 << HFSP_BLOCKSZ_BITS); + vol = (UInt16 *)malloc(2 * 1 << HFSP_BLOCKSZ_BITS); os_seek_offset( fd, 2 * (1 << HFSP_BLOCKSZ_BITS) + offset ); os_read(fd, vol, 2, HFSP_BLOCKSZ_BITS);
- if (__be16_to_cpu(vol->signature) != HFSP_VOLHEAD_SIG) { - free(vol); - return 0; + if (__be16_to_cpu(vol[0]) == HFS_VOLHEAD_SIG && + __be16_to_cpu(vol[0x7c]) == HFSP_VOLHEAD_SIG) { + ret = -1; + } else if (__be16_to_cpu(vol[0]) == HFSP_VOLHEAD_SIG) { + ret = -1; }
free(vol); - return -1; + return ret; } +
Modified: trunk/openbios-devel/packages/mac-parts.c ============================================================================== --- trunk/openbios-devel/packages/mac-parts.c Thu Jun 10 20:35:25 2010 (r793) +++ trunk/openbios-devel/packages/mac-parts.c Tue Jun 15 18:31:54 2010 (r794) @@ -127,13 +127,12 @@ /* search a bootable partition */ /* see PowerPC Microprocessor CHRP bindings */
- parnum = 1; - while (parnum <= __be32_to_cpu(par.pmMapBlkCnt)) { - SEEK( (bs * parnum) ); + for (parnum = 0; parnum <= __be32_to_cpu(par.pmMapBlkCnt); parnum++) { + SEEK( (bs * (parnum + 1)) ); READ( &par, sizeof(par) ); if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE || !__be16_to_cpu(par.pmPartBlkCnt) ) - goto out; + break;
DPRINTF("found partition type: %s\n", par.pmPartType);
@@ -169,7 +168,6 @@ goto out; }
- parnum++; } /* not found */ if (firstHFS != -1) { @@ -199,7 +197,7 @@ goto out;
found: - SEEK( (bs * parnum) ); + SEEK( (bs * (parnum + 1)) ); READ( &par, sizeof(par) ); if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE || !__be32_to_cpu(par.pmPartBlkCnt) ) goto out;