* [Qemu-devel] [PATCH v2 0/2] target-xtensa: xtfpga: support cores without MMU @ 2015-09-27 20:58 Max Filippov 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO Max Filippov 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 2/2] target-xtensa: xtfpga: support noMMU cores Max Filippov 0 siblings, 2 replies; 5+ messages in thread From: Max Filippov @ 2015-09-27 20:58 UTC (permalink / raw) To: qemu-devel; +Cc: Max Filippov, Peter Crosthwaite Hello, this series adds noMMU memory map to Xtensa XTFPGA board allowing to run uClinux on cores without MMU. Changes v1->v2: - drop patch 1; - create and initialize XTFPGA FLASH device in hw/xtensa/xtfpga.c with series of qdev_prop_set_*; - replace bool mmu with enum; - decide if system IO alias is needed based on alias address. Max Filippov (2): target-xtensa: xtfpga: attach FLASH to system IO target-xtensa: xtfpga: support noMMU cores hw/xtensa/xtfpga.c | 101 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 22 deletions(-) -- 1.8.1.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO 2015-09-27 20:58 [Qemu-devel] [PATCH v2 0/2] target-xtensa: xtfpga: support cores without MMU Max Filippov @ 2015-09-27 20:58 ` Max Filippov 2015-09-27 21:34 ` Peter Crosthwaite 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 2/2] target-xtensa: xtfpga: support noMMU cores Max Filippov 1 sibling, 1 reply; 5+ messages in thread From: Max Filippov @ 2015-09-27 20:58 UTC (permalink / raw) To: qemu-devel; +Cc: Max Filippov, Peter Crosthwaite XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important for systems with MMU where system IO block is visible at single location, but it's important for noMMU systems, where system IO block is accessible through two separate physical address ranges. Map XTFPGA FLASH to system IO block and fix offsets used for mapping. Create and initialize FLASH device with series of qdev_prop_set_* as that's the preferred interface now. Keep initialization in a separate function. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> --- Changes v1->v2: - create and initialize XTFPGA FLASH device in hw/xtensa/xtfpga.c with series of qdev_prop_set_*; hw/xtensa/xtfpga.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 72350f1..b3f5d09 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -149,6 +149,32 @@ static void lx60_net_init(MemoryRegion *address_space, memory_region_add_subregion(address_space, buffers, ram); } +static pflash_t *xtfpga_flash_init(MemoryRegion *address_space, + const LxBoardDesc *board, + DriveInfo *dinfo, int be) +{ + SysBusDevice *s; + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); + + qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), + &error_abort); + qdev_prop_set_uint32(dev, "num-blocks", + board->flash_size / board->flash_sector_size); + qdev_prop_set_uint64(dev, "sector-length", board->flash_sector_size); + qdev_prop_set_uint8(dev, "width", 4); + qdev_prop_set_bit(dev, "big-endian", be); + qdev_prop_set_uint16(dev, "id0", 0x00); + qdev_prop_set_uint16(dev, "id1", 0x00); + qdev_prop_set_uint16(dev, "id2", 0x00); + qdev_prop_set_uint16(dev, "id3", 0x00); + qdev_prop_set_string(dev, "name", "lx60.io.flash"); + qdev_init_nofail(dev); + s = SYS_BUS_DEVICE(dev); + memory_region_add_subregion(address_space, board->flash_base, + sysbus_mmio_get_region(s, 0)); + return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); +} + static uint64_t translate_phys_addr(void *opaque, uint64_t addr) { XtensaCPU *cpu = opaque; @@ -247,16 +273,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) dinfo = drive_get(IF_PFLASH, 0, 0); if (dinfo) { - flash = pflash_cfi01_register(board->flash_base, - NULL, "lx60.io.flash", board->flash_size, - blk_by_legacy_dinfo(dinfo), - board->flash_sector_size, - board->flash_size / board->flash_sector_size, - 4, 0x0000, 0x0000, 0x0000, 0x0000, be); - if (flash == NULL) { - error_report("unable to mount pflash"); - exit(EXIT_FAILURE); - } + flash = xtfpga_flash_init(system_io, board, dinfo, be); } /* Use presence of kernel file name as 'boot from SRAM' switch. */ @@ -386,7 +403,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) static void xtensa_lx60_init(MachineState *machine) { static const LxBoardDesc lx60_board = { - .flash_base = 0xf8000000, + .flash_base = 0x08000000, .flash_size = 0x00400000, .flash_sector_size = 0x10000, .sram_size = 0x20000, @@ -397,7 +414,7 @@ static void xtensa_lx60_init(MachineState *machine) static void xtensa_lx200_init(MachineState *machine) { static const LxBoardDesc lx200_board = { - .flash_base = 0xf8000000, + .flash_base = 0x08000000, .flash_size = 0x01000000, .flash_sector_size = 0x20000, .sram_size = 0x2000000, @@ -408,7 +425,7 @@ static void xtensa_lx200_init(MachineState *machine) static void xtensa_ml605_init(MachineState *machine) { static const LxBoardDesc ml605_board = { - .flash_base = 0xf8000000, + .flash_base = 0x08000000, .flash_size = 0x01000000, .flash_sector_size = 0x20000, .sram_size = 0x2000000, @@ -419,7 +436,7 @@ static void xtensa_ml605_init(MachineState *machine) static void xtensa_kc705_init(MachineState *machine) { static const LxBoardDesc kc705_board = { - .flash_base = 0xf0000000, + .flash_base = 0x00000000, .flash_size = 0x08000000, .flash_boot_base = 0x06000000, .flash_sector_size = 0x20000, -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO Max Filippov @ 2015-09-27 21:34 ` Peter Crosthwaite 2015-09-27 21:58 ` Max Filippov 0 siblings, 1 reply; 5+ messages in thread From: Peter Crosthwaite @ 2015-09-27 21:34 UTC (permalink / raw) To: Max Filippov; +Cc: qemu-devel@nongnu.org Developers On Sun, Sep 27, 2015 at 1:58 PM, Max Filippov <jcmvbkbc@gmail.com> wrote: > XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important > for systems with MMU where system IO block is visible at single > location, but it's important for noMMU systems, where system IO block is > accessible through two separate physical address ranges. > > Map XTFPGA FLASH to system IO block and fix offsets used for mapping. > Create and initialize FLASH device with series of qdev_prop_set_* as > that's the preferred interface now. Keep initialization in a separate > function. > > Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> > --- > Changes v1->v2: > - create and initialize XTFPGA FLASH device in hw/xtensa/xtfpga.c with > series of qdev_prop_set_*; > > hw/xtensa/xtfpga.c | 45 +++++++++++++++++++++++++++++++-------------- > 1 file changed, 31 insertions(+), 14 deletions(-) > > diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c > index 72350f1..b3f5d09 100644 > --- a/hw/xtensa/xtfpga.c > +++ b/hw/xtensa/xtfpga.c > @@ -149,6 +149,32 @@ static void lx60_net_init(MemoryRegion *address_space, > memory_region_add_subregion(address_space, buffers, ram); > } > > +static pflash_t *xtfpga_flash_init(MemoryRegion *address_space, > + const LxBoardDesc *board, > + DriveInfo *dinfo, int be) > +{ > + SysBusDevice *s; > + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); > + > + qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), > + &error_abort); > + qdev_prop_set_uint32(dev, "num-blocks", > + board->flash_size / board->flash_sector_size); > + qdev_prop_set_uint64(dev, "sector-length", board->flash_sector_size); > + qdev_prop_set_uint8(dev, "width", 4); > + qdev_prop_set_bit(dev, "big-endian", be); > + qdev_prop_set_uint16(dev, "id0", 0x00); > + qdev_prop_set_uint16(dev, "id1", 0x00); > + qdev_prop_set_uint16(dev, "id2", 0x00); > + qdev_prop_set_uint16(dev, "id3", 0x00); You can drop the ID setters to 0x00. That's the default. Otherwise: Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Something out of scope and possible follow-up: As these are real boards, ideally we have the ID for the actual parts populated. For ML605, the petalogix_ml605_mmu machine model does have this as non-zero. Regards, Peter > + qdev_prop_set_string(dev, "name", "lx60.io.flash"); > + qdev_init_nofail(dev); > + s = SYS_BUS_DEVICE(dev); > + memory_region_add_subregion(address_space, board->flash_base, > + sysbus_mmio_get_region(s, 0)); > + return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); > +} > + > static uint64_t translate_phys_addr(void *opaque, uint64_t addr) > { > XtensaCPU *cpu = opaque; > @@ -247,16 +273,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) > > dinfo = drive_get(IF_PFLASH, 0, 0); > if (dinfo) { > - flash = pflash_cfi01_register(board->flash_base, > - NULL, "lx60.io.flash", board->flash_size, > - blk_by_legacy_dinfo(dinfo), > - board->flash_sector_size, > - board->flash_size / board->flash_sector_size, > - 4, 0x0000, 0x0000, 0x0000, 0x0000, be); > - if (flash == NULL) { > - error_report("unable to mount pflash"); > - exit(EXIT_FAILURE); > - } > + flash = xtfpga_flash_init(system_io, board, dinfo, be); > } > > /* Use presence of kernel file name as 'boot from SRAM' switch. */ > @@ -386,7 +403,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) > static void xtensa_lx60_init(MachineState *machine) > { > static const LxBoardDesc lx60_board = { > - .flash_base = 0xf8000000, > + .flash_base = 0x08000000, > .flash_size = 0x00400000, > .flash_sector_size = 0x10000, > .sram_size = 0x20000, > @@ -397,7 +414,7 @@ static void xtensa_lx60_init(MachineState *machine) > static void xtensa_lx200_init(MachineState *machine) > { > static const LxBoardDesc lx200_board = { > - .flash_base = 0xf8000000, > + .flash_base = 0x08000000, > .flash_size = 0x01000000, > .flash_sector_size = 0x20000, > .sram_size = 0x2000000, > @@ -408,7 +425,7 @@ static void xtensa_lx200_init(MachineState *machine) > static void xtensa_ml605_init(MachineState *machine) > { > static const LxBoardDesc ml605_board = { > - .flash_base = 0xf8000000, > + .flash_base = 0x08000000, > .flash_size = 0x01000000, > .flash_sector_size = 0x20000, > .sram_size = 0x2000000, > @@ -419,7 +436,7 @@ static void xtensa_ml605_init(MachineState *machine) > static void xtensa_kc705_init(MachineState *machine) > { > static const LxBoardDesc kc705_board = { > - .flash_base = 0xf0000000, > + .flash_base = 0x00000000, > .flash_size = 0x08000000, > .flash_boot_base = 0x06000000, > .flash_sector_size = 0x20000, > -- > 1.8.1.4 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO 2015-09-27 21:34 ` Peter Crosthwaite @ 2015-09-27 21:58 ` Max Filippov 0 siblings, 0 replies; 5+ messages in thread From: Max Filippov @ 2015-09-27 21:58 UTC (permalink / raw) To: Peter Crosthwaite; +Cc: qemu-devel@nongnu.org Developers On Mon, Sep 28, 2015 at 12:34 AM, Peter Crosthwaite <crosthwaitepeter@gmail.com> wrote: > On Sun, Sep 27, 2015 at 1:58 PM, Max Filippov <jcmvbkbc@gmail.com> wrote: >> + qdev_prop_set_uint16(dev, "id0", 0x00); >> + qdev_prop_set_uint16(dev, "id1", 0x00); >> + qdev_prop_set_uint16(dev, "id2", 0x00); >> + qdev_prop_set_uint16(dev, "id3", 0x00); > > You can drop the ID setters to 0x00. That's the default. Otherwise: > > Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Ok. > Something out of scope and possible follow-up: As these are real > boards, ideally we have the ID for the actual parts populated. For > ML605, the petalogix_ml605_mmu machine model does have this as > non-zero. So far there were no need in this level of detail. -- Thanks. -- Max ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] target-xtensa: xtfpga: support noMMU cores 2015-09-27 20:58 [Qemu-devel] [PATCH v2 0/2] target-xtensa: xtfpga: support cores without MMU Max Filippov 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO Max Filippov @ 2015-09-27 20:58 ` Max Filippov 1 sibling, 0 replies; 5+ messages in thread From: Max Filippov @ 2015-09-27 20:58 UTC (permalink / raw) To: qemu-devel; +Cc: Max Filippov, Peter Crosthwaite 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> --- Changes v1->v2: - replace bool mmu with enum; - decide if system IO alias is needed based on alias address. hw/xtensa/xtfpga.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index b3f5d09..3bc27a8 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -225,8 +225,36 @@ 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; int n; + enum { + XTENSA_NO_MMU, + XTENSA_MMU, + } mmu; + + static const struct { + hwaddr ram; + hwaddr rom; + hwaddr io[2]; + } base[2] = { + [XTENSA_NO_MMU] = { + .ram = 0x60000000, + .rom = 0x50000000, + .io = { + 0x90000000, + 0x70000000, + }, + }, + [XTENSA_MMU] = { + .ram = 0, + .rom = 0xfe000000, + .io = { + 0xf0000000, + }, + }, + }; + if (!cpu_model) { cpu_model = XTENSA_DEFAULT_CPU_MODEL; } @@ -248,16 +276,25 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) cpu_reset(CPU(cpu)); } + mmu = xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ? + XTENSA_MMU : XTENSA_NO_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 (base[mmu].io[1]) { + 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, @@ -280,22 +317,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); @@ -394,7 +434,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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-27 21:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-27 20:58 [Qemu-devel] [PATCH v2 0/2] target-xtensa: xtfpga: support cores without MMU Max Filippov 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 1/2] target-xtensa: xtfpga: attach FLASH to system IO Max Filippov 2015-09-27 21:34 ` Peter Crosthwaite 2015-09-27 21:58 ` Max Filippov 2015-09-27 20:58 ` [Qemu-devel] [PATCH v2 2/2] target-xtensa: xtfpga: support noMMU cores Max Filippov
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).