Skip to content

Commit b318112

Browse files
committed
Minor formatting changes
Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent 2fd7ff6 commit b318112

File tree

3 files changed

+137
-101
lines changed

3 files changed

+137
-101
lines changed

portable/GCC/ARM_CR82/port.c

Lines changed: 72 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
#define portBIT_0_SET ( ( uint8_t ) 0x01 )
139139

140140
/* The space on the stack required to hold the FPU registers.
141-
* There are 32 128-bit plus 2 64-bit status registers.*/
141+
* There are 32 128-bit plus 2 64-bit status registers. */
142142
#define portFPU_REGISTER_WORDS ( ( 32 * 2 ) + 2 )
143143

144144
/*-----------------------------------------------------------*/
@@ -173,13 +173,13 @@ extern void vGIC_EnableCPUInterface( void );
173173
volatile uint64_t ullCriticalNestings[ configNUMBER_OF_CORES ] = { 0 };
174174

175175
/* Saved as part of the task context. If ullPortTaskHasFPUContext is non-zero
176-
* then floating point context must be saved and restored for the task. */
176+
* then floating point context must be saved and restored for the task. */
177177
uint64_t ullPortTaskHasFPUContext[ configNUMBER_OF_CORES ] = { pdFALSE };
178178
uint64_t ullPortYieldRequired[ configNUMBER_OF_CORES ] = { pdFALSE };
179179
uint64_t ullPortInterruptNestings[ configNUMBER_OF_CORES ] = { 0 };
180180

181-
/* flag to control tick ISR handling, this is made true just before schedular start */
182-
__attribute__((section(".shared_ram")))
181+
/* Flag to control tick ISR handling, this is made true just before schedular start. */
182+
__attribute__( ( section( ".shared_ram" ) ) )
183183
uint8_t ucPortSchedulerRunning = pdFALSE;
184184
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
185185

