--- /dev/null
+/*++\r
+\r
+Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
+\r
+ This program and the accompanying materials are licensed and made available under\r
+ the terms and conditions of the BSD License that accompanies this distribution.\r
+ 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
+\r
+--*/\r
+\r
+//\r
+// Include files\r
+//\r
+\r
+#include <PiDxe.h>\r
+#include <IndustryStandard/Acpi50.h>\r
+\r
+\r
+\r
+//\r
+// LPIT Definitions\r
+//\r
+\r
+#define EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION 0x1\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+\r
+typedef union _EFI_ACPI_LPI_STATE_FLAGS {\r
+ struct {\r
+ UINT32 Disabled :1;\r
+ UINT32 CounterUnavailable :1;\r
+ UINT32 Reserved :30;\r
+ };\r
+ UINT32 AsUlong;\r
+} EFI_ACPI_LPI_STATE_FLAGS, *PEFI_ACPI_LPI_STATE_FLAGS;\r
+\r
+// Only Mwait LPI here:\r
+\r
+typedef struct _EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR {\r
+ UINT32 Type; // offset: 0\r
+ UINT32 Length; // offset: 4\r
+ UINT16 UniqueId; // offset: 8\r
+ UINT8 Reserved[2]; // offset: 9\r
+ EFI_ACPI_LPI_STATE_FLAGS Flags; // offset: 12\r
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EntryTrigger; // offset: 16\r
+ UINT32 Residency; // offset: 28\r
+ UINT32 Latency; // offset: 32\r
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResidencyCounter; // offset: 36\r
+ UINT64 ResidencyCounterFrequency; //offset: 48\r
+} EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR;\r
+\r
+\r
+//\r
+// Defines for LPIT table, some are VLV specific\r
+//\r
+\r
+\r
+// signature "LPIT"\r
+#define EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE 0x5449504c\r
+\r
+#define EFI_ACPI_OEM_LPIT_REVISION 0x00000000\r
+\r
+#define EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE 0x0\r
+#define EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG 0x0\r
+#define EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K 0x8000 // 32768\r
+\r
+//\r
+// LPI state count (4 on VLV: S0ir, S0i1, S0i2, S0i3)\r
+//\r
+\r
+#define EFI_ACPI_VLV_LPI_STATE_COUNT 0x4\r
+\r
+//\r
+// LPI TRIGGER (HW C7 on VLV),\r
+// TOFIX!!!\r
+//\r
+#define EFI_ACPI_VLV_LPI_TRIGGER {0x7F,0x1,0x2,0x0,0x64}\r
+\r
+//\r
+// LPI residency counter (MMIO)\r
+//\r
+#define EFI_ACPI_VLV_LPI_RES_COUNTER0 {0x0,32,0x0,0x03,0xFED03080}\r
+#define EFI_ACPI_VLV_LPI_RES_COUNTER1 {0x0,32,0x0,0x03,0xFED03084}\r
+#define EFI_ACPI_VLV_LPI_RES_COUNTER2 {0x0,32,0x0,0x03,0xFED03088}\r
+#define EFI_ACPI_VLV_LPI_RES_COUNTER3 {0x0,32,0x0,0x03,0xFED0308C}\r
+\r
+//\r
+// LPI break-even residency in us - all match S0i3 residency\r
+// Residency estimate: Latency x 3\r
+//\r
+#define EFI_ACPI_VLV_LPI_MIN_RES0 15000\r
+#define EFI_ACPI_VLV_LPI_MIN_RES1 15000\r
+#define EFI_ACPI_VLV_LPI_MIN_RES2 15000\r
+#define EFI_ACPI_VLV_LPI_MIN_RES3 15000\r
+\r
+//\r
+// LPI latency in us - all match S0i3 latency\r
+//\r
+#define EFI_ACPI_VLV_LPI_LATENCY0 5000\r
+#define EFI_ACPI_VLV_LPI_LATENCY1 5000\r
+#define EFI_ACPI_VLV_LPI_LATENCY2 5000\r
+#define EFI_ACPI_VLV_LPI_LATENCY3 5000\r
+\r
+\r
+//\r
+// LPI ID\r
+//\r
+#define EFI_ACPI_VLV_LPI_UNIQUE_ID0 0\r
+#define EFI_ACPI_VLV_LPI_UNIQUE_ID1 1\r
+#define EFI_ACPI_VLV_LPI_UNIQUE_ID2 2\r
+#define EFI_ACPI_VLV_LPI_UNIQUE_ID3 3\r
+\r
+//\r
+// LPI ACPI table header\r
+//\r
+\r
+\r
+typedef struct _EFI_ACPI_LOW_POWER_IDLE_TABLE {\r
+ EFI_ACPI_DESCRIPTION_HEADER Header;\r
+ EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR LpiStates[EFI_ACPI_VLV_LPI_STATE_COUNT];\r
+} EFI_ACPI_LOW_POWER_IDLE_TABLE;\r
+\r
+#pragma pack()\r
+\r
+EFI_ACPI_LOW_POWER_IDLE_TABLE Lpit = {\r
+\r
+ //\r
+ // Header\r
+ //\r
+\r
+\r
+ EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE,\r
+ sizeof (EFI_ACPI_LOW_POWER_IDLE_TABLE),\r
+ EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION ,\r
+\r
+ //\r
+ // Checksum will be updated at runtime\r
+ //\r
+ 0x00,\r
+\r
+ //\r
+ // It is expected that these values will be updated at runtime\r
+ //\r
+ ' ', ' ', ' ', ' ', ' ', ' ',\r
+\r
+ 0,\r
+ EFI_ACPI_OEM_LPIT_REVISION,\r
+ 0,\r
+ 0,\r
+\r
+\r
+\r
+ //\r
+ // Descriptor\r
+ //\r
+ {\r
+ {\r
+ EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,\r
+ sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),\r
+ EFI_ACPI_VLV_LPI_UNIQUE_ID0,\r
+ {0,0},\r
+ {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags\r
+ EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger\r
+ EFI_ACPI_VLV_LPI_MIN_RES0, //Residency\r
+ EFI_ACPI_VLV_LPI_LATENCY0, //Latency\r
+ EFI_ACPI_VLV_LPI_RES_COUNTER0, //ResidencyCounter\r
+ EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency\r
+ },\r
+ {\r
+ EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,\r
+ sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),\r
+ EFI_ACPI_VLV_LPI_UNIQUE_ID1,\r
+ {0,0},\r
+ {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags\r
+ EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger\r
+ EFI_ACPI_VLV_LPI_MIN_RES1, //Residency\r
+ EFI_ACPI_VLV_LPI_LATENCY1, //Latency\r
+ EFI_ACPI_VLV_LPI_RES_COUNTER1, //ResidencyCounter\r
+ EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency\r
+ },\r
+ {\r
+ EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,\r
+ sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),\r
+ EFI_ACPI_VLV_LPI_UNIQUE_ID2,\r
+ {0,0},\r
+ {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags\r
+ EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger\r
+ EFI_ACPI_VLV_LPI_MIN_RES2, //Residency\r
+ EFI_ACPI_VLV_LPI_LATENCY2, //Latency\r
+ EFI_ACPI_VLV_LPI_RES_COUNTER2, //ResidencyCounter\r
+ EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency\r
+ },\r
+ {\r
+ EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,\r
+ sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),\r
+ EFI_ACPI_VLV_LPI_UNIQUE_ID3,\r
+ {0,0},\r
+ {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags\r
+ EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger\r
+ EFI_ACPI_VLV_LPI_MIN_RES3, //Residency\r
+ EFI_ACPI_VLV_LPI_LATENCY3, //Latency\r
+ EFI_ACPI_VLV_LPI_RES_COUNTER3, //ResidencyCounter\r
+ EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency\r
+ }\r
+ }\r
+\r
+};\r
+\r
+\r
+VOID*\r
+ReferenceAcpiTable (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Reference the table being generated to prevent the optimizer from\r
+ // removing the data structure from the executable\r
+ //\r
+ return (VOID*)&Lpit;\r
+}\r