3 A DXE_DRIVER providing SMRAM access by producing EFI_SMM_ACCESS2_PROTOCOL.
5 Q35 TSEG is expected to have been verified and set up by the SmmAccessPei
8 Copyright (C) 2013, 2015, Red Hat, Inc.<BR>
9 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
11 This program and the accompanying materials are licensed and made available
12 under the terms and conditions of the BSD License which accompanies this
13 distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
17 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Library/DebugLib.h>
22 #include <Library/PcdLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Protocol/SmmAccess2.h>
26 #include "SmramInternal.h"
29 Opens the SMRAM area to be accessible by a boot-service driver.
31 This function "opens" SMRAM so that it is visible while not inside of SMM.
32 The function should return EFI_UNSUPPORTED if the hardware does not support
33 hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM
34 configuration is locked.
36 @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.
38 @retval EFI_SUCCESS The operation was successful.
39 @retval EFI_UNSUPPORTED The system does not support opening and closing of
41 @retval EFI_DEVICE_ERROR SMRAM cannot be opened, perhaps because it is
48 IN EFI_SMM_ACCESS2_PROTOCOL
*This
51 return SmramAccessOpen (&This
->LockState
, &This
->OpenState
);
55 Inhibits access to the SMRAM.
57 This function "closes" SMRAM so that it is not visible while outside of SMM.
58 The function should return EFI_UNSUPPORTED if the hardware does not support
61 @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.
63 @retval EFI_SUCCESS The operation was successful.
64 @retval EFI_UNSUPPORTED The system does not support opening and closing of
66 @retval EFI_DEVICE_ERROR SMRAM cannot be closed.
72 IN EFI_SMM_ACCESS2_PROTOCOL
*This
75 return SmramAccessClose (&This
->LockState
, &This
->OpenState
);
79 Inhibits access to the SMRAM.
81 This function prohibits access to the SMRAM region. This function is usually
82 implemented such that it is a write-once operation.
84 @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.
86 @retval EFI_SUCCESS The device was successfully locked.
87 @retval EFI_UNSUPPORTED The system does not support locking of SMRAM.
93 IN EFI_SMM_ACCESS2_PROTOCOL
*This
96 return SmramAccessLock (&This
->LockState
, &This
->OpenState
);
100 Queries the memory controller for the possible regions that will support
103 @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance.
104 @param[in,out] SmramMapSize A pointer to the size, in bytes, of the
105 SmramMemoryMap buffer.
106 @param[in,out] SmramMap A pointer to the buffer in which firmware
107 places the current memory map.
109 @retval EFI_SUCCESS The chipset supported the given resource.
110 @retval EFI_BUFFER_TOO_SMALL The SmramMap parameter was too small. The
111 current buffer size needed to hold the memory
112 map is returned in SmramMapSize.
117 SmmAccess2DxeGetCapabilities (
118 IN CONST EFI_SMM_ACCESS2_PROTOCOL
*This
,
119 IN OUT UINTN
*SmramMapSize
,
120 IN OUT EFI_SMRAM_DESCRIPTOR
*SmramMap
123 return SmramAccessGetCapabilities (This
->LockState
, This
->OpenState
,
124 SmramMapSize
, SmramMap
);
128 // LockState and OpenState will be filled in by the entry point.
130 STATIC EFI_SMM_ACCESS2_PROTOCOL mAccess2
= {
134 &SmmAccess2DxeGetCapabilities
138 // Entry point of this driver.
142 SmmAccess2DxeEntryPoint (
143 IN EFI_HANDLE ImageHandle
,
144 IN EFI_SYSTEM_TABLE
*SystemTable
148 // This module should only be included if SMRAM support is required.
150 ASSERT (FeaturePcdGet (PcdSmmSmramRequire
));
152 InitQ35TsegMbytes ();
153 GetStates (&mAccess2
.LockState
, &mAccess2
.OpenState
);
154 return gBS
->InstallMultipleProtocolInterfaces (&ImageHandle
,
155 &gEfiSmmAccess2ProtocolGuid
, &mAccess2
,