imx8: set virtual timer offset to zero for all cores

we want CNTVCT_EL0 to be the same on all cores,
so we set the offset the same so it effectively
becomes the system counter.
This commit is contained in:
cinap_lenrek 2022-07-09 15:15:55 +00:00
parent 29a6cbf7ee
commit 2b89cdee02
3 changed files with 8 additions and 0 deletions

View file

@ -41,6 +41,9 @@ clockinit(void)
freq = sysrd(CNTFRQ_EL0); freq = sysrd(CNTFRQ_EL0);
print("timer frequency %lld Hz\n", freq); print("timer frequency %lld Hz\n", freq);
} }
m->cpuhz = freq;
m->cpumhz = (freq + Mhz/2 - 1) / Mhz;
m->cyclefreq = freq;
intrenable(IRQcntpns, localclockintr, nil, BUSUNKNOWN, "clock"); intrenable(IRQcntpns, localclockintr, nil, BUSUNKNOWN, "clock");
} }

View file

@ -96,6 +96,10 @@ el2:
MSR R0, MDCR_EL2 MSR R0, MDCR_EL2
ISB $SY ISB $SY
/* set virtual timer offset to zero */
MOV $0, R0
MSR R0, CNTVOFF_EL2
/* HCR = RW, HCD, SWIO, BSU, FB */ /* HCR = RW, HCD, SWIO, BSU, FB */
MOVWU $(1<<31 | 1<<29 | 1<<2 | 0<<10 | 0<<9), R0 MOVWU $(1<<31 | 1<<29 | 1<<2 | 0<<10 | 0<<9), R0
MSR R0, HCR_EL2 MSR R0, HCR_EL2

View file

@ -38,6 +38,7 @@
#define CNTP_TVAL_EL0 SYSREG(3,3,14,2,0) #define CNTP_TVAL_EL0 SYSREG(3,3,14,2,0)
#define CNTP_CTL_EL0 SYSREG(3,3,14,2,1) #define CNTP_CTL_EL0 SYSREG(3,3,14,2,1)
#define CNTP_CVAL_EL0 SYSREG(3,3,14,2,2) #define CNTP_CVAL_EL0 SYSREG(3,3,14,2,2)
#define CNTVOFF_EL2 SYSREG(3,4,14,0,3)
#define TPIDR_EL0 SYSREG(3,3,13,0,2) #define TPIDR_EL0 SYSREG(3,3,13,0,2)
#define TPIDR_EL1 SYSREG(3,0,13,0,4) #define TPIDR_EL1 SYSREG(3,0,13,0,4)