1 | /*␊ |
2 | * Copyright 2008 mackerintel␊ |
3 | */␊ |
4 | ␊ |
5 | /*␊ |
6 | * Copyright (c) 2010 cparm <armelcadetpetit@gmail.com>. All rights reserved.␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #ifndef __LIBSAIO_ACPI_PATCHER_H␊ |
11 | #define __LIBSAIO_ACPI_PATCHER_H␊ |
12 | ␊ |
13 | #include "libsaio.h"␊ |
14 | #include "efi.h"␊ |
15 | ␊ |
16 | #define kDSDT␉␉␉␉"DSDT"␉␉␉␉/* acpi_patcher.c */␊ |
17 | #define kRestartFix␉␉␉"RestartFix" /* acpi_patcher.c */␊ |
18 | #define kGeneratePStates␉"GeneratePStates"␉/* acpi_patcher.c */␊ |
19 | #define kGenerateCStates␉"GenerateCStates"␉/* acpi_patcher.c */␊ |
20 | #define kMaxRatio␉␉␉"MaxBusRatio"␉␉/* acpi_patcher.c */␊ |
21 | #define kMinRatio␉␉␉"MinBusRatio"␉␉/* acpi_patcher.c */␊ |
22 | #define␉kQSSDT␉␉␉␉"quickSSDTsearch"␉/* acpi_patcher.c */␊ |
23 | #define␉kSpeedstep␉␉␉"EnableSpeedStep"␉/* acpi_patcher.c */␊ |
24 | #define kEnableC4State␉␉"EnableC4State"␉␉/* acpi_patcher.c */␊ |
25 | ␊ |
26 | #define kFACS␉␉␉␉"FACS"␉␉␉␉/* acpi_patcher.c */␊ |
27 | #define kSSDT␉␉␉␉"SSDT"␉␉␉␉/* acpi_patcher.c */␊ |
28 | #define kHPET␉␉␉␉"HPET"␉␉␉␉/* acpi_patcher.c */␊ |
29 | #define kSBST␉␉␉␉"SBST"␉␉␉␉/* acpi_patcher.c */␊ |
30 | #define kECDT␉␉␉␉"ECDT"␉␉␉␉/* acpi_patcher.c */␊ |
31 | #define kASFT␉␉␉␉"ASFT"␉␉␉␉/* acpi_patcher.c */␊ |
32 | #define kDMAR␉␉␉␉"DMAR"␉␉␉␉/* acpi_patcher.c */␊ |
33 | #define kFADT␉␉␉␉"FADT"␉␉␉␉/* acpi_patcher.c */␊ |
34 | #define kAPIC␉␉␉␉"APIC"␉␉␉␉/* acpi_patcher.c */␊ |
35 | #define kMCFG␉␉␉␉"MCFG"␉␉␉␉/* acpi_patcher.c */␊ |
36 | #define kOEMDSDT␉␉␉"oemDSDT"␉␉␉/* acpi_patcher.c */␊ |
37 | #define kOEMSSDT␉␉␉"oemSSDT"␉␉␉/* acpi_patcher.c */␊ |
38 | #define kOEMHPET␉␉␉"oemHPET"␉␉␉/* acpi_patcher.c */␊ |
39 | #define kOEMSBST␉␉␉"oemSBST"␉␉␉/* acpi_patcher.c */␊ |
40 | #define kOEMECDT␉␉␉"oemECDT"␉␉␉/* acpi_patcher.c */␊ |
41 | #define kOEMASFT␉␉␉"oemASFT"␉␉␉/* acpi_patcher.c */␊ |
42 | #define kOEMDMAR␉␉␉"oemDMAR"␉␉␉/* acpi_patcher.c */␊ |
43 | #define kOEMFADT␉␉␉"oemFADT"␉␉␉/* acpi_patcher.c */␊ |
44 | #define kOEMAPIC␉␉␉"oemAPIC"␉␉␉/* acpi_patcher.c */␊ |
45 | #define kOEMMCFG␉␉␉"oemMCFG"␉␉␉/* acpi_patcher.c */␊ |
46 | ␊ |
47 | #define kUpdateACPI␉␉␉"UpdateACPI"␉ /* acpi_patcher.c */␊ |
48 | ␊ |
49 | #define kDisableASPM␉␉"DisableASPM"␉␉/* acpi_patcher.c */␊ |
50 | #define kDisableMSI␉␉␉"DisableMSI"␉␉/* acpi_patcher.c */␊ |
51 | ␊ |
52 | #if UNUSED␊ |
53 | #define kGenerateFACS␉␉"GenerateFACS"␉␉/* acpi_patcher.c */␊ |
54 | #define kOEMFACS␉␉␉"oemFACS"␉␉␉/* acpi_patcher.c */␊ |
55 | #endif␊ |
56 | ␊ |
57 | extern EFI_STATUS setupAcpi(void);␊ |
58 | ␊ |
59 | struct p_state ␊ |
60 | {␊ |
61 | ␉union ␊ |
62 | ␉{␊ |
63 | ␉␉uint16_t Control;␊ |
64 | ␉␉struct ␊ |
65 | ␉␉{␊ |
66 | ␉␉␉uint8_t VID;␉// Voltage ID␊ |
67 | ␉␉␉uint8_t FID;␉// Frequency ID␊ |
68 | ␉␉};␊ |
69 | ␉};␊ |
70 | ␉␊ |
71 | ␉uint8_t␉␉CID;␉␉// Compare ID␊ |
72 | ␉uint32_t␉Frequency;␊ |
73 | };␊ |
74 | ␊ |
75 | /*␊ |
76 | * SIGNATURE_16, SIGNATURE_32, SIGNATURE_64 are extracted from the edk2 project (Base.h), and are under the following license:␊ |
77 | *␊ |
78 | * Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.␊ |
79 | * Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.␊ |
80 | * This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.␊ |
81 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.␊ |
82 | */␊ |
83 | ␊ |
84 | #define SIGNATURE_16(A, B) ((A) | (B << 8))␊ |
85 | ␊ |
86 | #define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))␊ |
87 | ␊ |
88 | #define SIGNATURE_64(A, B, C, D, E, F, G, H) \␊ |
89 | (SIGNATURE_32 (A, B, C, D) | ((uint64_t) (SIGNATURE_32 (E, F, G, H)) << 32))␊ |
90 | ␊ |
91 | #define ACPI_SIGNATURE_UINT64_LE SIGNATURE_64('R','S','D',' ','P','T','R',' ')␊ |
92 | ␊ |
93 | ␊ |
94 | /* Per ACPI 3.0a spec */␊ |
95 | ␊ |
96 | // TODO Migrate␊ |
97 | struct acpi_2_rsdp {␊ |
98 | char Signature[8];␊ |
99 | uint8_t Checksum;␊ |
100 | char OEMID[6];␊ |
101 | uint8_t Revision;␊ |
102 | uint32_t RsdtAddress;␊ |
103 | uint32_t Length;␊ |
104 | uint64_t XsdtAddress;␊ |
105 | uint8_t ExtendedChecksum;␊ |
106 | char Reserved[3];␊ |
107 | } __attribute__((packed));␊ |
108 | ␊ |
109 | ␊ |
110 | #define ACPI_HEADER_CORE␉␉␉\␊ |
111 | char Signature[4];␉\␊ |
112 | uint32_t Length;␉␉␉\␊ |
113 | uint8_t Revision;␉␉\␊ |
114 | uint8_t Checksum;␉␉\␊ |
115 | char OEMID[6];␉␉\␊ |
116 | char OEMTableId[8];␉\␊ |
117 | uint32_t OEMRevision;␉\␊ |
118 | uint32_t CreatorId;␉␉\␊ |
119 | uint32_t CreatorRevision;␊ |
120 | ␊ |
121 | struct acpi_common_header {␊ |
122 | ␉ACPI_HEADER_CORE␉␊ |
123 | } __attribute__((packed));␊ |
124 | ␊ |
125 | // TODO Migrate␊ |
126 | struct acpi_2_rsdt {␊ |
127 | ␉ACPI_HEADER_CORE␉␊ |
128 | } __attribute__((packed));␊ |
129 | ␊ |
130 | // TODO Migrate␊ |
131 | struct acpi_2_xsdt {␊ |
132 | ␉ACPI_HEADER_CORE␉␊ |
133 | } __attribute__((packed));␊ |
134 | ␊ |
135 | // TODO Migrate␊ |
136 | struct acpi_2_gas {␊ |
137 | ␉uint8_t␉␉␉␉Address_Space_ID;␊ |
138 | ␉uint8_t␉␉␉␉Register_Bit_Width;␊ |
139 | ␉uint8_t␉␉␉␉Register_Bit_Offset;␊ |
140 | ␉uint8_t␉␉␉␉Access_Size;␊ |
141 | ␉uint64_t␉␉␉Address;␊ |
142 | } __attribute__((packed));␊ |
143 | ␊ |
144 | // TODO Migrate␊ |
145 | struct acpi_2_ssdt {␊ |
146 | ␉ACPI_HEADER_CORE␉␊ |
147 | } __attribute__((packed));␊ |
148 | ␊ |
149 | // TODO Migrate␊ |
150 | struct acpi_2_dsdt {␊ |
151 | ␉ACPI_HEADER_CORE␉␊ |
152 | } __attribute__((packed));␊ |
153 | ␊ |
154 | // TODO Migrate␊ |
155 | struct acpi_2_fadt {␊ |
156 | ␉ACPI_HEADER_CORE␉␊ |
157 | ␉uint32_t FIRMWARE_CTRL;␊ |
158 | ␉uint32_t DSDT;␊ |
159 | ␉uint8_t Model;␉␉␉// JrCs␊ |
160 | ␉uint8_t PM_Profile;␉␉// JrCs␊ |
161 | ␉uint16_t␉␉SCI_Interrupt;␊ |
162 | ␉uint32_t␉␉SMI_Command_Port;␊ |
163 | ␉uint8_t␉␉␉ACPI_Enable;␊ |
164 | ␉uint8_t␉␉␉ACPI_Disable;␊ |
165 | ␉uint8_t␉␉␉S4BIOS_Command;␊ |
166 | ␉uint8_t␉␉␉PState_Control;␊ |
167 | ␉uint32_t␉␉PM1A_Event_Block_Address;␊ |
168 | ␉uint32_t␉␉PM1B_Event_Block_Address;␊ |
169 | ␉uint32_t␉␉PM1A_Control_Block_Address;␊ |
170 | ␉uint32_t␉␉PM1B_Control_Block_Address;␊ |
171 | ␉uint32_t␉␉PM2_Control_Block_Address;␊ |
172 | ␉uint32_t␉␉PM_Timer_Block_Address;␊ |
173 | ␉uint32_t␉␉GPE0_Block_Address;␊ |
174 | ␉uint32_t␉␉GPE1_Block_Address;␊ |
175 | ␉uint8_t␉␉␉PM1_Event_Block_Length;␊ |
176 | ␉uint8_t␉␉␉PM1_Control_Block_Length;␊ |
177 | ␉uint8_t␉␉␉PM2_Control_Block_Length;␊ |
178 | ␉uint8_t␉␉␉PM_Timer_Block_Length;␊ |
179 | ␉uint8_t␉␉␉GPE0_Block_Length;␊ |
180 | ␉uint8_t␉␉␉GPE1_Block_Length;␊ |
181 | ␉uint8_t␉␉␉GPE1_Base_Offset;␊ |
182 | ␉uint8_t␉␉␉CST_Support;␊ |
183 | ␉uint16_t␉␉C2_Latency;␊ |
184 | ␉uint16_t␉␉C3_Latency;␊ |
185 | ␉uint16_t␉␉CPU_Cache_Size;␊ |
186 | ␉uint16_t␉␉Cache_Flush_Stride;␊ |
187 | ␉uint8_t␉␉␉Duty_Cycle_Offset;␊ |
188 | ␉uint8_t␉␉␉Duty_Cycle_Width;␊ |
189 | ␉uint8_t␉␉␉RTC_Day_Alarm_Index;␊ |
190 | ␉uint8_t␉␉␉RTC_Month_Alarm_Index;␊ |
191 | ␉uint8_t␉␉␉RTC_Century_Index;␊ |
192 | ␉uint16_t␉␉Boot_Flags;␊ |
193 | ␉uint8_t␉␉␉Reserved0;␊ |
194 | /* Begin Asere */␊ |
195 | ␉//Reset Fix␊ |
196 | ␉uint32_t␉␉␉Flags;␊ |
197 | ␉struct acpi_2_gas␉RESET_REG;␉␊ |
198 | ␉uint8_t␉␉␉␉Reset_Value;␊ |
199 | ␉uint8_t␉␉␉␉Reserved[3];␊ |
200 | ␊ |
201 | ␉uint64_t␉␉␉X_FIRMWARE_CTRL;␊ |
202 | ␉uint64_t␉␉␉X_DSDT;␊ |
203 | ␊ |
204 | #if UNUSED␊ |
205 | ␉/* End Asere */␊ |
206 | ␉/*We absolutely don't care about theese fields*/␊ |
207 | ␉uint8_t␉␉notimp2[96];␊ |
208 | #else␊ |
209 | ␉struct acpi_2_gas␉X_PM1a_EVT_BLK;␊ |
210 | ␉struct acpi_2_gas␉X_PM1b_EVT_BLK;␊ |
211 | ␉struct acpi_2_gas␉X_PM1a_CNT_BLK;␊ |
212 | ␉struct acpi_2_gas␉X_PM1b_CNT_BLK;␊ |
213 | ␉struct acpi_2_gas␉X_PM2_CNT_BLK;␊ |
214 | ␉struct acpi_2_gas␉X_PM_TMR_BLK;␊ |
215 | ␉struct acpi_2_gas␉X_GPE0_BLK;␊ |
216 | ␉struct acpi_2_gas␉X_GPE1_BLK;␊ |
217 | #endif␊ |
218 | ␉␊ |
219 | } __attribute__((packed));␊ |
220 | ␊ |
221 | struct acpi_2_facs {␊ |
222 | ␉char␉␉␉Signature[4];␉␊ |
223 | ␉uint32_t Length;␉␉␉␊ |
224 | ␉uint32_t␉␉hardware_signature;␊ |
225 | ␉uint32_t␉␉firmware_waking_vector;␊ |
226 | ␉uint32_t␉␉global_lock;␊ |
227 | ␉uint32_t␉␉flags;␊ |
228 | ␉uint64_t␉␉x_firmware_waking_vector;␉␊ |
229 | ␉uint8_t␉␉␉version;␊ |
230 | ␉uint8_t␉␉␉Reserved[3];␊ |
231 | ␉uint32_t␉␉ospm_flags;␊ |
232 | ␉uint8_t␉␉␉Reserved1[24];␊ |
233 | } __attribute__ ((packed));␊ |
234 | ␊ |
235 | #endif /* !__LIBSAIO_ACPI_PATCHER_H */␊ |
236 | |