2 SMM CPU Platform Hook library instance for QEMU.
4 Copyright (c) 2020, Red Hat, Inc.
5 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/BaseLib.h> // AsmReadMsr64()
11 #include <Register/Intel/ArchitecturalMsr.h> // MSR_IA32_APIC_BASE_REGISTER
13 #include <Library/SmmCpuPlatformHookLib.h>
16 Checks if platform produces a valid SMI.
18 This function checks if platform produces a valid SMI. This function is
19 called at SMM entry to detect if this is a spurious SMI. This function
20 must be implemented in an MP safe way because it is called by multiple CPU
23 @retval TRUE There is a valid SMI
24 @retval FALSE There is no valid SMI
37 Clears platform top level SMI status bit.
39 This function clears platform top level SMI status bit.
41 @retval TRUE The platform top level SMI status is cleared.
42 @retval FALSE The platform top level SMI status cannot be
48 ClearTopLevelSmiStatus (
56 Performs platform specific way of SMM BSP election.
58 This function performs platform specific way of SMM BSP election.
60 @param IsBsp Output parameter. TRUE: the CPU this function
61 executes on is elected to be the SMM BSP. FALSE:
62 the CPU this function executes on is to be SMM AP.
64 @retval EFI_SUCCESS The function executes successfully.
65 @retval EFI_NOT_READY The function does not determine whether this CPU
66 should be BSP or AP. This may occur if hardware
67 init sequence to enable the determination is yet to
68 be done, or the function chooses not to do BSP
69 election and will let SMM CPU driver to use its
70 default BSP election process.
71 @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU
72 should be BSP or AP due to hardware error.
77 PlatformSmmBspElection (
81 MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr
;
83 ApicBaseMsr
.Uint64
= AsmReadMsr64 (MSR_IA32_APIC_BASE
);
84 *IsBsp
= (BOOLEAN
)(ApicBaseMsr
.Bits
.BSP
== 1);
89 Get platform page table attribute.
91 This function gets page table attribute of platform.
93 @param Address Input parameter. Obtain the page table entries
94 attribute on this address.
95 @param PageSize Output parameter. The size of the page.
96 @param NumOfPages Output parameter. Number of page.
97 @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc).
99 @retval EFI_SUCCESS The platform page table attribute from the address
101 @retval EFI_UNSUPPORTED The platform does not support getting page table
102 attribute for the address.
107 GetPlatformPageTableAttribute (
109 IN OUT SMM_PAGE_SIZE_TYPE
*PageSize
,
110 IN OUT UINTN
*NumOfPages
,
111 IN OUT UINTN
*PageAttribute
114 return EFI_UNSUPPORTED
;