Skip to content

Commit aea8b67

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

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

target/hexagon/helper.h

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,79 @@ void HELPER(vmnewmap)(CPUHexagonState *env, uint32_t map_type, uint32_t input,
28492849
env->gpr[HEX_REG_R00] = fail ? -1 : 0;
28502850
}
28512851

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

0 commit comments

Comments
 (0)