]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
OvmfPkg/ResetSystemLib: rename to BaseResetSystemLib
[mirror_edk2.git] / OvmfPkg / Library / SmmCpuPlatformHookLibQemu / SmmCpuPlatformHookLibQemu.c
1 /** @file
2 SMM CPU Platform Hook library instance for QEMU.
3
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
7
8 **/
9 #include <Library/BaseLib.h> // AsmReadMsr64()
10 #include <PiSmm.h>
11 #include <Register/Intel/ArchitecturalMsr.h> // MSR_IA32_APIC_BASE_REGISTER
12
13 #include <Library/SmmCpuPlatformHookLib.h>
14
15 /**
16 Checks if platform produces a valid SMI.
17
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
21 threads.
22
23 @retval TRUE There is a valid SMI
24 @retval FALSE There is no valid SMI
25
26 **/
27 BOOLEAN
28 EFIAPI
29 PlatformValidSmi (
30 VOID
31 )
32 {
33 return TRUE;
34 }
35
36 /**
37 Clears platform top level SMI status bit.
38
39 This function clears platform top level SMI status bit.
40
41 @retval TRUE The platform top level SMI status is cleared.
42 @retval FALSE The platform top level SMI status cannot be
43 cleared.
44
45 **/
46 BOOLEAN
47 EFIAPI
48 ClearTopLevelSmiStatus (
49 VOID
50 )
51 {
52 return TRUE;
53 }
54
55 /**
56 Performs platform specific way of SMM BSP election.
57
58 This function performs platform specific way of SMM BSP election.
59
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.
63
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.
73
74 **/
75 EFI_STATUS
76 EFIAPI
77 PlatformSmmBspElection (
78 OUT BOOLEAN *IsBsp
79 )
80 {
81 MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;
82
83 ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);
84 *IsBsp = (BOOLEAN)(ApicBaseMsr.Bits.BSP == 1);
85 return EFI_SUCCESS;
86 }
87
88 /**
89 Get platform page table attribute.
90
91 This function gets page table attribute of platform.
92
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).
98
99 @retval EFI_SUCCESS The platform page table attribute from the address
100 is determined.
101 @retval EFI_UNSUPPORTED The platform does not support getting page table
102 attribute for the address.
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 GetPlatformPageTableAttribute (
108 IN UINT64 Address,
109 IN OUT SMM_PAGE_SIZE_TYPE *PageSize,
110 IN OUT UINTN *NumOfPages,
111 IN OUT UINTN *PageAttribute
112 )
113 {
114 return EFI_UNSUPPORTED;
115 }