mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-29 06:28:36 -04:00
Replace portasmHAS_CLINT with configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS definitions in the GCC RISC-V port - portasmHAS_CLIT will still work by deriving the new definitions from the old.
This commit is contained in:
parent
eaf9318df8
commit
fbb23055cd
5 changed files with 49 additions and 17 deletions
|
@ -37,8 +37,16 @@
|
|||
/* Standard includes. */
|
||||
#include "string.h"
|
||||
|
||||
#ifndef configCLINT_BASE_ADDRESS
|
||||
#warning configCLINT_BASE_ADDRESS must be defined in FreeRTOSConfig.h. If the target chip includes a Core Local Interrupter (CLINT) then set configCLINT_BASE_ADDRESS to the CLINT base address. Otherwise set configCLINT_BASE_ADDRESS to 0.
|
||||
#ifdef configCLINT_BASE_ADDRESS
|
||||
#warning The configCLINT_BASE_ADDRESS constant has been deprecated. configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS are currently being derived from configCLINT_BASE_ADDRESS. Please update to define configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS dirctly in place of configCLINT_BASE_ADDRESS.
|
||||
#endif
|
||||
|
||||
#ifndef configMTIME_BASE_ADDRESS
|
||||
#warning configMTIME_BASE_ADDRESS must be defined in FreeRTOSConfig.h. If the target chip includes a memory-mapped mtime register then set configMTIME_BASE_ADDRESS to the mapped address. Otherwise set configMTIME_BASE_ADDRESS to 0.
|
||||
#endif
|
||||
|
||||
#ifndef configMTIMECMP_BASE_ADDRESS
|
||||
#warning configMTIMECMP_BASE_ADDRESS must be defined in FreeRTOSConfig.h. If the target chip includes a memory-mapped mtimecmp register then set configMTIMECMP_BASE_ADDRESS to the mapped address. Otherwise set configMTIMECMP_BASE_ADDRESS to 0.
|
||||
#endif
|
||||
|
||||
/* Let the user override the pre-loading of the initial LR with the address of
|
||||
|
@ -83,7 +91,7 @@ void vPortSetupTimerInterrupt( void ) __attribute__(( weak ));
|
|||
uint64_t ullNextTime = 0ULL;
|
||||
const uint64_t *pullNextTime = &ullNextTime;
|
||||
const size_t uxTimerIncrementsForOneTick = ( size_t ) ( ( configCPU_CLOCK_HZ ) / ( configTICK_RATE_HZ ) ); /* Assumes increment won't go over 32-bits. */
|
||||
uint32_t const ullMachineTimerCompareRegisterBase = ( uint64_t const ) ( ( configCLINT_BASE_ADDRESS ) + 0x4000 );
|
||||
uint32_t const ullMachineTimerCompareRegisterBase = configMTIMECMP_BASE_ADDRESS;
|
||||
volatile uint64_t * pullMachineTimerCompareRegister = NULL;
|
||||
|
||||
/* Set configCHECK_FOR_STACK_OVERFLOW to 3 to add ISR stack checking to task
|
||||
|
@ -108,13 +116,13 @@ task stack, not the ISR stack). */
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if( configCLINT_BASE_ADDRESS != 0 )
|
||||
#if( configMTIME_BASE_ADDRESS != 0 ) && ( configMTIMECMP_BASE_ADDRESS != 0 )
|
||||
|
||||
void vPortSetupTimerInterrupt( void )
|
||||
{
|
||||
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
|
||||
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFFC );
|
||||
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFF8 );
|
||||
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( ( configMTIME_BASE_ADDRESS ) + 4UL ); /* 8-byte typer 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 ) );
|
||||
|
@ -127,7 +135,7 @@ task stack, not the ISR stack). */
|
|||
} while( ulCurrentTimeHigh != *pulTimeHigh );
|
||||
|
||||
ullNextTime = ( uint64_t ) ulCurrentTimeHigh;
|
||||
ullNextTime <<= 32ULL;
|
||||
ullNextTime <<= 32ULL; /* High 4-byte word is 32-bits up. */
|
||||
ullNextTime |= ( uint64_t ) ulCurrentTimeLow;
|
||||
ullNextTime += ( uint64_t ) uxTimerIncrementsForOneTick;
|
||||
*pullMachineTimerCompareRegister = ullNextTime;
|
||||
|
@ -136,7 +144,7 @@ task stack, not the ISR stack). */
|
|||
ullNextTime += ( uint64_t ) uxTimerIncrementsForOneTick;
|
||||
}
|
||||
|
||||
#endif /* ( configCLINT_BASE_ADDRESS != 0 ) */
|
||||
#endif /* ( configMTIME_BASE_ADDRESS != 0 ) && ( configMTIME_BASE_ADDRESS != 0 ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
|
@ -170,7 +178,7 @@ extern void xPortStartFirstTask( void );
|
|||
configure whichever clock is to be used to generate the tick interrupt. */
|
||||
vPortSetupTimerInterrupt();
|
||||
|
||||
#if( configCLINT_BASE_ADDRESS != 0 )
|
||||
#if( ( configMTIME_BASE_ADDRESS != 0 ) && ( configMTIMECMP_BASE_ADDRESS != 0 ) )
|
||||
{
|
||||
/* Enable mtime and external interrupts. 1<<7 for timer interrupt, 1<<11
|
||||
for external interrupt. _RB_ What happens here when mtime is not present as
|
||||
|
@ -182,7 +190,7 @@ extern void xPortStartFirstTask( void );
|
|||
/* Enable external interrupts. */
|
||||
__asm volatile( "csrs mie, %0" :: "r"(0x800) );
|
||||
}
|
||||
#endif /* configCLINT_BASE_ADDRESS */
|
||||
#endif /* ( configMTIME_BASE_ADDRESS != 0 ) && ( configMTIMECMP_BASE_ADDRESS != 0 ) */
|
||||
|
||||
xPortStartFirstTask();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue