hexagon system emulation v2, part 3/3
v2 cover hexagon system emulation v2, part 3/3
As with parts 1, 2 - some of the changes requested have been made, but not all.
New features for part 3:
- global registers device model
- boot-serial-test qtest case
Issues not addressed with v2:
* "Add l2vic interrupt controller" - DECLARE_SIMPLE_TYPE, bitops
- I might also push this and/or QTimer out of this series to simplify things a bit.
Brian Cain (8):
hw/hexagon: Add globalreg model
hw/hexagon: Add global register tracing
hw/hexagon: Add machine configs for sysemu
hw/hexagon: Add v68, sa8775-cdsp0 defs
hw/hexagon: Modify "Standalone" symbols
target/hexagon: add build config for softmmu
hw/hexagon: Define hexagon "virt" machine
tests/qtest: Add hexagon boot-serial-test
Sid Manning (3):
hw/hexagon: Add support for cfgbase
hw/timer: Add QTimer device
hw/intc: Add l2vic interrupt controller
MAINTAINERS | 7 + docs/devel/hexagon-l2vic.rst | 59 +++ docs/devel/index-internals.rst | 1 + configs/devices/hexagon-softmmu/default.mak | 8 + configs/targets/hexagon-softmmu.mak | 7 + meson.build | 1 + qapi/machine.json | 4 +- include/hw/hexagon/hexagon.h | 150 ++++++ include/hw/hexagon/hexagon_globalreg.h | 60 +++ include/hw/hexagon/virt.h | 43 ++ include/hw/intc/l2vic.h | 38 ++ include/hw/timer/qct-qtimer.h | 85 ++++ target/hexagon/cpu.h | 6 +- hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 63 +++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 63 +++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 64 +++ hw/hexagon/hexagon_dsp.c | 211 ++++++++ hw/hexagon/hexagon_globalreg.c | 345 +++++++++++++ hw/hexagon/virt.c | 457 +++++++++++++++++ hw/intc/l2vic.c | 421 ++++++++++++++++ hw/timer/qct-qtimer.c | 520 ++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/cpu.c | 5 + target/hexagon/op_helper.c | 2 +- target/hexagon/translate.c | 1 + tests/qtest/boot-serial-test.c | 8 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 16 + hw/hexagon/meson.build | 7 + hw/hexagon/trace-events | 3 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + hw/meson.build | 1 + hw/timer/meson.build | 2 + target/Kconfig | 1 + target/hexagon/Kconfig | 2 + target/hexagon/meson.build | 12 +- tests/qemu-iotests/testenv.py | 1 + tests/qtest/meson.build | 2 + 40 files changed, 2680 insertions(+), 8 deletions(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 include/hw/hexagon/hexagon.h create mode 100644 include/hw/hexagon/hexagon_globalreg.h create mode 100644 include/hw/hexagon/virt.h create mode 100644 include/hw/intc/l2vic.h create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc create mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644 hw/hexagon/machine_cfg_v68n_1024.h.inc create mode 100644 hw/hexagon/hexagon_dsp.c create mode 100644 hw/hexagon/hexagon_globalreg.c create mode 100644 hw/hexagon/virt.c create mode 100644 hw/intc/l2vic.c create mode 100644 hw/timer/qct-qtimer.c create mode 100644 hw/hexagon/Kconfig create mode 100644 hw/hexagon/meson.build create mode 100644 hw/hexagon/trace-events create mode 100644 target/hexagon/Kconfig
Signature · 1 line
2.34.1
PATCH v2 1/11 hw/hexagon: Add globalreg model
Some of the system registers are shared among all threads in the core. This object contains the representation and interface to the system registers.
--- include/hw/hexagon/hexagon_globalreg.h | 60 ++++++ target/hexagon/cpu.h | 1 + hw/hexagon/hexagon_globalreg.c | 269 +++++++++++++++++++++++++ target/hexagon/cpu.c | 2 + 4 files changed, 332 insertions(+) create mode 100644 include/hw/hexagon/hexagon_globalreg.h create mode 100644 hw/hexagon/hexagon_globalreg.c
include/hw/hexagon/hexagon_globalreg.h new file +60 -0
@@ -0,0 +1,60 @@ +/* +* Hexagon Global Registers QOM Object +* +* Copyright(c) 2025 Qualcomm Innovation Center, Inc. All Rights Reserved. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GLOBALREG_H +#define HEXAGON_GLOBALREG_H + +#include "hw/qdev-core.h" +#include "hw/sysbus.h" +#include "qom/object.h" +#include "target/hexagon/cpu.h" + +#define TYPE_HEXAGON_GLOBALREG "hexagon-globalreg" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonGlobalRegState, HEXAGON_GLOBALREG) + +struct HexagonGlobalRegState { +SysBusDevice parent_obj; + +/* Array of system registers */ +target_ulong regs[NUM_SREGS ]; + +/* Global performance cycle counter base */ +uint64_t g_pcycle_base; + +/* Properties for global register reset values */ +uint32_t boot_evb;/* Boot Exception Vector Base (HEX_SREG_EVB) */ +uint64_t config_table_addr;/* Configuration table base */ +uint32_t dsp_rev;/* DSP revision register (HEX_SREG_REV) */ + +/* ISDB properties */ +bool isdben_etm_enable;/* ISDB ETM enable bit */ +bool isdben_dfd_enable;/* ISDB DFD enable bit */ +bool isdben_trusted;/* ISDB trusted mode bit */ +bool isdben_secure;/* ISDB secure mode bit */ + +/* Hardware base addresses */ +uint32_t qtimer_base_addr;/* QTimer hardware base address */ +}; + +/* Public interface functions */ +uint32_t hexagon_globalreg_read (HexagonCPU *cpu,uint32_t reg); +void hexagon_globalreg_write (HexagonCPU *cpu,uint32_t reg, +uint32_t value); +uint32_t hexagon_globalreg_masked_value (HexagonCPU *cpu,uint32_t reg, +uint32_t value); +void hexagon_globalreg_write_masked (HexagonCPU *cpu,uint32_t reg, +uint32_t value); +void hexagon_globalreg_reset (HexagonCPU *cpu); + +/* Global performance cycle counter access */ +uint64_t hexagon_globalreg_get_pcycle_base (HexagonCPU *cpu); +void hexagon_globalreg_set_pcycle_base (HexagonCPU *cpu,uint64_t value); + +/* Hardware base address access */ +uint32_t hexagon_globalreg_get_qtimer_base_addr (HexagonCPU *cpu); + +#endif /* HEXAGON_GLOBALREG_H */
target/hexagon/cpu.h +1 -0
@@ -197,6 +197,7 @@ struct ArchCPU {uint32_t num_tlbs;uint32_t l2vic_base_addr;uint32_t boot_addr; +struct HexagonGlobalRegState *globalregs;#endif };
hw/hexagon/hexagon_globalreg.c new file +269 -0
269 lines not on this page · raw message
target/hexagon/cpu.c +2 -0
@@ -70,6 +70,8 @@ static const Property hexagon_cpu_properties[] = {DEFINE_PROP_UINT32 ("l2vic-base-addr" , HexagonCPU, l2vic_base_addr,0xffffffffULL ),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffffULL ), +DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, + TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *), #endifDEFINE_PROP_BOOL ("lldb-compat" , HexagonCPU, lldb_compat, false), DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, 0,
Signature · 1 line
2.34.1
PATCH v2 2/11 hw/hexagon: Add global register tracing
In reply to Brian Cain--- meson.build | 1 + hw/hexagon/hexagon_globalreg.c | 73 ++++++++++++++++++++++++++++++++++ hw/hexagon/trace-events | 3 ++ 3 files changed, 77 insertions(+) create mode 100644 hw/hexagon/trace-events
meson.build +1 -0
@@ -3669,6 +3669,7 @@ if have_system 'hw/display', 'hw/dma', 'hw/fsi', + 'hw/hexagon', 'hw/hyperv', 'hw/i2c', 'hw/i386',
hw/hexagon/hexagon_globalreg.c +73 -0
96 lines not on this page · raw message
hw/hexagon/trace-events new file +3 -0
@@ -0,0 +1,3 @@ +# Hexagon global register access +hexagon_globalreg_read(const char *reg_name, uint32_t value) "reg=%s value=0x%x" +hexagon_globalreg_write(const char *reg_name, uint32_t value) "reg=%s value=0x%x"
Signature · 1 line
2.34.1
Re: [PATCH v2 02/11] hw/hexagon: Add global register tracing
Quoted 23 lines · Brian Cain
Signed-off-by Brian Cain <[email protected]>--- meson.build | 1 + hw/hexagon/hexagon_globalreg.c | 73 ++++++++++++++++++++++++++++++++++ hw/hexagon/trace-events | 3 ++ 3 files changed, 77 insertions(+)create mode 100644 hw/hexagon/trace-events
hw/hexagon/hexagon_globalreg.c +1
-0@@ -99,6 +171,7 @@ void hexagon_globalreg_write(HexagonCPU *cpu, uint32_t reg,g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); s->regs[reg] = value; +trace_hexagon_globalreg_write (get_sreg_name (reg), value); } uint32_t hexagon_globalreg_masked_value(HexagonCPU *cpu, uint32_t reg,hw/hexagon/trace-events new file +0
-0
hw/hexagon/trace-events line 3
Quoted 3 lines
hw/hexagon/trace-events new file +3
-0@@ -0,0 +1,3 @@ +# Hexagon global register access +hexagon_globalreg_read(const char *reg_name, uint32_t value) "reg=%s value=0x%x" +hexagon_globalreg_write(const char *reg_name, uint32_t value) "reg=%s value=0x%x"
Maybe worth also tracing the cpuid, regardless:
PATCH v2 3/11 hw/hexagon: Add machine configs for sysemu
In reply to Brian CainFrom: Brian Cain <[email protected]>
Some header includes are modified here: these are uniquely required for basic system emulation functionality and had not been required for linux-user.
--- MAINTAINERS | 2 + qapi/machine.json | 4 +- include/hw/hexagon/hexagon.h | 150 ++++++++++++++++++++ target/hexagon/cpu.h | 1 + hw/hexagon/machine_cfg_v66g_1024.h.inc | 63 +++++++++ hw/hexagon/hexagon_dsp.c | 183 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/cpu.c | 1 + target/hexagon/op_helper.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 5 + hw/hexagon/meson.build | 5 + hw/meson.build | 1 + 14 files changed, 418 insertions(+), 3 deletions(-) create mode 100644 include/hw/hexagon/hexagon.h create mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644 hw/hexagon/hexagon_dsp.c create mode 100644 hw/hexagon/Kconfig create mode 100644 hw/hexagon/meson.build
MAINTAINERS +2 -0
@@ -229,6 +229,8 @@ Hexagon TCG CPUs M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ +F: hw/hexagon/ +F: include/hw/hexagon/ X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
qapi/machine.json +3 -1
@@ -26,6 +26,8 @@ # # @avr: since 5.1 # +# @hexagon: since 10.2 +# # @loongarch64: since 7.1 # # .. note:: The resulting QMP strings can be appended to the
@@ -35,7 +37,7 @@ # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hppa', 'i386', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386', 'loongarch64', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
include/hw/hexagon/hexagon.h new file +150 -0
150 lines not on this page · raw message
target/hexagon/cpu.h +1 -0
@@ -196,6 +196,7 @@ struct ArchCPU {#ifndef CONFIG_USER_ONLY uint32_t num_tlbs;uint32_t l2vic_base_addr; +uint32_t hvx_contexts;uint32_t boot_addr;struct HexagonGlobalRegState *globalregs;#endif
hw/hexagon/machine_cfg_v66g_1024.h.inc new file +63 -0
63 lines not on this page · raw message
hw/hexagon/hexagon_dsp.c new file +183 -0
183 lines not on this page · raw message
system/qdev-monitor.c +1 -1
@@ -69,7 +69,7 @@ typedef struct QDevAlias QEMU_ARCH_SPARC | \ QEMU_ARCH_XTENSA)#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X) -#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K) +#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K | QEMU_ARCH_HEXAGON)/* Please keep this table sorted by typename. */ static const QDevAlias qdev_alias_table[] = {
target/hexagon/cpu.c +1 -0
@@ -69,6 +69,7 @@ static const Property hexagon_cpu_properties[] = {DEFINE_PROP_UINT32 ("jtlb-entries" , HexagonCPU, num_tlbs,MAX_TLB_ENTRIES ),DEFINE_PROP_UINT32 ("l2vic-base-addr" , HexagonCPU, l2vic_base_addr,0xffffffffULL ), +DEFINE_PROP_UINT32 ("hvx-contexts" , HexagonCPU, hvx_contexts,0 ),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffffULL ),DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *),
target/hexagon/op_helper.c +1 -1
@@ -20,9 +20,9 @@#include "accel/tcg/cpu-ldst.h" #include "accel/tcg/probe.h" #include "qemu/main-loop.h" +#include "cpu.h" #include "exec/helper-proto.h" #include "fpu/softfloat.h" -#include "cpu.h" #include "exec/cpu-interrupt.h" #include "internal.h" #include "macros.h"
target/hexagon/translate.c +1 -0
@@ -32,6 +32,7 @@#include "translate.h" #include "genptr.h" #include "printinsn.h" +#include "exec/target_page.h" #define HELPER_H "helper.h"#include "exec/helper-info.c.inc"
hw/Kconfig +1 -0
@@ -52,6 +52,7 @@ source arm/Kconfig source cpu/Kconfig source alpha/Kconfig source avr/Kconfig +source hexagon/Kconfig source hppa/Kconfig source i386/Kconfig source loongarch/Kconfig
hw/hexagon/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config HEX_DSP + bool + default y + depends on HEXAGON && TCG + imply PTIMER
hw/hexagon/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +hexagon_ss = ss.source_set() +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c', 'hexagon_globalreg.c')) + +hw_arch += {'hexagon': hexagon_ss} +
hw/meson.build +1 -0
@@ -50,6 +50,7 @@ subdir('fsi') subdir('alpha') subdir('arm') subdir('avr') +subdir('hexagon') subdir('hppa') subdir('i386') subdir('loongarch')
Signature · 1 line
2.34.1
PATCH v2 4/11 hw/hexagon: Add v68, sa8775-cdsp0 defs
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 63 ++++++++++++++++++++++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 64 +++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc create mode 100644 hw/hexagon/machine_cfg_v68n_1024.h.inc
hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc new file +63 -0
@@ -0,0 +1,63 @@ + +static hexagon_machine_config SA8775P_cdsp0 = { + .cfgbase = 0x24000000 + 0x180000, + .l2tcm_size = 0x00000000, + .l2vic_base = 0x26300000 + 0x90000, + .l2vic_size = 0x00001000, + .csr_base = 0x26300000, + .qtmr_region = 0x26300000 + 0xA1000, + .cfgtable = { + .l2tcm_base = 0x00002400, + .reserved0 = 0x00000000, + .subsystem_base = 0x00002638, + .etm_base = 0x00002419, + .l2cfg_base = 0x0000241a, + .reserved1 = 0x0000241b, + .l1s0_base = 0x00002500, + .axi2_lowaddr = 0x00000000, + .streamer_base = 0x00000000, + .reserved2 = 0x00000000, + .fastl2vic_base = 0x0000241e, + .jtlb_size_entries = 0x00000080, + .coproc_present = 0x00000001, + .ext_contexts = 0x00000004, + .vtcm_base = 0x00002500, + .vtcm_size_kb = 0x00002000, + .l2tag_size = 0x00000400, + .l2ecomem_size = 0x00000000, + .thread_enable_mask = 0x0000003f, + .eccreg_base = 0x0000241f, + .l2line_size = 0x00000080, + .tiny_core = 0x00000000, + .l2itcm_size = 0x00000000, + .l2itcm_base = 0x00002400, + .reserved3 = 0x00000000, + .dtm_present = 0x00000000, + .dma_version = 0x00000003, + .hvx_vec_log_length = 0x00000007, + .core_id = 0x00000000, + .core_count = 0x00000000, + .coproc2_reg0 = 0x00000040, + .coproc2_reg1 = 0x00000020, + .v2x_mode = 0x00000001, + .coproc2_reg2 = 0x00000008, + .coproc2_reg3 = 0x00000020, + .coproc2_reg4 = 0x00000000, + .coproc2_reg5 = 0x00000002, + .coproc2_reg6 = 0x00000016, + .coproc2_reg7 = 0x00000006, + .acd_preset = 0x00000001, + .mnd_preset = 0x00000000, + .l1d_size_kb = 0x00000010, + .l1i_size_kb = 0x00000020, + .l1d_write_policy = 0x00000002, + .vtcm_bank_width = 0x00000080, + .reserved3 = 0x00000001, + .reserved4 = 0x00000000, + .reserved5 = 0x00000003, + .coproc2_cvt_mpy_size = 0x0000000a, + .consistency_domain = 0x000000e0, + .capacity_domain = 0x00000080, + .axi3_lowaddr = 0x00000000, + }, +};
hw/hexagon/machine_cfg_v68n_1024.h.inc new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 5/11 hw/hexagon: Add support for cfgbase
In reply to Brian CainFrom: Sid Manning <[email protected]>
--- hw/hexagon/hexagon_dsp.c | 10 ++++++++++ target/hexagon/cpu.c | 2 ++ 2 files changed, 12 insertions(+)
hw/hexagon/hexagon_dsp.c +10 -0
@@ -83,6 +83,12 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,MemoryRegion *address_space =get_system_memory (); +MemoryRegion *config_table_rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (config_table_rom,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (address_space, m_cfg->cfgbase, + config_table_rom); +MemoryRegion *sram =g_new (MemoryRegion,1 );memory_region_init_ram (sram,NULL ,"ddr.ram" , machine->ram_size, &error_fatal);
@@ -136,6 +142,10 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, } } + +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); }static void init_mc (MachineClass *mc)
target/hexagon/cpu.c +2 -0
@@ -405,6 +405,8 @@ void hexagon_cpu_soft_reset(CPUHexagonState *env) }#endif + +#define HEXAGON_CFG_ADDR_BASE (addr) (((addr) >> 16) & 0x0fffff)static void hexagon_cpu_reset_hold (Object *obj,ResetType type) {CPUState *cs =CPU (obj);
Signature · 1 line
2.34.1
PATCH v2 6/11 hw/hexagon: Modify "Standalone" symbols
In reply to Brian CainFrom: Brian Cain <[email protected]>
These symbols are used by Hexagon Standalone OS to indicate whether the program should halt and wait for interrupts at startup. For QEMU, we want these programs to just continue crt0 startup through to the user program's main().
--- hw/hexagon/hexagon_dsp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/hexagon/hexagon_dsp.c +15 -0
@@ -29,9 +29,17 @@#include "machine_cfg_v66g_1024.h.inc" +static hwaddr isdb_secure_flag; +static hwaddr isdb_trusted_flag;static void hex_symbol_callback (const char *st_name,int st_info,uint64_t st_value,uint64_t st_size) { +if (!g_strcmp0 ("isdb_secure_flag" , st_name)) { + isdb_secure_flag = st_value; + } +if (!g_strcmp0 ("isdb_trusted_flag" , st_name)) { + isdb_trusted_flag = st_value; + } }/* Board init. */
@@ -60,6 +68,13 @@ static void hexagon_init_bootstrap(MachineState *machine, HexagonCPU *cpu) {if (machine->kernel_filename) {hexagon_load_kernel (cpu); +uint32_t mem =1 ; +if (isdb_secure_flag) { +cpu_physical_memory_write (isdb_secure_flag, &mem,sizeof (mem)); + } +if (isdb_trusted_flag) { +cpu_physical_memory_write (isdb_trusted_flag, &mem,sizeof (mem)); + } } }
Signature · 1 line
2.34.1
PATCH v2 7/11 target/hexagon: add build config for softmmu
In reply to Brian Cain--- MAINTAINERS | 1 + configs/devices/hexagon-softmmu/default.mak | 7 +++++++ configs/targets/hexagon-softmmu.mak | 6 ++++++ target/hexagon/cpu.h | 4 ---- target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 12 +++++++++++- 7 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 target/hexagon/Kconfig
MAINTAINERS +1 -0
@@ -237,6 +237,7 @@ F: linux-user/hexagon/ F: tests/tcg/hexagon/ F: disas/hexagon.c F: configs/targets/hexagon-linux-user/default.mak +F: configs/devices/hexagon-softmmu/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst
configs/devices/hexagon-softmmu/default.mak new file +7 -0
@@ -0,0 +1,7 @@ +# Default configuration for hexagon-softmmu + +# Uncomment the following lines to disable these optional devices: + +# Boards are selected by default, uncomment to keep out of the build. +# CONFIG_HEX_DSP=y +# CONFIG_L2VIC=y
configs/targets/hexagon-softmmu.mak new file +6 -0
@@ -0,0 +1,6 @@ +# Default configuration for hexagon-softmmu + +TARGET_ARCH=hexagon +TARGET_SUPPORTS_MTTCG=y +TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml +TARGET_LONG_BITS=32
target/hexagon/cpu.h +0 -4
@@ -33,10 +33,6 @@#include "mmvec/mmvec.h" #include "hw/registerfields.h" -#ifndef CONFIG_USER_ONLY -#error "Hexagon does not support system emulation" -#endif -#ifndef CONFIG_USER_ONLY #include "reg_fields.h" typedef struct CPUHexagonTLBContext CPUHexagonTLBContext ;
target/Kconfig +1 -0
@@ -16,6 +16,7 @@ source sh4/Kconfig source sparc/Kconfig source tricore/Kconfig source xtensa/Kconfig +source hexagon/Kconfig config TARGET_BIG_ENDIAN bool
target/hexagon/Kconfig new file +2 -0
@@ -0,0 +1,2 @@ +config HEXAGON + bool
target/hexagon/meson.build +11 -1
@@ -245,6 +245,7 @@ decodetree_trans_funcs_generated = custom_target( command: [python, files('gen_trans_funcs.py'), semantics_generated, '@OUTPUT@'], ) hexagon_ss.add(decodetree_trans_funcs_generated) +hexagon_softmmu_ss = ss.source_set() hexagon_ss.add(files( 'cpu.c',
@@ -264,6 +265,13 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', )) +hexagon_softmmu_ss.add(files( + 'hex_mmu.c', + 'hex_interrupts.c', + 'hexswi.c', + 'machine.c', +)) + # # Step 4.5 # We use flex/bison based idef-parser to generate TCG code for a lot
@@ -273,7 +281,8 @@ hexagon_ss.add(files( # idef-generated-enabled-instructions # idef_parser_enabled = get_option('hexagon_idef_parser') -if idef_parser_enabled and 'hexagon-linux-user' in target_dirs +if idef_parser_enabled and ('hexagon-linux-user' in target_dirs or + 'hexagon-softmmu' in target_dirs) idef_parser_input_generated = custom_target( 'idef_parser_input.h.inc', output: 'idef_parser_input.h.inc',
@@ -400,3 +409,4 @@ analyze_funcs_generated = custom_target( hexagon_ss.add(analyze_funcs_generated) target_arch += {'hexagon': hexagon_ss} +target_system_arch += {'hexagon': hexagon_softmmu_ss}
Signature · 1 line
2.34.1
PATCH v2 8/11 hw/hexagon: Define hexagon "virt" machine
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- configs/devices/hexagon-softmmu/default.mak | 1 + configs/targets/hexagon-softmmu.mak | 1 + include/hw/hexagon/virt.h | 43 ++ hw/hexagon/virt.c | 435 ++++++++++++++++++++ hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 2 + tests/qemu-iotests/testenv.py | 1 + 7 files changed, 493 insertions(+) create mode 100644 include/hw/hexagon/virt.h create mode 100644 hw/hexagon/virt.c
configs/devices/hexagon-softmmu/default.mak +1 -0
@@ -3,5 +3,6 @@ # Uncomment the following lines to disable these optional devices: # Boards are selected by default, uncomment to keep out of the build. +# CONFIG_HEX_VIRT=y # CONFIG_HEX_DSP=y # CONFIG_L2VIC=y
configs/targets/hexagon-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ TARGET_ARCH=hexagon TARGET_SUPPORTS_MTTCG=y TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml TARGET_LONG_BITS=32 +TARGET_NEED_FDT=y
include/hw/hexagon/virt.h new file +43 -0
43 lines not on this page · raw message
hw/hexagon/virt.c new file +435 -0
435 lines not on this page · raw message
hw/hexagon/Kconfig +10 -0
@@ -3,3 +3,13 @@ config HEX_DSP default y depends on HEXAGON && TCG imply PTIMER + +config HEX_VIRT + bool + default y + depends on HEX_DSP && FDT + select DEVICE_TREE + select VIRTIO_MMIO + select PL011 + select VIRTIO_BLK + select VIRTIO_SCSI
hw/hexagon/meson.build +2 -0
@@ -3,3 +3,5 @@ hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c', 'hexagon_ hw_arch += {'hexagon': hexagon_ss} +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c', 'hexagon_globalreg.c')) +
tests/qemu-iotests/testenv.py +1 -0
@@ -239,6 +239,7 @@ def __init__(self, source_dir: str, build_dir: str, ('arm', 'virt'), ('aarch64', 'virt'), ('avr', 'mega2560'), + ('hexagon', 'virt'), ('m68k', 'virt'), ('or1k', 'virt'), ('riscv32', 'virt'),
Signature · 1 line
2.34.1
PATCH v2 9/11 tests/qtest: Add hexagon boot-serial-test
In reply to Brian CainAdd boot-serial-test support for Hexagon architecture using the virt machine.
--- tests/qtest/boot-serial-test.c | 8 ++++++++ tests/qtest/meson.build | 2 ++ 2 files changed, 10 insertions(+)
tests/qtest/boot-serial-test.c +8 -0
@@ -142,6 +142,13 @@ static const uint8_t kernel_stm32vldiscovery[] = {0x04 ,0x38 ,0x01 ,0x40 /* 0x40013804 = USART1 TXD */ }; +static const uint8_t bios_hexagon[] = { +0x00 ,0x40 ,0x00 ,0x01 ,/* immext(#0x10000000) */ +0x00 ,0xc0 ,0x00 ,0x78 ,/* r0 = ##0x10000000 */ +0x54 ,0xc0 ,0x00 ,0x3c ,/* memb(r0+#0) = #0x54 Write 'T' */ +0xf8 ,0xff ,0xff ,0x59 /* jump 0x0 ; Loop back to start */ +}; + typedef struct testdef { const char *arch; /* Target architecture */ const char *machine; /* Name of the machine */
@@ -194,6 +201,7 @@ static const testdef_t tests[] = { { "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 }, { "arm", "stm32vldiscovery", "", "T", sizeof(kernel_stm32vldiscovery), kernel_stm32vldiscovery }, + { "hexagon", "virt", "", "TT", sizeof(bios_hexagon), NULL, bios_hexagon }, { NULL } };
tests/qtest/meson.build +2 -0
@@ -284,6 +284,8 @@ qtests_riscv32 = \ qtests_riscv64 = ['riscv-csr-test'] + \ (unpack_edk2_blobs ? ['bios-tables-test'] : []) +qtests_hexagon = ['boot-serial-test'] + qos_test_ss = ss.source_set() qos_test_ss.add( 'ac97-test.c',
Signature · 1 line
2.34.1
PATCH v2 10/11 hw/timer: Add QTimer device
In reply to Brian CainFrom: Sid Manning <[email protected]>
Note: QTimer was implemented before ARM SSE Timer was upstreamed, there may be opportunity to use that device instead.
--- MAINTAINERS | 2 + include/hw/timer/qct-qtimer.h | 85 ++++++ hw/hexagon/hexagon_dsp.c | 7 +- hw/hexagon/hexagon_globalreg.c | 9 +- hw/hexagon/virt.c | 22 ++ hw/timer/qct-qtimer.c | 520 +++++++++++++++++++++++++++++++++ hw/timer/meson.build | 2 + 7 files changed, 642 insertions(+), 5 deletions(-) create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/timer/qct-qtimer.c
MAINTAINERS +2 -0
@@ -230,7 +230,9 @@ M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ F: hw/hexagon/ +F: hw/timer/qct-qtimer.c F: include/hw/hexagon/ +F: include/hw/timer/qct-qtimer.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
include/hw/timer/qct-qtimer.h new file +85 -0
85 lines not on this page · raw message
hw/hexagon/hexagon_dsp.c +5 -2
@@ -3,7 +3,6 @@* subsystem with few peripherals, like the Compute DSP. * * Copyright (c) 2020-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. -* * SPDX-License-Identifier: GPL-2.0-or-later */
@@ -126,7 +125,11 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,*/ qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 ));qdev_prop_set_uint32 (DEVICE (cpu),"l2vic-base-addr" , m_cfg->l2vic_base); -qdev_prop_set_uint32 (DEVICE (cpu),"config-table-addr" , m_cfg->cfgbase); +if (!object_property_set_link (OBJECT (cpu),"global-regs" , +OBJECT (glob_regs_dev), errp)) { +error_report ("Failed to link global system registers to CPU %d" , i); +return ; + }qdev_prop_set_uint32 (DEVICE (cpu),"hvx-contexts" , m_cfg->cfgtable.ext_contexts); qdev_prop_set_uint32(DEVICE(cpu), "jtlb-entries",
hw/hexagon/hexagon_globalreg.c +6 -3
@@ -14,6 +14,7 @@#include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h" +#include "hw/timer/qct-qtimer.h" #include "target/hexagon/hex_regs.h" #include "qemu/log.h" #include "trace/trace-hw_hexagon.h"
@@ -137,9 +138,11 @@ static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,static void read_timer (HexagonGlobalRegState *s,uint32_t *low,uint32_t *high) { -/* Not yet implemented */ - *low =0 ; - *high =0 ; +const hwaddr low_addr = s->qtimer_base_addr +QCT_QTIMER_CNTPCT_LO ; +const hwaddr high_addr = s->qtimer_base_addr +QCT_QTIMER_CNTPCT_HI ; + +cpu_physical_memory_read (low_addr, low,sizeof (*low)); +cpu_physical_memory_read (high_addr, high,sizeof (*high)); }uint32_t hexagon_globalreg_read (HexagonCPU *cpu,uint32_t reg)
hw/hexagon/virt.c +22 -0
@@ -17,6 +17,8 @@#include "hw/qdev-properties.h" #include "hw/qdev-clock.h" #include "hw/register.h" +#include "hw/timer/qct-qtimer.h" +#include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/guest-random.h" #include "qemu/units.h"
@@ -256,6 +258,25 @@ static void fdt_add_virtio_devices(const HexagonVirtMachineState *vms) } } +static void create_qtimer (HexagonVirtMachineState *vms, +const hexagon_machine_config *m_cfg) +{ +Error **errp =NULL ; +QCTQtimerState *qtimer =QCT_QTIMER (qdev_new (TYPE_QCT_QTIMER )); + +object_property_set_uint (OBJECT (qtimer),"nr_frames" ,2 , errp); +object_property_set_uint (OBJECT (qtimer),"nr_views" ,1 , errp); +object_property_set_uint (OBJECT (qtimer),"cnttid" ,0x111 , errp); +sysbus_realize_and_unref (SYS_BUS_DEVICE (qtimer), errp); + + +sysbus_mmio_map (SYS_BUS_DEVICE (qtimer),1 , m_cfg->qtmr_region); +sysbus_connect_irq (SYS_BUS_DEVICE (qtimer),0 , +qdev_get_gpio_in (vms->l2vic, irqmap[VIRT_QTMR0 ])); +sysbus_connect_irq (SYS_BUS_DEVICE (qtimer),1 , +qdev_get_gpio_in (vms->l2vic, irqmap[VIRT_QTMR1 ])); +} +static void virt_instance_init (Object *obj) {HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (obj);
@@ -395,6 +416,7 @@ static void virt_init(MachineState *ms)fdt_add_clocks (vms);fdt_add_uart (vms,VIRT_UART0 );fdt_add_gpt_node (vms); +create_qtimer (vms, m_cfg); rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, sizeof(m_cfg->cfgtable), m_cfg->cfgbase,
hw/timer/qct-qtimer.c new file +520 -0
520 lines not on this page · raw message
hw/timer/meson.build +2 -0
@@ -34,3 +34,5 @@ specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_timer.c')) system_ss.add(when: 'CONFIG_SIFIVE_PWM', if_true: files('sifive_pwm.c')) specific_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c')) + +specific_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('qct-qtimer.c'))
Signature · 1 line
2.34.1
PATCH v2 11/11 hw/intc: Add l2vic interrupt controller
In reply to Brian CainFrom: Sid Manning <[email protected]>
--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 38 +++ hw/intc/l2vic.c | 421 +++++++++++++++++++++++++++++++++ hw/hexagon/Kconfig | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 9 files changed, 531 insertions(+) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/intc/l2vic.h create mode 100644 hw/intc/l2vic.c
MAINTAINERS +2 -0
@@ -233,6 +233,7 @@ F: hw/hexagon/ F: hw/timer/qct-qtimer.c F: include/hw/hexagon/ F: include/hw/timer/qct-qtimer.h +F: hw/intc/l2vic.[ch] X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
@@ -245,6 +246,7 @@ F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/system/hexagon/cdsp.rst F: docs/devel/hexagon-sys.rst +F: docs/devel/hexagon-l2vic.rst T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parser
docs/devel/hexagon-l2vic.rst new file +59 -0
59 lines not on this page · raw message
docs/devel/index-internals.rst +1 -0
@@ -15,6 +15,7 @@ Details about QEMU's various subsystems including how to add features to them. clocks ebpf_rss hexagon-sys + hexagon-l2vic migration/index multi-process reset
include/hw/intc/l2vic.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#define L2VIC_VID_GRP_0 0x0/* Read */ +#define L2VIC_VID_GRP_1 0x4/* Read */ +#define L2VIC_VID_GRP_2 0x8/* Read */ +#define L2VIC_VID_GRP_3 0xC/* Read */ +#define L2VIC_VID_0 0x10/* Read SOFTWARE DEFINED */ +#define L2VIC_VID_1 0x14/* Read SOFTWARE DEFINED NOT YET USED */ +#define L2VIC_INT_ENABLEn 0x100/* Read/Write */ +#define L2VIC_INT_ENABLE_CLEARn 0x180/* Write */ +#define L2VIC_INT_ENABLE_SETn 0x200/* Write */ +#define L2VIC_INT_TYPEn 0x280/* Read/Write */ +#define L2VIC_INT_STATUSn 0x380/* Read */ +#define L2VIC_INT_CLEARn 0x400/* Write */ +#define L2VIC_SOFT_INTn 0x480/* Write */ +#define L2VIC_INT_PENDINGn 0x500/* Read */ +#define L2VIC_INT_GRPn_0 0x600/* Read/Write */ +#define L2VIC_INT_GRPn_1 0x680/* Read/Write */ +#define L2VIC_INT_GRPn_2 0x700/* Read/Write */ +#define L2VIC_INT_GRPn_3 0x780/* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +#define L2VIC_CIAD_INSTRUCTION -1 +#define L2VIC_NO_PENDING 0xffffffff +/* +* Note about l2vic groups: +* Each interrupt to L2VIC can be configured to associate with one of +* four groups. +* Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) +* Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) +* Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) +* Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) +*/
hw/intc/l2vic.c new file +421 -0
421 lines not on this page · raw message
hw/hexagon/Kconfig +1 -0
@@ -3,6 +3,7 @@ config HEX_DSP default y depends on HEXAGON && TCG imply PTIMER + select L2VIC config HEX_VIRT bool
hw/intc/Kconfig +3 -0
@@ -8,6 +8,9 @@ config I8259 config PL190 bool +config L2VIC + bool + config IOAPIC bool select I8259
hw/intc/meson.build +2 -0
@@ -67,6 +67,8 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) + +specific_ss.add(when: 'CONFIG_L2VIC', if_true: files('l2vic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
hw/intc/trace-events +4 -0
@@ -314,6 +314,10 @@ sh_intc_register(const char *s, int id, unsigned short v, int c, int m) "%s %u - sh_intc_read(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " -> 0x%lx" sh_intc_write(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " <- 0x%lx" sh_intc_set(int id, int enable) "setting interrupt group %d to %d" +# l2vic.c +l2vic_reg_write(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +l2vic_reg_read(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +l2vic_delivered(int irq, int vid) "l2vic: delivered %d (vid %d)" # loongson_ipi.c loongson_ipi_read(unsigned size, uint64_t addr, uint64_t val) "size: %u addr: 0x%"PRIx64 "val: 0x%"PRIx64
Signature · 1 line
2.34.1
Hi,
Quoted 22 lines · Brian Cain
As with parts 1, 2 - some of the changes requested have been made, but not all.
New features for part 3:
- global registers device model
- boot-serial-test qtest caseIssues not addressed with v2:
* "Add l2vic interrupt controller" -DECLARE_SIMPLE_TYPE, bitops
- I might also push this and/or QTimer out of this series to simplify things a bit.Brian Cain (8):
hw/hexagon: Add globalreg model
hw/hexagon: Add global register tracing
hw/hexagon: Add machine configs for sysemu
hw/hexagon: Add v68, sa8775-cdsp0 defs
hw/hexagon: Modify "Standalone" symbols
target/hexagon: add build config for softmmu
hw/hexagon: Define hexagon "virt" machine
tests/qtest: Add hexagon boot-serial-test
Quoted 4 lines
Sid Manning (3):
hw/hexagon: Add support for cfgbase
hw/timer: Add QTimer device
hw/intc: Add l2vic interrupt controller
FYI I have tagged this series to review, but I might not have time the following 3 weeks.
In doubt, please ping during last week of September to remind me ;)