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