Skip to content

Commit

Permalink
arm: arch code naming cleanup
Browse files Browse the repository at this point in the history
This patch re-namespaces global variables and functions
that are used only within the arch/arm/ code to be
prefixed with z_arm_.

Some instances of CamelCase have been corrected.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information
Andrew Boie authored and ioannisg committed Oct 4, 2019
1 parent 4bca0f3 commit 8c98a97
Show file tree
Hide file tree
Showing 51 changed files with 332 additions and 329 deletions.
83 changes: 42 additions & 41 deletions arch/arm/core/cortex_m/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ LOG_MODULE_DECLARE(os);
*/

#if (CONFIG_FAULT_DUMP == 1)
static void FaultShow(const z_arch_esf_t *esf, int fault)
static void fault_show(const z_arch_esf_t *esf, int fault)
{
PR_EXC("Fault! EXC #%d", fault);

Expand All @@ -156,7 +156,7 @@ static void FaultShow(const z_arch_esf_t *esf, int fault)
*
* For Dump level 0, no information needs to be generated.
*/
static void FaultShow(const z_arch_esf_t *esf, int fault)
static void fault_show(const z_arch_esf_t *esf, int fault)
{
(void)esf;
(void)fault;
Expand Down Expand Up @@ -205,13 +205,14 @@ u32_t z_check_thread_stack_fail(const u32_t fault_addr,

/**
*
* @brief Dump MPU fault information
* @brief Dump MemManage fault information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return error code to identify the fatal error reason
*/
static u32_t MpuFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)
static u32_t mem_manage_fault(z_arch_esf_t *esf, int from_hard_fault,
bool *recoverable)
{
u32_t reason = K_ERR_CPU_EXCEPTION;
u32_t mmfar = -EINVAL;
Expand Down Expand Up @@ -239,7 +240,7 @@ static u32_t MpuFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)

if ((SCB->CFSR & SCB_CFSR_MMARVALID_Msk) != 0) {
PR_EXC(" MMFAR Address: 0x%x", mmfar);
if (fromHardFault) {
if (from_hard_fault) {
/* clear SCB_MMAR[VALID] to reset */
SCB->CFSR &= ~SCB_CFSR_MMARVALID_Msk;
}
Expand Down Expand Up @@ -328,13 +329,13 @@ static u32_t MpuFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)

/**
*
* @brief Dump bus fault information
* @brief Dump BusFault information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return N/A
*/
static int BusFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)
static int bus_fault(z_arch_esf_t *esf, int from_hard_fault, bool *recoverable)
{
u32_t reason = K_ERR_CPU_EXCEPTION;

Expand All @@ -360,7 +361,7 @@ static int BusFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)

if ((SCB->CFSR & SCB_CFSR_BFARVALID_Msk) != 0) {
PR_EXC(" BFAR Address: 0x%x", bfar);
if (fromHardFault) {
if (from_hard_fault) {
/* clear SCB_CFSR_BFAR[VALID] to reset */
SCB->CFSR &= ~SCB_CFSR_BFARVALID_Msk;
}
Expand Down Expand Up @@ -482,13 +483,13 @@ static int BusFault(z_arch_esf_t *esf, int fromHardFault, bool *recoverable)

/**
*
* @brief Dump usage fault information
* @brief Dump UsageFault information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return error code to identify the fatal error reason
*/
static u32_t UsageFault(const z_arch_esf_t *esf)
static u32_t usage_fault(const z_arch_esf_t *esf)
{
u32_t reason = K_ERR_CPU_EXCEPTION;

Expand Down Expand Up @@ -538,13 +539,13 @@ static u32_t UsageFault(const z_arch_esf_t *esf)
#if defined(CONFIG_ARM_SECURE_FIRMWARE)
/**
*
* @brief Dump secure fault information
* @brief Dump SecureFault information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return N/A
*/
static void SecureFault(const z_arch_esf_t *esf)
static void secure_fault(const z_arch_esf_t *esf)
{
PR_FAULT_INFO("***** SECURE FAULT *****");

Expand Down Expand Up @@ -579,11 +580,11 @@ static void SecureFault(const z_arch_esf_t *esf)
*
* @brief Dump debug monitor exception information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return N/A
*/
static void DebugMonitor(const z_arch_esf_t *esf)
static void debug_monitor(const z_arch_esf_t *esf)
{
ARG_UNUSED(esf);

Expand All @@ -599,11 +600,11 @@ static void DebugMonitor(const z_arch_esf_t *esf)
*
* @brief Dump hard fault information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return error code to identify the fatal error reason
*/
static u32_t HardFault(z_arch_esf_t *esf, bool *recoverable)
static u32_t hard_fault(z_arch_esf_t *esf, bool *recoverable)
{
u32_t reason = K_ERR_CPU_EXCEPTION;

Expand Down Expand Up @@ -643,14 +644,14 @@ static u32_t HardFault(z_arch_esf_t *esf, bool *recoverable)
} else if ((SCB->HFSR & SCB_HFSR_FORCED_Msk) != 0) {
PR_EXC(" Fault escalation (see below)");
if (SCB_MMFSR != 0) {
reason = MpuFault(esf, 1, recoverable);
reason = mem_manage_fault(esf, 1, recoverable);
} else if (SCB_BFSR != 0) {
reason = BusFault(esf, 1, recoverable);
reason = bus_fault(esf, 1, recoverable);
} else if (SCB_UFSR != 0) {
reason = UsageFault(esf);
reason = usage_fault(esf);
#if defined(CONFIG_ARM_SECURE_FIRMWARE)
} else if (SAU->SFSR != 0) {
SecureFault(esf);
secure_fault(esf);
#endif /* CONFIG_ARM_SECURE_FIRMWARE */
}
}
Expand All @@ -665,11 +666,11 @@ static u32_t HardFault(z_arch_esf_t *esf, bool *recoverable)
*
* @brief Dump reserved exception information
*
* See _FaultDump() for example.
* See z_arm_fault_dump() for example.
*
* @return N/A
*/
static void ReservedException(const z_arch_esf_t *esf, int fault)
static void reserved_exception(const z_arch_esf_t *esf, int fault)
{
ARG_UNUSED(esf);

Expand All @@ -679,47 +680,47 @@ static void ReservedException(const z_arch_esf_t *esf, int fault)
}

/* Handler function for ARM fault conditions. */
static u32_t FaultHandle(z_arch_esf_t *esf, int fault, bool *recoverable)
static u32_t fault_handle(z_arch_esf_t *esf, int fault, bool *recoverable)
{
u32_t reason = K_ERR_CPU_EXCEPTION;

*recoverable = false;

switch (fault) {
case 3:
reason = HardFault(esf, recoverable);
reason = hard_fault(esf, recoverable);
break;
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
/* HardFault is used for all fault conditions on ARMv6-M. */
/* HardFault is raised for all fault conditions on ARMv6-M. */
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
case 4:
reason = MpuFault(esf, 0, recoverable);
reason = mem_manage_fault(esf, 0, recoverable);
break;
case 5:
reason = BusFault(esf, 0, recoverable);
reason = bus_fault(esf, 0, recoverable);
break;
case 6:
reason = UsageFault(esf);
reason = usage_fault(esf);
break;
#if defined(CONFIG_ARM_SECURE_FIRMWARE)
case 7:
SecureFault(esf);
secure_fault(esf);
break;
#endif /* CONFIG_ARM_SECURE_FIRMWARE */
case 12:
DebugMonitor(esf);
debug_monitor(esf);
break;
#else
#error Unknown ARM architecture
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
default:
ReservedException(esf, fault);
reserved_exception(esf, fault);
break;
}

if ((*recoverable) == false) {
/* Dump generic information about the fault. */
FaultShow(esf, fault);
fault_show(esf, fault);
}

return reason;
Expand All @@ -733,7 +734,7 @@ static u32_t FaultHandle(z_arch_esf_t *esf, int fault, bool *recoverable)
*
* @param secure_esf Pointer to the secure stack frame.
*/
static void SecureStackDump(const z_arch_esf_t *secure_esf)
static void secure_stack_dump(const z_arch_esf_t *secure_esf)
{
/*
* In case a Non-Secure exception interrupted the Secure
Expand Down Expand Up @@ -769,7 +770,7 @@ static void SecureStackDump(const z_arch_esf_t *secure_esf)
PR_FAULT_INFO(" S instruction address: 0x%x", sec_ret_addr);

}
#define SECURE_STACK_DUMP(esf) SecureStackDump(esf)
#define SECURE_STACK_DUMP(esf) secure_stack_dump(esf)
#else
/* We do not dump the Secure stack information for lower dump levels. */
#define SECURE_STACK_DUMP(esf)
Expand Down Expand Up @@ -805,7 +806,7 @@ static void SecureStackDump(const z_arch_esf_t *secure_esf)
* Note: exc_return argument shall only be used by the Fault handler if we are
* running a Secure Firmware.
*/
void _Fault(z_arch_esf_t *esf, u32_t exc_return)
void z_arm_fault(z_arch_esf_t *esf, u32_t exc_return)
{
u32_t reason = K_ERR_CPU_EXCEPTION;
int fault = SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk;
Expand Down Expand Up @@ -880,7 +881,7 @@ void _Fault(z_arch_esf_t *esf, u32_t exc_return)
(void) exc_return;
#endif /* CONFIG_ARM_SECURE_FIRMWARE */

reason = FaultHandle(esf, fault, &recoverable);
reason = fault_handle(esf, fault, &recoverable);
if (recoverable) {
return;
}
Expand All @@ -900,7 +901,7 @@ void _Fault(z_arch_esf_t *esf, u32_t exc_return)
*
* @return N/A
*/
void z_FaultInit(void)
void z_arm_fault_init(void)
{
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/core/cortex_m/irq_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @return N/A
*/

void z_IntLibInit(void)
void z_arm_int_lib_init(void)
{
int irq = 0;

Expand Down
8 changes: 4 additions & 4 deletions arch/arm/core/cortex_m/mpu/arm_core_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(mpu);
* available MPU regions for dynamic programming depends on the number of the
* static MPU regions currently being programmed, and the total number of HW-
* available MPU regions. This macro is only used internally in function
* z_arch_configure_dynamic_mpu_regions(), to reserve sufficient area for the
* z_arm_configure_dynamic_mpu_regions(), to reserve sufficient area for the
* array of dynamic regions passed to the underlying driver.
*/
#if defined(CONFIG_USERSPACE)
Expand Down Expand Up @@ -59,7 +59,7 @@ LOG_MODULE_REGISTER(mpu);
* For some MPU architectures, such as the unmodified ARMv8-M MPU,
* the function must execute with MPU enabled.
*/
void z_arch_configure_static_mpu_regions(void)
void z_arm_configure_static_mpu_regions(void)
{
#if defined(CONFIG_COVERAGE_GCOV) && defined(CONFIG_USERSPACE)
const struct k_mem_partition gcov_region =
Expand Down Expand Up @@ -142,7 +142,7 @@ void z_arch_configure_static_mpu_regions(void)
* For some MPU architectures, such as the unmodified ARMv8-M MPU,
* the function must execute with MPU enabled.
*/
void z_arch_configure_dynamic_mpu_regions(struct k_thread *thread)
void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread)
{
/* Define an array of k_mem_partition objects to hold the configuration
* of the respective dynamic MPU regions to be programmed for
Expand Down Expand Up @@ -293,7 +293,7 @@ void z_arch_mem_domain_thread_add(struct k_thread *thread)
* This triggers re-programming of the entire dynamic
* memory map.
*/
z_arch_configure_dynamic_mpu_regions(thread);
z_arm_configure_dynamic_mpu_regions(thread);
}

/*
Expand Down
20 changes: 10 additions & 10 deletions arch/arm/core/cortex_m/reset.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

_ASM_FILE_PROLOGUE

GTEXT(__reset)
GTEXT(z_arm_reset)
GTEXT(memset)
GDATA(_interrupt_stack)
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
Expand All @@ -39,19 +39,19 @@ GTEXT(z_platform_init)
* deep trouble.
*
* We want to use the process stack pointer (PSP) instead of the MSP, since the
* MSP is to be set up to point to the one-and-only interrupt stack during later
* boot. That would not be possible if in use for running C code.
* MSP is to be set up to point to the one-and-only interrupt stack during
* later boot. That would not be possible if in use for running C code.
*
* When these steps are completed, jump to _PrepC(), which will finish setting
* up the system for running C code.
* When these steps are completed, jump to z_arm_prep_c(), which will finish
* setting up the system for running C code.
*
* @return N/A
*/

SECTION_SUBSEC_FUNC(TEXT,_reset_section,__reset)
SECTION_SUBSEC_FUNC(TEXT,_reset_section,z_arm_reset)

/*
* The entry point is located at the __reset symbol, which
* The entry point is located at the z_arm_reset symbol, which
* is fetched by a XIP image playing the role of a bootloader, which jumps to
* it, not through the reset vector mechanism. Such bootloaders might want to
* search for a __start symbol instead, so create that alias here.
Expand All @@ -74,7 +74,7 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)

#ifdef CONFIG_WDOG_INIT
/* board-specific watchdog initialization is necessary */
bl _WdogInit
bl z_arm_watchdog_init
#endif

#ifdef CONFIG_INIT_STACKS
Expand Down Expand Up @@ -105,7 +105,7 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)

/*
* 'bl' jumps the furthest of the branch instructions that are
* supported on all platforms. So it is used when jumping to _PrepC
* supported on all platforms. So it is used when jumping to z_arm_prep_c
* (even though we do not intend to return).
*/
bl _PrepC
bl z_arm_prep_c
Loading

0 comments on commit 8c98a97

Please sign in to comment.