From e4525fbea131356e8308bc5490aba3c99d85a8e1 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Thu, 4 Oct 2018 16:26:47 -0500 Subject: [PATCH] Mbed Fault Handler was originally placed under rtos folder because of its dependency on some of the RTX data structures for capturing the thread info. But with the new error handling in place thread info collection on hardfaults has been moved to Mbed_error handler. There is no point for fault handler implementation to exist under rtos and can be used for RTOS-less builds as well. So moving under platform folder. Also removing some references to RTX data structs like osRtxInfo from fault handler implementation. --- .../TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S | 2 -- .../TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S | 1 - .../TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S | 2 -- .../TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.c | 5 ++--- .../TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.h | 8 ++++---- 5 files changed, 6 insertions(+), 12 deletions(-) rename {rtos => platform}/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S (98%) rename {rtos => platform}/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S (99%) rename {rtos => platform}/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S (98%) rename rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.c => platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.c (98%) rename rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.h => platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.h (91%) diff --git a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S similarity index 98% rename from rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S rename to platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S index 71607bf0b7..7892db01de 100644 --- a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S +++ b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S @@ -68,7 +68,6 @@ UsageFault_Handler\ Fault_Handler PROC EXPORT Fault_Handler #if (DOMAIN_NS == 1) - IMPORT osRtxInfo IMPORT mbed_fault_handler IMPORT mbed_fault_context @@ -152,7 +151,6 @@ Fault_Handler_Continue2 LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler MOV R0,R12 LDR R1,=mbed_fault_context - LDR R2,=osRtxInfo BLX R3 #endif B . ; Just in case we come back here diff --git a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S similarity index 99% rename from rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S rename to platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S index 2266d07223..b78b37c076 100644 --- a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S +++ b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S @@ -184,7 +184,6 @@ Fault_Handler_Continue2: LDR R3,=mbed_fault_handler // Load address of mbedFaultHandler MOV R0,R12 LDR R1,=mbed_fault_context - LDR R2,=osRtxInfo BLX R3 #endif B . // Just in case we come back here diff --git a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S similarity index 98% rename from rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S rename to platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S index d76fb473fb..21db339c5b 100644 --- a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S +++ b/platform/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S @@ -63,7 +63,6 @@ UsageFault_Handler Fault_Handler EXPORT Fault_Handler #if (DOMAIN_NS == 1) - IMPORT osRtxInfo IMPORT mbed_fault_context IMPORT mbed_fault_handler @@ -147,7 +146,6 @@ Fault_Handler_Continue2 LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler MOV R0,R12 LDR R1,=mbed_fault_context - LDR R2,=osRtxInfo BLX R3 #endif B . ; Just in case we come back here diff --git a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.c b/platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.c similarity index 98% rename from rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.c rename to platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.c index 20607431e9..63a1d7ec29 100644 --- a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.c +++ b/platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.c @@ -14,13 +14,12 @@ * limitations under the License. */ -#include "rtx_os.h" #include "device.h" #include "platform/mbed_error.h" #include "platform/mbed_interface.h" #ifndef MBED_FAULT_HANDLER_DISABLED -#include "mbed_rtx_fault_handler.h" +#include "mbed_fault_handler.h" //Functions Prototypes void print_context_info(void); @@ -30,7 +29,7 @@ mbed_fault_context_t mbed_fault_context; //This is a handler function called from Fault handler to print the error information out. //This runs in fault context and uses special functions(defined in mbed_rtx_fault_handler.c) to print the information without using C-lib support. -void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn) +void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in) { mbed_error_status_t faultStatus = MBED_SUCCESS; diff --git a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.h b/platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.h similarity index 91% rename from rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.h rename to platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.h index 2039f0bcd0..bcc3ded135 100644 --- a/rtos/TARGET_CORTEX/TARGET_CORTEX_M/mbed_rtx_fault_handler.h +++ b/platform/TARGET_CORTEX/TARGET_CORTEX_M/mbed_fault_handler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MBED_RTX_FAULT_HANDLER_H -#define MBED_RTX_FAULT_HANDLER_H +#ifndef MBED_FAULT_HANDLER_H +#define MBED_FAULT_HANDLER_H //Fault context struct //WARNING: DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES in except.S files. @@ -52,7 +52,7 @@ typedef struct { #define USAGE_FAULT_EXCEPTION (0x40) //This is a handler function called from Fault handler to print the error information out. -//This runs in fault context and uses special functions(defined in mbed_rtx_fault_handler.c) to print the information without using C-lib support. -void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn); +//This runs in fault context and uses special functions(defined in mbed_fault_handler.c) to print the information without using C-lib support. +void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in); #endif