/** Initialize debug agent. This function is used to set up debug environment to support source level debugging. If certain Debug Agent Library instance has to save some private data in the stack, this function must work on the mode that doesn't return to the caller, then the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is responsible to invoke the passing-in function at the end of InitializeDebugAgent(). If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by passing in the Context to be its parameter. If Function() is NULL, Debug Agent Library instance will return after setup debug environment. @param[in] InitFlag Init flag is used to decide the initialize process. @param[in] Context Context needed according to InitFlag; it was optional. @param[in] Function Continue function called by debug agent library; it was optional. **/ VOID EFIAPI InitializeDebugAgent ( IN UINT32 InitFlag, IN VOID *Context, OPTIONAL IN DEBUG_AGENT_CONTINUE Function OPTIONAL ) { UINTN Offset; UINTN Length; BOOLEAN IrqEnabled; UINT64 *VectorBase; // // Disable interrupts // IrqEnabled = ArmGetInterruptState (); ArmDisableInterrupts (); ArmDisableFiq (); // // Copy an implementation of the ARM exception vectors to PcdCpuVectorBaseAddress. // Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart; // // Reserve space for the exception handlers // VectorBase = (UINT64 *)(UINTN)PcdGet64 (PcdCpuVectorBaseAddress); // Copy our assembly code into the page that contains the exception vectors. CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length); // // Patch in the common Assembly exception handler // Offset = (UINTN)CommonExceptionEntry - (UINTN)ExceptionHandlersStart; *(UINTN *) (((UINT8 *)VectorBase) + Offset) = (UINTN)AsmCommonExceptionEntry; // Flush Caches since we updated executable stuff InvalidateInstructionCacheRange ((VOID *)PcdGet64(PcdCpuVectorBaseAddress), Length); // setup a timer so gdb can break in via ctrl-c DebugAgentTimerIntialize (); if (IrqEnabled) { ArmEnableInterrupts (); } if (Function != NULL) { Function (Context); } return; }
/** This function enables interrupt processing by the processor. @param This The EFI_CPU_ARCH_PROTOCOL instance. @retval EFI_SUCCESS Interrupts are enabled on the processor. @retval EFI_DEVICE_ERROR Interrupts could not be enabled on the processor. **/ EFI_STATUS EFIAPI CpuEnableInterrupt ( IN EFI_CPU_ARCH_PROTOCOL *This ) { ArmEnableInterrupts (); return EFI_SUCCESS; }
VOID AArch64DataCacheOperation ( IN AARCH64_CACHE_OPERATION DataCacheOperation ) { UINTN SavedInterruptState; SavedInterruptState = ArmGetInterruptState (); ArmDisableInterrupts(); AArch64AllDataCachesOperation (DataCacheOperation); ArmDrainWriteBuffer (); if (SavedInterruptState) { ArmEnableInterrupts (); } }
VOID ArmV7DataCacheOperation ( IN ARM_V7_CACHE_OPERATION DataCacheOperation ) { UINTN SavedInterruptState; SavedInterruptState = ArmGetInterruptState (); ArmDisableInterrupts (); ArmV7AllDataCachesOperation (DataCacheOperation); ArmDataSynchronizationBarrier (); if (SavedInterruptState) { ArmEnableInterrupts (); } }