]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/IAR/RISC-V/port.c
Update to the latest atomic.h.
[freertos] / FreeRTOS / Source / portable / IAR / RISC-V / port.c
index 025cb2faed7e5296de65de57969bf611e74d51bf..dd32a8e50ef5b072d4742cb0dc302b3b975ca273 100644 (file)
@@ -56,7 +56,7 @@ stack that was used by main before the scheduler was started for use as the
 interrupt stack after the scheduler has started. */\r
 #ifdef configISR_STACK_SIZE_WORDS\r
        static __attribute__ ((aligned(16))) StackType_t xISRStack[ configISR_STACK_SIZE_WORDS ] = { 0 };\r
-       StackType_t xISRStackTop = ( StackType_t ) 0;\r
+       const StackType_t xISRStackTop = ( StackType_t ) &( xISRStack[ configISR_STACK_SIZE_WORDS & ~portBYTE_ALIGNMENT_MASK ] );\r
 #else\r
        extern const uint32_t __freertos_irq_stack_top[];\r
        const StackType_t xISRStackTop = ( StackType_t ) __freertos_irq_stack_top;\r
@@ -75,7 +75,8 @@ void vPortSetupTimerInterrupt( void ) __attribute__(( weak ));
 uint64_t ullNextTime = 0ULL;\r
 const uint64_t *pullNextTime = &ullNextTime;\r
 const size_t uxTimerIncrementsForOneTick = ( size_t ) ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ); /* Assumes increment won't go over 32-bits. */\r
-volatile uint64_t * const pullMachineTimerCompareRegister = ( uint64_t * ) ( configCLINT_BASE_ADDRESS + 0x4000 );\r
+volatile uint64_t * const pullMachineTimerCompareRegisterBase = ( uint64_t * ) ( configCLINT_BASE_ADDRESS + 0x4000 );\r
+volatile uint64_t * pullMachineTimerCompareRegister = 0;\r
 \r
 /* Set configCHECK_FOR_STACK_OVERFLOW to 3 to add ISR stack checking to task\r
 stack checking.  A problem in the ISR stack will trigger an assert, not call the\r
@@ -110,6 +111,10 @@ task stack, not the ISR stack). */
        uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;\r
        volatile uint32_t * const pulTimeHigh = ( uint32_t * ) ( configCLINT_BASE_ADDRESS + 0xBFFC );\r
        volatile uint32_t * const pulTimeLow = ( uint32_t * ) ( configCLINT_BASE_ADDRESS + 0xBFF8 );\r
+       volatile uint32_t ulHartId = 0;\r
+\r
+               __asm volatile( "csrr %0, 0xf14" : "=r"( ulHartId ) ); /* 0xf14 is hartid. */\r
+               pullMachineTimerCompareRegister  = &( pullMachineTimerCompareRegisterBase[ ulHartId ] );\r
 \r
                do\r
                {\r
@@ -133,10 +138,6 @@ task stack, not the ISR stack). */
 BaseType_t xPortStartScheduler( void )\r
 {\r
 extern void xPortStartFirstTask( void );\r
-#warning Replicate this change in the GCC version.\r
-       #ifdef configISR_STACK_SIZE_WORDS\r
-               xISRStackTop = ( ( StackType_t ) &( xISRStack[ configISR_STACK_SIZE_WORDS - 1 ] ) & ~portBYTE_ALIGNMENT_MASK );\r
-       #endif\r
 \r
        #if( configASSERT_DEFINED == 1 )\r
        {\r
@@ -151,6 +152,12 @@ extern void xPortStartFirstTask( void );
                stack that was being used by main() prior to the scheduler being\r
                started. */\r
                configASSERT( ( xISRStackTop & portBYTE_ALIGNMENT_MASK ) == 0 );\r
+\r
+               #ifdef configISR_STACK_SIZE_WORDS\r
+               {\r
+                       memset( ( void * ) xISRStack, portISR_STACK_FILL_BYTE, sizeof( xISRStack ) );\r
+               }\r
+               #endif   /* configISR_STACK_SIZE_WORDS */\r
        }\r
        #endif /* configASSERT_DEFINED */\r
 \r