From: Max Filippov <jcmvbkbc@gmail.com>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>
Subject: [Qemu-devel] [PATCH 3/3] target-xtensa: xtfpga: support noMMU cores
Date: Sun, 27 Sep 2015 20:16:54 +0300 [thread overview]
Message-ID: <1443374214-27149-4-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1443374214-27149-1-git-send-email-jcmvbkbc@gmail.com>
Cores with and without MMU have system RAM and ROM at different locations.
Also with noMMU cores system IO region is accessible through two physical
address ranges.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
hw/xtensa/xtfpga.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index d4b9afb..b53f40d 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -199,7 +199,29 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
+ const unsigned system_io_size = 224 * 1024 * 1024;
+ bool mmu;
int n;
+ static const struct {
+ hwaddr ram;
+ hwaddr rom;
+ hwaddr io[2];
+ } base[2] = {
+ {
+ .ram = 0x60000000,
+ .rom = 0x50000000,
+ .io = {
+ 0x70000000,
+ 0x90000000,
+ },
+ }, {
+ .ram = 0,
+ .rom = 0xfe000000,
+ .io = {
+ 0xf0000000,
+ },
+ }
+ };
if (!cpu_model) {
cpu_model = XTENSA_DEFAULT_CPU_MODEL;
@@ -222,16 +244,24 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
cpu_reset(CPU(cpu));
}
+ mmu = xtensa_option_enabled(env->config, XTENSA_OPTION_MMU);
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, NULL, "lx60.dram", machine->ram_size,
&error_fatal);
vmstate_register_ram_global(ram);
- memory_region_add_subregion(system_memory, 0, ram);
+ memory_region_add_subregion(system_memory, base[mmu].ram, ram);
system_io = g_malloc(sizeof(*system_io));
memory_region_init_io(system_io, NULL, &lx60_io_ops, NULL, "lx60.io",
- 224 * 1024 * 1024);
- memory_region_add_subregion(system_memory, 0xf0000000, system_io);
+ system_io_size);
+ memory_region_add_subregion(system_memory, base[mmu].io[0], system_io);
+ if (!mmu) {
+ MemoryRegion *io = g_malloc(sizeof(*io));
+
+ memory_region_init_alias(io, NULL, "lx60.io.cached",
+ system_io, 0, system_io_size);
+ memory_region_add_subregion(system_memory, base[mmu].io[1], io);
+ }
lx60_fpga_init(system_io, 0x0d020000);
if (nd_table[0].used) {
lx60_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000,
@@ -267,22 +297,25 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
if (kernel_filename) {
uint32_t entry_point = env->pc;
size_t bp_size = 3 * get_tag_size(0); /* first/last and memory tags */
- uint32_t tagptr = 0xfe000000 + board->sram_size;
+ uint32_t tagptr = base[mmu].rom + board->sram_size;
uint32_t cur_tagptr;
BpMemInfo memory_location = {
.type = tswap32(MEMORY_TYPE_CONVENTIONAL),
- .start = tswap32(0),
- .end = tswap32(machine->ram_size),
+ .start = tswap32(base[mmu].ram),
+ .end = tswap32(base[mmu].ram + machine->ram_size),
};
uint32_t lowmem_end = machine->ram_size < 0x08000000 ?
machine->ram_size : 0x08000000;
uint32_t cur_lowmem = QEMU_ALIGN_UP(lowmem_end / 2, 4096);
+ lowmem_end += base[mmu].ram;
+ cur_lowmem += base[mmu].ram;
+
rom = g_malloc(sizeof(*rom));
memory_region_init_ram(rom, NULL, "lx60.sram", board->sram_size,
&error_fatal);
vmstate_register_ram_global(rom);
- memory_region_add_subregion(system_memory, 0xfe000000, rom);
+ memory_region_add_subregion(system_memory, base[mmu].rom, rom);
if (kernel_cmdline) {
bp_size += get_tag_size(strlen(kernel_cmdline) + 1);
@@ -381,7 +414,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
flash_mr, board->flash_boot_base,
board->flash_size - board->flash_boot_base < 0x02000000 ?
board->flash_size - board->flash_boot_base : 0x02000000);
- memory_region_add_subregion(system_memory, 0xfe000000,
+ memory_region_add_subregion(system_memory, base[mmu].rom,
flash_io);
}
}
--
1.8.1.4
next prev parent reply other threads:[~2015-09-27 17:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-27 17:16 [Qemu-devel] [PATCH 0/3] target-xtensa: xtfpga: support cores without MMU Max Filippov
2015-09-27 17:16 ` [Qemu-devel] [PATCH 1/3] pflash_cfi01: add pflash_cfi01_init Max Filippov
2015-09-27 17:25 ` Peter Crosthwaite
2015-09-27 17:51 ` Max Filippov
2015-09-27 18:32 ` Peter Crosthwaite
2015-09-27 18:43 ` Max Filippov
2015-09-27 17:16 ` [Qemu-devel] [PATCH 2/3] target-xtensa: xtfpga: attach FLASH to system IO Max Filippov
2015-09-27 17:42 ` Peter Crosthwaite
2015-09-27 18:01 ` Max Filippov
2015-09-27 18:36 ` Peter Crosthwaite
2015-09-27 17:16 ` Max Filippov [this message]
2015-09-27 17:38 ` [Qemu-devel] [PATCH 3/3] target-xtensa: xtfpga: support noMMU cores Peter Crosthwaite
2015-09-27 18:13 ` Max Filippov
2015-09-27 18:43 ` Peter Crosthwaite
2015-09-27 19:01 ` Max Filippov
2015-09-27 21:28 ` Peter Crosthwaite
2015-09-27 21:48 ` Max Filippov
2015-09-27 21:59 ` Peter Crosthwaite
2015-09-29 10:34 ` Max Filippov
2015-09-29 19:20 ` Peter Crosthwaite
2015-09-30 17:41 ` Max Filippov
2015-09-29 20:42 ` Peter Maydell
2015-09-30 20:17 ` Max Filippov
2015-09-30 20:45 ` Peter Maydell
2015-09-30 20:54 ` Max Filippov
2015-09-30 21:02 ` Peter Crosthwaite
2015-09-30 22:07 ` Max Filippov
2015-09-30 22:23 ` Peter Crosthwaite
2015-09-30 22:33 ` Peter Crosthwaite
2015-09-30 22:42 ` Max Filippov
2015-10-01 18:06 ` Peter Crosthwaite
2015-10-01 18:25 ` Max Filippov
2015-10-01 19:18 ` Peter Crosthwaite
2015-10-01 20:13 ` Max Filippov
2015-10-01 21:19 ` Peter Crosthwaite
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=1443374214-27149-4-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).