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

Function FixRTC

rEFIt_UEFI/Platform/FixBiosDsdt.cpp:2089–2177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2087}
2088
2089UINT32 FixRTC (UINT8 *dsdt, UINT32 len)
2090{
2091 UINT32 i, j, k, l;
2092 UINT32 IOADR = 0;
2093 UINT32 RESADR = 0;
2094 UINT32 adr = 0;
2095 UINT32 rtcsize = 0;
2096 INT32 shift, sizeoffset = 0;
2097
2098 DBG("Start RTC Fix\n");
2099
2100 for (j=20; j<len; j++) {
2101 // Find Device RTC // Name (_HID, EisaId ("PNP0B00")) for RTC
2102 if (CmpPNP(dsdt, j, 0x0B00))
2103 {
2104 adr = devFind(dsdt, j);
2105 if (!adr) {
2106 continue;
2107 }
2108 rtcsize = get_size(dsdt, adr);
2109 if (rtcsize) {
2110 break;
2111 }
2112 } // End RTC
2113 }
2114
2115 if (!rtcsize) {
2116 DBG("BUG! rtcsize not found\n");
2117 return len;
2118 }
2119
2120 for (i=adr+4; i<adr+rtcsize; i++) {
2121 // IO (Decode16, ((0x0070, 0x0070)) =>> find this
2122 if (dsdt[i] == 0x70 && dsdt[i+1] == 0x00 && dsdt[i+2] == 0x70 && dsdt[i+3] == 0x00) {
2123 if (dsdt[i+5] == 0x08 && gSettings.Rtc8Allowed) {
2124 MsgLog("CMOS reset not will be, patch length is not needed\n");
2125 } else {
2126 // First Fix RTC CMOS Reset Problem
2127 if (dsdt[i+4] != 0x00 || dsdt[i+5] != 0x02) { //dsdt[j+4] => Alignment dsdt[j+5] => Length
2128 dsdt[i+4] = 0x00; //Alignment
2129 dsdt[i+5] = 0x02; //Length
2130 MsgLog("found RTC Length not match, Maybe will cause CMOS reset, will patch it.\n");
2131 }
2132 }
2133 for (l = adr + 4; l < i; l++) {
2134 if (dsdt[l] == 0x11 && dsdt[l+2] == 0x0A) {
2135 RESADR = l + 1; //Format 11, size, 0A, size-3,... 79, 00
2136 IOADR = l + 3; //IO (Decode16 ==> 47, 01
2137 }
2138 }
2139 break;
2140 }
2141 if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
2142 break; //end of RTC device and begin of new Device()
2143 }
2144 }
2145
2146 for (l = adr + 4; l < adr + rtcsize; l++) {

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