void dump_timer_regs(void) { #if 0 unsigned int cntfrq = 0xFFFFFFFF; unsigned int cntkctl = 0xFFFFFFFF; #endif unsigned int cntpct_lo = 0xFFFFFFFF; unsigned int cntpct_hi = 0xFFFFFFFF; #if 0 unsigned int cntvct_lo = 0xFFFFFFFF; unsigned int cntvct_hi = 0xFFFFFFFF; #endif unsigned int cntp_ctl = 0xFFFFFFFF; unsigned int cntp_cval_lo = 0xFFFFFFFF; unsigned int cntp_cval_hi = 0xFFFFFFFF; unsigned int cntp_tval = 0xFFFFFFFF; #if 0 unsigned int cntv_ctl = 0xFFFFFFFF; unsigned int cntv_cval_lo = 0xFFFFFFFF; unsigned int cntv_cval_hi = 0xFFFFFFFF; unsigned int cntv_tval = 0xFFFFFFFF; #endif #if 0 read_cntfrq(cntfrq); read_cntkctl(cntkctl); #endif read_cntpct(cntpct_lo, cntpct_hi); #if 0 read_cntvct(cntvct_lo, cntvct_hi); #endif read_cntp_ctl(cntp_ctl); read_cntp_cval(cntp_cval_lo, cntp_cval_hi); read_cntp_tval(cntp_tval); #if 0 read_cntv_ctl(cntv_ctl); read_cntv_cval(cntv_cval_lo, cntv_cval_hi); read_cntv_tval(cntv_tval); #endif #if 0 printk("[ca7_timer]0. cntfrq = 0x%x\n", cntfrq); printk("[ca7_timer]1. cntkctl = 0x%x\n", cntkctl); #endif printk("[ca7_timer]2. cntpct_lo = 0x%08x, cntpct_hi = 0x%08x\n", cntpct_lo, cntpct_hi); #if 0 printk("[ca7_timer]3. cntvct_lo = 0x%08x, cntvct_hi = 0x%08x\n", cntvct_lo, cntvct_hi); #endif printk("[ca7_timer]4. cntp_ctl = 0x%x\n", cntp_ctl); printk("[ca7_timer]5. cntp_cval_lo = 0x%08x, cntp_cval_hi = 0x%08x\n", cntp_cval_lo, cntp_cval_hi); printk("[ca7_timer]6. cntp_tval = 0x%08x\n", cntp_tval); #if 0 printk("[ca7_timer]7. cntv_ctl = 0x%x\n", cntv_ctl); printk("[ca7_timer]8. cntv_cval_lo = 0x%08x, cntv_cval_hi = 0x%08x\n", cntv_cval_lo, cntv_cval_hi); printk("[ca7_timer]9. cntv_tval = 0x%08x\n", cntv_tval); #endif }
status_t platform_set_oneshot_timer(platform_timer_callback callback, void *arg, lk_time_t interval) { uint64_t cntpct_interval = lk_time_to_cntpct(interval); ASSERT(arg == NULL); t_callback = callback; if (cntpct_interval <= INT_MAX) write_cntp_tval(cntpct_interval); else write_cntp_cval(read_cntpct() + cntpct_interval); write_cntp_ctl(1); return 0; }
void scheduler_test_switch_to_next_guest(void *pdata){ struct arch_regs *regs = pdata; uint64_t pct = read_cntpct(); uint32_t tval = read_cnthp_tval(); uart_print( "cntpct:"); uart_print_hex64(pct); uart_print("\n\r"); uart_print( "cnth_tval:"); uart_print_hex32(tval); uart_print("\n\r"); /* Note: As of context_switchto() and context_perform_switch() are available, no need to test if trapped from Hyp mode. context_perform_switch() takes care of it */ /* Test guest context switch */ if ( (regs->cpsr & 0x1F) != 0x1A ) { scheduler_schedule(); } }
int dump_localtimer_register(char* buffer, int size) { int i; int len = 0; #define LOCAL_LEN 256 char fmt[LOCAL_LEN]; unsigned int cntp_ctl; unsigned int cntp_tval; unsigned int cntp_cval_lo, cntp_cval_hi; unsigned int cntpct_lo, cntpct_hi; if (!buffer || size <= 1) { return 0; } len += snprintf(fmt + len, LOCAL_LEN - len, "[localtimer]cpu evt ctl ext time\n"); for (i = 0; i < nr_cpu_ids; i++) { len += snprintf(fmt + len, LOCAL_LEN - len, "%d %lx %x %d %llx\n", i, save_data[i].evt, save_data[i].ctrl, save_data[i].ext, save_data[i].timestamp); } read_cntp_ctl(cntp_ctl); read_cntp_cval(cntp_cval_lo, cntp_cval_hi); read_cntp_tval(cntp_tval); read_cntpct(cntpct_lo, cntpct_hi); len += snprintf(fmt + len, LOCAL_LEN - len, "cpu ctl tval cval pct\n"); len += snprintf(fmt + len, LOCAL_LEN - len, "%d %x %x (%x,%x) (%x,%x)\n", smp_processor_id(), cntp_ctl, cntp_tval, cntp_cval_lo, cntp_cval_hi, cntpct_lo, cntpct_hi); len = min(len, size - 1); memcpy(buffer, fmt, len); *(buffer + len) = '\0'; return len; }
static void test_start_timer(void) { uint32_t ctl; uint32_t tval; uint64_t pct; HVMM_TRACE_ENTER(); /* every second */ tval = read_cntfrq(); write_cntp_tval(tval); pct = read_cntpct(); uart_print("cntpct:"); uart_print_hex64(pct); uart_print("\n\r"); uart_print("cntp_tval:"); uart_print_hex32(tval); uart_print("\n\r"); /* enable timer */ ctl = read_cntp_ctl(); ctl |= 0x1; write_cntp_ctl(ctl); HVMM_TRACE_EXIT(); }
static void syscnt_assist_handler(unsigned long data) { unsigned int assist_cnt; unsigned int syscnt_cnt[2] = {0}; unsigned int cnth; unsigned int pct_lo, pct_hi; int cnt = 0; struct gpt_device *assist_dev = id_to_dev(GPT_SYSCNT_ASSIST_ID); struct gpt_device *syscnt_dev = id_to_dev(GPT_SYSCNT_ID); __gpt_get_cnt(assist_dev, &assist_cnt); __gpt_get_cnt(syscnt_dev, syscnt_cnt); loop++; do { cnt++; cnth = DRV_Reg32(syscnt_dev->base_addr + GPT_CNTH); if ((cnt / CHECK_WARNING_TIMERS) && !(cnt % CHECK_WARNING_TIMERS)) { printk("[%s]WARNING: fail to sync GPT_CNTH!! assist(0x%08x)," "syscnt(0x%08x,0x%08x),cnth(0x%08x),loop(0x%08x),cnt(%d)\n", __func__, assist_cnt, syscnt_cnt[0], syscnt_cnt[1], cnth, loop, cnt); } } while (cnth != loop); read_cntpct(pct_lo, pct_hi); WARN_ON(pct_hi != loop); printk("[%s]syscnt assist IRQ!! assist(0x%08x),syscnt(0x%08x,0x%08x)," "cnth:pct_hi:loop(0x%08x,0x%08x,0x%08x),cnt(%d)\n", __func__, assist_cnt, syscnt_cnt[0], syscnt_cnt[1], cnth, pct_hi, loop, cnt); }
lk_time_t current_time(void) { return cntpct_to_lk_time(read_cntpct()); }
lk_bigtime_t current_time_hires(void) { return cntpct_to_lk_bigtime(read_cntpct()); }