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>



git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@570 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Laurent Vivier
2009-08-29 15:24:49 +00:00
parent a3e861a2cf
commit 1ced7923e7
2 changed files with 32 additions and 9 deletions

View File

@@ -126,11 +126,11 @@ get_partition( const char *path )
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 @@ encode_bootpath( const char *spec, const char *args )
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 @@ try_chrp_script(const char *of_path, const char *param, const char *script_path)
/* 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 @@ try_chrp_script(const char *of_path, const char *param, const char *script_path)
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 @@ yaboot_startup( void )
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++ ) {

View File

@@ -90,6 +90,7 @@ macparts_open( macparts_info_t *di )
goto out;
if (parnum == -1) {
int firstHFS = -1;
/* search a bootable partition */
/* see PowerPC Microprocessor CHRP bindings */
@@ -101,6 +102,10 @@ macparts_open( macparts_info_t *di )
!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 @@ macparts_open( macparts_info_t *di )
parnum++;
}
/* not found */
if (firstHFS != -1) {
parnum = firstHFS;
goto found;
}
ret = 0;
goto out;
}
@@ -135,6 +144,7 @@ macparts_open( macparts_info_t *di )
if( parnum > par.pmMapBlkCnt)
goto out;
found:
SEEK( (bs * parnum) );
READ( &par, sizeof(par) );
if( par.pmSig != DESC_PART_SIGNATURE || !par.pmPartBlkCnt )