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 "dsdt_patcher.h"␊ |
12 | ␊ |
13 | #ifndef DEBUG_DSDT␊ |
14 | #define DEBUG_DSDT 0␊ |
15 | #endif␊ |
16 | ␊ |
17 | #if DEBUG_DSDT==2␊ |
18 | #define DBG(x...) {printf(x); sleep(1);}␊ |
19 | #elif DEBUG_DSDT==1␊ |
20 | #define DBG(x...) printf(x)␊ |
21 | #else␊ |
22 | #define DBG(x...)␊ |
23 | #endif␊ |
24 | ␊ |
25 | /* Gets the ACPI 1.0 RSDP address */␊ |
26 | static struct acpi_2_rsdp* getAddressOfAcpiTable()␊ |
27 | {␊ |
28 | /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */␊ |
29 | ␉␊ |
30 | void *acpi_addr = (void*)ACPI_RANGE_START;␊ |
31 | for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16)␊ |
32 | {␊ |
33 | if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE)␊ |
34 | {␊ |
35 | uint8_t csum = checksum8(acpi_addr, 20);␊ |
36 | if(csum == 0)␊ |
37 | {␊ |
38 | // Only return the table if it is a true version 1.0 table (Revision 0)␊ |
39 | if(((struct acpi_2_rsdp*)acpi_addr)->Revision == 0)␊ |
40 | return acpi_addr;␊ |
41 | }␊ |
42 | }␊ |
43 | }␊ |
44 | return NULL;␊ |
45 | }␊ |
46 | ␊ |
47 | /* Gets the ACPI 2.0 RSDP address */␊ |
48 | static struct acpi_2_rsdp* getAddressOfAcpi20Table()␊ |
49 | {␊ |
50 | /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */␊ |
51 | ␉␊ |
52 | void *acpi_addr = (void*)ACPI_RANGE_START;␊ |
53 | for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16)␊ |
54 | {␊ |
55 | if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE)␊ |
56 | {␊ |
57 | uint8_t csum = checksum8(acpi_addr, 20);␊ |
58 | ␊ |
59 | /* Only assume this is a 2.0 or better table if the revision is greater than 0␊ |
60 | * NOTE: ACPI 3.0 spec only seems to say that 1.0 tables have revision 1␊ |
61 | * and that the current revision is 2.. I am going to assume that rev > 0 is 2.0.␊ |
62 | */␊ |
63 | ␊ |
64 | if(csum == 0 && (((struct acpi_2_rsdp*)acpi_addr)->Revision > 0))␊ |
65 | {␊ |
66 | uint8_t csum2 = checksum8(acpi_addr, sizeof(struct acpi_2_rsdp));␊ |
67 | if(csum2 == 0)␊ |
68 | return acpi_addr;␊ |
69 | }␊ |
70 | }␊ |
71 | }␊ |
72 | return NULL;␊ |
73 | }␊ |
74 | ␊ |
75 | void *loadACPITable (const char *filename)␊ |
76 | {␊ |
77 | ␉void *tableAddr;␊ |
78 | ␉int fd;␊ |
79 | ␉char dirspec[512];␊ |
80 | ␊ |
81 | ␉// Check booting partition␊ |
82 | ␉sprintf(dirspec,"%s",filename);␊ |
83 | ␉fd=open (dirspec,0);␊ |
84 | ␉if (fd<0)␊ |
85 | ␉{␉// Check Extra on booting partition␊ |
86 | ␉␉sprintf(dirspec,"/Extra/%s",filename);␊ |
87 | ␉␉fd=open (dirspec,0);␊ |
88 | ␉␉if (fd<0)␊ |
89 | ␉␉{␉// Fall back to booter partition␊ |
90 | ␉␉␉sprintf(dirspec,"bt(0,0)/Extra/%s",filename);␊ |
91 | ␉␉␉fd=open (dirspec,0);␊ |
92 | ␉␉␉if (fd<0)␊ |
93 | ␉␉␉{␊ |
94 | ␉␉␉␉verbose("ACPI Table not found: %s\n", filename);␊ |
95 | ␉␉␉␉return NULL;␊ |
96 | ␉␉␉}␊ |
97 | ␉␉}␊ |
98 | ␉}␊ |
99 | ␊ |
100 | ␉tableAddr=(void*)AllocateKernelMemory(file_size (fd));␊ |
101 | ␉if (tableAddr)␊ |
102 | ␉{␊ |
103 | ␉␉if (read (fd, tableAddr, file_size (fd))!=file_size (fd))␊ |
104 | ␉␉{␊ |
105 | ␉␉␉printf("Couldn't read table %s\n",dirspec);␊ |
106 | ␉␉␉free (tableAddr);␊ |
107 | ␉␉␉close (fd);␊ |
108 | ␉␉␉return NULL;␊ |
109 | ␉␉}␊ |
110 | ␊ |
111 | ␉␉DBG("Table %s read and stored at: %x\n", dirspec, tableAddr);␊ |
112 | ␉␉close (fd);␊ |
113 | ␉␉return tableAddr;␊ |
114 | ␉}␊ |
115 | ␊ |
116 | ␉printf("Couldn't allocate memory for table %s\n", dirspec);␊ |
117 | ␉close (fd);␊ |
118 | ␉return NULL;␊ |
119 | }␊ |
120 | ␊ |
121 | /* Setup ACPI without replacing DSDT. */␊ |
122 | int setupAcpiNoMod()␊ |
123 | {␊ |
124 | //␉addConfigurationTable(&gEfiAcpiTableGuid, getAddressOfAcpiTable(), "ACPI");␊ |
125 | //␉addConfigurationTable(&gEfiAcpi20TableGuid, getAddressOfAcpi20Table(), "ACPI_20");␊ |
126 | ␉acpi10_p = (uint32_t)getAddressOfAcpiTable();␊ |
127 | ␉acpi20_p = (uint32_t)getAddressOfAcpi20Table();␊ |
128 | ␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
129 | ␉if(acpi20_p) addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
130 | ␉return 1;␊ |
131 | }␊ |
132 | ␊ |
133 | /* Setup ACPI. Replace DSDT if DSDT.aml is found */␊ |
134 | int setupAcpi()␊ |
135 | {␊ |
136 | ␉int version;␊ |
137 | ␉void *new_dsdt;␊ |
138 | ␉const char *dsdt_filename;␊ |
139 | ␉/* const char *facp_filename; */␊ |
140 | ␉int len;␊ |
141 | ␉boolean_t drop_ssdt=NO;␊ |
142 | ␊ |
143 | ␉//DBG("Enter setupACPI\n");␊ |
144 | ␊ |
145 | ␉if (!getValueForKey("DSDT", &dsdt_filename, &len, &bootInfo->bootConfig))␊ |
146 | ␉␉dsdt_filename="DSDT.aml";␊ |
147 | ␉␊ |
148 | ␉// Load replacement DSDT␊ |
149 | ␉new_dsdt=loadACPITable(dsdt_filename);␊ |
150 | ␉if (!new_dsdt)␊ |
151 | ␉{␊ |
152 | ␉␉return setupAcpiNoMod();␊ |
153 | ␉}␊ |
154 | ␉DBG("New DSDT Loaded in memory\n");␊ |
155 | ␉␊ |
156 | ␉{␊ |
157 | ␉␉BOOL tmp;␊ |
158 | ␉␉drop_ssdt=getBoolForKey("DropSSDT",&tmp, &bootInfo->bootConfig)&&tmp;␊ |
159 | ␉}␊ |
160 | ␉␊ |
161 | ␉// Do the same procedure for both versions of ACPI␊ |
162 | ␉for (version=0;version<2;version++)␊ |
163 | ␉{␊ |
164 | ␉␉struct acpi_2_rsdp *rsdp, *rsdp_mod;␊ |
165 | ␉␉struct acpi_2_rsdt *rsdt, *rsdt_mod;␊ |
166 | ␉␉int rsdplength;␊ |
167 | ␉␉␊ |
168 | ␉␉// Find original rsdp␊ |
169 | ␉␉rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());␊ |
170 | ␉␉if (!rsdp)␊ |
171 | ␉␉{␊ |
172 | ␉␉␉DBG("No ACPI version %d found. Ignoring\n", version+1);␊ |
173 | ␉␉␉if (version)␊ |
174 | ␉␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, NULL, "ACPI_20");␊ |
175 | ␉␉␉else␊ |
176 | ␉␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI");␊ |
177 | ␉␉␉continue;␊ |
178 | ␉␉}␊ |
179 | ␉␉rsdplength=version?rsdp->Length:20;␊ |
180 | ␊ |
181 | ␉␉DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength);␊ |
182 | ␊ |
183 | ␉␉/* FIXME: no check that memory allocation succeeded ␊ |
184 | ␉␉ * Copy and patch RSDP,RSDT, XSDT and FADT␊ |
185 | ␉␉ * For more info see ACPI Specification pages 110 and following␊ |
186 | ␉␉ */␊ |
187 | ␊ |
188 | ␉␉rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);␊ |
189 | ␉␉memcpy(rsdp_mod, rsdp, rsdplength); ␊ |
190 | ␉␉rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);␊ |
191 | ␊ |
192 | ␉␉DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);␊ |
193 | ␉␉␊ |
194 | ␉␉if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000)␊ |
195 | ␉␉{␊ |
196 | ␉␉␉uint32_t *rsdt_entries;␊ |
197 | ␉␉␉int rsdt_entries_num;␊ |
198 | ␉␉␉int dropoffset=0, i;␊ |
199 | ␉␉␉␊ |
200 | ␉␉␉rsdt_mod=(struct acpi_2_rsdt *)AllocateKernelMemory(rsdt->Length); ␊ |
201 | ␉␉␉memcpy (rsdt_mod, rsdt, rsdt->Length);␊ |
202 | ␉␉␉rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;␊ |
203 | ␉␉␉rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;␊ |
204 | ␉␉␉rsdt_entries=(uint32_t *)(rsdt_mod+1);␊ |
205 | ␉␉␉for (i=0;i<rsdt_entries_num;i++)␊ |
206 | ␉␉␉{␊ |
207 | ␉␉␉␉char *table=(char *)(rsdt_entries[i]);␊ |
208 | ␉␉␉␉if (!table)␊ |
209 | ␉␉␉␉␉continue;␊ |
210 | ␊ |
211 | ␉␉␉␉DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]);␊ |
212 | ␊ |
213 | ␉␉␉␉rsdt_entries[i-dropoffset]=rsdt_entries[i];␊ |
214 | ␉␉␉␉if (drop_ssdt && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
215 | ␉␉␉␉{␊ |
216 | ␉␉␉␉␉dropoffset++;␊ |
217 | ␉␉␉␉␉continue;␊ |
218 | ␉␉␉␉}␊ |
219 | ␉␉␉␉if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
220 | ␉␉␉␉{␊ |
221 | ␉␉␉␉␉DBG("DSDT found\n");␊ |
222 | ␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
223 | ␉␉␉␉␉continue;␊ |
224 | ␉␉␉␉}␊ |
225 | ␉␉␉␉if (table[0]=='F' && table[1]=='A' && table[2]=='C' && table[3]=='P')␊ |
226 | ␉␉␉␉{␊ |
227 | ␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
228 | ␉␉␉␉␉fadt=(struct acpi_2_fadt *)rsdt_entries[i];␊ |
229 | ␊ |
230 | ␉␉␉␉␉DBG("FADT found @%x, Length %d\n",fadt, fadt->Length);␊ |
231 | ␊ |
232 | ␉␉␉␉␉if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000)␊ |
233 | ␉␉␉␉␉{␊ |
234 | ␉␉␉␉␉␉printf("FADT incorrect. Not modified\n");␊ |
235 | ␉␉␉␉␉␉continue;␊ |
236 | ␉␉␉␉␉}␊ |
237 | ␉␉␉␉␉␊ |
238 | ␉␉␉␉␉fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length); ␊ |
239 | ␉␉␉␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
240 | ␊ |
241 | ␉␉␉␉␉// Patch DSDT Address␊ |
242 | ␉␉␉␉␉DBG("Old DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
243 | ␊ |
244 | ␉␉␉␉␉fadt_mod->DSDT=(uint32_t)new_dsdt;␊ |
245 | ␉␉␉␉␉if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)␊ |
246 | ␉␉␉␉␉␉fadt_mod->X_DSDT=(uint32_t)new_dsdt;␊ |
247 | ␊ |
248 | ␉␉␉␉␉DBG("New DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
249 | ␊ |
250 | ␉␉␉␉␉// Correct the checksum␊ |
251 | ␉␉␉␉␉fadt_mod->Checksum=0;␊ |
252 | ␉␉␉␉␉fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);␊ |
253 | ␉␉␉␉␉␊ |
254 | ␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
255 | ␉␉␉␉␉continue;␊ |
256 | ␉␉␉␉}␊ |
257 | ␉␉␉}␊ |
258 | ␊ |
259 | ␉␉␉// Correct the checksum of RSDT␊ |
260 | ␉␉␉rsdt_mod->Length-=4*dropoffset;␊ |
261 | ␊ |
262 | ␉␉␉DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum);␊ |
263 | ␊ |
264 | ␉␉␉rsdt_mod->Checksum=0;␊ |
265 | ␉␉␉rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length);␊ |
266 | ␊ |
267 | ␉␉␉DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);␊ |
268 | ␉␉}␊ |
269 | ␉␉else␊ |
270 | ␉␉{␊ |
271 | ␉␉␉rsdp_mod->RsdtAddress=0;␊ |
272 | ␉␉␉printf("RSDT not found or RSDT incorrect\n");␊ |
273 | ␉␉}␊ |
274 | ␊ |
275 | ␉␉if (version)␊ |
276 | ␉␉{␊ |
277 | ␉␉␉struct acpi_2_xsdt *xsdt, *xsdt_mod;␊ |
278 | ␊ |
279 | ␉␉␉// FIXME: handle 64-bit address correctly␊ |
280 | ␊ |
281 | ␉␉␉xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);␊ |
282 | ␉␉␉DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress,␊ |
283 | ␉␉␉␉␉xsdt->Length);␊ |
284 | ␉␉␉if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000)␊ |
285 | ␉␉␉{␊ |
286 | ␉␉␉␉uint64_t *xsdt_entries;␊ |
287 | ␉␉␉␉int xsdt_entries_num, i;␊ |
288 | ␉␉␉␉int dropoffset=0;␊ |
289 | ␉␉␉␉␊ |
290 | ␉␉␉␉xsdt_mod=(struct acpi_2_xsdt*)AllocateKernelMemory(xsdt->Length); ␊ |
291 | ␉␉␉␉memcpy(xsdt_mod, xsdt, xsdt->Length);␊ |
292 | ␉␉␉␉rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;␊ |
293 | ␉␉␉␉xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;␊ |
294 | ␉␉␉␉xsdt_entries=(uint64_t *)(xsdt_mod+1);␊ |
295 | ␉␉␉␉for (i=0;i<xsdt_entries_num;i++)␊ |
296 | ␉␉␉␉{␊ |
297 | ␉␉␉␉␉char *table=(char *)((uint32_t)(xsdt_entries[i]));␊ |
298 | ␉␉␉␉␉if (!table)␊ |
299 | ␉␉␉␉␉␉continue;␊ |
300 | ␉␉␉␉␉xsdt_entries[i-dropoffset]=xsdt_entries[i];␊ |
301 | ␉␉␉␉␉if (drop_ssdt && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
302 | ␉␉␉␉␉{␊ |
303 | ␉␉␉␉␉␉dropoffset++;␊ |
304 | ␉␉␉␉␉␉continue;␊ |
305 | ␉␉␉␉␉}␉␉␉␉␉␊ |
306 | ␉␉␉␉␉if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
307 | ␉␉␉␉␉{␊ |
308 | ␉␉␉␉␉␉DBG("DSDT found\n");␊ |
309 | ␊ |
310 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
311 | ␊ |
312 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
313 | ␉␉␉␉␉␉␊ |
314 | ␉␉␉␉␉␉continue;␊ |
315 | ␉␉␉␉␉}␊ |
316 | ␉␉␉␉␉if (table[0]=='F' && table[1]=='A' && table[2]=='C' && table[3]=='P')␊ |
317 | ␉␉␉␉␉{␊ |
318 | ␉␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
319 | ␉␉␉␉␉␉fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i];␊ |
320 | ␊ |
321 | ␉␉␉␉␉␉DBG("FADT found @%x,%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt, ␊ |
322 | ␉␉␉␉␉␉␉␉ fadt->Length);␊ |
323 | ␊ |
324 | ␉␉␉␉␉␉if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000)␊ |
325 | ␉␉␉␉␉␉{␊ |
326 | ␉␉␉␉␉␉␉printf("FADT incorrect or after 4GB. Dropping XSDT\n");␊ |
327 | ␉␉␉␉␉␉␉goto drop_xsdt;␊ |
328 | ␉␉␉␉␉␉}␊ |
329 | ␉␉␉␉␉␉fadt_mod=(struct acpi_2_fadt*)AllocateKernelMemory(fadt->Length); ␊ |
330 | ␉␉␉␉␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
331 | ␊ |
332 | ␉␉␉␉␉␉// Patch DSDT Address␊ |
333 | ␉␉␉␉␉␉DBG("Old DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
334 | ␊ |
335 | ␉␉␉␉␉␉fadt_mod->DSDT=(uint32_t)new_dsdt;␊ |
336 | ␉␉␉␉␉␉if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)␊ |
337 | ␉␉␉␉␉␉␉fadt_mod->X_DSDT=(uint32_t)new_dsdt;␊ |
338 | ␊ |
339 | ␉␉␉␉␉␉DBG("New DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
340 | ␊ |
341 | ␉␉␉␉␉␉// Correct the checksum␊ |
342 | ␉␉␉␉␉␉fadt_mod->Checksum=0;␊ |
343 | ␉␉␉␉␉␉fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);␊ |
344 | ␉␉␉␉␉␉␊ |
345 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
346 | ␊ |
347 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
348 | ␊ |
349 | ␉␉␉␉␉␉continue;␊ |
350 | ␉␉␉␉␉}␊ |
351 | ␊ |
352 | ␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
353 | ␊ |
354 | ␉␉␉␉}␊ |
355 | ␊ |
356 | ␉␉␉␉// Correct the checksum of XSDT␊ |
357 | ␉␉␉␉xsdt_mod->Length-=8*dropoffset;␊ |
358 | ␉␉␉␉xsdt_mod->Checksum=0;␊ |
359 | ␉␉␉␉xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);␊ |
360 | ␉␉␉}␊ |
361 | ␉␉␉else␊ |
362 | ␉␉␉{␊ |
363 | ␉␉␉drop_xsdt:␊ |
364 | ␊ |
365 | ␉␉␉␉DBG("About to drop XSDT\n");␊ |
366 | ␊ |
367 | ␉␉␉␉/*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT. ␊ |
368 | ␉␉␉␉ * A Better strategy would be to generate␊ |
369 | ␉␉␉␉ */␊ |
370 | ␊ |
371 | ␉␉␉␉rsdp_mod->XsdtAddress=0xffffffffffffffffLL;␊ |
372 | ␉␉␉␉printf("XSDT not found or XSDT incorrect\n");␊ |
373 | ␉␉␉}␊ |
374 | ␉␉}␊ |
375 | ␊ |
376 | ␉␉// Correct the checksum of RSDP ␊ |
377 | ␊ |
378 | ␉␉DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum);␊ |
379 | ␊ |
380 | ␉␉rsdp_mod->Checksum=0;␊ |
381 | ␉␉rsdp_mod->Checksum=256-checksum8(rsdp_mod,20);␊ |
382 | ␊ |
383 | ␉␉DBG("New checksum %d\n", rsdp_mod->Checksum);␊ |
384 | ␊ |
385 | ␉␉if (version)␊ |
386 | ␉␉{␊ |
387 | ␉␉␉DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum);␊ |
388 | ␊ |
389 | ␉␉␉rsdp_mod->ExtendedChecksum=0;␊ |
390 | ␉␉␉rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length);␊ |
391 | ␊ |
392 | ␉␉␉DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum);␊ |
393 | ␊ |
394 | ␉␉}␊ |
395 | ␉␉␊ |
396 | ␉␉verbose("Patched ACPI version %d DSDT\n", version+1);␊ |
397 | ␉␉if (version)␊ |
398 | ␉␉{␊ |
399 | ␉␉␉acpi20_p = (uint32_t)rsdp_mod;␊ |
400 | ␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
401 | ␉␉}␊ |
402 | ␉␉else␊ |
403 | ␉␉{␊ |
404 | ␉␉␉acpi10_p = (uint32_t)rsdp_mod;␊ |
405 | ␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
406 | ␉␉}␊ |
407 | ␉}␊ |
408 | ␉#if DEBUG_DSDT␊ |
409 | ␉printf("Press a key to continue... (DEBUG_DSDT)\n");␊ |
410 | ␉getc();␊ |
411 | ␉#endif␊ |
412 | ␉return 1;␊ |
413 | }␊ |
414 | |