/** Set the period for the debug agent timer. Zero means disable the timer. @param[in] TimerPeriodMilliseconds Frequency of the debug agent timer. **/ VOID EFIAPI DebugAgentTimerSetPeriod ( IN UINT32 TimerPeriodMilliseconds ) { UINT64 TimerCount; INT32 LoadValue; if (TimerPeriodMilliseconds == 0) { // Turn off GPTIMER3 MmioWrite32 (gTCLR, TCLR_ST_OFF); DisableInterruptSource (); } else { // Calculate required timer count TimerCount = DivU64x32(TimerPeriodMilliseconds * 1000000, PcdGet32(PcdDebugAgentTimerFreqNanoSeconds)); // Set GPTIMER5 Load register LoadValue = (INT32) -TimerCount; MmioWrite32 (gTLDR, LoadValue); MmioWrite32 (gTCRR, LoadValue); // Enable Overflow interrupt MmioWrite32 (gTIER, TIER_TCAR_IT_DISABLE | TIER_OVF_IT_ENABLE | TIER_MAT_IT_DISABLE); // Turn on GPTIMER3, it will reload at overflow MmioWrite32 (gTCLR, TCLR_AR_AUTORELOAD | TCLR_ST_ON); EnableInterruptSource (); } }
/** Register Handler for the specified interrupt source. @param This Instance pointer for this protocol @param Source Hardware source of the interrupt @param Handler Callback for interrupt. NULL to unregister @retval EFI_SUCCESS Source was updated to support Handler. @retval EFI_DEVICE_ERROR Hardware could not be programmed. **/ STATIC EFI_STATUS EFIAPI RegisterInterruptSource ( IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This, IN HARDWARE_INTERRUPT_SOURCE Source, IN HARDWARE_INTERRUPT_HANDLER Handler ) { if (Source >= NUM_IRQS) { ASSERT (FALSE); return EFI_UNSUPPORTED; } if (Handler == NULL && mRegisteredInterruptHandlers[Source] == NULL) { return EFI_INVALID_PARAMETER; } if (Handler != NULL && mRegisteredInterruptHandlers[Source] != NULL) { return EFI_ALREADY_STARTED; } mRegisteredInterruptHandlers[Source] = Handler; return EnableInterruptSource (This, Source); }