Skip to content

Commit 1ed0a26

Browse files
committed
Implement a portion of vmgetinfo
Signed-off-by: Brian Cain <[email protected]>
1 parent d83a7e3 commit 1ed0a26

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

target/hexagon/helper.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ DEF_HELPER_2(start, void, env, i32)
5353
DEF_HELPER_1(stop, void, env)
5454

5555
DEF_HELPER_4(vmnewmap, void, env, i32, i32, i32)
56+
DEF_HELPER_2(vmgetinfo, i32, env, i32)
5657
#endif
5758

5859
DEF_HELPER_5(check_vtcm_memcpy, void, env, i32, i32, i32, i32)

target/hexagon/hex_vm.c.inc

+1-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ static inline void gen_vmrte(void)
306306

307307
static inline void gen_vmgetinfo(void)
308308
{
309-
/* FIXME */
310-
tcg_gen_movi_tl(hex_gpr[HEX_REG_R00], 0);
309+
gen_helper_vmgetinfo(hex_gpr[HEX_REG_R00], tcg_env, hex_gpr[HEX_REG_R00]);
311310
}
312311
static inline void gen_vmtimerop(void)
313312
{

target/hexagon/op_helper.c

+75
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,7 @@ void HELPER(check_vtcm_memcpy)(CPUHexagonState *env, uint32_t dst, uint32_t src,
27092709
}
27102710

27112711

2712+
#if !defined(CONFIG_USER_ONLY)
27122713
typedef enum {
27132714
HEXVM_ENTRY_DIRECTORY,
27142715
HEXVM_ENTRY_TABLE,
@@ -2849,6 +2850,80 @@ void HELPER(vmnewmap)(CPUHexagonState *env, uint32_t map_type, uint32_t input,
28492850
env->gpr[HEX_REG_R00] = fail ? -1 : 0;
28502851
}
28512852

2853+
typedef enum {
2854+
HEX_VM_INFO_BUILD_ID,
2855+
HEX_VM_INFO_BOOT_FLAGS,
2856+
HEX_VM_INFO_STLB,
2857+
HEX_VM_INFO_SYSCFG,
2858+
HEX_VM_INFO_LIVELOCK,
2859+
HEX_VM_INFO_REV,
2860+
HEX_VM_INFO_SSBASE,
2861+
HEX_VM_INFO_TLB_FREE,
2862+
HEX_VM_INFO_TLB_SIZE,
2863+
HEX_VM_INFO_PHYSADDR,
2864+
HEX_VM_INFO_TCM_BASE,
2865+
HEX_VM_INFO_L2MEM_SIZE_BYTES,
2866+
HEX_VM_INFO_TCM_SIZE,
2867+
HEX_VM_INFO_H2K_PGSIZE,
2868+
HEX_VM_INFO_H2K_NPAGES,
2869+
HEX_VM_INFO_L2VIC_BASE,
2870+
HEX_VM_INFO_TIMER_BASE,
2871+
HEX_VM_INFO_TIMER_INT,
2872+
HEX_VM_INFO_ERROR,
2873+
HEX_VM_INFO_HTHREADS,
2874+
HEX_VM_INFO_L2TAG_SIZE,
2875+
HEX_VM_INFO_L2CFG_BASE,
2876+
HEX_VM_INFO_RESERVED_00,
2877+
HEX_VM_INFO_CFGBASE,
2878+
HEX_VM_INFO_HVX_VLENGTH,
2879+
HEX_VM_INFO_HVX_CONTEXTS,
2880+
HEX_VM_INFO_HVX_SWITCH,
2881+
HEX_VM_INFO_MAX,
2882+
} HexVmInfoType;
2883+
2884+
2885+
uint32_t HELPER(vmgetinfo)(CPUHexagonState *env, uint32_t info_type)
2886+
{
2887+
HexagonCPU *cpu = env_archcpu(env);
2888+
hwaddr cfgtable_mem;
2889+
uint32_t cfg_val;
2890+
2891+
switch (info_type) {
2892+
case HEX_VM_INFO_BUILD_ID:
2893+
return 0x0001;
2894+
case HEX_VM_INFO_BOOT_FLAGS:
2895+
/* TODO: USE_TCM */
2896+
return 0;
2897+
case HEX_VM_INFO_STLB:
2898+
/* TODO: sets/ways/size/etc */
2899+
return 0;
2900+
case HEX_VM_INFO_SYSCFG:
2901+
/* TODO: host syscfg reg? */
2902+
return 0;
2903+
case HEX_VM_INFO_REV:
2904+
return cpu->rev_reg;
2905+
case HEX_VM_INFO_L2MEM_SIZE_BYTES:
2906+
/* location of l2size_kb entry: */
2907+
cfgtable_mem = cpu->config_table_addr + 0x44;
2908+
cpu_physical_memory_write(cfgtable_mem, &cfg_val, sizeof(cfg_val));
2909+
return cfg_val * 1024;
2910+
case HEX_VM_INFO_TCM_SIZE:
2911+
/* TODO: derive from l2 tags? */
2912+
return 0;
2913+
case HEX_VM_INFO_TCM_BASE:
2914+
cfgtable_mem = cpu->config_table_addr + 0;
2915+
cpu_physical_memory_write(cfgtable_mem, &cfg_val, sizeof(cfg_val));
2916+
return cfg_val << 16;
2917+
case HEX_VM_INFO_L2TAG_SIZE:
2918+
cfgtable_mem = cpu->config_table_addr + 0x40;
2919+
cpu_physical_memory_write(cfgtable_mem, &cfg_val, sizeof(cfg_val));
2920+
return cfg_val;
2921+
default:
2922+
return (uint32_t) -1;
2923+
}
2924+
}
2925+
#endif
2926+
28522927
/* These macros can be referenced in the generated helper functions */
28532928
#define warn(...) /* Nothing */
28542929
#define fatal(...) g_assert_not_reached();

0 commit comments

Comments
 (0)