Hexagon system emulation - Part 3/3
v7 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
- Hexagon TLB device implementation
- 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 v8 + Part 2 v6.
Changes since v6:
- Moved hexagon TLB device implementation from Part 1 into this series as a new patch ("Add hexagon TLB device implementation"), following the interface declaration now carried by Part 1
- Removed "Modify Standalone symbols" patch; incorporated changes directly into "Add machine configs for sysemu"
- Dropped MAINTAINERS doc path removals from "Add machine configs"
- "add build config for softmmu": removed CONFIG_L2VIC from default.mak; removed stale #ifndef CONFIG_USER_ONLY block from cpu.h; added Acked-by from Philippe
- "Define hexagon virt machine": removed l2vic integration; simplified fdt_add_uart() to drop irq_phandle parameter; removed VIRT_QTMR, VIRT_GPT, VIRT_MMIO memmap/irqmap entries; added R-b from Pierrick
Previous versions:
v6: https://lore.kernel.org/qemu-devel/[email protected]/
v5: https://lore.kernel.org/qemu-devel/[email protected]/
v4: https://lore.kernel.org/qemu-devel/[email protected]/
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 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 | 13 + configs/devices/hexagon-softmmu/default.mak | 7 + 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 | 30 ++ target/hexagon/cpu.h | 5 +- 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 | 347 +++++++++++++++++++++ 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, 1878 insertions(+), 7 deletions(-)
--
2.34.1
PATCH v7 1/1 hw/hexagon: Add machine configs for sysemu
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.
--- MAINTAINERS | 12 ++ 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(+), 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 +12 -0
@@ -1353,6 +1353,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 v7 1/1 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 v7 1/1 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 v7 1/1 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 v7 1/1 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 | 30 ++ hw/hexagon/virt.c | 347 ++++++++++++++++++++ hw/hexagon/Kconfig | 10 + hw/hexagon/meson.build | 1 + tests/qemu-iotests/testenv.py | 1 + 7 files changed, 391 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,4 +3,5 @@ # 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
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 +30 -0
@@ -0,0 +1,30 @@ +/* +* 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; +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 +347 -0
347 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
PATCH v7 1/1 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 v7 1/1 hw/hexagon: Add globalreg model
In reply to Brian CainSome 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 v7 1/1 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
PATCH v7 1/1 target/hexagon: add build config for softmmu
In reply to Brian Cain--- MAINTAINERS | 1 + configs/devices/hexagon-softmmu/default.mak | 6 ++++++ configs/targets/hexagon-softmmu.mak | 7 +++++++ target/hexagon/cpu.h | 5 +---- target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 13 ++++++++++++- 7 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 target/hexagon/Kconfig
MAINTAINERS +1 -0
@@ -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: tests/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 +6 -0
@@ -0,0 +1,6 @@ +# 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
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 -4
@@ -38,10 +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 - +#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