--- /dev/null
+/** @file\r
+Header file for SMM Access Driver.\r
+\r
+This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+Copyright (c) 2013-2015 Intel Corporation.\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _SMM_ACCESS_DRIVER_H\r
+#define _SMM_ACCESS_DRIVER_H\r
+\r
+#include <PiDxe.h>\r
+#include <IndustryStandard/Pci.h>\r
+\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+//\r
+// Driver Consumed Protocol Prototypes\r
+//\r
+#include <Protocol/PciRootBridgeIo.h>\r
+\r
+//\r
+// Driver Consumed GUID Prototypes\r
+//\r
+#include <Guid/SmramMemoryReserve.h>\r
+\r
+//\r
+// Driver produced protocol\r
+//\r
+#include <Protocol/SmmAccess2.h>\r
+\r
+#include <Library/QNCSmmLib.h>\r
+#include <QNCAccess.h>\r
+\r
+#define MAX_CPU_SOCKET 1\r
+#define MAX_SMRAM_RANGES 4\r
+\r
+//\r
+// Private data structure\r
+//\r
+#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('i', 's', 'm', 'a')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_HANDLE Handle;\r
+ EFI_SMM_ACCESS2_PROTOCOL SmmAccess;\r
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
+ UINTN NumberRegions;\r
+ EFI_SMRAM_DESCRIPTOR SmramDesc[MAX_SMRAM_RANGES];\r
+ UINT8 TsegSize;\r
+ UINT8 MaxBusNumber;\r
+ UINT8 SocketPopulated[MAX_CPU_SOCKET];\r
+ UINT64 SMMRegionState;\r
+ UINT8 ActualNLIioBusNumber;\r
+} SMM_ACCESS_PRIVATE_DATA;\r
+\r
+\r
+#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR ( \\r
+ a, \\r
+ SMM_ACCESS_PRIVATE_DATA, \\r
+ SmmAccess, \\r
+ SMM_ACCESS_PRIVATE_DATA_SIGNATURE \\r
+ )\r
+\r
+\r
+//\r
+// Prototypes\r
+// Driver model protocol interface\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+SmmAccessDriverEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This is the standard EFI driver point that detects\r
+ whether there is an proper chipset in the system\r
+ and if so, installs an SMM Access Protocol.\r
+\r
+Arguments:\r
+\r
+ ImageHandle - Handle for the image of this driver.\r
+ SystemTable - Pointer to the EFI System Table.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Protocol successfully started and installed.\r
+ EFI_UNSUPPORTED - Protocol can't be started.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Open (\r
+ IN EFI_SMM_ACCESS2_PROTOCOL *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine accepts a request to "open" a region of SMRAM. The\r
+ region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.\r
+ The use of "open" means that the memory is visible from all boot-service\r
+ and SMM agents.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to the SMM Access Interface.\r
+ DescriptorIndex - Region of SMRAM to Open.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The region was successfully opened.\r
+ EFI_DEVICE_ERROR - The region could not be opened because locked by\r
+ chipset.\r
+ EFI_INVALID_PARAMETER - The descriptor index was out of bounds.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Close (\r
+ IN EFI_SMM_ACCESS2_PROTOCOL *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine accepts a request to "close" a region of SMRAM. This is valid for\r
+ compatible SMRAM region.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to the SMM Access Interface.\r
+ DescriptorIndex - Region of SMRAM to Close.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The region was successfully closed.\r
+ EFI_DEVICE_ERROR - The region could not be closed because locked by\r
+ chipset.\r
+ EFI_INVALID_PARAMETER - The descriptor index was out of bounds.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Lock (\r
+ IN EFI_SMM_ACCESS2_PROTOCOL *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine accepts a request to "lock" SMRAM. The\r
+ region could be legacy AB or TSEG near top of physical memory.\r
+ The use of "lock" means that the memory can no longer be opened\r
+ to BS state..\r
+\r
+Arguments:\r
+\r
+ This - Pointer to the SMM Access Interface.\r
+ DescriptorIndex - Region of SMRAM to Lock.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The region was successfully locked.\r
+ EFI_DEVICE_ERROR - The region could not be locked because at least\r
+ one range is still open.\r
+ EFI_INVALID_PARAMETER - The descriptor index was out of bounds.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetCapabilities (\r
+ IN CONST EFI_SMM_ACCESS2_PROTOCOL *This,\r
+ IN OUT UINTN *SmramMapSize,\r
+ IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine services a user request to discover the SMRAM\r
+ capabilities of this platform. This will report the possible\r
+ ranges that are possible for SMRAM access, based upon the\r
+ memory controller capabilities.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to the SMRAM Access Interface.\r
+ SmramMapSize - Pointer to the variable containing size of the\r
+ buffer to contain the description information.\r
+ SmramMap - Buffer containing the data describing the Smram\r
+ region descriptors.\r
+\r
+Returns:\r
+\r
+ EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient buffer.\r
+ EFI_SUCCESS - The user provided a sufficiently-sized buffer.\r
+\r
+--*/\r
+;\r
+VOID\r
+SyncRegionState2SmramDesc(\r
+ IN BOOLEAN OrAnd,\r
+ IN UINT64 Value\r
+ );\r
+\r
+#endif\r