diff --git a/booter/booter.c b/booter/booter.c index 071702bc6..d704aeb9d 100644 --- a/booter/booter.c +++ b/booter/booter.c @@ -23,7 +23,6 @@ #include #include -#include #include #define VM_BEST_PRIO 0 @@ -797,7 +796,7 @@ void clade_setup(unsigned int idx, long offset) { h2_hwconfig_clade_set_reg(CLADE_REG_REGION, region_hi); clade_region = region_hi; - H2K_set_syscfg(h2_info(INFO_SYSCFG) | SYSCFG_CLADEN); // enable clade + h2_hwconfig_syscfg_set(h2_info(INFO_SYSCFG) | SYSCFG_CLADEN); // enable clade } else if (region_hi != clade_region) { // has to be identical for all concurrent clade guests FAIL("\tCLADE region address mismatch", ""); } @@ -1157,10 +1156,10 @@ void boot_vm(unsigned int idx) { BOOTER_PRINTF("Boot VM index %d, ID %d\n", idx, vm_params[idx].id); if (~0L != vm_params[idx].ccr) { - regval = H2K_get_ccr(); + regval = h2_hwconfig_ccr_get(); BOOTER_PRINTF("\told value for ccr: 0x%08x\n",regval); - H2K_set_ccr(vm_params[idx].ccr); - regval = H2K_get_ccr(); + h2_hwconfig_ccr_set(vm_params[idx].ccr); + regval = h2_hwconfig_ccr_get(); BOOTER_PRINTF("\tnew value for ccr: 0x%08x\n",regval); } #if ARCHV >= 73 // FIXME: Make this 79 if there is a separate build @@ -1389,7 +1388,7 @@ void run(unsigned int idx) { } } while (!done); - H2K_set_syscfg(h2_info(INFO_SYSCFG) & ~SYSCFG_CLADEN); // disable clade + h2_hwconfig_syscfg_set(h2_info(INFO_SYSCFG) & ~SYSCFG_CLADEN); // disable clade pd_num = 0; // reset h2_galloc_reset(&tcm_alloc, 0); @@ -1692,9 +1691,9 @@ typedef struct { } syscfg_field; syscfg_field syscfg[] = { - {"BQ", SYSCFG_BQ_BIT, SYSCFG_BQ_LEN, H2K_set_syscfg}, - {"DMT", SYSCFG_DMT_BIT, SYSCFG_DMT_LEN, H2K_set_syscfg}, - {"CLADEN", SYSCFG_CLADEN_BIT, SYSCFG_CLADEN_LEN, H2K_set_syscfg}, + {"BQ", SYSCFG_BQ_BIT, SYSCFG_BQ_LEN, (void (*)(unsigned int))h2_hwconfig_syscfg_set}, + {"DMT", SYSCFG_DMT_BIT, SYSCFG_DMT_LEN, (void (*)(unsigned int))h2_hwconfig_syscfg_set}, + {"CLADEN", SYSCFG_CLADEN_BIT, SYSCFG_CLADEN_LEN, (void (*)(unsigned int))h2_hwconfig_syscfg_set}, {"L2WB", SYSCFG_L2WB_BIT, SYSCFG_L2WB_LEN, set_l2wb}, {NULL, 0, 0} }; @@ -1784,7 +1783,7 @@ unsigned int process_line(int argc, char **argv, unsigned int idx) { regval = h2_info(INFO_SYSCFG); BOOTER_PRINTF("Old value for syscfg: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_syscfg(regval); + h2_hwconfig_syscfg_set(regval); regval = h2_info(INFO_SYSCFG); BOOTER_PRINTF("New value for syscfg: 0x%08x\n",regval); argc -= 2; argv += 2; @@ -1795,7 +1794,7 @@ unsigned int process_line(int argc, char **argv, unsigned int idx) { regval = h2_info(INFO_LIVELOCK); BOOTER_PRINTF("Old value for livelock: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_livelock(regval); + h2_hwconfig_livelock_set(regval); regval = h2_info(INFO_LIVELOCK); BOOTER_PRINTF("New value for livelock: 0x%08x\n",regval); argc -= 2; argv += 2; @@ -1803,55 +1802,55 @@ unsigned int process_line(int argc, char **argv, unsigned int idx) { } else if (0 == strcmp(argv[0],"--turkey")) { if (argc < 2) die_usage(); - regval = H2K_get_turkey(); + regval = h2_hwconfig_turkey_get(); BOOTER_PRINTF("Old value for turkey: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_turkey(regval); - regval = H2K_get_turkey(); + h2_hwconfig_turkey_set(regval); + regval = h2_hwconfig_turkey_get(); BOOTER_PRINTF("New value for turkey: 0x%08x\n",regval); argc -= 2; argv += 2; continue; } else if (0 == strcmp(argv[0],"--turkey")) { if (argc < 2) die_usage(); - regval = H2K_get_turkey(); + regval = h2_hwconfig_turkey_get(); printf("Old value for turkey: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_turkey(regval); - regval = H2K_get_turkey(); + h2_hwconfig_turkey_set(regval); + regval = h2_hwconfig_turkey_get(); printf("New value for turkey: 0x%08x\n",regval); argc -= 2; argv += 2; continue; } else if (0 == strcmp(argv[0],"--duck")) { if (argc < 2) die_usage(); - regval = H2K_get_duck(); + regval = h2_hwconfig_duck_get(); BOOTER_PRINTF("Old value for duck: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_duck(regval); - regval = H2K_get_duck(); + h2_hwconfig_duck_set(regval); + regval = h2_hwconfig_duck_get(); BOOTER_PRINTF("New value for duck: 0x%08x\n",regval); argc -= 2; argv += 2; continue; } else if (0 == strcmp(argv[0],"--chicken")) { if (argc < 2) die_usage(); - regval = H2K_get_chicken(); + regval = h2_hwconfig_chicken_get(); BOOTER_PRINTF("Old value for chicken: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_chicken(regval); - regval = H2K_get_chicken(); + h2_hwconfig_chicken_set(regval); + regval = h2_hwconfig_chicken_get(); BOOTER_PRINTF("New value for chicken: 0x%08x\n",regval); argc -= 2; argv += 2; continue; } else if (0 == strcmp(argv[0],"--rgdr")) { if (argc < 2) die_usage(); - regval = H2K_get_rgdr(); + regval = h2_hwconfig_rgdr_get(); BOOTER_PRINTF("Old value for rgdr: 0x%08x\n",regval); regval = strtoul(argv[1],NULL,0); - H2K_set_rgdr(regval); - regval = H2K_get_rgdr(); + h2_hwconfig_rgdr_set(regval); + regval = h2_hwconfig_rgdr_get(); BOOTER_PRINTF("New value for rgdr: 0x%08x\n",regval); argc -= 2; argv += 2; continue; diff --git a/kernel/event/error/test/test.c b/kernel/event/error/test/test.c index b02fb1068..95dd1402a 100644 --- a/kernel/event/error/test/test.c +++ b/kernel/event/error/test/test.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -106,11 +107,7 @@ void TH_call_error() int main() { h2_init(NULL); -#if ARCHV <= 3 - asm (" %0 = sgp\n" : "=r"(me)); -#else - asm (" %0 = sgp0\n" : "=r"(me)); -#endif + me = H2K_get_sgp(); /* * Put ourselves in guest mode, but don't have an EVB registered. * We expect this to call thread_fatal diff --git a/kernel/event/fastint/test/test.c b/kernel/event/fastint/test/test.c index 110ae33dd..d2c7b56d8 100644 --- a/kernel/event/fastint/test/test.c +++ b/kernel/event/fastint/test/test.c @@ -12,6 +12,7 @@ #include #include #include +#include H2K_thread_context *TH_me; u32_t TH_intno; @@ -59,12 +60,8 @@ int TH_good_interrupt(u32_t intno) if ((u32_t)(sp_check - ((u32_t)(&H2K_fastint_contexts[0]))) > ((u32_t)FASTINT_CONTEXT_SIZE)) { FAIL("Not fastint context sp"); } -#if ARCHV <= 3 - asm ( " %0 = sgp " : "=r"(sgp_check)); -#else - asm ( " %0 = sgp0 " : "=r"(sgp_check)); -#endif - if ((u32_t)(sgp_check) != ((u32_t)(&H2K_fastint_contexts[0]))) { + sgp_check = (u32_t)H2K_get_sgp(); + if (sgp_check != ((u32_t)(&H2K_fastint_contexts[0]))) { FAIL("Not fastint context sgp"); } return 0; @@ -79,12 +76,8 @@ int TH_good_interrupt_ackl2(u32_t intno) if ((u32_t)(sp_check - ((u32_t)(&H2K_fastint_contexts[0]))) > ((u32_t)FASTINT_CONTEXT_SIZE)) { FAIL("Not fastint context sp"); } -#if ARCHV <= 3 - asm ( " %0 = sgp " : "=r"(sgp_check)); -#else - asm ( " %0 = sgp0 " : "=r"(sgp_check)); -#endif - if ((u32_t)(sgp_check) != ((u32_t)(&H2K_fastint_contexts[0]))) { + sgp_check = (u32_t)H2K_get_sgp(); + if (sgp_check != ((u32_t)(&H2K_fastint_contexts[0]))) { FAIL("Not fastint context sgp"); } return 1; diff --git a/kernel/thread/create/create.ref.c b/kernel/thread/create/create.ref.c index fa716d75b..be7e3afb1 100644 --- a/kernel/thread/create/create.ref.c +++ b/kernel/thread/create/create.ref.c @@ -94,7 +94,7 @@ IN_SECTION(".text.misc.create") s32_t H2K_thread_create_no_squash(u32_t pc, u32_ } tmp->ssr_guest = 1; // start in guest mode - tmp->ssr_um = 1; + tmp->ssr_um = me->ssr_um; // inherit caller's user mode bit tmp->ssr_asid = (u8_t)asid; #ifdef HAVE_EXTENSIONS tmp->ssr_xa = EXT_NO_EXT; diff --git a/kernel/thread/state/state.ref.c b/kernel/thread/state/state.ref.c index eac50c4df..6cd547f0c 100644 --- a/kernel/thread/state/state.ref.c +++ b/kernel/thread/state/state.ref.c @@ -7,6 +7,7 @@ #include #include #include +#include IN_SECTION(".text.core.state") u64_t H2K_thread_state(H2K_id_t id, u32_t offset, H2K_thread_context *me) { u64_t val; @@ -15,9 +16,7 @@ IN_SECTION(".text.core.state") u64_t H2K_thread_state(H2K_id_t id, u32_t offset, // Special case, return SGP0 register if (offset == CONTEXT_PSEUDO_SGP0) { - void *sgp; - asm (" %0 = sgp0" : "=r"(sgp)); - return (u64_t)sgp; + return (u64_t)H2K_get_sgp(); } // Special case, return IMASK register diff --git a/kernel/traps/hwconfig/hwconfig.h b/kernel/traps/hwconfig/hwconfig.h index 10e8562ed..1515ca37f 100644 --- a/kernel/traps/hwconfig/hwconfig.h +++ b/kernel/traps/hwconfig/hwconfig.h @@ -46,6 +46,20 @@ u32_t H2K_trap_hwconfig_getvwctrl(u32_t unused, void *unusedp, u32_t unused2, u3 u32_t H2K_trap_hwconfig_setvwctrl(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); u32_t H2K_trap_hwconfig_get_dpm_voltlimitmgmt_reg(u32_t unused, void *unusedp, u32_t offset, u32_t unused3, H2K_thread_context *me)IN_SECTION(".text.config.hwconfig"); u32_t H2K_trap_hwconfig_set_dpm_voltlimitmgmt_reg(u32_t unused, void *unusedp, u32_t offset, u32_t val, H2K_thread_context *me)IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getccr(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setccr(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getsyscfg(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setsyscfg(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getlivelock(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setlivelock(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getturkey(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setturkey(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getduck(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setduck(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getchicken(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setchicken(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_getrgdr(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); +u32_t H2K_trap_hwconfig_setrgdr(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) IN_SECTION(".text.config.hwconfig"); #endif diff --git a/kernel/traps/hwconfig/hwconfig.ref.c b/kernel/traps/hwconfig/hwconfig.ref.c index 2b26fe9ab..76503e87b 100644 --- a/kernel/traps/hwconfig/hwconfig.ref.c +++ b/kernel/traps/hwconfig/hwconfig.ref.c @@ -65,7 +65,21 @@ static const configptr_t H2K_hwconfigtab[HWCONFIG_MAX] IN_SECTION(".data.config. H2K_trap_hwconfig_get_dpm_voltlimitmgmt_reg, H2K_trap_hwconfig_set_dpm_voltlimitmgmt_reg, H2K_trap_hwconfig_hlxbits, - H2K_trap_hwconfig_coproc_bits + H2K_trap_hwconfig_coproc_bits, + H2K_trap_hwconfig_getccr, + H2K_trap_hwconfig_setccr, + H2K_trap_hwconfig_getsyscfg, + H2K_trap_hwconfig_setsyscfg, + H2K_trap_hwconfig_getlivelock, + H2K_trap_hwconfig_setlivelock, + H2K_trap_hwconfig_getturkey, + H2K_trap_hwconfig_setturkey, + H2K_trap_hwconfig_getduck, + H2K_trap_hwconfig_setduck, + H2K_trap_hwconfig_getchicken, + H2K_trap_hwconfig_setchicken, + H2K_trap_hwconfig_getrgdr, + H2K_trap_hwconfig_setrgdr, }; typedef struct { @@ -801,3 +815,66 @@ u32_t H2K_trap_hwconfig_set_dpm_voltlimitmgmt_reg(u32_t unused, void *unusedp, u return 0; } } + +u32_t H2K_trap_hwconfig_getccr(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_ccr(); +} + +u32_t H2K_trap_hwconfig_setccr(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_ccr(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getsyscfg(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_syscfg(); +} + +u32_t H2K_trap_hwconfig_setsyscfg(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_syscfg(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getlivelock(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_livelock(); +} + +u32_t H2K_trap_hwconfig_setlivelock(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_livelock(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getturkey(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_turkey(); +} + +u32_t H2K_trap_hwconfig_setturkey(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_turkey(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getduck(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_duck(); +} + +u32_t H2K_trap_hwconfig_setduck(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_duck(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getchicken(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_chicken(); +} + +u32_t H2K_trap_hwconfig_setchicken(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_chicken(val); + return 0; +} + +u32_t H2K_trap_hwconfig_getrgdr(u32_t unused, void *unusedp, u32_t unused2, u32_t unused3, H2K_thread_context *me) { + return H2K_get_rgdr(); +} + +u32_t H2K_trap_hwconfig_setrgdr(u32_t unused, void *unusedp, u32_t val, u32_t unused3, H2K_thread_context *me) { + H2K_set_rgdr(val); + return 0; +} diff --git a/kernel/util/hw/hw.h b/kernel/util/hw/hw.h index 5e3386f69..bdcc6b5cb 100644 --- a/kernel/util/hw/hw.h +++ b/kernel/util/hw/hw.h @@ -125,6 +125,17 @@ static inline u32_t H2K_get_ssr() return ret; } +static inline H2K_thread_context *H2K_get_sgp() +{ + H2K_thread_context *me; +#if ARCHV <= 3 + asm volatile (" %0 = sgp\n" : "=r"(me)); +#else + asm volatile (" %0 = sgp0\n" : "=r"(me)); +#endif + return me; +} + static inline void H2K_set_ssr(u32_t val) { asm volatile (" ssr = %0 // set ssr" : : "r"(val)); diff --git a/kernel/util/max/max.h b/kernel/util/max/max.h index 2c2cf2b63..2980f4904 100644 --- a/kernel/util/max/max.h +++ b/kernel/util/max/max.h @@ -87,6 +87,10 @@ #define MAX_ASIDS (1<<(ASID_BITS)) +#define MODECTL_E_MASK 0x0000ffff +#define MODECTL_W_BITS 16 +#define MODECTL_W_MASK 0xffff0000 + /* QDSP6SS_PRIV_BASE is the subsystem base value read from cfg_table, but we map QDSP6SS_PUB_BASE to Q6_SS_BASE_VA so we can get at the public registers. FIXME? Is the QDSP6SS_PUB_PRIV_OFFSET the same for all subsystems? */ @@ -233,6 +237,7 @@ #define H2K_PAGESIZE (1 << ((PAGE_BITS) + ((H2K_KERNEL_PGSIZE) * 2))) #define SSR_IE_BIT 18 +#define SSR_UM_BIT 16 #if ARCHV <= 3 #define RESCHED_INT_INTMASK (0x80000000 >> RESCHED_INT) diff --git a/kernel/util/spinlock/test/test.c b/kernel/util/spinlock/test/test.c index 0a83fda9e..8d90a54cf 100644 --- a/kernel/util/spinlock/test/test.c +++ b/kernel/util/spinlock/test/test.c @@ -7,7 +7,6 @@ #include #include #include -#include void FAIL(const char *str) { diff --git a/kernel/util/stmode/test/Makefile b/kernel/util/stmode/test/Makefile index 71b74048c..8da090ae4 100644 --- a/kernel/util/stmode/test/Makefile +++ b/kernel/util/stmode/test/Makefile @@ -1,7 +1,9 @@ -STANDALONE=1 +INC_KERNEL=1 OBJS+=test.o EXEC=test.elf +EXTRA_CFLAGS += -ffixed-r28 +EXTRA_ASFLAGS += -ffixed-r28 + include Makefile.inc -OSLIB= diff --git a/kernel/util/stmode/test/test.c b/kernel/util/stmode/test/test.c index 2f9182552..079cc993c 100644 --- a/kernel/util/stmode/test/test.c +++ b/kernel/util/stmode/test/test.c @@ -9,7 +9,11 @@ #include #include #include -#include +#include +#include +#include +#include +#include void FAIL(const char *str) { @@ -21,10 +25,40 @@ void FAIL(const char *str) volatile int handshake = 0; #define STACK_SIZE 16 +#define NUM_TEST_THREADS 2 /* test1 + test2 */ unsigned long long int stack1[STACK_SIZE]; unsigned long long int stack2[STACK_SIZE]; +/* Extra thread contexts for test1/test2. The boot VM is created with + MAX_BOOT_CONTEXTS=1 (just main), leaving no free slots. We extend + the free list with two statically-allocated contexts before creating + any threads. */ +static H2K_thread_context extra_contexts[NUM_TEST_THREADS] __attribute__((aligned(32))); + +static inline void stmode_extend_bootvm_contexts(H2K_thread_context *me) +{ + H2K_vmblock_t *vm = me->vmblock; + int i; + for (i = 0; i < NUM_TEST_THREADS; i++) { + H2K_thread_context_clear(&extra_contexts[i]); + extra_contexts[i].id.raw = 0; + extra_contexts[i].id.vmidx = vm->vmidx; + extra_contexts[i].id.cpuidx = vm->max_cpus++; + extra_contexts[i].vmblock = vm; + extra_contexts[i].next = vm->free_threads; + vm->free_threads = &extra_contexts[i]; + } +} + +static inline void wait_for_threads_to_sleep(void) +{ + u32_t mc; + do { + mc = H2K_get_modectl(); + } while ((mc & ((~mc) >> MODECTL_W_BITS)) & ~0x1u); +} + void test1(void *unused) { u32_t tmp; @@ -47,8 +81,14 @@ void test2(void *unused) int main() { + h2_init(NULL); + H2K_thread_context *me = H2K_get_sgp(); u32_t tmp; - asm volatile (" %0 = #-1; imask=%0 " : "=r"(tmp)); + + stmode_extend_bootvm_contexts(me); + H2K_trap_hwconfig_hwthreads_mask(0, NULL, (u32_t)-1, 0, me); + wait_for_threads_to_sleep(); + H2K_set_gie(); tmp = H2K_stmode_begin(); @@ -57,7 +97,7 @@ int main() H2K_stmode_end(); if ((H2K_get_syscfg() & 0x10) == 0) FAIL("stmode_end didn't ensable gie"); - thread_create(&test1,stack1+STACK_SIZE,1,(void *)1); + h2_thread_create(test1, &stack1[STACK_SIZE], (void *)1, 0); while (handshake == 0) /* SPIN */; for (tmp = 0; tmp < 100; tmp++) { asm volatile ("nop"); } @@ -69,7 +109,7 @@ int main() handshake = 0; - thread_create(&test2,stack2+STACK_SIZE,2,(void *)2); + h2_thread_create(test2, &stack2[STACK_SIZE], (void *)2, 0); while (handshake == 0) /* SPIN */; for (tmp = 0; tmp < 100; tmp++) { asm volatile ("nop"); } @@ -80,4 +120,3 @@ int main() puts("TEST PASSED"); return 0; } - diff --git a/libs/h2/common/h2_common_hwconfig.h b/libs/h2/common/h2_common_hwconfig.h index 3d193e3bd..0bb0d1bf6 100644 --- a/libs/h2/common/h2_common_hwconfig.h +++ b/libs/h2/common/h2_common_hwconfig.h @@ -40,9 +40,23 @@ typedef enum { HWCONFIG_GETVWCTRL, HWCONFIG_SETVWCTRL, HWCONFIG_GET_DPM_VOLTLMTMGMT_REG, - HWCONFIG_SET_DPM_VOLTLMTMGMT_REG, + HWCONFIG_SET_DPM_VOLTLMTMGMT_REG, HWCONFIG_HLXBITS, HWCONFIG_COPROCBITS, + HWCONFIG_GETCCR, + HWCONFIG_SETCCR, + HWCONFIG_GETSYSCFG, + HWCONFIG_SETSYSCFG, + HWCONFIG_GETLIVELOCK, + HWCONFIG_SETLIVELOCK, + HWCONFIG_GETTURKEY, + HWCONFIG_SETTURKEY, + HWCONFIG_GETDUCK, + HWCONFIG_SETDUCK, + HWCONFIG_GETCHICKEN, + HWCONFIG_SETCHICKEN, + HWCONFIG_GETRGDR, + HWCONFIG_SETRGDR, HWCONFIG_MAX } hwconfig_type_t; diff --git a/libs/h2/hwconfig/h2_hwconfig.h b/libs/h2/hwconfig/h2_hwconfig.h index 00e799dd2..b79db4363 100644 --- a/libs/h2/hwconfig/h2_hwconfig.h +++ b/libs/h2/hwconfig/h2_hwconfig.h @@ -318,6 +318,111 @@ Set DPM volt limits management register. */ int h2_hwconfig_dpm_voltlmtmgmt_set_reg(unsigned int offset, unsigned int val); +/** +Get CCR (Compute Code Register). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_ccr_get(void); + +/** +Set CCR (Compute Code Register). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_ccr_set(unsigned int val); + +/** +Get SYSCFG register. +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_syscfg_get(void); + +/** +Set SYSCFG register. +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_syscfg_set(unsigned int val); + +/** +Get livelock detection register (s35). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_livelock_get(void); + +/** +Set livelock detection register (s35). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_livelock_set(unsigned int val); + +/** +Get turkey register (s61). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_turkey_get(void); + +/** +Set turkey register (s61). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_turkey_set(unsigned int val); + +/** +Get duck register (s62). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_duck_get(void); + +/** +Set duck register (s62). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_duck_set(unsigned int val); + +/** +Get chicken register (s63). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_chicken_get(void); + +/** +Set chicken register (s63). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_chicken_set(unsigned int val); + +/** +Get RGDR register (s60). +@returns register value +@dependencies None +*/ +unsigned int h2_hwconfig_rgdr_get(void); + +/** +Set RGDR register (s60). +@param[in] val Value to write +@returns 0 on success +@dependencies None +*/ +int h2_hwconfig_rgdr_set(unsigned int val); + #endif /** @} */ diff --git a/libs/h2/hwconfig/h2_hwconfig_imp.ref.c b/libs/h2/hwconfig/h2_hwconfig_imp.ref.c index 600bc42e0..b9eca2a38 100644 --- a/libs/h2/hwconfig/h2_hwconfig_imp.ref.c +++ b/libs/h2/hwconfig/h2_hwconfig_imp.ref.c @@ -180,3 +180,73 @@ int h2_hwconfig_dpm_voltlmtmgmt_set_reg(unsigned int offset, unsigned int val) { return h2_hwconfig_trap(HWCONFIG_SET_DPM_VOLTLMTMGMT_REG, NULL, offset, val); } + +unsigned int h2_hwconfig_ccr_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETCCR, NULL, 0, 0); +} + +int h2_hwconfig_ccr_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETCCR, NULL, val, 0); +} + +unsigned int h2_hwconfig_syscfg_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETSYSCFG, NULL, 0, 0); +} + +int h2_hwconfig_syscfg_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETSYSCFG, NULL, val, 0); +} + +unsigned int h2_hwconfig_livelock_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETLIVELOCK, NULL, 0, 0); +} + +int h2_hwconfig_livelock_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETLIVELOCK, NULL, val, 0); +} + +unsigned int h2_hwconfig_turkey_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETTURKEY, NULL, 0, 0); +} + +int h2_hwconfig_turkey_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETTURKEY, NULL, val, 0); +} + +unsigned int h2_hwconfig_duck_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETDUCK, NULL, 0, 0); +} + +int h2_hwconfig_duck_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETDUCK, NULL, val, 0); +} + +unsigned int h2_hwconfig_chicken_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETCHICKEN, NULL, 0, 0); +} + +int h2_hwconfig_chicken_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETCHICKEN, NULL, val, 0); +} + +unsigned int h2_hwconfig_rgdr_get(void) +{ + return h2_hwconfig_trap(HWCONFIG_GETRGDR, NULL, 0, 0); +} + +int h2_hwconfig_rgdr_set(unsigned int val) +{ + return h2_hwconfig_trap(HWCONFIG_SETRGDR, NULL, val, 0); +}