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

Function FIXSBUS

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:3336–3419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3334}
3335
3336UINT32 FIXSBUS (UINT8 *dsdt, UINT32 len)
3337{
3338 UINT32 i, k;
3339 UINT32 SBUSADR=0, Size=0;
3340 UINT32 PCIADR, PCISIZE = 0;
3341 INT32 sizeoffset;
3342 PCIADR = GetPciDevice(dsdt, len);
3343 if (PCIADR) {
3344 PCISIZE = get_size(dsdt, PCIADR);
3345 }
3346 if (!PCISIZE) {
3347// DBG("wrong PCI0 address, patch SBUS will not be applied\n");
3348 return len;
3349 }
3350 DBG("Start SBUS Fix PCI=%X len=%X\n", PCIADR, len);
3351
3352 // Find Device SBUS
3353 if (SBUSADR1) {
3354 for (i=0x20; len >= 10 && i < len - 10; i++) {
3355 if (CmpAdr(dsdt, i, SBUSADR1))
3356 {
3357 SBUSADR = devFind(dsdt, i);
3358 if (SBUSADR) {
3359 DBG("device (SBUS) found at %X\n", SBUSADR);
3360 break;
3361 }
3362 } // end SBUS
3363 }
3364 }
3365
3366 if (SBUSADR) { // bridge or device
3367 i = SBUSADR;
3368 Size = get_size(dsdt, i);
3369 k = FindMethod(dsdt + i, Size, "_DSM");
3370 if (k != 0) {
3371 k += i;
3372 Size = get_size(dsdt, k);
3373 sizeoffset = - 1 - Size;
3374 len = move_data(k - 1, dsdt, len, sizeoffset);
3375 len = CorrectOuters(dsdt, len, k - 2, sizeoffset);
3376 DBG("_DSM in SBUS already exists, dropped\n");
3377 }
3378 Size = get_size(dsdt, SBUSADR);
3379 if (ReplaceName(dsdt + SBUSADR, Size, NULL, "BUS0") < 0) {
3380 DBG("BUS0 already exists, patch SBUS will not be applied\n");
3381 return len;
3382 }
3383 }
3384
3385 if (SBUSADR)
3386 sizeoffset = sizeof(bus0);
3387 else
3388 sizeoffset = sizeof(sbus1);
3389
3390// DBG("SBUS address %X code size = 0x%08X\n", SBUSADR, sizeoffset);
3391
3392 if (SBUSADR) {
3393 // move data to back for add sbus

Callers 1

FixBiosDsdtFunction · 0.85

Calls 10

GetPciDeviceFunction · 0.85
get_sizeFunction · 0.85
CmpAdrFunction · 0.85
devFindFunction · 0.85
FindMethodFunction · 0.85
move_dataFunction · 0.85
CorrectOutersFunction · 0.85
ReplaceNameFunction · 0.85
write_sizeFunction · 0.85
CopyMemFunction · 0.50

Tested by

no test coverage detected