qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liming Wang <walimisdev@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] hw/vexpress.c: Add NOR flash model
Date: Tue, 20 Mar 2012 22:57:03 +0800	[thread overview]
Message-ID: <1332255423-21090-1-git-send-email-walimisdev@gmail.com> (raw)

Vexpress motherboard has two 2x16 NOR flash, but pflash_cfi01
doesn't support interleaving, so here only models two 1x32 flash.
Although it's not exactly modeled, it works fine for running linux.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
---
 hw/vexpress.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/vexpress.c b/hw/vexpress.c
index b9aafec..921b01b 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -29,9 +29,13 @@
 #include "sysemu.h"
 #include "boards.h"
 #include "exec-memory.h"
+#include "flash.h"
+#include "blockdev.h"
 
 #define VEXPRESS_BOARD_ID 0x8e0
 
+#define VEXPRESS_FLASH_SIZE 0x04000000
+
 static struct arm_boot_info vexpress_binfo;
 
 /* Address maps for peripherals:
@@ -355,6 +359,9 @@ static void vexpress_common_init(const VEDBoardInfo *daughterboard,
     MemoryRegion *vram = g_new(MemoryRegion, 1);
     MemoryRegion *sram = g_new(MemoryRegion, 1);
     const target_phys_addr_t *map = daughterboard->motherboard_map;
+    DriveInfo *dinfo = NULL;
+    uint32_t sector_len = 256 * 1024;
+    int i = 0;
 
     daughterboard->init(daughterboard, ram_size, cpu_model, pic, &proc_id);
 
@@ -405,9 +412,17 @@ static void vexpress_common_init(const VEDBoardInfo *daughterboard,
 
     sysbus_create_simple("pl111", map[VE_CLCD], pic[14]);
 
-    /* VE_NORFLASH0: not modelled */
+    for(i = 0; i < 2; i++) {
+	dinfo = drive_get(IF_PFLASH, 0, i);
+        if (dinfo) {
+	    pflash_cfi01_register(((i == 0) ? map[VE_NORFLASH0] : map[VE_NORFLASH1]), NULL,
+			    ((i == 0) ? "vexpress.flash0" : "vexpress:flash1"),
+			    VEXPRESS_FLASH_SIZE, dinfo->bdrv, sector_len,
+			    VEXPRESS_FLASH_SIZE / sector_len, 4,
+			    0, 0x89, 0x89, 0x19, 0);
+	}
+    }
     /* VE_NORFLASH0ALIAS: not modelled */
-    /* VE_NORFLASH1: not modelled */
 
     sram_size = 0x2000000;
     memory_region_init_ram(sram, "vexpress.sram", sram_size);
-- 
1.7.0.4

             reply	other threads:[~2012-03-20 14:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-20 14:57 Liming Wang [this message]
2012-03-20 15:13 ` [Qemu-devel] [PATCH] hw/vexpress.c: Add NOR flash model Peter Maydell
2012-03-20 16:00   ` walimis
2012-03-20 16:13     ` Peter Maydell
2012-03-20 16:41       ` walimis

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=1332255423-21090-1-git-send-email-walimisdev@gmail.com \
    --to=walimisdev@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).