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