VOID ArmCpuSetup ( IN UINTN MpId ) { // Note: System Counter frequency can only be set in Secure privileged mode, // if security extensions are implemented. ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz)); }
RETURN_STATUS EFIAPI TimerConstructor ( VOID ) { // Check if the ARM Generic Timer Extension is implemented if (ArmIsArchTimerImplemented ()) { UINTN TimerFreq; // Check if Architectural Timer frequency is valid number (should not be 0) ASSERT (PcdGet32 (PcdArmArchTimerFreqInHz)); // Check if ticks/uS is not 0. The Architectural timer runs at constant // frequency irrespective of CPU frequency. According to General Timer Ref // manual lower bound of the frequency is in the range of 1-10MHz ASSERT (TICKS_PER_MICRO_SEC); #ifdef MDE_CPU_ARM // Only set the frequency for ARMv7. We expect the secure firmware to have already do it // If the security extensions are not implemented set Timer Frequency if ((ArmReadIdPfr1 () & ARM_PFR1_SEC) == 0x0) { ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz)); } #endif // Architectural Timer Frequency must be set in the Secure privileged(if secure extensions are supported) mode. // If the reset value (0) is returned just ASSERT. TimerFreq = ArmArchTimerGetTimerFreq (); ASSERT (TimerFreq != 0); } else { DEBUG ((EFI_D_ERROR, "ARM Architectural Timer is not available in the CPU, hence this library can not be used.\n")); ASSERT (0); } return RETURN_SUCCESS; }