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 | struct acpi_2_fadt *␊ |
122 | patch_fadt(struct acpi_2_fadt *fadt, void *new_dsdt)␊ |
123 | {␊ |
124 | ␊ |
125 | ␉struct acpi_2_fadt *fadt_mod;␊ |
126 | ␉BOOL fadt_rev2_needed = NO;␊ |
127 | ␊ |
128 | ␉// Allocate new fadt table␊ |
129 | ␉if (fadt->Length < 0x84 && fadt_rev2_needed)␊ |
130 | ␉{␊ |
131 | ␉␉fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);␊ |
132 | ␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
133 | ␉␉fadt_mod->Length = 0x84;␊ |
134 | ␉␉fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)␊ |
135 | ␉}␊ |
136 | ␉else␊ |
137 | ␉{␊ |
138 | ␉␉fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);␊ |
139 | ␉␉memcpy(fadt_mod, fadt, fadt->Length);␊ |
140 | ␉}␊ |
141 | ␊ |
142 | ␉// Patch DSDT Address␊ |
143 | ␉DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
144 | ␊ |
145 | ␉fadt_mod->DSDT=(uint32_t)new_dsdt;␊ |
146 | ␉if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)␊ |
147 | ␉␉fadt_mod->X_DSDT=(uint32_t)new_dsdt;␊ |
148 | ␊ |
149 | ␉DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);␊ |
150 | ␊ |
151 | ␉// Correct the checksum␊ |
152 | ␉fadt_mod->Checksum=0;␊ |
153 | ␉fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);␊ |
154 | ␊ |
155 | ␉return fadt_mod;␊ |
156 | }␊ |
157 | ␊ |
158 | /* Setup ACPI without replacing DSDT. */␊ |
159 | int setupAcpiNoMod()␊ |
160 | {␊ |
161 | //␉addConfigurationTable(&gEfiAcpiTableGuid, getAddressOfAcpiTable(), "ACPI");␊ |
162 | //␉addConfigurationTable(&gEfiAcpi20TableGuid, getAddressOfAcpi20Table(), "ACPI_20");␊ |
163 | ␉acpi10_p = (uint32_t)getAddressOfAcpiTable();␊ |
164 | ␉acpi20_p = (uint32_t)getAddressOfAcpi20Table();␊ |
165 | ␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
166 | ␉if(acpi20_p) addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
167 | ␉return 1;␊ |
168 | }␊ |
169 | ␊ |
170 | /* Setup ACPI. Replace DSDT if DSDT.aml is found */␊ |
171 | int setupAcpi()␊ |
172 | {␊ |
173 | ␉int version;␊ |
174 | ␉void *new_dsdt;␊ |
175 | ␉const char *dsdt_filename;␊ |
176 | ␉/* const char *facp_filename; */␊ |
177 | ␉int len;␊ |
178 | ␉boolean_t drop_ssdt=NO;␊ |
179 | ␊ |
180 | ␉//DBG("Enter setupACPI\n");␊ |
181 | ␊ |
182 | ␉if (!getValueForKey("DSDT", &dsdt_filename, &len, &bootInfo->bootConfig))␊ |
183 | ␉␉dsdt_filename="DSDT.aml";␊ |
184 | ␉␊ |
185 | ␉// Load replacement DSDT␊ |
186 | ␉new_dsdt=loadACPITable(dsdt_filename);␊ |
187 | ␉if (!new_dsdt)␊ |
188 | ␉{␊ |
189 | ␉␉return setupAcpiNoMod();␊ |
190 | ␉}␊ |
191 | ␉DBG("New DSDT Loaded in memory\n");␊ |
192 | ␉␊ |
193 | ␉{␊ |
194 | ␉␉BOOL tmp;␊ |
195 | ␉␉drop_ssdt=getBoolForKey("DropSSDT",&tmp, &bootInfo->bootConfig)&&tmp;␊ |
196 | ␉}␊ |
197 | ␉␊ |
198 | ␉// Do the same procedure for both versions of ACPI␊ |
199 | ␉for (version=0;version<2;version++)␊ |
200 | ␉{␊ |
201 | ␉␉struct acpi_2_rsdp *rsdp, *rsdp_mod;␊ |
202 | ␉␉struct acpi_2_rsdt *rsdt, *rsdt_mod;␊ |
203 | ␉␉int rsdplength;␊ |
204 | ␉␉␊ |
205 | ␉␉// Find original rsdp␊ |
206 | ␉␉rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());␊ |
207 | ␉␉if (!rsdp)␊ |
208 | ␉␉{␊ |
209 | ␉␉␉DBG("No ACPI version %d found. Ignoring\n", version+1);␊ |
210 | ␉␉␉if (version)␊ |
211 | ␉␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, NULL, "ACPI_20");␊ |
212 | ␉␉␉else␊ |
213 | ␉␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI");␊ |
214 | ␉␉␉continue;␊ |
215 | ␉␉}␊ |
216 | ␉␉rsdplength=version?rsdp->Length:20;␊ |
217 | ␊ |
218 | ␉␉DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength);␊ |
219 | ␊ |
220 | ␉␉/* FIXME: no check that memory allocation succeeded ␊ |
221 | ␉␉ * Copy and patch RSDP,RSDT, XSDT and FADT␊ |
222 | ␉␉ * For more info see ACPI Specification pages 110 and following␊ |
223 | ␉␉ */␊ |
224 | ␊ |
225 | ␉␉rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);␊ |
226 | ␉␉memcpy(rsdp_mod, rsdp, rsdplength); ␊ |
227 | ␉␉rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);␊ |
228 | ␊ |
229 | ␉␉DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);␊ |
230 | ␉␉␊ |
231 | ␉␉if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000)␊ |
232 | ␉␉{␊ |
233 | ␉␉␉uint32_t *rsdt_entries;␊ |
234 | ␉␉␉int rsdt_entries_num;␊ |
235 | ␉␉␉int dropoffset=0, i;␊ |
236 | ␉␉␉␊ |
237 | ␉␉␉rsdt_mod=(struct acpi_2_rsdt *)AllocateKernelMemory(rsdt->Length); ␊ |
238 | ␉␉␉memcpy (rsdt_mod, rsdt, rsdt->Length);␊ |
239 | ␉␉␉rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;␊ |
240 | ␉␉␉rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;␊ |
241 | ␉␉␉rsdt_entries=(uint32_t *)(rsdt_mod+1);␊ |
242 | ␉␉␉for (i=0;i<rsdt_entries_num;i++)␊ |
243 | ␉␉␉{␊ |
244 | ␉␉␉␉char *table=(char *)(rsdt_entries[i]);␊ |
245 | ␉␉␉␉if (!table)␊ |
246 | ␉␉␉␉␉continue;␊ |
247 | ␊ |
248 | ␉␉␉␉DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]);␊ |
249 | ␊ |
250 | ␉␉␉␉rsdt_entries[i-dropoffset]=rsdt_entries[i];␊ |
251 | ␉␉␉␉if (drop_ssdt && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
252 | ␉␉␉␉{␊ |
253 | ␉␉␉␉␉dropoffset++;␊ |
254 | ␉␉␉␉␉continue;␊ |
255 | ␉␉␉␉}␊ |
256 | ␉␉␉␉if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
257 | ␉␉␉␉{␊ |
258 | ␉␉␉␉␉DBG("DSDT found\n");␊ |
259 | ␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
260 | ␉␉␉␉␉continue;␊ |
261 | ␉␉␉␉}␊ |
262 | ␉␉␉␉if (table[0]=='F' && table[1]=='A' && table[2]=='C' && table[3]=='P')␊ |
263 | ␉␉␉␉{␊ |
264 | ␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
265 | ␉␉␉␉␉fadt=(struct acpi_2_fadt *)rsdt_entries[i];␊ |
266 | ␊ |
267 | ␉␉␉␉␉DBG("FADT found @%x, Length %d\n",fadt, fadt->Length);␊ |
268 | ␊ |
269 | ␉␉␉␉␉if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000)␊ |
270 | ␉␉␉␉␉{␊ |
271 | ␉␉␉␉␉␉printf("FADT incorrect. Not modified\n");␊ |
272 | ␉␉␉␉␉␉continue;␊ |
273 | ␉␉␉␉␉}␊ |
274 | ␉␉␉␉␉␊ |
275 | ␉␉␉␉␉fadt_mod = patch_fadt(fadt, new_dsdt);␊ |
276 | ␊ |
277 | ␉␉␉␉␉rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
278 | ␉␉␉␉␉continue;␊ |
279 | ␉␉␉␉}␊ |
280 | ␉␉␉}␊ |
281 | ␉␉␉DBG("\n");␊ |
282 | ␊ |
283 | ␉␉␉// Correct the checksum of RSDT␊ |
284 | ␉␉␉rsdt_mod->Length-=4*dropoffset;␊ |
285 | ␊ |
286 | ␉␉␉DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum);␊ |
287 | ␊ |
288 | ␉␉␉rsdt_mod->Checksum=0;␊ |
289 | ␉␉␉rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length);␊ |
290 | ␊ |
291 | ␉␉␉DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);␊ |
292 | ␉␉}␊ |
293 | ␉␉else␊ |
294 | ␉␉{␊ |
295 | ␉␉␉rsdp_mod->RsdtAddress=0;␊ |
296 | ␉␉␉printf("RSDT not found or RSDT incorrect\n");␊ |
297 | ␉␉}␊ |
298 | ␊ |
299 | ␉␉if (version)␊ |
300 | ␉␉{␊ |
301 | ␉␉␉struct acpi_2_xsdt *xsdt, *xsdt_mod;␊ |
302 | ␊ |
303 | ␉␉␉// FIXME: handle 64-bit address correctly␊ |
304 | ␊ |
305 | ␉␉␉xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);␊ |
306 | ␉␉␉DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress,␊ |
307 | ␉␉␉␉␉xsdt->Length);␊ |
308 | ␉␉␉if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000)␊ |
309 | ␉␉␉{␊ |
310 | ␉␉␉␉uint64_t *xsdt_entries;␊ |
311 | ␉␉␉␉int xsdt_entries_num, i;␊ |
312 | ␉␉␉␉int dropoffset=0;␊ |
313 | ␉␉␉␉␊ |
314 | ␉␉␉␉xsdt_mod=(struct acpi_2_xsdt*)AllocateKernelMemory(xsdt->Length); ␊ |
315 | ␉␉␉␉memcpy(xsdt_mod, xsdt, xsdt->Length);␊ |
316 | ␉␉␉␉rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;␊ |
317 | ␉␉␉␉xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;␊ |
318 | ␉␉␉␉xsdt_entries=(uint64_t *)(xsdt_mod+1);␊ |
319 | ␉␉␉␉for (i=0;i<xsdt_entries_num;i++)␊ |
320 | ␉␉␉␉{␊ |
321 | ␉␉␉␉␉char *table=(char *)((uint32_t)(xsdt_entries[i]));␊ |
322 | ␉␉␉␉␉if (!table)␊ |
323 | ␉␉␉␉␉␉continue;␊ |
324 | ␉␉␉␉␉xsdt_entries[i-dropoffset]=xsdt_entries[i];␊ |
325 | ␉␉␉␉␉if (drop_ssdt && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
326 | ␉␉␉␉␉{␊ |
327 | ␉␉␉␉␉␉dropoffset++;␊ |
328 | ␉␉␉␉␉␉continue;␊ |
329 | ␉␉␉␉␉}␉␉␉␉␉␊ |
330 | ␉␉␉␉␉if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')␊ |
331 | ␉␉␉␉␉{␊ |
332 | ␉␉␉␉␉␉DBG("DSDT found\n");␊ |
333 | ␊ |
334 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;␊ |
335 | ␊ |
336 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
337 | ␉␉␉␉␉␉␊ |
338 | ␉␉␉␉␉␉continue;␊ |
339 | ␉␉␉␉␉}␊ |
340 | ␉␉␉␉␉if (table[0]=='F' && table[1]=='A' && table[2]=='C' && table[3]=='P')␊ |
341 | ␉␉␉␉␉{␊ |
342 | ␉␉␉␉␉␉struct acpi_2_fadt *fadt, *fadt_mod;␊ |
343 | ␉␉␉␉␉␉fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i];␊ |
344 | ␊ |
345 | ␉␉␉␉␉␉DBG("FADT found @%x,%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt, ␊ |
346 | ␉␉␉␉␉␉␉␉ fadt->Length);␊ |
347 | ␊ |
348 | ␉␉␉␉␉␉if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000)␊ |
349 | ␉␉␉␉␉␉{␊ |
350 | ␉␉␉␉␉␉␉printf("FADT incorrect or after 4GB. Dropping XSDT\n");␊ |
351 | ␉␉␉␉␉␉␉goto drop_xsdt;␊ |
352 | ␉␉␉␉␉␉}␊ |
353 | ␊ |
354 | ␉␉␉␉␉␉fadt_mod = patch_fadt(fadt, new_dsdt);␊ |
355 | ␊ |
356 | ␉␉␉␉␉␉xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;␊ |
357 | ␊ |
358 | ␉␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
359 | ␊ |
360 | ␉␉␉␉␉␉continue;␊ |
361 | ␉␉␉␉␉}␊ |
362 | ␊ |
363 | ␉␉␉␉␉DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);␊ |
364 | ␊ |
365 | ␉␉␉␉}␊ |
366 | ␊ |
367 | ␉␉␉␉// Correct the checksum of XSDT␊ |
368 | ␉␉␉␉xsdt_mod->Length-=8*dropoffset;␊ |
369 | ␉␉␉␉xsdt_mod->Checksum=0;␊ |
370 | ␉␉␉␉xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);␊ |
371 | ␉␉␉}␊ |
372 | ␉␉␉else␊ |
373 | ␉␉␉{␊ |
374 | ␉␉␉drop_xsdt:␊ |
375 | ␊ |
376 | ␉␉␉␉DBG("About to drop XSDT\n");␊ |
377 | ␊ |
378 | ␉␉␉␉/*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT. ␊ |
379 | ␉␉␉␉ * A Better strategy would be to generate␊ |
380 | ␉␉␉␉ */␊ |
381 | ␊ |
382 | ␉␉␉␉rsdp_mod->XsdtAddress=0xffffffffffffffffLL;␊ |
383 | ␉␉␉␉printf("XSDT not found or XSDT incorrect\n");␊ |
384 | ␉␉␉}␊ |
385 | ␉␉}␊ |
386 | ␊ |
387 | ␉␉// Correct the checksum of RSDP ␊ |
388 | ␊ |
389 | ␉␉DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum);␊ |
390 | ␊ |
391 | ␉␉rsdp_mod->Checksum=0;␊ |
392 | ␉␉rsdp_mod->Checksum=256-checksum8(rsdp_mod,20);␊ |
393 | ␊ |
394 | ␉␉DBG("New checksum %d\n", rsdp_mod->Checksum);␊ |
395 | ␊ |
396 | ␉␉if (version)␊ |
397 | ␉␉{␊ |
398 | ␉␉␉DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum);␊ |
399 | ␊ |
400 | ␉␉␉rsdp_mod->ExtendedChecksum=0;␊ |
401 | ␉␉␉rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length);␊ |
402 | ␊ |
403 | ␉␉␉DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum);␊ |
404 | ␊ |
405 | ␉␉}␊ |
406 | ␉␉␊ |
407 | ␉␉verbose("Patched ACPI version %d DSDT\n", version+1);␊ |
408 | ␉␉if (version)␊ |
409 | ␉␉{␊ |
410 | ␉␉␉acpi20_p = (uint32_t)rsdp_mod;␊ |
411 | ␉␉␉addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");␊ |
412 | ␉␉}␊ |
413 | ␉␉else␊ |
414 | ␉␉{␊ |
415 | ␉␉␉acpi10_p = (uint32_t)rsdp_mod;␊ |
416 | ␉␉␉addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");␊ |
417 | ␉␉}␊ |
418 | ␉}␊ |
419 | ␉#if DEBUG_DSDT␊ |
420 | ␉printf("Press a key to continue... (DEBUG_DSDT)\n");␊ |
421 | ␉getc();␊ |
422 | ␉#endif␊ |
423 | ␉return 1;␊ |
424 | }␊ |
425 | |