arm: Restructure ARM cpu related preprocessor conditionals.
The ARM code base provides for three mutually exclusive ARM architecture related conditional compilation choices. M0_M0PLUS, M3_M4 and M7. Throughout the code base we have conditional compilation gated around these three choices. Adjust the form of this conditional compilation to adopt a uniform structure. The uniform structure always selects code based on the definition of an appropriate config option rather the the absence of a definition. Removing the extensive use of #else ensures that when support for other ARM architecture versions is added we get hard compilation failures rather than attempting to compile inappropriate code for the added architecture with unexpected runtime consequences. Adopting this uniform structure makes it straight forward to replace the adhoc CPU_CORTEX_M3_M4 and CPU_CORTEX_M0_M0PLUS configuration variables with ones that directly represent the actual underlying ARM architectures we provide support for. This change also paves the way for folding adhoc conditional compilation related to CPU_CORTEX_M7 directly in support for ARMv7-M. This change is mechanical in nature involving two transforms: 1) #if !defined(CONFIG_CPU_CORTEX_M0_M0PLUS) ... is transformed to: #if defined(CONFIG_CPU_CORTEX_M0_M0PLUS) #elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7) ... 2) #if defined(CONFIG_CPU_CORTEX_M0_M0PLUS) ... #else ... #endif is transformed to: #if defined(CONFIG_CPU_CORTEX_M0_M0PLUS) ... #elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7) ... #else #error Unknown ARM architecture #endif Change-Id: I7229029b174da3a8b3c6fb2eec63d776f1d11e24 Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
This commit is contained in:
parent
36ab9dd31d
commit
e2d3cc4b81
15 changed files with 166 additions and 64 deletions
|
@ -69,7 +69,8 @@ void _FaultDump(const NANO_ESF *esf, int fault)
|
|||
k_current_get(),
|
||||
esf->pc);
|
||||
|
||||
#if !defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#if defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7)
|
||||
int escalation = 0;
|
||||
|
||||
if (3 == fault) { /* hard fault */
|
||||
|
@ -100,7 +101,9 @@ void _FaultDump(const NANO_ESF *esf, int fault)
|
|||
|
||||
/* clear USFR sticky bits */
|
||||
_ScbUsageFaultAllFaultsReset();
|
||||
#endif /* !CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -120,7 +123,8 @@ static void _FaultThreadShow(const NANO_ESF *esf)
|
|||
k_current_get(), esf->pc);
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#if defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7)
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -244,7 +248,9 @@ static void _DebugMonitor(const NANO_ESF *esf)
|
|||
PR_EXC("***** Debug monitor exception (not implemented) *****\n");
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -260,7 +266,7 @@ static void _HardFault(const NANO_ESF *esf)
|
|||
|
||||
#if defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
_FaultThreadShow(esf);
|
||||
#else /* CONFIG_CPU_CORTEX_M3_M4 */
|
||||
#elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7)
|
||||
if (_ScbHardFaultIsBusErrOnVectorRead()) {
|
||||
PR_EXC(" Bus fault on vector table read\n");
|
||||
} else if (_ScbHardFaultIsForced()) {
|
||||
|
@ -273,7 +279,9 @@ static void _HardFault(const NANO_ESF *esf)
|
|||
_UsageFault(esf);
|
||||
}
|
||||
}
|
||||
#endif /* !CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -318,7 +326,8 @@ static void _FaultDump(const NANO_ESF *esf, int fault)
|
|||
case 3:
|
||||
_HardFault(esf);
|
||||
break;
|
||||
#if !defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#if defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7)
|
||||
case 4:
|
||||
_MpuFault(esf, 0);
|
||||
break;
|
||||
|
@ -331,7 +340,9 @@ static void _FaultDump(const NANO_ESF *esf, int fault)
|
|||
case 12:
|
||||
_DebugMonitor(esf);
|
||||
break;
|
||||
#endif /* !CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
default:
|
||||
_ReservedException(esf, fault);
|
||||
break;
|
||||
|
@ -376,7 +387,10 @@ void _Fault(const NANO_ESF *esf)
|
|||
*/
|
||||
void _FaultInit(void)
|
||||
{
|
||||
#if !defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#if defined(CONFIG_CPU_CORTEX_M0_M0PLUS)
|
||||
#elif defined(CONFIG_CPU_CORTEX_M3_M4) || defined(CONFIG_CPU_CORTEX_M7)
|
||||
_ScbDivByZeroFaultEnable();
|
||||
#endif /* !CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
#else
|
||||
#error Unknown ARM architecture
|
||||
#endif /* CONFIG_CPU_CORTEX_M0_M0PLUS */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue