qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] hw/gumstix.c: Directly load a kernel


From: Thorsten Zitterell
Subject: [Qemu-devel] [PATCH] hw/gumstix.c: Directly load a kernel
Date: Mon, 04 May 2009 17:44:55 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

Previously, a Gumstix connex can only be booted if a flash image is provided.
This patch allows to
* specify a flash image with -pflash (as before)
* and/or provide a raw kernel image loaded to 0xa0000000 or elf kernel image

--
Thorsten




diff --git a/hw/gumstix.c b/hw/gumstix.c
index cce86fb..af69145 100644
--- a/hw/gumstix.c
+++ b/hw/gumstix.c
@@ -48,6 +48,8 @@ static void connex_init(ram_addr_t ram_size, int vga_ram_size,
 {
     struct pxa2xx_state_s *cpu;
     int index;
+    uint64_t entry;
+    int kernel_size;
 
     uint32_t connex_rom = 0x01000000;
     uint32_t connex_ram = 0x04000000;
@@ -55,20 +57,37 @@ static void connex_init(ram_addr_t ram_size, int 
vga_ram_size,
     cpu = pxa255_init(connex_ram);
 
     index = drive_get_index(IF_PFLASH, 0, 0);
-    if (index == -1) {
-        fprintf(stderr, "A flash image must be given with the "
-                "'pflash' parameter\n");
+
+    if ((index == -1) && (kernel_filename == NULL)) {
+        fprintf(stderr, "Give a flash image with the 'pflash' parameter\n");
+        fprintf(stderr, "or/and a kernel image with the 'kernel' parameter\n");
         exit(1);
     }
 
-    if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom),
+    if (index != -1) {
+        if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom),
             drives_table[index].bdrv, sector_len, connex_rom / sector_len,
-            2, 0, 0, 0, 0)) {
-        fprintf(stderr, "qemu: Error registering flash memory.\n");
-        exit(1);
+                2, 0, 0, 0, 0)) {
+            fprintf(stderr, "qemu: Error registering flash memory.\n");
+            exit(1);
+        }
+        cpu->env->regs[15] = 0x00000000;
     }
 
-    cpu->env->regs[15] = 0x00000000;
+    if (kernel_filename) {
+        kernel_size = load_elf(kernel_filename, 0, &entry, NULL, NULL);
+        if (kernel_size < 0) {
+            kernel_size = load_image_targphys(kernel_filename,
+                                              PXA2XX_SDRAM_BASE, connex_ram);
+            cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
+        } else {
+            cpu->env->regs[15] = entry;
+        }
+        if (kernel_size < 0) {
+            fprintf(stderr, "qemu: Error loading kernel.\n");
+            exit(1);
+        }
+    }
 
     /* Interrupt line of NIC is connected to GPIO line 36 */
     smc91c111_init(&nd_table[0], 0x04000300,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]