Advertisement
Guest User

Untitled

a guest
May 10th, 2022
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 78.55 KB | None | 0 0
  1. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/acpisym: obj
  2. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: MSG00001.bin
  3. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: acpilog.h
  4. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: acpilog.rc
  5. diff --strip-trailing-cr -ur ./driver/amlinew/amlipriv.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlipriv.h"
  6. --- ./driver/amlinew/amlipriv.h 2002-09-02 18:22:22.000000000 +0500
  7. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlipriv.h" 2022-04-16 06:47:51.856445300 +0500
  8. @@ -285,6 +285,7 @@
  9. #define AMLISTA_CONTINUE 0x00008003
  10. #define AMLISTA_PENDING 0x00008004
  11. #define AMLISTA_TIMEOUT 0x00008005
  12. +#define AMLISTA_CONTINUEOP 0x00008006
  13.  
  14. // Global AMLI flags
  15. #define AMLIF_LOCKED 0x00000001
  16. @@ -331,6 +332,7 @@
  17. #define ARGOBJ_BASICDATA 'D' //INTDATA,STRDATA,BUFFDATA
  18. #define ARGOBJ_COMPLEXDATA 'C' //BUFFDATA,PKGDATA
  19. #define ARGOBJ_REFERENCE 'R' //OBJALIAS,DATAALIAS,BUFFFIELD
  20. +#define ARGOBJ_STRBUFDATA 'T' //OBJTYPE_STRDATA/OBJTYPE_BUFFDATA
  21.  
  22. #define MAX_BYTE 0xff
  23. #define MAX_WORD 0xffff
  24. @@ -368,7 +370,8 @@
  25. /*** Type and Structure definitions
  26. */
  27.  
  28. -typedef NTSTATUS (LOCAL *PFNOP)(PFRAME, PPNSOBJ);
  29. +//typedef NTSTATUS (LOCAL *PFNOP)(PFRAME, PPNSOBJ);
  30. +typedef NTSTATUS (LOCAL *PFNOP)(PCTXT, PTERM);
  31.  
  32. typedef struct _amlterm
  33. {
  34. diff --strip-trailing-cr -ur ./driver/amlinew/amlitest.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlitest.c"
  35. --- ./driver/amlinew/amlitest.c 2002-09-02 18:22:22.000000000 +0500
  36. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlitest.c" 2022-04-16 06:47:51.870117100 +0500
  37. @@ -52,22 +52,24 @@
  38. PCCHAR DebugMessage,
  39. ...)
  40. {
  41. + int index;
  42. va_list ap;
  43. va_start(ap, DebugMessage);
  44.  
  45. -
  46. if(DebugPrintLevel & AmliTestDebugFlags)
  47. - {
  48. -
  49. -
  50. -
  51. - if(_vsnprintf(AmliTestDebugBuffer,
  52. + {
  53. + index = _vsnprintf(AmliTestDebugBuffer,
  54. 200,
  55. DebugMessage,
  56. - ap) == -1)
  57. + ap);
  58. + // SP3
  59. + if(index == -1)
  60. {
  61. - AmliTestDebugBuffer[199] = '\0';
  62. + AmliTestDebugBuffer[0] = '\0';
  63. + } else {
  64. + AmliTestDebugBuffer[index] = '\0';
  65. }
  66. + // SP3
  67.  
  68. DbgPrint(AmliTestDebugBuffer);
  69. }
  70. diff --strip-trailing-cr -ur ./driver/amlinew/data.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/data.c"
  71. --- ./driver/amlinew/data.c 2002-09-02 18:22:22.000000000 +0500
  72. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/data.c" 2022-04-16 06:47:51.880859300 +0500
  73. @@ -188,6 +188,23 @@
  74. atToBCD = {"ToBCD", OP_TOBCD, "CS", C2, 0, NULL, 0, ExprOp1},
  75. atWait = {"Wait", OP_WAIT, "SC", C2, 0, NULL, 0, Wait},
  76. atXOr = {"XOr", OP_XOR, "CCS", C2, 0, NULL, 0, ExprOp2},
  77. +
  78. + // ACPI 2.0
  79. + atToBuffer = {"ToBuffer", OP_TOBUFFER, "CS", C2, 0, NULL, 0, ToBuffer},
  80. + atToDecString = {"ToDecimalString", OP_TODECSTRING, "CS", C2, 0, NULL, 0, ToDecimalString},
  81. + atToHexString = {"ToHexString", OP_TOHEXSTRING, "CS", C2, 0, NULL, 0, ToHexString},
  82. + atToInteger = {"ToInteger", OP_TOINTEGER, "CS", C2, 0, NULL, 0, ToInteger},
  83. + atQWordField = {"CreateQWordField", OP_QWORDFIELD, "CCN", OB, 0, NULL, 0, CreateQWordField},
  84. + atConcatRes = {"ConcatenateResTemplate", OP_CONCATRESTMPL, "CCS", C2, 0, NULL, 0, ConcatenateResTemplate},
  85. + atMod = {"Mod", OP_MOD, "CCS", C2, 0, NULL, 0, ExprOp2},
  86. + atToString = {"ToString", OP_TOSTRING, "CCS", C2, 0, NULL, 0, ToString},
  87. + atCopyObject = {"CopyObject", OP_COPYOBJECT, "CS", C2, 0, NULL, 0, CopyObject},
  88. + atMid = {"Mid", OP_MID, "CCCS", C2, 0, NULL, 0, MidString},
  89. + atContinue = {"Continue", OP_CONTINUE, NULL, C1, 0, NULL, 0, Continue},
  90. + atTimer = {"Timer", OP_TIMER , NULL, C2, 0, NULL, 0, Timer},
  91. + // OP_QWORD=0xE - see atDataObj
  92. +
  93. +
  94. //
  95. // Misc. Opcodes
  96. //
  97. @@ -206,7 +223,7 @@
  98. //0x08 0x09 0x0a 0x0b
  99. &atName, NULL, &atDataObj, &atDataObj,
  100. //0x0c 0x0d 0x0e 0x0f
  101. - &atDataObj, &atString, NULL, NULL,
  102. + &atDataObj, &atString, &atDataObj, NULL,
  103. //0x10 0x11 0x12 0x13
  104. &atScope, &atBuffer, &atPackage, NULL,
  105. //0x14 0x15 0x16 0x17
  106. @@ -266,19 +283,19 @@
  107. //0x80 0x81 0x82 0x83
  108. &atNot, &atFindSetLBit, &atFindSetRBit, &atDerefOf,
  109. //0x84 0x85 0x86 0x87
  110. - NULL, NULL, &atNotify, &atSizeOf,
  111. + &atConcatRes, &atMod, &atNotify, &atSizeOf,
  112. //0x88 0x89 0x8a 0x8b
  113. &atIndex, &atMatch, &atDWordField, &atWordField,
  114. //0x8c 0x8d 0x8e 0x8f
  115. - &atByteField, &atBitField, &atObjType, NULL,
  116. + &atByteField, &atBitField, &atObjType, &atQWordField,
  117. //0x90 0x91 0x92 0x93
  118. &atLAnd, &atLOr, &atLNot, &atLEq,
  119. //0x94 0x95 0x96 0x97
  120. - &atLG, &atLL, NULL, NULL,
  121. + &atLG, &atLL, &atToBuffer, &atToDecString,
  122. //0x98 0x99 0x9a 0x9b
  123. - NULL, NULL, NULL, NULL,
  124. + &atToHexString, &atToInteger, NULL, NULL,
  125. //0x9c 0x9d 0x9e 0x9f
  126. - NULL, NULL, NULL, NULL,
  127. + &atToString, &atCopyObject, &atMid, &atContinue,
  128. //0xa0 0xa1 0xa2 0xa3
  129. &atIf, &atElse, &atWhile, &atNOP,
  130. //0xa4 0xa5 0xa6 0xa7
  131. @@ -349,6 +366,7 @@
  132. EXOP_REVISION, &atDataObj,
  133. EXOP_DEBUG, &atDebugObj,
  134. EXOP_FATAL, &atFatal,
  135. + EXOP_TIMER, &atTimer,
  136. EXOP_OPREGION, &atOpRegion,
  137. EXOP_FIELD, &atField,
  138. EXOP_DEVICE, &atDevice,
  139. diff --strip-trailing-cr -ur ./driver/amlinew/misc.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/misc.c"
  140. --- ./driver/amlinew/misc.c 2002-09-02 18:22:22.000000000 +0500
  141. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/misc.c" 2022-04-16 06:47:51.891601500 +0500
  142. @@ -1327,6 +1327,17 @@
  143. }
  144. break;
  145.  
  146. + case ARGOBJ_STRBUFDATA:
  147. + if ((pArgs[i].dwDataType != OBJTYPE_STRDATA) &&
  148. + (pArgs[i].dwDataType != OBJTYPE_BUFFDATA))
  149. + {
  150. + rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  151. + ("ValidateArgTypes: expected Arg%d to be type str/buff (Type=%s)",
  152. + i,
  153. + GetObjectTypeName(pArgs[i].dwDataType)));
  154. + }
  155. + break;
  156. +
  157. default:
  158. rc = AMLI_LOGERR(AMLIERR_ASSERT_FAILED,
  159. ("ValidateArgTypes: internal error (invalid type - %c)",
  160. diff --strip-trailing-cr -ur ./driver/amlinew/namedobj.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/namedobj.c"
  161. --- ./driver/amlinew/namedobj.c 2002-09-02 18:22:22.000000000 +0500
  162. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/namedobj.c" 2022-05-11 01:54:41.953125000 +0500
  163. @@ -344,6 +344,7 @@
  164. {
  165. TRACENAME("DEVICE")
  166. NTSTATUS rc = STATUS_SUCCESS;
  167. + PUCHAR NextOp, OneByte, TwoByte, ThreeByte, FourByte;
  168.  
  169. ENTER(2, ("Device(pctxt=%x,pbOp=%x,pterm=%x)\n",
  170. pctxt, pctxt->pbOp, pterm));
  171. @@ -361,6 +362,34 @@
  172. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, NULL, pterm->pnsObj,
  173. pctxt->powner, pctxt->pheapCurrent, pterm->pdataResult);
  174. }
  175. + else
  176. + if (rc == AMLIERR_OBJ_ALREADY_EXIST) {
  177. + // Doubled device definition workaround, change OpCode pointer to next object
  178. + NextOp = pctxt->pbOp; // next OP
  179. + OneByte = NextOp - 7 ; // 5B 82 (3F) NN AA MM EE
  180. + TwoByte = NextOp - 8 ; // 5B 82 (4F L2) NN AA MM EE
  181. + ThreeByte = NextOp - 9 ; // 5B 82 (8F L2 L3) NN AA MM EE
  182. + FourByte = NextOp - 10 ; // 5B 82 (CF L3 L3 L4) NN AA MM EE
  183. +
  184. + rc = STATUS_SUCCESS;
  185. +
  186. + if (NextOp) { // next OP exist
  187. + if (OneByte[0] == 0x5B && OneByte[1] == 0x82) { // 0x5B 0x82 Device() Opcode
  188. + pctxt->pbOp = OneByte + OneByte[2] + 2; // start + pkglength + opcodelength
  189. + } else
  190. + if (TwoByte[0] == 0x5B && TwoByte[1] == 0x82) {
  191. + pctxt->pbOp = TwoByte + (TwoByte[3] << 4) + (TwoByte[2] & 0x0F) + 2; // pkglength magic
  192. + } else
  193. + if (ThreeByte[0] == 0x5B && ThreeByte[1] == 0x82) {
  194. + pctxt->pbOp = ThreeByte + (ThreeByte[4] << (4+8)) + (ThreeByte[3] << 4) + (ThreeByte[2] & 0x0F) + 2;
  195. + } else
  196. + if (FourByte[0] == 0x5B && FourByte[1] == 0x82) {
  197. + pctxt->pbOp = FourByte + (FourByte[5] << (4+8+8)) + (FourByte[4] << (4+8)) + (FourByte[3] << 4) + (FourByte[2] & 0x0F) + 2;
  198. + }
  199. + else
  200. + rc = AMLIERR_OBJ_ALREADY_EXIST; // unknow Device() opcode coding
  201. + }
  202. + }
  203.  
  204. EXIT(2, ("Device=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  205. return rc;
  206. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: obj
  207. diff --strip-trailing-cr -ur ./driver/amlinew/object.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/object.c"
  208. --- ./driver/amlinew/object.c 2002-09-02 18:22:22.000000000 +0500
  209. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/object.c" 2022-04-16 06:47:51.904296800 +0500
  210. @@ -300,7 +300,7 @@
  211. ENTER(3, ("ReadField(pctxt=%x,pdataObj=%x,FieldDesc=%x,pdataResult=%x)\n",
  212. pctxt, pdataObj, pfd, pdataResult));
  213.  
  214. - if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_DWORD)
  215. + if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_QWORD)
  216. {
  217. PUCHAR pb;
  218. ULONG dwcb;
  219. @@ -309,11 +309,11 @@
  220. {
  221. case OBJTYPE_UNKNOWN:
  222. if (!(pfd->dwFieldFlags & FDF_BUFFER_TYPE) &&
  223. - (pfd->dwNumBits <= sizeof(ULONG)*8))
  224. + (pfd->dwNumBits <= sizeof(ULONG64)*8)) // dwNumBits = 64 for QWORD field
  225. {
  226. pdataResult->dwDataType = OBJTYPE_INTDATA;
  227. pb = (PUCHAR)&pdataResult->uipDataValue;
  228. - dwcb = sizeof(ULONG);
  229. + dwcb = sizeof(ULONG); // ULONG64 ACPI 2.0
  230. }
  231. else
  232. {
  233. @@ -341,7 +341,7 @@
  234.  
  235. case OBJTYPE_INTDATA:
  236. pb = (PUCHAR)&pdataResult->uipDataValue;
  237. - dwcb = sizeof(ULONG);
  238. + dwcb = sizeof(ULONG); // acpi 2.0: sizeof(ULONG64)
  239. break;
  240.  
  241. case OBJTYPE_STRDATA:
  242. @@ -410,14 +410,14 @@
  243. ENTER(3, ("WriteField(pctxt=%x,pdataObj=%x,FieldDesc=%x,pdataSrc=%x)\n",
  244. pctxt, pdataObj, pfd, pdataSrc));
  245.  
  246. - if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_DWORD)
  247. + if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_QWORD)
  248. {
  249. PWRFIELDLOOP pwfl;
  250.  
  251. switch (pdataSrc->dwDataType)
  252. {
  253. case OBJTYPE_INTDATA:
  254. - dwBuffSize = MIN(sizeof(ULONG), dwDataInc);
  255. + dwBuffSize = MIN(sizeof(ULONG), dwDataInc); // ULONG64 for Integer64
  256. pbBuff = (PUCHAR)&pdataSrc->uipDataValue;
  257. break;
  258.  
  259. diff --strip-trailing-cr -ur ./driver/amlinew/parser.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/parser.c"
  260. --- ./driver/amlinew/parser.c 2002-09-02 18:22:22.000000000 +0500
  261. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/parser.c" 2022-05-10 01:20:28.340820300 +0500
  262. @@ -30,7 +30,9 @@
  263. NTSTATUS LOCAL ParseScope(PCTXT pctxt, PSCOPE pscope, NTSTATUS rc)
  264. {
  265. TRACENAME("PARSESCOPE")
  266. - ULONG dwStage = ((rc == STATUS_SUCCESS) || (rc == AMLISTA_BREAK))?
  267. + ULONG dwStage = ((rc == STATUS_SUCCESS) ||
  268. + (rc == AMLISTA_BREAK) ||
  269. + (rc == AMLISTA_CONTINUEOP))?
  270. (pscope->FrameHdr.dwfFrame & FRAMEF_STAGE_MASK): 2;
  271.  
  272. ENTER(2, ("ParseScope(Stage=%d,pctxt=%p,pbOp=%p,pscope=%p,rc=%x)\n",
  273. @@ -67,9 +69,24 @@
  274. if (rc == AMLISTA_BREAK)
  275. {
  276. pctxt->pbOp = pscope->pbOpEnd;
  277. - rc = STATUS_SUCCESS;
  278. - }
  279. - else
  280. +
  281. + // SP3
  282. + pscope->pbOpRet = pscope->pbOpEnd;
  283. + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
  284. + rc = STATUS_SUCCESS;
  285. + }
  286. + // SP3
  287. + } else
  288. + if (rc == AMLISTA_CONTINUEOP)
  289. + {
  290. + pctxt->pbOp = pscope->pbOpEnd;
  291. +
  292. + // SP3
  293. + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
  294. + rc = STATUS_SUCCESS;
  295. + }
  296. + // SP3
  297. + } else
  298. {
  299. while (pctxt->pbOp < pscope->pbOpEnd)
  300. {
  301. @@ -113,7 +130,23 @@
  302. if (rc == AMLISTA_BREAK)
  303. {
  304. pctxt->pbOp = pscope->pbOpEnd;
  305. - rc = STATUS_SUCCESS;
  306. +
  307. + // SP3
  308. + pscope->pbOpRet = pscope->pbOpEnd;
  309. + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
  310. + rc = STATUS_SUCCESS;
  311. + }
  312. + // SP3
  313. + }
  314. + else if (rc == AMLISTA_CONTINUEOP)
  315. + {
  316. + pctxt->pbOp = pscope->pbOpEnd;
  317. +
  318. + // SP3
  319. + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
  320. + rc = STATUS_SUCCESS;
  321. + }
  322. + // SP3
  323. }
  324. else if ((rc == AMLISTA_PENDING) ||
  325. (&pscope->FrameHdr !=
  326. @@ -1317,6 +1350,18 @@
  327. #endif
  328. break;
  329.  
  330. + case OP_QWORD:
  331. + MEMCPY(&pdataResult->uipDataValue, *ppbOp, sizeof(ULONG)); // ignores high 4 bytes
  332. + (*ppbOp) += sizeof(ULONG64);
  333. + #ifdef DEBUGGER
  334. + if (gDebugger.dwfDebugger &
  335. + (DBGF_AMLTRACE_ON | DBGF_STEP_MODES))
  336. + {
  337. + PRINTF("0x%x", pdataResult->uipDataValue);
  338. + }
  339. + #endif
  340. + break;
  341. +
  342. default:
  343. (*ppbOp)--;
  344. if (fErrOK)
  345. @@ -1693,6 +1738,22 @@
  346. ENTER(2, ("ParseField(pctxt=%x,pbOp=%x,pnsParent=%x,FieldFlags=%x,BitPos=%x)\n",
  347. pctxt, pctxt->pbOp, pnsParent, *pdwFieldFlags, *pdwBitPos));
  348.  
  349. + // Connection Field, skip Connection() and jump to field definition
  350. + if (*pctxt->pbOp == 0x02) {
  351. + PUCHAR pbOp = pctxt->pbOp + 1;
  352. +
  353. + if (*pbOp == 0x11) { // BufferOp()
  354. + ULONG dwcbBits;
  355. + pbOp++;
  356. + dwcbBits = ParsePackageLen(&pbOp, NULL);
  357. + pctxt->pbOp += 2; // 0x02, 0x11, [Buffer]
  358. + pctxt->pbOp += dwcbBits; // Buffer len
  359. + } else { // NAMESEG
  360. + pctxt->pbOp += 1; // 0x02, NAMESEG
  361. + pctxt->pbOp += 4; // sizeof(NAMESEG)
  362. + }
  363. + }
  364. +
  365. if (*pctxt->pbOp == 0x01)
  366. {
  367. pctxt->pbOp++;
  368. diff --strip-trailing-cr -ur ./driver/amlinew/proto.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/proto.h"
  369. --- ./driver/amlinew/proto.h 2002-09-02 18:22:22.000000000 +0500
  370. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/proto.h" 2022-04-16 06:47:51.925781200 +0500
  371. @@ -150,6 +150,20 @@
  372. BOOLEAN LOCAL MatchData(ULONG dwPkgData, ULONG dwOp, ULONG dwData);
  373. NTSTATUS LOCAL OSInterface(PCTXT pctxt, PTERM pterm);
  374.  
  375. +// ACPI 2.0
  376. +NTSTATUS LOCAL ToInteger(PCTXT pctxt, PTERM pterm);
  377. +NTSTATUS LOCAL ToHexString(PCTXT pctxt, PTERM pterm);
  378. +NTSTATUS LOCAL ToDecimalString(PCTXT pctxt, PTERM pterm);
  379. +NTSTATUS LOCAL ToBuffer(PCTXT pctxt, PTERM pterm);
  380. +NTSTATUS LOCAL CreateQWordField(PCTXT pctxt, PTERM pterm);
  381. +NTSTATUS LOCAL ConcatenateResTemplate(PCTXT pctxt, PTERM pterm);
  382. +NTSTATUS LOCAL Mod(PCTXT pctxt, PTERM pterm);
  383. +NTSTATUS LOCAL ToString(PCTXT pctxt, PTERM pterm);
  384. +NTSTATUS LOCAL CopyObject(PCTXT pctxt, PTERM pterm);
  385. +NTSTATUS LOCAL MidString(PCTXT pctxt, PTERM pterm);
  386. +NTSTATUS LOCAL Continue(PCTXT pctxt, PTERM pterm);
  387. +NTSTATUS LOCAL Timer(PCTXT pctxt, PTERM pterm);
  388. +
  389. //object.c
  390. NTSTATUS LOCAL ReadObject(PCTXT pctxt, POBJDATA pdataObj, POBJDATA pdataResult);
  391. NTSTATUS LOCAL WriteObject(PCTXT pctxt, POBJDATA pdataObj, POBJDATA pdataSrc);
  392. diff --strip-trailing-cr -ur ./driver/amlinew/type1op.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type1op.c"
  393. --- ./driver/amlinew/type1op.c 2002-09-02 18:22:22.000000000 +0500
  394. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type1op.c" 2022-04-16 06:47:51.935546800 +0500
  395. @@ -581,6 +581,11 @@
  396. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, pterm->pbOpTerm,
  397. pctxt->pnsScope, pctxt->powner, pctxt->pheapCurrent,
  398. pterm->pdataResult);
  399. + // SP3
  400. + if (!rc) {
  401. + ((PFRAMEHDR)pctxt->LocalHeap.pbHeapEnd)->dwfFrame |= CALLF_ACQ_MUTEX;
  402. + }
  403. + // SP3
  404. }
  405. }
  406.  
  407. diff --strip-trailing-cr -ur ./driver/amlinew/type2op.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type2op.c"
  408. --- ./driver/amlinew/type2op.c 2002-09-02 18:22:22.000000000 +0500
  409. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type2op.c" 2022-05-11 01:54:42.042968700 +0500
  410. @@ -9,6 +9,11 @@
  411.  
  412. #include "pch.h"
  413.  
  414. +_CRTIMP unsigned __int64 __cdecl _strtoui64(
  415. + const char * _String,
  416. + char ** _EndPtr,
  417. + int _Radix);
  418. +
  419. #ifdef LOCKABLE_PRAGMA
  420. #pragma ACPI_LOCKABLE_DATA
  421. #pragma ACPI_LOCKABLE_CODE
  422. @@ -28,6 +33,7 @@
  423.  
  424. NTSTATUS LOCAL Buffer(PCTXT pctxt, PTERM pterm)
  425. {
  426. + USHORT* wIOBuf;
  427. TRACENAME("BUFFER")
  428. NTSTATUS rc = STATUS_SUCCESS;
  429. ULONG dwInitSize = (ULONG)(pterm->pbOpEnd - pctxt->pbOp);
  430. @@ -55,6 +61,15 @@
  431. rc = AMLI_LOGERR(AMLIERR_INVALID_BUFFSIZE,
  432. ("Buffer: invalid buffer size (size=%d)",
  433. pterm->pdataArgs[0].uipDataValue));
  434. +
  435. + // Zero length buffer BSOD workaround
  436. + pterm->pdataResult->pbDataBuff = NEWBDOBJ(gpheapGlobal, 1); // alloc 1 byte fake buffer
  437. + pterm->pdataResult->dwDataType = OBJTYPE_BUFFDATA;
  438. + pterm->pdataResult->dwDataLen = 1;
  439. + MEMZERO(pterm->pdataResult->pbDataBuff, 1);
  440. + pctxt->pbOp = pterm->pbOpEnd;
  441. +
  442. + rc = STATUS_SUCCESS;
  443. }
  444. else if ((pterm->pdataResult->pbDataBuff =
  445. NEWBDOBJ(gpheapGlobal,
  446. @@ -73,6 +88,34 @@
  447. pterm->pdataResult->dwDataLen);
  448. MEMCPY(pterm->pdataResult->pbDataBuff, pctxt->pbOp, dwInitSize);
  449. pctxt->pbOp = pterm->pbOpEnd;
  450. +
  451. + /* IOTRAPS range 0xFF00-0xFFFF vs VGA (10-bit decode!) conflict workaround
  452. + Device (IOTR)
  453. + {
  454. + ...
  455. + Name (BUF0, ResourceTemplate ()
  456. + {
  457. + IO (Decode16,
  458. + 0x0000, // Range Minimum
  459. + 0x0000, // Range Maximum
  460. + 0x01, // Alignment
  461. + 0xFF, // Length > 1
  462. + _Y21)
  463. + }) binary: 11 0D 0A _47 01 00 00 00 00 01 FF 79 00_
  464. + ...
  465. + }
  466. + */
  467. +
  468. + if (dwInitSize == 10) {
  469. + wIOBuf = (USHORT*) pterm->pdataResult->pbDataBuff;
  470. + if (wIOBuf[0] == 0x0147 &&
  471. + wIOBuf[1] == 0x0000 &&
  472. + wIOBuf[2] == 0x0000 &&
  473. + wIOBuf[3] == 0xFF01 &&
  474. + wIOBuf[4] == 0x0079 ) {
  475. + pterm->pdataResult->pbDataBuff[7] = 1; // limit range to one adress
  476. + }
  477. + }
  478. }
  479. }
  480.  
  481. @@ -704,6 +747,15 @@
  482. pterm->pdataArgs[1].uipDataValue;
  483. EXIT(2, ("XOr=%x (Result=%x)\n",
  484. rc, pterm->pdataResult->uipDataValue));
  485. + case OP_MOD:
  486. + ENTER(2, ("Mod(Value1=%x,Value2=%x)\n",
  487. + pterm->pdataArgs[0].uipDataValue,
  488. + pterm->pdataArgs[1].uipDataValue));
  489. + pterm->pdataResult->uipDataValue =
  490. + pterm->pdataArgs[0].uipDataValue %
  491. + pterm->pdataArgs[1].uipDataValue;
  492. + EXIT(2, ("Mod=%x (Result=%x)\n",
  493. + rc, pterm->pdataResult->uipDataValue));
  494. }
  495.  
  496. rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  497. @@ -1528,10 +1580,12 @@
  498. char Win2000[] = "Windows 2000";
  499. char Win2001[] = "Windows 2001";
  500. char Win2001SP1[] = "Windows 2001 SP1";
  501. + char Win2001SP2[] = "Windows 2001 SP2";
  502. char* SupportedOSList[] = {
  503. Win2000,
  504. Win2001,
  505. - Win2001SP1
  506. + Win2001SP1,
  507. + Win2001SP2
  508. };
  509. ULONG ListSize = sizeof(SupportedOSList) / sizeof(char*);
  510. ULONG i = 0;
  511. @@ -1558,8 +1612,7 @@
  512. // 0 == Windows 2000
  513. // 1 == Windows 2001
  514. // 2 == Windows 2001 SP1
  515. - // .
  516. - // .
  517. + // 3 == Windows 2001 SP2
  518. //
  519. if(gdwHighestOSVerQueried < i)
  520. {
  521. @@ -1577,3 +1630,837 @@
  522. } //OSInterface
  523.  
  524.  
  525. +
  526. +///////////////////////////////////////////////
  527. +// ACPI 2.0
  528. +
  529. +
  530. +NTSTATUS LOCAL ConvertToInteger(POBJDATA In, POBJDATA Out) {
  531. + ULONG dwDataLen;
  532. + OBJDATA data;
  533. +
  534. + MEMZERO(&data, sizeof(data));
  535. + data.dwDataType = OBJTYPE_INTDATA;
  536. + switch (In->dwDataType) {
  537. + case OBJTYPE_INTDATA:
  538. + data.dwDataValue = In->dwDataValue;
  539. +
  540. + FreeDataBuffs(Out, 1);
  541. + MEMCPY(Out, &data, sizeof(data));
  542. + return STATUS_SUCCESS;
  543. + break;
  544. + case OBJTYPE_STRDATA:
  545. + data.dwDataValue = StrToUL((PSZ)In->pbDataBuff, NULL, 0);
  546. +
  547. + FreeDataBuffs(Out, 1);
  548. + MEMCPY(Out, &data, sizeof(data));
  549. + return STATUS_SUCCESS;
  550. + break;
  551. + case OBJTYPE_BUFFDATA:
  552. + dwDataLen = In->dwDataLen;
  553. + if (dwDataLen > 4) // 8 - int64
  554. + dwDataLen = 4;
  555. + MEMCPY(&data.dwDataValue, In->pbDataBuff, dwDataLen);
  556. +
  557. + FreeDataBuffs(Out, 1);
  558. + MEMCPY(Out, &data, sizeof(data));
  559. + return STATUS_SUCCESS;
  560. + break;
  561. + default:
  562. + return AMLIERR_UNEXPECTED_OBJTYPE;
  563. + break;
  564. + }
  565. +}
  566. +
  567. +
  568. +NTSTATUS LOCAL ToInteger(PCTXT pctxt, PTERM pterm)
  569. +{
  570. + NTSTATUS rc = STATUS_SUCCESS;
  571. + POBJDATA pdata;
  572. + TRACENAME("TOINTEGER")
  573. + ENTER(2, ("ToInteger(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  574. +
  575. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
  576. + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  577. + if ((rc = ConvertToInteger(pterm->pdataArgs, pterm->pdataResult)) == STATUS_SUCCESS)
  578. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  579. + }
  580. +
  581. + EXIT(2, ("ToInteger=%x (Result=%x)\n", rc, pterm->pdataResult));
  582. + return rc;
  583. +}
  584. +
  585. +
  586. +char HTOALookupTable[]="0123456789ABCDEF";
  587. +
  588. +
  589. +NTSTATUS LOCAL ToHexString(PCTXT pctxt, PTERM pterm)
  590. +{
  591. + NTSTATUS rc = STATUS_SUCCESS;
  592. + POBJDATA pdata;
  593. + int StrLen;
  594. + POBJDATA In = pterm->pdataArgs;
  595. + POBJDATA Out = pterm->pdataResult;
  596. + ULONG int32;
  597. + ULONG SrcIdx;
  598. + int i;
  599. + UCHAR pair;
  600. + TRACENAME("TOHEXSTRING")
  601. + ENTER(2, ("ToHexString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  602. +
  603. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
  604. + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  605. + StrLen = 2;
  606. + Out->dwDataType = OBJTYPE_STRDATA;
  607. + switch (In->dwDataType) {
  608. + case OBJTYPE_INTDATA:
  609. + int32 = In->dwDataValue;
  610. + do {
  611. + int32 >>= 4;
  612. + ++StrLen;
  613. + } while (int32);
  614. +
  615. + Out->dwDataLen = StrLen + 1;
  616. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  617. +
  618. + if (Out->pbDataBuff == NULL) {
  619. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  620. + ("ToHexString: failed to allocate target buffer"));
  621. + } else {
  622. + Out->pbDataBuff[0] = '0';
  623. + Out->pbDataBuff[1] = 'x';
  624. + int32 = In->dwDataValue;
  625. + for (i = StrLen - 1; i >= 2; --i) {
  626. + Out->pbDataBuff[i] = HTOALookupTable[int32 & 0xF];
  627. + int32 >>= 4;
  628. + }
  629. +
  630. + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
  631. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  632. + }
  633. + break;
  634. + case OBJTYPE_STRDATA:
  635. + Out->dwDataLen = In->dwDataLen;
  636. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  637. +
  638. + if (Out->pbDataBuff == NULL) {
  639. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  640. + ("ToHexString: failed to allocate target buffer"));
  641. + } else {
  642. + MEMCPY(Out->pbDataBuff, In->pbDataBuff, Out->dwDataLen);
  643. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  644. + }
  645. + break;
  646. + case OBJTYPE_BUFFDATA:
  647. + Out->dwDataLen = 5 * In->dwDataLen;
  648. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  649. +
  650. + if (Out->pbDataBuff == NULL) {
  651. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  652. + ("ToHexString: failed to allocate target buffer"));
  653. + } else {
  654. + i = 0;
  655. + if (In->dwDataLen) {
  656. + for (SrcIdx = 0; SrcIdx < In->dwDataLen; SrcIdx++) {
  657. + Out->pbDataBuff[i] = '0';
  658. + Out->pbDataBuff[i+1] = 'x';
  659. + pair = In->pbDataBuff[SrcIdx];
  660. + Out->pbDataBuff[i+2] = HTOALookupTable[pair >> 4];
  661. + Out->pbDataBuff[i+3] = HTOALookupTable[pair & 0xF];
  662. + Out->pbDataBuff[i+4] = ',';
  663. + i += 5;
  664. + }
  665. + }
  666. +
  667. + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
  668. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  669. + }
  670. + break;
  671. + default:
  672. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  673. + ("ToHexString: invalid arg0 type"));
  674. + break;
  675. + }
  676. + }
  677. +
  678. + EXIT(2, ("ToHexString=%x (Result=%x)\n", rc, pterm->pdataResult));
  679. + return rc;
  680. +}
  681. +
  682. +
  683. +NTSTATUS LOCAL ConvertToBuffer(POBJDATA In, POBJDATA Out) {
  684. + OBJDATA data;
  685. + int Len;
  686. + int i;
  687. + ULONG int32;
  688. + NTSTATUS rc = STATUS_SUCCESS;
  689. +
  690. + MEMZERO(&data, sizeof(data));
  691. + data.dwDataType = OBJTYPE_BUFFDATA;
  692. + switch (In->dwDataType) {
  693. + case OBJTYPE_INTDATA:
  694. + int32 = In->dwDataValue;
  695. + Len = 4;
  696. +
  697. + data.dwDataLen = Len;
  698. + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Len);
  699. + if (data.pbDataBuff == NULL) {
  700. + rc = AMLIERR_OUT_OF_MEM;
  701. + } else {
  702. + for (i = 0; i < Len; i++) {
  703. + data.pbDataBuff[i] = (UCHAR) int32;
  704. + int32 >>= 8;
  705. + }
  706. +
  707. + FreeDataBuffs(Out, 1);
  708. + MEMCPY(Out, &data, sizeof(data));
  709. + }
  710. + break;
  711. + case OBJTYPE_STRDATA:
  712. + case OBJTYPE_BUFFDATA:
  713. + Len = In->dwDataLen;
  714. + data.dwDataLen = Len;
  715. +
  716. + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Len);
  717. + if (data.pbDataBuff == NULL) {
  718. + rc = AMLIERR_OUT_OF_MEM;
  719. + } else {
  720. + MEMCPY(data.pbDataBuff, In->pbDataBuff, Len);
  721. +
  722. + FreeDataBuffs(Out, 1);
  723. + MEMCPY(Out, &data, sizeof(data));
  724. + }
  725. + break;
  726. + default:
  727. + rc = AMLIERR_UNEXPECTED_OBJTYPE;
  728. + break;
  729. + }
  730. +
  731. + return rc;
  732. +}
  733. +
  734. +
  735. +NTSTATUS LOCAL ToBuffer(PCTXT pctxt, PTERM pterm)
  736. +{
  737. + NTSTATUS rc = STATUS_SUCCESS;
  738. + POBJDATA pdata;
  739. + TRACENAME("TOBUFFER")
  740. + ENTER(2, ("ToBuffer(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  741. +
  742. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
  743. + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  744. + if ((rc = ConvertToBuffer(pterm->pdataArgs, pterm->pdataResult)) == STATUS_SUCCESS)
  745. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  746. + }
  747. +
  748. + EXIT(2, ("ToBuffer=%x (Result=%x)\n", rc, pterm->pdataResult));
  749. + return rc;
  750. +}
  751. +
  752. +
  753. +NTSTATUS LOCAL ToDecimalString(PCTXT pctxt, PTERM pterm)
  754. +{
  755. + NTSTATUS rc = STATUS_SUCCESS;
  756. + POBJDATA pdata;
  757. + POBJDATA In = pterm->pdataArgs;
  758. + POBJDATA Out = pterm->pdataResult;
  759. + ULONG int32;
  760. + ULONG StrLen;
  761. + int SrcBufLen;
  762. + ULONG SrcIdx;
  763. + int i;
  764. + int j;
  765. + UCHAR number;
  766. + TRACENAME("TODECSTRING")
  767. + ENTER(2, ("ToDecimalString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  768. +
  769. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
  770. + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  771. + Out->dwDataType = OBJTYPE_STRDATA;
  772. + switch (In->dwDataType) {
  773. + case OBJTYPE_INTDATA:
  774. + int32 = In->dwDataValue;
  775. + StrLen = 0;
  776. + do {
  777. + int32 /= 10;
  778. + ++StrLen;
  779. + } while (int32);
  780. +
  781. + Out->dwDataLen = StrLen + 1;
  782. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  783. +
  784. + if (Out->pbDataBuff == NULL) {
  785. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  786. + ("ToDecimalString: failed to allocate target buffer"));
  787. + } else {
  788. + int32 = In->dwDataValue;
  789. + if (StrLen >= 1) {
  790. + for (i = StrLen - 1; i >= 0; --i) {
  791. + Out->pbDataBuff[i] = HTOALookupTable[int32 % 10];
  792. + int32 /= 10;
  793. + }
  794. + }
  795. +
  796. + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
  797. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  798. + }
  799. + break;
  800. + case OBJTYPE_STRDATA:
  801. + Out->dwDataLen = In->dwDataLen;
  802. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  803. +
  804. + if (Out->pbDataBuff == NULL) {
  805. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  806. + ("ToDecimalString: failed to allocate target buffer"));
  807. + } else {
  808. + MEMCPY(Out->pbDataBuff, In->pbDataBuff, Out->dwDataLen);
  809. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  810. + }
  811. + break;
  812. + case OBJTYPE_BUFFDATA:
  813. + SrcBufLen = In->dwDataLen;
  814. + StrLen = SrcBufLen - 1;
  815. + if (SrcBufLen) {
  816. + for (i = 0; i < SrcBufLen; i++) {
  817. + number = In->pbDataBuff[i];
  818. + if (number >= 10) {
  819. + if (number >= 100)
  820. + StrLen += 3;
  821. + else
  822. + StrLen += 2;
  823. + } else {
  824. + StrLen++;
  825. + }
  826. + }
  827. + }
  828. +
  829. + Out->dwDataLen = StrLen + 1;
  830. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
  831. +
  832. + if (Out->pbDataBuff == NULL) {
  833. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  834. + ("ToDecimalString: failed to allocate target buffer"));
  835. + } else {
  836. + j = 0; // result buffer index
  837. + for ( SrcIdx = 0; SrcIdx < In->dwDataLen; SrcIdx++ ) {
  838. + number = In->pbDataBuff[SrcIdx];
  839. + if (number >= 10) {
  840. + if (number >= 100)
  841. + Out->pbDataBuff[j++] = HTOALookupTable[(number / 100) % 10]; // 2xx
  842. +
  843. + Out->pbDataBuff[j++] = HTOALookupTable[(number / 10) % 10]; // x2x
  844. + Out->pbDataBuff[j++] = HTOALookupTable[number % 10]; // xx2
  845. + } else {
  846. + Out->pbDataBuff[j++] = HTOALookupTable[number];
  847. + }
  848. + Out->pbDataBuff[j++] = ',';
  849. + }
  850. +
  851. + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
  852. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  853. + }
  854. + break;
  855. + default:
  856. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  857. + ("ToDecimalString: invalid arg0 type"));
  858. + break;
  859. + }
  860. + }
  861. +
  862. + EXIT(2, ("ToDecimalString=%x (Result=%x)\n", rc, pterm->pdataResult));
  863. + return rc;
  864. +}
  865. +
  866. +
  867. +NTSTATUS LOCAL CreateQWordField(PCTXT pctxt, PTERM pterm)
  868. +{
  869. + TRACENAME("CREATEQWORDFIELD")
  870. + NTSTATUS rc = STATUS_SUCCESS;
  871. + PBUFFFIELDOBJ pbf;
  872. + ENTER(2, ("CreateQWordField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  873. + pctxt, pctxt->pbOp, pterm));
  874. +
  875. + if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
  876. + STATUS_SUCCESS)
  877. + {
  878. + pbf->FieldDesc.dwByteOffset = (ULONG)pterm->pdataArgs[1].uipDataValue;
  879. + pbf->FieldDesc.dwStartBitPos = 0;
  880. + pbf->FieldDesc.dwNumBits = 8*sizeof(ULONG); // 8*sizeof(ULONG64) ACPI 2.0
  881. + pbf->FieldDesc.dwFieldFlags = ACCTYPE_DWORD; // ACCTYPE_QWORD ACPI 2.0
  882. + }
  883. +
  884. + EXIT(2, ("CreateQWordField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  885. + return rc;
  886. +}
  887. +
  888. +
  889. +UCHAR LOCAL ComputeDataChkSum(UCHAR *Buffer, int Len) {
  890. + UCHAR checksum = 0;
  891. +
  892. + for ( ; Len; --Len ) {
  893. + checksum += *Buffer;
  894. + Buffer++;
  895. + }
  896. +
  897. + return -(checksum);
  898. +}
  899. +
  900. +
  901. +NTSTATUS LOCAL ConcatenateResTemplate(PCTXT pctxt, PTERM pterm)
  902. +{
  903. + NTSTATUS rc = STATUS_SUCCESS;
  904. + POBJDATA pdata;
  905. + POBJDATA In = pterm->pdataArgs;
  906. + POBJDATA Out = pterm->pdataResult;
  907. + ULONG i,j;
  908. + ULONG NewLength;
  909. + TRACENAME("CONCATENATERESTEMPLATE")
  910. + ENTER(2, ("ConcatenateResTemplate(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  911. +
  912. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "BB")) == STATUS_SUCCESS) &&
  913. + ((rc = ValidateTarget(&pterm->pdataArgs[2], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  914. + if (In[0].dwDataLen <= 1 || In[1].dwDataLen <= 1 ) {
  915. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  916. + ("ConcatenateResTemplate: arg0 or arg1 has length <= 1"));
  917. + } else {
  918. + Out->dwDataType = OBJTYPE_BUFFDATA;
  919. + NewLength = In[0].dwDataLen + In[1].dwDataLen - 2;
  920. + Out->dwDataLen = NewLength;
  921. +
  922. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength);
  923. + if (Out->pbDataBuff == NULL) {
  924. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  925. + ("ConcatenateResTemplate: failed to allocate target buffer"));
  926. + } else {
  927. + j = 0;
  928. +
  929. + i = 0;
  930. + if (In[0].dwDataLen != 2) {
  931. + do {
  932. + Out->pbDataBuff[j++] = In[0].pbDataBuff[i++];
  933. + } while (i < In[0].dwDataLen - 2);
  934. + }
  935. +
  936. + i = 0;
  937. + if (In[1].dwDataLen != 2) {
  938. + do {
  939. + Out->pbDataBuff[j++] = In[1].pbDataBuff[i++];
  940. + } while (i < In[1].dwDataLen - 2);
  941. + }
  942. +
  943. + Out->pbDataBuff[j++] = 0x79; //EndTag
  944. + Out->pbDataBuff[j] = ComputeDataChkSum(Out->pbDataBuff, NewLength - 1);
  945. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  946. + }
  947. +
  948. + }
  949. + }
  950. +
  951. + EXIT(2, ("ConcatenateResTemplate=%x (Result=%x)\n", rc, pterm->pdataResult));
  952. + return rc;
  953. +}
  954. +
  955. +
  956. +size_t LOCAL strnlen(const char *Str, size_t MaxCount)
  957. +{
  958. + size_t result;
  959. +
  960. + for (result = 0; result < MaxCount; ++Str) {
  961. + if (!*Str)
  962. + break;
  963. +
  964. + result++;
  965. + }
  966. + return result;
  967. +}
  968. +
  969. +
  970. +#define STRSAFE_MAX_CCH 2147483647
  971. +
  972. +// ntstrsafe.c
  973. +NTSTATUS RtlStringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList)
  974. +{
  975. + NTSTATUS status = STATUS_SUCCESS;
  976. +
  977. + if (cchDest == 0)
  978. + {
  979. + // can not null terminate a zero-byte dest buffer
  980. + status = STATUS_INVALID_PARAMETER;
  981. + }
  982. + else
  983. + {
  984. + int iRet;
  985. + size_t cchMax;
  986. +
  987. + // leave the last space for the null terminator
  988. + cchMax = cchDest - 1;
  989. +
  990. + iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList);
  991. +
  992. + if ((iRet < 0) || (((size_t)iRet) > cchMax))
  993. + {
  994. + // need to null terminate the string
  995. + pszDest += cchMax;
  996. + *pszDest = '\0';
  997. +
  998. + // we have truncated pszDest
  999. + status = STATUS_BUFFER_OVERFLOW;
  1000. + }
  1001. + else if (((size_t)iRet) == cchMax)
  1002. + {
  1003. + // need to null terminate the string
  1004. + pszDest += cchMax;
  1005. + *pszDest = '\0';
  1006. + }
  1007. + }
  1008. +
  1009. + return status;
  1010. +}
  1011. +
  1012. +
  1013. +// ntstrsafe.c
  1014. +NTSTATUS RtlStringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...)
  1015. +{
  1016. + NTSTATUS status;
  1017. +
  1018. + if (cchDest > STRSAFE_MAX_CCH)
  1019. + {
  1020. + status = STATUS_INVALID_PARAMETER;
  1021. + }
  1022. + else
  1023. + {
  1024. + va_list argList;
  1025. +
  1026. + va_start(argList, pszFormat);
  1027. +
  1028. + status = RtlStringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
  1029. +
  1030. + va_end(argList);
  1031. + }
  1032. +
  1033. + return status;
  1034. +}
  1035. +
  1036. +
  1037. +NTSTATUS LOCAL ConvertToString(POBJDATA In, ULONG MaxLen, POBJDATA Out)
  1038. +{
  1039. + NTSTATUS rc = STATUS_SUCCESS;
  1040. + ULONG StrLen = MaxLen;
  1041. + char TmpBuf[9]; // 17 ACPI 2.0
  1042. + OBJDATA data;
  1043. + ULONG BufLen;
  1044. + ULONG InStrLen;
  1045. +
  1046. + MEMZERO(&TmpBuf, sizeof(TmpBuf));
  1047. + MEMZERO(&data, sizeof(data));
  1048. + data.dwDataType = OBJTYPE_STRDATA;
  1049. +
  1050. + switch (In->dwDataType) {
  1051. + case OBJTYPE_INTDATA:
  1052. + BufLen = 9;
  1053. + RtlStringCchPrintfA(TmpBuf, 9, "%x", In->dwDataValue);
  1054. + if (!MaxLen || MaxLen >= BufLen)
  1055. + StrLen = strnlen(TmpBuf, BufLen);
  1056. + data.dwDataLen = StrLen + 1;
  1057. +
  1058. + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
  1059. + if (data.pbDataBuff == NULL) {
  1060. + rc = STATUS_INSUFFICIENT_RESOURCES;
  1061. + } else {
  1062. + MEMCPY(data.pbDataBuff, TmpBuf, data.dwDataLen);
  1063. + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
  1064. + FreeDataBuffs(Out, 1);
  1065. + MEMCPY(Out, &data, sizeof(data));
  1066. + }
  1067. + break;
  1068. + case OBJTYPE_STRDATA:
  1069. + if (MaxLen > In->dwDataLen - 1)
  1070. + rc = STATUS_ACPI_FATAL;
  1071. + else {
  1072. + if (!MaxLen)
  1073. + StrLen = In->dwDataLen - 1;
  1074. + data.dwDataLen = StrLen + 1;
  1075. +
  1076. + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
  1077. + if (data.pbDataBuff == NULL) {
  1078. + rc = STATUS_INSUFFICIENT_RESOURCES;
  1079. + } else {
  1080. + MEMCPY(data.pbDataBuff, In->pbDataBuff, data.dwDataLen);
  1081. + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
  1082. + FreeDataBuffs(Out, 1);
  1083. + MEMCPY(Out, &data, sizeof(data));
  1084. + }
  1085. + }
  1086. + break;
  1087. + case OBJTYPE_BUFFDATA:
  1088. + InStrLen = In->dwDataLen;
  1089. + if (InStrLen >= 201)
  1090. + InStrLen = 201;
  1091. + if (!MaxLen) {
  1092. + StrLen = strnlen((PCHAR)In->pbDataBuff, InStrLen);
  1093. + if (StrLen == InStrLen)
  1094. + return STATUS_INVALID_BUFFER_SIZE;
  1095. + } else {
  1096. + if (MaxLen > InStrLen || MaxLen > 200)
  1097. + return STATUS_ACPI_FATAL;
  1098. + }
  1099. +
  1100. + data.dwDataLen = StrLen + 1;
  1101. + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
  1102. + if (data.pbDataBuff == NULL) {
  1103. + rc = STATUS_INSUFFICIENT_RESOURCES;
  1104. + } else {
  1105. + MEMCPY(data.pbDataBuff, In->pbDataBuff, data.dwDataLen - 1);
  1106. + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
  1107. + FreeDataBuffs(Out, 1);
  1108. + MEMCPY(Out, &data, sizeof(data));
  1109. + }
  1110. + break;
  1111. + default:
  1112. + rc = STATUS_ACPI_INVALID_OBJTYPE;
  1113. + }
  1114. +
  1115. + return rc;
  1116. +}
  1117. +
  1118. +
  1119. +NTSTATUS LOCAL ToString(PCTXT pctxt, PTERM pterm)
  1120. +{
  1121. + NTSTATUS rc = STATUS_SUCCESS;
  1122. + POBJDATA pdata;
  1123. + ULONG MaxLen;
  1124. + TRACENAME("TOSTRING")
  1125. + ENTER(2, ("ToString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  1126. +
  1127. + if ( pterm->icArgs == 2 &&
  1128. + ((rc = ValidateArgTypes(pterm->pdataArgs, "B")) == STATUS_SUCCESS) &&
  1129. + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATA, &pdata)) == STATUS_SUCCESS) ) {
  1130. + rc = ConvertToString(pterm->pdataArgs, 0, pterm->pdataResult);
  1131. +
  1132. + switch (rc) {
  1133. + case STATUS_INSUFFICIENT_RESOURCES:
  1134. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1135. + ("ToString: failed to allocate target buffer"));
  1136. + break;
  1137. + case STATUS_INVALID_BUFFER_SIZE:
  1138. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1139. + ("ToString: buffer length exceeds maximum value"));
  1140. + break;
  1141. + case STATUS_ACPI_FATAL:
  1142. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1143. + ("ToString: length specified exceeds input buffer length or maximum value"));
  1144. + break;
  1145. + }
  1146. + } else
  1147. + if ( pterm->icArgs == 3 &&
  1148. + ((rc = ValidateArgTypes(pterm->pdataArgs, "BI")) == STATUS_SUCCESS) &&
  1149. + ((rc = ValidateTarget(&pterm->pdataArgs[2], OBJTYPE_DATA, &pdata)) == STATUS_SUCCESS) ) {
  1150. + MaxLen = pterm->pdataArgs[1].dwDataValue;
  1151. + if (MaxLen != 0 &&
  1152. + MaxLen != 0xFFFFFFFF) {
  1153. + rc = ConvertToString(pterm->pdataArgs, MaxLen, pterm->pdataResult);
  1154. + } else {
  1155. + rc = ConvertToString(pterm->pdataArgs, 0, pterm->pdataResult);
  1156. + }
  1157. +
  1158. + switch (rc) {
  1159. + case STATUS_INSUFFICIENT_RESOURCES:
  1160. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1161. + ("ToString: failed to allocate target buffer"));
  1162. + break;
  1163. + case STATUS_INVALID_BUFFER_SIZE:
  1164. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1165. + ("ToString: buffer length exceeds maximum value"));
  1166. + break;
  1167. + case STATUS_ACPI_FATAL:
  1168. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1169. + ("ToString: length specified exceeds input buffer length or maximum value"));
  1170. + break;
  1171. + }
  1172. + } else {
  1173. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1174. + ("ToString: invalid # of arguments: %x", pterm->icArgs));
  1175. + }
  1176. +
  1177. + EXIT(2, ("ToString=%x (Result=%x)\n", rc, pterm->pdataResult));
  1178. + return rc;
  1179. +}
  1180. +
  1181. +
  1182. +NTSTATUS LOCAL CopyObject(PCTXT pctxt, PTERM pterm)
  1183. +{
  1184. + NTSTATUS rc = STATUS_SUCCESS;
  1185. + POBJDATA In = pterm->pdataArgs;
  1186. + POBJDATA Out = pterm->pdataResult;
  1187. + POBJDATA pdata;
  1188. + BOOLEAN bWrite;
  1189. + TRACENAME("COPYOBJECT")
  1190. + ENTER(2, ("CopyObject(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  1191. +
  1192. + bWrite = FALSE;
  1193. + rc = ValidateTarget(&pterm->pdataArgs[1], 0, &pdata);
  1194. + if (rc) {
  1195. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1196. + ("CopyObject: failed because target object is not a supername"));
  1197. + } else {
  1198. + if (MatchObjType(pdata->dwDataType, OBJTYPE_DATAFIELD)) {
  1199. + if (In->dwDataType != OBJTYPE_INTDATA &&
  1200. + In->dwDataType != OBJTYPE_BUFFDATA)
  1201. + {
  1202. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1203. + ("CopyObject: Only Integer and Buffer data can be copied to a Field unit or Buffer Field"));
  1204. + goto Exit;
  1205. + }
  1206. + bWrite = TRUE;
  1207. + }
  1208. +
  1209. + MoveObjData(Out, In);
  1210. + if (bWrite)
  1211. + rc = WriteObject(pctxt, pdata, Out);
  1212. + else
  1213. + rc = DupObjData(gpheapGlobal, pdata, Out);
  1214. +
  1215. + if (rc) {
  1216. + AMLI_LOGERR(rc,
  1217. + ("CopyObject: failed to duplicate objdata"));
  1218. + }
  1219. + }
  1220. +
  1221. +Exit:
  1222. + EXIT(2, ("CopyObject=%x (type=%s,value=%I64x,buff=%x,len=%x)\n",
  1223. + rc,
  1224. + GetObjectTypeName(In->dwDataType),
  1225. + In->dwDataValue,
  1226. + In->pbDataBuff,
  1227. + In->dwDataLen));
  1228. + return rc;
  1229. +}
  1230. +
  1231. +
  1232. +NTSTATUS LOCAL MidString(PCTXT pctxt, PTERM pterm)
  1233. +{
  1234. + NTSTATUS rc = STATUS_SUCCESS;
  1235. + POBJDATA In = pterm->pdataArgs;
  1236. + POBJDATA Out = pterm->pdataResult;
  1237. + POBJDATA pdata;
  1238. + ULONG DataLen, NewLength;
  1239. + ULONG MidIndex, MidSize;
  1240. + ULONG i,j;
  1241. + TRACENAME("MID")
  1242. + ENTER(2, ("MidString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  1243. +
  1244. + if (((rc = ValidateArgTypes(pterm->pdataArgs, "TII")) == STATUS_SUCCESS) &&
  1245. + ((rc = ValidateTarget(&pterm->pdataArgs[3], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
  1246. + if (In->dwDataType > OBJTYPE_BUFFDATA) {
  1247. + rc = AMLI_LOGERR(AMLIERR_FATAL,
  1248. + ("Mid: invalid arg0 type"));
  1249. + } else {
  1250. + Out->dwDataType = In->dwDataType;
  1251. + DataLen = In->dwDataLen;
  1252. + MidIndex = In[1].dwDataValue;
  1253. + MidSize = In[2].dwDataValue;
  1254. + if (MidIndex < DataLen) {
  1255. + NewLength = MidSize;
  1256. +
  1257. + if (Out->dwDataType == OBJTYPE_STRDATA) {
  1258. + DataLen--; // exclude ending zero
  1259. + if ((MidIndex + MidSize) > DataLen)
  1260. + NewLength = DataLen - MidIndex;
  1261. +
  1262. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength + 1);
  1263. + if (Out->pbDataBuff == NULL) {
  1264. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1265. + ("Mid: failed to allocate target string"));
  1266. + } else {
  1267. + Out->dwDataLen = NewLength + 1;
  1268. + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
  1269. + }
  1270. + } else {
  1271. + if ( Out->dwDataType != OBJTYPE_BUFFDATA ) {
  1272. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1273. + ("Mid: pterm->pdataResult->dwDataType != OBJTYPE_BUFFDATA"));
  1274. + } else {
  1275. + if ((MidIndex + MidSize) > DataLen)
  1276. + NewLength = DataLen - MidIndex;
  1277. +
  1278. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength);
  1279. + if (Out->pbDataBuff == NULL) {
  1280. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1281. + ("Mid: failed to allocate target string"));
  1282. + } else {
  1283. + Out->dwDataLen = NewLength;
  1284. + }
  1285. + }
  1286. + }
  1287. +
  1288. + if (!rc) {
  1289. + i = MidIndex;
  1290. + j = 0;
  1291. + if (NewLength) {
  1292. + do {
  1293. + Out->pbDataBuff[j++] = In->pbDataBuff[i++];
  1294. + } while (j < NewLength);
  1295. + }
  1296. +
  1297. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  1298. + }
  1299. + } else { // MidIndex >= DataLen, set len = 0
  1300. + if (In->dwDataType == OBJTYPE_STRDATA) {
  1301. + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, 1);
  1302. + if (Out->pbDataBuff == NULL) {
  1303. + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  1304. + ("Mid: failed to allocate target string"));
  1305. + } else {
  1306. + Out->pbDataBuff[0] = '\0'; // ending zero
  1307. + Out->dwDataLen = 1;
  1308. +
  1309. + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
  1310. + }
  1311. + }
  1312. + }
  1313. + }
  1314. + }
  1315. +
  1316. + EXIT(2, ("MidString=%x (Result=%x)\n", rc, pterm->pdataResult));
  1317. + return rc;
  1318. +}
  1319. +
  1320. +
  1321. +NTSTATUS LOCAL Continue(PCTXT pctxt, PTERM pterm)
  1322. +{
  1323. + TRACENAME("CONTINUE")
  1324. + ENTER(2, ("Continue(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  1325. +
  1326. + ;
  1327. +
  1328. + EXIT(2, ("Continue=%x\n", AMLISTA_CONTINUEOP));
  1329. + return AMLISTA_CONTINUEOP;
  1330. +}
  1331. +
  1332. +
  1333. +NTSTATUS LOCAL Timer(PCTXT pctxt, PTERM pterm)
  1334. +{
  1335. + TRACENAME("TIMER")
  1336. + ENTER(2, ("Timer(pctxt=%x,pbOp=%x,pterm=%x, Querying for %s)\n",
  1337. + pctxt,
  1338. + pctxt->pbOp,
  1339. + pterm,
  1340. + pterm->pdataArgs->pbDataBuff));
  1341. +
  1342. + pterm->pdataResult->dwDataType = 1;
  1343. + pterm->pdataResult->dwDataValue = (ULONG)KeQueryInterruptTime();
  1344. +
  1345. + EXIT(2, ("Timer=%x (pnsObj=%x)\n", 0, pterm->pnsObj));
  1346. + return AMLIERR_NONE;
  1347. +}
  1348. +
  1349. +
  1350. + /*
  1351. + __asm {
  1352. + L1: jmp L1
  1353. + }
  1354. + */
  1355. +
  1356. +
  1357. +// ACPI 2.0
  1358. +///////////////////////////////////////////////
  1359. \ No newline at end of file
  1360. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver: build.log
  1361. diff --strip-trailing-cr -ur ./driver/inc/aml.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/inc/aml.h"
  1362. --- ./driver/inc/aml.h 2002-09-02 18:22:22.000000000 +0500
  1363. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/inc/aml.h" 2022-04-16 06:47:51.964843700 +0500
  1364. @@ -90,6 +90,23 @@
  1365. #define OP_LEQ 0x93
  1366. #define OP_LG 0x94
  1367. #define OP_LL 0x95
  1368. +
  1369. +// Win7 ACPI 2.0
  1370. +#define OP_QWORD 0x0e
  1371. +#define OP_CONCATRESTMPL 0x84
  1372. +#define OP_MOD 0x85
  1373. +#define OP_QWORDFIELD 0x8f
  1374. +#define OP_TOBUFFER 0x96
  1375. +#define OP_TODECSTRING 0x97
  1376. +#define OP_TOHEXSTRING 0x98
  1377. +#define OP_TOINTEGER 0x99
  1378. +#define OP_TOSTRING 0x9c
  1379. +#define OP_COPYOBJECT 0x9d
  1380. +#define OP_MID 0x9e
  1381. +#define OP_CONTINUE 0x9f
  1382. +#define EXOP_TIMER 0x33
  1383. +#define OP_TIMER EXOP(EXOP_TIMER) // 5B33
  1384. +
  1385. #define OP_IF 0xa0
  1386. #define OP_ELSE 0xa1
  1387. #define OP_WHILE 0xa2
  1388. @@ -173,12 +190,12 @@
  1389. #define UPDATERULE_WRITEASZEROS 0x40 //WriteAsZeros
  1390. #define ACCATTRIB_MASK 0xff00
  1391.  
  1392. +
  1393. //
  1394. -// Returns 1, 2 or 4 for BYTE, WORD or DWORD respectively and returns 1 for
  1395. -// any other sizes.
  1396. -//
  1397. +// Returns 1, 2 or 4 for BYTE, WORD or DWORD respectively and returns 1 for any other sizes.
  1398. +// ACPI 2.0: return 8 for QWORD
  1399. #define ACCSIZE(f) (((((f) & ACCTYPE_MASK) >= ACCTYPE_BYTE) && \
  1400. - (((f) & ACCTYPE_MASK) <= ACCTYPE_DWORD))? \
  1401. + (((f) & ACCTYPE_MASK) <= ACCTYPE_QWORD))? \
  1402. (1 << (((f) & ACCTYPE_MASK) - 1)): 1)
  1403.  
  1404. /*** Operation region space
  1405. diff --strip-trailing-cr -ur ./driver/nt/acpiosnt.rc "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/acpiosnt.rc"
  1406. --- ./driver/nt/acpiosnt.rc 2002-09-02 18:22:22.000000000 +0500
  1407. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/acpiosnt.rc" 2022-04-16 06:47:51.973632800 +0500
  1408. @@ -1,9 +1,12 @@
  1409. #include <windows.h>
  1410. #include <ntverp.h>
  1411.  
  1412. +#define VER_FILEVERSION 5,1,2600,7777
  1413. +#define VER_FILEVERSION_STR "5,1,2600,7777"
  1414. +
  1415. #define VER_FILETYPE VFT_DRV
  1416. #define VER_FILESUBTYPE VFT2_DRV_SYSTEM
  1417. -#define VER_FILEDESCRIPTION_STR "ACPI Driver for NT"
  1418. +#define VER_FILEDESCRIPTION_STR "ACPI 2.0 Driver for NT"
  1419. #define VER_INTERNALNAME_STR "ACPI.sys"
  1420. #define VER_ORIGINALFILENAME_STR "ACPI.sys"
  1421.  
  1422. diff --strip-trailing-cr -ur ./driver/nt/buildsrc.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/buildsrc.c"
  1423. --- ./driver/nt/buildsrc.c 2002-09-02 18:22:22.000000000 +0500
  1424. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/buildsrc.c" 2022-04-26 20:08:52.334960900 +0500
  1425. @@ -399,7 +399,7 @@
  1426. {
  1427. PACPI_BUILD_REQUEST buildRequest = (PACPI_BUILD_REQUEST) Context;
  1428. ULONG nextWorkDone = buildRequest->NextWorkDone;
  1429. -
  1430. + ULONG ParentName;
  1431. //
  1432. // Device what state we should transition to next
  1433. //
  1434. @@ -413,10 +413,12 @@
  1435. //
  1436. // Death
  1437. //
  1438. +
  1439. + ParentName = AcpiObject ? (AcpiObject->pnsParent ? AcpiObject->pnsParent->dwNameSeg : 0) : 0 ;
  1440. KeBugCheckEx(
  1441. ACPI_BIOS_ERROR,
  1442. ACPI_FAILED_MUST_SUCCEED_METHOD,
  1443. - (ULONG_PTR) AcpiObject,
  1444. + (ULONG_PTR) ParentName,
  1445. Status,
  1446. (AcpiObject ? AcpiObject->dwNameSeg : 0)
  1447. );
  1448. diff --strip-trailing-cr -ur ./driver/nt/bus.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/bus.c"
  1449. --- ./driver/nt/bus.c 2002-09-02 18:22:22.000000000 +0500
  1450. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/bus.c" 2022-04-28 11:57:02.785156200 +0500
  1451. @@ -2547,7 +2547,7 @@
  1452. PNP_BIOS_TO_IO_NO_CONSUMED_RESOURCES : 0),
  1453. &resList
  1454. );
  1455. - ASSERT(NT_SUCCESS(status));
  1456. + //ASSERT(NT_SUCCESS(status));
  1457.  
  1458. }
  1459.  
  1460. diff --strip-trailing-cr -ur ./driver/nt/debug.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.c"
  1461. --- ./driver/nt/debug.c 2002-09-02 18:22:24.000000000 +0500
  1462. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.c" 2022-04-16 06:47:51.983398400 +0500
  1463. @@ -80,6 +80,18 @@
  1464. {
  1465. KeBugCheckEx (ACPI_DRIVER_INTERNAL, 0x1, Bugcode, 0, 0);
  1466. }
  1467. +
  1468. +// SP3
  1469. +VOID
  1470. +_ACPIInternalErrorEx(
  1471. + IN ULONG Bugcode0,
  1472. + IN ULONG_PTR Bugcode1,
  1473. + IN ULONG_PTR Bugcode2
  1474. + )
  1475. +{
  1476. + KeBugCheckEx (ACPI_DRIVER_INTERNAL, 0x2, Bugcode0, Bugcode1, Bugcode2);
  1477. +}
  1478. +// SP3
  1479. #if DBG
  1480. VOID
  1481. diff --strip-trailing-cr -ur ./driver/nt/debug.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.h"
  1482. --- ./driver/nt/debug.h 2002-09-02 18:22:24.000000000 +0500
  1483. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.h" 2022-04-16 06:47:51.993164000 +0500
  1484. @@ -53,6 +53,15 @@
  1485. IN ULONG Bugcode
  1486. );
  1487.  
  1488. + // SP3
  1489. + VOID
  1490. + _ACPIInternalErrorEx(
  1491. + IN ULONG Bugcode0,
  1492. + IN ULONG_PTR Bugcode1,
  1493. + IN ULONG_PTR Bugcode2
  1494. + );
  1495. + // SP3
  1496. +
  1497. #if DBG
  1498. VOID
  1499. ACPIDebugResourceDescriptor(
  1500. diff --strip-trailing-cr -ur ./driver/nt/detect.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/detect.c"
  1501. --- ./driver/nt/detect.c 2002-09-02 18:22:24.000000000 +0500
  1502. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/detect.c" 2022-04-28 15:45:43.399414000 +0500
  1503. @@ -955,13 +955,14 @@
  1504. "ACPIDetectDuplicateHID - matches with %08lx\n",
  1505. childExtension
  1506. ) );
  1507. - KeBugCheckEx(
  1508. - ACPI_BIOS_ERROR,
  1509. - ACPI_REQUIRED_METHOD_NOT_PRESENT,
  1510. - (ULONG_PTR) DeviceExtension,
  1511. - PACKED_UID,
  1512. - 0
  1513. - );
  1514. +
  1515. + //KeBugCheckEx(
  1516. + // ACPI_BIOS_ERROR,
  1517. + // ACPI_REQUIRED_METHOD_NOT_PRESENT,
  1518. + // (ULONG_PTR) DeviceExtension,
  1519. + // PACKED_UID,
  1520. + // 0
  1521. + // );
  1522.  
  1523. //
  1524. // Make sure to only muck with the DeviceExtension UID if it doesn't
  1525. @@ -974,7 +975,7 @@
  1526. //
  1527. DeviceExtension->InstanceID = ExAllocatePoolWithTag(
  1528. NonPagedPool,
  1529. - 9 * sizeof(UCHAR),
  1530. + 5 * sizeof(UCHAR),
  1531. ACPI_STRING_POOLTAG
  1532. );
  1533. if (DeviceExtension->InstanceID == NULL) {
  1534. @@ -987,8 +988,8 @@
  1535. ACPIInternalError( ACPI_DETECT );
  1536.  
  1537. }
  1538. - RtlZeroMemory( DeviceExtension->InstanceID, 9 * sizeof(UCHAR) );
  1539. - sprintf( DeviceExtension->InstanceID, "%lx", DeviceExtension->AcpiObject->dwNameSeg );
  1540. + RtlZeroMemory( DeviceExtension->InstanceID, 5 * sizeof(UCHAR) );
  1541. + sprintf( DeviceExtension->InstanceID, "%.4s", & DeviceExtension->AcpiObject->dwNameSeg );
  1542.  
  1543. //
  1544. // Remember that we have a fixed uid
  1545. @@ -1012,7 +1013,7 @@
  1546. //
  1547. childExtension->InstanceID = ExAllocatePoolWithTag(
  1548. NonPagedPool,
  1549. - 9 * sizeof(UCHAR),
  1550. + 5 * sizeof(UCHAR),
  1551. ACPI_STRING_POOLTAG
  1552. );
  1553. if (childExtension->InstanceID == NULL) {
  1554. @@ -1025,8 +1026,8 @@
  1555. ACPIInternalError( ACPI_DETECT );
  1556.  
  1557. }
  1558. - RtlZeroMemory( childExtension->InstanceID, 9 * sizeof(UCHAR) );
  1559. - sprintf( childExtension->InstanceID, "%lx", childExtension->AcpiObject->dwNameSeg );
  1560. + RtlZeroMemory( childExtension->InstanceID, 5 * sizeof(UCHAR) );
  1561. + sprintf( childExtension->InstanceID, "%.4s", & childExtension->AcpiObject->dwNameSeg );
  1562.  
  1563. //
  1564. // Update the flags for both devices to indicate the fixed UID
  1565. diff --strip-trailing-cr -ur ./driver/nt/devpower.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/devpower.c"
  1566. --- ./driver/nt/devpower.c 2002-09-02 18:22:24.000000000 +0500
  1567. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/devpower.c" 2022-04-16 06:47:52.005859300 +0500
  1568. @@ -4712,7 +4712,7 @@
  1569. } // ACPIDevicePowerProcessPhase2SystemSubPhase3
  1570. NTSTATUS
  1571. -ACPIDevicePowerProcessPhase3(
  1572. +ACPIDevicePowerProcessPhase3_SP1(
  1573. VOID
  1574. )
  1575. /*++
  1576. @@ -5058,6 +5058,215 @@
  1577. return (returnPending ? STATUS_PENDING : STATUS_SUCCESS);
  1578.  
  1579. } // ACPIPowerProcessPhase3
  1580. +
  1581. +
  1582. +#ifdef _X86_
  1583. +// SP3
  1584. +__declspec(naked) NTSTATUS
  1585. +ACPIDevicePowerProcessPhase3(
  1586. + VOID
  1587. + )
  1588. +{
  1589. + __asm {
  1590. + mov edi, edi
  1591. + push ebp
  1592. + mov ebp, esp
  1593. + sub esp, 18h
  1594. + push ebx
  1595. + push esi
  1596. + mov ebx, offset AcpiPowerLock
  1597. + push edi
  1598. + mov ecx, ebx
  1599. + mov byte ptr [ebp-1], 0
  1600. + call dword ptr [KefAcquireSpinLockAtDpcLevel]
  1601. + mov esi, dword ptr [AcpiPowerNodeList+0] ;Flink
  1602. + mov eax, offset AcpiPowerNodeList
  1603. + cmp esi, eax
  1604. + jz loc_1535A
  1605. + jmp short loc_15250
  1606. +loc_1524D:
  1607. + mov esi, [ebp-0Ch]
  1608. +loc_15250:
  1609. + mov eax, [esi]
  1610. + mov [ebp-0Ch], eax
  1611. + mov eax, [esi+8]
  1612. + and eax, 2
  1613. + xor ecx, ecx
  1614. + or eax, ecx
  1615. + jz loc_1534C
  1616. + push 3
  1617. + push 4
  1618. + lea ecx, [esi+28h]
  1619. + pop edx
  1620. + call dword ptr [InterlockedCompareExchange]
  1621. + cmp eax, 3
  1622. + jnz loc_1534C
  1623. + and dword ptr [ebp-8], 0
  1624. + lea eax, [esi+20h]
  1625. + mov edi, [eax]
  1626. + jmp short loc_152C6
  1627. +loc_15287:
  1628. + lea eax, [edi-18h]
  1629. + mov edi, [edi]
  1630. + mov [ebp-14h], eax
  1631. + mov eax, [eax+14h]
  1632. + push 0
  1633. + lea ecx, [eax+0F0h]
  1634. + xor edx, edx
  1635. + mov [ebp-10h], eax
  1636. + call dword ptr [InterlockedCompareExchange]
  1637. + mov ecx, [ebp-10h]
  1638. + mov edx, [ecx+0ECh]
  1639. + mov ecx, [ebp-14h]
  1640. + cmp edx, [ecx+0Ch]
  1641. + jz short loc_152C0
  1642. + test eax, eax
  1643. + jz short loc_152C3
  1644. + cmp byte ptr [ecx+10h], 0
  1645. + jz short loc_152C3
  1646. +
  1647. +loc_152C0:
  1648. + inc dword ptr [ebp-8]
  1649. +
  1650. +loc_152C3:
  1651. + lea eax, [esi+20h]
  1652. +
  1653. +loc_152C6:
  1654. + cmp edi, eax
  1655. + jnz short loc_15287
  1656. + mov edx, [ebp-8]
  1657. + lea ecx, [esi+10h]
  1658. + call dword ptr [InterlockedExchange]
  1659. + mov eax, [esi+0Ch]
  1660. + mov ecx, [esi+8]
  1661. + mov [ebp-14h], eax
  1662. + mov eax, ecx
  1663. + and eax, 440h
  1664. + xor edx, edx
  1665. + or eax, edx
  1666. + jnz short loc_1534C
  1667. + and ecx, 220h
  1668. + xor eax, eax
  1669. + xor edi, edi
  1670. + or ecx, eax
  1671. + jnz short loc_152FF
  1672. + cmp [ebp-8], edi
  1673. + jz short loc_1534C
  1674. +
  1675. +loc_152FF:
  1676. + xor edx, edx
  1677. + push 4
  1678. + inc edx
  1679. + lea ecx, [esi+28h]
  1680. + call dword ptr [InterlockedCompareExchange]
  1681. + mov ecx, ebx
  1682. + call dword ptr [KefReleaseSpinLockFromDpcLevel]
  1683. + push esi
  1684. + push offset ACPIDeviceCompletePhase3On
  1685. + push edi
  1686. + push edi
  1687. + push edi
  1688. + push dword ptr [esi+2Ch]
  1689. + call AMLIAsyncEvalObject
  1690. + add esp, 18h
  1691. + cmp eax, 103h
  1692. + jz short loc_15340
  1693. + push esi
  1694. + push edi
  1695. + push eax
  1696. + push dword ptr [esi+2Ch]
  1697. + call ACPIDeviceCompletePhase3On
  1698. + add esp, 10h
  1699. + jmp short loc_15344
  1700. +
  1701. +
  1702. +loc_15340:
  1703. + mov byte ptr [ebp-1], 1
  1704. +
  1705. +loc_15344:
  1706. + mov ecx, ebx
  1707. + call dword ptr [KefAcquireSpinLockAtDpcLevel]
  1708. +
  1709. +loc_1534C:
  1710. + mov eax, offset AcpiPowerNodeList
  1711. + cmp [ebp-0Ch], eax
  1712. + jnz loc_1524D
  1713. +
  1714. +loc_1535A:
  1715. + mov edi, dword ptr [AcpiPowerNodeList+4] ; Blink
  1716. + cmp edi, eax
  1717. + jz short loc_153DC
  1718. +
  1719. +loc_15364:
  1720. + mov esi, edi
  1721. + mov eax, [esi+8]
  1722. + mov edi, [edi+4]
  1723. + and eax, 2
  1724. + xor ecx, ecx
  1725. + or eax, ecx
  1726. + jz short loc_153D4
  1727. + xor edx, edx
  1728. + push 4
  1729. + lea ecx, [esi+28h]
  1730. + inc edx
  1731. + call dword ptr [InterlockedCompareExchange]
  1732. + cmp eax, 4
  1733. + jz short loc_15392
  1734. + test eax, eax
  1735. + jz short loc_153D4
  1736. + mov byte ptr [ebp-1], 1
  1737. + jmp short loc_153D4
  1738. +
  1739. +loc_15392:
  1740. + mov ecx, ebx
  1741. + call dword ptr [KefReleaseSpinLockFromDpcLevel]
  1742. + push esi
  1743. + push offset ACPIDeviceCompletePhase3Off
  1744. + xor eax, eax
  1745. + push eax
  1746. + push eax
  1747. + push eax
  1748. + push dword ptr [esi+30h]
  1749. + call AMLIAsyncEvalObject
  1750. + add esp, 18h
  1751. + cmp eax, 103h
  1752. + jz short loc_153C8
  1753. + push esi
  1754. + push 0
  1755. + push eax
  1756. + push dword ptr [esi+30h]
  1757. + call ACPIDeviceCompletePhase3Off
  1758. + add esp, 10h
  1759. + jmp short loc_153CC
  1760. +
  1761. +loc_153C8:
  1762. + mov byte ptr [ebp-1], 1
  1763. +
  1764. +loc_153CC:
  1765. + mov ecx, ebx
  1766. + call dword ptr [KefAcquireSpinLockAtDpcLevel]
  1767. +
  1768. +loc_153D4:
  1769. + cmp edi, offset AcpiPowerNodeList
  1770. + jnz short loc_15364
  1771. +
  1772. +loc_153DC:
  1773. + mov ecx, ebx
  1774. + call dword ptr [KefReleaseSpinLockFromDpcLevel]
  1775. + mov al, [ebp-1]
  1776. + neg al
  1777. + pop edi
  1778. + pop esi
  1779. + pop ebx
  1780. + sbb eax, eax
  1781. + and eax, 103h
  1782. + _emit 0xc9 ; "leave" opcode
  1783. + ret
  1784. + }
  1785. +}
  1786. +// SP3
  1787. +#endif
  1788. +
  1789. NTSTATUS
  1790. ACPIDevicePowerProcessPhase4(
  1791. diff --strip-trailing-cr -ur ./driver/nt/internal.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/internal.c"
  1792. --- ./driver/nt/internal.c 2002-09-02 18:22:24.000000000 +0500
  1793. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/internal.c" 2022-04-16 06:47:52.018554600 +0500
  1794. @@ -304,6 +304,15 @@
  1795. //
  1796. deviceExtension = DeviceObject->DeviceExtension;
  1797.  
  1798. + // SP3
  1799. + if ( deviceExtension &&
  1800. + deviceExtension->Signature != '_SGP' ) {
  1801. + _ACPIInternalErrorEx(0x00090147,
  1802. + (ULONG_PTR)DeviceObject,
  1803. + (ULONG_PTR)deviceExtension);
  1804. + }
  1805. + // SP3
  1806. +
  1807. #if 0
  1808. //
  1809. // Is this a surprise removed device extension?
  1810. diff --strip-trailing-cr -ur ./driver/nt/interupt.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/interupt.c"
  1811. --- ./driver/nt/interupt.c 2002-09-02 18:22:24.000000000 +0500
  1812. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/interupt.c" 2022-04-16 06:47:52.028320300 +0500
  1813. @@ -711,11 +711,14 @@
  1814. // behind our back. The way that we can correct this problem is by
  1815. // forcing a check of the GPEs...
  1816. //
  1817. - if (!IntStatus) {
  1818. +
  1819. + // SP3
  1820. + if ( !(AcpiOverrideAttributes & 0x0100) && !IntStatus ) { // test byte ptr _AcpiOverrideAttributes+1, 1
  1821.  
  1822. IntStatus |= PM1_GPE_PENDING;
  1823.  
  1824. }
  1825. + // SP3
  1826.  
  1827. //
  1828. // Are any status bits set for events which are handled at ISR time?
  1829. diff --strip-trailing-cr -ur ./driver/nt/irqarb.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.c"
  1830. --- ./driver/nt/irqarb.c 2002-09-02 18:22:24.000000000 +0500
  1831. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.c" 2022-05-11 01:54:42.166015600 +0500
  1832. @@ -39,7 +39,8 @@
  1833. extern LONG ArbDebugLevel;
  1834.  
  1835. #define DEBUG_PRINT(Level, Message) \
  1836. - if (ArbDebugLevel >= Level) DbgPrint Message
  1837. + DbgPrint Message
  1838. +
  1839. #else
  1840. #define DEBUG_PRINT(Level, Message)
  1841. #endif
  1842. @@ -3509,6 +3510,22 @@
  1843. }
  1844. }
  1845.  
  1846. + // BSOD 0x7E(c0000005, ...) AcpiArbCrackPRT() two workarounds:
  1847. + // 1) pci.sys presence check
  1848. + // 2) not PCI device type check
  1849. + if (0) {
  1850. + if (!PciInterfacesInstantiated) {
  1851. + return STATUS_NOT_FOUND;
  1852. + }
  1853. + } else {
  1854. + if (Pdo->DriverObject == AcpiDriverObject) {
  1855. + status = ACPIInternalIsPci(Pdo);
  1856. + if (NT_SUCCESS(status))
  1857. + if ( (((PDEVICE_EXTENSION)Pdo->DeviceExtension)->Flags & DEV_CAP_PCI_DEVICE) == 0 )
  1858. + return STATUS_NOT_FOUND;
  1859. + }
  1860. + }
  1861. +
  1862. ASSERT(PciInterfacesInstantiated);
  1863.  
  1864. *LinkNode = NULL;
  1865. @@ -4970,16 +4987,18 @@
  1866. }
  1867.  
  1868. } else {
  1869. + if (0) { // BSOD 0xA5 (0x10006, ...) workaround, missing _DIS method for "PNP0C0F" (PCI Interrupt Link Devices)
  1870.  
  1871. - //
  1872. - // Link nodes must be disablable.
  1873. - //
  1874. + //
  1875. + // Link nodes must be disablable.
  1876. + //
  1877.  
  1878. - KeBugCheckEx(ACPI_BIOS_ERROR,
  1879. - ACPI_LINK_NODE_CANNOT_BE_DISABLED,
  1880. - (ULONG_PTR)context->RootDevice,
  1881. - 0,
  1882. - 0);
  1883. + KeBugCheckEx(ACPI_BIOS_ERROR,
  1884. + ACPI_LINK_NODE_CANNOT_BE_DISABLED,
  1885. + (ULONG_PTR)context->RootDevice,
  1886. + 0,
  1887. + 0);
  1888. + }
  1889. }
  1890. }
  1891. }
  1892. diff --strip-trailing-cr -ur ./driver/nt/irqarb.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.h"
  1893. --- ./driver/nt/irqarb.h 2002-09-02 18:22:24.000000000 +0500
  1894. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.h" 2022-04-26 20:08:52.452148400 +0500
  1895. @@ -99,7 +99,8 @@
  1896. extern ACPI_ARBITER AcpiArbiter;
  1897. extern BOOLEAN PciInterfacesInstantiated;
  1898.  
  1899. -#define PCI_PNP_ID "PNP0A03"
  1900. +#define PCI_PNP_ID "PNP0A03"
  1901. +#define PCIE_PNP_ID "PNP0A08"
  1902. #define LINK_NODE_PNP_ID "PNP0C0F"
  1903.  
  1904. // Prototypes for stuff used by msi.c
  1905. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/nt: obj
  1906. diff --strip-trailing-cr -ur ./driver/nt/osnotify.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/osnotify.c"
  1907. --- ./driver/nt/osnotify.c 2002-09-02 18:22:24.000000000 +0500
  1908. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/osnotify.c" 2022-04-16 06:47:52.056640600 +0500
  1909. @@ -723,7 +723,7 @@
  1910. NTSTATUS
  1911. EXPORT
  1912. -OSNotifyDeviceCheck(
  1913. +OSNotifyDeviceCheck_SP1(
  1914. IN PNSOBJ AcpiObject
  1915. )
  1916. /*++
  1917. @@ -827,6 +827,91 @@
  1918. //
  1919. return STATUS_SUCCESS;
  1920. }
  1921. +
  1922. +
  1923. +#ifdef _X86_
  1924. +// SP3
  1925. +__declspec(naked) NTSTATUS
  1926. +EXPORT
  1927. +OSNotifyDeviceCheck(
  1928. + IN PNSOBJ AcpiObject
  1929. + )
  1930. +{
  1931. +__asm {
  1932. + mov edi, edi
  1933. + push ebp
  1934. + mov ebp, esp
  1935. + push [ebp+8]
  1936. + call ACPIDockIsDockDevice
  1937. + test al, al
  1938. + jz short loc_1C94F
  1939. + pop ebp
  1940. + jmp OSNotifyDeviceEject
  1941. +
  1942. +loc_1C94F:
  1943. + push ebx
  1944. + push esi
  1945. + mov esi, offset AcpiDeviceTreeLock
  1946. + mov ecx, esi
  1947. + call dword ptr [KfAcquireSpinLock]
  1948. + mov ecx, [ebp+8]
  1949. + mov bl, al
  1950. + xor edx, edx
  1951. +
  1952. +loc_1C965:
  1953. + mov eax, [ecx+30h]
  1954. + cmp eax, edx
  1955. + mov ecx, [ecx+8]
  1956. + jz short loc_1C97E
  1957. + cmp dword ptr [eax+8], '_SGP'
  1958. + jz short loc_1C97A
  1959. + xor eax, eax
  1960. +
  1961. +loc_1C97A:
  1962. + cmp eax, edx
  1963. + jnz short loc_1C986
  1964. +
  1965. +loc_1C97E:
  1966. + cmp ecx, edx
  1967. + jnz short loc_1C965
  1968. + cmp eax, edx
  1969. + jz short loc_1C9B0
  1970. +
  1971. +loc_1C986:
  1972. + mov ecx, [eax+13Ch]
  1973. + jmp short loc_1C99D
  1974. +
  1975. +loc_1C98E:
  1976. + mov eax, [ecx]
  1977. + and eax, 8
  1978. + or eax, edx
  1979. + jz short loc_1C9A3
  1980. + mov ecx, [ecx+13Ch]
  1981. +
  1982. +loc_1C99D:
  1983. + cmp ecx, edx
  1984. + jnz short loc_1C98E
  1985. + jmp short loc_1C9B0
  1986. +
  1987. +loc_1C9A3:
  1988. + push edx
  1989. + push dword ptr [ecx+138h]
  1990. + call dword ptr [IoInvalidateDeviceRelations]
  1991. +
  1992. +loc_1C9B0:
  1993. + mov ecx, esi
  1994. + mov dl, bl
  1995. + call dword ptr [KfReleaseSpinLock]
  1996. + pop esi
  1997. + xor eax, eax
  1998. + pop ebx
  1999. + pop ebp
  2000. + ret
  2001. +}
  2002. +}
  2003. +// SP3
  2004. +#endif
  2005. +
  2006. NTSTATUS
  2007. EXPORT
  2008. diff --strip-trailing-cr -ur ./driver/nt/pciopregion.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/pciopregion.c"
  2009. --- ./driver/nt/pciopregion.c 2002-09-02 18:22:24.000000000 +0500
  2010. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/pciopregion.c" 2022-04-26 20:08:52.482421800 +0500
  2011. @@ -1119,7 +1119,10 @@
  2012.  
  2013. pciConfig = (PPCI_COMMON_CONFIG)buffer;
  2014.  
  2015. - if (pciConfig->HeaderType != PCI_BRIDGE_TYPE) {
  2016. + // SP3
  2017. + if ((PCI_CONFIGURATION_TYPE(pciConfig) != PCI_BRIDGE_TYPE) &&
  2018. + (PCI_CONFIGURATION_TYPE(pciConfig) != PCI_CARDBUS_BRIDGE_TYPE)) {
  2019. + // SP3
  2020.  
  2021. //
  2022. // Make a guess that the bus number was 0.
  2023. @@ -1388,7 +1391,8 @@
  2024.  
  2025. if (state->Hid) {
  2026.  
  2027. - if (strstr(state->Hid, PCI_PNP_ID)) {
  2028. + if (strstr(state->Hid, PCI_PNP_ID) ||
  2029. + strstr(state->Hid, PCIE_PNP_ID)) {
  2030. //
  2031. // Was PCI.
  2032. //
  2033. @@ -1432,7 +1436,8 @@
  2034.  
  2035. if (state->Cid) {
  2036.  
  2037. - if (strstr(state->Cid, PCI_PNP_ID)) {
  2038. + if (strstr(state->Cid, PCI_PNP_ID) ||
  2039. + strstr(state->Cid, PCIE_PNP_ID)) {
  2040. //
  2041. // Was PCI.
  2042. //
  2043. @@ -1669,7 +1674,8 @@
  2044.  
  2045. if (state->Hid) {
  2046.  
  2047. - if (strstr(state->Hid, PCI_PNP_ID)) {
  2048. + if (strstr(state->Hid, PCI_PNP_ID) ||
  2049. + strstr(state->Hid, PCIE_PNP_ID)) {
  2050. //
  2051. // Was PCI.
  2052. //
  2053. @@ -1711,7 +1717,8 @@
  2054.  
  2055. if (state->Cid) {
  2056.  
  2057. - if (strstr(state->Cid, PCI_PNP_ID)) {
  2058. + if (strstr(state->Cid, PCI_PNP_ID) ||
  2059. + strstr(state->Cid, PCIE_PNP_ID)) {
  2060. //
  2061. // Was PCI.
  2062. //
  2063. diff --strip-trailing-cr -ur ./driver/nt/rangesup.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/rangesup.c"
  2064. --- ./driver/nt/rangesup.c 2002-09-02 18:22:24.000000000 +0500
  2065. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/rangesup.c" 2022-04-16 06:47:52.079101500 +0500
  2066. @@ -2311,9 +2311,11 @@
  2067. //
  2068. // Do we errors?
  2069. //
  2070. - if (bugCheck) {
  2071.  
  2072. - ACPIPrint( (
  2073. + if (0) { // BSOD 0xA5 (0x02, ...) workaround, ACPI vs E820 mem ranges conflict
  2074. + //if (bugCheck) {
  2075. +
  2076. + ACPIPrint( (
  2077. ACPI_PRINT_CRITICAL,
  2078. "ACPI:\n"
  2079. "ACPI: FATAL BIOS ERROR - Need new BIOS to fix PCI problems\n"
  2080. diff --strip-trailing-cr -ur ./driver/nt/root.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/root.c"
  2081. --- ./driver/nt/root.c 2002-09-02 18:22:24.000000000 +0500
  2082. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/root.c" 2022-04-16 06:47:52.089843700 +0500
  2083. @@ -142,8 +142,10 @@
  2084. --*/
  2085. {
  2086. PKEVENT event = (PKEVENT) Context;
  2087. -#if DBG
  2088. + // SP3
  2089. PDEVICE_EXTENSION deviceExtension = ACPIInternalGetDeviceExtension(DeviceObject);
  2090. + // SP3
  2091. +#if DBG
  2092. PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation( Irp );
  2093.  
  2094. if (deviceExtension != NULL) {
  2095. diff --strip-trailing-cr -ur ./driver/nt/wake.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/wake.c"
  2096. --- ./driver/nt/wake.c 2002-09-02 18:22:26.000000000 +0500
  2097. +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/wake.c" 2022-04-16 06:47:52.100585900 +0500
  2098. @@ -475,11 +475,6 @@
  2099. PNSOBJ pswObject = NULL;
  2100.  
  2101. //
  2102. - // Acquire the Spinlock
  2103. - //
  2104. - KeAcquireSpinLock( &AcpiPowerLock, &oldIrql );
  2105. -
  2106. - //
  2107. // Update the number of references on the device
  2108. //
  2109. if (Enable) {
  2110. @@ -595,6 +590,13 @@
  2111. pswContext->DeviceExtension = DeviceExtension;
  2112. pswContext->Count = 1;
  2113.  
  2114. + // SP3
  2115. + //
  2116. + // Acquire the Spinlock
  2117. + //
  2118. + KeAcquireSpinLock( &AcpiPowerLock, &oldIrql );
  2119. + // SP3
  2120. +
  2121. //
  2122. // Check to see if we are simply going to queue the context up, or
  2123. // call the interpreter
  2124. @@ -699,11 +701,6 @@
  2125. ACPIWakeEnableDisableAsyncExit:
  2126.  
  2127. //
  2128. - // Release the lock
  2129. - //
  2130. - KeReleaseSpinLock( &AcpiPowerLock, oldIrql );
  2131. -
  2132. - //
  2133. // What happened
  2134. //
  2135. ACPIDevPrint( (
  2136. Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/shared: obj
  2137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement