Chameleon

Chameleon Commit Details

Date:2010-01-17 14:27:39 (9 years 9 months ago)
Author:JrCs
Commit:17
Parents: 16
Message:New patch_fadt function
Changes:
M/branches/JrCs/i386/libsaio/dsdt_patcher.c

File differences

branches/JrCs/i386/libsaio/dsdt_patcher.c
118118
119119
120120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
121158
122159
123160
......
235272
236273
237274
238
239
275
240276
241
242
243
244
245
246
247
248
249
250
251
252
253
254277
255278
256279
257280
281
258282
259283
260284
......
326350
327351
328352
329
330
331353
332
333
354
334355
335
336
337
338
339
340
341
342
343
344
345356
346357
347358
return NULL;
}
struct acpi_2_fadt *
patch_fadt(struct acpi_2_fadt *fadt, void *new_dsdt)
{
struct acpi_2_fadt *fadt_mod;
BOOL fadt_rev2_needed = NO;
// Allocate new fadt table
if (fadt->Length < 0x84 && fadt_rev2_needed)
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = 0x84;
fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)
}
else
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
// Patch DSDT Address
DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT);
fadt_mod->DSDT=(uint32_t)new_dsdt;
if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)
fadt_mod->X_DSDT=(uint32_t)new_dsdt;
DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
// Correct the checksum
fadt_mod->Checksum=0;
fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);
return fadt_mod;
}
/* Setup ACPI without replacing DSDT. */
int setupAcpiNoMod()
{
continue;
}
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod = patch_fadt(fadt, new_dsdt);
// Patch DSDT Address
DBG("Old DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
fadt_mod->DSDT=(uint32_t)new_dsdt;
if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)
fadt_mod->X_DSDT=(uint32_t)new_dsdt;
DBG("New DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
// Correct the checksum
fadt_mod->Checksum=0;
fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);
rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
continue;
}
}
DBG("\n");
// Correct the checksum of RSDT
rsdt_mod->Length-=4*dropoffset;
printf("FADT incorrect or after 4GB. Dropping XSDT\n");
goto drop_xsdt;
}
fadt_mod=(struct acpi_2_fadt*)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
// Patch DSDT Address
DBG("Old DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
fadt_mod = patch_fadt(fadt, new_dsdt);
fadt_mod->DSDT=(uint32_t)new_dsdt;
if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)
fadt_mod->X_DSDT=(uint32_t)new_dsdt;
DBG("New DSDT @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
// Correct the checksum
fadt_mod->Checksum=0;
fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length);
xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);

Archive Download the corresponding diff file

Revision: 17