qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: qemu-devel@nongnu.org
Cc: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>,
	Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Subject: [Qemu-devel] [RFC] [PATCH] r2d add pflash support
Date: Mon, 19 Jan 2009 21:19:04 +0100	[thread overview]
Message-ID: <1232396344-30061-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1232296556-8752-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>
Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---
please use to style of cmdline
qemu-system-sh4 -M r2d -pflash r2dplus/u-boot.bin -nographic -monitor null -serial pty -serial stdio

Best Regards,
J.
 Makefile.target     |    2 +-
 hw/r2d.c            |   20 ++++++++++++++++++--
 target-sh4/helper.c |    4 ++--
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 7060385..7c50172 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -721,7 +721,7 @@ endif
 ifeq ($(TARGET_BASE_ARCH), sh4)
 OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 OBJS+= sh_timer.o ptimer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o
-OBJS+= ide.o
+OBJS+= ide.o pflash_cfi01.o
 endif
 ifeq ($(TARGET_BASE_ARCH), m68k)
 OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
diff --git a/hw/r2d.c b/hw/r2d.c
index a8207c2..24e1328 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -31,9 +31,12 @@
 #include "pci.h"
 #include "net.h"
 #include "sh7750_regs.h"
+#include "flash.h"
 
 #define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */
 #define SDRAM_SIZE 0x04000000
+#define FLASH_BASE 0xa0000000
+#define FLASH_SIZE 0x02000000
 
 #define SM501_VRAM_SIZE 0x800000
 
@@ -203,6 +206,7 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
     qemu_irq *irq;
     PCIBus *pci;
     int i;
+    int index;
 
     if (!cpu_model)
         cpu_model = "SH7751R";
@@ -247,6 +251,18 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
         usb_ohci_init_pci(pci, 4, -1);
 
     /* Todo: register on board registers */
+    if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) {
+        uint32_t sector_len = 128 * 1024;
+
+        if (!pflash_cfi01_register(FLASH_BASE, qemu_ram_alloc(FLASH_SIZE),
+            drives_table[index].bdrv, sector_len, FLASH_SIZE / sector_len,
+            4, 0, 0, 0, 0)) {
+            fprintf(stderr, "qemu: Error registering flash memory.\n");
+	} else {
+            env->pc = FLASH_BASE;
+	}
+    }
+
     if (kernel_filename) {
       int kernel_size;
       /* initialization which should be done by firmware */
@@ -257,11 +273,11 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
 
       if (kernel_cmdline) {
           kernel_size = load_image(kernel_filename, phys_ram_base + 0x80000);
-          env->pc = (SDRAM_BASE + 0x80000) | 0xa0000000;
+          env->pc = (SDRAM_BASE + 0x80000) | FLASH_BASE;
           pstrcpy(phys_ram_base + 0x10100, 256, kernel_cmdline);
       } else {
           kernel_size = load_image(kernel_filename, phys_ram_base);
-          env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */
+          env->pc = SDRAM_BASE | FLASH_BASE; /* Start from P2 area */
       }
       if (kernel_size < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
diff --git a/target-sh4/helper.c b/target-sh4/helper.c
index a790aeb..221ce20 100644
--- a/target-sh4/helper.c
+++ b/target-sh4/helper.c
@@ -436,8 +436,8 @@ int get_physical_address(CPUState * env, target_ulong * physical,
 	    else
 		return MMU_IADDR_ERROR;
 	}
-	if (address >= 0x80000000 && address < 0xc0000000) {
-	    /* Mask upper 3 bits for P1 and P2 areas */
+	if (address >= 0x80000000 && address < 0xa0000000) {
+	    /* Mask upper 3 bits for P1 area */
 	    *physical = address & 0x1fffffff;
 	} else {
 	    *physical = address;
-- 
1.5.6.5

  reply	other threads:[~2009-01-19 20:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18  8:25 [Qemu-devel] [FYI] sh: QEMU-SH patch list Shin-ichiro KAWASAKI
2009-01-18 16:35 ` [Qemu-devel] [PATCH 1/1] sh: fix TMU init Jean-Christophe PLAGNIOL-VILLARD
2009-01-19 20:19   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2009-01-25  5:21     ` [Qemu-devel] [RFC] [PATCH] r2d add pflash support takasi-y
2009-01-25  9:18       ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-07 15:19   ` [Qemu-devel] [PATCH 1/1] sh: fix TMU init Aurelien Jarno

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=1232396344-30061-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=kawasaki@juno.dti.ne.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=takasi-y@ops.dti.ne.jp \
    /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).