Author: laurent Date: 2009-08-29 17:24:49 +0200 (Sat, 29 Aug 2009) New Revision: 570
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/modules/mac-parts.c Log: For mac-parts, when no partition number is provided, open the first HFS partition (type is "Apple_HFS").
Signed-off-by: Laurent Vivier Laurent@vivier.eu
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c =================================================================== --- trunk/openbios-devel/arch/ppc/qemu/main.c 2009-08-23 12:40:24 UTC (rev 569) +++ trunk/openbios-devel/arch/ppc/qemu/main.c 2009-08-29 15:24:49 UTC (rev 570) @@ -126,11 +126,11 @@ path++;
if (!*path) - return 0; + return -1; path++;
if (!strchr(path, ',')) /* check if there is a ',' */ - return 0; + return -1;
return atol(path); } @@ -177,10 +177,16 @@ char path[1024]; phandle_t chosen_ph = find_dev("/chosen"); char *filename, *directory; + int partition;
filename = get_filename(spec, &directory); - snprintf(path, sizeof(path), "%s:%d,%s\%s", get_device(spec), - get_partition(spec), directory, filename); + partition = get_partition(spec); + if (partition == -1) + snprintf(path, sizeof(path), "%s:,%s\%s", get_device(spec), + directory, filename); + else + snprintf(path, sizeof(path), "%s:%d,%s\%s", get_device(spec), + partition, directory, filename);
ELF_DPRINTF("bootpath %s bootargs %s\n", path, args); set_property( chosen_ph, "bootpath", path, strlen(spec)+1 ); @@ -240,8 +246,12 @@
/* read boot script */
- snprintf(bootscript, sizeof(bootscript), "%s:%d,%s", - device, partition, script_path); + if (partition == -1) + snprintf(bootscript, sizeof(bootscript), "%s:,%s", + device, script_path); + else + snprintf(bootscript, sizeof(bootscript), "%s:%d,%s", + device, partition, script_path);
CHRP_DPRINTF("Trying %s\n", bootscript); if ((fd = open_io(bootscript)) == -1) { @@ -287,7 +297,10 @@ strcpy(bootscript + scriptlen, device); scriptlen += strlen(device); } else if (strcasecmp(tagbuf, "partition") == 0) { - sprintf(bootscript + scriptlen, "%d", partition); + if (partition != -1) + sprintf(bootscript + scriptlen, "%d", partition); + else + *(bootscript + scriptlen) = 0; scriptlen = strlen(bootscript); } else if (strcasecmp(tagbuf, "directory") == 0) { strcpy(bootscript + scriptlen, directory); @@ -409,11 +422,11 @@ uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); switch (boot_device) { case 'c': - path = strdup("hd:0"); + path = strdup("hd:"); break; default: case 'd': - path = strdup("cd:0"); + path = strdup("cd:"); break; } for( i=0; i < sizeof(chrp_paths) / sizeof(chrp_paths[0]); i++ ) {
Modified: trunk/openbios-devel/modules/mac-parts.c =================================================================== --- trunk/openbios-devel/modules/mac-parts.c 2009-08-23 12:40:24 UTC (rev 569) +++ trunk/openbios-devel/modules/mac-parts.c 2009-08-29 15:24:49 UTC (rev 570) @@ -90,6 +90,7 @@ goto out;
if (parnum == -1) { + int firstHFS = -1; /* search a bootable partition */ /* see PowerPC Microprocessor CHRP bindings */
@@ -101,6 +102,10 @@ !par.pmPartBlkCnt ) goto out;
+ if (firstHFS == -1 && + strcmp(par.pmPartType, "Apple_HFS") == 0) + firstHFS = parnum; + if( (par.pmPartStatus & kPartitionAUXIsBootValid) && (par.pmPartStatus & kPartitionAUXIsValid) && (par.pmPartStatus & kPartitionAUXIsAllocated) && @@ -120,6 +125,10 @@ parnum++; } /* not found */ + if (firstHFS != -1) { + parnum = firstHFS; + goto found; + } ret = 0; goto out; } @@ -135,6 +144,7 @@ if( parnum > par.pmMapBlkCnt) goto out;
+found: SEEK( (bs * parnum) ); READ( &par, sizeof(par) ); if( par.pmSig != DESC_PART_SIGNATURE || !par.pmPartBlkCnt )