From: Max Filippov <jcmvbkbc@gmail.com>
To: qemu-devel@nongnu.org
Cc: jcmvbkbc@gmail.com
Subject: [Qemu-devel] [PATCH 1/3] xtensa_lx60: add FLASH support
Date: Sun, 30 Oct 2011 22:03:12 +0400 [thread overview]
Message-ID: <1319997794-10542-2-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1319997794-10542-1-git-send-email-jcmvbkbc@gmail.com>
LX60 carry 4 Mbyte FLASH and 128 Kbyte SRAM, LX200 carry 16 Mbyte FLASH
and 32 Mbyte SRAM. Either of these memories may be mapped to the system
ROM region.
Select boot from FLASH if -kernel option is not specified, otherwise
boot from SRAM.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
default-configs/xtensa-softmmu.mak | 1 +
default-configs/xtensaeb-softmmu.mak | 1 +
hw/xtensa_lx60.c | 79 ++++++++++++++++++++++++++++++---
3 files changed, 73 insertions(+), 8 deletions(-)
diff --git a/default-configs/xtensa-softmmu.mak b/default-configs/xtensa-softmmu.mak
index 7f0df34..9d8899c 100644
--- a/default-configs/xtensa-softmmu.mak
+++ b/default-configs/xtensa-softmmu.mak
@@ -2,3 +2,4 @@
CONFIG_SERIAL=y
CONFIG_OPENCORES_ETH=y
+CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/xtensaeb-softmmu.mak b/default-configs/xtensaeb-softmmu.mak
index 7f0df34..9d8899c 100644
--- a/default-configs/xtensaeb-softmmu.mak
+++ b/default-configs/xtensaeb-softmmu.mak
@@ -2,3 +2,4 @@
CONFIG_SERIAL=y
CONFIG_OPENCORES_ETH=y
+CONFIG_PFLASH_CFI01=y
diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c
index 3cebca1..cb047d2 100644
--- a/hw/xtensa_lx60.c
+++ b/hw/xtensa_lx60.c
@@ -33,6 +33,13 @@
#include "exec-memory.h"
#include "pc.h"
#include "sysbus.h"
+#include "flash.h"
+
+typedef struct LxBoardDesc {
+ size_t flash_size;
+ size_t flash_sector_size;
+ size_t sram_size;
+} LxBoardDesc;
typedef struct Lx60FpgaState {
MemoryRegion iomem;
@@ -142,8 +149,8 @@ static void lx60_reset(void *env)
cpu_reset(env);
}
-static void lx60_init(ram_addr_t ram_size,
- const char *boot_device,
+static void lx_init(const LxBoardDesc *board,
+ ram_addr_t ram_size, const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
@@ -155,8 +162,14 @@ static void lx60_init(ram_addr_t ram_size,
MemoryRegion *system_memory = get_system_memory();
CPUState *env = NULL;
MemoryRegion *ram, *rom, *system_io;
+ DriveInfo *dinfo;
+ pflash_t *flash = NULL;
int n;
+ if (!cpu_model) {
+ cpu_model = "dc232b";
+ }
+
for (n = 0; n < smp_cpus; n++) {
env = cpu_init(cpu_model);
if (!env) {
@@ -195,6 +208,20 @@ static void lx60_init(ram_addr_t ram_size,
serial_mm_init(system_io, 0x0d050020, 2, xtensa_get_extint(env, 0),
115200, serial_hds[0], DEVICE_NATIVE_ENDIAN);
+ dinfo = drive_get(IF_PFLASH, 0, 0);
+ if (dinfo) {
+ flash = pflash_cfi01_register(0xf8000000,
+ NULL, "lx60.io.flash", board->flash_size,
+ dinfo->bdrv, board->flash_sector_size,
+ board->flash_size / board->flash_sector_size,
+ 4, 0x0000, 0x0000, 0x0000, 0x0000, be);
+ if (flash == NULL) {
+ fprintf(stderr, "Unable to mount pflash\n");
+ exit(1);
+ }
+ }
+
+ /* Use presence of kernel file name as 'boot from SRAM' switch. */
if (kernel_filename) {
uint64_t elf_entry;
uint64_t elf_lowaddr;
@@ -203,6 +230,16 @@ static void lx60_init(ram_addr_t ram_size,
if (success > 0) {
env->pc = elf_entry;
}
+ } else {
+ if (flash) {
+ MemoryRegion *flash_mr = pflash_cfi01_get_memory(flash);
+ MemoryRegion *flash_io = g_malloc(sizeof(*flash_io));
+
+ memory_region_init_alias(flash_io, "lx60.flash",
+ flash_mr, 0, board->flash_size);
+ memory_region_add_subregion(system_memory, 0xfe000000,
+ flash_io);
+ }
}
}
@@ -211,10 +248,28 @@ static void xtensa_lx60_init(ram_addr_t ram_size,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
- if (!cpu_model) {
- cpu_model = "dc232b";
- }
- lx60_init(ram_size, boot_device, kernel_filename, kernel_cmdline,
+ static const LxBoardDesc lx60_board = {
+ .flash_size = 0x400000,
+ .flash_sector_size = 0x10000,
+ .sram_size = 0x20000,
+ };
+ lx_init(&lx60_board, ram_size, boot_device,
+ kernel_filename, kernel_cmdline,
+ initrd_filename, cpu_model);
+}
+
+static void xtensa_lx200_init(ram_addr_t ram_size,
+ const char *boot_device,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+ static const LxBoardDesc lx200_board = {
+ .flash_size = 0x1000000,
+ .flash_sector_size = 0x20000,
+ .sram_size = 0x2000000,
+ };
+ lx_init(&lx200_board, ram_size, boot_device,
+ kernel_filename, kernel_cmdline,
initrd_filename, cpu_model);
}
@@ -225,9 +280,17 @@ static QEMUMachine xtensa_lx60_machine = {
.max_cpus = 4,
};
-static void xtensa_lx60_machine_init(void)
+static QEMUMachine xtensa_lx200_machine = {
+ .name = "lx200",
+ .desc = "lx200 EVB (dc232b)",
+ .init = xtensa_lx200_init,
+ .max_cpus = 4,
+};
+
+static void xtensa_lx_machines_init(void)
{
qemu_register_machine(&xtensa_lx60_machine);
+ qemu_register_machine(&xtensa_lx200_machine);
}
-machine_init(xtensa_lx60_machine_init);
+machine_init(xtensa_lx_machines_init);
--
1.7.6.4
next prev parent reply other threads:[~2011-10-30 18:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-30 18:03 [Qemu-devel] [PATCH 0/3] xtensa_lx60: FLASH, kernel args support, minor fixes Max Filippov
2011-10-30 18:03 ` Max Filippov [this message]
2011-10-30 18:03 ` [Qemu-devel] [PATCH 2/3] xtensa_lx60: pass kernel arguments from -append Max Filippov
2011-10-30 18:03 ` [Qemu-devel] [PATCH 3/3] xtensa_lx60: fix build date code and change memory region names Max Filippov
-- strict thread matches above, loose matches on Subject: below --
2011-10-31 22:17 [Qemu-devel] [PULL 0/7] target-xtensa patches for 1.0 Max Filippov
2011-10-31 22:17 ` [Qemu-devel] [PATCH 1/3] xtensa_lx60: add FLASH support Max Filippov
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=1319997794-10542-2-git-send-email-jcmvbkbc@gmail.com \
--to=jcmvbkbc@gmail.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 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).