]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / SmmCpuPlatformHookLibQemu / SmmCpuPlatformHookLibQemu.c
CommitLineData
c69f6406
LE
1/** @file\r
2SMM CPU Platform Hook library instance for QEMU.\r
3\r
4Copyright (c) 2020, Red Hat, Inc.\r
5Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
43df6187 9#include <Library/BaseLib.h> // AsmReadMsr64()\r
c69f6406 10#include <PiSmm.h>\r
43df6187
LE
11#include <Register/Intel/ArchitecturalMsr.h> // MSR_IA32_APIC_BASE_REGISTER\r
12\r
c69f6406
LE
13#include <Library/SmmCpuPlatformHookLib.h>\r
14\r
15/**\r
16 Checks if platform produces a valid SMI.\r
17\r
18 This function checks if platform produces a valid SMI. This function is\r
19 called at SMM entry to detect if this is a spurious SMI. This function\r
20 must be implemented in an MP safe way because it is called by multiple CPU\r
21 threads.\r
22\r
23 @retval TRUE There is a valid SMI\r
24 @retval FALSE There is no valid SMI\r
25\r
26**/\r
27BOOLEAN\r
28EFIAPI\r
29PlatformValidSmi (\r
30 VOID\r
31 )\r
32{\r
33 return TRUE;\r
34}\r
35\r
36/**\r
37 Clears platform top level SMI status bit.\r
38\r
39 This function clears platform top level SMI status bit.\r
40\r
41 @retval TRUE The platform top level SMI status is cleared.\r
42 @retval FALSE The platform top level SMI status cannot be\r
43 cleared.\r
44\r
45**/\r
46BOOLEAN\r
47EFIAPI\r
48ClearTopLevelSmiStatus (\r
49 VOID\r
50 )\r
51{\r
52 return TRUE;\r
53}\r
54\r
55/**\r
56 Performs platform specific way of SMM BSP election.\r
57\r
58 This function performs platform specific way of SMM BSP election.\r
59\r
60 @param IsBsp Output parameter. TRUE: the CPU this function\r
61 executes on is elected to be the SMM BSP. FALSE:\r
62 the CPU this function executes on is to be SMM AP.\r
63\r
64 @retval EFI_SUCCESS The function executes successfully.\r
65 @retval EFI_NOT_READY The function does not determine whether this CPU\r
66 should be BSP or AP. This may occur if hardware\r
67 init sequence to enable the determination is yet to\r
68 be done, or the function chooses not to do BSP\r
69 election and will let SMM CPU driver to use its\r
70 default BSP election process.\r
71 @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU\r
72 should be BSP or AP due to hardware error.\r
73\r
74**/\r
75EFI_STATUS\r
76EFIAPI\r
77PlatformSmmBspElection (\r
ac0a286f 78 OUT BOOLEAN *IsBsp\r
c69f6406
LE
79 )\r
80{\r
ac0a286f 81 MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;\r
43df6187
LE
82\r
83 ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);\r
ac0a286f 84 *IsBsp = (BOOLEAN)(ApicBaseMsr.Bits.BSP == 1);\r
43df6187 85 return EFI_SUCCESS;\r
c69f6406
LE
86}\r
87\r
88/**\r
89 Get platform page table attribute.\r
90\r
91 This function gets page table attribute of platform.\r
92\r
93 @param Address Input parameter. Obtain the page table entries\r
94 attribute on this address.\r
95 @param PageSize Output parameter. The size of the page.\r
96 @param NumOfPages Output parameter. Number of page.\r
97 @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc).\r
98\r
99 @retval EFI_SUCCESS The platform page table attribute from the address\r
100 is determined.\r
101 @retval EFI_UNSUPPORTED The platform does not support getting page table\r
102 attribute for the address.\r
103\r
104**/\r
105EFI_STATUS\r
106EFIAPI\r
107GetPlatformPageTableAttribute (\r
ac0a286f
MK
108 IN UINT64 Address,\r
109 IN OUT SMM_PAGE_SIZE_TYPE *PageSize,\r
110 IN OUT UINTN *NumOfPages,\r
111 IN OUT UINTN *PageAttribute\r
c69f6406
LE
112 )\r
113{\r
114 return EFI_UNSUPPORTED;\r
115}\r