X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FLibrary%2FBaseXApicLib%2FBaseXApicLib.c;fp=UefiCpuPkg%2FLibrary%2FBaseXApicLib%2FBaseXApicLib.c;h=1fca66ef1b293b76483aa818d5e757c094e5d01c;hp=6cf36cb8f4afd6f4ecfb0ec2edd6a8380eca7a0c;hb=14e4ca25c6199fa29bda7066f31d919197840664;hpb=0d4c1db81aab86963536deb8253f35546c4398ea diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c index 6cf36cb8f4..1fca66ef1b 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -563,6 +563,39 @@ SendInitSipiSipiAllExcludingSelf ( SendIpi (IcrLow.Uint32, 0); } +/** + Initialize the state of the SoftwareEnable bit in the Local APIC + Spurious Interrupt Vector register. + + @param Enable If TRUE, then set SoftwareEnable to 1 + If FALSE, then set SoftwareEnable to 0. + +**/ +VOID +EFIAPI +InitializeLocalApicSoftwareEnable ( + IN BOOLEAN Enable + ) +{ + LOCAL_APIC_SVR Svr; + + // + // Set local APIC software-enabled bit. + // + Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); + if (Enable) { + if (Svr.Bits.SoftwareEnable == 0) { + Svr.Bits.SoftwareEnable = 1; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } else { + if (Svr.Bits.SoftwareEnable == 1) { + Svr.Bits.SoftwareEnable = 0; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } +} + /** Programming Virtual Wire Mode. @@ -679,7 +712,6 @@ InitializeApicTimer ( IN UINT8 Vector ) { - LOCAL_APIC_SVR Svr; LOCAL_APIC_DCR Dcr; LOCAL_APIC_LVT_TIMER LvtTimer; UINT32 Divisor; @@ -687,9 +719,7 @@ InitializeApicTimer ( // // Ensure local APIC is in software-enabled state. // - Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); - Svr.Bits.SoftwareEnable = 1; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + InitializeLocalApicSoftwareEnable (TRUE); // // Program init-count register.