All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch 4/4] Add Flash support to the Versatile PB platform
Date: Fri, 3 Oct 2008 16:37:13 +0200	[thread overview]
Message-ID: <20081003163713.27fff17a@surf> (raw)
In-Reply-To: <20081003154403.736e0e2b@surf>

Le Fri, 3 Oct 2008 15:44:03 +0200,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> a écrit :

> Another solution is to set
> 
>  .ram_require = 64 * 1024 * 1024
> 
> So that 64 MB will always be allocated for the Flash. To these 64 MB,
> the user-specified amount of memory is added for the RAM.

The following patch implements this solution. The drawback is that
these 64 MB of Flash are allocated even if the -pflash option is not
passed.

Thomas

---

Add Flash support to the Versatile PB platform

This patch adds the emulation of the 64 MB Intel Flash present at
address 0x34000000 on the ARM Versatile PB platform, with a 256 KB
sector size. This flash emulation is enabled using the -pflash
option. If not enabled, Qemu falls back to the traditionnal way of
loading the kernel.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 hw/versatilepb.c |   43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)

Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c
+++ qemu/hw/versatilepb.c
@@ -15,6 +15,7 @@
 #include "sysemu.h"
 #include "pci.h"
 #include "boards.h"
+#include "flash.h"
 
 /* Primary interrupt controller.  */
 
@@ -159,6 +160,10 @@
 
 static struct arm_boot_info versatile_binfo;
 
+#define VERSATILE_FLASH_ADDR      0x34000000
+#define VERSATILE_FLASH_SIZE      (64 * 1024 * 1024)
+#define VERSATILE_FLASH_SECT_SIZE (256 * 1024)
+
 static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
                      const char *boot_device, DisplayState *ds,
                      const char *kernel_filename, const char *kernel_cmdline,
@@ -174,6 +179,7 @@
     int n;
     int done_smc = 0;
     int index;
+    int hasflash = 0;
 
     if (!cpu_model)
         cpu_model = "arm926";
@@ -184,7 +190,8 @@
     }
     /* ??? RAM should repeat to fill physical memory space.  */
     /* SDRAM at address zero.  */
-    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
+    cpu_register_physical_memory(0, ram_size,
+				 qemu_ram_alloc(ram_size) | IO_MEM_RAM);
 
     arm_sysctl_init(0x10000000, 0x41007004);
     pic = arm_pic_init_cpu(env);
@@ -249,6 +256,21 @@
     /* Add PL031 Real Time Clock. */
     pl031_init(0x101e8000,pic[10]);
 
+    index = drive_get_index(IF_PFLASH, 0, 0);
+    if (index != -1) {
+      if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR,
+				 qemu_ram_alloc(VERSATILE_FLASH_SIZE),
+				 drives_table[index].bdrv,
+				 VERSATILE_FLASH_SECT_SIZE,
+				 VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE,
+				 4, 0, 0, 0, 0)) {
+	fprintf(stderr, "qemu: error registering flash memory.\n");
+	exit(1);
+      }
+
+      hasflash = 1;
+    }
+
     /* Memory map for Versatile/PB:  */
     /* 0x10000000 System registers.  */
     /* 0x10001000 PCI controller config registers.  */
@@ -285,12 +307,17 @@
     /*  0x101f3000 UART2.  */
     /* 0x101f4000 SSPI.  */
 
-    versatile_binfo.ram_size = ram_size;
-    versatile_binfo.kernel_filename = kernel_filename;
-    versatile_binfo.kernel_cmdline = kernel_cmdline;
-    versatile_binfo.initrd_filename = initrd_filename;
-    versatile_binfo.board_id = board_id;
-    arm_load_kernel(env, &versatile_binfo);
+    if (! hasflash) {
+      versatile_binfo.ram_size = ram_size;
+      versatile_binfo.kernel_filename = kernel_filename;
+      versatile_binfo.kernel_cmdline = kernel_cmdline;
+      versatile_binfo.initrd_filename = initrd_filename;
+      versatile_binfo.board_id = board_id;
+      arm_load_kernel(env, &versatile_binfo);
+    }
+    else {
+      env->regs[15] = 0x34000000;
+    }
 }
 
 static void vpb_init(ram_addr_t ram_size, int vga_ram_size,
@@ -320,6 +347,7 @@
     .desc = "ARM Versatile/PB (ARM926EJ-S)",
     .init = vpb_init,
     .use_scsi = 1,
+    .ram_require = VERSATILE_FLASH_SIZE,
 };
 
 QEMUMachine versatileab_machine = {
@@ -327,4 +355,5 @@
     .desc = "ARM Versatile/AB (ARM926EJ-S)",
     .init = vab_init,
     .use_scsi = 1,
+    .ram_require = VERSATILE_FLASH_SIZE,
 };

-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2008-10-03 14:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-02 13:02 [Qemu-devel] [patch 0/4] [RFC] Add flash emulation to the Versatile PB platform Thomas Petazzoni
2008-10-02 13:02 ` [Qemu-devel] [patch 1/4] Increase write buffer size in pflash emulation Thomas Petazzoni
2008-10-03 23:05   ` andrzej zaborowski
2008-10-06  9:47     ` Thomas Petazzoni
2008-10-02 13:02 ` [Qemu-devel] [patch 2/4] Reset wcycle after erase confirm Thomas Petazzoni
2008-10-02 13:02 ` [Qemu-devel] [patch 3/4] Improve pflash cfi01 debug messages Thomas Petazzoni
2008-10-02 13:02 ` [Qemu-devel] [patch 4/4] Add Flash support to the Versatile PB platform Thomas Petazzoni
2008-10-02 16:33   ` Paul Brook
2008-10-02 17:00     ` Thomas Petazzoni
2008-10-03 13:44     ` Thomas Petazzoni
2008-10-03 14:37       ` Thomas Petazzoni [this message]
2008-10-06  9:48         ` Thomas Petazzoni
2008-10-02 18:25   ` andrzej zaborowski
2008-10-03  7:55     ` Thomas Petazzoni
2008-10-06 17:23 ` [Qemu-devel] [Patch 0/4] [RFC] Zero Cluster Dedup, Offline dedup, qemu-img extentions Shahar Frank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081003163713.27fff17a@surf \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.