Hexagon system emulation, Part 3/3
v6 cover Hexagon system emulation, Part 3/3
Hexagon sysemu part 3: device models (globalreg, TLB), machine definitions (DSP, Virt), hexagon-softmmu build config, and boot-serial-test.
Changes in v6:
- Dropped "Modify Standalone symbols"; added "Add hexagon TLB device implementation" (moved from Part 1, which now only has the header).
- globalreg: g_assert(s) -> early-return null guards; dropped public reset wrapper; memset uses sizeof(s->regs).
- Machine configs: added TYPE_HEXAGON_COMMON_MACHINE (abstract, holds ram + cfgtable_rom) and TYPE_HEXAGON_DSP_MACHINE; wired up TLB device and global-regs links; isdb symbol detection; new MAINTAINERS "Hexagon Machines" section with Pierrick as R:.
- Virt machine: re-parented to HEXAGON_COMMON_MACHINE; replaced static phandle globals with return values; moved enums into .c file; simplified realize paths.
- Build config: mttcg_supported = true; fixed reg_fields.h include.
- Picked up A-b from Philippe and R-b from Pierrick on several patches.
Patches still needing review:
- 08/09: hw/hexagon: Define hexagon "virt" machine
Brian Cain (8):
hw/hexagon: Add globalreg model hw/hexagon: Add global register tracing hw/hexagon: Add hexagon TLB device implementation hw/hexagon: Add machine configs for sysemu hw/hexagon: Add v68, sa8775-cdsp0 defs 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 | 15 +- 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 | 161 +++++++ include/hw/hexagon/hexagon_globalreg.h | 55 +++ include/hw/hexagon/virt.h | 31 ++ 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 | 224 ++++++++++ hw/hexagon/hexagon_globalreg.c | 316 +++++++++++++ hw/hexagon/hexagon_tlb.c | 466 ++++++++++++++++++++ hw/hexagon/virt.c | 463 +++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/cpu.c | 1 - target/hexagon/translate.c | 1 + tests/qtest/boot-serial-test.c | 8 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 14 + hw/hexagon/meson.build | 7 + 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 + 30 files changed, 1996 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/hexagon_tlb.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 v6 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 | 55 ++++++ hw/hexagon/hexagon_globalreg.c | 243 +++++++++++++++++++++++++ 2 files changed, 298 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 +55 -0
@@ -0,0 +1,55 @@ +/* +* 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); + +/* 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 +243 -0
243 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v6 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
@@ -3599,6 +3599,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 v6 3/9 hw/hexagon: Add hexagon TLB device implementation
In reply to Brian CainAdd the hexagon TLB QOM device model implementation.
--- hw/hexagon/hexagon_tlb.c | 466 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 466 insertions(+) create mode 100644 hw/hexagon/hexagon_tlb.c
hw/hexagon/hexagon_tlb.c new file +466 -0
@@ -0,0 +1,466 @@ +/* +* Hexagon TLB QOM Device +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/resettable.h" +#include "migration/vmstate.h" +#include "monitor/monitor.h" +#include "qapi/error.h" +#include "exec/target_page.h" +#include "target/hexagon/cpu.h" +#include "target/hexagon/cpu_bits.h" + +/* PTE (TLB entry) field extraction */ +#define GET_PTE_PPD (entry) extract64((entry), 0, 24) +#define GET_PTE_C (entry) extract64((entry), 24, 4) +#define GET_PTE_U (entry) extract64((entry), 28, 1) +#define GET_PTE_R (entry) extract64((entry), 29, 1) +#define GET_PTE_W (entry) extract64((entry), 30, 1) +#define GET_PTE_X (entry) extract64((entry), 31, 1) +#define GET_PTE_VPN (entry) extract64((entry), 32, 20) +#define GET_PTE_ASID (entry) extract64((entry), 52, 7) +#define GET_PTE_ATR0 (entry) extract64((entry), 59, 1) +#define GET_PTE_ATR1 (entry) extract64((entry), 60, 1) +#define GET_PTE_PA35 (entry) extract64((entry), 61, 1) +#define GET_PTE_G (entry) extract64((entry), 62, 1) +#define GET_PTE_V (entry) extract64((entry), 63, 1) + +/* PPD (physical page descriptor) */ +static inline uint64_t GET_PPD (uint64_t entry) +{ +return GET_PTE_PPD (entry) | (GET_PTE_PA35 (entry) <<24 ); +} + +#define NO_ASID (1 << 8) + +typedef enum { +PGSIZE_4K , +PGSIZE_16K , +PGSIZE_64K , +PGSIZE_256K , +PGSIZE_1M , +PGSIZE_4M , +PGSIZE_16M , +PGSIZE_64M , +PGSIZE_256M , +PGSIZE_1G , +}tlb_pgsize_t ; + +#define NUM_PGSIZE_TYPES (PGSIZE_1G + 1) + +static const char *pgsize_str[NUM_PGSIZE_TYPES ] = { +"4K" , +"16K" , +"64K" , +"256K" , +"1M" , +"4M" , +"16M" , +"64M" , +"256M" , +"1G" , +}; + +#define INVALID_MASK 0xffffffffLL + +static const uint64_t encmask_2_mask[] = { +0x0fffLL ,/* 4k, 0000 */ +0x3fffLL ,/* 16k, 0001 */ +0xffffLL ,/* 64k, 0010 */ +0x3ffffLL ,/* 256k, 0011 */ +0xfffffLL ,/* 1m, 0100 */ +0x3fffffLL ,/* 4m, 0101 */ +0xffffffLL ,/* 16m, 0110 */ +0x3ffffffLL ,/* 64m, 0111 */ +0xfffffffLL ,/* 256m, 1000 */ +0x3fffffffLL ,/* 1g, 1001 */ +INVALID_MASK ,/* RSVD, 1010 */ +}; + +static inline tlb_pgsize_t hex_tlb_pgsize_type (uint64_t entry) +{ +if (entry ==0 ) { +qemu_log_mask (CPU_LOG_MMU ,"%s: Supplied TLB entry was 0!\n" , + __func__); +return 0 ; + } +tlb_pgsize_t size =ctz64 (entry); +g_assert (size <NUM_PGSIZE_TYPES ); +return size; +} + +static inline uint64_t hex_tlb_page_size_bytes (uint64_t entry) +{ +return 1ull << (qemu_target_page_bits () +2 *hex_tlb_pgsize_type (entry)); +} + +static inline uint64_t hex_tlb_phys_page_num (uint64_t entry) +{ +uint32_t ppd =GET_PPD (entry); +return ppd >>1 ; +} + +static inline uint64_t hex_tlb_phys_addr (uint64_t entry) +{ +uint64_t pagemask = encmask_2_mask[hex_tlb_pgsize_type (entry)]; +uint64_t pagenum =hex_tlb_phys_page_num (entry); +uint64_t PA = (pagenum <<qemu_target_page_bits ()) & (~pagemask); +return PA ; +} + +static inline uint64_t hex_tlb_virt_addr (uint64_t entry) +{ +return (uint64_t )GET_PTE_VPN (entry) <<qemu_target_page_bits (); +} + +bool hexagon_tlb_dump_entry (Monitor *mon,uint64_t entry) +{ +if (GET_PTE_V (entry)) { +uint64_t PA =hex_tlb_phys_addr (entry); +uint64_t VA =hex_tlb_virt_addr (entry); +monitor_printf (mon,"0x%016" PRIx64": " , entry); +monitor_printf (mon,"V:%" PRId64" G:%" PRId64 +" A1:%" PRId64" A0:%" PRId64, +GET_PTE_V (entry), +GET_PTE_G (entry), +GET_PTE_ATR1 (entry), +GET_PTE_ATR0 (entry)); +monitor_printf (mon," ASID:0x%02" PRIx64" VA:0x%08" PRIx64, +GET_PTE_ASID (entry),VA ); +monitor_printf (mon, +" X:%" PRId64" W:%" PRId64" R:%" PRId64 +" U:%" PRId64" C:%" PRId64, +GET_PTE_X (entry), +GET_PTE_W (entry), +GET_PTE_R (entry), +GET_PTE_U (entry), +GET_PTE_C (entry)); +monitor_printf (mon," PA:0x%09" PRIx64" SZ:%s (0x%" PRIx64")" , +PA , pgsize_str[hex_tlb_pgsize_type (entry)], +hex_tlb_page_size_bytes (entry)); +monitor_printf (mon,"\n" ); +return true; + } + +/* Not valid */ +return false; +} + +static inline bool hex_tlb_entry_match_noperm (uint64_t entry,uint32_t asid, +uint64_t VA ) +{ +if (GET_PTE_V (entry)) { +if (GET_PTE_G (entry)) { +/* Global entry - ignore ASID */ + }else if (asid !=NO_ASID ) { +uint32_t tlb_asid =GET_PTE_ASID (entry); +if (tlb_asid != asid) { +return false; + } + } + +uint64_t page_size =hex_tlb_page_size_bytes (entry); +uint64_t page_start = +ROUND_DOWN (hex_tlb_virt_addr (entry), page_size); +if (page_start <=VA &&VA < page_start + page_size) { +return true; + } + } +return false; +} + +static inline void hex_tlb_entry_get_perm (uint64_t entry, +MMUAccessType access_type, +int mmu_idx,int *prot, +int32_t *excp,int *cause_code) +{ +bool perm_x =GET_PTE_X (entry); +bool perm_w =GET_PTE_W (entry); +bool perm_r =GET_PTE_R (entry); +bool perm_u =GET_PTE_U (entry); +bool user_idx = mmu_idx ==MMU_USER_IDX ; + +if (mmu_idx ==MMU_KERNEL_IDX ) { + *prot =PAGE_VALID |PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +return ; + } + + *prot =PAGE_VALID ; +switch (access_type) { +case MMU_INST_FETCH : +if (user_idx && !perm_u) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_FETCH_NO_UPAGE ; + }else if (!perm_x) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_FETCH_NO_XPAGE ; + } +break ; +case MMU_DATA_LOAD : +if (user_idx && !perm_u) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_PRIV_NO_UREAD ; + }else if (!perm_r) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_PRIV_NO_READ ; + } +break ; +case MMU_DATA_STORE : +if (user_idx && !perm_u) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_PRIV_NO_UWRITE ; + }else if (!perm_w) { + *excp =HEX_EVENT_PRECISE ; + *cause_code =HEX_CAUSE_PRIV_NO_WRITE ; + } +break ; + } + +if (!user_idx || perm_u) { +if (perm_x) { + *prot |=PAGE_EXEC ; + } +if (perm_r) { + *prot |=PAGE_READ ; + } +if (perm_w) { + *prot |=PAGE_WRITE ; + } + } +} + +static inline bool hex_tlb_entry_match (uint64_t entry,uint8_t asid, +uint32_t VA , +MMUAccessType access_type,hwaddr *PA , +int *prot,uint64_t *size, +int32_t *excp,int *cause_code, +int mmu_idx) +{ +if (hex_tlb_entry_match_noperm (entry, asid,VA )) { +hex_tlb_entry_get_perm (entry, access_type, mmu_idx, prot, excp, + cause_code); + *PA =hex_tlb_phys_addr (entry); + *size =hex_tlb_page_size_bytes (entry); +return true; + } +return false; +} + +static bool hex_tlb_is_match (uint64_t entry1,uint64_t entry2, +bool consider_gbit) +{ +bool valid1 =GET_PTE_V (entry1); +bool valid2 =GET_PTE_V (entry2); +uint64_t size1 =hex_tlb_page_size_bytes (entry1); +uint64_t vaddr1 =ROUND_DOWN (hex_tlb_virt_addr (entry1), size1); +uint64_t size2 =hex_tlb_page_size_bytes (entry2); +uint64_t vaddr2 =ROUND_DOWN (hex_tlb_virt_addr (entry2), size2); +int asid1 =GET_PTE_ASID (entry1); +int asid2 =GET_PTE_ASID (entry2); +bool gbit1 =GET_PTE_G (entry1); +bool gbit2 =GET_PTE_G (entry2); + +if (!valid1 || !valid2) { +return false; + } + +if (((vaddr1 <= vaddr2) && (vaddr2 < (vaddr1 + size1))) || + ((vaddr2 <= vaddr1) && (vaddr1 < (vaddr2 + size2)))) { +if (asid1 == asid2) { +return true; + } +if ((consider_gbit && gbit1) || gbit2) { +return true; + } + } +return false; +} + +/* Public API */ + +uint64_t hexagon_tlb_read (HexagonTLBState *tlb,uint32_t index) +{ +g_assert (index < tlb->num_entries); +return tlb->entries[index]; +} + +void hexagon_tlb_write (HexagonTLBState *tlb,uint32_t index,uint64_t value) +{ +g_assert (index < tlb->num_entries); + tlb->entries[index] = value; +} + +bool hexagon_tlb_find_match (HexagonTLBState *tlb,uint32_t asid, +uint32_t VA ,MMUAccessType access_type, +hwaddr *PA ,int *prot,uint64_t *size, +int32_t *excp,int *cause_code,int mmu_idx) +{ + *PA =0 ; + *prot =0 ; + *size =0 ; + *excp =0 ; + *cause_code =0 ; + +for (uint32_t i =0 ; i < tlb->num_entries; i++) { +if (hex_tlb_entry_match (tlb->entries[i], asid,VA , access_type, +PA , prot, size, excp, cause_code, mmu_idx)) { +return true; + } + } +return false; +} + +uint32_t hexagon_tlb_lookup (HexagonTLBState *tlb,uint32_t asid, +uint32_t VA ,int *cause_code) +{ +uint32_t not_found =0x80000000 ; +uint32_t idx = not_found; + +for (uint32_t i =0 ; i < tlb->num_entries; i++) { +uint64_t entry = tlb->entries[i]; +if (hex_tlb_entry_match_noperm (entry, asid,VA )) { +if (idx != not_found) { + *cause_code =HEX_CAUSE_IMPRECISE_MULTI_TLB_MATCH ; +break ; + } + idx = i; + } + } + +if (idx == not_found) { +qemu_log_mask (CPU_LOG_MMU , +"%s: 0x%" PRIx32", 0x%08" PRIx32" => NOT FOUND\n" , + __func__, asid,VA ); + }else { +qemu_log_mask (CPU_LOG_MMU , +"%s: 0x%" PRIx32", 0x%08" PRIx32" => %d\n" , + __func__, asid,VA , idx); + } + +return idx; +} + +/* +* Return codes: +* 0 or positive index of match +* -1 multiple matches +* -2 no match +*/ +int hexagon_tlb_check_overlap (HexagonTLBState *tlb,uint64_t entry, +uint64_t index) +{ +int matches =0 ; +int last_match =0 ; + +for (uint32_t i =0 ; i < tlb->num_entries; i++) { +if (hex_tlb_is_match (entry, tlb->entries[i], false)) { + matches++; + last_match = i; + } + } + +if (matches ==1 ) { +return last_match; + } +if (matches ==0 ) { +return -2 ; + } +return -1 ; +} + +void hexagon_tlb_dump (Monitor *mon,HexagonTLBState *tlb) +{ +for (uint32_t i =0 ; i < tlb->num_entries; i++) { +hexagon_tlb_dump_entry (mon, tlb->entries[i]); + } +} + +uint32_t hexagon_tlb_get_num_entries (HexagonTLBState *tlb) +{ +return tlb->num_entries; +} + +/* QOM lifecycle */ + +static void hexagon_tlb_init (Object *obj) +{ +} + +static void hexagon_tlb_realize (DeviceState *dev,Error **errp) +{ +HexagonTLBState *s =HEXAGON_TLB (dev); + +if (s->num_entries ==0 || s->num_entries >MAX_TLB_ENTRIES ) { +error_setg (errp,"Invalid TLB num-entries: %" PRIu32, + s->num_entries); +return ; + } + s->entries =g_new0 (uint64_t, s->num_entries); +} + +static void hexagon_tlb_unrealize (DeviceState *dev) +{ +HexagonTLBState *s =HEXAGON_TLB (dev); +g_free (s->entries); + s->entries =NULL ; +} + +static void hexagon_tlb_reset_hold (Object *obj,ResetType type) +{ +HexagonTLBState *s =HEXAGON_TLB (obj); +if (s->entries) { +memset (s->entries,0 ,sizeof (uint64_t ) * s->num_entries); + } +} + +static const VMStateDescription vmstate_hexagon_tlb = { + .name ="hexagon-tlb" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (const VMStateField []) { +VMSTATE_UINT32 (num_entries, HexagonTLBState), +VMSTATE_VARRAY_UINT32_ALLOC (entries, HexagonTLBState, num_entries, +0 , vmstate_info_uint64, uint64_t), +VMSTATE_END_OF_LIST () + }, +}; + +static const Property hexagon_tlb_properties[] = { +DEFINE_PROP_UINT32 ("num-entries" , HexagonTLBState, num_entries, +MAX_TLB_ENTRIES ), +}; + +static void hexagon_tlb_class_init (ObjectClass *klass,const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + + dc->realize = hexagon_tlb_realize; + dc->unrealize = hexagon_tlb_unrealize; + rc->phases.hold = hexagon_tlb_reset_hold; + dc->vmsd = &vmstate_hexagon_tlb; + dc->user_creatable = false; +device_class_set_props (dc, hexagon_tlb_properties); +} + +static const TypeInfo hexagon_tlb_info = { + .name =TYPE_HEXAGON_TLB , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (HexagonTLBState), + .instance_init = hexagon_tlb_init, + .class_init = hexagon_tlb_class_init, +}; + +static void hexagon_tlb_register_types (void ) +{ +type_register_static (&hexagon_tlb_info); +} + +type_init (hexagon_tlb_register_types)
Signature · 1 line
2.34.1
PATCH v6 4/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 | 14 +- include/hw/hexagon/hexagon.h | 161 ++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 +++++++ hw/hexagon/hexagon_dsp.c | 220 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 4 + hw/hexagon/meson.build | 6 + hw/meson.build | 1 + 10 files changed, 471 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 +12 -2
@@ -260,8 +260,6 @@ F: configs/targets/hexagon-linux-user/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdbstub/gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst -F: docs/system/hexagon/ -F: docs/devel/hexagon-sys.rst T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parser
@@ -1348,6 +1346,18 @@ F: pc-bios/hppa-firmware.img F: roms/seabios-hppa/ F: tests/functional/hppa/ +Hexagon Machines +---------------- +V66G_1024, V68N_1024, sa8775-cdsp0 +M: Brian Cain <[email protected]> +R: Pierrick Bouvier <[email protected]> +S: Supported +F: hw/hexagon/ +F: include/hw/hexagon/ +F: configs/devices/hexagon-softmmu/default.mak +F: docs/system/hexagon/ +F: docs/devel/hexagon-sys.rst + LoongArch Machines ------------------ Virt
include/hw/hexagon/hexagon.h new file +161 -0
161 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 +220 -0
220 lines not on this page · raw message
system/qdev-monitor.c +1 -1
@@ -71,7 +71,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
@@ -53,6 +53,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 +4 -0
@@ -0,0 +1,4 @@ +config HEX_DSP + bool + default y + depends on HEXAGON
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
PATCH v6 5/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 v6 6/9 hw/hexagon: Add support for cfgbase
In reply to Brian CainFrom: Sid Manning <[email protected]>
--- hw/hexagon/hexagon_dsp.c | 4 ++++ target/hexagon/cpu.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
hw/hexagon/hexagon_dsp.c +4 -0
@@ -161,6 +161,10 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(tlb_dev), &error_fatal);qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); } + +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
@@ -399,7 +399,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 v6 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/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 13 ++++++++++++- 7 files changed, 31 insertions(+), 7 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
@@ -257,6 +257,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
@@ -38,12 +38,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegState;#include "hw/core/registerfields.h" #include "qemu/bitmap.h" -#ifndef CONFIG_USER_ONLY -#error "Hexagon does not support system emulation" -#endif - -#ifndef CONFIG_USER_ONLY -#endif +#include "target/hexagon/reg_fields.h" #define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
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
Re: [PATCH v6 7/9] target/hexagon: add build config for softmmu
Quoted 23 lines · Brian Cain
Reviewed-by Taylor Simpson <[email protected]>Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 1 + configs/devices/hexagon-softmmu/default.mak | 7 +++++++ configs/targets/hexagon-softmmu.mak | 7 +++++++ target/hexagon/cpu.h | 7 +------ target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 13 ++++++++++++- 7 files changed, 31 insertions(+), 7 deletions(-)create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 target/hexagon/Kconfig
configs/devices/hexagon-softmmu/default.mak new file +0
-0
configs/devices/hexagon-softmmu/default.mak line 7
Quoted 7 lines
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
Please remove that CONFIG_L2VIC line: this symbol is never defined AFAICT. No need to repost.
PATCH v6 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 | 31 ++ hw/hexagon/virt.c | 463 ++++++++++++++++++++ hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 1 + tests/qemu-iotests/testenv.py | 1 + 7 files changed, 508 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 +31 -0
@@ -0,0 +1,31 @@ +/* +* 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/hexagon/hexagon.h" +#include "target/hexagon/cpu.h" + +struct HexagonVirtMachineState { +HexagonCommonMachineState parent_obj; + +int fdt_size; +MemoryRegion *sys; +MemoryRegion tcm; +MemoryRegion vtcm; +MemoryRegion bios; +DeviceState *l2vic; +Clock *apb_clk; +}; + +void hexagon_load_fdt (const struct HexagonVirtMachineState *vms); + +#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 +463 -0
463 lines not on this page · raw message
hw/hexagon/Kconfig +10 -0
@@ -2,3 +2,13 @@ config HEX_DSP bool default y depends on HEXAGON + +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 +1 -0
@@ -2,5 +2,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')) +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c')) hw_arch += {'hexagon': hexagon_ss}
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 v6 8/9] hw/hexagon: Define hexagon "virt" machine
Quoted 15 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 | 31 ++ hw/hexagon/virt.c | 463 ++++++++++++++++++++ hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 1 + tests/qemu-iotests/testenv.py | 1 + 7 files changed, 508 insertions(+) create mode 100644 include/hw/hexagon/virt.h create mode 100644 hw/hexagon/virt.c
Re: [PATCH v6 8/9] hw/hexagon: Define hexagon "virt" machine
In reply to Brian CainHi Brian,
Quoted 16 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 | 31 ++ hw/hexagon/virt.c | 463 ++++++++++++++++++++ hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 1 + tests/qemu-iotests/testenv.py | 1 + 7 files changed, 508 insertions(+)create mode 100644
include/hw/hexagon/virt.h
create mode 100644hw/hexagon/virt.c
hw/hexagon/virt.c line 121
Quoted 3 lines
hw/hexagon/virt.c new file +3
-0+static int32_t fdt_add_hvm_pic_node (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg) +{
[*] Dead code (see below)
Quoted 37 lines
hw/hexagon/virt.c new file +35
-0+MachineState *ms =MACHINE (vms); +int32_t irq_phandle =qemu_fdt_alloc_phandle (ms->fdt); + +qemu_fdt_setprop_cell (ms->fdt,"/soc" ,"interrupt-parent" , + irq_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_phandle); + +sysbus_mmio_map (SYS_BUS_DEVICE (vms->l2vic),1 , + m_cfg->cfgtable.fastl2vic_base <<16 ); + +return irq_phandle; +} +static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart, +int32_t irq_phandle,int32_t clk_phandle) +{ +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;
hw/hexagon/virt.c line 200
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+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));
[*] Dead code (see below)
hw/hexagon/virt.c line 209
Quoted 9 lines
hw/hexagon/virt.c new file +9
-0+ } + + 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) {
[*] Dead code (see below)
Quoted 31 lines
hw/hexagon/virt.c new file +29
-0+qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , +32 + irq,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_phandle); + } +qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clk_phandle, + clk_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_virtio_devices (const HexagonVirtMachineState *vms, +int32_t irq_phandle) +{ +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);
hw/hexagon/virt.c line 269
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+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_phandle); + +sysbus_create_simple ( +"virtio-mmio" , base, +qdev_get_gpio_in (vms->l2vic, irqmap[VIRT_MMIO ] + i));
[*] Unreachable otherwise that'd crash... Dead code.
Quoted 72 lines
hw/hexagon/virt.c new file +70
-0+ +g_free (nodename); + } +} +static void virt_init (MachineState *ms) +{ +HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms); +const struct hexagon_machine_config *m_cfg = &v68n_1024; +DeviceState *gsregs_dev; +DeviceState *tlb_dev; +DeviceState *cpu0; +int32_t irq_phandle =-1 ; +int32_t clk_phandle; + +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->parent_obj.ram,NULL ,"ddr.ram" , + ms->ram_size, &error_fatal); +memory_region_add_subregion (vms->sys,0x0 , &vms->parent_obj.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->parent_obj.cfgtable_rom,NULL , +"config_table.rom" ,sizeof (m_cfg->cfgtable), + &error_fatal); +memory_region_add_subregion (vms->sys, m_cfg->cfgbase, + &vms->parent_obj.cfgtable_rom); +fdt_add_hvx (vms, m_cfg); + + 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); + + cpu0 =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 ) { + cpu0 =DEVICE (cpu); +if (ms->kernel_filename) { +uint64_t entry =load_kernel (vms); +qdev_prop_set_uint32 (cpu0,"exec-start-addr" , entry); + }else if (ms->firmware) { +uint64_t entry =load_bios (vms); +qdev_prop_set_uint32 (cpu0,"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",
hw/hexagon/virt.c line 408
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+ OBJECT(gsregs_dev), &error_fatal); +object_property_set_link (OBJECT (cpu),"tlb" , +OBJECT (tlb_dev), &error_fatal); + +qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); + } +/* TODO: enable l2vic when l2vic device arrives */ +if (object_class_by_name ("l2vic" )) { + vms->l2vic = sysbus_create_varargs( + "l2vic", m_cfg->l2vic_base,
I'm really confused by this code, since no "l2vic" exist. Yet I suppose. Can't we just remove this code and re-introduce once with the former addition? I'd also remove the fdt_add_hvm_pic_node() and fdt_add_virtio_devices() methods.
Normally all code should be used / tested, and IIUC [*] is dead code.
Quoted 14 lines
hw/hexagon/virt.c new file +14
-0+qdev_get_gpio_in (cpu0,0 ), +qdev_get_gpio_in (cpu0,1 ), +qdev_get_gpio_in (cpu0,2 ), +qdev_get_gpio_in (cpu0,3 ), +qdev_get_gpio_in (cpu0,4 ), +qdev_get_gpio_in (cpu0,5 ), +qdev_get_gpio_in (cpu0,6 ), + qdev_get_gpio_in(cpu0, 7), NULL); + + irq_phandle =fdt_add_hvm_pic_node (vms, m_cfg); +fdt_add_virtio_devices (vms, irq_phandle); +fdt_add_gpt_node (vms); + } +
hw/hexagon/virt.c line 432
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+fdt_add_cpu_nodes (vms); + clk_phandle =fdt_add_clocks (vms); +fdt_add_uart (vms,VIRT_UART0 , irq_phandle, clk_phandle); + +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); +}
Rest of the patch LGTM.
Regards,
Phil.
PATCH v6 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
@@ -293,6 +293,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