Source code of Windows XP (NT5)
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.

829 lines
23 KiB

  1. /*** acpins.c - ACPI Name Space functions
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created 09/09/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 GetNameSpaceObject - Find a name space object
  15. *
  16. * ENTRY
  17. * pszObjPath -> object path string
  18. * pnsScope - object scope to start the search (NULL means root)
  19. * ppnsObj -> to hold the object found
  20. * dwfNS - flags
  21. *
  22. * EXIT-SUCCESS
  23. * returns STATUS_SUCCESS
  24. * EXIT-FAILURE
  25. * returns AMLIERR_ code
  26. */
  27. NTSTATUS LOCAL GetNameSpaceObject(PSZ pszObjPath, PNSOBJ pnsScope, PPNSOBJ ppns,
  28. ULONG dwfNS)
  29. {
  30. TRACENAME("GETNAMESPACEOBJECT")
  31. NTSTATUS rc = STATUS_SUCCESS;
  32. PSZ psz;
  33. ENTER(3, ("GetNameSpaceObject(ObjPath=%s,Scope=%s,ppns=%x,Flags=%x)\n",
  34. pszObjPath, GetObjectPath(pnsScope), ppns, dwfNS));
  35. if (pnsScope == NULL)
  36. pnsScope = gpnsNameSpaceRoot;
  37. if (*pszObjPath == '\\')
  38. {
  39. psz = &pszObjPath[1];
  40. pnsScope = gpnsNameSpaceRoot;
  41. }
  42. else
  43. {
  44. psz = pszObjPath;
  45. while ((*psz == '^') && (pnsScope != NULL))
  46. {
  47. psz++;
  48. pnsScope = pnsScope->pnsParent;
  49. }
  50. }
  51. *ppns = pnsScope;
  52. if (pnsScope == NULL)
  53. rc = AMLIERR_OBJ_NOT_FOUND;
  54. else if (*psz != '\0')
  55. {
  56. BOOLEAN fSearchUp;
  57. PNSOBJ pns;
  58. fSearchUp = (BOOLEAN)(!(dwfNS & NSF_LOCAL_SCOPE) &&
  59. (pszObjPath[0] != '\\') &&
  60. (pszObjPath[0] != '^') &&
  61. (STRLEN(pszObjPath) <= sizeof(NAMESEG)));
  62. for (;;)
  63. {
  64. do
  65. {
  66. if ((pns = pnsScope->pnsFirstChild) == NULL)
  67. rc = AMLIERR_OBJ_NOT_FOUND;
  68. else
  69. {
  70. BOOLEAN fFound;
  71. PSZ pszEnd;
  72. ULONG dwLen;
  73. NAMESEG dwName;
  74. if ((pszEnd = STRCHR(psz, '.')) != NULL)
  75. dwLen = (ULONG)(pszEnd - psz);
  76. else
  77. dwLen = STRLEN(psz);
  78. if (dwLen > sizeof(NAMESEG))
  79. {
  80. rc = AMLI_LOGERR(AMLIERR_INVALID_NAME,
  81. ("GetNameSpaceObject: invalid name - %s",
  82. pszObjPath));
  83. // Satisfy the compiler...
  84. fFound = FALSE;
  85. }
  86. else
  87. {
  88. dwName = NAMESEG_BLANK;
  89. MEMCPY(&dwName, psz, dwLen);
  90. //
  91. // Search all siblings for a matching NameSeg.
  92. //
  93. fFound = FALSE;
  94. do
  95. {
  96. if (pns->dwNameSeg == dwName)
  97. {
  98. pnsScope = pns;
  99. fFound = TRUE;
  100. break;
  101. }
  102. pns = (PNSOBJ)pns->list.plistNext;
  103. } while (pns != pns->pnsParent->pnsFirstChild);
  104. }
  105. if (rc == STATUS_SUCCESS)
  106. {
  107. if (!fFound)
  108. rc = AMLIERR_OBJ_NOT_FOUND;
  109. else
  110. {
  111. psz += dwLen;
  112. if (*psz == '.')
  113. {
  114. psz++;
  115. }
  116. else if (*psz == '\0')
  117. {
  118. *ppns = pnsScope;
  119. break;
  120. }
  121. }
  122. }
  123. }
  124. } while (rc == STATUS_SUCCESS);
  125. if ((rc == AMLIERR_OBJ_NOT_FOUND) && fSearchUp &&
  126. (pnsScope != NULL) && (pnsScope->pnsParent != NULL))
  127. {
  128. pnsScope = pnsScope->pnsParent;
  129. rc = STATUS_SUCCESS;
  130. }
  131. else
  132. {
  133. break;
  134. }
  135. }
  136. }
  137. if ((dwfNS & NSF_WARN_NOTFOUND) && (rc == AMLIERR_OBJ_NOT_FOUND))
  138. {
  139. rc = AMLI_LOGERR(rc, ("GetNameSpaceObject: object %s not found",
  140. pszObjPath));
  141. }
  142. if (rc != STATUS_SUCCESS)
  143. {
  144. *ppns = NULL;
  145. }
  146. EXIT(3, ("GetNameSpaceObject=%x (pns=%x)\n", rc, *ppns));
  147. return rc;
  148. } //GetNameSpaceObject
  149. /***LP CreateNameSpaceObject - Create a name space object under current scope
  150. *
  151. * ENTRY
  152. * pheap -> HEAP
  153. * pszName -> name string of the object (NULL if creating noname object)
  154. * pnsScope - scope to create object under (NULL means root)
  155. * powner -> object owner
  156. * ppns -> to hold the pointer to the new object (can be NULL)
  157. * dwfNS - flags
  158. *
  159. * EXIT-SUCCESS
  160. * returns STATUS_SUCCESS
  161. * EXIT-FAILURE
  162. * returns AMLIERR_ code
  163. */
  164. NTSTATUS LOCAL CreateNameSpaceObject(PHEAP pheap, PSZ pszName, PNSOBJ pnsScope,
  165. POBJOWNER powner, PPNSOBJ ppns,
  166. ULONG dwfNS)
  167. {
  168. TRACENAME("CREATENAMESPACEOBJECT")
  169. NTSTATUS rc = STATUS_SUCCESS;
  170. PNSOBJ pns = NULL;
  171. ENTER(3, ("CreateNameSpaceObject(pheap=%x,Name=%s,pnsScope=%x,powner=%x,ppns=%x,Flags=%x)\n",
  172. pheap, pszName? pszName: "<null>", pnsScope, powner, ppns, dwfNS));
  173. if (pnsScope == NULL)
  174. pnsScope = gpnsNameSpaceRoot;
  175. if (pszName == NULL)
  176. {
  177. if ((pns = NEWNSOBJ(pheap, sizeof(NSOBJ))) == NULL)
  178. {
  179. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  180. ("CreateNameSpaceObject: fail to allocate name space object"));
  181. }
  182. else
  183. {
  184. ASSERT(gpnsNameSpaceRoot != NULL);
  185. MEMZERO(pns, sizeof(NSOBJ));
  186. pns->pnsParent = pnsScope;
  187. InsertOwnerObjList(powner, pns);
  188. ListInsertTail(&pns->list,
  189. (PPLIST)&pnsScope->pnsFirstChild);
  190. }
  191. }
  192. else if ((*pszName != '\0') &&
  193. ((rc = GetNameSpaceObject(pszName, pnsScope, &pns,
  194. NSF_LOCAL_SCOPE)) == STATUS_SUCCESS))
  195. {
  196. if (!(dwfNS & NSF_EXIST_OK))
  197. {
  198. rc = AMLI_LOGERR(AMLIERR_OBJ_ALREADY_EXIST,
  199. ("CreateNameSpaceObject: object already exist - %s",
  200. pszName));
  201. }
  202. }
  203. else if ((*pszName == '\0') || (rc == AMLIERR_OBJ_NOT_FOUND))
  204. {
  205. rc = STATUS_SUCCESS;
  206. //
  207. // Are we creating root?
  208. //
  209. if (STRCMP(pszName, "\\") == 0)
  210. {
  211. ASSERT(gpnsNameSpaceRoot == NULL);
  212. ASSERT(powner == NULL);
  213. if ((pns = NEWNSOBJ(pheap, sizeof(NSOBJ))) == NULL)
  214. {
  215. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  216. ("CreateNameSpaceObject: fail to allocate name space object"));
  217. }
  218. else
  219. {
  220. MEMZERO(pns, sizeof(NSOBJ));
  221. pns->dwNameSeg = NAMESEG_ROOT;
  222. gpnsNameSpaceRoot = pns;
  223. InsertOwnerObjList(powner, pns);
  224. }
  225. }
  226. else
  227. {
  228. PSZ psz;
  229. PNSOBJ pnsParent;
  230. if ((psz = STRRCHR(pszName, '.')) != NULL)
  231. {
  232. *psz = '\0';
  233. psz++;
  234. rc = GetNameSpaceObject(pszName, pnsScope, &pnsParent,
  235. NSF_LOCAL_SCOPE | NSF_WARN_NOTFOUND);
  236. }
  237. else if (*pszName == '\\')
  238. {
  239. psz = &pszName[1];
  240. //
  241. // By this time, we'd better created root already.
  242. //
  243. ASSERT(gpnsNameSpaceRoot != NULL);
  244. pnsParent = gpnsNameSpaceRoot;
  245. }
  246. else if (*pszName == '^')
  247. {
  248. psz = pszName;
  249. pnsParent = pnsScope;
  250. while ((*psz == '^') && (pnsParent != NULL))
  251. {
  252. pnsParent = pnsParent->pnsParent;
  253. psz++;
  254. }
  255. }
  256. else
  257. {
  258. ASSERT(pnsScope != NULL);
  259. psz = pszName;
  260. pnsParent = pnsScope;
  261. }
  262. if (rc == STATUS_SUCCESS)
  263. {
  264. int iLen = STRLEN(psz);
  265. if ((*psz != '\0') && (iLen > sizeof(NAMESEG)))
  266. {
  267. rc = AMLI_LOGERR(AMLIERR_INVALID_NAME,
  268. ("CreateNameSpaceObject: invalid name - %s",
  269. psz));
  270. }
  271. else if ((pns = NEWNSOBJ(pheap, sizeof(NSOBJ)))
  272. == NULL)
  273. {
  274. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  275. ("CreateNameSpaceObject: fail to allocate name space object"));
  276. }
  277. else
  278. {
  279. MEMZERO(pns, sizeof(NSOBJ));
  280. if (*pszName == '\0')
  281. pns->dwNameSeg = NAMESEG_NONE;
  282. else
  283. {
  284. pns->dwNameSeg = NAMESEG_BLANK;
  285. MEMCPY(&pns->dwNameSeg, psz, iLen);
  286. }
  287. pns->pnsParent = pnsParent;
  288. InsertOwnerObjList(powner, pns);
  289. ListInsertTail(&pns->list,
  290. (PPLIST)&pnsParent->pnsFirstChild);
  291. }
  292. }
  293. }
  294. }
  295. if ((rc == STATUS_SUCCESS) && (ppns != NULL))
  296. *ppns = pns;
  297. EXIT(3, ("CreateNameSpaceObject=%x (pns=%x)\n", rc, pns));
  298. return rc;
  299. } //CreateNameSpaceObject
  300. /***LP FreeNameSpaceObjects - Free Name Space object and its children
  301. *
  302. * ENTRY
  303. * pnsObj -> name space object
  304. *
  305. * EXIT
  306. * None
  307. */
  308. VOID LOCAL FreeNameSpaceObjects(PNSOBJ pnsObj)
  309. {
  310. TRACENAME("FREENAMESPACEOBJECTS")
  311. PNSOBJ pns, pnsSibling, pnsParent;
  312. #ifdef DEBUGGER
  313. POBJSYM pos;
  314. #endif
  315. ENTER(3, ("FreeNameSpaceObjects(Obj=%s)\n", GetObjectPath(pnsObj)));
  316. ASSERT(pnsObj != NULL);
  317. for (pns = pnsObj; pns != NULL;)
  318. {
  319. while (pns->pnsFirstChild != NULL)
  320. {
  321. pns = pns->pnsFirstChild;
  322. }
  323. pnsSibling = NSGETNEXTSIBLING(pns);
  324. pnsParent = NSGETPARENT(pns);
  325. ENTER(4, ("FreeNSObj(Obj=%s)\n", GetObjectPath(pns)));
  326. #ifdef DEBUGGER
  327. //
  328. // If I am in the symbol list, get rid of it before I die.
  329. //
  330. for (pos = gDebugger.posSymbolList; pos != NULL; pos = pos->posNext)
  331. {
  332. if (pns == pos->pnsObj)
  333. {
  334. if (pos->posPrev != NULL)
  335. pos->posPrev->posNext = pos->posNext;
  336. if (pos->posNext != NULL)
  337. pos->posNext->posPrev = pos->posPrev;
  338. if (pos == gDebugger.posSymbolList)
  339. gDebugger.posSymbolList = pos->posNext;
  340. FREESYOBJ(pos);
  341. break;
  342. }
  343. }
  344. #endif
  345. //
  346. // All my children are gone, I must die now.
  347. //
  348. ASSERT(pns->pnsFirstChild == NULL);
  349. if ((pns->ObjData.dwDataType == OBJTYPE_OPREGION) &&
  350. (((POPREGIONOBJ)pns->ObjData.pbDataBuff)->bRegionSpace ==
  351. REGSPACE_MEM))
  352. {
  353. ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
  354. MmUnmapIoSpace((PVOID)
  355. ((POPREGIONOBJ)pns->ObjData.pbDataBuff)->uipOffset,
  356. ((POPREGIONOBJ)pns->ObjData.pbDataBuff)->dwLen);
  357. }
  358. if (pns->pnsParent == NULL)
  359. {
  360. //
  361. // I am root!
  362. //
  363. ASSERT(pns == gpnsNameSpaceRoot);
  364. gpnsNameSpaceRoot = NULL;
  365. }
  366. else
  367. {
  368. ListRemoveEntry(&pns->list,
  369. (PPLIST)&pns->pnsParent->pnsFirstChild);
  370. }
  371. //
  372. // Free any attached data buffer if any
  373. //
  374. FreeDataBuffs(&pns->ObjData, 1);
  375. //
  376. // Free myself
  377. //
  378. if (pns->dwRefCount == 0)
  379. {
  380. FREENSOBJ(pns);
  381. }
  382. else
  383. {
  384. pns->ObjData.dwfData |= DATAF_NSOBJ_DEFUNC;
  385. ListInsertTail(&pns->list, &gplistDefuncNSObjs);
  386. }
  387. EXIT(4, ("FreeNSObj!\n"));
  388. if (pns == pnsObj)
  389. {
  390. //
  391. // I was the last one, done!
  392. //
  393. pns = NULL;
  394. }
  395. else if (pnsSibling != NULL)
  396. {
  397. //
  398. // I have siblings, go kill them.
  399. //
  400. pns = pnsSibling;
  401. }
  402. else
  403. {
  404. ASSERT(pnsParent != NULL);
  405. pns = pnsParent;
  406. }
  407. }
  408. EXIT(3, ("FreeNameSpaceObjects!\n"));
  409. } //FreeNameSpaceObjects
  410. /***LP LoadDDB - Load and parse Differentiated Definition Block
  411. *
  412. * ENTRY
  413. * pctxt -> CTXT
  414. * pdsdt -> DSDT block
  415. * pnsScope -> current scope
  416. * ppowner -> to hold new object owner
  417. *
  418. * EXIT-SUCCESS
  419. * returns STATUS_SUCCESS
  420. * EXIT-FAILURE
  421. * returns AMLIERR_ code
  422. */
  423. NTSTATUS
  424. LOCAL
  425. LoadDDB(
  426. PCTXT pctxt,
  427. PDSDT pdsdt,
  428. PNSOBJ pnsScope,
  429. POBJOWNER *ppowner
  430. )
  431. {
  432. BOOLEAN freeTable = FALSE;
  433. NTSTATUS rc = STATUS_SUCCESS;
  434. if (!ValidateTable(pdsdt)) {
  435. rc = AMLI_LOGERR(
  436. AMLIERR_INVALID_TABLE,
  437. ("LoadDDB: invalid table %s at 0x%08x",
  438. NameSegString(pdsdt->Header.Signature), pdsdt)
  439. );
  440. freeTable = TRUE;
  441. } else {
  442. rc = NewObjOwner( gpheapGlobal, ppowner);
  443. if (rc == STATUS_SUCCESS) {
  444. if (pctxt->pcall == NULL) {
  445. rc = PushCall(pctxt, NULL, &pctxt->Result);
  446. }
  447. if (rc == STATUS_SUCCESS) {
  448. #ifdef DEBUGGER
  449. gDebugger.pbBlkBegin = pdsdt->DiffDefBlock;
  450. gDebugger.pbBlkEnd = (PUCHAR)pdsdt + pdsdt->Header.Length;
  451. #endif
  452. rc = PushScope(
  453. pctxt,
  454. pdsdt->DiffDefBlock,
  455. (PUCHAR)pdsdt + pdsdt->Header.Length, pctxt->pbOp,
  456. pnsScope, *ppowner, gpheapGlobal, &pctxt->Result
  457. );
  458. }
  459. } else {
  460. freeTable = TRUE;
  461. }
  462. }
  463. if (freeTable) {
  464. pctxt->powner = NULL;
  465. FreeContext(pctxt);
  466. }
  467. return rc;
  468. } //LoadDDB
  469. /***LP LoadMemDDB - Load DDB from physical memory
  470. *
  471. * ENTRY
  472. * pctxt -> CTXT
  473. * pDDB -> beginning of DDB
  474. * ppowner -> to hold owner handle
  475. *
  476. * EXIT-SUCCESS
  477. * returns STATUS_SUCCESS
  478. * EXIT-FAILURE
  479. * returns AMLIERR_ code
  480. */
  481. NTSTATUS LOCAL LoadMemDDB(PCTXT pctxt, PDSDT pDDB, POBJOWNER *ppowner)
  482. {
  483. TRACENAME("LOADMEMDDB")
  484. NTSTATUS rc = STATUS_SUCCESS;
  485. ENTER(3, ("LoadMemDDB(pctxt=%x,Addr=%x,ppowner=%x)\n",
  486. pctxt, pDDB, ppowner));
  487. if ((ghValidateTable.pfnHandler != NULL) &&
  488. ((rc = ((PFNVT)ghValidateTable.pfnHandler)(pDDB,
  489. ghValidateTable.uipParam)) !=
  490. STATUS_SUCCESS))
  491. {
  492. rc = AMLI_LOGERR(AMLIERR_INVALID_TABLE,
  493. ("LoadMemDDB: table validation failed (rc=%x)",
  494. rc));
  495. }
  496. else
  497. {
  498. rc = LoadDDB(pctxt, pDDB, pctxt->pnsScope, ppowner);
  499. }
  500. EXIT(3, ("LoadMemDDB=%x (powner=%x)\n", rc, *ppowner));
  501. return rc;
  502. } //LoadMemDDB
  503. /***LP LoadFieldUnitDDB - Load DDB from a FieldUnit object
  504. *
  505. * ENTRY
  506. * pctxt -> CTXT
  507. * pdataObj -> FieldUnit object
  508. * ppowner -> to hold owner handle
  509. *
  510. * EXIT-SUCCESS
  511. * returns STATUS_SUCCESS
  512. * EXIT-FAILURE
  513. * returns AMLIERR_ code
  514. */
  515. NTSTATUS LOCAL LoadFieldUnitDDB(PCTXT pctxt, POBJDATA pdataObj,
  516. POBJOWNER *ppowner)
  517. {
  518. TRACENAME("LOADFIELDUNITDDB")
  519. NTSTATUS rc = STATUS_SUCCESS;
  520. POBJDATA pdataTmp;
  521. DESCRIPTION_HEADER *pdh;
  522. ENTER(3, ("LoadFieldUnitDDB(pctxt=%x,pdataObj=%x,ppowner=%x)\n",
  523. pctxt, pdataObj, ppowner));
  524. if ((pdataTmp = NEWODOBJ(pctxt->pheapCurrent, sizeof(OBJDATA))) == NULL)
  525. {
  526. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  527. ("LoadFieldUnitDDB: failed to allocate temp. object data"));
  528. }
  529. else if ((pdh = NEWBDOBJ(gpheapGlobal, sizeof(DESCRIPTION_HEADER))) == NULL)
  530. {
  531. FREEODOBJ(pdataTmp);
  532. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  533. ("LoadFieldUnitDDB: failed to allocate description header"));
  534. }
  535. else
  536. {
  537. PUCHAR pbTable;
  538. MEMZERO(pdataTmp, sizeof(OBJDATA));
  539. pdataTmp->dwDataType = OBJTYPE_BUFFDATA;
  540. pdataTmp->dwDataLen = sizeof(DESCRIPTION_HEADER);
  541. pdataTmp->pbDataBuff = (PUCHAR)pdh;
  542. if ((rc = ReadObject(pctxt, pdataObj, pdataTmp)) == STATUS_SUCCESS)
  543. {
  544. if ((pbTable = NEWBDOBJ(gpheapGlobal, pdh->Length)) == NULL)
  545. {
  546. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  547. ("LoadFieldUnitDDB: failed to allocate buffer"));
  548. }
  549. else
  550. {
  551. MEMCPY(pbTable, pdh, sizeof(DESCRIPTION_HEADER));
  552. pdataTmp->dwDataLen = pdh->Length - sizeof(DESCRIPTION_HEADER);
  553. pdataTmp->pbDataBuff = pbTable + sizeof(DESCRIPTION_HEADER);
  554. if ((rc = ReadObject(pctxt, pdataObj, pdataTmp)) ==
  555. STATUS_SUCCESS)
  556. {
  557. if ((ghValidateTable.pfnHandler != NULL) &&
  558. ((rc = ((PFNVT)ghValidateTable.pfnHandler)(
  559. (PDSDT)pbTable, ghValidateTable.uipParam)) !=
  560. STATUS_SUCCESS))
  561. {
  562. rc = AMLI_LOGERR(AMLIERR_INVALID_TABLE,
  563. ("LoadFieldUnitDDB: table validation failed (rc=%x)",
  564. rc));
  565. }
  566. else
  567. {
  568. rc = LoadDDB(pctxt, (PDSDT)pbTable, pctxt->pnsScope,
  569. ppowner);
  570. }
  571. }
  572. else if (rc == AMLISTA_PENDING)
  573. {
  574. rc = AMLI_LOGERR(AMLIERR_FATAL,
  575. ("LoadFieldUnitDDB: definition block loading cannot block"));
  576. }
  577. FREEBDOBJ(pbTable);
  578. }
  579. }
  580. else if (rc == AMLISTA_PENDING)
  581. {
  582. rc = AMLI_LOGERR(AMLIERR_FATAL,
  583. ("LoadFieldUnitDDB: definition block loading cannot block"));
  584. }
  585. FREEBDOBJ(pdh);
  586. FREEODOBJ(pdataTmp);
  587. }
  588. EXIT(3, ("LoadFieldUnitDDB=%x (powner=%x)\n", rc, *ppowner));
  589. return rc;
  590. } //LoadFieldUnitDDB
  591. /***LP UnloadDDB - Unload Differentiated Definition Block
  592. *
  593. * ENTRY
  594. * powner -> OBJOWNER
  595. *
  596. * EXIT-SUCCESS
  597. * returns STATUS_SUCCESS
  598. * EXIT-FAILURE
  599. * returns AMLIERR_ code
  600. */
  601. VOID LOCAL UnloadDDB(POBJOWNER powner)
  602. {
  603. TRACENAME("UNLOADDDB")
  604. ENTER(3, ("UnloadDDB(powner=%x)\n", powner));
  605. //
  606. // Walk name space and remove all objects belongs to this DDB.
  607. //
  608. FreeObjOwner(powner, TRUE);
  609. #ifdef DEBUG
  610. {
  611. KIRQL oldIrql;
  612. KeAcquireSpinLock( &gdwGHeapSpinLock, &oldIrql );
  613. gdwGHeapSnapshot = gdwGlobalHeapSize;
  614. KeReleaseSpinLock( &gdwGHeapSpinLock, oldIrql );
  615. }
  616. #endif
  617. EXIT(3, ("UnloadDDB!\n"));
  618. } //UnloadDDB
  619. /***LP EvalPackageElement - Evaluate a package element
  620. *
  621. * ENTRY
  622. * ppkg -> package object
  623. * iPkgIndex - package index (0-based)
  624. * pdataResult -> result object
  625. *
  626. * EXIT-SUCCESS
  627. * returns STATUS_SUCCESS
  628. * EXIT-FAILURE
  629. * returns AMLIERR_ code
  630. */
  631. NTSTATUS LOCAL EvalPackageElement(PPACKAGEOBJ ppkg, int iPkgIndex,
  632. POBJDATA pdataResult)
  633. {
  634. TRACENAME("EVALPACKAGEELEMENT")
  635. NTSTATUS rc = STATUS_SUCCESS;
  636. ENTER(3, ("EvalPackageElement(ppkg=%x,Index=%d,pdataResult=%x)\n",
  637. ppkg, iPkgIndex, pdataResult));
  638. ASSERT(pdataResult != NULL);
  639. if (iPkgIndex >= (int)ppkg->dwcElements)
  640. {
  641. rc = AMLIERR_INDEX_TOO_BIG;
  642. }
  643. else
  644. {
  645. rc = DupObjData(gpheapGlobal, pdataResult, &ppkg->adata[iPkgIndex]);
  646. }
  647. EXIT(3, ("EvalPackageElement=%x (Type=%s,Value=%x,Len=%d,Buff=%x)\n",
  648. rc, GetObjectTypeName(pdataResult->dwDataType),
  649. pdataResult->uipDataValue, pdataResult->dwDataLen,
  650. pdataResult->pbDataBuff));
  651. return rc;
  652. } //EvalPackageElement
  653. #ifdef DEBUGGER
  654. /***LP DumpNameSpaceObject - Dump name space object
  655. *
  656. * ENTRY
  657. * pszPath -> name space path string
  658. * fRecursive - TRUE if also dump the subtree recursively
  659. *
  660. * EXIT-SUCCESS
  661. * returns STATUS_SUCCESS
  662. * EXIT-FAILURE
  663. * returns AMLIERR_ code
  664. */
  665. LONG LOCAL DumpNameSpaceObject(PSZ pszPath, BOOLEAN fRecursive)
  666. {
  667. TRACENAME("DUMPNAMESPACEOBJECT")
  668. NTSTATUS rc = STATUS_SUCCESS;
  669. PNSOBJ pns;
  670. char szName[sizeof(NAMESEG) + 1];
  671. ENTER(3, ("DumpNameSpaceObject(Path=%s,fRecursive=%x)\n",
  672. pszPath, fRecursive));
  673. if ((rc = GetNameSpaceObject(pszPath, NULL, &pns,
  674. NSF_LOCAL_SCOPE)) == STATUS_SUCCESS)
  675. {
  676. PRINTF("\nACPI Name Space: %s (%x)\n", pszPath, pns);
  677. if (!fRecursive)
  678. {
  679. STRCPYN(szName, (PSZ)&pns->dwNameSeg, sizeof(NAMESEG));
  680. DumpObject(&pns->ObjData, szName, 0);
  681. }
  682. else
  683. DumpNameSpaceTree(pns, 0);
  684. }
  685. else if (rc == AMLIERR_OBJ_NOT_FOUND)
  686. {
  687. PRINTF(MODNAME "_ERROR: object %s not found\n", pszPath);
  688. }
  689. EXIT(3, ("DumpNameSpaceObject=%x\n", rc));
  690. return rc;
  691. } //DumpNameSpaceObject
  692. /***LP DumpNameSpaceTree - Dump all the name space objects in the subtree
  693. *
  694. * ENTRY
  695. * pnsObj -> name space subtree root
  696. * dwLevel - indent level
  697. *
  698. * EXIT
  699. * None
  700. */
  701. VOID LOCAL DumpNameSpaceTree(PNSOBJ pnsObj, ULONG dwLevel)
  702. {
  703. TRACENAME("DUMPNAMESPACETREE")
  704. PNSOBJ pns, pnsNext;
  705. char szName[sizeof(NAMESEG) + 1];
  706. ENTER(3, ("DumpNameSpaceTree(pns=%x,level=%d)\n", pnsObj, dwLevel));
  707. //
  708. // First, dump myself
  709. //
  710. STRCPYN(szName, (PSZ)&pnsObj->dwNameSeg, sizeof(NAMESEG));
  711. DumpObject(&pnsObj->ObjData, szName, dwLevel);
  712. //
  713. // Then, recursively dump each of my children
  714. //
  715. for (pns = pnsObj->pnsFirstChild; pns != NULL; pns = pnsNext)
  716. {
  717. //
  718. // If this is the last child, we have no more.
  719. //
  720. if ((pnsNext = (PNSOBJ)pns->list.plistNext) == pnsObj->pnsFirstChild)
  721. pnsNext = NULL;
  722. //
  723. // Dump a child
  724. //
  725. DumpNameSpaceTree(pns, dwLevel + 1);
  726. }
  727. EXIT(3, ("DumpNameSpaceTree!\n"));
  728. } //DumpNameSpaceTree
  729. #endif //ifdef DEBUGGER