qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Alex Dumitrache" <broscutamaker@gmail.com>,
	"Peter Crosthwaite" <peter.crosthwaite@xilinx.com>,
	"Giovanni Condello" <condellog@gmail.com>,
	g3gg0 <georg.hofstetter@lx-networking.de>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Paul Brook" <paul@codesourcery.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Antony Pavlov" <antonynpavlov@gmail.com>
Subject: [Qemu-devel] [RFC v4 5/5] hw/arm/digic: add NOR ROM support
Date: Thu,  5 Sep 2013 11:52:59 +0400	[thread overview]
Message-ID: <1378367579-1099-6-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1378367579-1099-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 hw/arm/digic_boards.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index 0b99227..850e320 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -1,6 +1,13 @@
 #include "hw/boards.h"
 #include "exec/address-spaces.h"
 #include "hw/arm/digic.h"
+#include "hw/block/flash.h"
+#include "hw/loader.h"
+#include "sysemu/sysemu.h"
+
+#define DIGIC4_ROM0_BASE      0xf0000000
+#define DIGIC4_ROM1_BASE      0xf8000000
+# define DIGIC4_ROM_MAX_SIZE      0x08000000
 
 typedef struct DigicBoardState {
     DigicState *digic;
@@ -9,6 +16,10 @@ typedef struct DigicBoardState {
 
 typedef struct DigicBoard {
     hwaddr ram_size;
+    void (*add_rom0)(DigicBoardState *, hwaddr, const char *);
+    const char *rom0_def_filename;
+    void (*add_rom1)(DigicBoardState *, hwaddr, const char *);
+    const char *rom1_def_filename;
     hwaddr start_addr;
 } DigicBoard;
 
@@ -35,11 +46,74 @@ static void digic4_board_init(DigicBoard *board)
 
     digic4_board_setup_ram(s, board->ram_size);
 
+    if (board->add_rom0) {
+        board->add_rom0(s, DIGIC4_ROM0_BASE, board->rom0_def_filename);
+    }
+
+    if (board->add_rom1) {
+        board->add_rom1(s, DIGIC4_ROM1_BASE, board->rom1_def_filename);
+    }
+
     s->digic->cpu.env.regs[15] = board->start_addr;
 }
 
+static void digic_load_rom(DigicBoardState *s, hwaddr addr,
+                           hwaddr max_size, const char *def_filename)
+{
+
+    target_long rom_size;
+    const char *filename;
+
+    if (bios_name) {
+        filename = bios_name;
+    } else {
+        filename = def_filename;
+    }
+
+    if (filename) {
+        char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, filename);
+
+        if (!fn) {
+            fprintf(stderr, "Couldn't find rom image '%s'.\n", filename);
+            exit(1);
+        }
+
+        rom_size = load_image_targphys(fn, addr, max_size);
+        if (rom_size < 0 || rom_size > max_size) {
+            fprintf(stderr, "Couldn't load rom image '%s'\n", filename);
+            exit(1);
+        }
+    }
+}
+
+static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr,
+                                      const char *def_filename)
+{
+#define FLASH_K8P3215UQB_SIZE (4 * 1024 * 1024)
+#define FLASH_K8P3215UQB_SECTOR_SIZE (64 * 1024)
+
+    /*
+     * Samsung K8P3215UQB:
+     *  * AMD command set;
+     *  * multiple sector size: some sectors are 8K the other ones are 64K.
+     * Alas! The pflash_cfi02_register() function creates a flash
+     * device with unified sector size.
+     */
+    pflash_cfi02_register(addr, NULL, "pflash", FLASH_K8P3215UQB_SIZE,
+                          NULL, FLASH_K8P3215UQB_SECTOR_SIZE,
+                          FLASH_K8P3215UQB_SIZE / FLASH_K8P3215UQB_SECTOR_SIZE,
+                          DIGIC4_ROM_MAX_SIZE / FLASH_K8P3215UQB_SIZE,
+                          4,
+                          0x00EC, 0x007E, 0x0003, 0x0001,
+                          0x0555, 0x2aa, 0);
+
+    digic_load_rom(s, addr, FLASH_K8P3215UQB_SIZE, def_filename);
+}
+
 static DigicBoard digic4_board_canon_a1100 = {
     .ram_size = 64 * 1024 * 1024,
+    .add_rom1 = digic4_add_k8p3215uqb_rom,
+    .rom1_def_filename = "canon-a1100-rom1.bin",
     /* CHDK recommends this address for ROM disassembly */
     .start_addr = 0xffc00000,
 };
-- 
1.8.4.rc3

  parent reply	other threads:[~2013-09-05  7:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05  7:52 [Qemu-devel] [RFC v4 0/5] hw/arm: add initial support for Canon DIGIC SoC Antony Pavlov
2013-09-05  7:52 ` [Qemu-devel] [RFC v4 1/5] hw/arm: add very " Antony Pavlov
2013-09-05 18:08   ` Andreas Färber
2013-09-05 21:23     ` Antony Pavlov
2013-09-05 21:38       ` Andreas Färber
2013-09-06  5:01         ` Antony Pavlov
2013-09-05  7:52 ` [Qemu-devel] [RFC v4 2/5] hw/arm/digic: prepare DIGIC-based boards support Antony Pavlov
2013-09-05 17:54   ` Peter Maydell
2013-09-06  7:12     ` Antony Pavlov
2013-09-05  7:52 ` [Qemu-devel] [RFC v4 3/5] hw/arm/digic: add timer support Antony Pavlov
2013-09-05  7:52 ` [Qemu-devel] [RFC v4 4/5] hw/arm/digic: add UART support Antony Pavlov
2013-09-05 18:17   ` Peter Maydell
2013-09-06  6:54     ` Antony Pavlov
2013-09-06  7:25       ` Peter Maydell
2013-09-06 13:00         ` Antony Pavlov
2013-09-06 13:40           ` Peter Maydell
2013-09-07  5:45             ` Antony Pavlov
2013-09-07  8:33               ` Peter Maydell
2013-09-05  7:52 ` Antony Pavlov [this message]
2013-09-05 18:19   ` [Qemu-devel] [RFC v4 5/5] hw/arm/digic: add NOR ROM support Peter Maydell

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=1378367579-1099-6-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=afaerber@suse.de \
    --cc=broscutamaker@gmail.com \
    --cc=condellog@gmail.com \
    --cc=georg.hofstetter@lx-networking.de \
    --cc=paul@codesourcery.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.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).