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

Function FIXLPCB

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:2404–2489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2402UINT8 dataLPC[] = {0x18, 0x3A, 0x00, 0x00};
2403
2404UINT32 FIXLPCB (UINT8 *dsdt, UINT32 len)
2405{
2406 UINT32 i, j, k;
2407 INT32 sizeoffset, shift = 0, Size;
2408 UINT32 LPCBADR = 0, LPCBSIZE = 0, LPCBADR1 = 0;
2409 AML_CHUNK* root;
2410 AML_CHUNK* met;
2411 AML_CHUNK* pack;
2412 CHAR8 *lpcb;
2413 CHAR8 NameCard[32];
2414
2415
2416 DBG("Start LPCB Fix\n");
2417 //DBG("len = 0x%08X\n", len);
2418 //have to find LPC
2419 for (j=0x20; len >= 10 && j < len - 10; j++) {
2420 if (CmpAdr(dsdt, j, 0x001F0000))
2421 {
2422 LPCBADR = devFind(dsdt, j);
2423 if (!LPCBADR) {
2424 continue;
2425 }
2426 LPCBSIZE = get_size(dsdt, LPCBADR);
2427 device_name[3] = (__typeof_am__(device_name[3]))AllocateZeroPool(5);
2428 CopyMem(device_name[3], dsdt + j, 4);
2429 MsgLog("found LPCB device NAME(_ADR,0x001F0000) at %X And Name is %s\n", j,
2430 device_name[3]);
2431
2432 if (LPCBSIZE) break;
2433 } // End LPCB find
2434 }
2435 if (!LPCBSIZE) return len;
2436 LPCBADR1 = LPCBADR + LPCBSIZE;
2437 ReplaceName(dsdt, len, device_name[3], "LPCB");
2438
2439 if (LPCBADR) { // bridge or device
2440 i = LPCBADR;
2441 Size = get_size(dsdt, i);
2442 k = FindMethod(dsdt + i, Size, "_DSM");
2443 if (k != 0) {
2444 k += i;
2445 Size = get_size(dsdt, k);
2446 if(!Size) {
2447 return len;
2448 }
2449 sizeoffset = - 1 - Size;
2450 len = move_data(k - 1, dsdt, len, sizeoffset);
2451 //to correct outers we have to calculate offset
2452 len = CorrectOuters(dsdt, len, k - 2, sizeoffset);
2453 MsgLog("_DSM in LPC already exists, dropped\n");
2454 }
2455 }
2456
2457 root = aml_create_node(NULL);
2458 // add Method(_DSM,4,NotSerialized) for LPC
2459 met = aml_add_method(root, "_DSM", 4);
2460 met = aml_add_store(met);
2461 pack = aml_add_package(met);

Callers 1

FixBiosDsdtFunction · 0.85

Calls 15

CmpAdrFunction · 0.85
devFindFunction · 0.85
get_sizeFunction · 0.85
ReplaceNameFunction · 0.85
FindMethodFunction · 0.85
move_dataFunction · 0.85
CorrectOutersFunction · 0.85
aml_create_nodeFunction · 0.85
aml_add_methodFunction · 0.85
aml_add_storeFunction · 0.85
aml_add_packageFunction · 0.85
aml_add_stringFunction · 0.85

Tested by

no test coverage detected