]>
Commit | Line | Data |
---|---|---|
c5b7c805 LE |
1 | /** @file\r |
2 | \r | |
3 | A DXE_DRIVER providing SMRAM access by producing EFI_SMM_ACCESS2_PROTOCOL.\r | |
4 | \r | |
5 | Q35 TSEG is expected to have been verified and set up by the SmmAccessPei\r | |
6 | driver.\r | |
7 | \r | |
8 | Copyright (C) 2013, 2015, Red Hat, Inc.<BR>\r | |
9 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
10 | \r | |
b26f0cf9 | 11 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c5b7c805 LE |
12 | \r |
13 | **/\r | |
14 | \r | |
15 | #include <Library/DebugLib.h>\r | |
16 | #include <Library/PcdLib.h>\r | |
17 | #include <Library/UefiBootServicesTableLib.h>\r | |
18 | #include <Protocol/SmmAccess2.h>\r | |
19 | \r | |
20 | #include "SmramInternal.h"\r | |
21 | \r | |
22 | /**\r | |
23 | Opens the SMRAM area to be accessible by a boot-service driver.\r | |
24 | \r | |
25 | This function "opens" SMRAM so that it is visible while not inside of SMM.\r | |
26 | The function should return EFI_UNSUPPORTED if the hardware does not support\r | |
27 | hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM\r | |
28 | configuration is locked.\r | |
29 | \r | |
30 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
31 | \r | |
32 | @retval EFI_SUCCESS The operation was successful.\r | |
33 | @retval EFI_UNSUPPORTED The system does not support opening and closing of\r | |
34 | SMRAM.\r | |
35 | @retval EFI_DEVICE_ERROR SMRAM cannot be opened, perhaps because it is\r | |
36 | locked.\r | |
37 | **/\r | |
38 | STATIC\r | |
39 | EFI_STATUS\r | |
40 | EFIAPI\r | |
41 | SmmAccess2DxeOpen (\r | |
42 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
43 | )\r | |
44 | {\r | |
45 | return SmramAccessOpen (&This->LockState, &This->OpenState);\r | |
46 | }\r | |
47 | \r | |
48 | /**\r | |
49 | Inhibits access to the SMRAM.\r | |
50 | \r | |
51 | This function "closes" SMRAM so that it is not visible while outside of SMM.\r | |
52 | The function should return EFI_UNSUPPORTED if the hardware does not support\r | |
53 | hiding of SMRAM.\r | |
54 | \r | |
55 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
56 | \r | |
57 | @retval EFI_SUCCESS The operation was successful.\r | |
58 | @retval EFI_UNSUPPORTED The system does not support opening and closing of\r | |
59 | SMRAM.\r | |
60 | @retval EFI_DEVICE_ERROR SMRAM cannot be closed.\r | |
61 | **/\r | |
62 | STATIC\r | |
63 | EFI_STATUS\r | |
64 | EFIAPI\r | |
65 | SmmAccess2DxeClose (\r | |
66 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
67 | )\r | |
68 | {\r | |
69 | return SmramAccessClose (&This->LockState, &This->OpenState);\r | |
70 | }\r | |
71 | \r | |
72 | /**\r | |
73 | Inhibits access to the SMRAM.\r | |
74 | \r | |
75 | This function prohibits access to the SMRAM region. This function is usually\r | |
76 | implemented such that it is a write-once operation.\r | |
77 | \r | |
78 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
79 | \r | |
80 | @retval EFI_SUCCESS The device was successfully locked.\r | |
81 | @retval EFI_UNSUPPORTED The system does not support locking of SMRAM.\r | |
82 | **/\r | |
83 | STATIC\r | |
84 | EFI_STATUS\r | |
85 | EFIAPI\r | |
86 | SmmAccess2DxeLock (\r | |
87 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
88 | )\r | |
89 | {\r | |
90 | return SmramAccessLock (&This->LockState, &This->OpenState);\r | |
91 | }\r | |
92 | \r | |
93 | /**\r | |
94 | Queries the memory controller for the possible regions that will support\r | |
95 | SMRAM.\r | |
96 | \r | |
97 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
98 | @param[in,out] SmramMapSize A pointer to the size, in bytes, of the\r | |
99 | SmramMemoryMap buffer.\r | |
100 | @param[in,out] SmramMap A pointer to the buffer in which firmware\r | |
101 | places the current memory map.\r | |
102 | \r | |
103 | @retval EFI_SUCCESS The chipset supported the given resource.\r | |
104 | @retval EFI_BUFFER_TOO_SMALL The SmramMap parameter was too small. The\r | |
105 | current buffer size needed to hold the memory\r | |
106 | map is returned in SmramMapSize.\r | |
107 | **/\r | |
108 | STATIC\r | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | SmmAccess2DxeGetCapabilities (\r | |
112 | IN CONST EFI_SMM_ACCESS2_PROTOCOL *This,\r | |
113 | IN OUT UINTN *SmramMapSize,\r | |
114 | IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap\r | |
115 | )\r | |
116 | {\r | |
117 | return SmramAccessGetCapabilities (This->LockState, This->OpenState,\r | |
118 | SmramMapSize, SmramMap);\r | |
119 | }\r | |
120 | \r | |
121 | //\r | |
122 | // LockState and OpenState will be filled in by the entry point.\r | |
123 | //\r | |
124 | STATIC EFI_SMM_ACCESS2_PROTOCOL mAccess2 = {\r | |
125 | &SmmAccess2DxeOpen,\r | |
126 | &SmmAccess2DxeClose,\r | |
127 | &SmmAccess2DxeLock,\r | |
128 | &SmmAccess2DxeGetCapabilities\r | |
129 | };\r | |
130 | \r | |
131 | //\r | |
132 | // Entry point of this driver.\r | |
133 | //\r | |
134 | EFI_STATUS\r | |
135 | EFIAPI\r | |
136 | SmmAccess2DxeEntryPoint (\r | |
137 | IN EFI_HANDLE ImageHandle,\r | |
138 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
139 | )\r | |
140 | {\r | |
141 | //\r | |
142 | // This module should only be included if SMRAM support is required.\r | |
143 | //\r | |
144 | ASSERT (FeaturePcdGet (PcdSmmSmramRequire));\r | |
145 | \r | |
1372f8d3 | 146 | InitQ35TsegMbytes ();\r |
c5b7c805 | 147 | GetStates (&mAccess2.LockState, &mAccess2.OpenState);\r |
9108fc17 LE |
148 | \r |
149 | //\r | |
150 | // SmramAccessLock() depends on "mQ35SmramAtDefaultSmbase"; init the latter\r | |
151 | // just before exposing the former via EFI_SMM_ACCESS2_PROTOCOL.Lock().\r | |
152 | //\r | |
153 | InitQ35SmramAtDefaultSmbase ();\r | |
154 | \r | |
c5b7c805 LE |
155 | return gBS->InstallMultipleProtocolInterfaces (&ImageHandle,\r |
156 | &gEfiSmmAccess2ProtocolGuid, &mAccess2,\r | |
157 | NULL);\r | |
158 | }\r |