| 2087 | } |
| 2088 | |
| 2089 | UINT32 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++) { |
no test coverage detected