[OpenBIOS] [PATCH 2/2] PPC: Add the old-world bootcode device dev:, %BOOT to the bootdevice list

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Fri Mar 22 17:28:07 CET 2013


By adding the bootcode device to the bootdevice list as processed by load,
we automatically attempt to invoke the bootcode loader as required.

As a consequence of this, we can now remove the separate C codepath used
in order to facilitate an old-world boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
CC: Alexander Graf <agraf at suse.de>
CC: Andreas Färber <afaerber at suse.de>
---
 openbios-devel/arch/ppc/qemu/init.c |    2 +-
 openbios-devel/arch/ppc/qemu/main.c |  139 -----------------------------------
 2 files changed, 1 insertion(+), 140 deletions(-)

diff --git a/openbios-devel/arch/ppc/qemu/init.c b/openbios-devel/arch/ppc/qemu/init.c
index a8fc320..bb3f933 100644
--- a/openbios-devel/arch/ppc/qemu/init.c
+++ b/openbios-devel/arch/ppc/qemu/init.c
@@ -855,7 +855,7 @@ arch_of_init(void)
     }
 
     /* Setup default boot devices */
-    snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt", boot_path, boot_path);
+    snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt %s:,%%BOOT", boot_path, boot_path, boot_path);
     push_str(buf);
     fword("encode-string");
     push_str("boot-device");
diff --git a/openbios-devel/arch/ppc/qemu/main.c b/openbios-devel/arch/ppc/qemu/main.c
index f9c1a53..30a4375 100644
--- a/openbios-devel/arch/ppc/qemu/main.c
+++ b/openbios-devel/arch/ppc/qemu/main.c
@@ -39,141 +39,6 @@
 #define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args)
 #define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
 
-static char *
-get_device( const char *path )
-{
-	int i;
-	static char buf[1024];
-
-	for (i = 0; i < sizeof(buf) && path[i] && path[i] != ':'; i++)
-		buf[i] = path[i];
-	buf[i] = 0;
-
-	return buf;
-}
-
-static int
-get_partition( const char *path )
-{
-	while ( *path && *path != ':' )
-		path++;
-
-	if (!*path)
-		return -1;
-	path++;
-
-	if (!strchr(path, ','))	/* check if there is a ',' */
-		return -1;
-
-	return atol(path);
-}
-
-static char *
-get_filename( const char * path , char **dirname)
-{
-	static char buf[1024];
-	char *filename;
-
-	while ( *path && *path != ':' )
-		path++;
-
-	if (!*path) {
-		*dirname = NULL;
-		return NULL;
-	}
-	path++;
-
-	while ( *path && isdigit(*path) )
-		path++;
-
-	if (*path == ',')
-		path++;
-
-	strncpy(buf, path, sizeof(buf));
-	buf[sizeof(buf) - 1] = 0;
-
-	filename = strrchr(buf, '\\');
-	if (filename) {
-		*dirname = buf;
-		(*filename++) = 0;
-	} else {
-		*dirname = NULL;
-		filename = buf;
-	}
-
-	return filename;
-}
-
-
-static void
-encode_bootpath( const char *spec, const char *args )
-{
-	char path[1024];
-	phandle_t chosen_ph = find_dev("/chosen");
-	char *filename, *directory;
-	int partition;
-
-	if (spec)
-		return;
-	
-	filename = get_filename(spec, &directory);
-	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(path)+1 );
-	if (args)
-		set_property( chosen_ph, "bootargs", args, strlen(args)+1 );
-}
-
-#define OLDWORLD_BOOTCODE_BASEADDR	(0x3f4000)
-
-static void
-oldworld_boot( void )
-{
-	int fd;
-	int len, total;
-	const char *path = "hd:,%BOOT";
-	char *bootcode;
-
-	if ((fd = open_io(path)) == -1) {
-		ELF_DPRINTF("Can't open %s\n", path);
-		return;
-	}
-
-
-	total = 0;
-	bootcode = (char*)OLDWORLD_BOOTCODE_BASEADDR;
-	while(1) {
-		if (seek_io(fd, total) == -1)
-			break;
-		len = read_io(fd, bootcode, 512);
-		bootcode += len;
-		total += len;
-	}
-
-	close_io( fd );
-
-	if (total == 0) {
-		ELF_DPRINTF("Can't read %s\n", path);
-		return;
-	}
-
-	encode_bootpath(path, "Linux");
-
-	if( ofmem_claim( OLDWORLD_BOOTCODE_BASEADDR, total, 0 ) == -1 )
-		fatal_error("Claim failed!\n");
-
-	call_elf(0, 0, OLDWORLD_BOOTCODE_BASEADDR);
-
-        return;
-}
-
 static void check_preloaded_kernel(void)
 {
     unsigned long kernel_image, kernel_size;
@@ -213,9 +78,5 @@ boot( void )
 	        check_preloaded_kernel();
 	}
 
-	if (boot_device == 'c') {
-		oldworld_boot();
-	}
-
 	update_nvram();
 }
-- 
1.7.10.4




More information about the OpenBIOS mailing list