mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-03-09 18:13:30 -04:00
RISC-V: add configMTIME_INIT_IN_BSP
Add a new configMTIME_INIT_IN_BSP configuration macro to allow BSPs and demo applications to initialise the MMIO MTIME pointers within the CLINT. This enables BSPs to provide custom addresses or properly typed pointer values, rather than relying on plain integer constants coming from macros as is currently the case. This change does not affect existing assumptions and usage, but allows architectures that differentiate between integers and pointers to work. Signed-off-by: Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk>
This commit is contained in:
parent
ab6ccbb04e
commit
2fe3c61c26
1 changed files with 10 additions and 7 deletions
|
|
@ -93,6 +93,9 @@ const size_t uxTimerIncrementsForOneTick = ( size_t ) ( ( configCPU_CLOCK_HZ ) /
|
|||
UBaseType_t const ullMachineTimerCompareRegisterBase = configMTIMECMP_BASE_ADDRESS;
|
||||
volatile uint64_t * pullMachineTimerCompareRegister = NULL;
|
||||
|
||||
volatile uint32_t * pulTimeHigh = ( volatile uint32_t * const ) ( ( configMTIME_BASE_ADDRESS ) + 4UL ); /* 8-byte type so high 32-bit word is 4 bytes up. */
|
||||
volatile uint32_t * pulTimeLow = ( volatile uint32_t * const ) ( configMTIME_BASE_ADDRESS );
|
||||
|
||||
/* Holds the critical nesting value - deliberately non-zero at start up to
|
||||
* ensure interrupts are not accidentally enabled before the scheduler starts. */
|
||||
size_t xCriticalNesting = ( size_t ) 0xaaaaaaaa;
|
||||
|
|
@ -130,13 +133,13 @@ ReturnFunctionType_t xTaskReturnAddress = ( ReturnFunctionType_t ) portTASK_RETU
|
|||
void vPortSetupTimerInterrupt( void )
|
||||
{
|
||||
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
|
||||
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( ( configMTIME_BASE_ADDRESS ) + 4UL ); /* 8-byte type so high 32-bit word is 4 bytes up. */
|
||||
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configMTIME_BASE_ADDRESS );
|
||||
volatile uint32_t ulHartId;
|
||||
|
||||
__asm volatile ( "csrr %0, mhartid" : "=r" ( ulHartId ) );
|
||||
|
||||
pullMachineTimerCompareRegister = ( volatile uint64_t * ) ( ullMachineTimerCompareRegisterBase + ( ulHartId * sizeof( uint64_t ) ) );
|
||||
#ifndef configMTIME_INIT_IN_BSP
|
||||
{
|
||||
volatile uint32_t ulHartId;
|
||||
__asm volatile ( "csrr %0, mhartid" : "=r" ( ulHartId ) );
|
||||
pullMachineTimerCompareRegister = ( volatile uint64_t * ) ( ullMachineTimerCompareRegisterBase + ( ulHartId * sizeof( uint64_t ) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue