Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: MSG00001.bin
- Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: acpilog.h
- Only in c:\ACPI\ACPI_SP1\Base\busdrv\acpi/driver/amlinew: acpilog.rc
- diff --strip-trailing-cr -ur ./driver/amlinew/amlipriv.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlipriv.h"
- --- ./driver/amlinew/amlipriv.h 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlipriv.h" 2022-04-16 06:47:51.856445300 +0500
- @@ -285,6 +285,7 @@
- #define AMLISTA_CONTINUE 0x00008003
- #define AMLISTA_PENDING 0x00008004
- #define AMLISTA_TIMEOUT 0x00008005
- +#define AMLISTA_CONTINUEOP 0x00008006
- // Global AMLI flags
- #define AMLIF_LOCKED 0x00000001
- @@ -331,6 +332,7 @@
- #define ARGOBJ_BASICDATA 'D' //INTDATA,STRDATA,BUFFDATA
- #define ARGOBJ_COMPLEXDATA 'C' //BUFFDATA,PKGDATA
- #define ARGOBJ_REFERENCE 'R' //OBJALIAS,DATAALIAS,BUFFFIELD
- +#define ARGOBJ_STRBUFDATA 'T' //OBJTYPE_STRDATA/OBJTYPE_BUFFDATA
- #define MAX_BYTE 0xff
- #define MAX_WORD 0xffff
- @@ -368,7 +370,8 @@
- /*** Type and Structure definitions
- */
- -typedef NTSTATUS (LOCAL *PFNOP)(PFRAME, PPNSOBJ);
- +//typedef NTSTATUS (LOCAL *PFNOP)(PFRAME, PPNSOBJ);
- +typedef NTSTATUS (LOCAL *PFNOP)(PCTXT, PTERM);
- typedef struct _amlterm
- {
- diff --strip-trailing-cr -ur ./driver/amlinew/amlitest.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlitest.c"
- --- ./driver/amlinew/amlitest.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/amlitest.c" 2022-04-16 06:47:51.870117100 +0500
- @@ -52,22 +52,24 @@
- PCCHAR DebugMessage,
- ...)
- {
- + int index;
- va_list ap;
- va_start(ap, DebugMessage);
- -
- if(DebugPrintLevel & AmliTestDebugFlags)
- - {
- -
- -
- -
- - if(_vsnprintf(AmliTestDebugBuffer,
- + {
- + index = _vsnprintf(AmliTestDebugBuffer,
- 200,
- DebugMessage,
- - ap) == -1)
- + ap);
- + // SP3
- + if(index == -1)
- {
- - AmliTestDebugBuffer[199] = '\0';
- + AmliTestDebugBuffer[0] = '\0';
- + } else {
- + AmliTestDebugBuffer[index] = '\0';
- }
- + // SP3
- DbgPrint(AmliTestDebugBuffer);
- }
- diff --strip-trailing-cr -ur ./driver/amlinew/data.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/data.c"
- --- ./driver/amlinew/data.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/data.c" 2022-04-16 06:47:51.880859300 +0500
- @@ -188,6 +188,23 @@
- atToBCD = {"ToBCD", OP_TOBCD, "CS", C2, 0, NULL, 0, ExprOp1},
- atWait = {"Wait", OP_WAIT, "SC", C2, 0, NULL, 0, Wait},
- atXOr = {"XOr", OP_XOR, "CCS", C2, 0, NULL, 0, ExprOp2},
- +
- + // ACPI 2.0
- + atToBuffer = {"ToBuffer", OP_TOBUFFER, "CS", C2, 0, NULL, 0, ToBuffer},
- + atToDecString = {"ToDecimalString", OP_TODECSTRING, "CS", C2, 0, NULL, 0, ToDecimalString},
- + atToHexString = {"ToHexString", OP_TOHEXSTRING, "CS", C2, 0, NULL, 0, ToHexString},
- + atToInteger = {"ToInteger", OP_TOINTEGER, "CS", C2, 0, NULL, 0, ToInteger},
- + atQWordField = {"CreateQWordField", OP_QWORDFIELD, "CCN", OB, 0, NULL, 0, CreateQWordField},
- + atConcatRes = {"ConcatenateResTemplate", OP_CONCATRESTMPL, "CCS", C2, 0, NULL, 0, ConcatenateResTemplate},
- + atMod = {"Mod", OP_MOD, "CCS", C2, 0, NULL, 0, ExprOp2},
- + atToString = {"ToString", OP_TOSTRING, "CCS", C2, 0, NULL, 0, ToString},
- + atCopyObject = {"CopyObject", OP_COPYOBJECT, "CS", C2, 0, NULL, 0, CopyObject},
- + atMid = {"Mid", OP_MID, "CCCS", C2, 0, NULL, 0, MidString},
- + atContinue = {"Continue", OP_CONTINUE, NULL, C1, 0, NULL, 0, Continue},
- + atTimer = {"Timer", OP_TIMER , NULL, C2, 0, NULL, 0, Timer},
- + // OP_QWORD=0xE - see atDataObj
- +
- +
- //
- // Misc. Opcodes
- //
- @@ -206,7 +223,7 @@
- //0x08 0x09 0x0a 0x0b
- &atName, NULL, &atDataObj, &atDataObj,
- //0x0c 0x0d 0x0e 0x0f
- - &atDataObj, &atString, NULL, NULL,
- + &atDataObj, &atString, &atDataObj, NULL,
- //0x10 0x11 0x12 0x13
- &atScope, &atBuffer, &atPackage, NULL,
- //0x14 0x15 0x16 0x17
- @@ -266,19 +283,19 @@
- //0x80 0x81 0x82 0x83
- &atNot, &atFindSetLBit, &atFindSetRBit, &atDerefOf,
- //0x84 0x85 0x86 0x87
- - NULL, NULL, &atNotify, &atSizeOf,
- + &atConcatRes, &atMod, &atNotify, &atSizeOf,
- //0x88 0x89 0x8a 0x8b
- &atIndex, &atMatch, &atDWordField, &atWordField,
- //0x8c 0x8d 0x8e 0x8f
- - &atByteField, &atBitField, &atObjType, NULL,
- + &atByteField, &atBitField, &atObjType, &atQWordField,
- //0x90 0x91 0x92 0x93
- &atLAnd, &atLOr, &atLNot, &atLEq,
- //0x94 0x95 0x96 0x97
- - &atLG, &atLL, NULL, NULL,
- + &atLG, &atLL, &atToBuffer, &atToDecString,
- //0x98 0x99 0x9a 0x9b
- - NULL, NULL, NULL, NULL,
- + &atToHexString, &atToInteger, NULL, NULL,
- //0x9c 0x9d 0x9e 0x9f
- - NULL, NULL, NULL, NULL,
- + &atToString, &atCopyObject, &atMid, &atContinue,
- //0xa0 0xa1 0xa2 0xa3
- &atIf, &atElse, &atWhile, &atNOP,
- //0xa4 0xa5 0xa6 0xa7
- @@ -349,6 +366,7 @@
- EXOP_REVISION, &atDataObj,
- EXOP_DEBUG, &atDebugObj,
- EXOP_FATAL, &atFatal,
- + EXOP_TIMER, &atTimer,
- EXOP_OPREGION, &atOpRegion,
- EXOP_FIELD, &atField,
- EXOP_DEVICE, &atDevice,
- diff --strip-trailing-cr -ur ./driver/amlinew/misc.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/misc.c"
- --- ./driver/amlinew/misc.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/misc.c" 2022-04-16 06:47:51.891601500 +0500
- @@ -1327,6 +1327,17 @@
- }
- break;
- + case ARGOBJ_STRBUFDATA:
- + if ((pArgs[i].dwDataType != OBJTYPE_STRDATA) &&
- + (pArgs[i].dwDataType != OBJTYPE_BUFFDATA))
- + {
- + rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
- + ("ValidateArgTypes: expected Arg%d to be type str/buff (Type=%s)",
- + i,
- + GetObjectTypeName(pArgs[i].dwDataType)));
- + }
- + break;
- +
- default:
- rc = AMLI_LOGERR(AMLIERR_ASSERT_FAILED,
- ("ValidateArgTypes: internal error (invalid type - %c)",
- diff --strip-trailing-cr -ur ./driver/amlinew/object.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/object.c"
- --- ./driver/amlinew/object.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/object.c" 2022-04-16 06:47:51.904296800 +0500
- @@ -300,7 +300,7 @@
- ENTER(3, ("ReadField(pctxt=%x,pdataObj=%x,FieldDesc=%x,pdataResult=%x)\n",
- pctxt, pdataObj, pfd, pdataResult));
- - if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_DWORD)
- + if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_QWORD)
- {
- PUCHAR pb;
- ULONG dwcb;
- @@ -309,11 +309,11 @@
- {
- case OBJTYPE_UNKNOWN:
- if (!(pfd->dwFieldFlags & FDF_BUFFER_TYPE) &&
- - (pfd->dwNumBits <= sizeof(ULONG)*8))
- + (pfd->dwNumBits <= sizeof(ULONG64)*8)) // dwNumBits = 64 for QWORD field
- {
- pdataResult->dwDataType = OBJTYPE_INTDATA;
- pb = (PUCHAR)&pdataResult->uipDataValue;
- - dwcb = sizeof(ULONG);
- + dwcb = sizeof(ULONG); // ULONG64 ACPI 2.0
- }
- else
- {
- @@ -341,7 +341,7 @@
- case OBJTYPE_INTDATA:
- pb = (PUCHAR)&pdataResult->uipDataValue;
- - dwcb = sizeof(ULONG);
- + dwcb = sizeof(ULONG); // acpi 2.0: sizeof(ULONG64)
- break;
- case OBJTYPE_STRDATA:
- @@ -410,14 +410,14 @@
- ENTER(3, ("WriteField(pctxt=%x,pdataObj=%x,FieldDesc=%x,pdataSrc=%x)\n",
- pctxt, pdataObj, pfd, pdataSrc));
- - if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_DWORD)
- + if ((pfd->dwFieldFlags & ACCTYPE_MASK) <= ACCTYPE_QWORD)
- {
- PWRFIELDLOOP pwfl;
- switch (pdataSrc->dwDataType)
- {
- case OBJTYPE_INTDATA:
- - dwBuffSize = MIN(sizeof(ULONG), dwDataInc);
- + dwBuffSize = MIN(sizeof(ULONG), dwDataInc); // ULONG64 for Integer64
- pbBuff = (PUCHAR)&pdataSrc->uipDataValue;
- break;
- diff --strip-trailing-cr -ur ./driver/amlinew/parser.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/parser.c"
- --- ./driver/amlinew/parser.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/parser.c" 2022-04-16 06:47:51.915039000 +0500
- @@ -30,7 +30,9 @@
- NTSTATUS LOCAL ParseScope(PCTXT pctxt, PSCOPE pscope, NTSTATUS rc)
- {
- TRACENAME("PARSESCOPE")
- - ULONG dwStage = ((rc == STATUS_SUCCESS) || (rc == AMLISTA_BREAK))?
- + ULONG dwStage = ((rc == STATUS_SUCCESS) ||
- + (rc == AMLISTA_BREAK) ||
- + (rc == AMLISTA_CONTINUEOP))?
- (pscope->FrameHdr.dwfFrame & FRAMEF_STAGE_MASK): 2;
- ENTER(2, ("ParseScope(Stage=%d,pctxt=%p,pbOp=%p,pscope=%p,rc=%x)\n",
- @@ -67,9 +69,24 @@
- if (rc == AMLISTA_BREAK)
- {
- pctxt->pbOp = pscope->pbOpEnd;
- - rc = STATUS_SUCCESS;
- - }
- - else
- +
- + // SP3
- + pscope->pbOpRet = pscope->pbOpEnd;
- + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
- + rc = STATUS_SUCCESS;
- + }
- + // SP3
- + } else
- + if (rc == AMLISTA_CONTINUEOP)
- + {
- + pctxt->pbOp = pscope->pbOpEnd;
- +
- + // SP3
- + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
- + rc = STATUS_SUCCESS;
- + }
- + // SP3
- + } else
- {
- while (pctxt->pbOp < pscope->pbOpEnd)
- {
- @@ -113,7 +130,23 @@
- if (rc == AMLISTA_BREAK)
- {
- pctxt->pbOp = pscope->pbOpEnd;
- - rc = STATUS_SUCCESS;
- +
- + // SP3
- + pscope->pbOpRet = pscope->pbOpEnd;
- + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
- + rc = STATUS_SUCCESS;
- + }
- + // SP3
- + }
- + else if (rc == AMLISTA_CONTINUEOP)
- + {
- + pctxt->pbOp = pscope->pbOpEnd;
- +
- + // SP3
- + if (pscope->FrameHdr.dwfFrame & CALLF_ACQ_MUTEX) { // test byte ptr [esi+0Ah], 2
- + rc = STATUS_SUCCESS;
- + }
- + // SP3
- }
- else if ((rc == AMLISTA_PENDING) ||
- (&pscope->FrameHdr !=
- @@ -1311,6 +1344,18 @@
- #ifdef DEBUGGER
- if (gDebugger.dwfDebugger &
- (DBGF_AMLTRACE_ON | DBGF_STEP_MODES))
- + {
- + PRINTF("0x%x", pdataResult->uipDataValue);
- + }
- + #endif
- + break;
- +
- + case OP_QWORD:
- + MEMCPY(&pdataResult->uipDataValue, *ppbOp, sizeof(ULONG)); // ignores high 4 bytes
- + (*ppbOp) += sizeof(ULONG64);
- + #ifdef DEBUGGER
- + if (gDebugger.dwfDebugger &
- + (DBGF_AMLTRACE_ON | DBGF_STEP_MODES))
- {
- PRINTF("0x%x", pdataResult->uipDataValue);
- }
- diff --strip-trailing-cr -ur ./driver/amlinew/proto.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/proto.h"
- --- ./driver/amlinew/proto.h 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/proto.h" 2022-04-16 06:47:51.925781200 +0500
- @@ -150,6 +150,20 @@
- BOOLEAN LOCAL MatchData(ULONG dwPkgData, ULONG dwOp, ULONG dwData);
- NTSTATUS LOCAL OSInterface(PCTXT pctxt, PTERM pterm);
- +// ACPI 2.0
- +NTSTATUS LOCAL ToInteger(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL ToHexString(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL ToDecimalString(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL ToBuffer(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL CreateQWordField(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL ConcatenateResTemplate(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL Mod(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL ToString(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL CopyObject(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL MidString(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL Continue(PCTXT pctxt, PTERM pterm);
- +NTSTATUS LOCAL Timer(PCTXT pctxt, PTERM pterm);
- +
- //object.c
- NTSTATUS LOCAL ReadObject(PCTXT pctxt, POBJDATA pdataObj, POBJDATA pdataResult);
- NTSTATUS LOCAL WriteObject(PCTXT pctxt, POBJDATA pdataObj, POBJDATA pdataSrc);
- diff --strip-trailing-cr -ur ./driver/amlinew/type1op.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type1op.c"
- --- ./driver/amlinew/type1op.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type1op.c" 2022-04-16 06:47:51.935546800 +0500
- @@ -581,6 +581,11 @@
- rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, pterm->pbOpTerm,
- pctxt->pnsScope, pctxt->powner, pctxt->pheapCurrent,
- pterm->pdataResult);
- + // SP3
- + if (!rc) {
- + ((PFRAMEHDR)pctxt->LocalHeap.pbHeapEnd)->dwfFrame |= CALLF_ACQ_MUTEX;
- + }
- + // SP3
- }
- }
- diff --strip-trailing-cr -ur ./driver/amlinew/type2op.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type2op.c"
- --- ./driver/amlinew/type2op.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/amlinew/type2op.c" 2022-04-16 06:47:51.953125000 +0500
- @@ -9,6 +9,11 @@
- #include "pch.h"
- +_CRTIMP unsigned __int64 __cdecl _strtoui64(
- + const char * _String,
- + char ** _EndPtr,
- + int _Radix);
- +
- #ifdef LOCKABLE_PRAGMA
- #pragma ACPI_LOCKABLE_DATA
- #pragma ACPI_LOCKABLE_CODE
- @@ -28,6 +33,7 @@
- NTSTATUS LOCAL Buffer(PCTXT pctxt, PTERM pterm)
- {
- + USHORT* wIOBuf;
- TRACENAME("BUFFER")
- NTSTATUS rc = STATUS_SUCCESS;
- ULONG dwInitSize = (ULONG)(pterm->pbOpEnd - pctxt->pbOp);
- @@ -73,6 +79,34 @@
- pterm->pdataResult->dwDataLen);
- MEMCPY(pterm->pdataResult->pbDataBuff, pctxt->pbOp, dwInitSize);
- pctxt->pbOp = pterm->pbOpEnd;
- +
- + /* IOTRAPS range 0xFF00-0xFFFF vs VGA (10-bit decode!) conflict workaround
- + Device (IOTR)
- + {
- + ...
- + Name (BUF0, ResourceTemplate ()
- + {
- + IO (Decode16,
- + 0x0000, // Range Minimum
- + 0x0000, // Range Maximum
- + 0x01, // Alignment
- + 0xFF, // Length > 1
- + _Y21)
- + }) binary: 11 0D 0A _47 01 00 00 00 00 01 FF 79 00_
- + ...
- + }
- + */
- +
- + if (dwInitSize == 10) {
- + wIOBuf = (USHORT*) pterm->pdataResult->pbDataBuff;
- + if (wIOBuf[0] == 0x0147 &&
- + wIOBuf[1] == 0x0000 &&
- + wIOBuf[2] == 0x0000 &&
- + wIOBuf[3] == 0xFF01 &&
- + wIOBuf[4] == 0x0079 ) {
- + pterm->pdataResult->pbDataBuff[7] = 1; // limit range to one adress
- + }
- + }
- }
- }
- @@ -704,6 +738,15 @@
- pterm->pdataArgs[1].uipDataValue;
- EXIT(2, ("XOr=%x (Result=%x)\n",
- rc, pterm->pdataResult->uipDataValue));
- + case OP_MOD:
- + ENTER(2, ("Mod(Value1=%x,Value2=%x)\n",
- + pterm->pdataArgs[0].uipDataValue,
- + pterm->pdataArgs[1].uipDataValue));
- + pterm->pdataResult->uipDataValue =
- + pterm->pdataArgs[0].uipDataValue %
- + pterm->pdataArgs[1].uipDataValue;
- + EXIT(2, ("Mod=%x (Result=%x)\n",
- + rc, pterm->pdataResult->uipDataValue));
- }
- rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- @@ -1528,10 +1571,12 @@
- char Win2000[] = "Windows 2000";
- char Win2001[] = "Windows 2001";
- char Win2001SP1[] = "Windows 2001 SP1";
- + char Win2001SP2[] = "Windows 2001 SP2";
- char* SupportedOSList[] = {
- Win2000,
- Win2001,
- - Win2001SP1
- + Win2001SP1,
- + Win2001SP2
- };
- ULONG ListSize = sizeof(SupportedOSList) / sizeof(char*);
- ULONG i = 0;
- @@ -1558,8 +1603,7 @@
- // 0 == Windows 2000
- // 1 == Windows 2001
- // 2 == Windows 2001 SP1
- - // .
- - // .
- + // 3 == Windows 2001 SP2
- //
- if(gdwHighestOSVerQueried < i)
- {
- @@ -1577,3 +1621,837 @@
- } //OSInterface
- +
- +///////////////////////////////////////////////
- +// ACPI 2.0
- +
- +
- +NTSTATUS LOCAL ConvertToInteger(POBJDATA In, POBJDATA Out) {
- + ULONG dwDataLen;
- + OBJDATA data;
- +
- + MEMZERO(&data, sizeof(data));
- + data.dwDataType = OBJTYPE_INTDATA;
- + switch (In->dwDataType) {
- + case OBJTYPE_INTDATA:
- + data.dwDataValue = In->dwDataValue;
- +
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + return STATUS_SUCCESS;
- + break;
- + case OBJTYPE_STRDATA:
- + data.dwDataValue = StrToUL((PSZ)In->pbDataBuff, NULL, 0);
- +
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + return STATUS_SUCCESS;
- + break;
- + case OBJTYPE_BUFFDATA:
- + dwDataLen = In->dwDataLen;
- + if (dwDataLen > 4) // 8 - int64
- + dwDataLen = 4;
- + MEMCPY(&data.dwDataValue, In->pbDataBuff, dwDataLen);
- +
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + return STATUS_SUCCESS;
- + break;
- + default:
- + return AMLIERR_UNEXPECTED_OBJTYPE;
- + break;
- + }
- +}
- +
- +
- +NTSTATUS LOCAL ToInteger(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + TRACENAME("TOINTEGER")
- + ENTER(2, ("ToInteger(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + if ((rc = ConvertToInteger(pterm->pdataArgs, pterm->pdataResult)) == STATUS_SUCCESS)
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- +
- + EXIT(2, ("ToInteger=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +char HTOALookupTable[]="0123456789ABCDEF";
- +
- +
- +NTSTATUS LOCAL ToHexString(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + int StrLen;
- + POBJDATA In = pterm->pdataArgs;
- + POBJDATA Out = pterm->pdataResult;
- + ULONG int32;
- + ULONG SrcIdx;
- + int i;
- + UCHAR pair;
- + TRACENAME("TOHEXSTRING")
- + ENTER(2, ("ToHexString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + StrLen = 2;
- + Out->dwDataType = OBJTYPE_STRDATA;
- + switch (In->dwDataType) {
- + case OBJTYPE_INTDATA:
- + int32 = In->dwDataValue;
- + do {
- + int32 >>= 4;
- + ++StrLen;
- + } while (int32);
- +
- + Out->dwDataLen = StrLen + 1;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToHexString: failed to allocate target buffer"));
- + } else {
- + Out->pbDataBuff[0] = '0';
- + Out->pbDataBuff[1] = 'x';
- + int32 = In->dwDataValue;
- + for (i = StrLen - 1; i >= 2; --i) {
- + Out->pbDataBuff[i] = HTOALookupTable[int32 & 0xF];
- + int32 >>= 4;
- + }
- +
- + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + case OBJTYPE_STRDATA:
- + Out->dwDataLen = In->dwDataLen;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToHexString: failed to allocate target buffer"));
- + } else {
- + MEMCPY(Out->pbDataBuff, In->pbDataBuff, Out->dwDataLen);
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + case OBJTYPE_BUFFDATA:
- + Out->dwDataLen = 5 * In->dwDataLen;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToHexString: failed to allocate target buffer"));
- + } else {
- + i = 0;
- + if (In->dwDataLen) {
- + for (SrcIdx = 0; SrcIdx < In->dwDataLen; SrcIdx++) {
- + Out->pbDataBuff[i] = '0';
- + Out->pbDataBuff[i+1] = 'x';
- + pair = In->pbDataBuff[SrcIdx];
- + Out->pbDataBuff[i+2] = HTOALookupTable[pair >> 4];
- + Out->pbDataBuff[i+3] = HTOALookupTable[pair & 0xF];
- + Out->pbDataBuff[i+4] = ',';
- + i += 5;
- + }
- + }
- +
- + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + default:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToHexString: invalid arg0 type"));
- + break;
- + }
- + }
- +
- + EXIT(2, ("ToHexString=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL ConvertToBuffer(POBJDATA In, POBJDATA Out) {
- + OBJDATA data;
- + int Len;
- + int i;
- + ULONG int32;
- + NTSTATUS rc = STATUS_SUCCESS;
- +
- + MEMZERO(&data, sizeof(data));
- + data.dwDataType = OBJTYPE_BUFFDATA;
- + switch (In->dwDataType) {
- + case OBJTYPE_INTDATA:
- + int32 = In->dwDataValue;
- + Len = 4;
- +
- + data.dwDataLen = Len;
- + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Len);
- + if (data.pbDataBuff == NULL) {
- + rc = AMLIERR_OUT_OF_MEM;
- + } else {
- + for (i = 0; i < Len; i++) {
- + data.pbDataBuff[i] = (UCHAR) int32;
- + int32 >>= 8;
- + }
- +
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + }
- + break;
- + case OBJTYPE_STRDATA:
- + case OBJTYPE_BUFFDATA:
- + Len = In->dwDataLen;
- + data.dwDataLen = Len;
- +
- + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Len);
- + if (data.pbDataBuff == NULL) {
- + rc = AMLIERR_OUT_OF_MEM;
- + } else {
- + MEMCPY(data.pbDataBuff, In->pbDataBuff, Len);
- +
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + }
- + break;
- + default:
- + rc = AMLIERR_UNEXPECTED_OBJTYPE;
- + break;
- + }
- +
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL ToBuffer(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + TRACENAME("TOBUFFER")
- + ENTER(2, ("ToBuffer(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + if ((rc = ConvertToBuffer(pterm->pdataArgs, pterm->pdataResult)) == STATUS_SUCCESS)
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- +
- + EXIT(2, ("ToBuffer=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL ToDecimalString(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + POBJDATA In = pterm->pdataArgs;
- + POBJDATA Out = pterm->pdataResult;
- + ULONG int32;
- + ULONG StrLen;
- + int SrcBufLen;
- + ULONG SrcIdx;
- + int i;
- + int j;
- + UCHAR number;
- + TRACENAME("TODECSTRING")
- + ENTER(2, ("ToDecimalString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "D")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + Out->dwDataType = OBJTYPE_STRDATA;
- + switch (In->dwDataType) {
- + case OBJTYPE_INTDATA:
- + int32 = In->dwDataValue;
- + StrLen = 0;
- + do {
- + int32 /= 10;
- + ++StrLen;
- + } while (int32);
- +
- + Out->dwDataLen = StrLen + 1;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToDecimalString: failed to allocate target buffer"));
- + } else {
- + int32 = In->dwDataValue;
- + if (StrLen >= 1) {
- + for (i = StrLen - 1; i >= 0; --i) {
- + Out->pbDataBuff[i] = HTOALookupTable[int32 % 10];
- + int32 /= 10;
- + }
- + }
- +
- + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + case OBJTYPE_STRDATA:
- + Out->dwDataLen = In->dwDataLen;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToDecimalString: failed to allocate target buffer"));
- + } else {
- + MEMCPY(Out->pbDataBuff, In->pbDataBuff, Out->dwDataLen);
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + case OBJTYPE_BUFFDATA:
- + SrcBufLen = In->dwDataLen;
- + StrLen = SrcBufLen - 1;
- + if (SrcBufLen) {
- + for (i = 0; i < SrcBufLen; i++) {
- + number = In->pbDataBuff[i];
- + if (number >= 10) {
- + if (number >= 100)
- + StrLen += 3;
- + else
- + StrLen += 2;
- + } else {
- + StrLen++;
- + }
- + }
- + }
- +
- + Out->dwDataLen = StrLen + 1;
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, Out->dwDataLen);
- +
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToDecimalString: failed to allocate target buffer"));
- + } else {
- + j = 0; // result buffer index
- + for ( SrcIdx = 0; SrcIdx < In->dwDataLen; SrcIdx++ ) {
- + number = In->pbDataBuff[SrcIdx];
- + if (number >= 10) {
- + if (number >= 100)
- + Out->pbDataBuff[j++] = HTOALookupTable[(number / 100) % 10]; // 2xx
- +
- + Out->pbDataBuff[j++] = HTOALookupTable[(number / 10) % 10]; // x2x
- + Out->pbDataBuff[j++] = HTOALookupTable[number % 10]; // xx2
- + } else {
- + Out->pbDataBuff[j++] = HTOALookupTable[number];
- + }
- + Out->pbDataBuff[j++] = ',';
- + }
- +
- + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + break;
- + default:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToDecimalString: invalid arg0 type"));
- + break;
- + }
- + }
- +
- + EXIT(2, ("ToDecimalString=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL CreateQWordField(PCTXT pctxt, PTERM pterm)
- +{
- + TRACENAME("CREATEQWORDFIELD")
- + NTSTATUS rc = STATUS_SUCCESS;
- + PBUFFFIELDOBJ pbf;
- + ENTER(2, ("CreateQWordField(pctxt=%x,pbOp=%x,pterm=%x)\n",
- + pctxt, pctxt->pbOp, pterm));
- +
- + if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
- + STATUS_SUCCESS)
- + {
- + pbf->FieldDesc.dwByteOffset = (ULONG)pterm->pdataArgs[1].uipDataValue;
- + pbf->FieldDesc.dwStartBitPos = 0;
- + pbf->FieldDesc.dwNumBits = 8*sizeof(ULONG); // 8*sizeof(ULONG64) ACPI 2.0
- + pbf->FieldDesc.dwFieldFlags = ACCTYPE_DWORD; // ACCTYPE_QWORD ACPI 2.0
- + }
- +
- + EXIT(2, ("CreateQWordField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
- + return rc;
- +}
- +
- +
- +UCHAR LOCAL ComputeDataChkSum(UCHAR *Buffer, int Len) {
- + UCHAR checksum = 0;
- +
- + for ( ; Len; --Len ) {
- + checksum += *Buffer;
- + Buffer++;
- + }
- +
- + return -(checksum);
- +}
- +
- +
- +NTSTATUS LOCAL ConcatenateResTemplate(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + POBJDATA In = pterm->pdataArgs;
- + POBJDATA Out = pterm->pdataResult;
- + ULONG i,j;
- + ULONG NewLength;
- + TRACENAME("CONCATENATERESTEMPLATE")
- + ENTER(2, ("ConcatenateResTemplate(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "BB")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[2], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + if (In[0].dwDataLen <= 1 || In[1].dwDataLen <= 1 ) {
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ConcatenateResTemplate: arg0 or arg1 has length <= 1"));
- + } else {
- + Out->dwDataType = OBJTYPE_BUFFDATA;
- + NewLength = In[0].dwDataLen + In[1].dwDataLen - 2;
- + Out->dwDataLen = NewLength;
- +
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength);
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ConcatenateResTemplate: failed to allocate target buffer"));
- + } else {
- + j = 0;
- +
- + i = 0;
- + if (In[0].dwDataLen != 2) {
- + do {
- + Out->pbDataBuff[j++] = In[0].pbDataBuff[i++];
- + } while (i < In[0].dwDataLen - 2);
- + }
- +
- + i = 0;
- + if (In[1].dwDataLen != 2) {
- + do {
- + Out->pbDataBuff[j++] = In[1].pbDataBuff[i++];
- + } while (i < In[1].dwDataLen - 2);
- + }
- +
- + Out->pbDataBuff[j++] = 0x79; //EndTag
- + Out->pbDataBuff[j] = ComputeDataChkSum(Out->pbDataBuff, NewLength - 1);
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- +
- + }
- + }
- +
- + EXIT(2, ("ConcatenateResTemplate=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +size_t LOCAL strnlen(const char *Str, size_t MaxCount)
- +{
- + size_t result;
- +
- + for (result = 0; result < MaxCount; ++Str) {
- + if (!*Str)
- + break;
- +
- + result++;
- + }
- + return result;
- +}
- +
- +
- +#define STRSAFE_MAX_CCH 2147483647
- +
- +// ntstrsafe.c
- +NTSTATUS RtlStringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList)
- +{
- + NTSTATUS status = STATUS_SUCCESS;
- +
- + if (cchDest == 0)
- + {
- + // can not null terminate a zero-byte dest buffer
- + status = STATUS_INVALID_PARAMETER;
- + }
- + else
- + {
- + int iRet;
- + size_t cchMax;
- +
- + // leave the last space for the null terminator
- + cchMax = cchDest - 1;
- +
- + iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList);
- +
- + if ((iRet < 0) || (((size_t)iRet) > cchMax))
- + {
- + // need to null terminate the string
- + pszDest += cchMax;
- + *pszDest = '\0';
- +
- + // we have truncated pszDest
- + status = STATUS_BUFFER_OVERFLOW;
- + }
- + else if (((size_t)iRet) == cchMax)
- + {
- + // need to null terminate the string
- + pszDest += cchMax;
- + *pszDest = '\0';
- + }
- + }
- +
- + return status;
- +}
- +
- +
- +// ntstrsafe.c
- +NTSTATUS RtlStringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...)
- +{
- + NTSTATUS status;
- +
- + if (cchDest > STRSAFE_MAX_CCH)
- + {
- + status = STATUS_INVALID_PARAMETER;
- + }
- + else
- + {
- + va_list argList;
- +
- + va_start(argList, pszFormat);
- +
- + status = RtlStringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
- +
- + va_end(argList);
- + }
- +
- + return status;
- +}
- +
- +
- +NTSTATUS LOCAL ConvertToString(POBJDATA In, ULONG MaxLen, POBJDATA Out)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + ULONG StrLen = MaxLen;
- + char TmpBuf[9]; // 17 ACPI 2.0
- + OBJDATA data;
- + ULONG BufLen;
- + ULONG InStrLen;
- +
- + MEMZERO(&TmpBuf, sizeof(TmpBuf));
- + MEMZERO(&data, sizeof(data));
- + data.dwDataType = OBJTYPE_STRDATA;
- +
- + switch (In->dwDataType) {
- + case OBJTYPE_INTDATA:
- + BufLen = 9;
- + RtlStringCchPrintfA(TmpBuf, 9, "%x", In->dwDataValue);
- + if (!MaxLen || MaxLen >= BufLen)
- + StrLen = strnlen(TmpBuf, BufLen);
- + data.dwDataLen = StrLen + 1;
- +
- + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
- + if (data.pbDataBuff == NULL) {
- + rc = STATUS_INSUFFICIENT_RESOURCES;
- + } else {
- + MEMCPY(data.pbDataBuff, TmpBuf, data.dwDataLen);
- + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + }
- + break;
- + case OBJTYPE_STRDATA:
- + if (MaxLen > In->dwDataLen - 1)
- + rc = STATUS_ACPI_FATAL;
- + else {
- + if (!MaxLen)
- + StrLen = In->dwDataLen - 1;
- + data.dwDataLen = StrLen + 1;
- +
- + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
- + if (data.pbDataBuff == NULL) {
- + rc = STATUS_INSUFFICIENT_RESOURCES;
- + } else {
- + MEMCPY(data.pbDataBuff, In->pbDataBuff, data.dwDataLen);
- + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + }
- + }
- + break;
- + case OBJTYPE_BUFFDATA:
- + InStrLen = In->dwDataLen;
- + if (InStrLen >= 201)
- + InStrLen = 201;
- + if (!MaxLen) {
- + StrLen = strnlen((PCHAR)In->pbDataBuff, InStrLen);
- + if (StrLen == InStrLen)
- + return STATUS_INVALID_BUFFER_SIZE;
- + } else {
- + if (MaxLen > InStrLen || MaxLen > 200)
- + return STATUS_ACPI_FATAL;
- + }
- +
- + data.dwDataLen = StrLen + 1;
- + data.pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, data.dwDataLen);
- + if (data.pbDataBuff == NULL) {
- + rc = STATUS_INSUFFICIENT_RESOURCES;
- + } else {
- + MEMCPY(data.pbDataBuff, In->pbDataBuff, data.dwDataLen - 1);
- + data.pbDataBuff[data.dwDataLen - 1] = '\0'; // ending zero
- + FreeDataBuffs(Out, 1);
- + MEMCPY(Out, &data, sizeof(data));
- + }
- + break;
- + default:
- + rc = STATUS_ACPI_INVALID_OBJTYPE;
- + }
- +
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL ToString(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA pdata;
- + ULONG MaxLen;
- + TRACENAME("TOSTRING")
- + ENTER(2, ("ToString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if ( pterm->icArgs == 2 &&
- + ((rc = ValidateArgTypes(pterm->pdataArgs, "B")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[1], OBJTYPE_DATA, &pdata)) == STATUS_SUCCESS) ) {
- + rc = ConvertToString(pterm->pdataArgs, 0, pterm->pdataResult);
- +
- + switch (rc) {
- + case STATUS_INSUFFICIENT_RESOURCES:
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToString: failed to allocate target buffer"));
- + break;
- + case STATUS_INVALID_BUFFER_SIZE:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToString: buffer length exceeds maximum value"));
- + break;
- + case STATUS_ACPI_FATAL:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToString: length specified exceeds input buffer length or maximum value"));
- + break;
- + }
- + } else
- + if ( pterm->icArgs == 3 &&
- + ((rc = ValidateArgTypes(pterm->pdataArgs, "BI")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[2], OBJTYPE_DATA, &pdata)) == STATUS_SUCCESS) ) {
- + MaxLen = pterm->pdataArgs[1].dwDataValue;
- + if (MaxLen != 0 &&
- + MaxLen != 0xFFFFFFFF) {
- + rc = ConvertToString(pterm->pdataArgs, MaxLen, pterm->pdataResult);
- + } else {
- + rc = ConvertToString(pterm->pdataArgs, 0, pterm->pdataResult);
- + }
- +
- + switch (rc) {
- + case STATUS_INSUFFICIENT_RESOURCES:
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("ToString: failed to allocate target buffer"));
- + break;
- + case STATUS_INVALID_BUFFER_SIZE:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToString: buffer length exceeds maximum value"));
- + break;
- + case STATUS_ACPI_FATAL:
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToString: length specified exceeds input buffer length or maximum value"));
- + break;
- + }
- + } else {
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("ToString: invalid # of arguments: %x", pterm->icArgs));
- + }
- +
- + EXIT(2, ("ToString=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL CopyObject(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA In = pterm->pdataArgs;
- + POBJDATA Out = pterm->pdataResult;
- + POBJDATA pdata;
- + BOOLEAN bWrite;
- + TRACENAME("COPYOBJECT")
- + ENTER(2, ("CopyObject(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + bWrite = FALSE;
- + rc = ValidateTarget(&pterm->pdataArgs[1], 0, &pdata);
- + if (rc) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("CopyObject: failed because target object is not a supername"));
- + } else {
- + if (MatchObjType(pdata->dwDataType, OBJTYPE_DATAFIELD)) {
- + if (In->dwDataType != OBJTYPE_INTDATA &&
- + In->dwDataType != OBJTYPE_BUFFDATA)
- + {
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("CopyObject: Only Integer and Buffer data can be copied to a Field unit or Buffer Field"));
- + goto Exit;
- + }
- + bWrite = TRUE;
- + }
- +
- + MoveObjData(Out, In);
- + if (bWrite)
- + rc = WriteObject(pctxt, pdata, Out);
- + else
- + rc = DupObjData(gpheapGlobal, pdata, Out);
- +
- + if (rc) {
- + AMLI_LOGERR(rc,
- + ("CopyObject: failed to duplicate objdata"));
- + }
- + }
- +
- +Exit:
- + EXIT(2, ("CopyObject=%x (type=%s,value=%I64x,buff=%x,len=%x)\n",
- + rc,
- + GetObjectTypeName(In->dwDataType),
- + In->dwDataValue,
- + In->pbDataBuff,
- + In->dwDataLen));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL MidString(PCTXT pctxt, PTERM pterm)
- +{
- + NTSTATUS rc = STATUS_SUCCESS;
- + POBJDATA In = pterm->pdataArgs;
- + POBJDATA Out = pterm->pdataResult;
- + POBJDATA pdata;
- + ULONG DataLen, NewLength;
- + ULONG MidIndex, MidSize;
- + ULONG i,j;
- + TRACENAME("MID")
- + ENTER(2, ("MidString(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + if (((rc = ValidateArgTypes(pterm->pdataArgs, "TII")) == STATUS_SUCCESS) &&
- + ((rc = ValidateTarget(&pterm->pdataArgs[3], OBJTYPE_DATAOBJ, &pdata)) == STATUS_SUCCESS)) {
- + if (In->dwDataType > OBJTYPE_BUFFDATA) {
- + rc = AMLI_LOGERR(AMLIERR_FATAL,
- + ("Mid: invalid arg0 type"));
- + } else {
- + Out->dwDataType = In->dwDataType;
- + DataLen = In->dwDataLen;
- + MidIndex = In[1].dwDataValue;
- + MidSize = In[2].dwDataValue;
- + if (MidIndex < DataLen) {
- + NewLength = MidSize;
- +
- + if (Out->dwDataType == OBJTYPE_STRDATA) {
- + DataLen--; // exclude ending zero
- + if ((MidIndex + MidSize) > DataLen)
- + NewLength = DataLen - MidIndex;
- +
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength + 1);
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("Mid: failed to allocate target string"));
- + } else {
- + Out->dwDataLen = NewLength + 1;
- + Out->pbDataBuff[Out->dwDataLen - 1] = '\0'; // ending zero
- + }
- + } else {
- + if ( Out->dwDataType != OBJTYPE_BUFFDATA ) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("Mid: pterm->pdataResult->dwDataType != OBJTYPE_BUFFDATA"));
- + } else {
- + if ((MidIndex + MidSize) > DataLen)
- + NewLength = DataLen - MidIndex;
- +
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, NewLength);
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("Mid: failed to allocate target string"));
- + } else {
- + Out->dwDataLen = NewLength;
- + }
- + }
- + }
- +
- + if (!rc) {
- + i = MidIndex;
- + j = 0;
- + if (NewLength) {
- + do {
- + Out->pbDataBuff[j++] = In->pbDataBuff[i++];
- + } while (j < NewLength);
- + }
- +
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + } else { // MidIndex >= DataLen, set len = 0
- + if (In->dwDataType == OBJTYPE_STRDATA) {
- + Out->pbDataBuff = (PUCHAR) NEWSDOBJ(gpheapGlobal, 1);
- + if (Out->pbDataBuff == NULL) {
- + rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
- + ("Mid: failed to allocate target string"));
- + } else {
- + Out->pbDataBuff[0] = '\0'; // ending zero
- + Out->dwDataLen = 1;
- +
- + rc = WriteObject(pctxt, pdata, pterm->pdataResult);
- + }
- + }
- + }
- + }
- + }
- +
- + EXIT(2, ("MidString=%x (Result=%x)\n", rc, pterm->pdataResult));
- + return rc;
- +}
- +
- +
- +NTSTATUS LOCAL Continue(PCTXT pctxt, PTERM pterm)
- +{
- + TRACENAME("CONTINUE")
- + ENTER(2, ("Continue(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
- +
- + ;
- +
- + EXIT(2, ("Continue=%x\n", AMLISTA_CONTINUEOP));
- + return AMLISTA_CONTINUEOP;
- +}
- +
- +
- +NTSTATUS LOCAL Timer(PCTXT pctxt, PTERM pterm)
- +{
- + TRACENAME("TIMER")
- + ENTER(2, ("Timer(pctxt=%x,pbOp=%x,pterm=%x, Querying for %s)\n",
- + pctxt,
- + pctxt->pbOp,
- + pterm,
- + pterm->pdataArgs->pbDataBuff));
- +
- + pterm->pdataResult->dwDataType = 1;
- + pterm->pdataResult->dwDataValue = (ULONG)KeQueryInterruptTime();
- +
- + EXIT(2, ("Timer=%x (pnsObj=%x)\n", 0, pterm->pnsObj));
- + return AMLIERR_NONE;
- +}
- +
- +
- + /*
- + __asm {
- + L1: jmp L1
- + }
- + */
- +
- +
- +// ACPI 2.0
- +///////////////////////////////////////////////
- \ No newline at end of file
- diff --strip-trailing-cr -ur ./driver/inc/aml.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/inc/aml.h"
- --- ./driver/inc/aml.h 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/inc/aml.h" 2022-04-16 06:47:51.964843700 +0500
- @@ -90,6 +90,23 @@
- #define OP_LEQ 0x93
- #define OP_LG 0x94
- #define OP_LL 0x95
- +
- +// Win7 ACPI 2.0
- +#define OP_QWORD 0x0e
- +#define OP_CONCATRESTMPL 0x84
- +#define OP_MOD 0x85
- +#define OP_QWORDFIELD 0x8f
- +#define OP_TOBUFFER 0x96
- +#define OP_TODECSTRING 0x97
- +#define OP_TOHEXSTRING 0x98
- +#define OP_TOINTEGER 0x99
- +#define OP_TOSTRING 0x9c
- +#define OP_COPYOBJECT 0x9d
- +#define OP_MID 0x9e
- +#define OP_CONTINUE 0x9f
- +#define EXOP_TIMER 0x33
- +#define OP_TIMER EXOP(EXOP_TIMER) // 5B33
- +
- #define OP_IF 0xa0
- #define OP_ELSE 0xa1
- #define OP_WHILE 0xa2
- @@ -173,12 +190,12 @@
- #define UPDATERULE_WRITEASZEROS 0x40 //WriteAsZeros
- #define ACCATTRIB_MASK 0xff00
- +
- //
- -// Returns 1, 2 or 4 for BYTE, WORD or DWORD respectively and returns 1 for
- -// any other sizes.
- -//
- +// Returns 1, 2 or 4 for BYTE, WORD or DWORD respectively and returns 1 for any other sizes.
- +// ACPI 2.0: return 8 for QWORD
- #define ACCSIZE(f) (((((f) & ACCTYPE_MASK) >= ACCTYPE_BYTE) && \
- - (((f) & ACCTYPE_MASK) <= ACCTYPE_DWORD))? \
- + (((f) & ACCTYPE_MASK) <= ACCTYPE_QWORD))? \
- (1 << (((f) & ACCTYPE_MASK) - 1)): 1)
- /*** Operation region space
- diff --strip-trailing-cr -ur ./driver/nt/acpiosnt.rc "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/acpiosnt.rc"
- --- ./driver/nt/acpiosnt.rc 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/acpiosnt.rc" 2022-04-16 06:47:51.973632800 +0500
- @@ -1,9 +1,12 @@
- #include <windows.h>
- #include <ntverp.h>
- +#define VER_FILEVERSION 5,1,2600,7777
- +#define VER_FILEVERSION_STR "5,1,2600,7777"
- +
- #define VER_FILETYPE VFT_DRV
- #define VER_FILESUBTYPE VFT2_DRV_SYSTEM
- -#define VER_FILEDESCRIPTION_STR "ACPI Driver for NT"
- +#define VER_FILEDESCRIPTION_STR "ACPI 2.0 Driver for NT"
- #define VER_INTERNALNAME_STR "ACPI.sys"
- #define VER_ORIGINALFILENAME_STR "ACPI.sys"
- diff --strip-trailing-cr -ur ./driver/nt/buildsrc.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/buildsrc.c"
- --- ./driver/nt/buildsrc.c 2002-09-02 18:22:22.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/buildsrc.c" 2022-04-14 04:20:49.132812500 +0500
- @@ -399,7 +399,7 @@
- {
- PACPI_BUILD_REQUEST buildRequest = (PACPI_BUILD_REQUEST) Context;
- ULONG nextWorkDone = buildRequest->NextWorkDone;
- -
- + ULONG ParentName;
- //
- // Device what state we should transition to next
- //
- @@ -413,10 +413,12 @@
- //
- // Death
- //
- +
- + ParentName = AcpiObject ? (AcpiObject->pnsParent ? AcpiObject->pnsParent->dwNameSeg : 0) : 0 ;
- KeBugCheckEx(
- ACPI_BIOS_ERROR,
- ACPI_FAILED_MUST_SUCCEED_METHOD,
- - (ULONG_PTR) AcpiObject,
- + (ULONG_PTR) ParentName,
- Status,
- (AcpiObject ? AcpiObject->dwNameSeg : 0)
- );
- diff --strip-trailing-cr -ur ./driver/nt/debug.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.c"
- --- ./driver/nt/debug.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.c" 2022-04-16 06:47:51.983398400 +0500
- @@ -80,6 +80,18 @@
- {
- KeBugCheckEx (ACPI_DRIVER_INTERNAL, 0x1, Bugcode, 0, 0);
- }
- +
- +// SP3
- +VOID
- +_ACPIInternalErrorEx(
- + IN ULONG Bugcode0,
- + IN ULONG_PTR Bugcode1,
- + IN ULONG_PTR Bugcode2
- + )
- +{
- + KeBugCheckEx (ACPI_DRIVER_INTERNAL, 0x2, Bugcode0, Bugcode1, Bugcode2);
- +}
- +// SP3
- #if DBG
- VOID
- diff --strip-trailing-cr -ur ./driver/nt/debug.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.h"
- --- ./driver/nt/debug.h 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/debug.h" 2022-04-16 06:47:51.993164000 +0500
- @@ -53,6 +53,15 @@
- IN ULONG Bugcode
- );
- + // SP3
- + VOID
- + _ACPIInternalErrorEx(
- + IN ULONG Bugcode0,
- + IN ULONG_PTR Bugcode1,
- + IN ULONG_PTR Bugcode2
- + );
- + // SP3
- +
- #if DBG
- VOID
- ACPIDebugResourceDescriptor(
- diff --strip-trailing-cr -ur ./driver/nt/devpower.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/devpower.c"
- --- ./driver/nt/devpower.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/devpower.c" 2022-04-16 06:47:52.005859300 +0500
- @@ -4712,7 +4712,7 @@
- } // ACPIDevicePowerProcessPhase2SystemSubPhase3
- NTSTATUS
- -ACPIDevicePowerProcessPhase3(
- +ACPIDevicePowerProcessPhase3_SP1(
- VOID
- )
- /*++
- @@ -5058,6 +5058,215 @@
- return (returnPending ? STATUS_PENDING : STATUS_SUCCESS);
- } // ACPIPowerProcessPhase3
- +
- +
- +#ifdef _X86_
- +// SP3
- +__declspec(naked) NTSTATUS
- +ACPIDevicePowerProcessPhase3(
- + VOID
- + )
- +{
- + __asm {
- + mov edi, edi
- + push ebp
- + mov ebp, esp
- + sub esp, 18h
- + push ebx
- + push esi
- + mov ebx, offset AcpiPowerLock
- + push edi
- + mov ecx, ebx
- + mov byte ptr [ebp-1], 0
- + call dword ptr [KefAcquireSpinLockAtDpcLevel]
- + mov esi, dword ptr [AcpiPowerNodeList+0] ;Flink
- + mov eax, offset AcpiPowerNodeList
- + cmp esi, eax
- + jz loc_1535A
- + jmp short loc_15250
- +loc_1524D:
- + mov esi, [ebp-0Ch]
- +loc_15250:
- + mov eax, [esi]
- + mov [ebp-0Ch], eax
- + mov eax, [esi+8]
- + and eax, 2
- + xor ecx, ecx
- + or eax, ecx
- + jz loc_1534C
- + push 3
- + push 4
- + lea ecx, [esi+28h]
- + pop edx
- + call dword ptr [InterlockedCompareExchange]
- + cmp eax, 3
- + jnz loc_1534C
- + and dword ptr [ebp-8], 0
- + lea eax, [esi+20h]
- + mov edi, [eax]
- + jmp short loc_152C6
- +loc_15287:
- + lea eax, [edi-18h]
- + mov edi, [edi]
- + mov [ebp-14h], eax
- + mov eax, [eax+14h]
- + push 0
- + lea ecx, [eax+0F0h]
- + xor edx, edx
- + mov [ebp-10h], eax
- + call dword ptr [InterlockedCompareExchange]
- + mov ecx, [ebp-10h]
- + mov edx, [ecx+0ECh]
- + mov ecx, [ebp-14h]
- + cmp edx, [ecx+0Ch]
- + jz short loc_152C0
- + test eax, eax
- + jz short loc_152C3
- + cmp byte ptr [ecx+10h], 0
- + jz short loc_152C3
- +
- +loc_152C0:
- + inc dword ptr [ebp-8]
- +
- +loc_152C3:
- + lea eax, [esi+20h]
- +
- +loc_152C6:
- + cmp edi, eax
- + jnz short loc_15287
- + mov edx, [ebp-8]
- + lea ecx, [esi+10h]
- + call dword ptr [InterlockedExchange]
- + mov eax, [esi+0Ch]
- + mov ecx, [esi+8]
- + mov [ebp-14h], eax
- + mov eax, ecx
- + and eax, 440h
- + xor edx, edx
- + or eax, edx
- + jnz short loc_1534C
- + and ecx, 220h
- + xor eax, eax
- + xor edi, edi
- + or ecx, eax
- + jnz short loc_152FF
- + cmp [ebp-8], edi
- + jz short loc_1534C
- +
- +loc_152FF:
- + xor edx, edx
- + push 4
- + inc edx
- + lea ecx, [esi+28h]
- + call dword ptr [InterlockedCompareExchange]
- + mov ecx, ebx
- + call dword ptr [KefReleaseSpinLockFromDpcLevel]
- + push esi
- + push offset ACPIDeviceCompletePhase3On
- + push edi
- + push edi
- + push edi
- + push dword ptr [esi+2Ch]
- + call AMLIAsyncEvalObject
- + add esp, 18h
- + cmp eax, 103h
- + jz short loc_15340
- + push esi
- + push edi
- + push eax
- + push dword ptr [esi+2Ch]
- + call ACPIDeviceCompletePhase3On
- + add esp, 10h
- + jmp short loc_15344
- +
- +
- +loc_15340:
- + mov byte ptr [ebp-1], 1
- +
- +loc_15344:
- + mov ecx, ebx
- + call dword ptr [KefAcquireSpinLockAtDpcLevel]
- +
- +loc_1534C:
- + mov eax, offset AcpiPowerNodeList
- + cmp [ebp-0Ch], eax
- + jnz loc_1524D
- +
- +loc_1535A:
- + mov edi, dword ptr [AcpiPowerNodeList+4] ; Blink
- + cmp edi, eax
- + jz short loc_153DC
- +
- +loc_15364:
- + mov esi, edi
- + mov eax, [esi+8]
- + mov edi, [edi+4]
- + and eax, 2
- + xor ecx, ecx
- + or eax, ecx
- + jz short loc_153D4
- + xor edx, edx
- + push 4
- + lea ecx, [esi+28h]
- + inc edx
- + call dword ptr [InterlockedCompareExchange]
- + cmp eax, 4
- + jz short loc_15392
- + test eax, eax
- + jz short loc_153D4
- + mov byte ptr [ebp-1], 1
- + jmp short loc_153D4
- +
- +loc_15392:
- + mov ecx, ebx
- + call dword ptr [KefReleaseSpinLockFromDpcLevel]
- + push esi
- + push offset ACPIDeviceCompletePhase3Off
- + xor eax, eax
- + push eax
- + push eax
- + push eax
- + push dword ptr [esi+30h]
- + call AMLIAsyncEvalObject
- + add esp, 18h
- + cmp eax, 103h
- + jz short loc_153C8
- + push esi
- + push 0
- + push eax
- + push dword ptr [esi+30h]
- + call ACPIDeviceCompletePhase3Off
- + add esp, 10h
- + jmp short loc_153CC
- +
- +loc_153C8:
- + mov byte ptr [ebp-1], 1
- +
- +loc_153CC:
- + mov ecx, ebx
- + call dword ptr [KefAcquireSpinLockAtDpcLevel]
- +
- +loc_153D4:
- + cmp edi, offset AcpiPowerNodeList
- + jnz short loc_15364
- +
- +loc_153DC:
- + mov ecx, ebx
- + call dword ptr [KefReleaseSpinLockFromDpcLevel]
- + mov al, [ebp-1]
- + neg al
- + pop edi
- + pop esi
- + pop ebx
- + sbb eax, eax
- + and eax, 103h
- + _emit 0xc9 ; "leave" opcode
- + ret
- + }
- +}
- +// SP3
- +#endif
- +
- NTSTATUS
- ACPIDevicePowerProcessPhase4(
- diff --strip-trailing-cr -ur ./driver/nt/internal.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/internal.c"
- --- ./driver/nt/internal.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/internal.c" 2022-04-16 06:47:52.018554600 +0500
- @@ -304,6 +304,15 @@
- //
- deviceExtension = DeviceObject->DeviceExtension;
- + // SP3
- + if ( deviceExtension &&
- + deviceExtension->Signature != '_SGP' ) {
- + _ACPIInternalErrorEx(0x00090147,
- + (ULONG_PTR)DeviceObject,
- + (ULONG_PTR)deviceExtension);
- + }
- + // SP3
- +
- #if 0
- //
- // Is this a surprise removed device extension?
- diff --strip-trailing-cr -ur ./driver/nt/interupt.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/interupt.c"
- --- ./driver/nt/interupt.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/interupt.c" 2022-04-16 06:47:52.028320300 +0500
- @@ -711,11 +711,14 @@
- // behind our back. The way that we can correct this problem is by
- // forcing a check of the GPEs...
- //
- - if (!IntStatus) {
- +
- + // SP3
- + if ( !(AcpiOverrideAttributes & 0x0100) && !IntStatus ) { // test byte ptr _AcpiOverrideAttributes+1, 1
- IntStatus |= PM1_GPE_PENDING;
- }
- + // SP3
- //
- // Are any status bits set for events which are handled at ISR time?
- diff --strip-trailing-cr -ur ./driver/nt/irqarb.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.c"
- --- ./driver/nt/irqarb.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.c" 2022-04-16 06:47:01.192382800 +0500
- @@ -39,7 +39,8 @@
- extern LONG ArbDebugLevel;
- #define DEBUG_PRINT(Level, Message) \
- - if (ArbDebugLevel >= Level) DbgPrint Message
- + DbgPrint Message
- +
- #else
- #define DEBUG_PRINT(Level, Message)
- #endif
- @@ -3509,6 +3510,22 @@
- }
- }
- + // BSOD 0x7E(c0000005, ...) AcpiArbCrackPRT() two workarounds:
- + // 1) pci.sys presence check
- + // 2) not PCI device type check
- + if (0) {
- + if (!PciInterfacesInstantiated) {
- + return STATUS_NOT_FOUND;
- + }
- + } else {
- + if (Pdo->DriverObject == AcpiDriverObject) {
- + status = ACPIInternalIsPci(Pdo);
- + if (NT_SUCCESS(status))
- + if ( (((PDEVICE_EXTENSION)Pdo->DeviceExtension)->Flags & DEV_CAP_PCI_DEVICE) == 0 )
- + return STATUS_NOT_FOUND;
- + }
- + }
- +
- ASSERT(PciInterfacesInstantiated);
- *LinkNode = NULL;
- @@ -4970,16 +4987,18 @@
- }
- } else {
- + if (0) { // BSOD 0xA5 (0x10006, ...) workaround, missing _DIS method for "PNP0C0F" (PCI Interrupt Link Devices)
- - //
- - // Link nodes must be disablable.
- - //
- + //
- + // Link nodes must be disablable.
- + //
- - KeBugCheckEx(ACPI_BIOS_ERROR,
- - ACPI_LINK_NODE_CANNOT_BE_DISABLED,
- - (ULONG_PTR)context->RootDevice,
- - 0,
- - 0);
- + KeBugCheckEx(ACPI_BIOS_ERROR,
- + ACPI_LINK_NODE_CANNOT_BE_DISABLED,
- + (ULONG_PTR)context->RootDevice,
- + 0,
- + 0);
- + }
- }
- }
- }
- diff --strip-trailing-cr -ur ./driver/nt/irqarb.h "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.h"
- --- ./driver/nt/irqarb.h 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/irqarb.h" 2022-04-09 05:05:41.876953100 +0500
- @@ -99,7 +99,8 @@
- extern ACPI_ARBITER AcpiArbiter;
- extern BOOLEAN PciInterfacesInstantiated;
- -#define PCI_PNP_ID "PNP0A03"
- +#define PCI_PNP_ID "PNP0A03"
- +#define PCIE_PNP_ID "PNP0A08"
- #define LINK_NODE_PNP_ID "PNP0C0F"
- // Prototypes for stuff used by msi.c
- diff --strip-trailing-cr -ur ./driver/nt/osnotify.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/osnotify.c"
- --- ./driver/nt/osnotify.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/osnotify.c" 2022-04-16 06:47:52.056640600 +0500
- @@ -723,7 +723,7 @@
- NTSTATUS
- EXPORT
- -OSNotifyDeviceCheck(
- +OSNotifyDeviceCheck_SP1(
- IN PNSOBJ AcpiObject
- )
- /*++
- @@ -827,6 +827,91 @@
- //
- return STATUS_SUCCESS;
- }
- +
- +
- +#ifdef _X86_
- +// SP3
- +__declspec(naked) NTSTATUS
- +EXPORT
- +OSNotifyDeviceCheck(
- + IN PNSOBJ AcpiObject
- + )
- +{
- +__asm {
- + mov edi, edi
- + push ebp
- + mov ebp, esp
- + push [ebp+8]
- + call ACPIDockIsDockDevice
- + test al, al
- + jz short loc_1C94F
- + pop ebp
- + jmp OSNotifyDeviceEject
- +
- +loc_1C94F:
- + push ebx
- + push esi
- + mov esi, offset AcpiDeviceTreeLock
- + mov ecx, esi
- + call dword ptr [KfAcquireSpinLock]
- + mov ecx, [ebp+8]
- + mov bl, al
- + xor edx, edx
- +
- +loc_1C965:
- + mov eax, [ecx+30h]
- + cmp eax, edx
- + mov ecx, [ecx+8]
- + jz short loc_1C97E
- + cmp dword ptr [eax+8], '_SGP'
- + jz short loc_1C97A
- + xor eax, eax
- +
- +loc_1C97A:
- + cmp eax, edx
- + jnz short loc_1C986
- +
- +loc_1C97E:
- + cmp ecx, edx
- + jnz short loc_1C965
- + cmp eax, edx
- + jz short loc_1C9B0
- +
- +loc_1C986:
- + mov ecx, [eax+13Ch]
- + jmp short loc_1C99D
- +
- +loc_1C98E:
- + mov eax, [ecx]
- + and eax, 8
- + or eax, edx
- + jz short loc_1C9A3
- + mov ecx, [ecx+13Ch]
- +
- +loc_1C99D:
- + cmp ecx, edx
- + jnz short loc_1C98E
- + jmp short loc_1C9B0
- +
- +loc_1C9A3:
- + push edx
- + push dword ptr [ecx+138h]
- + call dword ptr [IoInvalidateDeviceRelations]
- +
- +loc_1C9B0:
- + mov ecx, esi
- + mov dl, bl
- + call dword ptr [KfReleaseSpinLock]
- + pop esi
- + xor eax, eax
- + pop ebx
- + pop ebp
- + ret
- +}
- +}
- +// SP3
- +#endif
- +
- NTSTATUS
- EXPORT
- diff --strip-trailing-cr -ur ./driver/nt/pciopregion.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/pciopregion.c"
- --- ./driver/nt/pciopregion.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/pciopregion.c" 2022-04-09 05:06:57.275390600 +0500
- @@ -1119,7 +1119,10 @@
- pciConfig = (PPCI_COMMON_CONFIG)buffer;
- - if (pciConfig->HeaderType != PCI_BRIDGE_TYPE) {
- + // SP3
- + if ((PCI_CONFIGURATION_TYPE(pciConfig) != PCI_BRIDGE_TYPE) &&
- + (PCI_CONFIGURATION_TYPE(pciConfig) != PCI_CARDBUS_BRIDGE_TYPE)) {
- + // SP3
- //
- // Make a guess that the bus number was 0.
- @@ -1388,7 +1391,8 @@
- if (state->Hid) {
- - if (strstr(state->Hid, PCI_PNP_ID)) {
- + if (strstr(state->Hid, PCI_PNP_ID) ||
- + strstr(state->Hid, PCIE_PNP_ID)) {
- //
- // Was PCI.
- //
- @@ -1432,7 +1436,8 @@
- if (state->Cid) {
- - if (strstr(state->Cid, PCI_PNP_ID)) {
- + if (strstr(state->Cid, PCI_PNP_ID) ||
- + strstr(state->Cid, PCIE_PNP_ID)) {
- //
- // Was PCI.
- //
- @@ -1669,7 +1674,8 @@
- if (state->Hid) {
- - if (strstr(state->Hid, PCI_PNP_ID)) {
- + if (strstr(state->Hid, PCI_PNP_ID) ||
- + strstr(state->Hid, PCIE_PNP_ID)) {
- //
- // Was PCI.
- //
- @@ -1711,7 +1717,8 @@
- if (state->Cid) {
- - if (strstr(state->Cid, PCI_PNP_ID)) {
- + if (strstr(state->Cid, PCI_PNP_ID) ||
- + strstr(state->Cid, PCIE_PNP_ID)) {
- //
- // Was PCI.
- //
- diff --strip-trailing-cr -ur ./driver/nt/rangesup.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/rangesup.c"
- --- ./driver/nt/rangesup.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/rangesup.c" 2022-04-16 06:47:52.079101500 +0500
- @@ -2311,9 +2311,11 @@
- //
- // Do we errors?
- //
- - if (bugCheck) {
- - ACPIPrint( (
- + if (0) { // BSOD 0xA5 (0x02, ...) workaround, ACPI vs E820 mem ranges conflict
- + //if (bugCheck) {
- +
- + ACPIPrint( (
- ACPI_PRINT_CRITICAL,
- "ACPI:\n"
- "ACPI: FATAL BIOS ERROR - Need new BIOS to fix PCI problems\n"
- diff --strip-trailing-cr -ur ./driver/nt/root.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/root.c"
- --- ./driver/nt/root.c 2002-09-02 18:22:24.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/root.c" 2022-04-16 06:47:52.089843700 +0500
- @@ -142,8 +142,10 @@
- --*/
- {
- PKEVENT event = (PKEVENT) Context;
- -#if DBG
- + // SP3
- PDEVICE_EXTENSION deviceExtension = ACPIInternalGetDeviceExtension(DeviceObject);
- + // SP3
- +#if DBG
- PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation( Irp );
- if (deviceExtension != NULL) {
- diff --strip-trailing-cr -ur ./driver/nt/wake.c "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/wake.c"
- --- ./driver/nt/wake.c 2002-09-02 18:22:26.000000000 +0500
- +++ "c:\\ACPI\\ACPI_SP1\\Base\\busdrv\\acpi/driver/nt/wake.c" 2022-04-16 06:47:52.100585900 +0500
- @@ -475,11 +475,6 @@
- PNSOBJ pswObject = NULL;
- //
- - // Acquire the Spinlock
- - //
- - KeAcquireSpinLock( &AcpiPowerLock, &oldIrql );
- -
- - //
- // Update the number of references on the device
- //
- if (Enable) {
- @@ -595,6 +590,13 @@
- pswContext->DeviceExtension = DeviceExtension;
- pswContext->Count = 1;
- + // SP3
- + //
- + // Acquire the Spinlock
- + //
- + KeAcquireSpinLock( &AcpiPowerLock, &oldIrql );
- + // SP3
- +
- //
- // Check to see if we are simply going to queue the context up, or
- // call the interpreter
- @@ -699,11 +701,6 @@
- ACPIWakeEnableDisableAsyncExit:
- //
- - // Release the lock
- - //
- - KeReleaseSpinLock( &AcpiPowerLock, oldIrql );
- -
- - //
- // What happened
- //
- ACPIDevPrint( (
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement