1 | /*␊ |
2 | * Copyright 2008 mackerintel␊ |
3 | */␊ |
4 | ␊ |
5 | //Azi:include␊ |
6 | //#include "libsaio.h" // included on boot.h, acpi_patcher.h, platform.h...␊ |
7 | #include "boot.h"␊ |
8 | #include "bootstruct.h"␊ |
9 | #include "acpi.h"␊ |
10 | #include "efi_tables.h"␊ |
11 | #include "fake_efi.h"␊ |
12 | #include "acpi_patcher.h"␊ |
13 | #include "platform.h"␊ |
14 | #include "cpu.h"␊ |
15 | #include "aml_generator.h"␊ |
16 | ␊ |
17 | #ifndef DEBUG_ACPI␊ |
18 | #define DEBUG_ACPI 0␊ |
19 | #endif␊ |
20 | ␊ |
21 | #if DEBUG_ACPI==2␊ |
22 | #define DBG(x...) {printf(x); sleep(1);}␊ |
23 | #elif DEBUG_ACPI==1␊ |
24 | #define DBG(x...) printf(x)␊ |
25 | #else␊ |
26 | #define DBG(x...)␊ |
27 | #endif␊ |
28 | ␊ |
29 | static uint64_t acpi10_p; //Azi: aserebln␊ |
30 | static uint64_t acpi20_p; //␉␉||␊ |
31 | ␊ |
32 | // Slice: New signature compare function␊ |
33 | boolean_t tableSign(char *table, const char *sgn)␊ |
34 | {␊ |
35 | ␉int i;␊ |
36 | ␉for (i=0; i<4; i++) {␊ |
37 | ␉␉if ((table[i] &~0x20) != (sgn[i] &~0x20)) {␊ |
38 | ␉␉␉return false;␊ |
39 | ␉␉}␊ |
40 | ␉}␊ |
41 | ␉return true;␊ |
42 | }␊ |
43 | ␊ |
44 | /* Gets the ACPI 1.0 RSDP address */␊ |
45 | static struct acpi_2_rsdp* getAddressOfAcpiTable()␊ |
46 | {␊ |
47 | /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */␊ |
48 | ␉␊ |
49 | void *acpi_addr = (void*)ACPI_RANGE_START;␊ |
50 | for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16)␊ |
51 | {␊ |
52 | if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE)␊ |
53 | {␊ |
54 | uint8_t csum = checksum8(acpi_addr, 20);␊ |
55 | if(csum == 0)␊ |
56 | {␊ |
57 | // Only return the table if it is a true version 1.0 table (Revision 0)␊ |
58 | if(((struct acpi_2_rsdp*)acpi_addr)->Revision == 0)␊ |
59 | return acpi_addr;␊ |
60 | }␊ |
61 | }␊ |
62 | }␊ |
63 | return NULL;␊ |
64 | }␊ |
65 | ␊ |
66 | /* Gets the ACPI 2.0 RSDP address */␊ |
67 | static struct acpi_2_rsdp* getAddressOfAcpi20Table()␊ |
68 | {␊ |
69 | /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */␊ |
70 | ␉␊ |
71 | void *acpi_addr = (void*)ACPI_RANGE_START;␊ |
72 | for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16)␊ |
73 | {␊ |
74 | if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE)␊ |
75 | {␊ |
76 | uint8_t csum = checksum8(acpi_addr, 20);␊ |
77 | ␉␉␉␊ |
78 | /* Only assume this is a 2.0 or better table if the revision is greater than 0␊ |
79 | * NOTE: ACPI 3.0 spec only seems to say that 1.0 tables have revision 1␊ |
80 | * and that the current revision is 2.. I am going to assume that rev > 0 is 2.0.␊ |
81 | */␊ |
82 | ␉␉␉␊ |
83 | if(csum == 0 && (((struct acpi_2_rsdp*)acpi_addr)->Revision > 0))␊ |
84 | {␊ |
85 | uint8_t csum2 = checksum8(acpi_addr, sizeof(struct acpi_2_rsdp));␊ |
86 | if(csum2 == 0)␊ |
87 | return acpi_addr;␊ |
88 | }␊ |
89 | }␊ |
90 | }␊ |
91 | return NULL;␊ |
92 | }␊ |
93 | ␊ |
94 | /** The following ACPI Table search algo, should be reused anywhere needed: */␊ |
95 | int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)␊ |
96 | {␊ |
97 | ␉static bool first_time = true;␊ |
98 | ␉static char␉dirSpecDSDT[128] = "";␊ |
99 | ␉const char *override_pathname = NULL; // full path to a file.␊ |
100 | ␉int␉␉␉len = 0, fd = 0;␊ |
101 | ␉extern char gMacOSVersion;␊ |
102 | ␉␊ |
103 | ␉// Take in account user overriding if it's DSDT only␊ |
104 | ␉if (strstr(filename, "DSDT") &&␊ |
105 | ␉␉getValueForKey(kDSDTKey, &override_pathname, &len, &bootInfo->bootConfig))␊ |
106 | ␉{␊ |
107 | ␉␉// Specify a path to a file, e.g. DSDT=/Extra/test.aml␊ |
108 | ␉␉sprintf(dirSpecDSDT, override_pathname);␊ |
109 | ␉␉fd = open(dirSpecDSDT, 0);␊ |
110 | ␉␉if (fd >= 0) goto success_fd;␊ |
111 | ␉}␊ |
112 | ␉␊ |
113 | ␉// Check that dirSpecDSDT is not already assigned with a path␊ |
114 | ␉if (!first_time && *dirSpecDSDT) ␊ |
115 | ␉{ // it is so start searching this cached patch first␊ |
116 | ␉␉//extract path␊ |
117 | ␉␉for (len = strlen(dirSpecDSDT)-1; len; len--)␊ |
118 | ␉␉{␊ |
119 | ␉␉␉if (dirSpecDSDT[len] == '/' || len == 0)␊ |
120 | ␉␉␉{␊ |
121 | ␉␉␉␉dirSpecDSDT[len] = '\0';␊ |
122 | ␉␉␉␉break;␊ |
123 | ␉␉␉}␊ |
124 | ␉␉}␊ |
125 | ␉␉␊ |
126 | ␉␉// now concat with the filename␊ |
127 | ␉␉strncat(dirSpecDSDT, "/", sizeof(dirSpecDSDT));␊ |
128 | ␉␉strncat(dirSpecDSDT, filename, sizeof(dirSpecDSDT));␊ |
129 | ␉␉␊ |
130 | ␉␉// and test to see if we don't have our big boy here:␊ |
131 | ␉␉fd = open(dirSpecDSDT,0);␊ |
132 | ␉␉if (fd >= 0) ␊ |
133 | ␉␉{␊ |
134 | ␉␉␉printf("ACPI file search cache hit: file found at %s\n", dirSpecDSDT);␊ |
135 | ␉␉␉goto success_fd;␊ |
136 | ␉␉}␊ |
137 | ␉}␊ |
138 | ␉␊ |
139 | ␉// Start searching any potential location for ACPI Table␊ |
140 | ␉// Check rd's root.␊ |
141 | ␉sprintf(dirSpecDSDT, "rd(0,0)/%s", filename);␊ |
142 | ␉fd = open(dirSpecDSDT, 0);␊ |
143 | ␉if (fd >= 0) goto success_fd;␊ |
144 | ␉␊ |
145 | ␉// Check booter volume/rdbt for OS specific folders.␊ |
146 | ␉sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s/%s", &gMacOSVersion, filename);␊ |
147 | ␉fd = open(dirSpecDSDT, 0);␊ |
148 | ␉if (fd >= 0) goto success_fd;␊ |
149 | ␉␊ |
150 | ␉// Check booter volume/rdbt Extra.␊ |
151 | ␉sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s", filename);␊ |
152 | ␉fd = open(dirSpecDSDT, 0);␊ |
153 | ␉if (fd >= 0) goto success_fd;␊ |
154 | ␉␊ |
155 | ␉//Azi: All loaded files stay in Extra.. please!? :)␊ |
156 | ␉//sprintf(dirspec, "/%s", filename); // search root␊ |
157 | ␉//fd=open (dirspec,0);␊ |
158 | ␉//if (fd>=0) goto success_fd;␊ |
159 | ␉␊ |
160 | ␉// NOT FOUND:␊ |
161 | ␉//Azi: a reminder - handling this verbose only on pci_root.c, getPciRootUID()␊ |
162 | ␉// (it's enough to check if *.aml file exists), to reduce number of printed messages␊ |
163 | ␉// and the confusion caused by them on users.␊ |
164 | ␉//verbose("ACPI Table not found: %s\n", filename);␊ |
165 | ␉if (outDirspec) *outDirspec = "";␊ |
166 | ␉first_time = false;␊ |
167 | ␉return -1;␊ |
168 | ␉// FOUND␊ |
169 | success_fd:␊ |
170 | ␉first_time = false;␊ |
171 | ␉if (outDirspec) *outDirspec = dirSpecDSDT;␊ |
172 | ␉return fd;␊ |
173 | }␊ |
174 | ␊ |
175 | void *loadACPITable (const char * filename) //Azi: called on setupAcpi()␊ |
176 | {␊ |
177 | ␉void *tableAddr;␊ |
178 | ␉const char * dsdt_filename = NULL; //Azi: = dirSpecDSDT␊ |
179 | ␉␊ |
180 | ␉//Azi:dsdt - call 2; call 1 on pci_root.c (getPciRootUID), changed dirspec to dsdt_filename according (review this!!!).␊ |
181 | ␉int fd = search_and_get_acpi_fd(filename, &dsdt_filename);␊ |
182 | ␉␊ |
183 | ␉if (fd >= 0)␊ |
184 | ␉{␊ |
185 | ␉␉tableAddr = (void*)AllocateKernelMemory(file_size (fd));␊ |
186 | ␉␉␊ |
187 | ␉␉if (tableAddr)␊ |
188 | ␉␉{␊ |
189 | ␉␉␉if (read (fd, tableAddr, file_size (fd)) != file_size (fd))␊ |
190 | ␉␉␉{␊ |
191 | ␉␉␉␉printf("Couldn't read table %s\n",dsdt_filename);␊ |
192 | ␉␉␉␉free (tableAddr);␊ |
193 | ␉␉␉␉close (fd);␊ |
194 | ␉␉␉␉return NULL;␊ |
195 | ␉␉␉}␊ |
196 | ␉␉␉␊ |
197 | ␉␉␉DBG("Table %s read and stored at: %x\n", dsdt_filename, tableAddr);␊ |
198 | ␉␉␉close (fd);␊ |
199 | ␉␉␉return tableAddr;␊ |
200 | ␉␉}␊ |
201 | ␉␉close (fd);␊ |
202 | ␉␉printf("Couldn't allocate memory for table \n", dsdt_filename);␊ |
203 | ␉}␊ |
204 | ␉return NULL;␊ |
205 | }␊ |
206 | ␊ |
207 | uint8_t␉acpi_cpu_count = 0;␊ |
208 | char* acpi_cpu_name[32];␊ |
209 | ␊ |
210 | void get_acpi_cpu_names(unsigned char* dsdt, uint32_t length)␊ |
211 | {␊ |
212 | ␉uint32_t i;␊ |
213 | ␉␊ |
214 | ␉for (i=0; i<length-7; i++) ␊ |
215 | ␉{␊ |
216 | ␉␉if (dsdt[i] == 0x5B && dsdt[i+1] == 0x83) // ProcessorOP␊ |
217 | ␉␉{␊ |
218 | ␉␉␉uint32_t offset = i + 3 + (dsdt[i+2] >> 6);␊ |
219 | ␉␉␉␊ |
220 | ␉␉␉bool add_name = true;␊ |
221 | ␊ |
222 | ␉␉␉uint8_t j;␊ |
223 | ␉␉␉␊ |
224 | ␉␉␉for (j=0; j<4; j++) ␊ |
225 | ␉␉␉{␊ |
226 | ␉␉␉␉char c = dsdt[offset+j];␊ |
227 | ␉␉␉␉␊ |
228 | ␉␉␉␉if (!aml_isvalidchar(c)) ␊ |
229 | ␉␉␉␉{␊ |
230 | ␉␉␉␉␉add_name = false;␊ |
231 | ␉␉␉␉␉verbose("Invalid character found in ProcessorOP 0x%x!\n", c);␊ |
232 | ␉␉␉␉␉break;␊ |
233 | ␉␉␉␉}␊ |
234 | ␉␉␉}␊ |
235 | ␉␉␉␊ |
236 | ␉␉␉if (add_name) ␊ |
237 | ␉␉␉{␊ |
238 | ␉␉␉␉acpi_cpu_name[acpi_cpu_count] = malloc(4);␊ |
239 | ␉␉␉␉memcpy(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4);␊ |
240 | ␉␉␉␉i = offset + 5;␊ |
241 | ␉␉␉␉␊ |
242 | ␉␉␉␉verbose("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]);␊ |
243 | ␉␉␉␉␊ |
244 | ␉␉␉␉if (++acpi_cpu_count == 32) return;␊ |
245 | ␉␉␉}␊ |
246 | ␉␉}␊ |
247 | ␉}␊ |
248 | }␊ |
249 | ␊ |
250 | struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt)␊ |
251 | {␊ |
252 | ␉char ssdt_header[] =␊ |
253 | ␉{␊ |
254 | ␉␉0x53, 0x53, 0x44, 0x54, 0xE7, 0x00, 0x00, 0x00, /* SSDT.... */␊ |
255 | ␉␉0x01, 0x17, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x41, /* ..PmRefA */␊ |
256 | ␉␉0x43, 0x70, 0x75, 0x43, 0x73, 0x74, 0x00, 0x00, /* CpuCst.. */␊ |
257 | ␉␉0x00, 0x10, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* ....INTL */␊ |
258 | ␉␉0x31, 0x03, 0x10, 0x20 ␉␉␉␉␉␉␉/* 1.._␉␉*/␊ |
259 | ␉};␊ |
260 | ␉␊ |
261 | ␉char cstate_resource_template[] = ␊ |
262 | ␉{␊ |
263 | ␉␉0x11, 0x14, 0x0A, 0x11, 0x82, 0x0C, 0x00, 0x7F, ␊ |
264 | ␉␉0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, ␊ |
265 | ␉␉0x00, 0x00, 0x00, 0x79, 0x00␊ |
266 | ␉};␊ |
267 | ␊ |
268 | ␉if (Platform.CPU.Vendor != 0x756E6547) {␊ |
269 | ␉␉verbose ("Not an Intel platform: C-States will not be generated !!!\n");␊ |
270 | ␉␉return NULL;␊ |
271 | ␉}␊ |
272 | ␉␊ |
273 | ␉if (fadt == NULL) {␊ |
274 | ␉␉verbose ("FACP not exists: C-States will not be generated !!!\n");␊ |
275 | ␉␉return NULL;␊ |
276 | ␉}␊ |
277 | ␉␊ |
278 | ␉struct acpi_2_dsdt* dsdt = (void*)fadt->DSDT;␊ |
279 | ␉␊ |
280 | ␉if (dsdt == NULL) {␊ |
281 | ␉␉verbose ("DSDT not found: C-States will not be generated !!!\n");␊ |
282 | ␉␉return NULL;␊ |
283 | ␉}␊ |
284 | ␉␊ |
285 | ␉if (acpi_cpu_count == 0) ␊ |
286 | ␉␉get_acpi_cpu_names((void*)dsdt, dsdt->Length);␊ |
287 | ␉␊ |
288 | ␉if (acpi_cpu_count > 0) ␊ |
289 | ␉{␊ |
290 | ␉␉bool c2_enabled = fadt->C2_Latency < 100;␊ |
291 | ␉␉bool c3_enabled = fadt->C3_Latency < 1000;␊ |
292 | ␉␉bool c4_enabled = false;␊ |
293 | ␉␉␊ |
294 | ␉␉getBoolForKey(kEnableC4States, &c4_enabled, &bootInfo->bootConfig);␊ |
295 | ␊ |
296 | ␉␉unsigned char cstates_count = 1 + (c2_enabled ? 1 : 0) + (c3_enabled ? 1 : 0);␊ |
297 | ␉␉␊ |
298 | ␉␉struct aml_chunk* root = aml_create_node(NULL);␊ |
299 | ␉␉␉aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header␊ |
300 | ␉␉␉struct aml_chunk* scop = aml_add_scope(root, "\\_PR_");␊ |
301 | ␉␉␉␉struct aml_chunk* name = aml_add_name(scop, "CST_");␊ |
302 | ␉␉␉␉␉struct aml_chunk* pack = aml_add_package(name);␊ |
303 | ␉␉␉␉␉␉aml_add_byte(pack, cstates_count);␊ |
304 | ␉␉␊ |
305 | ␉␉␉␉␉␉struct aml_chunk* tmpl = aml_add_package(pack);␊ |
306 | ␉␉␉␉␉␉␉cstate_resource_template[11] = 0x00; // C1␊ |
307 | ␉␉␉␉␉␉␉aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template));␊ |
308 | ␉␉␉␉␉␉␉aml_add_byte(tmpl, 0x01); // C1␊ |
309 | ␉␉␉␉␉␉␉aml_add_byte(tmpl, 0x01); // Latency␊ |
310 | ␉␉␉␉␉␉␉aml_add_word(tmpl, 0x03e8); // Power␊ |
311 | ␊ |
312 | ␉␉␉␉␉␉// C2␊ |
313 | ␉␉␉␉␉␉if (c2_enabled) ␊ |
314 | ␉␉␉␉␉␉{␊ |
315 | ␉␉␉␉␉␉␉tmpl = aml_add_package(pack);␊ |
316 | ␉␉␉␉␉␉␉␉cstate_resource_template[11] = 0x10; // C2␊ |
317 | ␉␉␉␉␉␉␉␉aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template));␊ |
318 | ␉␉␉␉␉␉␉␉aml_add_byte(tmpl, 0x02); // C2␊ |
319 | ␉␉␉␉␉␉␉␉aml_add_byte(tmpl, fadt->C2_Latency);␊ |
320 | ␉␉␉␉␉␉␉␉aml_add_word(tmpl, 0x01f4); // Power␊ |
321 | ␉␉␉␉␉␉}␊ |
322 | ␉␉␉␉␉␉// C4␊ |
323 | ␉␉␉␉␉␉if (c4_enabled) ␊ |
324 | ␉␉␉␉␉␉{␊ |
325 | ␉␉␉␉␉␉␉tmpl = aml_add_package(pack);␊ |
326 | ␉␉␉␉␉␉␉cstate_resource_template[11] = 0x30; // C4␊ |
327 | ␉␉␉␉␉␉␉aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template));␊ |
328 | ␉␉␉␉␉␉␉aml_add_byte(tmpl, 0x04); // C4␊ |
329 | ␉␉␉␉␉␉␉aml_add_word(tmpl, fadt->C3_Latency / 2); // TODO: right latency for C4␊ |
330 | ␉␉␉␉␉␉␉aml_add_byte(tmpl, 0xfa); // Power␊ |
331 | ␉␉␉␉␉␉}␊ |
332 | ␉␉␉␉␉␉else␊ |
333 | ␉␉␉␉␉␉// C3␊ |
334 | ␉␉␉␉␉␉if (c3_enabled) ␊ |
335 | ␉␉␉␉␉␉{␊ |
336 | ␉␉␉␉␉␉␉tmpl = aml_add_package(pack);␊ |
337 | ␉␉␉␉␉␉␉cstate_resource_template[11] = 0x20; // C3␊ |
338 | ␉␉␉␉␉␉␉aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template));␊ |
339 | ␉␉␉␉␉␉␉aml_add_byte(tmpl, 0x03); // C3␊ |
340 | ␉␉␉␉␉␉␉aml_add_word(tmpl, fadt->C3_Latency);␊ |
341 | ␉␉␉␉␉␉␉aml_add_word(tmpl, 0x015e); // Power␊ |
342 | ␉␉␉␉␉␉}␊ |
343 | ␉␉␉␉␉␉␊ |
344 | ␉␉␉␊ |
345 | ␉␉␉// Aliaces␊ |
346 | ␉␉␉int i;␊ |
347 | ␉␉␉for (i = 0; i < acpi_cpu_count; i++) ␊ |
348 | ␉␉␉{␊ |
349 | ␉␉␉␉char name[9];␊ |
350 | ␉␉␉␉sprintf(name, "_PR_%c%c%c%c", acpi_cpu_name[i][0], acpi_cpu_name[i][1], acpi_cpu_name[i][2], acpi_cpu_name[i][3]);␊ |
351 | ␉␉␉␉␊ |
352 | ␉␉␉␉scop = aml_add_scope(root, name);␊ |
353 | ␉␉␉␉␉aml_add_alias(scop, "CST_", "_CST");␊ |
354 | ␉␉␉}␊ |
355 | ␉␉␊ |
356 | ␉␉aml_calculate_size(root);␊ |
357 | ␉␉␊ |
358 | ␉␉struct acpi_2_ssdt *ssdt = (struct acpi_2_ssdt *)AllocateKernelMemory(root->Size);␊ |
359 | ␉␊ |
360 | ␉␉aml_write_node(root, (void*)ssdt, 0);␊ |
361 | ␉␉␊ |
362 | ␉␉ssdt->Length = root->Size;␊ |
363 | ␉␉ssdt->Checksum = 0;␊ |
364 | ␉␉ssdt->Checksum = 256 - checksum8(ssdt, ssdt->Length);␊ |
365 | ␉␉␊ |
366 | ␉␉aml_destroy_node(root);␊ |
367 | ␉␉␊ |
368 | ␉␉//dumpPhysAddr("C-States SSDT content: ", ssdt, ssdt->Length);␊ |
369 | ␉␉␉␉␊ |
370 | ␉␉verbose ("SSDT with CPU C-States generated successfully\n");␊ |
371 | ␉␉␊ |
372 | ␉␉return ssdt;␊ |
373 | ␉}␊ |
374 | ␉else ␊ |
375 | ␉{␊ |
376 | ␉␉verbose ("ACPI CPUs not found: C-States not generated !!!\n");␊ |
377 | ␉}␊ |
378 | ␊ |
379 | ␉return NULL;␊ |
380 | }␊ |
381 | ␊ |
382 | struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt)␊ |
383 | {␊ |
384 | ␉char ssdt_header[] =␊ |
385 | ␉{␊ |
386 | ␉␉0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */␊ |
387 | ␉␉0x01, 0x6A, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x00, /* ..PmRef. */␊ |
388 | ␉␉0x43, 0x70, 0x75, 0x50, 0x6D, 0x00, 0x00, 0x00, /* CpuPm... */␊ |
389 | ␉␉0x00, 0x30, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* .0..INTL */␊ |
390 | ␉␉0x31, 0x03, 0x10, 0x20,␉␉␉␉␉␉␉/* 1.._␉␉*/␊ |
391 | ␉};␊ |
392 | ␉␊ |
393 | ␉if (Platform.CPU.Vendor != 0x756E6547) {␊ |
394 | ␉␉verbose ("Not an Intel platform: P-States will not be generated !!!\n");␊ |
395 | ␉␉return NULL;␊ |
396 | ␉}␊ |
397 | ␉␊ |
398 | ␉if (!(Platform.CPU.Features & CPU_FEATURE_MSR)) {␊ |
399 | ␉␉verbose ("Unsupported CPU: P-States will not be generated !!!\n");␊ |
400 | ␉␉return NULL;␊ |
401 | ␉}␊ |
402 | ␉␊ |
403 | ␉if (acpi_cpu_count == 0) ␊ |
404 | ␉␉get_acpi_cpu_names((void*)dsdt, dsdt->Length);␊ |
405 | ␉␊ |
406 | ␉if (acpi_cpu_count > 0) ␊ |
407 | ␉{␊ |
408 | ␉␉struct p_state initial, maximum, minimum, p_states[32];␊ |
409 | ␉␉uint8_t p_states_count = 0;␉␉␊ |
410 | ␉␉␊ |
411 | ␉␉// Retrieving P-States, ported from code by superhai (c)␊ |
412 | ␉␉switch (Platform.CPU.Family) {␊ |
413 | ␉␉␉case 0x06: ␊ |
414 | ␉␉␉{␊ |
415 | ␉␉␉␉switch (Platform.CPU.Model) ␊ |
416 | ␉␉␉␉{␊ |
417 | ␉␉␉␉␉case 0x0D: // ?␊ |
418 | ␉␉␉␉␉case CPU_MODEL_YONAH: // Yonah␊ |
419 | ␉␉␉␉␉case CPU_MODEL_MEROM: // Merom␊ |
420 | ␉␉␉␉␉case CPU_MODEL_PENRYN: // Penryn␊ |
421 | ␉␉␉␉␉case CPU_MODEL_ATOM: // Intel Atom (45nm)␊ |
422 | ␉␉␉␉␉{␊ |
423 | ␉␉␉␉␉␉bool cpu_dynamic_fsb = false;␊ |
424 | ␉␉␉␉␉␉␊ |
425 | ␉␉␉␉␉␉if (rdmsr64(MSR_IA32_EXT_CONFIG) & (1 << 27)) ␊ |
426 | ␉␉␉␉␉␉{␊ |
427 | ␉␉␉␉␉␉␉wrmsr64(MSR_IA32_EXT_CONFIG, (rdmsr64(MSR_IA32_EXT_CONFIG) | (1 << 28))); ␊ |
428 | ␉␉␉␉␉␉␉delay(1);␊ |
429 | ␉␉␉␉␉␉␉cpu_dynamic_fsb = rdmsr64(MSR_IA32_EXT_CONFIG) & (1 << 28);␊ |
430 | ␉␉␉␉␉␉}␊ |
431 | ␉␉␉␉␉␉␊ |
432 | ␉␉␉␉␉␉bool cpu_noninteger_bus_ratio = (rdmsr64(MSR_IA32_PERF_STATUS) & (1ULL << 46));␊ |
433 | ␉␉␉␉␉␉␊ |
434 | ␉␉␉␉␉␉initial.Control = rdmsr64(MSR_IA32_PERF_STATUS);␊ |
435 | ␉␉␉␉␉␉␊ |
436 | ␉␉␉␉␉␉maximum.Control = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 32) & 0x1F3F) | (0x4000 * cpu_noninteger_bus_ratio);␊ |
437 | ␉␉␉␉␉␉maximum.CID = ((maximum.FID & 0x1F) << 1) | cpu_noninteger_bus_ratio;␊ |
438 | ␉␉␉␉␉␉␊ |
439 | ␉␉␉␉␉␉minimum.FID = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 24) & 0x1F) | (0x80 * cpu_dynamic_fsb);␊ |
440 | ␉␉␉␉␉␉minimum.VID = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 48) & 0x3F);␊ |
441 | ␉␉␉␉␉␉␊ |
442 | ␉␉␉␉␉␉if (minimum.FID == 0) ␊ |
443 | ␉␉␉␉␉␉{␊ |
444 | ␉␉␉␉␉␉␉uint64_t msr;␊ |
445 | ␉␉␉␉␉␉␉uint8_t i;␊ |
446 | ␉␉␉␉␉␉␉// Probe for lowest fid␊ |
447 | ␉␉␉␉␉␉␉for (i = maximum.FID; i >= 0x6; i--) ␊ |
448 | ␉␉␉␉␉␉␉{␊ |
449 | ␉␉␉␉␉␉␉␉msr = rdmsr64(MSR_IA32_PERF_CONTROL);␊ |
450 | ␉␉␉␉␉␉␉␉wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (i << 8) | minimum.VID);␊ |
451 | ␉␉␉␉␉␉␉␉intel_waitforsts();␊ |
452 | ␉␉␉␉␉␉␉␉minimum.FID = (rdmsr64(MSR_IA32_PERF_STATUS) >> 8) & 0x1F; ␊ |
453 | ␉␉␉␉␉␉␉␉delay(1);␊ |
454 | ␉␉␉␉␉␉␉}␊ |
455 | ␉␉␉␉␉␉␉␊ |
456 | ␉␉␉␉␉␉␉msr = rdmsr64(MSR_IA32_PERF_CONTROL);␊ |
457 | ␉␉␉␉␉␉␉wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID);␊ |
458 | ␉␉␉␉␉␉␉intel_waitforsts();␊ |
459 | ␉␉␉␉␉␉}␊ |
460 | ␉␉␉␉␉␉␊ |
461 | ␉␉␉␉␉␉if (minimum.VID == maximum.VID) ␊ |
462 | ␉␉␉␉␉␉{␉␊ |
463 | ␉␉␉␉␉␉␉uint64_t msr;␊ |
464 | ␉␉␉␉␉␉␉uint8_t i;␊ |
465 | ␉␉␉␉␉␉␉// Probe for lowest vid␊ |
466 | ␉␉␉␉␉␉␉for (i = maximum.VID; i > 0xA; i--) ␊ |
467 | ␉␉␉␉␉␉␉{␊ |
468 | ␉␉␉␉␉␉␉␉msr = rdmsr64(MSR_IA32_PERF_CONTROL);␊ |
469 | ␉␉␉␉␉␉␉␉wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (minimum.FID << 8) | i);␊ |
470 | ␉␉␉␉␉␉␉␉intel_waitforsts();␊ |
471 | ␉␉␉␉␉␉␉␉minimum.VID = rdmsr64(MSR_IA32_PERF_STATUS) & 0x3F; ␊ |
472 | ␉␉␉␉␉␉␉␉delay(1);␊ |
473 | ␉␉␉␉␉␉␉}␊ |
474 | ␉␉␉␉␉␉␉␊ |
475 | ␉␉␉␉␉␉␉msr = rdmsr64(MSR_IA32_PERF_CONTROL);␊ |
476 | ␉␉␉␉␉␉␉wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID);␊ |
477 | ␉␉␉␉␉␉␉intel_waitforsts();␊ |
478 | ␉␉␉␉␉␉}␊ |
479 | ␉␉␉␉␉␉␊ |
480 | ␉␉␉␉␉␉minimum.CID = ((minimum.FID & 0x1F) << 1) >> cpu_dynamic_fsb;␊ |
481 | ␉␉␉␉␉␉␊ |
482 | ␉␉␉␉␉␉// Sanity check␊ |
483 | ␉␉␉␉␉␉if (maximum.CID < minimum.CID) ␊ |
484 | ␉␉␉␉␉␉{␊ |
485 | ␉␉␉␉␉␉␉DBG("Insane FID values!");␊ |
486 | ␉␉␉␉␉␉␉p_states_count = 1;␊ |
487 | ␉␉␉␉␉␉}␊ |
488 | ␉␉␉␉␉␉else␊ |
489 | ␉␉␉␉␉␉{␊ |
490 | ␉␉␉␉␉␉␉// Finalize P-States␊ |
491 | ␉␉␉␉␉␉␉// Find how many P-States machine supports␊ |
492 | ␉␉␉␉␉␉␉p_states_count = maximum.CID - minimum.CID + 1;␊ |
493 | ␉␉␉␉␉␉␉␊ |
494 | ␉␉␉␉␉␉␉if (p_states_count > 32) ␊ |
495 | ␉␉␉␉␉␉␉␉p_states_count = 32;␊ |
496 | ␉␉␉␉␉␉␉␊ |
497 | ␉␉␉␉␉␉␉uint8_t vidstep;␊ |
498 | ␉␉␉␉␉␉␉uint8_t i = 0, u, invalid = 0;␊ |
499 | ␉␉␉␉␉␉␉␊ |
500 | ␉␉␉␉␉␉␉vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1);␊ |
501 | ␉␉␉␉␉␉␉␊ |
502 | ␉␉␉␉␉␉␉for (u = 0; u < p_states_count; u++) ␊ |
503 | ␉␉␉␉␉␉␉{␊ |
504 | ␉␉␉␉␉␉␉␉i = u - invalid;␊ |
505 | ␉␉␉␉␉␉␉␉␊ |
506 | ␉␉␉␉␉␉␉␉p_states[i].CID = maximum.CID - u;␊ |
507 | ␉␉␉␉␉␉␉␉p_states[i].FID = (p_states[i].CID >> 1);␊ |
508 | ␉␉␉␉␉␉␉␉␊ |
509 | ␉␉␉␉␉␉␉␉if (p_states[i].FID < 0x6) ␊ |
510 | ␉␉␉␉␉␉␉␉{␊ |
511 | ␉␉␉␉␉␉␉␉␉if (cpu_dynamic_fsb) ␊ |
512 | ␉␉␉␉␉␉␉␉␉␉p_states[i].FID = (p_states[i].FID << 1) | 0x80;␊ |
513 | ␉␉␉␉␉␉␉␉} ␊ |
514 | ␉␉␉␉␉␉␉␉else if (cpu_noninteger_bus_ratio) ␊ |
515 | ␉␉␉␉␉␉␉␉{␊ |
516 | ␉␉␉␉␉␉␉␉␉p_states[i].FID = p_states[i].FID | (0x40 * (p_states[i].CID & 0x1));␊ |
517 | ␉␉␉␉␉␉␉␉}␊ |
518 | ␉␉␉␉␉␉␉␉␊ |
519 | ␉␉␉␉␉␉␉␉if (i && p_states[i].FID == p_states[i-1].FID)␊ |
520 | ␉␉␉␉␉␉␉␉␉invalid++;␊ |
521 | ␉␉␉␉␉␉␉␉␊ |
522 | ␉␉␉␉␉␉␉␉p_states[i].VID = ((maximum.VID << 2) - (vidstep * u)) >> 2;␊ |
523 | ␉␉␉␉␉␉␉␉␊ |
524 | ␉␉␉␉␉␉␉␉uint32_t multiplier = p_states[i].FID & 0x1f;␉␉// = 0x08␊ |
525 | ␉␉␉␉␉␉␉␉bool half = p_states[i].FID & 0x40;␉␉␉␉␉// = 0x01␊ |
526 | ␉␉␉␉␉␉␉␉bool dfsb = p_states[i].FID & 0x80;␉␉␉␉␉// = 0x00␊ |
527 | ␉␉␉␉␉␉␉␉uint32_t fsb = Platform.CPU.FSBFrequency / 1000000; // = 400␊ |
528 | ␉␉␉␉␉␉␉␉uint32_t halffsb = (fsb + 1) >> 1;␉␉␉␉␉// = 200␊ |
529 | ␉␉␉␉␉␉␉␉uint32_t frequency = (multiplier * fsb);␉␉␉// = 3200␊ |
530 | ␉␉␉␉␉␉␉␉␊ |
531 | ␉␉␉␉␉␉␉␉p_states[i].Frequency = (frequency + (half * halffsb)) >> dfsb;␉// = 3200 + 200 = 3400␊ |
532 | ␉␉␉␉␉␉␉}␊ |
533 | ␉␉␉␉␉␉␉␊ |
534 | ␉␉␉␉␉␉␉p_states_count -= invalid;␊ |
535 | ␉␉␉␉␉␉}␊ |
536 | ␉␉␉␉␉} break;␊ |
537 | ␉␉␉␉␉case CPU_MODEL_FIELDS:␊ |
538 | ␉␉␉␉␉case CPU_MODEL_DALES:␊ |
539 | ␉␉␉␉␉case CPU_MODEL_DALES_32NM:␊ |
540 | ␉␉␉␉␉case CPU_MODEL_NEHALEM:␊ |
541 | ␉␉␉␉␉case CPU_MODEL_NEHALEM_EX:␊ |
542 | ␉␉␉␉␉case CPU_MODEL_WESTMERE:␊ |
543 | ␉␉␉␉␉case CPU_MODEL_WESTMERE_EX:␊ |
544 | ␉␉␉␉␉default:␊ |
545 | ␉␉␉␉␉␉verbose ("Unsupported CPU: P-States not generated !!!\n");␊ |
546 | ␉␉␉␉␉␉break;␊ |
547 | ␉␉␉␉}␊ |
548 | ␉␉␉}␊ |
549 | ␉␉}␊ |
550 | ␉␉␊ |
551 | ␉␉// Generating SSDT␊ |
552 | ␉␉if (p_states_count > 0) ␊ |
553 | ␉␉{␉␊ |
554 | ␉␉␉int i;␊ |
555 | ␉␉␉␊ |
556 | ␉␉␉struct aml_chunk* root = aml_create_node(NULL);␊ |
557 | ␉␉␉␉aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header␊ |
558 | ␉␉␉␉␉struct aml_chunk* scop = aml_add_scope(root, "\\_PR_");␊ |
559 | ␉␉␉␉␉␉struct aml_chunk* name = aml_add_name(scop, "PSS_");␊ |
560 | ␉␉␉␉␉␉␉struct aml_chunk* pack = aml_add_package(name);␊ |
561 | ␉␉␉␊ |
562 | ␉␉␉␉␉␉␉␉for (i = 0; i < p_states_count; i++) ␊ |
563 | ␉␉␉␉␉␉␉␉{␊ |
564 | ␉␉␉␉␉␉␉␉␉struct aml_chunk* pstt = aml_add_package(pack);␊ |
565 | ␉␉␉␉␉␉␉␉␉␊ |
566 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, p_states[i].Frequency);␊ |
567 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, 0x00000000); // Power␊ |
568 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, 0x0000000A); // Latency␊ |
569 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, 0x0000000A); // Latency␊ |
570 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, p_states[i].Control);␊ |
571 | ␉␉␉␉␉␉␉␉␉aml_add_dword(pstt, i+1); // Status␊ |
572 | ␉␉␉␉␉␉␉␉}␊ |
573 | ␉␉␉␉␊ |
574 | ␉␉␉// Add aliaces␊ |
575 | ␉␉␉for (i = 0; i < acpi_cpu_count; i++) ␊ |
576 | ␉␉␉{␊ |
577 | ␉␉␉␉char name[9];␊ |
578 | ␉␉␉␉sprintf(name, "_PR_%c%c%c%c", acpi_cpu_name[i][0], acpi_cpu_name[i][1], acpi_cpu_name[i][2], acpi_cpu_name[i][3]);␊ |
579 | ␉␉␉␉␊ |
580 | ␉␉␉␉scop = aml_add_scope(root, name);␊ |
581 | ␉␉␉␉aml_add_alias(scop, "PSS_", "_PSS");␊ |
582 | ␉␉␉}␊ |
583 | ␉␉␉␊ |
584 | ␉␉␉aml_calculate_size(root);␊ |
585 | ␉␉␉␊ |
586 | ␉␉␉struct acpi_2_ssdt *ssdt = (struct acpi_2_ssdt *)AllocateKernelMemory(root->Size);␊ |
587 | ␉␉␉␊ |
588 | ␉␉␉aml_write_node(root, (void*)ssdt, 0);␊ |
589 | ␉␉␉␊ |
590 | ␉␉␉ssdt->Length = root->Size;␊ |
591 | ␉␉␉ssdt->Checksum = 0;␊ |
592 | ␉␉␉ssdt->Checksum = 256 - checksum8(ssdt, ssdt->Length);␊ |
593 | ␉␉␉␊ |
594 | ␉␉␉aml_destroy_node(root);␊ |
595 | ␉␉␉␊ |
596 | ␉␉␉//dumpPhysAddr("P-States SSDT content: ", ssdt, ssdt->Length);␊ |
597 | ␉␉␉␊ |
598 | ␉␉␉verbose ("SSDT with CPU P-States generated successfully\n");␊ |
599 | ␉␉␉␊ |
600 | ␉␉␉return ssdt;␊ |
601 | ␉␉}␊ |
602 | ␉}␊ |
603 | ␉else ␊ |
604 | ␉{␊ |
605 | ␉␉verbose ("ACPI CPUs not found: P-States not generated !!!\n");␊ |
606 | ␉}␊ |
607 | ␉␊ |
608 | ␉return NULL;␊ |
609 | }␊ |
610 | ␊ |
611 | struct acpi_2_fadt *patch_fadt(struct acpi_2_fadt *fadt, struct acpi_2_dsdt *new_dsdt)␊ |
612 | {␊ |
613 | ␉extern void setupSystemType(); ␊ |
614 | ␉␊ |
615 | ␉struct acpi_2_fadt *fadt_mod;␊ |
616 | ␉bool fadt_rev2_needed = false;␊ |
617 | ␉bool fix_restart;␊ |
618 | ␉const char * value;␊ |
619 | ␉␊ |
620 | ␉// Restart Fix␊ |
621 | ␉if (Platform.CPU.Vendor == 0x756E6547) // Intel␊ |
622 | ␉{␊ |
623 | ␉␉fix_restart = false; //Azi: think this should be false by default!?␊ |
624 | ␉␉// On the other hand, i could use a shutdown fix now and then :)␊ |
625 | ␉␉getBoolForKey(kRestartFixKey, &fix_restart, &bootInfo->bootConfig);␊ |
626 | ␉}␊ |
627 | ␉else␊ |
628 | ␉{␊ |
629 | ␉␉verbose ("Not an Intel platform: Restart Fix not applied !!!\n");␊ |
630 | ␉␉fix_restart = false;␊ |
631 | ␉}␊ |
632 | ␉␊ |
633 | ␉if (fix_restart) fadt_rev2_needed = true;␊ |
634 | ␉␊ |
635 | ␉// Allocate new fadt table␊ |
636 | ␉if (fadt->Length < 0x84 && fadt_rev2_needed)␊ |
637 | ␉{␊ |
638 | ␉␉fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);␊ |
639 | ␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
640 | ␉␉fadt_mod->Length = 0x84;␊ |
641 | ␉␉fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)␊ |
642 | ␉}␊ |
643 | ␉else␊ |
644 | ␉{␊ |
645 | ␉␉fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);␊ |
646 | ␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
647 | ␉}␊ |
648 | ␉// Determine system type / PM_Model␊ |
649 | ␉if ( (value=getStringForKey(kSystemTypeKey, &bootInfo->bootConfig))!=NULL)␊ |
650 | ␉{␊ |
651 | ␉␉if (Platform.Type > 6) ␊ |
652 | ␉␉{␊ |
653 | ␉␉␉if(fadt_mod->PM_Profile<=6)␊ |
654 | ␉␉␉␉Platform.Type = fadt_mod->PM_Profile; // get the fadt if correct␊ |
655 | ␉␉␉else ␊ |
656 | ␉␉␉␉Platform.Type = 1;␉␉/* Set a fixed value (Desktop) */␊ |
657 | ␉␉␉verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform.Type);␊ |
658 | ␉␉}␊ |
659 | ␉␉else␊ |
660 | ␉␉␉Platform.Type = (unsigned char) strtoul(value, NULL, 10);␊ |
661 | ␉}␊ |
662 | ␊ |
663 | ␉// Set PM_Profile from System-type only if user wanted this value to be forced␊ |
664 | ␉if (fadt_mod->PM_Profile != Platform.Type) ␊ |
665 | ␉{␊ |
666 | ␉ if (value) ␊ |
667 | ␉␉{ // user has overriden the SystemType so take care of it in FACP␊ |
668 | ␉␉␉verbose("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform.Type);␊ |
669 | ␉␉␉fadt_mod->PM_Profile = Platform.Type;␊ |
670 | ␉ }␊ |
671 | ␉ else␊ |
672 | ␉ { // PM_Profile has a different value and no override has been set, so reflect the user value to ioregs␊ |
673 | ␉␉␉Platform.Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1;␊ |
674 | ␉ } ␊ |
675 | ␉}␊ |
676 | ␉// We now have to write the systemm-type in ioregs: we cannot do it before in setupDeviceTree()␊ |
677 | ␉// because we need to take care of facp original content, if it is correct.␊ |
678 | ␉setupSystemType();␊ |
679 | ␉␊ |
680 | ␉// Patch FADT to fix restart␊ |
681 | ␉if (fix_restart)␊ |
682 | ␉{␊ |
683 | ␉␉fadt_mod->Flags|= 0x400;␊ |
684 | ␉␉fadt_mod->Reset_SpaceID␉␉= 0x01; // System I/O␊ |
685 | ␉␉fadt_mod->Reset_BitWidth␉= 0x08; // 1 byte␊ |
686 | ␉␉fadt_mod->Reset_BitOffset␉= 0x00; // Offset 0␊ |
687 | ␉␉fadt_mod->Reset_AccessWidth␉= 0x01; // Byte access␊ |
688 | ␉␉fadt_mod->Reset_Address␉␉= 0x0cf9; // Address of the register␊ |
689 | ␉␉fadt_mod->Reset_Value␉␉= 0x06; // Value to write to reset the system␊ |
690 | ␉␉verbose("FADT: Restart Fix applied!\n");␊ |
691 | ␉}␊ |
692 | ␉␊ |
693 | ␉// Patch DSDT Address if we have loaded DSDT.aml␊ |
694 | ␉if(new_dsdt)␊ |
695 | ␉{␊ |
696 | ␉␉DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
697 | ␉␉␊ |
698 | ␉␉fadt_mod->DSDT=(uint32_t)new_dsdt;␊ |
699 | ␉␉if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)␊ |
700 | ␉␉␉fadt_mod->X_DSDT=(uint32_t)new_dsdt;␊ |
701 | ␉␉␊ |
702 | ␉␉DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
703 | ␉␉␊ |
704 | ␉␉//Azi: using only getPciRootUID() to signal user supplied acpi table.␊ |
705 | ␉␉//verbose("FADT: Using custom DSDT!\n");␊ |
706 | ␉}␊ |
707 | ␉␊ |
708 | ␉// Correct the checksum␊ |
709 | ␉fadt_mod->Checksum=0;␊ |
710 | ␉fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);␊ |
711 | ␉␊ |
712 | ␉return fadt_mod;␊ |
713 | }␊ |
714 | ␊ |
715 | /* Setup ACPI without replacing DSDT. */␊ |
716 | int setupAcpiNoMod() //Azi:mozo - not used atm.␊ |
717 | {␊ |
718 | ␉//␉addConfigurationTable(&gEfiAcpiTableGuid, getAddressOfAcpiTable(), "ACPI");␊ |
719 | ␉//␉addConfigurationTable(&gEfiAcpi20TableGuid, getAddressOfAcpi20Table(), "ACPI_20");␊ |
720 | ␉// XXX aserebln why uint32 cast if pointer is uint64?␊ |
721 | ␉//Azi: "Slice: because rsdp_mod is a pointer (32bit in i386) to a structure uint64_t*"␊ |
722 | ␉acpi10_p = /*(uint64_t)*/(uint32_t)getAddressOfAcpiTable();␊ |
723 | ␉acpi20_p = /*(uint64_t)*/(uint32_t)getAddressOfAcpi20Table();␊ |
724 | ␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
725 | ␉if(acpi20_p) addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
726 | ␉return 1;␊ |
727 | }␊ |
728 | ␊ |
729 | /* Setup ACPI. Replace DSDT if DSDT.aml is found */␊ |
730 | int setupAcpi(void)␊ |
731 | {␊ |
732 | ␉int version;␊ |
733 | ␉void *new_dsdt;␊ |
734 | ␉␊ |
735 | ␉// Load replacement DSDT␊ |
736 | ␉new_dsdt = loadACPITable("DSDT.aml"); //Azi:dsdt␊ |
737 | ␉// Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present␊ |
738 | ␉/*if (!new_dsdt)␊ |
739 | ␉{␊ |
740 | ␉␉return setupAcpiNoMod();␊ |
741 | ␉}*/␊ |
742 | ␉␊ |
743 | ␉// Mozodojo: Load additional SSDTs␊ |
744 | ␉struct acpi_2_ssdt *new_ssdt[32]; // 30 + 2 additional tables for pss & cst␊ |
745 | ␉int ssdt_count=0;␊ |
746 | ␉␊ |
747 | ␉// SSDT Options␊ |
748 | ␉bool drop_ssdt=false, generate_pstates=false, generate_cstates=false; ␊ |
749 | ␉␊ |
750 | ␉getBoolForKey(kDropSSDTKey, &drop_ssdt, &bootInfo->bootConfig);␊ |
751 | ␉getBoolForKey(kGeneratePStatesKey, &generate_pstates, &bootInfo->bootConfig);␊ |
752 | ␉getBoolForKey(kGenerateCStatesKey, &generate_cstates, &bootInfo->bootConfig);␊ |
753 | ␉␊ |
754 | ␉{␊ |
755 | ␉␉int i;␊ |
756 | ␉␉␊ |
757 | ␉␉for (i=0; i<30; i++)␊ |
758 | ␉␉{␊ |
759 | ␉␉␉char filename[512];␊ |
760 | ␊ |
761 | ␉␉␉sprintf(filename, i>0?"SSDT-%d.aml":"SSDT.aml", i);␊ |
762 | ␉␉␉␊ |
763 | ␉␉␉if(new_ssdt[ssdt_count] = loadACPITable(filename)) ␊ |
764 | ␉␉␉{␉␉␉␉␊ |
765 | ␉␉␉␉ssdt_count++;␊ |
766 | ␉␉␉}␊ |
767 | ␉␉␉else ␊ |
768 | ␉␉␉{␊ |
769 | ␉␉␉␉break;␊ |
770 | ␉␉␉}␊ |
771 | ␉␉}␊ |
772 | ␉}␊ |
773 | ␉␉␊ |
774 | ␉// Do the same procedure for both versions of ACPI␊ |
775 | ␉for (version=0; version<2; version++) {␊ |
776 | ␉␉struct acpi_2_rsdp *rsdp, *rsdp_mod;␊ |
777 | ␉␉struct acpi_2_rsdt *rsdt, *rsdt_mod;␊ |
778 | ␉␉int rsdplength;␊ |
779 | ␉␉␊ |
780 | ␉␉// Find original rsdp␊ |
781 | ␉␉rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());␊ |
782 | ␉␉if (!rsdp)␊ |
783 | ␉␉{␊ |
784 | ␉␉␉DBG("No ACPI version %d found. Ignoring\n", version+1);␊ |
785 | ␉␉␉if (version)␊ |
786 | ␉␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, NULL, "ACPI_20");␊ |
787 | ␉␉␉else␊ |
788 | ␉␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI");␊ |
789 | ␉␉␉continue;␊ |
790 | ␉␉}␊ |
791 | ␉␉rsdplength=version?rsdp->Length:20;␊ |
792 | ␉␉␊ |
793 | ␉␉DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength);␊ |
794 | ␉␉␊ |
795 | ␉␉/* FIXME: no check that memory allocation succeeded ␊ |
796 | ␉␉ * Copy and patch RSDP,RSDT, XSDT and FADT␊ |
797 | ␉␉ * For more info see ACPI Specification pages 110 and following␊ |
798 | ␉␉ */␊ |
799 | ␉␉␊ |
800 | ␉␉rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);␊ |
801 | ␉␉memcpy(rsdp_mod, rsdp, rsdplength); ␊ |
802 | ␉␉rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);␊ |
803 | ␉␉␊ |
804 | ␉␉DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);␊ |
805 | ␉␉␊ |
806 | ␉␉if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000)␊ |
807 | ␉␉{␊ |
808 | ␉␉␉uint32_t *rsdt_entries;␊ |
809 | ␉␉␉int rsdt_entries_num;␊ |
810 | ␉␉␉int dropoffset=0, i;␊ |
811 | ␉␉␉␊ |
812 | ␉␉␉// mozo: using malloc cos I didn't found how to free already allocated kernel memory␊ |
813 | ␉␉␉rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length); ␊ |
814 | ␉␉␉memcpy (rsdt_mod, rsdt, rsdt->Length);␊ |
815 | ␉␉␉rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;␊ |
816 | ␉␉␉rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;␊ |
817 | ␉␉␉rsdt_entries=(uint32_t *)(rsdt_mod+1);␊ |
818 | ␉␉␉for (i=0;i<rsdt_entries_num;i++)␊ |
819 | ␉␉␉{␊ |
820 | ␉␉␉␉char *table=(char *)(rsdt_entries[i]);␊ |
821 | ␉␉␉␉if (!table)␊ |
822 | ␉␉␉␉␉continue;␊ |
823 | ␉␉␉␉␊ |
824 | ␉␉␉␉DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]);␊ |
825 | ␉␉␉␉␊ |
826 | ␉␉␉␉rsdt_entries[i-dropoffset]=rsdt_entries[i];␊ |
827 | ␉␉␉␉␊ |
828 | ␉␉␉␉if (drop_ssdt && tableSign(table, "SSDT"))␊ |
829 | ␉␉␉␉{␊ |
830 | ␉␉␉␉␉dropoffset++;␊ |
831 | ␉␉␉␉␉continue;␊ |
832 | ␉␉␉␉}␊ |
833 | ␉␉␉␉if (tableSign(table, "DSDT"))␊ |
834 | ␉␉␉␉{␊ |
835 | ␉␉␉␉␉DBG("DSDT found\n");␊ |
836 | ␉␉␉␉␉␊ |
837 | ␉␉␉␉␉if(new_dsdt)␊ |
838 | ␉␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
839 | ␉␉␉␉␉␉␉␉␉␉␊ |
840 | ␉␉␉␉␉continue;␊ |
841 | ␉␉␉␉}␊ |
842 | ␉␉␉␉if (tableSign(table, "FACP"))␊ |
843 | ␉␉␉␉{␊ |
844 | ␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
845 | ␉␉␉␉␉fadt=(struct acpi_2_fadt *)rsdt_entries[i];␊ |
846 | ␉␉␉␉␉␊ |
847 | ␉␉␉␉␉DBG("FADT found @%x, Length %d\n",fadt, fadt->Length);␊ |
848 | ␉␉␉␉␉␊ |
849 | ␉␉␉␉␉if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000)␊ |
850 | ␉␉␉␉␉{␊ |
851 | ␉␉␉␉␉␉printf("FADT incorrect. Not modified\n");␊ |
852 | ␉␉␉␉␉␉continue;␊ |
853 | ␉␉␉␉␉}␊ |
854 | ␉␉␉␉␉␊ |
855 | ␉␉␉␉␉fadt_mod = patch_fadt(fadt, new_dsdt);␊ |
856 | ␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
857 | ␉␉␉␉␉␊ |
858 | ␉␉␉␉␉// Generate _CST SSDT␊ |
859 | ␉␉␉␉␉if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod)))␊ |
860 | ␉␉␉␉␉{␊ |
861 | ␉␉␉␉␉␉generate_cstates = false; // Generate SSDT only once!␊ |
862 | ␉␉␉␉␉␉ssdt_count++;␊ |
863 | ␉␉␉␉␉}␊ |
864 | ␉␉␉␉␉␊ |
865 | ␉␉␉␉␉// Generating _PSS SSDT␊ |
866 | ␉␉␉␉␉if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT)))␊ |
867 | ␉␉␉␉␉{␊ |
868 | ␉␉␉␉␉␉generate_pstates = false; // Generate SSDT only once!␊ |
869 | ␉␉␉␉␉␉ssdt_count++;␊ |
870 | ␉␉␉␉␉}␊ |
871 | ␉␉␉␉␉␊ |
872 | ␉␉␉␉␉continue;␊ |
873 | ␉␉␉␉}␊ |
874 | ␉␉␉}␊ |
875 | ␉␉␉DBG("\n");␊ |
876 | ␉␉␉␊ |
877 | ␉␉␉// Allocate rsdt in Kernel memory area␊ |
878 | ␉␉␉rsdt_mod->Length += 4*ssdt_count - 4*dropoffset;␊ |
879 | ␉␉␉struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length);␊ |
880 | ␉␉␉memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length);␊ |
881 | ␉␉␉free(rsdt_mod); rsdt_mod = rsdt_copy;␊ |
882 | ␉␉␉rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;␊ |
883 | ␉␉␉rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;␊ |
884 | ␉␉␉rsdt_entries=(uint32_t *)(rsdt_mod+1);␊ |
885 | ␉␉␉␊ |
886 | ␉␉␉// Mozodojo: Insert additional SSDTs into RSDT␊ |
887 | ␉␉␉if(ssdt_count>0)␊ |
888 | ␉␉␉{␊ |
889 | ␉␉␉␉int j;␊ |
890 | ␉␉␉␉␊ |
891 | ␉␉␉␉for (j=0; j<ssdt_count; j++)␊ |
892 | ␉␉␉␉␉rsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];␊ |
893 | ␉␉␉␉␉␊ |
894 | ␉␉␉␉verbose("RSDT: Added %d SSDT table(s)\n", ssdt_count);␊ |
895 | ␉␉␉}␊ |
896 | ␊ |
897 | ␉␉␉// Correct the checksum of RSDT␊ |
898 | ␉␉␉DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum);␊ |
899 | ␉␉␉␊ |
900 | ␉␉␉rsdt_mod->Checksum=0;␊ |
901 | ␉␉␉rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length);␊ |
902 | ␉␉␉␊ |
903 | ␉␉␉DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);␊ |
904 | ␉␉}␊ |
905 | ␉␉else␊ |
906 | ␉␉{␊ |
907 | ␉␉␉rsdp_mod->RsdtAddress=0;␊ |
908 | ␉␉␉printf("RSDT not found or RSDT incorrect\n");␊ |
909 | ␉␉}␊ |
910 | ␉␉␊ |
911 | ␉␉if (version)␊ |
912 | ␉␉{␊ |
913 | ␉␉␉struct acpi_2_xsdt *xsdt, *xsdt_mod;␊ |
914 | ␉␉␉␊ |
915 | ␉␉␉// FIXME: handle 64-bit address correctly␊ |
916 | ␉␉␉␊ |
917 | ␉␉␉xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);␊ |
918 | ␉␉␉DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress,␊ |
919 | ␉␉␉␉xsdt->Length);␊ |
920 | ␉␉␉if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000)␊ |
921 | ␉␉␉{␊ |
922 | ␉␉␉␉uint64_t *xsdt_entries;␊ |
923 | ␉␉␉␉int xsdt_entries_num, i;␊ |
924 | ␉␉␉␉int dropoffset=0;␊ |
925 | ␉␉␉␉␊ |
926 | ␉␉␉␉// mozo: using malloc cos I didn't found how to free already allocated kernel memory␊ |
927 | ␉␉␉␉xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length); ␊ |
928 | ␉␉␉␉memcpy(xsdt_mod, xsdt, xsdt->Length);␊ |
929 | ␉␉␉␉rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;␊ |
930 | ␉␉␉␉xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;␊ |
931 | ␉␉␉␉xsdt_entries=(uint64_t *)(xsdt_mod+1);␊ |
932 | ␉␉␉␉for (i=0;i<xsdt_entries_num;i++)␊ |
933 | ␉␉␉␉{␊ |
934 | ␉␉␉␉␉char *table=(char *)((uint32_t)(xsdt_entries[i]));␊ |
935 | ␉␉␉␉␉if (!table)␊ |
936 | ␉␉␉␉␉␉continue;␊ |
937 | ␉␉␉␉␉␊ |
938 | ␉␉␉␉␉xsdt_entries[i-dropoffset]=xsdt_entries[i];␊ |
939 | ␉␉␉␉␉␊ |
940 | ␉␉␉␉␉if (drop_ssdt && tableSign(table, "SSDT"))␊ |
941 | ␉␉␉␉␉{␊ |
942 | ␉␉␉␉␉␉dropoffset++;␊ |
943 | ␉␉␉␉␉␉continue;␊ |
944 | ␉␉␉␉␉}␉␉␉␉␉␊ |
945 | ␉␉␉␉␉if (tableSign(table, "DSDT"))␊ |
946 | ␉␉␉␉␉{␊ |
947 | ␉␉␉␉␉␉DBG("DSDT found\n");␊ |
948 | ␉␉␉␉␉␉␊ |
949 | ␉␉␉␉␉␉if (new_dsdt) ␊ |
950 | ␉␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
951 | ␉␉␉␉␉␉␊ |
952 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
953 | ␉␉␉␉␉␉␊ |
954 | ␉␉␉␉␉␉continue;␊ |
955 | ␉␉␉␉␉}␊ |
956 | ␉␉␉␉␉if (tableSign(table, "FACP"))␊ |
957 | ␉␉␉␉␉{␊ |
958 | ␉␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
959 | ␉␉␉␉␉␉fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i];␊ |
960 | ␉␉␉␉␉␉␊ |
961 | ␉␉␉␉␉␉DBG("FADT found @%x,%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt, ␊ |
962 | ␉␉␉␉␉␉␉fadt->Length);␊ |
963 | ␉␉␉␉␉␉␊ |
964 | ␉␉␉␉␉␉if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000)␊ |
965 | ␉␉␉␉␉␉{␊ |
966 | ␉␉␉␉␉␉␉verbose("FADT incorrect or after 4GB. Dropping XSDT\n");␊ |
967 | ␉␉␉␉␉␉␉goto drop_xsdt;␊ |
968 | ␉␉␉␉␉␉}␊ |
969 | ␉␉␉␉␉␉␊ |
970 | ␉␉␉␉␉␉fadt_mod = patch_fadt(fadt, new_dsdt);␊ |
971 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
972 | ␉␉␉␉␉␉␊ |
973 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
974 | ␉␉␉␉␉␉␊ |
975 | ␉␉␉␉␉␉// Generate _CST SSDT␊ |
976 | ␉␉␉␉␉␉if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) ␊ |
977 | ␉␉␉␉␉␉{␊ |
978 | ␉␉␉␉␉␉␉generate_cstates = false; // Generate SSDT only once!␊ |
979 | ␉␉␉␉␉␉␉ssdt_count++;␊ |
980 | ␉␉␉␉␉␉}␊ |
981 | ␉␉␉␉␉␉␊ |
982 | ␉␉␉␉␉␉// Generating _PSS SSDT␊ |
983 | ␉␉␉␉␉␉if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT)))␊ |
984 | ␉␉␉␉␉␉{␊ |
985 | ␉␉␉␉␉␉␉generate_pstates = false; // Generate SSDT only once!␊ |
986 | ␉␉␉␉␉␉␉ssdt_count++;␊ |
987 | ␉␉␉␉␉␉}␊ |
988 | ␉␉␉␉␉␉␊ |
989 | ␉␉␉␉␉␉continue;␊ |
990 | ␉␉␉␉␉}␊ |
991 | ␉␉␉␉␉␊ |
992 | ␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
993 | ␉␉␉␉␉␊ |
994 | ␉␉␉␉}␊ |
995 | ␉␉␉␉␊ |
996 | ␉␉␉␉// Allocate xsdt in Kernel memory area␊ |
997 | ␉␉␉␉xsdt_mod->Length += 8*ssdt_count - 8*dropoffset;␊ |
998 | ␉␉␉␉struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length);␊ |
999 | ␉␉␉␉memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length);␊ |
1000 | ␉␉␉␉free(xsdt_mod); xsdt_mod = xsdt_copy;␊ |
1001 | ␉␉␉␉rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;␊ |
1002 | ␉␉␉␉xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;␊ |
1003 | ␉␉␉␉xsdt_entries=(uint64_t *)(xsdt_mod+1);␊ |
1004 | ␉␉␉␉␊ |
1005 | ␉␉␉␉// Mozodojo: Insert additional SSDTs into XSDT␊ |
1006 | ␉␉␉␉if(ssdt_count>0)␊ |
1007 | ␉␉␉␉{␊ |
1008 | ␉␉␉␉␉int j;␊ |
1009 | ␉␉␉␉␉␊ |
1010 | ␉␉␉␉␉for (j=0; j<ssdt_count; j++)␊ |
1011 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];␊ |
1012 | ␉␉␉␉␉␉␊ |
1013 | ␉␉␉␉␉verbose("Added %d SSDT table(s) into XSDT\n", ssdt_count);␊ |
1014 | ␉␉␉␉}␊ |
1015 | ␊ |
1016 | ␉␉␉␉// Correct the checksum of XSDT␊ |
1017 | ␉␉␉␉xsdt_mod->Checksum=0;␊ |
1018 | ␉␉␉␉xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);␊ |
1019 | ␉␉␉}␊ |
1020 | ␉␉␉else␊ |
1021 | ␉␉␉{␊ |
1022 | ␉␉␉drop_xsdt:␊ |
1023 | ␉␉␉␉␊ |
1024 | ␉␉␉␉DBG("About to drop XSDT\n");␊ |
1025 | ␉␉␉␉␊ |
1026 | ␉␉␉␉/*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT. ␊ |
1027 | ␉␉␉␉ * A Better strategy would be to generate␊ |
1028 | ␉␉␉␉ */␊ |
1029 | ␉␉␉␉␊ |
1030 | ␉␉␉␉rsdp_mod->XsdtAddress=0xffffffffffffffffLL;␊ |
1031 | ␉␉␉␉verbose("XSDT not found or XSDT incorrect\n");␊ |
1032 | ␉␉␉}␊ |
1033 | ␉␉}␊ |
1034 | ␉␉␊ |
1035 | ␉␉// Correct the checksum of RSDP ␊ |
1036 | ␉␉␊ |
1037 | ␉␉DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum);␊ |
1038 | ␉␉␊ |
1039 | ␉␉rsdp_mod->Checksum=0;␊ |
1040 | ␉␉rsdp_mod->Checksum=256-checksum8(rsdp_mod,20);␊ |
1041 | ␉␉␊ |
1042 | ␉␉DBG("New checksum %d\n", rsdp_mod->Checksum);␊ |
1043 | ␉␉␊ |
1044 | ␉␉if (version)␊ |
1045 | ␉␉{␊ |
1046 | ␉␉␉DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum);␊ |
1047 | ␉␉␉␊ |
1048 | ␉␉␉rsdp_mod->ExtendedChecksum=0;␊ |
1049 | ␉␉␉rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length);␊ |
1050 | ␉␉␉␊ |
1051 | ␉␉␉DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum);␊ |
1052 | ␉␉␉␊ |
1053 | ␉␉}␊ |
1054 | ␉␉␊ |
1055 | ␉␉//Azi:mozo - commented out; using instead of "FADT: Using custom DSDT!"␊ |
1056 | ␉␉verbose("ACPI version %d\n", version + 1); // always prints so, just print acpi version.␊ |
1057 | ␉␉if (version)␊ |
1058 | ␉␉{␊ |
1059 | ␉␉␉// XXX aserebln why uint32 cast if pointer is uint64?␊ |
1060 | ␉␉␉//Azi: See setupAcpiNoMod.␊ |
1061 | ␉␉␉acpi20_p = (/*uint64_t)(*/uint32_t)rsdp_mod;␊ |
1062 | ␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
1063 | ␉␉}␊ |
1064 | ␉␉else␊ |
1065 | ␉␉{␊ |
1066 | ␉␉␉// XXX aserebln why uint32 cast if pointer is uint64?␊ |
1067 | ␉␉␉acpi10_p = (/*uint64_t)(*/uint32_t)rsdp_mod;␊ |
1068 | ␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
1069 | ␉␉}␊ |
1070 | ␉}␊ |
1071 | #if DEBUG_ACPI␊ |
1072 | ␉printf("Press a key to continue... (DEBUG_ACPI)\n");␊ |
1073 | ␉getc();␊ |
1074 | #endif␊ |
1075 | ␉return 1;␊ |
1076 | }␊ |
1077 | |