target-xtensa patches for 1.0
The following fixes for target-xtensa targeting 1.0 are available in the git repository at
git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa
Max Filippov (7):
target-xtensa: mask out undefined bits of WINDOWBASE SR
target-xtensa: handle cache options in the overlay tool
target-xtensa: raise an exception for invalid and reserved opcodes
opencores_eth: fix RX path: FCS, padding and TL
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/opencores_eth.c | 29 +++++++-- hw/xtensa_bootparam.h | 25 ++++++++ hw/xtensa_lx60.c | 111 +++++++++++++++++++++++++++++----- target-xtensa/overlay_tool.h | 6 ++ target-xtensa/translate.c | 9 ++- 7 files changed, 159 insertions(+), 23 deletions(-) create mode 100644 hw/xtensa_bootparam.h
Signature · 1 line
1.7.6.4
PATCH 1/7 target-xtensa: mask out undefined bits of WINDOWBASE SR
According to ISA, table 5-156, bits 32:NAREG/4 of the WINDOWSTART SR must be zero.
--- target-xtensa/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-xtensa/translate.c +1 -1
@@ -466,7 +466,7 @@ static void gen_wsr_windowbase(DisasContext *dc, uint32_t sr, TCGv_i32 v)static void gen_wsr_windowstart (DisasContext *dc,uint32_t sr,TCGv_i32 v) { -tcg_gen_mov_i32 (cpu_SR[sr], v); +tcg_gen_andi_i32 (cpu_SR[sr], v, (1 << dc->config->nareg /4 ) -1 );reset_used_window (dc); }
Signature · 1 line
1.7.6.4
PATCH 1/3 xtensa_lx60: add FLASH support
In reply to Max FilippovLX60 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
@@ -2,3 +2,4 @@ CONFIG_SERIAL=y CONFIG_OPENCORES_ETH=y +CONFIG_PFLASH_CFI01=y
default-configs/xtensaeb-softmmu.mak +1 -0
@@ -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
PATCH 2/7 target-xtensa: handle cache options in the overlay tool
In reply to Max FilippovCache options must be enabled for the cores that have cache to avoid illegal instruction exceptions.
--- target-xtensa/overlay_tool.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
target-xtensa/overlay_tool.h +6 -0
@@ -71,6 +71,12 @@ XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT) | \XCHAL_OPTION (XCHAL_HAVE_CCOUNT ,XTENSA_OPTION_TIMER_INTERRUPT ) | \/* Local memory, TODO */ \ +XCHAL_OPTION (XCHAL_ICACHE_WAYS ,XTENSA_OPTION_ICACHE ) | \ +XCHAL_OPTION (XCHAL_ICACHE_LINE_LOCKABLE , \ +XTENSA_OPTION_ICACHE_INDEX_LOCK ) | \ +XCHAL_OPTION (XCHAL_DCACHE_WAYS ,XTENSA_OPTION_DCACHE ) | \ +XCHAL_OPTION (XCHAL_DCACHE_LINE_LOCKABLE , \ +XTENSA_OPTION_DCACHE_INDEX_LOCK ) | \XCHAL_OPTION (XCHAL_UNALIGNED_LOAD_HW ,XTENSA_OPTION_HW_ALIGNMENT ) | \/* Memory protection and translation */ \ XCHAL_OPTION(XCHAL_HAVE_MIMIC_CACHEATTR, \
Signature · 1 line
1.7.6.4
PATCH 3/7 target-xtensa: raise an exception for invalid and reserved opcodes
In reply to Max FilippovThis includes opcodes from disabled features and those marked reserved in the ISA. Also end TB on opcodes that definitely generate an exception: illegal instructions, syscall and privileged instructions.
--- target-xtensa/translate.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
target-xtensa/translate.c +6 -1
@@ -266,6 +266,10 @@ static void gen_exception_cause(DisasContext *dc, uint32_t cause)gen_helper_exception_cause (tpc, tcause);tcg_temp_free (tpc);tcg_temp_free (tcause); +if (cause ==ILLEGAL_INSTRUCTION_CAUSE || + cause ==SYSCALL_CAUSE ) { + dc->is_jmp =DISAS_UPDATE ; + } } static void gen_exception_cause_vaddr(DisasContext *dc, uint32_t cause,
@@ -283,6 +287,7 @@ static void gen_check_privilege(DisasContext *dc) {if (dc->cring) {gen_exception_cause (dc,PRIVILEGED_CAUSE ); + dc->is_jmp =DISAS_UPDATE ; } }
@@ -2378,7 +2383,7 @@ static void disas_xtensa_insn(DisasContext *dc) invalid_opcode:qemu_log ("INVALID(pc = %08x)\n" , dc->pc); - dc->pc = dc->next_pc; +gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE );#undef HAS_OPTION }
Signature · 1 line
1.7.6.4
PATCH 3/3 xtensa_lx60: fix build date code and change memory region names
In reply to Max FilippovFix 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
@@ -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
PATCH 2/3 xtensa_lx60: pass kernel arguments from -append
In reply to Max FilippovCreate 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
@@ -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
@@ -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
PATCH 4/7 opencores_eth: fix RX path: FCS, padding and TL
In reply to Max FilippovOpenCores 10/100 Mbps Ethernet MAC specification doesn't clearly state whether FCS is counted in the RX frame length or not. Looks like it is. Append zero FCS to the received frames.
Get rid of big static buffer for RX frame padding, optimize it for the most common MINFL value range.
Set RXD_TL for the long frames only when HUGEN bit is set.
--- hw/opencores_eth.c | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-)
hw/opencores_eth.c +24 -5
@@ -382,6 +382,7 @@ static ssize_t open_eth_receive(VLANClientState *nc,OpenEthState *s =DO_UPCAST (NICState, nc, nc)->opaque;size_t maxfl =GET_REGFIELD (s,PACKETLEN ,MAXFL );size_t minfl =GET_REGFIELD (s,PACKETLEN ,MINFL ); +size_t fcsl =4 ;bool miss = true;trace_open_eth_receive ((unsigned )size);
@@ -418,6 +419,7 @@ static ssize_t open_eth_receive(VLANClientState *nc,#else {#endif +static const uint8_t zero[64 ] = {0 };desc *desc =rx_desc (s);size_t copy_size =GET_REGBIT (s,MODER ,HUGEN ) ?65536 : maxfl;
@@ -426,11 +428,13 @@ static ssize_t open_eth_receive(VLANClientState *nc,if (copy_size > size) { copy_size = size; + }else { + fcsl =0 ; }if (miss) { desc->len_flags |=RXD_M ; } -if (size > maxfl) { +if (GET_REGBIT (s,MODER ,HUGEN ) && size > maxfl) { desc->len_flags |=RXD_TL ; }#ifdef USE_RECSMALL
@@ -442,13 +446,28 @@ static ssize_t open_eth_receive(VLANClientState *nc,cpu_physical_memory_write (desc->buf_ptr, buf, copy_size);if (GET_REGBIT (s,MODER ,PAD ) && copy_size < minfl) { -static const uint8_t zero[65536 ] = {0 }; +if (minfl - copy_size > fcsl) { + fcsl =0 ; + }else { + fcsl -= minfl - copy_size; + } +while (copy_size < minfl) { +size_t zero_sz = minfl - copy_size <sizeof (zero) ? + minfl - copy_size :sizeof (zero); -cpu_physical_memory_write (desc->buf_ptr + copy_size, - zero, minfl - copy_size); - copy_size = minfl; +cpu_physical_memory_write (desc->buf_ptr + copy_size, + zero, zero_sz); + copy_size += zero_sz; + } } +/* There's no FCS in the frames handed to us by the QEMU, zero fill it. +* Don't do it if the frame is cut at the MAXFL or padded with 4 or +* more bytes to the MINFL. +*/ +cpu_physical_memory_write (desc->buf_ptr + copy_size, zero, fcsl); + copy_size += fcsl; +SET_FIELD (desc->len_flags,RXD_LEN , copy_size);if ((desc->len_flags &RXD_WRAP ) || s->rx_desc ==0x7f ) {
Signature · 1 line
1.7.6.4
PATCH 5/7 xtensa_lx60: add FLASH support
In reply to Max FilippovLX60 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
@@ -2,3 +2,4 @@ CONFIG_SERIAL=y CONFIG_OPENCORES_ETH=y +CONFIG_PFLASH_CFI01=y
default-configs/xtensaeb-softmmu.mak +1 -0
@@ -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
PATCH 6/7 xtensa_lx60: pass kernel arguments from -append
In reply to Max FilippovCreate 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
@@ -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
@@ -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
PATCH 7/7 xtensa_lx60: fix build date code and change memory region names
In reply to Max FilippovFix 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
@@ -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
Quoted 14 lines
The following fixes for target-xtensa targeting 1.0 are available in the git repository at
git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.gitxtensaMax Filippov (7):
target-xtensa: mask out undefined bits of WINDOWBASE SR
target-xtensa: handle cache options in the overlay tool
target-xtensa: raise an exception for invalid and reserved opcodes
opencores_eth: fix RX path: FCS, padding and TL
xtensa_lx60: add FLASH support
xtensa_lx60: pass kernel arguments from -append
xtensa_lx60: fix build date code and change memory region names
Quoted 10 lines
default-configs/xtensa-softmmu.mak | 1 + default-configs/xtensaeb-softmmu.mak | 1 + hw/opencores_eth.c | 29 +++++++-- hw/xtensa_bootparam.h | 25 ++++++++ hw/xtensa_lx60.c | 111 +++++++++++++++++++++++++++++----- target-xtensa/overlay_tool.h | 6 ++ target-xtensa/translate.c | 9 ++- 7 files changed, 159 insertions(+), 23 deletions(-) create mode 100644 hw/xtensa_bootparam.h
Please ignore letters [PATCH x/3], there are 7 patches in this series.
Thanks.
-- Max
PATCH v2 1/1 target-xtensa: mask out undefined bits of WINDOWSTART SR
In reply to Max FilippovAccording to ISA, table 5-156, bits 32:NAREG/4 of the WINDOWSTART SR must be zero.
---v1->v2 changes: fix commit log subject
--- target-xtensa/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-xtensa/translate.c +1 -1
@@ -466,7 +466,7 @@ static void gen_wsr_windowbase(DisasContext *dc, uint32_t sr, TCGv_i32 v)static void gen_wsr_windowstart (DisasContext *dc,uint32_t sr,TCGv_i32 v) { -tcg_gen_mov_i32 (cpu_SR[sr], v); +tcg_gen_andi_i32 (cpu_SR[sr], v, (1 << dc->config->nareg /4 ) -1 );reset_used_window (dc); }
Signature · 1 line
1.7.6.4
Quoted 4 lines · Max Filippov
The following fixes for target-xtensa targeting 1.0 are available in the git repository at
git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa
Thanks, pulled.
Quoted 23 lines
Max Filippov (7):
target-xtensa: mask out undefined bits of WINDOWBASE SR
target-xtensa: handle cache options in the overlay tool
target-xtensa: raise an exception for invalid and reserved opcodes
opencores_eth: fix RX path: FCS, padding and TL
xtensa_lx60: add FLASH support
xtensa_lx60: pass kernel arguments from -append
xtensa_lx60: fix build date code and change memory region namesdefault-configs/xtensa-softmmu.mak | 1 + default-configs/xtensaeb-softmmu.mak | 1 +
hw/opencores_eth.c | 29 +++++++--hw/xtensa_bootparam.h| 25 ++++++++hw/xtensa_lx60.c| 111 +++++++++++++++++++++++++++++-----target-xtensa/overlay_tool.h| 6 ++target-xtensa/translate.c| 9 ++-7 files changed, 159 insertions(+), 23 deletions(-)create mode 100644
hw/xtensa_bootparam.h--
1.7.6.4