Skip to contentSkip to conversation

qemu: ppc: if not a uImage, try to load kernel as ELF

PATCH New Hollis Blanchard 1 participant 1 message Oct 24, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu: ppc: if not a uImage, try to load kernel as ELF

# HG changeset patch
# User Hollis Blanchard <[email protected]> # Date 1224864394 18000
# Node ID 1303bfcb4f9eb5b1462f1709ae1e64300829fca0 # Parent e7d30fcd4f7cf6a64d45e756ff1e1e0a914b7d0d
qemu: ppc: if not a uImage, try to load kernel as ELF

This allows qemu to load "bare metal" ELF kernels, useful for standalone benchmarks and testcases.

We could/should also load the specified file as a flat binary, if both uImage and ELF loaders fail. (See hw/arm_boot.c.)

qemu/hw/ppc440_bamboo.c +5 -2
@@ -35,8 +35,8 @@ void bamboo_init(ram_addr_t ram_size, in
 	qemu_irq *pic;
 	ppc4xx_pci_t *pci;
 	CPUState *env;
-	target_ulong ep=0;
-	target_ulong la=0;
+	uint64_t ep=0;
+	uint64_t la=0;
 	int is_linux=1; /* Will assume allways is Linux for now */
 	target_long kernel_size=0;
 	target_ulong initrd_base=0;
@@ -98,6 +98,9 @@ void bamboo_init(ram_addr_t ram_size, in
 	/* load kernel with uboot loader */
 	printf("%s: load kernel\n", __func__);
 	ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux);
+	if (ret < 0)
+		ret = load_elf(kernel_filename, 0, &ep, &la, NULL);
+
 	if (ret < 0) {
 		fprintf(stderr, "qemu: could not load kernel '%s'\n",
 			kernel_filename);