1 /** @file 2 Header file for SMM Access Driver. 3 4 This file includes package header files, library classes and protocol, PPI & GUID definitions. 5 6 Copyright (c) 2013-2015 Intel Corporation. 7 8 This program and the accompanying materials 9 are licensed and made available under the terms and conditions of the BSD License 10 which accompanies this distribution. The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php 12 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 **/ 16 17 #ifndef _SMM_ACCESS_DRIVER_H 18 #define _SMM_ACCESS_DRIVER_H 19 20 #include <PiDxe.h> 21 #include <IndustryStandard/Pci.h> 22 23 #include <Library/HobLib.h> 24 #include <Library/BaseLib.h> 25 #include <Library/UefiLib.h> 26 #include <Library/DebugLib.h> 27 #include <Library/BaseMemoryLib.h> 28 #include <Library/UefiDriverEntryPoint.h> 29 #include <Library/UefiBootServicesTableLib.h> 30 #include <Library/PcdLib.h> 31 32 // 33 // Driver Consumed Protocol Prototypes 34 // 35 #include <Protocol/PciRootBridgeIo.h> 36 37 // 38 // Driver Consumed GUID Prototypes 39 // 40 #include <Guid/SmramMemoryReserve.h> 41 42 // 43 // Driver produced protocol 44 // 45 #include <Protocol/SmmAccess2.h> 46 47 #include <Library/QNCSmmLib.h> 48 #include <QNCAccess.h> 49 50 #define MAX_CPU_SOCKET 1 51 #define MAX_SMRAM_RANGES 4 52 53 // 54 // Private data structure 55 // 56 #define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('i', 's', 'm', 'a') 57 58 typedef struct { 59 UINTN Signature; 60 EFI_HANDLE Handle; 61 EFI_SMM_ACCESS2_PROTOCOL SmmAccess; 62 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; 63 UINTN NumberRegions; 64 EFI_SMRAM_DESCRIPTOR SmramDesc[MAX_SMRAM_RANGES]; 65 UINT8 TsegSize; 66 UINT8 MaxBusNumber; 67 UINT8 SocketPopulated[MAX_CPU_SOCKET]; 68 UINT64 SMMRegionState; 69 UINT8 ActualNLIioBusNumber; 70 } SMM_ACCESS_PRIVATE_DATA; 71 72 73 #define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \ 74 CR ( \ 75 a, \ 76 SMM_ACCESS_PRIVATE_DATA, \ 77 SmmAccess, \ 78 SMM_ACCESS_PRIVATE_DATA_SIGNATURE \ 79 ) 80 81 82 // 83 // Prototypes 84 // Driver model protocol interface 85 // 86 EFI_STATUS 87 EFIAPI 88 SmmAccessDriverEntryPoint ( 89 IN EFI_HANDLE ImageHandle, 90 IN EFI_SYSTEM_TABLE *SystemTable 91 ) 92 /*++ 93 94 Routine Description: 95 96 This is the standard EFI driver point that detects 97 whether there is an proper chipset in the system 98 and if so, installs an SMM Access Protocol. 99 100 Arguments: 101 102 ImageHandle - Handle for the image of this driver. 103 SystemTable - Pointer to the EFI System Table. 104 105 Returns: 106 107 EFI_SUCCESS - Protocol successfully started and installed. 108 EFI_UNSUPPORTED - Protocol can't be started. 109 110 --*/ 111 ; 112 113 EFI_STATUS 114 EFIAPI 115 Open ( 116 IN EFI_SMM_ACCESS2_PROTOCOL *This 117 ) 118 /*++ 119 120 Routine Description: 121 122 This routine accepts a request to "open" a region of SMRAM. The 123 region could be legacy ABSEG, HSEG, or TSEG near top of physical memory. 124 The use of "open" means that the memory is visible from all boot-service 125 and SMM agents. 126 127 Arguments: 128 129 This - Pointer to the SMM Access Interface. 130 DescriptorIndex - Region of SMRAM to Open. 131 132 Returns: 133 134 EFI_SUCCESS - The region was successfully opened. 135 EFI_DEVICE_ERROR - The region could not be opened because locked by 136 chipset. 137 EFI_INVALID_PARAMETER - The descriptor index was out of bounds. 138 139 --*/ 140 ; 141 142 EFI_STATUS 143 EFIAPI 144 Close ( 145 IN EFI_SMM_ACCESS2_PROTOCOL *This 146 ) 147 /*++ 148 149 Routine Description: 150 151 This routine accepts a request to "close" a region of SMRAM. This is valid for 152 compatible SMRAM region. 153 154 Arguments: 155 156 This - Pointer to the SMM Access Interface. 157 DescriptorIndex - Region of SMRAM to Close. 158 159 Returns: 160 161 EFI_SUCCESS - The region was successfully closed. 162 EFI_DEVICE_ERROR - The region could not be closed because locked by 163 chipset. 164 EFI_INVALID_PARAMETER - The descriptor index was out of bounds. 165 166 --*/ 167 ; 168 169 EFI_STATUS 170 EFIAPI 171 Lock ( 172 IN EFI_SMM_ACCESS2_PROTOCOL *This 173 ) 174 /*++ 175 176 Routine Description: 177 178 This routine accepts a request to "lock" SMRAM. The 179 region could be legacy AB or TSEG near top of physical memory. 180 The use of "lock" means that the memory can no longer be opened 181 to BS state.. 182 183 Arguments: 184 185 This - Pointer to the SMM Access Interface. 186 DescriptorIndex - Region of SMRAM to Lock. 187 188 Returns: 189 190 EFI_SUCCESS - The region was successfully locked. 191 EFI_DEVICE_ERROR - The region could not be locked because at least 192 one range is still open. 193 EFI_INVALID_PARAMETER - The descriptor index was out of bounds. 194 195 --*/ 196 ; 197 198 EFI_STATUS 199 EFIAPI 200 GetCapabilities ( 201 IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, 202 IN OUT UINTN *SmramMapSize, 203 IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap 204 ) 205 /*++ 206 207 Routine Description: 208 209 This routine services a user request to discover the SMRAM 210 capabilities of this platform. This will report the possible 211 ranges that are possible for SMRAM access, based upon the 212 memory controller capabilities. 213 214 Arguments: 215 216 This - Pointer to the SMRAM Access Interface. 217 SmramMapSize - Pointer to the variable containing size of the 218 buffer to contain the description information. 219 SmramMap - Buffer containing the data describing the Smram 220 region descriptors. 221 222 Returns: 223 224 EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient buffer. 225 EFI_SUCCESS - The user provided a sufficiently-sized buffer. 226 227 --*/ 228 ; 229 VOID 230 SyncRegionState2SmramDesc( 231 IN BOOLEAN OrAnd, 232 IN UINT64 Value 233 ); 234 235 #endif 236