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

Function FixPIC

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:2256–2339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2254}
2255
2256UINT32 FixPIC (UINT8 *dsdt, UINT32 len)
2257{
2258 UINT32 i, j, k;
2259 UINT32 IOADR = 0;
2260 UINT32 RESADR = 0;
2261 UINT32 adr = 0;
2262 INT32 offset = 0, sizeoffset = 0;
2263 UINT32 PICADR, picsize = 0;
2264
2265 DBG("Start PIC Fix\n");
2266 for (j=20; j<len; j++) {
2267 // Find Device PIC or IPIC PNP0000
2268 if (CmpPNP(dsdt, j, 0x0000)) {
2269 PICADR = devFind(dsdt, j);
2270 adr = PICADR;
2271 if (!adr) {
2272 continue;
2273 }
2274 picsize = get_size(dsdt, adr);
2275 DBG("PIC size=%X at %X\n", picsize, adr);
2276 if (picsize) {
2277 break;
2278 }
2279 } // End PIC
2280 }
2281 if (!picsize) {
2282 DBG("IPIC not found\n");
2283 return len;
2284 }
2285
2286 for (i=adr; i<adr+picsize; i++)
2287 {
2288 if (dsdt[i] == 0x11 && dsdt[i+2] == 0x0A) {
2289 RESADR = i+1; //Format 11, size, 0A, size-3,... 79, 00
2290 IOADR = i+3; //IO (Decode16 ==> 47, 01
2291 continue;
2292 } else {
2293 // or 11 41 09 0A 8D 47 01 20 00 -> size=0x91 size-4=0x89
2294 if ((dsdt[i] == 0x11) &&
2295 (dsdt[i+3] == 0x0A) &&
2296 ((dsdt[i+1] & 0xF0) == 0x40)) {
2297 RESADR = i+1; //Format 11, size1, size2, 0A, size-4,... 79, 00
2298 IOADR = i+4; //IO (Decode16 ==> 47, 01
2299 DBG("found CRS at %X size %hhX\n", RESADR, dsdt[IOADR]);
2300 continue;
2301 }
2302 }
2303
2304 if (dsdt[i] == 0x22) { // Had IRQNoFlag
2305 for (k = i; k < RESADR + dsdt[IOADR] + 4; k++) {
2306 if ((dsdt[k] == 0x79) ||
2307 ((dsdt[k] == 0x47) && (dsdt[k+1] == 0x01)) ||
2308 ((dsdt[k] == 0x86) && (dsdt[k+1] == 0x09))) {
2309 sizeoffset = i - k;
2310 MsgLog("found PIC had IRQNoFlag will move %d bytes\n", sizeoffset);
2311 // First move offset byte remove IRQNoFlag
2312 len = move_data(i, dsdt, len, sizeoffset);
2313 // Fix IO (Decode16, size and _CRS size

Callers 1

FixBiosDsdtFunction · 0.85

Calls 6

CmpPNPFunction · 0.85
devFindFunction · 0.85
get_sizeFunction · 0.85
move_dataFunction · 0.85
write_sizeFunction · 0.85
CorrectOutersFunction · 0.85

Tested by

no test coverage detected