Skip to contentSkip to conversation

xtensa_lx60: FLASH, kernel args support, minor fixes

PATCH New Max Filippov 1 participant 4 messages Oct 30, 2011

lore
Share & tools
lore
#0 lore raw

cover xtensa_lx60: FLASH, kernel args support, minor fixes

Max Filippov (3):
xtensa_lx60: add FLASH support
xtensa_lx60: pass kernel arguments from -append
xtensa_lx60: fix build date code and change memory region names

 default-configs/xtensa-softmmu.mak   |    1 +
 default-configs/xtensaeb-softmmu.mak |    1 +
 hw/xtensa_bootparam.h                |   25 ++++++++
 hw/xtensa_lx60.c                     |  111 +++++++++++++++++++++++++++++-----
 4 files changed, 122 insertions(+), 16 deletions(-)
 create mode 100644 hw/xtensa_bootparam.h
Signature · 1 line
1.7.6.4
#2 lore raw

PATCH 2/3 xtensa_lx60: pass kernel arguments from -append

Create boot parameters in the end of SRAM region, insert kernel arguments specified in -append there.

---
 hw/xtensa_bootparam.h |   25 +++++++++++++++++++++++++
 hw/xtensa_lx60.c      |   24 ++++++++++++++++++++----
 2 files changed, 45 insertions(+), 4 deletions(-)
 create mode 100644 hw/xtensa_bootparam.h
hw/xtensa_bootparam.h new file +25 -0
new file mode 100644
index 0000000..38ef32b
@@ -0,0 +1,25 @@
+#ifndef HW_XTENSA_BOOTPARAM
+#define HW_XTENSA_BOOTPARAM
+
+typedef struct BpTag {
+    uint16_t tag;
+    uint16_t size;
+} BpTag;
+
+static inline ram_addr_t put_tag(ram_addr_t addr, uint16_t tag,
+        size_t size, const void *data)
+{
+    BpTag bp_tag = {
+        .tag = tswap16(tag),
+        .size = tswap16((size + 3) & ~3),
+    };
+
+    cpu_physical_memory_write(addr, &bp_tag, sizeof(bp_tag));
+    addr += sizeof(bp_tag);
+    cpu_physical_memory_write(addr, data, size);
+    addr += (size + 3) & ~3;
+
+    return addr;
+}
+
+#endif
hw/xtensa_lx60.c +20 -4
index cb047d2..069b21c 100644
@@ -34,6 +34,7 @@
 #include "pc.h"
 #include "sysbus.h"
 #include "flash.h"
