]>
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 | |
11 | This program and the accompanying materials are licensed and made available\r | |
12 | under the terms and conditions of the BSD License which accompanies this\r | |
13 | distribution. The full text of the license may be found at\r | |
14 | http://opensource.org/licenses/bsd-license.php\r | |
15 | \r | |
16 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r | |
17 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
18 | \r | |
19 | **/\r | |
20 | \r | |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/PcdLib.h>\r | |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
24 | #include <Protocol/SmmAccess2.h>\r | |
25 | \r | |
26 | #include "SmramInternal.h"\r | |
27 | \r | |
28 | /**\r | |
29 | Opens the SMRAM area to be accessible by a boot-service driver.\r | |
30 | \r | |
31 | This function "opens" SMRAM so that it is visible while not inside of SMM.\r | |
32 | The function should return EFI_UNSUPPORTED if the hardware does not support\r | |
33 | hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM\r | |
34 | configuration is locked.\r | |
35 | \r | |
36 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
37 | \r | |
38 | @retval EFI_SUCCESS The operation was successful.\r | |
39 | @retval EFI_UNSUPPORTED The system does not support opening and closing of\r | |
40 | SMRAM.\r | |
41 | @retval EFI_DEVICE_ERROR SMRAM cannot be opened, perhaps because it is\r | |
42 | locked.\r | |
43 | **/\r | |
44 | STATIC\r | |
45 | EFI_STATUS\r | |
46 | EFIAPI\r | |
47 | SmmAccess2DxeOpen (\r | |
48 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
49 | )\r | |
50 | {\r | |
51 | return SmramAccessOpen (&This->LockState, &This->OpenState);\r | |
52 | }\r | |
53 | \r | |
54 | /**\r | |
55 | Inhibits access to the SMRAM.\r | |
56 | \r | |
57 | This function "closes" SMRAM so that it is not visible while outside of SMM.\r | |
58 | The function should return EFI_UNSUPPORTED if the hardware does not support\r | |
59 | hiding of SMRAM.\r | |
60 | \r | |
61 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
62 | \r | |
63 | @retval EFI_SUCCESS The operation was successful.\r | |
64 | @retval EFI_UNSUPPORTED The system does not support opening and closing of\r | |
65 | SMRAM.\r | |
66 | @retval EFI_DEVICE_ERROR SMRAM cannot be closed.\r | |
67 | **/\r | |
68 | STATIC\r | |
69 | EFI_STATUS\r | |
70 | EFIAPI\r | |
71 | SmmAccess2DxeClose (\r | |
72 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
73 | )\r | |
74 | {\r | |
75 | return SmramAccessClose (&This->LockState, &This->OpenState);\r | |
76 | }\r | |
77 | \r | |
78 | /**\r | |
79 | Inhibits access to the SMRAM.\r | |
80 | \r | |
81 | This function prohibits access to the SMRAM region. This function is usually\r | |
82 | implemented such that it is a write-once operation.\r | |
83 | \r | |
84 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
85 | \r | |
86 | @retval EFI_SUCCESS The device was successfully locked.\r | |
87 | @retval EFI_UNSUPPORTED The system does not support locking of SMRAM.\r | |
88 | **/\r | |
89 | STATIC\r | |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | SmmAccess2DxeLock (\r | |
93 | IN EFI_SMM_ACCESS2_PROTOCOL *This\r | |
94 | )\r | |
95 | {\r | |
96 | return SmramAccessLock (&This->LockState, &This->OpenState);\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | Queries the memory controller for the possible regions that will support\r | |
101 | SMRAM.\r | |
102 | \r | |
103 | @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.\r | |
104 | @param[in,out] SmramMapSize A pointer to the size, in bytes, of the\r | |
105 | SmramMemoryMap buffer.\r | |
106 | @param[in,out] SmramMap A pointer to the buffer in which firmware\r | |
107 | places the current memory map.\r | |
108 | \r | |
109 | @retval EFI_SUCCESS The chipset supported the given resource.\r | |
110 | @retval EFI_BUFFER_TOO_SMALL The SmramMap parameter was too small. The\r | |
111 | current buffer size needed to hold the memory\r | |
112 | map is returned in SmramMapSize.\r | |
113 | **/\r | |
114 | STATIC\r | |
115 | EFI_STATUS\r | |
116 | EFIAPI\r | |
117 | SmmAccess2DxeGetCapabilities (\r | |
118 | IN CONST EFI_SMM_ACCESS2_PROTOCOL *This,\r | |
119 | IN OUT UINTN *SmramMapSize,\r | |
120 | IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap\r | |
121 | )\r | |
122 | {\r | |
123 | return SmramAccessGetCapabilities (This->LockState, This->OpenState,\r | |
124 | SmramMapSize, SmramMap);\r | |
125 | }\r | |
126 | \r | |
127 | //\r | |
128 | // LockState and OpenState will be filled in by the entry point.\r | |
129 | //\r | |
130 | STATIC EFI_SMM_ACCESS2_PROTOCOL mAccess2 = {\r | |
131 | &SmmAccess2DxeOpen,\r | |
132 | &SmmAccess2DxeClose,\r | |
133 | &SmmAccess2DxeLock,\r | |
134 | &SmmAccess2DxeGetCapabilities\r | |
135 | };\r | |
136 | \r | |
137 | //\r | |
138 | // Entry point of this driver.\r | |
139 | //\r | |
140 | EFI_STATUS\r | |
141 | EFIAPI\r | |
142 | SmmAccess2DxeEntryPoint (\r | |
143 | IN EFI_HANDLE ImageHandle,\r | |
144 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
145 | )\r | |
146 | {\r | |
147 | //\r | |
148 | // This module should only be included if SMRAM support is required.\r | |
149 | //\r | |
150 | ASSERT (FeaturePcdGet (PcdSmmSmramRequire));\r | |
151 | \r | |
1372f8d3 | 152 | InitQ35TsegMbytes ();\r |
c5b7c805 LE |
153 | GetStates (&mAccess2.LockState, &mAccess2.OpenState);\r |
154 | return gBS->InstallMultipleProtocolInterfaces (&ImageHandle,\r | |
155 | &gEfiSmmAccess2ProtocolGuid, &mAccess2,\r | |
156 | NULL);\r | |
157 | }\r |