SmmAccessDriver.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /** @file
  2. Header file for SMM Access Driver.
  3. Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _SMM_ACCESS_DRIVER_H_
  7. #define _SMM_ACCESS_DRIVER_H_
  8. #include <Library/BaseMemoryLib.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/HobLib.h>
  11. #include <Library/PciLib.h>
  12. #include <Library/MemoryAllocationLib.h>
  13. #include <Library/UefiBootServicesTableLib.h>
  14. #include <Uefi/UefiBaseType.h>
  15. #include <Guid/SmramMemoryReserve.h>
  16. #include <Protocol/SmmAccess2.h>
  17. #include <IndustryStandard/Pci22.h>
  18. #define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's', 'a')
  19. ///
  20. /// Private data
  21. ///
  22. typedef struct {
  23. UINTN Signature;
  24. EFI_HANDLE Handle;
  25. EFI_SMM_ACCESS2_PROTOCOL SmmAccess;
  26. ///
  27. /// Local Data for SMM Access interface goes here
  28. ///
  29. UINTN NumberRegions;
  30. EFI_SMRAM_DESCRIPTOR *SmramDesc;
  31. } SMM_ACCESS_PRIVATE_DATA;
  32. #define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \
  33. CR (a, \
  34. SMM_ACCESS_PRIVATE_DATA, \
  35. SmmAccess, \
  36. SMM_ACCESS_PRIVATE_DATA_SIGNATURE \
  37. )
  38. //
  39. // Prototypes
  40. // Driver model protocol interface
  41. //
  42. /**
  43. <b>SMM Access Driver Entry Point</b>
  44. This driver installs an SMM Access Protocol
  45. - <b>Introduction</b> \n
  46. This module publishes the SMM access protocol. The protocol is used by the SMM Base driver to access the SMRAM region when the processor is not in SMM.
  47. The SMM Base driver uses the services provided by the SMM access protocol to open SMRAM during POST and copy the SMM handler.
  48. SMM access protocol is also used to close the SMRAM region once the copying is done.
  49. Finally, the SMM access protocol provides services to "Lock" the SMRAM region.
  50. Please refer the SMM Protocols section in the attached SMM CIS Specification version 0.9 for further details.
  51. This driver is required if SMM is supported. Proper configuration of SMM registers is recommended even if SMM is not supported.
  52. - <b>Porting Recommendations</b> \n
  53. No modification of this module is recommended. Any modification should be done in compliance with the _EFI_SMM_ACCESS_PROTOCOL protocol definition.
  54. @param[in] ImageHandle - Handle for the image of this driver
  55. @param[in] SystemTable - Pointer to the EFI System Table
  56. @retval EFI_SUCCESS - Protocol was installed successfully
  57. @retval EFI_UNSUPPORTED - Protocol was not installed
  58. @retval EFI_NOT_FOUND - Protocol can't be found.
  59. @retval EFI_OUT_OF_RESOURCES - Protocol does not have enough resources to initialize the driver.
  60. **/
  61. EFI_STATUS
  62. EFIAPI
  63. SmmAccessDriverEntryPoint (
  64. IN EFI_HANDLE ImageHandle,
  65. IN EFI_SYSTEM_TABLE *SystemTable
  66. );
  67. /**
  68. This routine accepts a request to "open" a region of SMRAM. The
  69. region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.
  70. The use of "open" means that the memory is visible from all boot-service
  71. and SMM agents.
  72. @param[in] This - Pointer to the SMM Access Interface.
  73. @retval EFI_SUCCESS - The region was successfully opened.
  74. @retval EFI_DEVICE_ERROR - The region could not be opened because locked by chipset.
  75. @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
  76. **/
  77. EFI_STATUS
  78. EFIAPI
  79. Open (
  80. IN EFI_SMM_ACCESS2_PROTOCOL *This
  81. );
  82. /**
  83. This routine accepts a request to "close" a region of SMRAM. The
  84. region could be legacy AB or TSEG near top of physical memory.
  85. The use of "close" means that the memory is only visible from SMM agents,
  86. not from BS or RT code.
  87. @param[in] This - Pointer to the SMM Access Interface.
  88. @retval EFI_SUCCESS - The region was successfully closed.
  89. @retval EFI_DEVICE_ERROR - The region could not be closed because locked by chipset.
  90. @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
  91. **/
  92. EFI_STATUS
  93. EFIAPI
  94. Close (
  95. IN EFI_SMM_ACCESS2_PROTOCOL *This
  96. );
  97. /**
  98. This routine accepts a request to "lock" SMRAM. The
  99. region could be legacy AB or TSEG near top of physical memory.
  100. The use of "lock" means that the memory can no longer be opened
  101. to BS state..
  102. @param[in] This - Pointer to the SMM Access Interface.
  103. @retval EFI_SUCCESS - The region was successfully locked.
  104. @retval EFI_DEVICE_ERROR - The region could not be locked because at least
  105. one range is still open.
  106. @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
  107. **/
  108. EFI_STATUS
  109. EFIAPI
  110. Lock (
  111. IN EFI_SMM_ACCESS2_PROTOCOL *This
  112. );
  113. /**
  114. This routine services a user request to discover the SMRAM
  115. capabilities of this platform. This will report the possible
  116. ranges that are possible for SMRAM access, based upon the
  117. memory controller capabilities.
  118. @param[in] This - Pointer to the SMRAM Access Interface.
  119. @param[in, out] SmramMapSize - Pointer to the variable containing size of the
  120. buffer to contain the description information.
  121. @param[in, out] SmramMap - Buffer containing the data describing the Smram
  122. region descriptors.
  123. @retval EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient buffer.
  124. @retval EFI_SUCCESS - The user provided a sufficiently-sized buffer.
  125. **/
  126. EFI_STATUS
  127. EFIAPI
  128. GetCapabilities (
  129. IN CONST EFI_SMM_ACCESS2_PROTOCOL *This,
  130. IN OUT UINTN *SmramMapSize,
  131. IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
  132. );
  133. #endif