/** Setup all the hardware needed for the debug agents timer. This function is used to set up debug enviroment. It may enable interrupts. **/ VOID EFIAPI DebugAgentTimerIntialize ( VOID ) { UINT32 TimerBaseAddress; UINT32 TimerNumber; TimerNumber = PcdGet32(PcdOmap35xxDebugAgentTimer); gVector = InterruptVectorForTimer (TimerNumber); // Set up the timer registers TimerBaseAddress = TimerBase (TimerNumber); gTISR = TimerBaseAddress + GPTIMER_TISR; gTCLR = TimerBaseAddress + GPTIMER_TCLR; gTLDR = TimerBaseAddress + GPTIMER_TLDR; gTCRR = TimerBaseAddress + GPTIMER_TCRR; gTIER = TimerBaseAddress + GPTIMER_TIER; if ((TimerNumber < 2) || (TimerNumber > 9)) { // This code assumes one the General Purpose timers is used // GPT2 - GPT9 CpuDeadLoop (); } // Set source clock for GPT2 - GPT9 to SYS_CLK MmioOr32 (CM_CLKSEL_PER, 1 << (TimerNumber - 2)); }
/** Initialize the state information for the Timer Architectural Protocol and the Timer Debug support protocol that allows the debugger to break into a running program. @param ImageHandle of the loaded driver @param SystemTable Pointer to the System Table @retval EFI_SUCCESS Protocol registered @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure @retval EFI_DEVICE_ERROR Hardware problems **/ EFI_STATUS EFIAPI TimerInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_HANDLE Handle = NULL; EFI_STATUS Status; UINT32 TimerBaseAddress; // Find the interrupt controller protocol. ASSERT if not found. Status = gBS->LocateProtocol (&gHardwareInterruptProtocolGuid, NULL, (VOID **)&gInterrupt); ASSERT_EFI_ERROR (Status); // Set up the timer registers TimerBaseAddress = TimerBase (FixedPcdGet32(PcdOmap35xxArchTimer)); TISR = TimerBaseAddress + GPTIMER_TISR; TCLR = TimerBaseAddress + GPTIMER_TCLR; TLDR = TimerBaseAddress + GPTIMER_TLDR; TCRR = TimerBaseAddress + GPTIMER_TCRR; TIER = TimerBaseAddress + GPTIMER_TIER; // Disable the timer Status = TimerDriverSetTimerPeriod (&gTimer, 0); ASSERT_EFI_ERROR (Status); // Install interrupt handler gVector = InterruptVectorForTimer (FixedPcdGet32(PcdOmap35xxArchTimer)); Status = gInterrupt->RegisterInterruptSource (gInterrupt, gVector, TimerInterruptHandler); ASSERT_EFI_ERROR (Status); // Turn on the functional clock for Timer MmioOr32 (CM_FCLKEN_PER, CM_FCLKEN_PER_EN_GPT3_ENABLE); // Set up default timer Status = TimerDriverSetTimerPeriod (&gTimer, FixedPcdGet32(PcdTimerPeriod)); ASSERT_EFI_ERROR (Status); // Install the Timer Architectural Protocol onto a new handle Status = gBS->InstallMultipleProtocolInterfaces ( &Handle, &gEfiTimerArchProtocolGuid, &gTimer, NULL ); ASSERT_EFI_ERROR(Status); return Status; }