Author: mcayland Date: Sun Jan 13 16:27:00 2013 New Revision: 1089 URL: http://tracker.coreboot.org/trac/openbios/changeset/1089
Log: mac-parts.c: Update bootpath to reflect the chosen partition if unspecified.
When not booting from a specified partition, bootpath doesn't contain the selected partition id. Since this is parsed by BootX in order to locate the Mach kernel, update it accordingly. Otherwise BootX falls back to its default behaviour of scanning the first 3 partitions in order to find the kernel and fails on early Darwin/OS X images.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/packages/mac-parts.c
Modified: trunk/openbios-devel/packages/mac-parts.c ============================================================================== --- trunk/openbios-devel/packages/mac-parts.c Sun Jan 13 16:26:57 2013 (r1088) +++ trunk/openbios-devel/packages/mac-parts.c Sun Jan 13 16:27:00 2013 (r1089) @@ -50,13 +50,14 @@ { char *str = my_args_copy(); char *parstr = NULL, *argstr = NULL; + char *tmpstr, *bootpath; int bs, parnum=-1, apple_parnum=-1; int parlist[2], parlist_size = 0; desc_map_t dmap; part_entry_t par; int ret = 0, i = 0, j = 0; int want_bootcode = 0; - phandle_t ph; + phandle_t ph, chosen_ph; ducell offs = 0, size = -1;
DPRINTF("macparts_open '%s'\n", str ); @@ -256,6 +257,35 @@ DPRINTF("mac-parts: filesystem found on partition %d with ph " FMT_ucellx " and args %s\n", parnum, ph, argstr); di->filesystem_ph = ph;
+ /* Update bootpath to reflect where we booted from */ + chosen_ph = find_dev("/chosen"); + tmpstr = get_property(chosen_ph, "bootpath", &i); + if (tmpstr == NULL) { + tmpstr = strdup(""); + } + + /* Find just the device */ + if (strlen(tmpstr)) { + for (i = 0; i < strlen(tmpstr); i++) { + if (tmpstr[i] == ':' || tmpstr[i] == ',') { + tmpstr[i] = '\0'; + } + } + + /* Rebuild bootpath with the currently selected partition number */ + bootpath = malloc(strlen(tmpstr) + strlen(str) + 4); + sprintf(bootpath, "%s:%d", tmpstr, parnum); + if (strlen(argstr)) { + sprintf(bootpath, "%s:%d,%s", tmpstr, parnum, argstr); + } else { + sprintf(bootpath, "%s:%d", tmpstr, parnum); + } + + DPRINTF("mac-parts: setting bootpath to %s\n", bootpath); + + set_property(chosen_ph, "bootpath", bootpath, strlen(bootpath) + 1); + } + /* If the filename was %BOOT then it's not a real filename, so clear argstr before attempting interpose */ if (want_bootcode) {
I confirm that this patch works with Mac OS 10.0. I am able to boot off the cd and start running the kernel without specifying the partition. Thanks Mark.
On Jan 13, 2013, at 10:27 AM, repository service wrote:
Author: mcayland Date: Sun Jan 13 16:27:00 2013 New Revision: 1089 URL: http://tracker.coreboot.org/trac/openbios/changeset/1089
Log: mac-parts.c: Update bootpath to reflect the chosen partition if unspecified.
When not booting from a specified partition, bootpath doesn't contain the selected partition id. Since this is parsed by BootX in order to locate the Mach kernel, update it accordingly. Otherwise BootX falls back to its default behaviour of scanning the first 3 partitions in order to find the kernel and fails on early Darwin/OS X images.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/packages/mac-parts.c
Modified: trunk/openbios-devel/packages/mac-parts.c
--- trunk/openbios-devel/packages/mac-parts.c Sun Jan 13 16:26:57 2013 (r1088) +++ trunk/openbios-devel/packages/mac-parts.c Sun Jan 13 16:27:00 2013 (r1089) @@ -50,13 +50,14 @@ { char *str = my_args_copy(); char *parstr = NULL, *argstr = NULL;
- char *tmpstr, *bootpath; int bs, parnum=-1, apple_parnum=-1; int parlist[2], parlist_size = 0; desc_map_t dmap; part_entry_t par; int ret = 0, i = 0, j = 0; int want_bootcode = 0;
- phandle_t ph;
phandle_t ph, chosen_ph; ducell offs = 0, size = -1;
DPRINTF("macparts_open '%s'\n", str );
@@ -256,6 +257,35 @@ DPRINTF("mac-parts: filesystem found on partition %d with ph " FMT_ucellx " and args %s\n", parnum, ph, argstr); di->filesystem_ph = ph;
/* Update bootpath to reflect where we booted from */
chosen_ph = find_dev("/chosen");
tmpstr = get_property(chosen_ph, "bootpath", &i);
if (tmpstr == NULL) {
tmpstr = strdup("");
}
/* Find just the device */
if (strlen(tmpstr)) {
for (i = 0; i < strlen(tmpstr); i++) {
if (tmpstr[i] == ':' || tmpstr[i] == ',') {
tmpstr[i] = '\0';
}
}
/* Rebuild bootpath with the currently selected partition number */
bootpath = malloc(strlen(tmpstr) + strlen(str) + 4);
sprintf(bootpath, "%s:%d", tmpstr, parnum);
if (strlen(argstr)) {
sprintf(bootpath, "%s:%d,%s", tmpstr, parnum, argstr);
} else {
sprintf(bootpath, "%s:%d", tmpstr, parnum);
}
DPRINTF("mac-parts: setting bootpath to %s\n", bootpath);
set_property(chosen_ph, "bootpath", bootpath, strlen(bootpath) + 1);
}
/* If the filename was %BOOT then it's not a real filename, so clear argstr before attempting interpose */ if (want_bootcode) {
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you