Hexagon system emulation - Part 3/3
v4 cover Hexagon system emulation - Part 3/3
This is Part 3 of the Hexagon system emulation series. It adds the board-level support, machine definitions, and build infrastructure needed to run hexagon-softmmu.
This includes:
- Global register model (QOM device for shared system registers)
- Global register tracing
- Machine configuration definitions (v66g, v68n, sa8775-cdsp0)
- cfgbase support
- Hexagon "virt" machine definition
- Build configuration for hexagon-softmmu target
- Boot serial test for hexagon
Based on Part 1 v6 + Part 2 v4.
Changes since v3:
- Rebased onto Part 1 v6 / Part 2 v4
- Created hw/hexagon/trace.h wrapper (Philippe)
- Converted TARGET_SUPPORTS_MTTCG=y to TCGCPUOps::mttcg_supported = true (Philippe)
- Added TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y and TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y to hexagon-softmmu.mak (Philippe)
- Added const qualifier to machine config structs (Philippe)
- Fixed mid-block variable declarations (C89 style)
- Moved DEFINE_PROP_LINK("tlb") to virt machine commit
Previous versions:
- v3: https://lore.kernel.org/qemu-devel/[email protected]/
- v2: https://lore.kernel.org/qemu-devel/[email protected]/
- v1: https://lore.kernel.org/qemu-devel/[email protected]/
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 (1):
hw/hexagon: Add support for cfgbase
MAINTAINERS | 3 + configs/devices/hexagon-softmmu/default.mak | 8 + configs/targets/hexagon-softmmu.mak | 8 + meson.build | 1 + hw/hexagon/trace.h | 2 + include/hw/hexagon/hexagon.h | 150 +++++++ include/hw/hexagon/hexagon_globalreg.h | 56 +++ include/hw/hexagon/virt.h | 43 ++ target/hexagon/cpu.h | 7 +- hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 64 +++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 +++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 65 +++ hw/hexagon/hexagon_dsp.c | 188 ++++++++ hw/hexagon/hexagon_globalreg.c | 318 ++++++++++++++ hw/hexagon/virt.c | 456 ++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/cpu.c | 6 +- target/hexagon/translate.c | 1 + tests/qtest/boot-serial-test.c | 8 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 15 + hw/hexagon/meson.build | 8 + hw/hexagon/trace-events | 3 + hw/meson.build | 1 + target/Kconfig | 1 + target/hexagon/Kconfig | 2 + target/hexagon/meson.build | 13 +- tests/qemu-iotests/testenv.py | 1 + tests/qtest/meson.build | 2 + 29 files changed, 1486 insertions(+), 11 deletions(-) create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 hw/hexagon/trace.h 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 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/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 v4 1/9 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 | 56 ++++++ hw/hexagon/hexagon_globalreg.c | 245 +++++++++++++++++++++++++ 2 files changed, 301 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 +56 -0
@@ -0,0 +1,56 @@ +/* +* Hexagon Global Registers QOM Object +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GLOBALREG_H +#define HEXAGON_GLOBALREG_H + +#include "hw/core/qdev.h" +#include "hw/core/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 */ +uint32_t 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 */ +}; + +/* Public interface functions */ +uint32_t hexagon_globalreg_read (HexagonGlobalRegState *s,uint32_t reg, +uint32_t htid); +void hexagon_globalreg_write (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value,uint32_t htid); +uint32_t hexagon_globalreg_masked_value (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value); +void hexagon_globalreg_write_masked (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value); +void hexagon_globalreg_reset (HexagonGlobalRegState *s); + +/* Global performance cycle counter access */ +uint64_t hexagon_globalreg_get_pcycle_base (HexagonGlobalRegState *s); +void hexagon_globalreg_set_pcycle_base (HexagonGlobalRegState *s, +uint64_t value); + +#endif /* HEXAGON_GLOBALREG_H */
hw/hexagon/hexagon_globalreg.c new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v4 1/9] hw/hexagon: Add globalreg model
Quoted 254 lines · Brian Cain
Some of the system registers are shared among all threads in the core. This object contains the representation and interface to the system registers.
Signed-off-by Brian Cain <[email protected]>--- include/hw/hexagon/hexagon_globalreg.h | 56 ++++++ hw/hexagon/hexagon_globalreg.c | 245 +++++++++++++++++++++++++ 2 files changed, 301 insertions(+) create mode 100644 include/hw/hexagon/hexagon_globalreg.h create mode 100644 hw/hexagon/hexagon_globalreg.cinclude/hw/hexagon/hexagon_globalreg.h new file +29
-0@@ -0,0 +1,56 @@ +/* +* Hexagon Global Registers QOM Object +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GLOBALREG_H +#define HEXAGON_GLOBALREG_H + +#include "hw/core/qdev.h" +#include "hw/core/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 */ + uint32_t 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) */include/hw/hexagon/hexagon_globalreg.h new file +16
-0+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 */ +}; + +/* Public interface functions */ +uint32_t hexagon_globalreg_read (HexagonGlobalRegState *s,uint32_t reg, +uint32_t htid); +void hexagon_globalreg_write (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value,uint32_t htid); +uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s,
uint32_treg,include/hw/hexagon/hexagon_globalreg.h new file +2
-0+ uint32_t value); +void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_treg,
include/hw/hexagon/hexagon_globalreg.h new file +9
-0+ uint32_t value); +void hexagon_globalreg_reset (HexagonGlobalRegState *s); + +/* Global performance cycle counter access */ +uint64_t hexagon_globalreg_get_pcycle_base (HexagonGlobalRegState *s); +void hexagon_globalreg_set_pcycle_base (HexagonGlobalRegState *s, +uint64_t value); + +#endif /* HEXAGON_GLOBALREG_H */ hw/hexagon/hexagon_globalreg.c new file +58
-0@@ -0,0 +1,245 @@ +/* +* Hexagon Global Registers +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/sysbus.h" +#include "hw/core/resettable.h" +#include "migration/vmstate.h" +#include "qom/object.h" +#include "target/hexagon/cpu.h" +#include "target/hexagon/hex_regs.h" +#include "qemu/log.h" +#include "qapi/error.h" + +#define IMMUTABLE (~0) +#define INVALID_REG_VAL 0xdeadbeef + +/* Global system register mutability masks */ +static const uint32_t global_sreg_immut_masks[NUM_SREGS ] = { + [HEX_SREG_EVB ] =0x000000ff , + [HEX_SREG_MODECTL ] =IMMUTABLE , + [HEX_SREG_SYSCFG ] =0x80001c00 , + [HEX_SREG_IPENDAD ] =IMMUTABLE , + [HEX_SREG_VID ] =0xfc00fc00 , + [HEX_SREG_VID1 ] =0xfc00fc00 , + [HEX_SREG_BESTWAIT ] =0xfffffe00 , + [HEX_SREG_IAHL ] =0x00000000 , + [HEX_SREG_SCHEDCFG ] =0xfffffee0 , + [HEX_SREG_CFGBASE ] =IMMUTABLE , + [HEX_SREG_DIAG ] =0x00000000 , + [HEX_SREG_REV ] =IMMUTABLE , + [HEX_SREG_ISDBST ] =IMMUTABLE , + [HEX_SREG_ISDBCFG0 ] =0xe0000000 , + [HEX_SREG_BRKPTPC0 ] =0x00000003 , + [HEX_SREG_BRKPTCFG0 ] =0xfc007000 , + [HEX_SREG_BRKPTPC1 ] =0x00000003 , + [HEX_SREG_BRKPTCFG1 ] =0xfc007000 , + [HEX_SREG_ISDBMBXIN ] =IMMUTABLE , + [HEX_SREG_ISDBMBXOUT ] =0x00000000 , + [HEX_SREG_ISDBEN ] =0xfffffffe , + [HEX_SREG_TIMERLO ] =IMMUTABLE , + [HEX_SREG_TIMERHI ] =IMMUTABLE , +}; + +static void hexagon_globalreg_init (Object *obj) +{ +HexagonGlobalRegState *s =HEXAGON_GLOBALREG (obj); + +memset (s->regs,0 ,sizeof (uint32_t ) *NUM_SREGS ); +} + +static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t
cur_val,hw/hexagon/hexagon_globalreg.c new file +32
-0+ uint32_t reg_mask) +{ +if (reg_mask) { +return (new_val & ~reg_mask) | (cur_val & reg_mask); + } +return new_val; +} + +uint32_t hexagon_globalreg_read (HexagonGlobalRegState *s,uint32_t reg, +uint32_t htid) +{ +uint32_t value; + +g_assert (reg <NUM_SREGS ); +g_assert (reg >=HEX_SREG_GLB_START ); +g_assert (s); + + value = s->regs[reg]; + +return value; +} + +void hexagon_globalreg_write (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value,uint32_t htid) +{ +g_assert (s); +g_assert (reg <NUM_SREGS ); +g_assert (reg >=HEX_SREG_GLB_START ); + s->regs[reg] = value; +} + +uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s,
uint32_treg,hw/hexagon/hexagon_globalreg.c new file +14
-0+ uint32_t value) +{ +uint32_t reg_mask; + +g_assert (s); +g_assert (reg <NUM_SREGS ); +g_assert (reg >=HEX_SREG_GLB_START ); + reg_mask = global_sreg_immut_masks[reg]; +return reg_mask ==IMMUTABLE ? + s->regs[reg] : +apply_write_mask (value, s->regs[reg], reg_mask); +} + +void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_treg,
hw/hexagon/hexagon_globalreg.c new file +30
-0+ uint32_t value) +{ +g_assert (s); + s->regs[reg] =hexagon_globalreg_masked_value (s, reg, value); +} + +uint64_t hexagon_globalreg_get_pcycle_base (HexagonGlobalRegState *s) +{ +g_assert (s); +return s->g_pcycle_base; +} + +void hexagon_globalreg_set_pcycle_base (HexagonGlobalRegState *s, +uint64_t value) +{ +g_assert (s); + s->g_pcycle_base = value; +} + +static void do_hexagon_globalreg_reset (HexagonGlobalRegState *s) +{ +uint32_t isdben_val =0 ; + +g_assert (s); +memset (s->regs,0 ,sizeof (uint32_t ) *NUM_SREGS ); + + s->g_pcycle_base =0 ; + + s->regs[HEX_SREG_EVB ] = s->boot_evb; + s->regs[HEX_SREG_CFGBASE] =
HEXAGON_CFG_ADDR_BASE(s->config_table_addr);hw/hexagon/hexagon_globalreg.c new file +30
-0+ s->regs[HEX_SREG_REV ] = s->dsp_rev; + +if (s->isdben_etm_enable) { + isdben_val |= (1 <<0 );/* ETM enable bit */ + } +if (s->isdben_dfd_enable) { + isdben_val |= (1 <<1 );/* DFD enable bit */ + } +if (s->isdben_trusted) { + isdben_val |= (1 <<2 );/* Trusted bit */ + } +if (s->isdben_secure) { + isdben_val |= (1 <<3 );/* Secure bit */ + } + s->regs[HEX_SREG_ISDBEN ] = isdben_val; + s->regs[HEX_SREG_MODECTL ] =0x1 ; + +/* +* These register indices are placeholders in these arrays +* and their actual values are synthesized from state elsewhere. +* We can initialize these with invalid values so that if we +* mistakenly generate reads, they will look obviously wrong. +*/ + s->regs[HEX_SREG_PCYCLELO ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PCYCLEHI ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_TIMERLO ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_TIMERHI ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT0 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT1 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT2 ] =INVALID_REG_VAL ;
hw/hexagon/hexagon_globalreg.c line 174
Quoted 10 lines
hw/hexagon/hexagon_globalreg.c new file +10
-0+ s->regs[HEX_SREG_PMUCNT3 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT4 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT5 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT6 ] =INVALID_REG_VAL ; + s->regs[HEX_SREG_PMUCNT7 ] =INVALID_REG_VAL ; +} + +static void hexagon_globalreg_realize (DeviceState *dev,Error **errp) +{ +}
This could be removed and the reference to it below in dc->realize. Otherwise LGTM.
Reviewed by: [email protected]
Quoted 76 lines
hw/hexagon/hexagon_globalreg.c new file +46
-0+ +void hexagon_globalreg_reset (HexagonGlobalRegState *s) +{ +do_hexagon_globalreg_reset (s); +} + +static void hexagon_globalreg_reset_hold (Object *obj,ResetType type) +{ +HexagonGlobalRegState *s =HEXAGON_GLOBALREG (obj); +do_hexagon_globalreg_reset (s); +} + +static const VMStateDescription vmstate_hexagon_globalreg = { + .name ="hexagon_globalreg" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []){ +VMSTATE_UINT32_ARRAY (regs, HexagonGlobalRegState,NUM_SREGS ), +VMSTATE_UINT64 (g_pcycle_base, HexagonGlobalRegState), +VMSTATE_UINT32 (boot_evb, HexagonGlobalRegState), +VMSTATE_UINT64 (config_table_addr, HexagonGlobalRegState), +VMSTATE_UINT32 (dsp_rev, HexagonGlobalRegState), +VMSTATE_BOOL (isdben_etm_enable, HexagonGlobalRegState), +VMSTATE_BOOL (isdben_dfd_enable, HexagonGlobalRegState), +VMSTATE_BOOL (isdben_trusted, HexagonGlobalRegState), +VMSTATE_BOOL (isdben_secure, HexagonGlobalRegState), +VMSTATE_END_OF_LIST () + } +}; + +static const Property hexagon_globalreg_properties[] = { +DEFINE_PROP_UINT32 ("boot-evb" , HexagonGlobalRegState, boot_evb,0x0 ), +DEFINE_PROP_UINT64 ("config-table-addr" , HexagonGlobalRegState, + config_table_addr,0xffffffffULL ), +DEFINE_PROP_UINT32 ("dsp-rev" , HexagonGlobalRegState, dsp_rev,0 ), +DEFINE_PROP_BOOL ("isdben-etm-enable" , HexagonGlobalRegState, + isdben_etm_enable, false), +DEFINE_PROP_BOOL ("isdben-dfd-enable" , HexagonGlobalRegState, + isdben_dfd_enable, false), +DEFINE_PROP_BOOL ("isdben-trusted" , HexagonGlobalRegState, + isdben_trusted, false), +DEFINE_PROP_BOOL ("isdben-secure" , HexagonGlobalRegState, + isdben_secure, false), +}; + +static void hexagon_globalreg_class_init(ObjectClass *klass, const void*data)
hw/hexagon/hexagon_globalreg.c new file +25
-1+{ +DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + + dc->realize = hexagon_globalreg_realize; + rc->phases.hold = hexagon_globalreg_reset_hold; + dc->vmsd = &vmstate_hexagon_globalreg; + dc->user_creatable = false; +device_class_set_props (dc, hexagon_globalreg_properties); +} + +static const TypeInfo hexagon_globalreg_info = { + .name =TYPE_HEXAGON_GLOBALREG , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (HexagonGlobalRegState), + .instance_init = hexagon_globalreg_init, + .class_init = hexagon_globalreg_class_init, +}; + +static void hexagon_globalreg_register_types (void ) +{ +type_register_static (&hexagon_globalreg_info); +} + +type_init (hexagon_globalreg_register_types) --2.34.1
PATCH v4 2/9 hw/hexagon: Add global register tracing
In reply to Brian Cain--- meson.build | 1 + hw/hexagon/trace.h | 2 + hw/hexagon/hexagon_globalreg.c | 73 ++++++++++++++++++++++++++++++++++ hw/hexagon/trace-events | 3 ++ 4 files changed, 79 insertions(+) create mode 100644 hw/hexagon/trace.h create mode 100644 hw/hexagon/trace-events
meson.build +1 -0
@@ -3625,6 +3625,7 @@ if have_system 'hw/display', 'hw/dma', 'hw/fsi', + 'hw/hexagon', 'hw/hyperv', 'hw/i2c', 'hw/i3c',
hw/hexagon/trace.h new file +2 -0
@@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "trace/trace-hw_hexagon.h"
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(uint32_t htid, const char *reg_name, uint32_t value) "htid=%u reg=%s value=0x%x" +hexagon_globalreg_write(uint32_t htid, const char *reg_name, uint32_t value) "htid=%u reg=%s value=0x%x"
Signature · 1 line
2.34.1
PATCH v4 3/9 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 + include/hw/hexagon/hexagon.h | 150 +++++++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 ++++++++++ hw/hexagon/hexagon_dsp.c | 161 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 5 + hw/hexagon/meson.build | 6 + hw/meson.build | 1 + 10 files changed, 392 insertions(+), 1 deletion(-) 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
@@ -246,6 +246,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/
include/hw/hexagon/hexagon.h new file +150 -0
150 lines not on this page · raw message
hw/hexagon/machine_cfg_v66g_1024.h.inc new file +64 -0
64 lines not on this page · raw message
hw/hexagon/hexagon_dsp.c new file +161 -0
161 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/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
@@ -54,6 +54,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 +6 -0
@@ -0,0 +1,6 @@ +hexagon_ss = ss.source_set() +hexagon_ss.add(files('hexagon_tlb.c')) +hexagon_ss.add(files('hexagon_globalreg.c')) +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) + +hw_arch += {'hexagon': hexagon_ss}
hw/meson.build +1 -0
@@ -3,6 +3,7 @@ subdir('alpha') subdir('arm') subdir('avr') subdir('hppa') +subdir('hexagon') subdir('xenpv') # i386 uses it subdir('i386') subdir('loongarch')
Signature · 1 line
2.34.1
Re: [PATCH v4 3/9] hw/hexagon: Add machine configs for sysemu
Hi Brian,
Quoted 33 lines · Brian Cain
From: 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.
Co-authored-by Mike Lambert <[email protected]>Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + include/hw/hexagon/hexagon.h | 150 +++++++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 ++++++++++ hw/hexagon/hexagon_dsp.c | 161 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 5 + hw/hexagon/meson.build | 6 + hw/meson.build | 1 + 10 files changed, 392 insertions(+), 1 deletion(-)create mode 100644
include/hw/hexagon/hexagon.hcreate mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644hw/hexagon/hexagon_dsp.ccreate mode 100644 hw/hexagon/Kconfig
create mode 100644 hw/hexagon/meson.buildtarget/hexagon/translate.c +0
-0
target/hexagon/translate.c line 35
Quoted 4 lines
target/hexagon/translate.c +1
-0@@ -32,6 +32,7 @@#include "translate.h" #include "genptr.h" #include "printinsn.h" +#include "exec/target_page.h"
Why? Rebase left-over?
Quoted 10 lines
target/hexagon/translate.c +0
-0#define HELPER_H "helper.h"#include "exec/helper-info.c.inc" hw/hexagon/Kconfig new file +0
-0
hw/hexagon/Kconfig line 4
Quoted 4 lines
hw/hexagon/Kconfig new file +4
-0@@ -0,0 +1,5 @@ +config HEX_DSP + bool + default y + depends on HEXAGON && TCG
No need to check for TCG.
hw/hexagon/Kconfig line 5
Quoted 1 line
hw/hexagon/Kconfig new file +1
-0+ imply PTIMER
Usually you want "select" here, not "imply", but
I don't see any PTIMER code being used.
Re: [PATCH v4 3/9] hw/hexagon: Add machine configs for sysemu
Quoted 32 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 26 lines · Brian Cain
From: 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.
Co-authored-by Mike Lambert <[email protected]>Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + include/hw/hexagon/hexagon.h | 150 +++++++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 ++++++++++ hw/hexagon/hexagon_dsp.c | 161 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 5 + hw/hexagon/meson.build | 6 + hw/meson.build | 1 + 10 files changed, 392 insertions(+), 1 deletion(-)create mode 100644
include/hw/hexagon/hexagon.hcreate mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644hw/hexagon/hexagon_dsp.ccreate mode 100644 hw/hexagon/Kconfig
create mode 100644 hw/hexagon/meson.build
Quoted 11 lines
target/hexagon/translate.c line 35
Quoted 9 lines
target/hexagon/translate.c +1
-0@@ -32,6 +32,7 @@#include "translate.h" #include "genptr.h" #include "printinsn.h" +#include "exec/target_page.h" Why? Rebase left-over?
Will be removed.
Quoted 18 lines
Quoted 11 lines
target/hexagon/translate.c +0
-0#define HELPER_H "helper.h"#include "exec/helper-info.c.inc" hw/hexagon/Kconfig new file +0
-0hw/hexagon/Kconfig line 4
Quoted 4 lines
hw/hexagon/Kconfig new file +4
-0@@ -0,0 +1,5 @@ +config HEX_DSP + bool + default y + depends on HEXAGON && TCGNo need to check for TCG.
Quoted 4 lines
hw/hexagon/Kconfig line 5
Quoted 1 line
hw/hexagon/Kconfig new file +1
-0+ imply PTIMERUsually you want "select" here, not "imply", but
I don't see any PTIMER code being used.
Thanks - I will include fixes for these in v5.
PATCH v4 4/9 hw/hexagon: Add v68, sa8775-cdsp0 defs
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 64 ++++++++++++++++++++++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 65 +++++++++++++++++++++++ 2 files changed, 129 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 +64 -0
@@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +static const struct 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, + .reserved4 = 0x00000001, + .reserved5 = 0x00000000, + .reserved6 = 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 +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 5/9 hw/hexagon: Add support for cfgbase
In reply to Brian CainFrom: Sid Manning <[email protected]>
--- hw/hexagon/hexagon_dsp.c | 11 +++++++++++ target/hexagon/cpu.c | 1 - 2 files changed, 11 insertions(+), 1 deletion(-)
hw/hexagon/hexagon_dsp.c +11 -0
@@ -73,6 +73,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, const struct hexagon_machine_config *m_cfg) {MemoryRegion *address_space; +MemoryRegion *config_table_rom;MemoryRegion *sram;DeviceState *glob_regs_dev;
@@ -86,6 +87,12 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, address_space =get_system_memory (); + 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); + sram =g_new (MemoryRegion,1 );memory_region_init_ram (sram,NULL ,"ddr.ram" , machine->ram_size, &error_fatal);
@@ -114,6 +121,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 +0 -1
@@ -404,7 +404,6 @@ void hexagon_cpu_soft_reset(CPUHexagonState *env) }#endif -static void hexagon_cpu_reset_hold (Object *obj,ResetType type) {CPUState *cs =CPU (obj);
Signature · 1 line
2.34.1
PATCH v4 6/9 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
hw/hexagon/hexagon_dsp.c +16 -0
@@ -28,9 +28,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. */
@@ -58,7 +66,15 @@ static void hexagon_load_kernel(HexagonCPU *cpu)static void hexagon_init_bootstrap (MachineState *machine,HexagonCPU *cpu) {if (machine->kernel_filename) { +uint32_t mem =1 ; +hexagon_load_kernel (cpu); +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 v4 7/9 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 | 7 +++++++ target/hexagon/cpu.h | 7 +------ target/hexagon/cpu.c | 3 +-- target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 13 ++++++++++++- 8 files changed, 32 insertions(+), 9 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
@@ -254,6 +254,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: gdbstub/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 +7 -0
@@ -0,0 +1,7 @@ +# Default configuration for hexagon-softmmu + +TARGET_ARCH=hexagon +TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml +TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
target/hexagon/cpu.h +1 -6
@@ -37,12 +37,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegState;#include "mmvec/mmvec.h" #include "hw/core/registerfields.h" -#ifndef CONFIG_USER_ONLY -#error "Hexagon does not support system emulation" -#endif - -#ifndef CONFIG_USER_ONLY -#endif +#include "reg_fields.h" #define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
target/hexagon/cpu.c +1 -2
@@ -713,9 +713,8 @@ static vaddr hexagon_pointer_wrap(CPUState *cs, int mmu_idx,#endif static const TCGCPUOps hexagon_tcg_ops = { -/* MTTCG not yet supported: require strict ordering */ .guest_default_memory_order =TCG_MO_ALL , - .mttcg_supported = false, + .mttcg_supported = true, .initialize = hexagon_translate_init, .translate_code = hexagon_translate_code, .get_tb_cpu_state = hexagon_get_tb_cpu_state,
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 +12 -1
@@ -235,6 +235,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',
@@ -253,6 +254,14 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', )) +hexagon_softmmu_ss.add(files( + 'cpu_helper.c', + '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
@@ -262,7 +271,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',
@@ -390,3 +400,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 v4 8/9 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 | 456 ++++++++++++++++++++ target/hexagon/cpu.c | 2 + hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 2 + tests/qemu-iotests/testenv.py | 1 + 8 files changed, 516 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
@@ -5,3 +5,4 @@ TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml TARGET_LONG_BITS=32 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y +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 +456 -0
456 lines not on this page · raw message
target/hexagon/cpu.c +2 -0
@@ -68,6 +68,8 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model)static const Property hexagon_cpu_properties[] = { #if !defined(CONFIG_USER_ONLY) +DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , + HexagonTLBState *),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffff ),DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *),
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
@@ -4,3 +4,5 @@ hexagon_ss.add(files('hexagon_globalreg.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hw_arch += {'hexagon': hexagon_ss} + +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
tests/qemu-iotests/testenv.py +1 -0
@@ -259,6 +259,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
Re: [PATCH v4 8/9] hw/hexagon: Define hexagon "virt" machine
Quoted 421 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by 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 | 456 ++++++++++++++++++++ target/hexagon/cpu.c | 2 + hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 2 + tests/qemu-iotests/testenv.py | 1 + 8 files changed, 516 insertions(+) create mode 100644 include/hw/hexagon/virt.h create mode 100644 hw/hexagon/virt.cconfigs/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=yconfigs/targets/hexagon-softmmu.mak +1
-0@@ -5,3 +5,4 @@ TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml TARGET_LONG_BITS=32 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y +TARGET_NEED_FDT=yinclude/hw/hexagon/virt.h new file +43
-0@@ -0,0 +1,43 @@ +/* +* Definitions for hexagon virt board. +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_HEXAGONVIRT_H +#define HW_HEXAGONVIRT_H + +#include "hw/core/boards.h" +#include "target/hexagon/cpu.h" + +struct HexagonVirtMachineState { +/*< private >*/ +MachineState parent_obj; + +int fdt_size; +MemoryRegion *sys; +MemoryRegion cfgtable; +MemoryRegion ram; +MemoryRegion tcm; +MemoryRegion vtcm; +MemoryRegion bios; +DeviceState *l2vic; +Clock *apb_clk; +}; + +void hexagon_load_fdt (const struct HexagonVirtMachineState *vms); + +enum { +VIRT_UART0 , +VIRT_QTMR0 , +VIRT_QTMR1 , +VIRT_GPT , +VIRT_MMIO , +VIRT_FDT , +}; + +#define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +OBJECT_DECLARE_SIMPLE_TYPE(HexagonVirtMachineState, HEXAGON_VIRT_MACHINE) + +#endif /* HW_HEXAGONVIRT_H */ hw/hexagon/virt.c new file +76
-0@@ -0,0 +1,456 @@ +/* +* Hexagon virt emulation +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hexagon/virt.h" +#include "elf.h" +#include "hw/char/pl011.h" +#include "hw/core/clock.h" +#include "hw/core/sysbus-fdt.h" +#include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "hw/core/loader.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/qdev-clock.h" +#include "hw/core/register.h" +#include "qemu/error-report.h" +#include "qemu/guest-random.h" +#include "qemu/units.h" +#include "elf.h" +#include "machine_cfg_v68n_1024.h.inc" +#include "system/address-spaces.h" +#include "system/device_tree.h" +#include "system/reset.h" +#include "system/system.h" +#include <libfdt.h> + +static const int VIRTIO_DEV_COUNT =8 ; + +static const MemMapEntry base_memmap[] = { + [VIRT_UART0 ] = {0x10000000 ,0x00000200 }, + [VIRT_MMIO ] = {0x11000000 ,0x1000000 , }, + [VIRT_GPT ] = {0xab000000 ,0x00001000 }, + [VIRT_FDT ] = {0x99800000 ,0x00400000 }, +}; + +static const int irqmap[] = { + [VIRT_MMIO ] =18 ,/* ...to 18 + VIRTIO_DEV_COUNT - 1 */ + [VIRT_GPT ] =12 , + [VIRT_UART0 ] =15 , + [VIRT_QTMR0 ] =2 , + [VIRT_QTMR1 ] =4 , +}; + + +static void create_fdt (HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +void *fdt =create_device_tree (&vms->fdt_size); +uint8_t rng_seed[32 ]; + +if (!fdt) { +error_report ("create_device_tree() failed" ); +exit (1 ); + } + + ms->fdt = fdt; + +qemu_fdt_setprop_cell (fdt,"/" ,"#address-cells" ,0x2 ); +qemu_fdt_setprop_cell (fdt,"/" ,"#size-cells" ,0x1 ); +qemu_fdt_setprop_string (fdt,"/" ,"model" ,"hexagon-virt,qemu" ); +qemu_fdt_setprop_string (fdt,"/" ,"compatible" ,"qcom,sm8150" ); + +qemu_fdt_add_subnode (fdt,"/soc" ); +qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 ); +qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x1 ); +qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); + +qemu_fdt_add_subnode (fdt,"/chosen" ); +qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); + qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed,
sizeof(rng_seed));hw/hexagon/virt.c new file +10
-0+} + +static void fdt_add_hvx (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg, +Error **errp) +{ +const MachineState *ms =MACHINE (vms); +uint32_t vtcm_size_bytes = m_cfg->cfgtable.vtcm_size_kb *1024 ; +if (vtcm_size_bytes >0 ) { + memory_region_init_ram(&vms->vtcm, NULL, "vtcm.ram",
vtcm_size_bytes,hw/hexagon/virt.c new file +2
-0+ errp); + memory_region_add_subregion(vms->sys, m_cfg->cfgtable.vtcm_base<< 16,
hw/hexagon/virt.c new file +26
-0+ &vms->vtcm); + +qemu_fdt_add_subnode (ms->fdt,"/soc/vtcm" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/vtcm" ,"compatible" , +"qcom,hexagon_vtcm" ); + +assert (sizeof (m_cfg->cfgtable.vtcm_base) ==sizeof (uint32_t )); +qemu_fdt_setprop_cells (ms->fdt,"/soc/vtcm" ,"reg" ,0 , + m_cfg->cfgtable.vtcm_base <<16 , + vtcm_size_bytes); + } + +if (m_cfg->cfgtable.ext_contexts >0 ) { +qemu_fdt_add_subnode (ms->fdt,"/soc/hvx" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/hvx" ,"compatible" , +"qcom,hexagon-hvx" ); +qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-max-ctxts" , + m_cfg->cfgtable.ext_contexts); +qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-vlength" , + m_cfg->cfgtable.hvx_vec_log_length); + } +} + +static int32_t irq_hvm_ic_phandle =-1 ; +static void fdt_add_hvm_pic_node (HexagonVirtMachineState *vms, + const struct hexagon_machine_config
*m_cfg)hw/hexagon/virt.c new file +13
-0+{ +MachineState *ms =MACHINE (vms); + irq_hvm_ic_phandle =qemu_fdt_alloc_phandle (ms->fdt); + +qemu_fdt_setprop_cell (ms->fdt,"/soc" ,"interrupt-parent" , + irq_hvm_ic_phandle); + +qemu_fdt_add_subnode (ms->fdt,"/soc/interrupt-controller" ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" , +"#address-cells" ,2 ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" , +"#interrupt-cells" ,2 ); + qemu_fdt_setprop_string(ms->fdt, "/soc/interrupt-controller","compatible",
hw/hexagon/virt.c new file +22
-0+ "qcom,h2-pic,hvm-pic"); +qemu_fdt_setprop (ms->fdt,"/soc/interrupt-controller" , +"interrupt-controller" ,NULL ,0 ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" ,"phandle" , + irq_hvm_ic_phandle); + +sysbus_mmio_map (SYS_BUS_DEVICE (vms->l2vic),1 , + m_cfg->cfgtable.fastl2vic_base <<16 ); +} + + +static void fdt_add_gpt_node (HexagonVirtMachineState *vms) +{ + g_autofree char *name = NULL; +MachineState *ms =MACHINE (vms); + + name =g_strdup_printf ("/soc/gpt@%" PRIx64, + (int64_t )base_memmap[VIRT_GPT ].base); +qemu_fdt_add_subnode (ms->fdt, name); +qemu_fdt_setprop_string (ms->fdt, name,"compatible" , +"qcom,h2-timer,hvm-timer" ); + qemu_fdt_setprop_cells(ms->fdt, name, "interrupts", irqmap[VIRT_GPT],0);
hw/hexagon/virt.c new file +12
-0+qemu_fdt_setprop_cells (ms->fdt, name,"reg" ,0x0 , + base_memmap[VIRT_GPT ].base, + base_memmap[VIRT_GPT ].size); +} + +static int32_t clock_phandle =-1 ; +static void fdt_add_clocks (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); + clock_phandle =qemu_fdt_alloc_phandle (ms->fdt); +qemu_fdt_add_subnode (ms->fdt,"/apb-pclk" ); + qemu_fdt_setprop_string(ms->fdt, "/apb-pclk", "compatible","fixed-clock");
hw/hexagon/virt.c new file +2
-0+qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"#clock-cells" ,0x0 ); + qemu_fdt_setprop_cell(ms->fdt, "/apb-pclk", "clock-frequency",24000000);
hw/hexagon/virt.c new file +32
-0+qemu_fdt_setprop_string (ms->fdt,"/apb-pclk" ,"clock-output-names" , +"clk24mhz" ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"phandle" , clock_phandle); +} + +static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart) +{ +char *nodename; +hwaddr base = base_memmap[uart].base; +hwaddr size = base_memmap[uart].size; +assert (uart ==0 ); +int irq = irqmap[VIRT_UART0 + uart]; +const char compat[] ="arm,pl011\0arm,primecell" ; +const char clocknames[] ="uartclk\0apb_pclk" ; +MachineState *ms =MACHINE (vms); +DeviceState *dev; +SysBusDevice *s; + + dev =qdev_new (TYPE_PL011 ); + s =SYS_BUS_DEVICE (dev); +qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); +qdev_connect_clock_in (dev,"clk" , vms->apb_clk); +sysbus_realize_and_unref (s, &error_fatal); +sysbus_mmio_map (s,0 , base); +if (vms->l2vic) { +sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->l2vic, irq)); + } + + nodename =g_strdup_printf ("/pl011@%" PRIx64, base); +qemu_fdt_add_subnode (ms->fdt, nodename); + +/* Note that we can't use setprop_string because of the embedded NUL */
+ qemu_fdt_setprop(ms->fdt, nodename, "compatible", compat,
sizeof(compat));hw/hexagon/virt.c new file +52
-0+qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +if (vms->l2vic) { +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , +32 + irq,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_hvm_ic_phandle); + } +qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clock_phandle, + clock_phandle); +qemu_fdt_setprop (ms->fdt, nodename,"clock-names" , clocknames, +sizeof (clocknames)); + +qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"stdout-path" , nodename); +qemu_fdt_add_subnode (ms->fdt,"/aliases" ); +qemu_fdt_setprop_string (ms->fdt,"/aliases" ,"serial0" , nodename); + +g_free (nodename); +} + +static void fdt_add_cpu_nodes (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +qemu_fdt_add_subnode (ms->fdt,"/cpus" ); +qemu_fdt_setprop_cell (ms->fdt,"/cpus" ,"#address-cells" ,0x1 ); +qemu_fdt_setprop_cell (ms->fdt,"/cpus" ,"#size-cells" ,0x0 ); + +/* cpu nodes */ +for (int num = ms->smp.cpus -1 ; num >=0 ; num--) { +char *nodename =g_strdup_printf ("/cpus/cpu@%d" , num); +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename,"device_type" ,"cpu" ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"reg" , num); +qemu_fdt_setprop_cell (ms->fdt, nodename,"phandle" , +qemu_fdt_alloc_phandle (ms->fdt)); +g_free (nodename); + } +} + + +static void fdt_add_virtio_devices (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +/* VirtIO MMIO devices */ +for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) { +char *nodename; +int irq = irqmap[VIRT_MMIO ] + i; +size_t size = base_memmap[VIRT_MMIO ].size; +hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; + + nodename =g_strdup_printf ("/virtio_mmio@%" PRIx64, base); +qemu_fdt_add_subnode (ms->fdt, nodename); + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible","virtio,mmio");
hw/hexagon/virt.c new file +41
-0+qemu_fdt_setprop_sized_cells (ms->fdt, nodename,"reg" ,2 , base,1 , + size); +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , irq,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_hvm_ic_phandle); + +sysbus_create_simple ( +"virtio-mmio" , base, +qdev_get_gpio_in (vms->l2vic, irqmap[VIRT_MMIO ] + i)); + +g_free (nodename); + } +} + +static void virt_instance_init (Object *obj) +{ +HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (obj); + +create_fdt (vms); +} + +void hexagon_load_fdt (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +hwaddr fdt_addr = base_memmap[VIRT_FDT ].base; +uint32_t fdtsize = vms->fdt_size; + +g_assert (fdtsize <= base_memmap[VIRT_FDT ].size); +/* copy in the device tree */ +rom_add_blob_fixed_as ("fdt" , ms->fdt, fdtsize, fdt_addr, + &address_space_memory); +qemu_register_reset_nosnapshotload ( + qemu_fdt_randomize_seeds, +rom_ptr_for_as (&address_space_memory, fdt_addr, fdtsize)); +} + +static uint64_t load_kernel (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +uint64_t entry =0 ; + if (load_elf_ram_sym(ms->kernel_filename, NULL, NULL, NULL, &entry,NULL,
+ NULL, NULL, 0,EM_HEXAGON, 0, 0,&address_space_memory,hw/hexagon/virt.c new file +24
-0+ false, NULL) > 0) { +return entry; + } +error_report ("error loading '%s'" , ms->kernel_filename); +exit (1 ); +} + +static uint64_t load_bios (HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +uint64_t bios_addr =0x0 ;/* Load BIOS at reset vector address 0x0 */ +int bios_size; + + bios_size =load_image_targphys (ms->firmware ?:"" , + bios_addr,64 *1024 ,NULL ); +if (bios_size <0 ) { +error_report ("Could not load BIOS '%s'" , ms->firmware ?:"" ); +exit (1 ); + } + +return bios_addr;/* Return entry point at address 0x0 */ +} + +static void do_cpu_reset (void *opaque)
hw/hexagon/virt.c line 324
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+{ +HexagonCPU *cpu = opaque; +CPUState *cs =CPU (cpu); +cpu_reset (cs); +} + +static void virt_init (MachineState *ms) +{ +HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms); +const struct hexagon_machine_config *m_cfg = &v68n_1024;
This is v68 but in virt_class_init mc->default_cpu_type is set to v73, should that be 68?
+ const char *cpu_model;
Quoted 196 lines
hw/hexagon/virt.c new file +5
-0+DeviceState *gsregs_dev; +DeviceState *tlb_dev; +HexagonCPU *cpu_0; + + qemu_fdt_setprop_string(ms->fdt, "/chosen", "bootargs",
ms->kernel_cmdline);hw/hexagon/virt.c new file +13
-0+ + vms->sys =get_system_memory (); + +/* Create APB clock for peripherals */ + vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" ); +clock_set_hz (vms->apb_clk,24000000 ); + +memory_region_init_ram (&vms->ram,NULL ,"ddr.ram" , ms->ram_size, + &error_fatal); +memory_region_add_subregion (vms->sys,0x0 , &vms->ram); + +if (m_cfg->l2tcm_size) { + memory_region_init_ram(&vms->tcm, NULL, "tcm.ram",
m_cfg->l2tcm_size,hw/hexagon/virt.c new file +2
-0+ &error_fatal); + memory_region_add_subregion(vms->sys, m_cfg->cfgtable.l2tcm_base<< 16,
hw/hexagon/virt.c new file +15
-0+ &vms->tcm); + } + +memory_region_init_rom (&vms->cfgtable,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (vms->sys, m_cfg->cfgbase, &vms->cfgtable); +fdt_add_hvx (vms, m_cfg, &error_fatal); + cpu_model = ms->cpu_type; + +if (!cpu_model) { + cpu_model =HEXAGON_CPU_TYPE_NAME ("v73" ); + } + + gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); + object_property_add_child(OBJECT(ms), "global-regs",
OBJECT(gsregs_dev));hw/hexagon/virt.c new file +20
-0+qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase); +qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev); +sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); + + tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); +object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev)); +qdev_prop_set_uint32 (tlb_dev,"num-entries" , + m_cfg->cfgtable.jtlb_size_entries); +sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); + + cpu_0 =NULL ; +for (int i =0 ; i < ms->smp.cpus; i++) { +HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type)); +qemu_register_reset (do_cpu_reset, cpu); + +if (i ==0 ) { + cpu_0 = cpu; +if (ms->kernel_filename) { +uint64_t entry =load_kernel (vms); + qdev_prop_set_uint32(DEVICE(cpu_0), "exec-start-addr",entry);
hw/hexagon/virt.c new file +3
-0+ }else if (ms->firmware) { +uint64_t entry =load_bios (vms); + qdev_prop_set_uint32(DEVICE(cpu_0), "exec-start-addr",entry);
hw/hexagon/virt.c new file +73
-0+ } + } +qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i); +qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); +object_property_set_link (OBJECT (cpu),"global-regs" , +OBJECT (gsregs_dev), &error_fatal); +object_property_set_link (OBJECT (cpu),"tlb" , +OBJECT (tlb_dev), &error_fatal); + +if (!qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal)) { +return ; + } + } +/* TODO: enable l2vic when l2vic device arrives */ +if (object_class_by_name ("l2vic" )) { + vms->l2vic =sysbus_create_varargs ( +"l2vic" , m_cfg->l2vic_base, +qdev_get_gpio_in (DEVICE (cpu_0),0 ), +qdev_get_gpio_in (DEVICE (cpu_0),1 ), +qdev_get_gpio_in (DEVICE (cpu_0),2 ), +qdev_get_gpio_in (DEVICE (cpu_0),3 ), +qdev_get_gpio_in (DEVICE (cpu_0),4 ), +qdev_get_gpio_in (DEVICE (cpu_0),5 ), +qdev_get_gpio_in (DEVICE (cpu_0),6 ), +qdev_get_gpio_in (DEVICE (cpu_0),7 ),NULL ); + +fdt_add_hvm_pic_node (vms, m_cfg); +fdt_add_virtio_devices (vms); +fdt_add_gpt_node (vms); + } + +fdt_add_cpu_nodes (vms); +fdt_add_clocks (vms); +fdt_add_uart (vms,VIRT_UART0 ); + +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); + + +hexagon_load_fdt (vms); +} + + +static void virt_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->desc ="Hexagon Virtual Machine" ; + mc->init = virt_init; + mc->default_cpu_type =HEXAGON_CPU_TYPE_NAME ("v73" ); + mc->default_ram_size =4 * GiB; + mc->max_cpus =8 ; + mc->default_cpus =8 ; + mc->is_default = false; + mc->default_kernel_irqchip_split = false; + mc->block_default_type =IF_VIRTIO ; + mc->default_boot_order =NULL ; + mc->no_cdrom =1 ; + mc->numa_mem_supported = false; + mc->default_nic ="virtio-mmio-bus" ; +} + + +static const TypeInfo virt_machine_types[] = { { + .name =TYPE_HEXAGON_VIRT_MACHINE , + .parent =TYPE_MACHINE , + .instance_size =sizeof (HexagonVirtMachineState), + .class_init = virt_class_init, + .instance_init = virt_instance_init, +} }; + +DEFINE_TYPES (virt_machine_types)target/hexagon/cpu.c +2
-0@@ -68,6 +68,8 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model) static const Property hexagon_cpu_properties[] = {#if !defined(CONFIG_USER_ONLY ) +DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , + HexagonTLBState *),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr, 0xffffffff),DEFINE_PROP_LINK("global-regs", HexagonCPU, globalregs,
TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *),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_SCSIhw/hexagon/meson.build +2
-0@@ -4,3 +4,5 @@ hexagon_ss.add(files('hexagon_globalreg.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hw_arch += {'hexagon': hexagon_ss} + +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))tests/qemu-iotests/testenv.py +1
-1@@ -259,6 +259,7 @@ def __init__(self, source_dir: str, build_dir: str, ('arm', 'virt'), ('aarch64', 'virt'), ('avr', 'mega2560'), + ('hexagon', 'virt'), ('m68k', 'virt'), ('or1k', 'virt'), ('riscv32', 'virt'), --2.34.1
Re: [PATCH v4 8/9] hw/hexagon: Define hexagon "virt" machine
Quoted 414 lines · Sid Manning
Quoted 410 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by 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 | 456 ++++++++++++++++++++ target/hexagon/cpu.c | 2 + hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 2 + tests/qemu-iotests/testenv.py | 1 + 8 files changed, 516 insertions(+) create mode 100644 include/hw/hexagon/virt.h create mode 100644 hw/hexagon/virt.cconfigs/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=yconfigs/targets/hexagon-softmmu.mak +1
-0@@ -5,3 +5,4 @@ TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml TARGET_LONG_BITS=32 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y +TARGET_NEED_FDT=yinclude/hw/hexagon/virt.h new file +43
-0@@ -0,0 +1,43 @@ +/* +* Definitions for hexagon virt board. +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_HEXAGONVIRT_H +#define HW_HEXAGONVIRT_H + +#include "hw/core/boards.h" +#include "target/hexagon/cpu.h" + +struct HexagonVirtMachineState { +/*< private >*/ +MachineState parent_obj; + +int fdt_size; +MemoryRegion *sys; +MemoryRegion cfgtable; +MemoryRegion ram; +MemoryRegion tcm; +MemoryRegion vtcm; +MemoryRegion bios; +DeviceState *l2vic; +Clock *apb_clk; +}; + +void hexagon_load_fdt (const struct HexagonVirtMachineState *vms); + +enum { +VIRT_UART0 , +VIRT_QTMR0 , +VIRT_QTMR1 , +VIRT_GPT , +VIRT_MMIO , +VIRT_FDT , +}; + +#define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +OBJECT_DECLARE_SIMPLE_TYPE(HexagonVirtMachineState, HEXAGON_VIRT_MACHINE) + +#endif /* HW_HEXAGONVIRT_H */ hw/hexagon/virt.c new file +318
-0@@ -0,0 +1,456 @@ +/* +* Hexagon virt emulation +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hexagon/virt.h" +#include "elf.h" +#include "hw/char/pl011.h" +#include "hw/core/clock.h" +#include "hw/core/sysbus-fdt.h" +#include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "hw/core/loader.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/qdev-clock.h" +#include "hw/core/register.h" +#include "qemu/error-report.h" +#include "qemu/guest-random.h" +#include "qemu/units.h" +#include "elf.h" +#include "machine_cfg_v68n_1024.h.inc" +#include "system/address-spaces.h" +#include "system/device_tree.h" +#include "system/reset.h" +#include "system/system.h" +#include <libfdt.h> + +static const int VIRTIO_DEV_COUNT =8 ; + +static const MemMapEntry base_memmap[] = { + [VIRT_UART0 ] = {0x10000000 ,0x00000200 }, + [VIRT_MMIO ] = {0x11000000 ,0x1000000 , }, + [VIRT_GPT ] = {0xab000000 ,0x00001000 }, + [VIRT_FDT ] = {0x99800000 ,0x00400000 }, +}; + +static const int irqmap[] = { + [VIRT_MMIO ] =18 ,/* ...to 18 + VIRTIO_DEV_COUNT - 1 */ + [VIRT_GPT ] =12 , + [VIRT_UART0 ] =15 , + [VIRT_QTMR0 ] =2 , + [VIRT_QTMR1 ] =4 , +}; + + +static void create_fdt (HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +void *fdt =create_device_tree (&vms->fdt_size); +uint8_t rng_seed[32 ]; + +if (!fdt) { +error_report ("create_device_tree() failed" ); +exit (1 ); + } + + ms->fdt = fdt; + +qemu_fdt_setprop_cell (fdt,"/" ,"#address-cells" ,0x2 ); +qemu_fdt_setprop_cell (fdt,"/" ,"#size-cells" ,0x1 ); +qemu_fdt_setprop_string (fdt,"/" ,"model" ,"hexagon-virt,qemu" ); +qemu_fdt_setprop_string (fdt,"/" ,"compatible" ,"qcom,sm8150" ); + +qemu_fdt_add_subnode (fdt,"/soc" ); +qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 ); +qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x1 ); +qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); + +qemu_fdt_add_subnode (fdt,"/chosen" ); +qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); +qemu_fdt_setprop (fdt,"/chosen" ,"rng-seed" , rng_seed,sizeof (rng_seed)); +} + +static void fdt_add_hvx (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg, +Error **errp) +{ +const MachineState *ms =MACHINE (vms); +uint32_t vtcm_size_bytes = m_cfg->cfgtable.vtcm_size_kb *1024 ; +if (vtcm_size_bytes >0 ) { +memory_region_init_ram (&vms->vtcm,NULL ,"vtcm.ram" , vtcm_size_bytes, + errp); +memory_region_add_subregion (vms->sys, m_cfg->cfgtable.vtcm_base <<16 , + &vms->vtcm); + +qemu_fdt_add_subnode (ms->fdt,"/soc/vtcm" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/vtcm" ,"compatible" , +"qcom,hexagon_vtcm" ); + +assert (sizeof (m_cfg->cfgtable.vtcm_base) ==sizeof (uint32_t )); +qemu_fdt_setprop_cells (ms->fdt,"/soc/vtcm" ,"reg" ,0 , + m_cfg->cfgtable.vtcm_base <<16 , + vtcm_size_bytes); + } + +if (m_cfg->cfgtable.ext_contexts >0 ) { +qemu_fdt_add_subnode (ms->fdt,"/soc/hvx" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/hvx" ,"compatible" , +"qcom,hexagon-hvx" ); +qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-max-ctxts" , + m_cfg->cfgtable.ext_contexts); +qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-vlength" , + m_cfg->cfgtable.hvx_vec_log_length); + } +} + +static int32_t irq_hvm_ic_phandle =-1 ; +static void fdt_add_hvm_pic_node (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg) +{ +MachineState *ms =MACHINE (vms); + irq_hvm_ic_phandle =qemu_fdt_alloc_phandle (ms->fdt); + +qemu_fdt_setprop_cell (ms->fdt,"/soc" ,"interrupt-parent" , + irq_hvm_ic_phandle); + +qemu_fdt_add_subnode (ms->fdt,"/soc/interrupt-controller" ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" , +"#address-cells" ,2 ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" , +"#interrupt-cells" ,2 ); +qemu_fdt_setprop_string (ms->fdt,"/soc/interrupt-controller" ,"compatible" , +"qcom,h2-pic,hvm-pic" ); +qemu_fdt_setprop (ms->fdt,"/soc/interrupt-controller" , +"interrupt-controller" ,NULL ,0 ); +qemu_fdt_setprop_cell (ms->fdt,"/soc/interrupt-controller" ,"phandle" , + irq_hvm_ic_phandle); + +sysbus_mmio_map (SYS_BUS_DEVICE (vms->l2vic),1 , + m_cfg->cfgtable.fastl2vic_base <<16 ); +} + + +static void fdt_add_gpt_node (HexagonVirtMachineState *vms) +{ + g_autofree char *name = NULL; +MachineState *ms =MACHINE (vms); + + name =g_strdup_printf ("/soc/gpt@%" PRIx64, + (int64_t )base_memmap[VIRT_GPT ].base); +qemu_fdt_add_subnode (ms->fdt, name); +qemu_fdt_setprop_string (ms->fdt, name,"compatible" , +"qcom,h2-timer,hvm-timer" ); +qemu_fdt_setprop_cells (ms->fdt, name,"interrupts" , irqmap[VIRT_GPT ],0 ); +qemu_fdt_setprop_cells (ms->fdt, name,"reg" ,0x0 , + base_memmap[VIRT_GPT ].base, + base_memmap[VIRT_GPT ].size); +} + +static int32_t clock_phandle =-1 ; +static void fdt_add_clocks (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); + clock_phandle =qemu_fdt_alloc_phandle (ms->fdt); +qemu_fdt_add_subnode (ms->fdt,"/apb-pclk" ); +qemu_fdt_setprop_string (ms->fdt,"/apb-pclk" ,"compatible" ,"fixed-clock" ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"#clock-cells" ,0x0 ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"clock-frequency" ,24000000 ); +qemu_fdt_setprop_string (ms->fdt,"/apb-pclk" ,"clock-output-names" , +"clk24mhz" ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"phandle" , clock_phandle); +} + +static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart) +{ +char *nodename; +hwaddr base = base_memmap[uart].base; +hwaddr size = base_memmap[uart].size; +assert (uart ==0 ); +int irq = irqmap[VIRT_UART0 + uart]; +const char compat[] ="arm,pl011\0arm,primecell" ; +const char clocknames[] ="uartclk\0apb_pclk" ; +MachineState *ms =MACHINE (vms); +DeviceState *dev; +SysBusDevice *s; + + dev =qdev_new (TYPE_PL011 ); + s =SYS_BUS_DEVICE (dev); +qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); +qdev_connect_clock_in (dev,"clk" , vms->apb_clk); +sysbus_realize_and_unref (s, &error_fatal); +sysbus_mmio_map (s,0 , base); +if (vms->l2vic) { +sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->l2vic, irq)); + } + + nodename =g_strdup_printf ("/pl011@%" PRIx64, base); +qemu_fdt_add_subnode (ms->fdt, nodename); + +/* Note that we can't use setprop_string because of the embedded NUL */ +qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat)); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +if (vms->l2vic) { +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , +32 + irq,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_hvm_ic_phandle); + } +qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clock_phandle, + clock_phandle); +qemu_fdt_setprop (ms->fdt, nodename,"clock-names" , clocknames, +sizeof (clocknames)); + +qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"stdout-path" , nodename); +qemu_fdt_add_subnode (ms->fdt,"/aliases" ); +qemu_fdt_setprop_string (ms->fdt,"/aliases" ,"serial0" , nodename); + +g_free (nodename); +} + +static void fdt_add_cpu_nodes (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +qemu_fdt_add_subnode (ms->fdt,"/cpus" ); +qemu_fdt_setprop_cell (ms->fdt,"/cpus" ,"#address-cells" ,0x1 ); +qemu_fdt_setprop_cell (ms->fdt,"/cpus" ,"#size-cells" ,0x0 ); + +/* cpu nodes */ +for (int num = ms->smp.cpus -1 ; num >=0 ; num--) { +char *nodename =g_strdup_printf ("/cpus/cpu@%d" , num); +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename,"device_type" ,"cpu" ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"reg" , num); +qemu_fdt_setprop_cell (ms->fdt, nodename,"phandle" , +qemu_fdt_alloc_phandle (ms->fdt)); +g_free (nodename); + } +} + + +static void fdt_add_virtio_devices (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +/* VirtIO MMIO devices */ +for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) { +char *nodename; +int irq = irqmap[VIRT_MMIO ] + i; +size_t size = base_memmap[VIRT_MMIO ].size; +hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; + + nodename =g_strdup_printf ("/virtio_mmio@%" PRIx64, base); +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename,"compatible" ,"virtio,mmio" ); +qemu_fdt_setprop_sized_cells (ms->fdt, nodename,"reg" ,2 , base,1 , + size); +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , irq,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_hvm_ic_phandle); + +sysbus_create_simple ( +"virtio-mmio" , base, +qdev_get_gpio_in (vms->l2vic, irqmap[VIRT_MMIO ] + i)); + +g_free (nodename); + } +} + +static void virt_instance_init (Object *obj) +{ +HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (obj); + +create_fdt (vms); +} + +void hexagon_load_fdt (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +hwaddr fdt_addr = base_memmap[VIRT_FDT ].base; +uint32_t fdtsize = vms->fdt_size; + +g_assert (fdtsize <= base_memmap[VIRT_FDT ].size); +/* copy in the device tree */ +rom_add_blob_fixed_as ("fdt" , ms->fdt, fdtsize, fdt_addr, + &address_space_memory); +qemu_register_reset_nosnapshotload ( + qemu_fdt_randomize_seeds, +rom_ptr_for_as (&address_space_memory, fdt_addr, fdtsize)); +} + +static uint64_t load_kernel (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +uint64_t entry =0 ; +if (load_elf_ram_sym (ms->kernel_filename,NULL ,NULL ,NULL , &entry,NULL , +NULL ,NULL ,0 ,EM_HEXAGON ,0 ,0 , &address_space_memory, + false,NULL ) >0 ) { +return entry; + } +error_report ("error loading '%s'" , ms->kernel_filename); +exit (1 ); +} + +static uint64_t load_bios (HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +uint64_t bios_addr =0x0 ;/* Load BIOS at reset vector address 0x0 */ +int bios_size; + + bios_size =load_image_targphys (ms->firmware ?:"" , + bios_addr,64 *1024 ,NULL ); +if (bios_size <0 ) { +error_report ("Could not load BIOS '%s'" , ms->firmware ?:"" ); +exit (1 ); + } + +return bios_addr;/* Return entry point at address 0x0 */ +} + +static void do_cpu_reset (void *opaque) +{ +HexagonCPU *cpu = opaque; +CPUState *cs =CPU (cpu); +cpu_reset (cs);
Quoted 8 lines
hw/hexagon/virt.c line 324
Quoted 6 lines
hw/hexagon/virt.c new file +6
-0+} + +static void virt_init (MachineState *ms) +{ +HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms); +const struct hexagon_machine_config *m_cfg = &v68n_1024;This is v68 but in
virt_class_initmc->default_cpu_typeis set to v73, should that be 68?
Fixed these, thanks Sid!
https://github.com/quic/qemu/tree/bcain/sysemu_review e5f9d63 has the requested changes, will give it a ~couple of days and send a new round of patches for review w/the fixes.
Here's a range-diff:
1: d2341f42a80 ! 1: 846fe3f0958 hw/hexagon: Add globalreg model
@@ Commit message
interface to the system registers.
+ Reviewed-by: Sid Manning <[email protected]>
## include/hw/hexagon/hexagon_globalreg.h (new) ##
@@
@@ hw/hexagon/hexagon_globalreg.c (new)
+ s->regs[HEX_SREG_PMUCNT7] = INVALID_REG_VAL;
+}
+
-+static void hexagon_globalreg_realize(DeviceState *dev, Error **errp) -+{
-+}
-+
+void hexagon_globalreg_reset(HexagonGlobalRegState *s)
+{
+ do_hexagon_globalreg_reset(s);
@@ hw/hexagon/hexagon_globalreg.c (new)
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
+
-+ dc->realize = hexagon_globalreg_realize;
+ rc->phases.hold = hexagon_globalreg_reset_hold;
+ dc->vmsd = &vmstate_hexagon_globalreg;
+ dc->user_creatable = false;
2: 21483a7154e = 2: e3ed41133e7 hw/hexagon: Add global register tracing 3: 76011b26056 = 3: 735792b3493 hw/hexagon: Add machine configs for sysemu 4: 8b58db4d79b = 4: 9bbc363926a hw/hexagon: Add v68, sa8775-cdsp0 defs 5: 50c227946bc = 5: db09e484815 hw/hexagon: Add support for cfgbase 6: 58150cb26eb = 6: ad4b71cf913 hw/hexagon: Modify "Standalone" symbols 7: d6a21abad25 = 7: 81f67470f1f target/hexagon: add build config for softmmu 8: fdfbf4bd5f5 ! 8: 48c194c1b33 hw/hexagon: Define hexagon "virt" machine
@@ hw/hexagon/virt.c (new)
+ cpu_model = ms->cpu_type;
+
+ if (!cpu_model) {
-+ cpu_model = HEXAGON_CPU_TYPE_NAME("v73");
++ cpu_model = HEXAGON_CPU_TYPE_NAME("v68");
+ }
+
+ gsregs_dev = qdev_new(TYPE_HEXAGON_GLOBALREG);
@@ hw/hexagon/virt.c (new)
+
+ mc->desc = "Hexagon Virtual Machine";
+ mc->init = virt_init;
-+ mc->default_cpu_type = HEXAGON_CPU_TYPE_NAME("v73");
++ mc->default_cpu_type = HEXAGON_CPU_TYPE_NAME("v68");
+ mc->default_ram_size = 4 * GiB;
+ mc->max_cpus = 8;
+ mc->default_cpus = 8;
9: 8e81fac5f64 = 9: e5f9d632610 tests/qtest: Add hexagon boot-serial-test
Quoted 188 lines
Quoted 188 lines
hw/hexagon/virt.c new file +132
-0+const char *cpu_model; +DeviceState *gsregs_dev; +DeviceState *tlb_dev; +HexagonCPU *cpu_0; + +qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"bootargs" , ms->kernel_cmdline); + + vms->sys =get_system_memory (); + +/* Create APB clock for peripherals */ + vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" ); +clock_set_hz (vms->apb_clk,24000000 ); + +memory_region_init_ram (&vms->ram,NULL ,"ddr.ram" , ms->ram_size, + &error_fatal); +memory_region_add_subregion (vms->sys,0x0 , &vms->ram); + +if (m_cfg->l2tcm_size) { +memory_region_init_ram (&vms->tcm,NULL ,"tcm.ram" , m_cfg->l2tcm_size, + &error_fatal); +memory_region_add_subregion (vms->sys, m_cfg->cfgtable.l2tcm_base <<16 , + &vms->tcm); + } + +memory_region_init_rom (&vms->cfgtable,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (vms->sys, m_cfg->cfgbase, &vms->cfgtable); +fdt_add_hvx (vms, m_cfg, &error_fatal); + cpu_model = ms->cpu_type; + +if (!cpu_model) { + cpu_model =HEXAGON_CPU_TYPE_NAME ("v73" ); + } + + gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); +object_property_add_child (OBJECT (ms),"global-regs" ,OBJECT (gsregs_dev)); +qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase); +qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev); +sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); + + tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); +object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev)); +qdev_prop_set_uint32 (tlb_dev,"num-entries" , + m_cfg->cfgtable.jtlb_size_entries); +sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); + + cpu_0 =NULL ; +for (int i =0 ; i < ms->smp.cpus; i++) { +HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type)); +qemu_register_reset (do_cpu_reset, cpu); + +if (i ==0 ) { + cpu_0 = cpu; +if (ms->kernel_filename) { +uint64_t entry =load_kernel (vms); +qdev_prop_set_uint32 (DEVICE (cpu_0),"exec-start-addr" , entry); + }else if (ms->firmware) { +uint64_t entry =load_bios (vms); +qdev_prop_set_uint32 (DEVICE (cpu_0),"exec-start-addr" , entry); + } + } +qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i); +qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); +object_property_set_link (OBJECT (cpu),"global-regs" , +OBJECT (gsregs_dev), &error_fatal); +object_property_set_link (OBJECT (cpu),"tlb" , +OBJECT (tlb_dev), &error_fatal); + +if (!qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal)) { +return ; + } + } +/* TODO: enable l2vic when l2vic device arrives */ +if (object_class_by_name ("l2vic" )) { + vms->l2vic =sysbus_create_varargs ( +"l2vic" , m_cfg->l2vic_base, +qdev_get_gpio_in (DEVICE (cpu_0),0 ), +qdev_get_gpio_in (DEVICE (cpu_0),1 ), +qdev_get_gpio_in (DEVICE (cpu_0),2 ), +qdev_get_gpio_in (DEVICE (cpu_0),3 ), +qdev_get_gpio_in (DEVICE (cpu_0),4 ), +qdev_get_gpio_in (DEVICE (cpu_0),5 ), +qdev_get_gpio_in (DEVICE (cpu_0),6 ), +qdev_get_gpio_in (DEVICE (cpu_0),7 ),NULL ); + +fdt_add_hvm_pic_node (vms, m_cfg); +fdt_add_virtio_devices (vms); +fdt_add_gpt_node (vms); + } + +fdt_add_cpu_nodes (vms); +fdt_add_clocks (vms); +fdt_add_uart (vms,VIRT_UART0 ); + +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); + + +hexagon_load_fdt (vms); +} + + +static void virt_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->desc ="Hexagon Virtual Machine" ; + mc->init = virt_init; + mc->default_cpu_type =HEXAGON_CPU_TYPE_NAME ("v73" ); + mc->default_ram_size =4 * GiB; + mc->max_cpus =8 ; + mc->default_cpus =8 ; + mc->is_default = false; + mc->default_kernel_irqchip_split = false; + mc->block_default_type =IF_VIRTIO ; + mc->default_boot_order =NULL ; + mc->no_cdrom =1 ; + mc->numa_mem_supported = false; + mc->default_nic ="virtio-mmio-bus" ; +} + + +static const TypeInfo virt_machine_types[] = { { + .name =TYPE_HEXAGON_VIRT_MACHINE , + .parent =TYPE_MACHINE , + .instance_size =sizeof (HexagonVirtMachineState), + .class_init = virt_class_init, + .instance_init = virt_instance_init, +} }; + +DEFINE_TYPES (virt_machine_types)target/hexagon/cpu.c +2
-0@@ -68,6 +68,8 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model)static const Property hexagon_cpu_properties[] = { #if !defined(CONFIG_USER_ONLY) +DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , + HexagonTLBState *),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffff ),DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *),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_SCSIhw/hexagon/meson.build +2
-0@@ -4,3 +4,5 @@ hexagon_ss.add(files('hexagon_globalreg.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hw_arch += {'hexagon': hexagon_ss} + +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))tests/qemu-iotests/testenv.py +1
-1@@ -259,6 +259,7 @@ def __init__(self, source_dir: str, build_dir: str, ('arm', 'virt'), ('aarch64', 'virt'), ('avr', 'mega2560'), + ('hexagon', 'virt'), ('m68k', 'virt'), ('or1k', 'virt'), ('riscv32', 'virt'), --2.34.1
PATCH v4 9/9 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
@@ -290,6 +290,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \ config_all_devices.has_key('CONFIG_RISCV_IOMMU') ? ['iommu-riscv-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