qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC] [PATCH] r2d add pflash support


From: Jean-Christophe PLAGNIOL-VILLARD
Subject: [Qemu-devel] [RFC] [PATCH] r2d add pflash support
Date: Mon, 19 Jan 2009 21:19:04 +0100

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <address@hidden>
Cc: Shin-ichiro KAWASAKI <address@hidden>
Cc: Takashi YOSHII <address@hidden>
---
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 via email to

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