mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Astyle format mbed_fault_handler.[ch]
							parent
							
								
									49928ec143
								
							
						
					
					
						commit
						020f0e580d
					
				| 
						 | 
				
			
			@ -32,22 +32,22 @@
 | 
			
		|||
void print_context_info(void);
 | 
			
		||||
 | 
			
		||||
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
 | 
			
		||||
    //Global for populating the context in exception handler
 | 
			
		||||
    mbed_fault_context_t *const mbed_fault_context=(mbed_fault_context_t *)(FAULT_CONTEXT_LOCATION);
 | 
			
		||||
//Global for populating the context in exception handler
 | 
			
		||||
mbed_fault_context_t *const mbed_fault_context = (mbed_fault_context_t *)(FAULT_CONTEXT_LOCATION);
 | 
			
		||||
#else
 | 
			
		||||
    mbed_fault_context_t fault_context;
 | 
			
		||||
    mbed_fault_context_t *const mbed_fault_context=(mbed_fault_context_t *)&fault_context;
 | 
			
		||||
mbed_fault_context_t fault_context;
 | 
			
		||||
mbed_fault_context_t *const mbed_fault_context = (mbed_fault_context_t *) &fault_context;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//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 mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in)
 | 
			
		||||
{
 | 
			
		||||
    mbed_error_status_t faultStatus = MBED_SUCCESS;
 | 
			
		||||
 | 
			
		||||
    mbed_error_printf("\n++ MbedOS Fault Handler ++\n\nFaultType: ");
 | 
			
		||||
 | 
			
		||||
    switch( fault_type ) {
 | 
			
		||||
    switch (fault_type) {
 | 
			
		||||
        case MEMMANAGE_FAULT_EXCEPTION:
 | 
			
		||||
            mbed_error_printf("MemManageFault");
 | 
			
		||||
            faultStatus = MBED_ERROR_MEMMANAGE_EXCEPTION;
 | 
			
		||||
| 
						 | 
				
			
			@ -76,14 +76,14 @@ void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in)
 | 
			
		|||
    mbed_error_printf("\n\n-- MbedOS Fault Handler --\n\n");
 | 
			
		||||
 | 
			
		||||
    //Now call mbed_error, to log the error and halt the system
 | 
			
		||||
    mbed_error( faultStatus, "Fault exception", mbed_fault_context->PC_reg, NULL, 0 );
 | 
			
		||||
    mbed_error(faultStatus, "Fault exception", mbed_fault_context->PC_reg, NULL, 0);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MBED_NOINLINE void print_context_info(void)
 | 
			
		||||
{
 | 
			
		||||
    //Context Regs
 | 
			
		||||
    for(int i=0;i<13;i++) {
 | 
			
		||||
    for (int i = 0; i < 13; i++) {
 | 
			
		||||
        mbed_error_printf("\nR%-4d: %08" PRIX32, i, ((uint32_t *)(mbed_fault_context))[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ MBED_NOINLINE void print_context_info(void)
 | 
			
		|||
                      "\nxPSR : %08" PRIX32
 | 
			
		||||
                      "\nPSP  : %08" PRIX32
 | 
			
		||||
                      "\nMSP  : %08" PRIX32, mbed_fault_context->SP_reg, mbed_fault_context->LR_reg, mbed_fault_context->PC_reg,
 | 
			
		||||
                                     mbed_fault_context->xPSR, mbed_fault_context->PSP, mbed_fault_context->MSP );
 | 
			
		||||
                      mbed_fault_context->xPSR, mbed_fault_context->PSP, mbed_fault_context->MSP);
 | 
			
		||||
 | 
			
		||||
    //Capture CPUID to get core/cpu info
 | 
			
		||||
    mbed_error_printf("\nCPUID: %08" PRIX32, SCB->CPUID);
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ MBED_NOINLINE void print_context_info(void)
 | 
			
		|||
                      "\nUFSR : %08" PRIX32
 | 
			
		||||
                      "\nDFSR : %08" PRIX32
 | 
			
		||||
                      "\nAFSR : %08" PRIX32  ////Split/Capture CFSR into MMFSR, BFSR, UFSR
 | 
			
		||||
                    ,SCB->HFSR, (0xFF & SCB->CFSR), ((0xFF00 & SCB->CFSR) >> 8), ((0xFFFF0000 & SCB->CFSR) >> 16), SCB->DFSR, SCB->AFSR ); 
 | 
			
		||||
                      , SCB->HFSR, (0xFF & SCB->CFSR), ((0xFF00 & SCB->CFSR) >> 8), ((0xFFFF0000 & SCB->CFSR) >> 16), SCB->DFSR, SCB->AFSR);
 | 
			
		||||
 | 
			
		||||
    //Print MMFAR only if its valid as indicated by MMFSR
 | 
			
		||||
    if ((0xFF & SCB->CFSR) & 0x80) {
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ MBED_NOINLINE void print_context_info(void)
 | 
			
		|||
        //Print Priv level in Thread mode - We capture CONTROL reg which reflects the privilege.
 | 
			
		||||
        //Note that the CONTROL register captured still reflects the privilege status of the
 | 
			
		||||
        //thread mode eventhough we are in Handler mode by the time we capture it.
 | 
			
		||||
        if(mbed_fault_context->CONTROL & 0x1) {
 | 
			
		||||
        if (mbed_fault_context->CONTROL & 0x1) {
 | 
			
		||||
            mbed_error_printf("\nPriv : User");
 | 
			
		||||
        } else {
 | 
			
		||||
            mbed_error_printf("\nPriv : Privileged");
 | 
			
		||||
| 
						 | 
				
			
			@ -141,12 +141,13 @@ MBED_NOINLINE void print_context_info(void)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mbed_error_status_t mbed_get_reboot_fault_context (mbed_fault_context_t *fault_context)
 | 
			
		||||
mbed_error_status_t mbed_get_reboot_fault_context(mbed_fault_context_t *fault_context)
 | 
			
		||||
{
 | 
			
		||||
    mbed_error_status_t status = MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_ITEM_NOT_FOUND);
 | 
			
		||||
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
 | 
			
		||||
    if(fault_context == NULL)
 | 
			
		||||
    if (fault_context == NULL) {
 | 
			
		||||
        return MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INVALID_ARGUMENT);
 | 
			
		||||
    }
 | 
			
		||||
    memcpy(fault_context, mbed_fault_context, sizeof(mbed_fault_context_t));
 | 
			
		||||
    status = MBED_SUCCESS;
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ typedef struct {
 | 
			
		|||
 | 
			
		||||
//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_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 mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Call this function to retrieve the fault context after a fatal exception which triggered a system reboot. The function retrieves the fault context stored in crash-report ram area which is preserved over reboot.
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in);
 | 
			
		|||
 *                              MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by teh system
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
mbed_error_status_t mbed_get_reboot_fault_context (mbed_fault_context_t *fault_context);
 | 
			
		||||
mbed_error_status_t mbed_get_reboot_fault_context(mbed_fault_context_t *fault_context);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue