SmramInternal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /** @file
  2. Functions and types shared by the SMM accessor PEI and DXE modules.
  3. Copyright (C) 2015, Red Hat, Inc.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Pi/PiMultiPhase.h>
  7. //
  8. // We'll have two SMRAM ranges.
  9. //
  10. // The first is a tiny one that hosts an SMM_S3_RESUME_STATE object, to be
  11. // filled in by the CPU SMM driver during normal boot, for the PEI instance of
  12. // the LockBox library (which will rely on the object during S3 resume).
  13. //
  14. // The other SMRAM range is the main one, for the SMM core and the SMM drivers.
  15. //
  16. typedef enum {
  17. DescIdxSmmS3ResumeState = 0,
  18. DescIdxMain = 1,
  19. DescIdxCount = 2
  20. } DESCRIPTOR_INDEX;
  21. //
  22. // The value of PcdQ35TsegMbytes is saved into this variable at module startup.
  23. //
  24. extern UINT16 mQ35TsegMbytes;
  25. /**
  26. Save PcdQ35TsegMbytes into mQ35TsegMbytes.
  27. **/
  28. VOID
  29. InitQ35TsegMbytes (
  30. VOID
  31. );
  32. /**
  33. Save PcdQ35SmramAtDefaultSmbase into mQ35SmramAtDefaultSmbase.
  34. **/
  35. VOID
  36. InitQ35SmramAtDefaultSmbase (
  37. VOID
  38. );
  39. /**
  40. Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
  41. OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
  42. from the D_LCK and T_EN bits.
  43. PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
  44. the LockState and OpenState fields being up-to-date on entry, and they need
  45. to restore the same invariant on exit, if they touch the bits in question.
  46. @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
  47. locked.
  48. @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
  49. iff SMRAM is open.
  50. **/
  51. VOID
  52. GetStates (
  53. OUT BOOLEAN *LockState,
  54. OUT BOOLEAN *OpenState
  55. );
  56. //
  57. // The functions below follow the PEI_SMM_ACCESS_PPI and
  58. // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
  59. // pointers are removed (TSEG doesn't depend on them), and so is the
  60. // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
  61. //
  62. // The LockState and OpenState members that are common to both
  63. // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
  64. // isolation from the rest of the (non-shared) members.
  65. //
  66. EFI_STATUS
  67. SmramAccessOpen (
  68. OUT BOOLEAN *LockState,
  69. OUT BOOLEAN *OpenState
  70. );
  71. EFI_STATUS
  72. SmramAccessClose (
  73. OUT BOOLEAN *LockState,
  74. OUT BOOLEAN *OpenState
  75. );
  76. EFI_STATUS
  77. SmramAccessLock (
  78. OUT BOOLEAN *LockState,
  79. IN OUT BOOLEAN *OpenState
  80. );
  81. EFI_STATUS
  82. SmramAccessGetCapabilities (
  83. IN BOOLEAN LockState,
  84. IN BOOLEAN OpenState,
  85. IN OUT UINTN *SmramMapSize,
  86. IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
  87. );