MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / FixHPET

Function FixHPET

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:2341–2400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2339}
2340
2341UINT32 FixHPET (UINT8* dsdt, UINT32 len)
2342{
2343 UINT32 i, j;
2344 UINT32 adr = 0;
2345 UINT32 hpetsize = 0;
2346 INT32 sizeoffset = sizeof(hpet0);
2347 INT32 shift = 0;
2348 UINT32 LPCBADR = 0, LPCBSIZE = 0;
2349
2350 MsgLog("Start HPET Fix\n");
2351 //have to find LPC
2352 for (j=0x20; len >= 10 && j < len - 10; j++) {
2353 if (CmpAdr(dsdt, j, 0x001F0000)) {
2354 LPCBADR = devFind(dsdt, j);
2355 if (!LPCBADR) {
2356 continue;
2357 }
2358 LPCBSIZE = get_size(dsdt, LPCBADR);
2359 } // End LPCB find
2360 }
2361 if (!LPCBSIZE) {
2362 MsgLog("No LPCB device! Patch HPET will not be applied\n");
2363 return len;
2364 }
2365 for (j=20; j<len; j++) {
2366 // Find Device HPET // PNP0103
2367 if (CmpPNP(dsdt, j, 0x0103)) {
2368 adr = devFind(dsdt, j);
2369 if (!adr) {
2370 continue;
2371 }
2372 hpetsize = get_size(dsdt, adr);
2373 if (hpetsize) {
2374 break;
2375 }
2376 } // End HPET
2377 }
2378
2379 if (hpetsize) {
2380 i = adr - 2; //pointer to device HPET
2381 j = hpetsize + 2;
2382 sizeoffset -= j;
2383 len = move_data(i, dsdt, len, sizeoffset);
2384 // add new HPET code
2385 CopyMem(dsdt+i, hpet0, sizeof(hpet0));
2386 len = CorrectOuters(dsdt, len, i - 3, sizeoffset); //assume LPC may be outer or not
2387 } else {
2388 i = LPCBADR + LPCBSIZE; //pointer to the end of LPC
2389 //in this case LPC becomes Outer device
2390 shift = write_size(LPCBADR, dsdt, len, sizeoffset); //correct LPC
2391 sizeoffset += shift;
2392 len += shift;
2393 i += shift;
2394 len = move_data(i, dsdt, len, sizeof(hpet0));
2395 // add new HPET code
2396 CopyMem(dsdt + i, hpet0, sizeof(hpet0));
2397 len = CorrectOuters(dsdt, len, LPCBADR - 3, sizeoffset); //outer for LPC
2398 }

Callers 1

FixBiosDsdtFunction · 0.85

Calls 8

CmpAdrFunction · 0.85
devFindFunction · 0.85
get_sizeFunction · 0.85
CmpPNPFunction · 0.85
move_dataFunction · 0.85
CorrectOutersFunction · 0.85
write_sizeFunction · 0.85
CopyMemFunction · 0.50

Tested by

no test coverage detected