Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

946 lines
31 KiB

  1. /*** namedobj.c - Parse named object instructions
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created 09/10/96
  6. *
  7. * MODIFICATION HISTORY
  8. */
  9. #include "pch.h"
  10. #ifdef LOCKABLE_PRAGMA
  11. #pragma ACPI_LOCKABLE_DATA
  12. #pragma ACPI_LOCKABLE_CODE
  13. #endif
  14. /***LP BankField - Parse and execute the BankField instruction
  15. *
  16. * ENTRY
  17. * pctxt -> CTXT
  18. * pterm -> TERM
  19. *
  20. * EXIT-SUCCESS
  21. * returns STATUS_SUCCESS
  22. * EXIT-FAILURE
  23. * returns AMLIERR_ code
  24. */
  25. NTSTATUS LOCAL BankField(PCTXT pctxt, PTERM pterm)
  26. {
  27. TRACENAME("BANKFIELD")
  28. NTSTATUS rc = STATUS_SUCCESS;
  29. PNSOBJ pnsBase, pnsBank;
  30. ENTER(2, ("BankField(pctxt=%x,pterm=%x,pbOp=%x)\n",
  31. pctxt, pterm, pctxt->pbOp));
  32. if (((rc = GetNameSpaceObject((PSZ)pterm->pdataArgs[0].pbDataBuff,
  33. pctxt->pnsScope, &pnsBase, NSF_WARN_NOTFOUND))
  34. == STATUS_SUCCESS) &&
  35. ((rc = GetNameSpaceObject((PSZ)pterm->pdataArgs[1].pbDataBuff,
  36. pctxt->pnsScope, &pnsBank, NSF_WARN_NOTFOUND))
  37. == STATUS_SUCCESS))
  38. {
  39. if (pnsBase->ObjData.dwDataType != OBJTYPE_OPREGION)
  40. {
  41. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  42. ("BankField: %s is not an operation region",
  43. pterm->pdataArgs[0].pbDataBuff));
  44. }
  45. else if (pnsBank->ObjData.dwDataType != OBJTYPE_FIELDUNIT)
  46. {
  47. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  48. ("BankField: %s is not a field unit",
  49. pterm->pdataArgs[1].pbDataBuff));
  50. }
  51. else if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent, NULL,
  52. pctxt->pnsScope, pctxt->powner,
  53. &pterm->pnsObj, 0)) ==
  54. STATUS_SUCCESS)
  55. {
  56. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_BANKFIELD;
  57. pterm->pnsObj->ObjData.dwDataLen = sizeof(BANKFIELDOBJ);
  58. if ((pterm->pnsObj->ObjData.pbDataBuff =
  59. NEWKFOBJ(pctxt->pheapCurrent,
  60. pterm->pnsObj->ObjData.dwDataLen)) == NULL)
  61. {
  62. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  63. ("BankField: failed to allocate BankField object"));
  64. }
  65. else
  66. {
  67. PBANKFIELDOBJ pbf;
  68. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  69. pterm->pnsObj->ObjData.dwDataLen);
  70. pbf = (PBANKFIELDOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  71. pbf->pnsBase = pnsBase;
  72. pbf->pnsBank = pnsBank;
  73. pbf->dwBankValue = (ULONG)pterm->pdataArgs[2].uipDataValue;
  74. rc = ParseFieldList(pctxt, pterm->pbOpEnd, pterm->pnsObj,
  75. (ULONG)pterm->pdataArgs[3].uipDataValue,
  76. ((POPREGIONOBJ)pnsBase->ObjData.pbDataBuff)->dwLen);
  77. }
  78. }
  79. }
  80. EXIT(2, ("BankField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  81. return rc;
  82. } //BankField
  83. /***LP CreateXField - Parse and execute the CreateXField instructions
  84. *
  85. * ENTRY
  86. * pctxt -> CTXT
  87. * pterm -> TERM
  88. * pdataTarget -> Target object data
  89. * ppbf -> to hold created target BuffField object
  90. *
  91. * EXIT-SUCCESS
  92. * returns STATUS_SUCCESS
  93. * EXIT-FAILURE
  94. * returns AMLIERR_ code
  95. */
  96. NTSTATUS LOCAL CreateXField(PCTXT pctxt, PTERM pterm, POBJDATA pdataTarget,
  97. PBUFFFIELDOBJ *ppbf)
  98. {
  99. TRACENAME("CREATEXFIELD")
  100. NTSTATUS rc = STATUS_SUCCESS;
  101. POBJDATA pdata = NULL;
  102. ENTER(2, ("CreateXField(pctxt=%x,pbOp=%x,pterm=%x,pdataTarget=%x,ppbf=%x)\n",
  103. pctxt, pctxt->pbOp, pterm, pdataTarget, ppbf));
  104. ASSERT(pdataTarget != NULL);
  105. ASSERT(pdataTarget->dwDataType == OBJTYPE_STRDATA);
  106. if (((rc = ValidateArgTypes(pterm->pdataArgs, "BI")) == STATUS_SUCCESS) &&
  107. ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  108. (PSZ)pdataTarget->pbDataBuff,
  109. pctxt->pnsScope, pctxt->powner,
  110. &pterm->pnsObj, 0)) == STATUS_SUCCESS))
  111. {
  112. pdata = &pterm->pnsObj->ObjData;
  113. pdata->dwDataType = OBJTYPE_BUFFFIELD;
  114. pdata->dwDataLen = sizeof(BUFFFIELDOBJ);
  115. if ((pdata->pbDataBuff = NEWBFOBJ(pctxt->pheapCurrent,
  116. pdata->dwDataLen)) == NULL)
  117. {
  118. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  119. ("CreateXField: failed to allocate BuffField object"));
  120. }
  121. else
  122. {
  123. MEMZERO(pdata->pbDataBuff, pdata->dwDataLen);
  124. *ppbf = (PBUFFFIELDOBJ)pdata->pbDataBuff;
  125. (*ppbf)->pbDataBuff = pterm->pdataArgs[0].pbDataBuff;
  126. (*ppbf)->dwBuffLen = pterm->pdataArgs[0].dwDataLen;
  127. }
  128. }
  129. EXIT(2, ("CreateXField=%x (pdata=%x)\n", rc, pdata));
  130. return rc;
  131. } //CreateXField
  132. /***LP CreateBitField - Parse and execute the CreateBitField instruction
  133. *
  134. * ENTRY
  135. * pctxt -> CTXT
  136. * pterm -> TERM
  137. *
  138. * EXIT-SUCCESS
  139. * returns STATUS_SUCCESS
  140. * EXIT-FAILURE
  141. * returns AMLIERR_ code
  142. */
  143. NTSTATUS LOCAL CreateBitField(PCTXT pctxt, PTERM pterm)
  144. {
  145. TRACENAME("CREATEBITFIELD")
  146. NTSTATUS rc = STATUS_SUCCESS;
  147. PBUFFFIELDOBJ pbf;
  148. ENTER(2, ("CreateBitField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  149. pctxt, pctxt->pbOp, pterm));
  150. if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
  151. STATUS_SUCCESS)
  152. {
  153. pbf->FieldDesc.dwByteOffset = (ULONG)
  154. (pterm->pdataArgs[1].uipDataValue/8);
  155. pbf->FieldDesc.dwStartBitPos = (ULONG)
  156. (pterm->pdataArgs[1].uipDataValue -
  157. pbf->FieldDesc.dwByteOffset*8);
  158. pbf->FieldDesc.dwNumBits = 1;
  159. pbf->FieldDesc.dwFieldFlags = ACCTYPE_BYTE;
  160. }
  161. EXIT(2, ("CreateBitField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  162. return rc;
  163. } //CreateBitField
  164. /***LP CreateByteField - Parse and execute the CreateByteField instruction
  165. *
  166. * ENTRY
  167. * pctxt -> CTXT
  168. * pterm -> TERM
  169. *
  170. * EXIT-SUCCESS
  171. * returns STATUS_SUCCESS
  172. * EXIT-FAILURE
  173. * returns AMLIERR_ code
  174. */
  175. NTSTATUS LOCAL CreateByteField(PCTXT pctxt, PTERM pterm)
  176. {
  177. TRACENAME("CREATEBYTEFIELD")
  178. NTSTATUS rc = STATUS_SUCCESS;
  179. PBUFFFIELDOBJ pbf;
  180. ENTER(2, ("CreateByteField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  181. pctxt, pctxt->pbOp, pterm));
  182. if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
  183. STATUS_SUCCESS)
  184. {
  185. pbf->FieldDesc.dwByteOffset = (ULONG)pterm->pdataArgs[1].uipDataValue;
  186. pbf->FieldDesc.dwStartBitPos = 0;
  187. pbf->FieldDesc.dwNumBits = 8*sizeof(UCHAR);
  188. pbf->FieldDesc.dwFieldFlags = ACCTYPE_BYTE;
  189. }
  190. EXIT(2, ("CreateByteField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  191. return rc;
  192. } //CreateByteField
  193. /***LP CreateWordField - Parse and execute the CreateWordField instruction
  194. *
  195. * ENTRY
  196. * pctxt -> CTXT
  197. * pterm -> TERM
  198. *
  199. * EXIT-SUCCESS
  200. * returns STATUS_SUCCESS
  201. * EXIT-FAILURE
  202. * returns AMLIERR_ code
  203. */
  204. NTSTATUS LOCAL CreateWordField(PCTXT pctxt, PTERM pterm)
  205. {
  206. TRACENAME("CREATEWORDFIELD")
  207. NTSTATUS rc = STATUS_SUCCESS;
  208. PBUFFFIELDOBJ pbf;
  209. ENTER(2, ("CreateWordField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  210. pctxt, pctxt->pbOp, pterm));
  211. if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
  212. STATUS_SUCCESS)
  213. {
  214. pbf->FieldDesc.dwByteOffset = (ULONG)pterm->pdataArgs[1].uipDataValue;
  215. pbf->FieldDesc.dwStartBitPos = 0;
  216. pbf->FieldDesc.dwNumBits = 8*sizeof(USHORT);
  217. pbf->FieldDesc.dwFieldFlags = ACCTYPE_WORD;
  218. }
  219. EXIT(2, ("CreateWordField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  220. return rc;
  221. } //CreateWordField
  222. /***LP CreateDWordField - Parse and execute the CreateDWordField instruction
  223. *
  224. * ENTRY
  225. * pctxt -> CTXT
  226. * pterm -> TERM
  227. *
  228. * EXIT-SUCCESS
  229. * returns STATUS_SUCCESS
  230. * EXIT-FAILURE
  231. * returns AMLIERR_ code
  232. */
  233. NTSTATUS LOCAL CreateDWordField(PCTXT pctxt, PTERM pterm)
  234. {
  235. TRACENAME("CREATEDWORDFIELD")
  236. NTSTATUS rc = STATUS_SUCCESS;
  237. PBUFFFIELDOBJ pbf;
  238. ENTER(2, ("CreateDWordField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  239. pctxt, pctxt->pbOp, pterm));
  240. if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[2], &pbf)) ==
  241. STATUS_SUCCESS)
  242. {
  243. pbf->FieldDesc.dwByteOffset = (ULONG)pterm->pdataArgs[1].uipDataValue;
  244. pbf->FieldDesc.dwStartBitPos = 0;
  245. pbf->FieldDesc.dwNumBits = 8*sizeof(ULONG);
  246. pbf->FieldDesc.dwFieldFlags = ACCTYPE_DWORD;
  247. }
  248. EXIT(2, ("CreateDWordField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  249. return rc;
  250. } //CreateDWordField
  251. /***LP CreateField - Parse and execute the CreateField instruction
  252. *
  253. * ENTRY
  254. * pctxt -> CTXT
  255. * pterm -> TERM
  256. *
  257. * EXIT-SUCCESS
  258. * returns STATUS_SUCCESS
  259. * EXIT-FAILURE
  260. * returns AMLIERR_ code
  261. */
  262. NTSTATUS LOCAL CreateField(PCTXT pctxt, PTERM pterm)
  263. {
  264. TRACENAME("CREATEFIELD")
  265. NTSTATUS rc = STATUS_SUCCESS;
  266. PBUFFFIELDOBJ pbf;
  267. ENTER(2, ("CreateField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  268. pctxt, pctxt->pbOp, pterm));
  269. if (pterm->pdataArgs[2].dwDataType == OBJTYPE_INTDATA)
  270. {
  271. if ((rc = CreateXField(pctxt, pterm, &pterm->pdataArgs[3], &pbf)) ==
  272. STATUS_SUCCESS)
  273. {
  274. pbf->FieldDesc.dwByteOffset = (ULONG)
  275. (pterm->pdataArgs[1].uipDataValue/8);
  276. pbf->FieldDesc.dwStartBitPos = (ULONG)
  277. (pterm->pdataArgs[1].uipDataValue -
  278. pbf->FieldDesc.dwByteOffset*8);
  279. pbf->FieldDesc.dwNumBits = (ULONG)pterm->pdataArgs[2].uipDataValue;
  280. pbf->FieldDesc.dwFieldFlags = ACCTYPE_BYTE | FDF_BUFFER_TYPE;
  281. }
  282. }
  283. else
  284. {
  285. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_ARGTYPE,
  286. ("CreateField: NoBits must be evaluated to integer type"));
  287. }
  288. EXIT(2, ("CreateField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  289. return rc;
  290. } //CreateField
  291. /***LP Device - Parse and execute the Scope instruction
  292. *
  293. * ENTRY
  294. * pctxt -> CTXT
  295. * pterm -> TERM
  296. *
  297. * EXIT-SUCCESS
  298. * returns STATUS_SUCCESS
  299. * EXIT-FAILURE
  300. * returns AMLIERR_ code
  301. */
  302. NTSTATUS LOCAL Device(PCTXT pctxt, PTERM pterm)
  303. {
  304. TRACENAME("DEVICE")
  305. NTSTATUS rc = STATUS_SUCCESS;
  306. ENTER(2, ("Device(pctxt=%x,pbOp=%x,pterm=%x)\n",
  307. pctxt, pctxt->pbOp, pterm));
  308. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  309. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  310. pctxt->pnsScope, pctxt->powner,
  311. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  312. {
  313. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_DEVICE;
  314. if (ghCreate.pfnHandler != NULL)
  315. {
  316. ((PFNOO)ghCreate.pfnHandler)(OBJTYPE_DEVICE, pterm->pnsObj);
  317. }
  318. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, NULL, pterm->pnsObj,
  319. pctxt->powner, pctxt->pheapCurrent, pterm->pdataResult);
  320. }
  321. EXIT(2, ("Device=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  322. return rc;
  323. } //Device
  324. /***LP InitEvent - Initialize an event object
  325. *
  326. * ENTRY
  327. * pheap -> HEAP
  328. * pns -> event object to be initialized
  329. *
  330. * EXIT-SUCCESS
  331. * returns STATUS_SUCCESS
  332. * EXIT-FAILURE
  333. * returns AMLIERR_ code
  334. */
  335. NTSTATUS LOCAL InitEvent(PHEAP pheap, PNSOBJ pns)
  336. {
  337. TRACENAME("INITEVENT")
  338. NTSTATUS rc = STATUS_SUCCESS;
  339. ENTER(2, ("InitEvent(pheap=%x,pns=%x)\n", pheap, pns));
  340. pns->ObjData.dwDataType = OBJTYPE_EVENT;
  341. pns->ObjData.dwDataLen = sizeof(EVENTOBJ);
  342. if ((pns->ObjData.pbDataBuff = NEWEVOBJ(pheap, pns->ObjData.dwDataLen)) ==
  343. NULL)
  344. {
  345. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  346. ("InitEvent: failed to allocate Event object"));
  347. }
  348. else
  349. {
  350. MEMZERO(pns->ObjData.pbDataBuff, pns->ObjData.dwDataLen);
  351. }
  352. EXIT(2, ("InitEvent=%x\n", rc));
  353. return rc;
  354. } //InitEvent
  355. /***LP Event - Parse and execute the Event instruction
  356. *
  357. * ENTRY
  358. * pctxt -> CTXT
  359. * pterm -> TERM
  360. *
  361. * EXIT-SUCCESS
  362. * returns STATUS_SUCCESS
  363. * EXIT-FAILURE
  364. * returns AMLIERR_ code
  365. */
  366. NTSTATUS LOCAL Event(PCTXT pctxt, PTERM pterm)
  367. {
  368. TRACENAME("EVENT")
  369. NTSTATUS rc = STATUS_SUCCESS;
  370. ENTER(2, ("Event(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  371. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  372. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  373. pctxt->pnsScope, pctxt->powner,
  374. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  375. {
  376. rc = InitEvent(pctxt->pheapCurrent, pterm->pnsObj);
  377. }
  378. EXIT(2, ("Event=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  379. return rc;
  380. } //Event
  381. /***LP Field - Parse and execute the Field instruction
  382. *
  383. * ENTRY
  384. * pctxt -> CTXT
  385. * pterm -> TERM
  386. *
  387. * EXIT-SUCCESS
  388. * returns STATUS_SUCCESS
  389. * EXIT-FAILURE
  390. * returns AMLIERR_ code
  391. */
  392. NTSTATUS LOCAL Field(PCTXT pctxt, PTERM pterm)
  393. {
  394. TRACENAME("FIELD")
  395. NTSTATUS rc = STATUS_SUCCESS;
  396. PNSOBJ pnsBase;
  397. ENTER(2, ("Field(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  398. if ((rc = GetNameSpaceObject((PSZ)pterm->pdataArgs[0].pbDataBuff,
  399. pctxt->pnsScope, &pnsBase, NSF_WARN_NOTFOUND))
  400. == STATUS_SUCCESS)
  401. {
  402. if (pnsBase->ObjData.dwDataType != OBJTYPE_OPREGION)
  403. {
  404. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  405. ("Field: %s is not an operation region",
  406. pterm->pdataArgs[0].pbDataBuff));
  407. }
  408. else if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent, NULL,
  409. pctxt->pnsScope, pctxt->powner,
  410. &pterm->pnsObj, 0)) ==
  411. STATUS_SUCCESS)
  412. {
  413. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_FIELD;
  414. pterm->pnsObj->ObjData.dwDataLen = sizeof(FIELDOBJ);
  415. if ((pterm->pnsObj->ObjData.pbDataBuff =
  416. NEWFOBJ(pctxt->pheapCurrent,
  417. pterm->pnsObj->ObjData.dwDataLen)) == NULL)
  418. {
  419. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  420. ("Field: failed to allocate Field object"));
  421. }
  422. else
  423. {
  424. PFIELDOBJ pfd;
  425. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  426. pterm->pnsObj->ObjData.dwDataLen);
  427. pfd = (PFIELDOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  428. pfd->pnsBase = pnsBase;
  429. rc = ParseFieldList(pctxt, pterm->pbOpEnd, pterm->pnsObj,
  430. (ULONG)pterm->pdataArgs[1].uipDataValue,
  431. ((POPREGIONOBJ)pnsBase->ObjData.pbDataBuff)->dwLen);
  432. }
  433. }
  434. }
  435. EXIT(2, ("Field=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  436. return rc;
  437. } //Field
  438. /***LP IndexField - Parse and execute the Field instruction
  439. *
  440. * ENTRY
  441. * pctxt -> CTXT
  442. * pterm -> TERM
  443. *
  444. * EXIT-SUCCESS
  445. * returns STATUS_SUCCESS
  446. * EXIT-FAILURE
  447. * returns AMLIERR_ code
  448. */
  449. NTSTATUS LOCAL IndexField(PCTXT pctxt, PTERM pterm)
  450. {
  451. TRACENAME("INDEXFIELD")
  452. NTSTATUS rc = STATUS_SUCCESS;
  453. PNSOBJ pnsIdx, pnsData;
  454. ENTER(2, ("IndexField(pctxt=%x,pbOp=%x,pterm=%x)\n",
  455. pctxt, pctxt->pbOp, pterm));
  456. if (((rc = GetNameSpaceObject((PSZ)pterm->pdataArgs[0].pbDataBuff,
  457. pctxt->pnsScope, &pnsIdx, NSF_WARN_NOTFOUND))
  458. == STATUS_SUCCESS) &&
  459. ((rc = GetNameSpaceObject((PSZ)pterm->pdataArgs[1].pbDataBuff,
  460. pctxt->pnsScope, &pnsData, NSF_WARN_NOTFOUND))
  461. == STATUS_SUCCESS))
  462. {
  463. if (pnsIdx->ObjData.dwDataType != OBJTYPE_FIELDUNIT)
  464. {
  465. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  466. ("IndexField: Index (%s) is not a field unit",
  467. pterm->pdataArgs[0].pbDataBuff));
  468. }
  469. else if (pnsData->ObjData.dwDataType != OBJTYPE_FIELDUNIT)
  470. {
  471. rc = AMLI_LOGERR(AMLIERR_UNEXPECTED_OBJTYPE,
  472. ("IndexField: Data (%s) is not a field unit",
  473. pterm->pdataArgs[1].pbDataBuff));
  474. }
  475. else if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent, NULL,
  476. pctxt->pnsScope, pctxt->powner,
  477. &pterm->pnsObj, 0)) ==
  478. STATUS_SUCCESS)
  479. {
  480. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_INDEXFIELD;
  481. pterm->pnsObj->ObjData.dwDataLen = sizeof(INDEXFIELDOBJ);
  482. if ((pterm->pnsObj->ObjData.pbDataBuff =
  483. NEWIFOBJ(pctxt->pheapCurrent,
  484. pterm->pnsObj->ObjData.dwDataLen)) == NULL)
  485. {
  486. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  487. ("IndexField: failed to allocate IndexField object"));
  488. }
  489. else
  490. {
  491. PINDEXFIELDOBJ pif;
  492. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  493. pterm->pnsObj->ObjData.dwDataLen);
  494. pif = (PINDEXFIELDOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  495. pif->pnsIndex = pnsIdx;
  496. pif->pnsData = pnsData;
  497. rc = ParseFieldList(pctxt, pterm->pbOpEnd, pterm->pnsObj,
  498. (ULONG)pterm->pdataArgs[2].uipDataValue,
  499. 0xffffffff);
  500. }
  501. }
  502. }
  503. EXIT(2, ("IndexField=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  504. return rc;
  505. } //IndexField
  506. /***LP Method - Parse and execute the Method instruction
  507. *
  508. * ENTRY
  509. * pctxt -> CTXT
  510. * pterm -> TERM
  511. *
  512. * EXIT-SUCCESS
  513. * returns STATUS_SUCCESS
  514. * EXIT-FAILURE
  515. * returns AMLIERR_ code
  516. */
  517. NTSTATUS LOCAL Method(PCTXT pctxt, PTERM pterm)
  518. {
  519. TRACENAME("METHOD")
  520. NTSTATUS rc = STATUS_SUCCESS;
  521. ENTER(2, ("Method(pctxt=%x,pbOp=%x,pterm=%x)\n",
  522. pctxt, pctxt->pbOp, pterm));
  523. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  524. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  525. pctxt->pnsScope, pctxt->powner,
  526. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  527. {
  528. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_METHOD;
  529. pterm->pnsObj->ObjData.dwDataLen = (ULONG)(FIELD_OFFSET(METHODOBJ,
  530. abCodeBuff) +
  531. pterm->pbOpEnd -
  532. pctxt->pbOp);
  533. if ((pterm->pnsObj->ObjData.pbDataBuff =
  534. NEWMEOBJ(pctxt->pheapCurrent, pterm->pnsObj->ObjData.dwDataLen))
  535. == NULL)
  536. {
  537. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  538. ("Method: failed to allocate method buffer"));
  539. }
  540. else
  541. {
  542. PMETHODOBJ pm = (PMETHODOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  543. #ifdef DEBUGGER
  544. AddObjSymbol(pm->abCodeBuff, pterm->pnsObj);
  545. #endif
  546. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  547. pterm->pnsObj->ObjData.dwDataLen);
  548. pm->bMethodFlags = *(pctxt->pbOp - 1);
  549. MEMCPY(&pm->abCodeBuff, pctxt->pbOp, pterm->pbOpEnd - pctxt->pbOp);
  550. pctxt->pbOp = pterm->pbOpEnd;
  551. }
  552. }
  553. EXIT(2, ("Method=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  554. return rc;
  555. } //Method
  556. /***LP InitMutex - Initialize a mutex object
  557. *
  558. * ENTRY
  559. * pheap -> HEAP
  560. * pns -> mutex object to be initialized
  561. * dwLevel - sync level
  562. *
  563. * EXIT-SUCCESS
  564. * returns STATUS_SUCCESS
  565. * EXIT-FAILURE
  566. * returns AMLIERR_ code
  567. */
  568. NTSTATUS LOCAL InitMutex(PHEAP pheap, PNSOBJ pns, ULONG dwLevel)
  569. {
  570. TRACENAME("INITMUTEX")
  571. NTSTATUS rc = STATUS_SUCCESS;
  572. ENTER(2, ("InitMutex(pheap=%x,pns=%x,Level=%x)\n", pheap, pns, dwLevel));
  573. pns->ObjData.dwDataType = OBJTYPE_MUTEX;
  574. pns->ObjData.dwDataLen = sizeof(MUTEXOBJ);
  575. if ((pns->ObjData.pbDataBuff = NEWMTOBJ(pheap, pns->ObjData.dwDataLen)) ==
  576. NULL)
  577. {
  578. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  579. ("InitMutex: failed to allocate Mutex object"));
  580. }
  581. else
  582. {
  583. MEMZERO(pns->ObjData.pbDataBuff, pns->ObjData.dwDataLen);
  584. ((PMUTEXOBJ)pns->ObjData.pbDataBuff)->dwSyncLevel = dwLevel;
  585. }
  586. EXIT(2, ("InitMutex=%x\n", rc));
  587. return rc;
  588. } //InitMutex
  589. /***LP Mutex - Parse and execute the Mutex instruction
  590. *
  591. * ENTRY
  592. * pctxt -> CTXT
  593. * pterm -> TERM
  594. *
  595. * EXIT-SUCCESS
  596. * returns STATUS_SUCCESS
  597. * EXIT-FAILURE
  598. * returns AMLIERR_ code
  599. */
  600. NTSTATUS LOCAL Mutex(PCTXT pctxt, PTERM pterm)
  601. {
  602. TRACENAME("MUTEX")
  603. NTSTATUS rc = STATUS_SUCCESS;
  604. ENTER(2, ("Mutex(pctxt=%x,pbOp=%x,pterm=%x)\n", pctxt, pctxt->pbOp, pterm));
  605. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  606. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  607. pctxt->pnsScope, pctxt->powner,
  608. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  609. {
  610. rc = InitMutex(pctxt->pheapCurrent, pterm->pnsObj,
  611. (ULONG)pterm->pdataArgs[1].uipDataValue);
  612. }
  613. EXIT(2, ("Mutex=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  614. return rc;
  615. } //Mutex
  616. /***LP OpRegion - Parse and execute the Field instruction
  617. *
  618. * ENTRY
  619. * pctxt -> CTXT
  620. * pterm -> TERM
  621. *
  622. * EXIT-SUCCESS
  623. * returns STATUS_SUCCESS
  624. * EXIT-FAILURE
  625. * returns AMLIERR_ code
  626. */
  627. NTSTATUS LOCAL OpRegion(PCTXT pctxt, PTERM pterm)
  628. {
  629. TRACENAME("OPREGION")
  630. NTSTATUS rc = STATUS_SUCCESS;
  631. ENTER(2, ("OpRegion(pctxt=%x,pbOp=%x,pterm=%x)\n",
  632. pctxt, pctxt->pbOp, pterm));
  633. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  634. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  635. pctxt->pnsScope, pctxt->powner,
  636. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  637. {
  638. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_OPREGION;
  639. pterm->pnsObj->ObjData.dwDataLen = sizeof(OPREGIONOBJ);
  640. if ((pterm->pnsObj->ObjData.pbDataBuff =
  641. NEWOROBJ(pctxt->pheapCurrent, pterm->pnsObj->ObjData.dwDataLen))
  642. == NULL)
  643. {
  644. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  645. ("OpRegion: failed to allocate OpRegion object"));
  646. }
  647. else
  648. {
  649. POPREGIONOBJ pop;
  650. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  651. pterm->pnsObj->ObjData.dwDataLen);
  652. pop = (POPREGIONOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  653. pop->bRegionSpace = (UCHAR)pterm->pdataArgs[1].uipDataValue;
  654. pop->uipOffset = pterm->pdataArgs[2].uipDataValue;
  655. pop->dwLen = (ULONG)pterm->pdataArgs[3].uipDataValue;
  656. KeInitializeSpinLock(&pop->listLock);
  657. if (pop->bRegionSpace == REGSPACE_MEM)
  658. {
  659. if(gInitTime)
  660. {
  661. ValidateMemoryOpregionRange(pop->uipOffset, pop->dwLen);
  662. }
  663. rc = MapUnmapPhysMem(pctxt, pop->uipOffset, pop->dwLen,
  664. &pop->uipOffset);
  665. }
  666. else if (pop->bRegionSpace == REGSPACE_IO)
  667. {
  668. PHYSICAL_ADDRESS phyaddr = {0, 0}, XlatedAddr;
  669. ULONG dwAddrSpace;
  670. phyaddr.LowPart = (ULONG)pop->uipOffset;
  671. dwAddrSpace = 1;
  672. if (HalTranslateBusAddress(Internal, 0, phyaddr, &dwAddrSpace,
  673. &XlatedAddr))
  674. {
  675. pop->uipOffset = (ULONG_PTR)XlatedAddr.LowPart;
  676. }
  677. else
  678. {
  679. rc = AMLI_LOGERR(AMLIERR_FAILED_ADDR_XLATE,
  680. ("OpRegion: failed to translate IO address %x",
  681. pop->uipOffset));
  682. }
  683. }
  684. else if (pop->bRegionSpace == REGSPACE_PCIBARTARGET)
  685. {
  686. if (ghCreate.pfnHandler != NULL)
  687. {
  688. ((PFNOO)ghCreate.pfnHandler)(OBJTYPE_OPREGION, pterm->pnsObj);
  689. }
  690. }
  691. }
  692. }
  693. EXIT(2, ("OpRegion=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  694. return rc;
  695. } //OpRegion
  696. /***LP PowerRes - Parse and execute the PowerRes instruction
  697. *
  698. * ENTRY
  699. * pctxt -> CTXT
  700. * pterm -> TERM
  701. *
  702. * EXIT-SUCCESS
  703. * returns STATUS_SUCCESS
  704. * EXIT-FAILURE
  705. * returns AMLIERR_ code
  706. */
  707. NTSTATUS LOCAL PowerRes(PCTXT pctxt, PTERM pterm)
  708. {
  709. TRACENAME("POWERRES")
  710. NTSTATUS rc = STATUS_SUCCESS;
  711. ENTER(2, ("PowerRes(pctxt=%x,pbOp=%x,pterm=%x)\n",
  712. pctxt, pctxt->pbOp, pterm));
  713. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  714. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  715. pctxt->pnsScope, pctxt->powner,
  716. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  717. {
  718. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_POWERRES;
  719. pterm->pnsObj->ObjData.dwDataLen = sizeof(POWERRESOBJ);
  720. if ((pterm->pnsObj->ObjData.pbDataBuff =
  721. NEWPROBJ(pctxt->pheapCurrent, pterm->pnsObj->ObjData.dwDataLen))
  722. == NULL)
  723. {
  724. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  725. ("PowerRes: failed to allocate PowerRes object"));
  726. }
  727. else
  728. {
  729. PPOWERRESOBJ ppr;
  730. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  731. pterm->pnsObj->ObjData.dwDataLen);
  732. ppr = (PPOWERRESOBJ)pterm->pnsObj->ObjData.pbDataBuff;
  733. ppr->bSystemLevel = (UCHAR)pterm->pdataArgs[1].uipDataValue;
  734. ppr->bResOrder = (UCHAR)pterm->pdataArgs[2].uipDataValue;
  735. if (ghCreate.pfnHandler != NULL)
  736. {
  737. ((PFNOO)ghCreate.pfnHandler)(OBJTYPE_POWERRES, pterm->pnsObj);
  738. }
  739. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, NULL,
  740. pterm->pnsObj, pctxt->powner, pctxt->pheapCurrent,
  741. pterm->pdataResult);
  742. }
  743. }
  744. EXIT(2, ("PowerRes=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  745. return rc;
  746. } //PowerRes
  747. /***LP Processor - Parse and execute the Processor instruction
  748. *
  749. * ENTRY
  750. * pctxt -> CTXT
  751. * pterm -> TERM
  752. *
  753. * EXIT-SUCCESS
  754. * returns STATUS_SUCCESS
  755. * EXIT-FAILURE
  756. * returns AMLIERR_ code
  757. */
  758. NTSTATUS LOCAL Processor(PCTXT pctxt, PTERM pterm)
  759. {
  760. TRACENAME("PROCESSOR")
  761. NTSTATUS rc = STATUS_SUCCESS;
  762. ENTER(2, ("Processor(pctxt=%x,pbOp=%x,pterm=%x)\n",
  763. pctxt, pctxt->pbOp, pterm));
  764. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  765. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  766. pctxt->pnsScope, pctxt->powner,
  767. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  768. {
  769. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_PROCESSOR;
  770. pterm->pnsObj->ObjData.dwDataLen = sizeof(PROCESSOROBJ);
  771. if ((pterm->pnsObj->ObjData.pbDataBuff =
  772. NEWPCOBJ(pctxt->pheapCurrent, pterm->pnsObj->ObjData.dwDataLen))
  773. == NULL)
  774. {
  775. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  776. ("Processor: failed to allocate processor object"));
  777. }
  778. else
  779. {
  780. PPROCESSOROBJ pproc;
  781. MEMZERO(pterm->pnsObj->ObjData.pbDataBuff,
  782. pterm->pnsObj->ObjData.dwDataLen);
  783. pproc = (PPROCESSOROBJ)pterm->pnsObj->ObjData.pbDataBuff;
  784. pproc->bApicID = (UCHAR)pterm->pdataArgs[1].uipDataValue;
  785. pproc->dwPBlk = (ULONG)pterm->pdataArgs[2].uipDataValue;
  786. pproc->dwPBlkLen = (ULONG)pterm->pdataArgs[3].uipDataValue;
  787. if (ghCreate.pfnHandler != NULL)
  788. {
  789. ((PFNOO)ghCreate.pfnHandler)(OBJTYPE_PROCESSOR, pterm->pnsObj);
  790. }
  791. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, NULL,
  792. pterm->pnsObj, pctxt->powner, pctxt->pheapCurrent,
  793. pterm->pdataResult);
  794. }
  795. }
  796. EXIT(2, ("Processor=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  797. return rc;
  798. } //Processor
  799. /***LP ThermalZone - Parse and execute the ThermalZone instruction
  800. *
  801. * ENTRY
  802. * pctxt -> CTXT
  803. * pterm -> TERM
  804. *
  805. * EXIT-SUCCESS
  806. * returns STATUS_SUCCESS
  807. * EXIT-FAILURE
  808. * returns AMLIERR_ code
  809. */
  810. NTSTATUS LOCAL ThermalZone(PCTXT pctxt, PTERM pterm)
  811. {
  812. TRACENAME("ThermalZone")
  813. NTSTATUS rc = STATUS_SUCCESS;
  814. ENTER(2, ("ThermalZone(pctxt=%x,pbOp=%x,pterm=%x)\n",
  815. pctxt, pctxt->pbOp, pterm));
  816. if ((rc = CreateNameSpaceObject(pctxt->pheapCurrent,
  817. (PSZ)pterm->pdataArgs[0].pbDataBuff,
  818. pctxt->pnsScope, pctxt->powner,
  819. &pterm->pnsObj, 0)) == STATUS_SUCCESS)
  820. {
  821. pterm->pnsObj->ObjData.dwDataType = OBJTYPE_THERMALZONE;
  822. if (ghCreate.pfnHandler != NULL)
  823. {
  824. ((PFNOO)ghCreate.pfnHandler)(OBJTYPE_THERMALZONE, pterm->pnsObj);
  825. }
  826. rc = PushScope(pctxt, pctxt->pbOp, pterm->pbOpEnd, NULL, pterm->pnsObj,
  827. pctxt->powner, pctxt->pheapCurrent, pterm->pdataResult);
  828. }
  829. EXIT(2, ("ThermalZone=%x (pnsObj=%x)\n", rc, pterm->pnsObj));
  830. return rc;
  831. } //ThermalZone