+#include "xtensa_bootparam.h"
 
 typedef struct LxBoardDesc {
     size_t flash_size;
@@ -188,10 +189,6 @@ static void lx_init(const LxBoardDesc *board,
     memory_region_init_ram(ram, NULL, "xtensa.sram", ram_size);
     memory_region_add_subregion(system_memory, 0, ram);
 
-    rom = g_malloc(sizeof(*rom));
-    memory_region_init_ram(rom, NULL, "xtensa.rom", 0x1000);
-    memory_region_add_subregion(system_memory, 0xfe000000, rom);
-
     system_io = g_malloc(sizeof(*system_io));
     memory_region_init(system_io, "system.io", 224 * 1024 * 1024);
     memory_region_add_subregion(system_memory, 0xf0000000, system_io);
@@ -223,6 +220,25 @@ static void lx_init(const LxBoardDesc *board,
 
     /* Use presence of kernel file name as 'boot from SRAM' switch. */
     if (kernel_filename) {
+        rom = g_malloc(sizeof(*rom));
+        memory_region_init_ram(rom, NULL, "lx60.sram", board->sram_size);
+        memory_region_add_subregion(system_memory, 0xfe000000, rom);
+
+        /* Put kernel bootparameters to the end of that SRAM */
+        if (kernel_cmdline) {
+            size_t cmdline_size = strlen(kernel_cmdline) + 1;
+            size_t bp_size = sizeof(BpTag[4]) + cmdline_size;
+            uint32_t tagptr = (0xfe000000 + board->sram_size - bp_size) & ~0xff;
+
+            env->regs[2] = tagptr;
+
+            tagptr = put_tag(tagptr, 0x7b0b, 0, NULL);
+            if (cmdline_size > 1) {
+                tagptr = put_tag(tagptr, 0x1001,
+                        cmdline_size, kernel_cmdline);
+            }
+            tagptr = put_tag(tagptr, 0x7e0b, 0, NULL);
+        }
         uint64_t elf_entry;
         uint64_t elf_lowaddr;
         int success = load_elf(kernel_filename, translate_phys_addr, env,
Signature · 1 line
1.7.6.4
#3 lore raw

PATCH 3/3 xtensa_lx60: fix build date code and change memory region names

In reply to Max Filippov

Fix date code to uses MMDDYYYY notation.
Change memory region names to reflect specification that defines them.

---
 hw/xtensa_lx60.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
hw/xtensa_lx60.c +4 -4
index 069b21c..8947157 100644
@@ -63,7 +63,7 @@ static uint64_t lx60_fpga_read(void *opaque, target_phys_addr_t addr,
 
     switch (addr) {
     case 0x0: /*build date code*/
-        return 0x27092011;
+        return 0x09272011;
 
     case 0x4: /*processor clock frequency, Hz*/
         return 10000000;
@@ -107,7 +107,7 @@ static Lx60FpgaState *lx60_fpga_init(MemoryRegion *address_space,
     Lx60FpgaState *s = g_malloc(sizeof(Lx60FpgaState));
 
     memory_region_init_io(&s->iomem, &lx60_fpga_ops, s,
-            "lx60-fpga", 0x10000);
+            "lx60.fpga", 0x10000);
     memory_region_add_subregion(address_space, base, &s->iomem);
     lx60_fpga_reset(s);
     qemu_register_reset(lx60_fpga_reset, s);
@@ -186,11 +186,11 @@ static void lx_init(const LxBoardDesc *board,
     }
 
     ram = g_malloc(sizeof(*ram));
-    memory_region_init_ram(ram, NULL, "xtensa.sram", ram_size);
+    memory_region_init_ram(ram, NULL, "lx60.dram", ram_size);
     memory_region_add_subregion(system_memory, 0, ram);
 
     system_io = g_malloc(sizeof(*system_io));
-    memory_region_init(system_io, "system.io", 224 * 1024 * 1024);
+    memory_region_init(system_io, "lx60.io", 224 * 1024 * 1024);
     memory_region_add_subregion(system_memory, 0xf0000000, system_io);
     lx60_fpga_init(system_io, 0x0d020000);
     if (nd_table[0].vlan) {
Signature · 1 line
1.7.6.4
#1 lore raw

PATCH 1/3 xtensa_lx60: add FLASH support

In reply to Max Filippov

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.

---
 default-configs/xtensa-softmmu.mak   |    1 +
 default-configs/xtensaeb-softmmu.mak |    1 +
 hw/xtensa_lx60.c                     |   79 ++++++++++++++++++++++++++++++---
 3 files changed, 73 insertions(+), 8 deletions(-)
default-configs/xtensa-softmmu.mak +1 -0
index 7f0df34..9d8899c 100644
@@ -2,3 +2,4 @@
 
 CONFIG_SERIAL=y
 CONFIG_OPENCORES_ETH=y
+CONFIG_PFLASH_CFI01=y
default-configs/xtensaeb-softmmu.mak +1 -0
index 7f0df34..9d8899c 100644
@@ -2,3 +2,4 @@
 
 CONFIG_SERIAL=y
 CONFIG_OPENCORES_ETH=y
+CONFIG_PFLASH_CFI01=y
hw/xtensa_lx60.c +71 -8

124 lines not on this page · raw message

Signature · 1 line
1.7.6.4