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