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