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

Function FixTMR

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:2180–2254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2178
2179
2180UINT32 FixTMR (UINT8 *dsdt, UINT32 len)
2181{
2182 UINT32 i, j, k;
2183 UINT32 IOADR = 0;
2184 UINT32 RESADR = 0;
2185 UINT32 adr = 0;
2186 UINT32 TMRADR, tmrsize = 0;
2187 INT32 offset = 0, sizeoffset = 0;
2188 DBG("Start TMR Fix\n");
2189
2190 for (j=20; j<len; j++) {
2191 // Find Device TMR PNP0100
2192 if (CmpPNP(dsdt, j, 0x0100)) {
2193 TMRADR = devFind(dsdt, j);
2194 adr = TMRADR;
2195 if (!adr) {
2196 continue;
2197 }
2198 tmrsize = get_size(dsdt, adr);
2199 // DBG("TMR size=%X at %X\n", tmrsize, adr);
2200 if (tmrsize) {
2201 break;
2202 }
2203 } // End TMR
2204 }
2205 if (!adr) {
2206 DBG("TMR device not found!\n");
2207 return len;
2208 }
2209
2210
2211 // Fix TMR
2212 // Find Name(_CRS, ResourceTemplate ()) find ResourceTemplate 0x11
2213 j = 0;
2214 for (i=adr; i<adr+tmrsize; i++) { //until next Device()
2215 if (dsdt[i] == 0x11 && dsdt[i+2] == 0x0A) {
2216 RESADR = i+1; //Format 11, size, 0A, size-3,... 79, 00
2217 IOADR = i+3; //IO (Decode16 ==> 47, 01
2218 j = get_size(dsdt, IOADR);
2219 }
2220
2221 if (dsdt[i] == 0x22) { // Had IRQNoFlag
2222 for (k=i; k<i+j; k++) {
2223 if ((dsdt[k] == 0x79) || ((dsdt[k] == 0x47) && (dsdt[k+1] == 0x01)) ||
2224 ((dsdt[k] == 0x86) && (dsdt[k+1] == 0x09))) {
2225 sizeoffset = i - k;
2226 //DBG("found TMR had IRQNoFlag will move %d bytes\n", sizeoffset);
2227 // First move offset byte remove IRQNoFlag
2228 len = move_data(i, dsdt, len, sizeoffset);
2229 // Fix IO (Decode16, size and _CRS size
2230 dsdt[RESADR] += (UINT8)sizeoffset;
2231 dsdt[IOADR] += (UINT8)sizeoffset;
2232 break;
2233 }
2234 }
2235 }
2236
2237 // if offset > 0 Fix Device TMR 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