mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-01 08:54:14 -04:00
First task running in RISC-V-Qemu-sifive_e-FreedomStudio demo.
This commit is contained in:
parent
d0ef322b13
commit
dc99300fa9
11 changed files with 422 additions and 277 deletions
|
@ -376,9 +376,9 @@ is used in assert() statements. */
|
|||
* memory to be allocated dynamically.
|
||||
*
|
||||
* @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will
|
||||
* be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer
|
||||
* are NULL then the task will not be created and
|
||||
* errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned.
|
||||
* be created and a handle to the created task is returned. If either
|
||||
* pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
|
||||
* NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
|
|
|
@ -51,7 +51,7 @@ static void prvTaskExitError( void );
|
|||
/* Used to program the machine timer compare register. */
|
||||
static uint64_t ullNextTime = 0ULL;
|
||||
static const uint64_t ullTimerIncrementsForOneTick = ( uint64_t ) ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );
|
||||
static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCTRL_BASE + 0x4000 );
|
||||
static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCLINT_BASE_ADDRESS + 0x4000 );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -175,8 +175,8 @@ const uint32_t ulMPIE_Bit = 0x80, ulMPP_Bits = 0x1800;
|
|||
void vPortSetupTimerInterrupt( void )
|
||||
{
|
||||
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
|
||||
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFFC );
|
||||
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFF8 );
|
||||
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 );
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -200,12 +200,12 @@ volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCTR
|
|||
|
||||
void Software_IRQHandler( void )
|
||||
{
|
||||
volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCTRL_BASE;
|
||||
volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCLINT_BASE_ADDRESS;
|
||||
|
||||
vTaskSwitchContext();
|
||||
|
||||
/* Clear software interrupt. */
|
||||
*( ( uint32_t * ) configCTRL_BASE ) &= 0x08UL;
|
||||
*( ( uint32_t * ) configCLINT_BASE_ADDRESS ) &= 0x08UL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -246,6 +246,14 @@ extern void xPortStartFirstTask( void );
|
|||
should be executing. */
|
||||
return pdFAIL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
/* Not implemented. */
|
||||
for( ;; );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,13 +41,16 @@
|
|||
.global xPortStartFirstTask
|
||||
.global vPortTrapHandler
|
||||
.extern pxCurrentTCB
|
||||
.extern handle_trap
|
||||
.extern ulPortTrapHandler
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
.align 8
|
||||
xPortStartFirstTask:
|
||||
|
||||
la t0, vPortTrapHandler
|
||||
csrw mtvec, t0
|
||||
|
||||
lw sp, pxCurrentTCB /* Load pxCurrentTCB. */
|
||||
lw sp, 0( sp ) /* Read sp from first TCB member. */
|
||||
|
||||
|
@ -127,7 +130,7 @@ vPortTrapHandler:
|
|||
csrr a1, mepc
|
||||
mv a2, sp
|
||||
/*_RB_ Does stack need aligning here? */
|
||||
jal handle_trap
|
||||
jal ulPortTrapHandler
|
||||
csrw mepc, a0
|
||||
/* Save exception return address. */
|
||||
sw a0, 0( sp )
|
||||
|
|
|
@ -70,7 +70,7 @@ not need to be guarded with a critical section. */
|
|||
|
||||
|
||||
/* Scheduler utilities. */
|
||||
#define portYIELD() __asm volatile( "ecall" ); // software interrupt alternative *( ( uint32_t * ) configCTRL_BASE ) |= 0x08UL
|
||||
#define portYIELD() __asm volatile( "ecall" ); // software interrupt alternative *( ( uint32_t * ) configCLINT_BASE_ADDRESS ) |= 0x08UL
|
||||
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield()
|
||||
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
@ -2937,28 +2937,28 @@ void vTaskSwitchContext( void )
|
|||
|
||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||
{
|
||||
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
|
||||
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
|
||||
#else
|
||||
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||
#endif
|
||||
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
|
||||
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
|
||||
#else
|
||||
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||
#endif
|
||||
|
||||
/* Add the amount of time the task has been running to the
|
||||
accumulated time so far. The time the task started running was
|
||||
stored in ulTaskSwitchedInTime. Note that there is no overflow
|
||||
protection here so count values are only valid until the timer
|
||||
overflows. The guard against negative values is to protect
|
||||
against suspect run time stat counter implementations - which
|
||||
are provided by the application, not the kernel. */
|
||||
if( ulTotalRunTime > ulTaskSwitchedInTime )
|
||||
{
|
||||
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
ulTaskSwitchedInTime = ulTotalRunTime;
|
||||
/* Add the amount of time the task has been running to the
|
||||
accumulated time so far. The time the task started running was
|
||||
stored in ulTaskSwitchedInTime. Note that there is no overflow
|
||||
protection here so count values are only valid until the timer
|
||||
overflows. The guard against negative values is to protect
|
||||
against suspect run time stat counter implementations - which
|
||||
are provided by the application, not the kernel. */
|
||||
if( ulTotalRunTime > ulTaskSwitchedInTime )
|
||||
{
|
||||
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
ulTaskSwitchedInTime = ulTotalRunTime;
|
||||
}
|
||||
#endif /* configGENERATE_RUN_TIME_STATS */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue