Hi Matheus,
On 1/9/26 21:27, Matheus Tavares Bernardino wrote:
Baremetal Hexagon programs use semihosting to enumerate host
directories via OPENDIR, READDIR, and CLOSEDIR calls. The list of
open directory handles are global to all CPUs, so that guest
index values map back to host DIR pointers across calls.
Also add functional tests for the new semihosting ops.
Signed-off-by: Matheus Tavares Bernardino <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
---
Note: based on
https://lore.kernel.org/qemu-devel/[email protected]/
The added test was verified on Ubuntu x86-64, Debian PowerPC
(big-endian) and Windows.
hw/hexagon/hexagon_dsp.c | 7 ++
hw/hexagon/virt.c | 7 ++
target/hexagon/cpu.h | 1 +
target/hexagon/hexswi.c | 83 +++++++++++++++++++++++
tests/functional/hexagon/test_systests.py | 9 +++
5 files changed, 107 insertions(+)
diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c
index 2198436a44..4c6aad886e 100644
--- a/hw/hexagon/hexagon_dsp.c
+++ b/hw/hexagon/hexagon_dsp.c
@@ -141,6 +141,13 @@ static void hexagon_common_init(MachineState *machine,
Rev_t rev,
for (int i = 0; i < machine->smp.cpus; i++) {
hex_subsys_realize_cpu(hms, DEVICE(cpus[i]), (i == 0));
+ CPUHexagonState *env = &cpus[i]->env;
+ if (i == 0) {
+ env->g_dir_list = g_malloc0(sizeof(GList *));
+ } else {
+ CPUHexagonState *env0 = cpu_env(qemu_get_cpu(0));
+ env->g_dir_list = env0->g_dir_list;
env->g_dir_list = &cpus[0]->env->g_dir_list;
+ }
}
}
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index c50fbb3f72..fd2cb96cd2 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -145,6 +145,7 @@ typedef struct CPUArchState {
uint32_t tlb_lock_count;
uint32_t k0_lock_count;
uint64_t t_cycle_count;
+ GList **g_dir_list;
But I'd rather the QOM layout to be:
struct HexagonClusterState {
CPUClusterState parent_obj;
struct {
GList **g_dir_list;
} semihosting;
};
struct HexagonCommonMachineState {
MachineState parent_obj;
MemoryRegion ram;
MemoryRegion cfgtable_rom;
MemoryRegion vtcm;
HexagonClusterState cluster;
...
};
Regards,
Phil.