Lpit.aslc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*++
  2. Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. --*/
  5. //
  6. // Include files
  7. //
  8. #include <PiDxe.h>
  9. #include <IndustryStandard/Acpi50.h>
  10. //
  11. // LPIT Definitions
  12. //
  13. #define EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION 0x1
  14. //
  15. // Ensure proper structure formats
  16. //
  17. #pragma pack(1)
  18. typedef union _EFI_ACPI_LPI_STATE_FLAGS {
  19. struct {
  20. UINT32 Disabled :1;
  21. UINT32 CounterUnavailable :1;
  22. UINT32 Reserved :30;
  23. };
  24. UINT32 AsUlong;
  25. } EFI_ACPI_LPI_STATE_FLAGS, *PEFI_ACPI_LPI_STATE_FLAGS;
  26. // Only Mwait LPI here:
  27. typedef struct _EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR {
  28. UINT32 Type; // offset: 0
  29. UINT32 Length; // offset: 4
  30. UINT16 UniqueId; // offset: 8
  31. UINT8 Reserved[2]; // offset: 9
  32. EFI_ACPI_LPI_STATE_FLAGS Flags; // offset: 12
  33. EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EntryTrigger; // offset: 16
  34. UINT32 Residency; // offset: 28
  35. UINT32 Latency; // offset: 32
  36. EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResidencyCounter; // offset: 36
  37. UINT64 ResidencyCounterFrequency; //offset: 48
  38. } EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR;
  39. //
  40. // Defines for LPIT table, some are VLV specific
  41. //
  42. // signature "LPIT"
  43. #define EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE 0x5449504c
  44. #define EFI_ACPI_OEM_LPIT_REVISION 0x00000000
  45. #define EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE 0x0
  46. #define EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG 0x0
  47. #define EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K 0x8000 // 32768
  48. //
  49. // LPI state count (4 on VLV: S0ir, S0i1, S0i2, S0i3)
  50. //
  51. #define EFI_ACPI_VLV_LPI_STATE_COUNT 0x4
  52. //
  53. // LPI TRIGGER (HW C7 on VLV),
  54. // TOFIX!!!
  55. //
  56. #define EFI_ACPI_VLV_LPI_TRIGGER {0x7F,0x1,0x2,0x0,0x64}
  57. //
  58. // LPI residency counter (MMIO)
  59. //
  60. #define EFI_ACPI_VLV_LPI_RES_COUNTER0 {0x0,32,0x0,0x03,0xFED03080}
  61. #define EFI_ACPI_VLV_LPI_RES_COUNTER1 {0x0,32,0x0,0x03,0xFED03084}
  62. #define EFI_ACPI_VLV_LPI_RES_COUNTER2 {0x0,32,0x0,0x03,0xFED03088}
  63. #define EFI_ACPI_VLV_LPI_RES_COUNTER3 {0x0,32,0x0,0x03,0xFED0308C}
  64. //
  65. // LPI break-even residency in us - all match S0i3 residency
  66. // Residency estimate: Latency x 3
  67. //
  68. #define EFI_ACPI_VLV_LPI_MIN_RES0 15000
  69. #define EFI_ACPI_VLV_LPI_MIN_RES1 15000
  70. #define EFI_ACPI_VLV_LPI_MIN_RES2 15000
  71. #define EFI_ACPI_VLV_LPI_MIN_RES3 15000
  72. //
  73. // LPI latency in us - all match S0i3 latency
  74. //
  75. #define EFI_ACPI_VLV_LPI_LATENCY0 5000
  76. #define EFI_ACPI_VLV_LPI_LATENCY1 5000
  77. #define EFI_ACPI_VLV_LPI_LATENCY2 5000
  78. #define EFI_ACPI_VLV_LPI_LATENCY3 5000
  79. //
  80. // LPI ID
  81. //
  82. #define EFI_ACPI_VLV_LPI_UNIQUE_ID0 0
  83. #define EFI_ACPI_VLV_LPI_UNIQUE_ID1 1
  84. #define EFI_ACPI_VLV_LPI_UNIQUE_ID2 2
  85. #define EFI_ACPI_VLV_LPI_UNIQUE_ID3 3
  86. //
  87. // LPI ACPI table header
  88. //
  89. typedef struct _EFI_ACPI_LOW_POWER_IDLE_TABLE {
  90. EFI_ACPI_DESCRIPTION_HEADER Header;
  91. EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR LpiStates[EFI_ACPI_VLV_LPI_STATE_COUNT];
  92. } EFI_ACPI_LOW_POWER_IDLE_TABLE;
  93. #pragma pack()
  94. EFI_ACPI_LOW_POWER_IDLE_TABLE Lpit = {
  95. //
  96. // Header
  97. //
  98. EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE,
  99. sizeof (EFI_ACPI_LOW_POWER_IDLE_TABLE),
  100. EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION ,
  101. //
  102. // Checksum will be updated at runtime
  103. //
  104. 0x00,
  105. //
  106. // It is expected that these values will be updated at runtime
  107. //
  108. ' ', ' ', ' ', ' ', ' ', ' ',
  109. 0,
  110. EFI_ACPI_OEM_LPIT_REVISION,
  111. 0,
  112. 0,
  113. //
  114. // Descriptor
  115. //
  116. {
  117. {
  118. EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
  119. sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
  120. EFI_ACPI_VLV_LPI_UNIQUE_ID0,
  121. {0,0},
  122. {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
  123. EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
  124. EFI_ACPI_VLV_LPI_MIN_RES0, //Residency
  125. EFI_ACPI_VLV_LPI_LATENCY0, //Latency
  126. EFI_ACPI_VLV_LPI_RES_COUNTER0, //ResidencyCounter
  127. EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
  128. },
  129. {
  130. EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
  131. sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
  132. EFI_ACPI_VLV_LPI_UNIQUE_ID1,
  133. {0,0},
  134. {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
  135. EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
  136. EFI_ACPI_VLV_LPI_MIN_RES1, //Residency
  137. EFI_ACPI_VLV_LPI_LATENCY1, //Latency
  138. EFI_ACPI_VLV_LPI_RES_COUNTER1, //ResidencyCounter
  139. EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
  140. },
  141. {
  142. EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
  143. sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
  144. EFI_ACPI_VLV_LPI_UNIQUE_ID2,
  145. {0,0},
  146. {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
  147. EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
  148. EFI_ACPI_VLV_LPI_MIN_RES2, //Residency
  149. EFI_ACPI_VLV_LPI_LATENCY2, //Latency
  150. EFI_ACPI_VLV_LPI_RES_COUNTER2, //ResidencyCounter
  151. EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
  152. },
  153. {
  154. EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
  155. sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
  156. EFI_ACPI_VLV_LPI_UNIQUE_ID3,
  157. {0,0},
  158. {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
  159. EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
  160. EFI_ACPI_VLV_LPI_MIN_RES3, //Residency
  161. EFI_ACPI_VLV_LPI_LATENCY3, //Latency
  162. EFI_ACPI_VLV_LPI_RES_COUNTER3, //ResidencyCounter
  163. EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
  164. }
  165. }
  166. };
  167. VOID*
  168. ReferenceAcpiTable (
  169. VOID
  170. )
  171. {
  172. //
  173. // Reference the table being generated to prevent the optimizer from
  174. // removing the data structure from the executable
  175. //
  176. return (VOID*)&Lpit;
  177. }