@@ -191,12 +191,12 @@ __attribute__( ( used ) ) const uint64_t ullMaxAPIPriorityMask = ( configMAX_API
191191
/*
192192
* See header file for description.
193193
*/
194-
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
195-
TaskFunction_t pxCode,
196-
void * pvParameters )
194+
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
195+
TaskFunction_t pxCode,
196+
void * pvParameters )
197197
{
198198
/* Setup the initial stack of the task. The stack is set exactly as
199-
* expected by the portRESTORE_CONTEXT() macro. */
199+
* expected by the portRESTORE_CONTEXT() macro. */
200200

201201
/* First all the general purpose registers. */
202202
pxTopOfStack--;
@@ -273,25 +273,25 @@ __attribute__( ( used ) ) const uint64_t ullMaxAPIPriorityMask = ( configMAX_API
273273
#if ( configUSE_TASK_FPU_SUPPORT == portTASK_NO_FPU_CONTEXT_BY_DEFAULT )
274274
{
275275
/* The task will start with a critical nesting count of 0 as interrupts are
276-
* enabled. */
276+
* enabled. */
277277
pxTopOfStack--;
278278
*pxTopOfStack = portNO_CRITICAL_NESTING;
279279

280280
/* The task will start without a floating point context. A task that
281-
* uses the floating point hardware must call vPortTaskUsesFPU() before
282-
* executing any floating point instructions. */
281+
* uses the floating point hardware must call vPortTaskUsesFPU() before
282+
* executing any floating point instructions. */
283283
pxTopOfStack--;
284284
*pxTopOfStack = portNO_FLOATING_POINT_CONTEXT;
285285
}
286286
#elif ( configUSE_TASK_FPU_SUPPORT == portTASK_HAVE_FPU_CONTEXT_BY_DEFAULT )
287287
{
288288
/* The task will start with a floating point context. Leave enough
289-
* space for the registers - and ensure they are initialised to 0. */
289+
* space for the registers - and ensure they are initialised to 0. */
290290
pxTopOfStack -= portFPU_REGISTER_WORDS;
291291
memset( pxTopOfStack, 0x00, portFPU_REGISTER_WORDS * sizeof( StackType_t ) );
292292

293293
/* The task will start with a critical nesting count of 0 as interrupts are
294-
* enabled. */
294+
* enabled. */
295295
pxTopOfStack--;
296296
*pxTopOfStack = portNO_CRITICAL_NESTING;
297297

@@ -322,18 +322,18 @@ BaseType_t xPortStartScheduler( void )
322322
#if ( configASSERT_DEFINED == 1 )
323323
{
324324
if ( portGET_CORE_ID() == 0 )
325-
{
325+
{
326326
volatile uint8_t ucOriginalPriority;
327327
volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET );
328328
volatile uint8_t ucMaxPriorityValue;
329329

330330
/* Determine how many priority bits are implemented in the GIC.
331-
*
332-
* Save the interrupt priority value that is about to be clobbered. */
331+
*
332+
* Save the interrupt priority value that is about to be clobbered. */
333333
ucOriginalPriority = *pucFirstUserPriorityRegister;
334334

335335
/* Determine the number of priority bits available. First write to
336-
* all possible bits. */
336+
* all possible bits. */
337337
*pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE;
338338

339339
/* Read the value back to see how many bits stuck. */
@@ -346,13 +346,12 @@ BaseType_t xPortStartScheduler( void )
346346
}
347347

348348
/* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read
349-
* value. */
350-
349+
* value. */
351350
configASSERT( ucMaxPriorityValue >= portLOWEST_INTERRUPT_PRIORITY );
352351

353352

354353
/* Restore the clobbered interrupt priority register to its original
355-
* value. */
354+
* value. */
356355
*pucFirstUserPriorityRegister = ucOriginalPriority;
357356
}
358357
}
@@ -369,14 +368,14 @@ BaseType_t xPortStartScheduler( void )
369368
* executing. */
370369
portDISABLE_INTERRUPTS();
371370
#if ( configNUMBER_OF_CORES > 1 )
372-
if (0 == portGET_CORE_ID())
371+
if( portGET_CORE_ID() == 0 )
373372
{
374373
/* Start the timer that generates the tick ISR. */
375374
configSETUP_TICK_INTERRUPT();
376375
ucPortSchedulerRunning = pdTRUE;
377-
__asm__ volatile ("dsb sy");
378-
/* Start all other Cores and let them execute vPortRestoreTaskContext()*/
379-
__asm__ volatile ("sev");
376+
__asm__ volatile ( "dsb sy" );
377+
/* Start all other Cores and let them execute vPortRestoreTaskContext(). */
378+
__asm__ volatile ( "sev" );
380379
}
381380
else
382381
{
@@ -386,6 +385,7 @@ BaseType_t xPortStartScheduler( void )
386385
/* Start the timer that generates the tick ISR. */
387386
configSETUP_TICK_INTERRUPT();
388387
#endif /* if ( configNUMBER_OF_CORES > 1 ) */
388+
389389
/* Start the first task executing. */
390390
vPortRestoreTaskContext();
391391

@@ -456,12 +456,13 @@ void FreeRTOS_Tick_Handler( void )
456456
__asm volatile ( "MRS %0, ICC_RPR_EL1" : "=r" ( ullRunningInterruptPriority ) );
457457

458458
configASSERT( ullRunningInterruptPriority == ( portLOWEST_USABLE_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) );
459+
459460
/* Interrupts should not be enabled before this point. */
460461
#if ( configASSERT_DEFINED == 1 )
461462
{
462463
uint64_t ullMaskBits;
463464

464-
__asm volatile ( "mrs %0, DAIF" : "=r" ( ullMaskBits )::"memory" );
465+
__asm volatile ( "MRS %0, DAIF" : "=r" ( ullMaskBits )::"memory" );
465466
configASSERT( ( ullMaskBits & portDAIF_I ) != 0 );
466467
}
467468
#endif /* configASSERT_DEFINED */
@@ -483,6 +484,7 @@ void FreeRTOS_Tick_Handler( void )
483484
#if ( configNUMBER_OF_CORES > 1 )
484485
UBaseType_t x = portENTER_CRITICAL_FROM_ISR();
485486
#endif /* if ( configNUMBER_OF_CORES > 1 ) */
487+
486488
/* Increment the RTOS tick. */
487489
if( xTaskIncrementTick() != pdFALSE )
488490
{
@@ -495,6 +497,7 @@ void FreeRTOS_Tick_Handler( void )
495497
#if ( configNUMBER_OF_CORES > 1 )
496498
portEXIT_CRITICAL_FROM_ISR(x);
497499
#endif /* if ( configNUMBER_OF_CORES > 1 ) */
500+
498501
/* Ensure all interrupt priorities are active again. */
499502
portCLEAR_INTERRUPT_PRIORITIES_MASK();
500503
}
@@ -614,25 +617,29 @@ UBaseType_t uxPortSetInterruptMask( void )
614617
configASSERT( ( volatile void * ) NULL );
615618
}
616619

620+
/*-----------------------------------------------------------*/
621+
617622
#if ( configNUMBER_OF_CORES > 1 )
618623

619-
/* Which core owns the lock */
624+
/* Which core owns the lock? */
620625
volatile uint64_t ucOwnedByCore[ portMAX_CORE_COUNT ];
621-
/* Lock count a core owns */
626+
/* Lock count a core owns. */
622627
volatile uint64_t ucRecursionCountByLock[ eLockCount ];
623-
/* Index 0 is used for ISR lock and Index 1 is used for task lock */
628+
/* Index 0 is used for ISR lock and Index 1 is used for task lock. */
624629
uint32_t ulGateWord[ eLockCount ];
625630

626-
void vInterruptCore(uint32_t ulInterruptID, uint32_t ulCoreID)
631+
void vInterruptCore( uint32_t ulInterruptID, uint32_t ulCoreID )
627632
{
628633
uint64_t ulRegVal = 0;
629-
uint32_t ulCoreMask = (1UL << ulCoreID);
634+
uint32_t ulCoreMask = ( 1UL << ulCoreID );
630635
ulRegVal |= ( (ulCoreMask & 0xFFFF) | ( ( ulInterruptID & 0xF ) << 24U ) );
631636
__asm__ volatile ( "msr ICC_SGI1R_EL1, %0" : : "r" ( ulRegVal ) );
632637
__asm__ volatile ( "dsb sy");
633638
__asm__ volatile ( "isb sy");
634639
}
635640

641+
/*-----------------------------------------------------------*/
642+
636643
static inline void prvSpinUnlock( uint32_t * ulLock )
637644
{
638645
__asm volatile (
@@ -647,6 +654,8 @@ UBaseType_t uxPortSetInterruptMask( void )
647654
);
648655
}
649656

657+
/*-----------------------------------------------------------*/
658+
650659
static inline uint32_t prvSpinTrylock( uint32_t * ulLock )
651660
{
652661
register uint32_t ulRet;
@@ -670,26 +679,32 @@ UBaseType_t uxPortSetInterruptMask( void )
670679
return ulRet;
671680
}
672681

673-
/* Read 64b value shared between cores */
682+
/*-----------------------------------------------------------*/
683+
684+
/* Read 64b value shared between cores. */
674685
static inline uint64_t prvGet64( volatile uint64_t * x )
675686
{
676687
__asm( "dsb sy" );
677688
return *x;
678689
}
679690

680-
/* Write 64b value shared between cores */
691+
/*-----------------------------------------------------------*/
692+
693+
/* Write 64b value shared between cores. */
681694
static inline void prvSet64( volatile uint64_t * x,
682695
uint64_t value )
683696
{
684697
*x = value;
685698
__asm( "dsb sy" );
686699
}
687700

701+
/*-----------------------------------------------------------*/
702+
688703
void vPortRecursiveLock( BaseType_t xCoreID,
689704
ePortRTOSLock eLockNum,
690705
BaseType_t uxAcquire )
691706
{
692-
/* Validate the core ID and lock number */
707+
/* Validate the core ID and lock number. */
693708
configASSERT( xCoreID < portMAX_CORE_COUNT );
694709
configASSERT( eLockNum < eLockCount );
695710

@@ -698,21 +713,21 @@ UBaseType_t uxPortSetInterruptMask( void )
698713
/* Lock acquire */
699714
if( uxAcquire )
700715
{
701-
/* Check if spinlock is available */
702-
/* If spinlock is not available check if the core owns the lock */
703-
/* If the core owns the lock wait increment the lock count by the core */
704-
/* If core does not own the lock wait for the spinlock */
716+
/* Check if spinlock is available. */
717+
/* If spinlock is not available check if the core owns the lock. */
718+
/* If the core owns the lock wait increment the lock count by the core. */
719+
/* If core does not own the lock wait for the spinlock. */
705720
if( prvSpinTrylock( &ulGateWord[ eLockNum ] ) != 0 )
706721
{
707-
/* Check if the core owns the spinlock */
722+
/* Check if the core owns the spinlock. */
708723
if( prvGet64( &ucOwnedByCore[ xCoreID ] ) & ulLockBit )
709724
{
710725
configASSERT( prvGet64( &ucRecursionCountByLock[ eLockNum ] ) != 255u );
711726
prvSet64( &ucRecursionCountByLock[ eLockNum ], ( prvGet64( &ucRecursionCountByLock[ eLockNum ] ) + 1 ) );
712727
return;
713728
}
714729

715-
/* Preload the gate word into the cache */
730+
/* Preload the gate word into the cache. */
716731
uint32_t dummy = ulGateWord[ eLockNum ];
717732
dummy++;
718733

@@ -722,37 +737,39 @@ UBaseType_t uxPortSetInterruptMask( void )
722737
}
723738
}
724739

725-
/* Add barrier to ensure lock is taken before we proceed */
740+
/* Add barrier to ensure lock is taken before we proceed. */
726741
__asm__ __volatile__ ( "dmb sy" ::: "memory" );
727742

728-
/* Assert the lock count is 0 when the spinlock is free and is acquired */
743+
/* Assert the lock count is 0 when the spinlock is free and is acquired. */
729744
configASSERT( prvGet64( &ucRecursionCountByLock[ eLockNum ] ) == 0 );
730745

731-
/* Set lock count as 1 */
746+
/* Set lock count as 1. */
732747
prvSet64( &ucRecursionCountByLock[ eLockNum ], 1 );
733-
/* Set ucOwnedByCore */
748+
/* Set ucOwnedByCore. */
734749
prvSet64( &ucOwnedByCore[ xCoreID ], ( prvGet64( &ucOwnedByCore[ xCoreID ] ) | ulLockBit ) );
735750
}
736-
/* Lock release */
751+
/* Lock release. */
737752
else
738753
{
739-
/* Assert the lock is not free already */
754+
/* Assert the lock is not free already. */
740755
configASSERT( ( prvGet64( &ucOwnedByCore[ xCoreID ] ) & ulLockBit ) != 0 );
741756
configASSERT( prvGet64( &ucRecursionCountByLock[ eLockNum ] ) != 0 );
742757

743-
/* Reduce ucRecursionCountByLock by 1 */
758+
/* Reduce ucRecursionCountByLock by 1. */
744759
prvSet64( &ucRecursionCountByLock[ eLockNum ], ( prvGet64( &ucRecursionCountByLock[ eLockNum ] ) - 1 ) );
745760

746761
if( !prvGet64( &ucRecursionCountByLock[ eLockNum ] ) )
747762
{
748763
prvSet64( &ucOwnedByCore[ xCoreID ], ( prvGet64( &ucOwnedByCore[ xCoreID ] ) & ~ulLockBit ) );
749764
prvSpinUnlock( &ulGateWord[ eLockNum ] );
750-
/* Add barrier to ensure lock status is reflected before we proceed */
765+
/* Add barrier to ensure lock status is reflected before we proceed. */
751766
__asm__ __volatile__ ( "dmb sy" ::: "memory" );
752767
}
753768
}
754769
}
755770

771+
/*-----------------------------------------------------------*/
772+
756773
BaseType_t xPortGetCoreID( void )
757774
{
758775
register BaseType_t xCoreID;
@@ -768,6 +785,8 @@ UBaseType_t uxPortSetInterruptMask( void )
768785
return xCoreID;
769786
}
770787

788+
/*-----------------------------------------------------------*/
789+
771790
void FreeRTOS_SGI_Handler( void )
772791
{
773792
/* Must be the lowest possible priority. */
@@ -786,10 +805,10 @@ UBaseType_t uxPortSetInterruptMask( void )
786805
#endif /* configASSERT_DEFINED */
787806

788807
/* Set interrupt mask before altering scheduler structures. The SGI
789-
* handler runs at the lowest priority, so interrupts cannot already be masked,
790-
* so there is no need to save and restore the current mask value. It is
791-
* necessary to turn off interrupts in the CPU itself while the ICCPMR is being
792-
* updated. */
808+
* handler runs at the lowest priority, so interrupts cannot already be masked,
809+
* so there is no need to save and restore the current mask value. It is
810+
* necessary to turn off interrupts in the CPU itself while the ICCPMR is being
811+
* updated. */
793812
__asm volatile ( "MSR ICC_PMR_EL1, %0 \n"
794813
"DSB SY \n"
795814
"ISB SY \n"
@@ -808,4 +827,6 @@ UBaseType_t uxPortSetInterruptMask( void )
808827
portCLEAR_INTERRUPT_PRIORITIES_MASK();
809828
}
810829

830+
/*-----------------------------------------------------------*/
831+
811832
#endif /* if( configNUMBER_OF_CORES > 1 ) */

0 commit comments

Comments
 (0)