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.

833 lines
24 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. if(((POPREGIONOBJ)pns->ObjData.pbDataBuff)->dwLen)
  355. {
  356. MmUnmapIoSpace((PVOID)
  357. ((POPREGIONOBJ)pns->ObjData.pbDataBuff)->uipOffset,
  358. ((POPREGIONOBJ)pns->ObjData.pbDataBuff)->dwLen);
  359. }
  360. }
  361. if (pns->pnsParent == NULL)
  362. {
  363. //
  364. // I am root!
  365. //
  366. ASSERT(pns == gpnsNameSpaceRoot);
  367. gpnsNameSpaceRoot = NULL;
  368. }
  369. else
  370. {
  371. ListRemoveEntry(&pns->list,
  372. (PPLIST)&pns->pnsParent->pnsFirstChild);
  373. }
  374. //
  375. // Free any attached data buffer if any
  376. //
  377. FreeDataBuffs(&pns->ObjData, 1);
  378. //
  379. // Free myself
  380. //
  381. if (pns->dwRefCount == 0)
  382. {
  383. FREENSOBJ(pns);
  384. }
  385. else
  386. {
  387. pns->ObjData.dwfData |= DATAF_NSOBJ_DEFUNC;
  388. ListInsertTail(&pns->list, &gplistDefuncNSObjs);
  389. }
  390. EXIT(4, ("FreeNSObj!\n"));
  391. if (pns == pnsObj)
  392. {
  393. //
  394. // I was the last one, done!
  395. //
  396. pns = NULL;
  397. }
  398. else if (pnsSibling != NULL)
  399. {
  400. //
  401. // I have siblings, go kill them.
  402. //
  403. pns = pnsSibling;
  404. }
  405. else
  406. {
  407. ASSERT(pnsParent != NULL);
  408. pns = pnsParent;
  409. }
  410. }
  411. EXIT(3, ("FreeNameSpaceObjects!\n"));
  412. } //FreeNameSpaceObjects
  413. /***LP LoadDDB - Load and parse Differentiated Definition Block
  414. *
  415. * ENTRY
  416. * pctxt -> CTXT
  417. * pdsdt -> DSDT block
  418. * pnsScope -> current scope
  419. * ppowner -> to hold new object owner
  420. *
  421. * EXIT-SUCCESS
  422. * returns STATUS_SUCCESS
  423. * EXIT-FAILURE
  424. * returns AMLIERR_ code
  425. */
  426. NTSTATUS
  427. LOCAL
  428. LoadDDB(
  429. PCTXT pctxt,
  430. PDSDT pdsdt,
  431. PNSOBJ pnsScope,
  432. POBJOWNER *ppowner
  433. )
  434. {
  435. BOOLEAN freeTable = FALSE;
  436. NTSTATUS rc = STATUS_SUCCESS;
  437. if (!ValidateTable(pdsdt)) {
  438. rc = AMLI_LOGERR(
  439. AMLIERR_INVALID_TABLE,
  440. ("LoadDDB: invalid table %s at 0x%08x",
  441. NameSegString(pdsdt->Header.Signature), pdsdt)
  442. );
  443. freeTable = TRUE;
  444. } else {
  445. rc = NewObjOwner( gpheapGlobal, ppowner);
  446. if (rc == STATUS_SUCCESS) {
  447. if (pctxt->pcall == NULL) {
  448. rc = PushCall(pctxt, NULL, &pctxt->Result);
  449. }
  450. if (rc == STATUS_SUCCESS) {
  451. #ifdef DEBUGGER
  452. gDebugger.pbBlkBegin = pdsdt->DiffDefBlock;
  453. gDebugger.pbBlkEnd = (PUCHAR)pdsdt + pdsdt->Header.Length;
  454. #endif
  455. rc = PushScope(
  456. pctxt,
  457. pdsdt->DiffDefBlock,
  458. (PUCHAR)pdsdt + pdsdt->Header.Length, pctxt->pbOp,
  459. pnsScope, *ppowner, gpheapGlobal, &pctxt->Result
  460. );
  461. }
  462. } else {
  463. freeTable = TRUE;
  464. }
  465. }
  466. if (freeTable) {
  467. pctxt->powner = NULL;
  468. FreeContext(pctxt);
  469. }
  470. return rc;
  471. } //LoadDDB
  472. /***LP LoadMemDDB - Load DDB from physical memory
  473. *
  474. * ENTRY
  475. * pctxt -> CTXT
  476. * pDDB -> beginning of DDB
  477. * ppowner -> to hold owner handle
  478. *
  479. * EXIT-SUCCESS
  480. * returns STATUS_SUCCESS
  481. * EXIT-FAILURE
  482. * returns AMLIERR_ code
  483. */
  484. NTSTATUS LOCAL LoadMemDDB(PCTXT pctxt, PDSDT pDDB, POBJOWNER *ppowner)
  485. {
  486. TRACENAME("LOADMEMDDB")
  487. NTSTATUS rc = STATUS_SUCCESS;
  488. ENTER(3, ("LoadMemDDB(pctxt=%x,Addr=%x,ppowner=%x)\n",
  489. pctxt, pDDB, ppowner));
  490. if ((ghValidateTable.pfnHandler != NULL) &&
  491. ((rc = ((PFNVT)ghValidateTable.pfnHandler)(pDDB,
  492. ghValidateTable.uipParam)) !=
  493. STATUS_SUCCESS))
  494. {
  495. rc = AMLI_LOGERR(AMLIERR_INVALID_TABLE,
  496. ("LoadMemDDB: table validation failed (rc=%x)",
  497. rc));
  498. }
  499. else
  500. {
  501. rc = LoadDDB(pctxt, pDDB, pctxt->pnsScope, ppowner);
  502. }
  503. EXIT(3, ("LoadMemDDB=%x (powner=%x)\n", rc, *ppowner));
  504. return rc;
  505. } //LoadMemDDB
  506. /***LP LoadFieldUnitDDB - Load DDB from a FieldUnit object
  507. *
  508. * ENTRY
  509. * pctxt -> CTXT
  510. * pdataObj -> FieldUnit object
  511. * ppowner -> to hold owner handle
  512. *
  513. * EXIT-SUCCESS
  514. * returns STATUS_SUCCESS
  515. * EXIT-FAILURE
  516. * returns AMLIERR_ code
  517. */
  518. NTSTATUS LOCAL LoadFieldUnitDDB(PCTXT pctxt, POBJDATA pdataObj,
  519. POBJOWNER *ppowner)
  520. {
  521. TRACENAME("LOADFIELDUNITDDB")
  522. NTSTATUS rc = STATUS_SUCCESS;
  523. POBJDATA pdataTmp;
  524. DESCRIPTION_HEADER *pdh;
  525. ENTER(3, ("LoadFieldUnitDDB(pctxt=%x,pdataObj=%x,ppowner=%x)\n",
  526. pctxt, pdataObj, ppowner));
  527. if ((pdataTmp = NEWODOBJ(pctxt->pheapCurrent, sizeof(OBJDATA))) == NULL)
  528. {
  529. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  530. ("LoadFieldUnitDDB: failed to allocate temp. object data"));
  531. }
  532. else if ((pdh = NEWBDOBJ(gpheapGlobal, sizeof(DESCRIPTION_HEADER))) == NULL)
  533. {
  534. FREEODOBJ(pdataTmp);
  535. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  536. ("LoadFieldUnitDDB: failed to allocate description header"));
  537. }
  538. else
  539. {
  540. PUCHAR pbTable;
  541. MEMZERO(pdataTmp, sizeof(OBJDATA));
  542. pdataTmp->dwDataType = OBJTYPE_BUFFDATA;
  543. pdataTmp->dwDataLen = sizeof(DESCRIPTION_HEADER);
  544. pdataTmp->pbDataBuff = (PUCHAR)pdh;
  545. if ((rc = ReadObject(pctxt, pdataObj, pdataTmp)) == STATUS_SUCCESS)
  546. {
  547. if ((pbTable = NEWBDOBJ(gpheapGlobal, pdh->Length)) == NULL)
  548. {
  549. rc = AMLI_LOGERR(AMLIERR_OUT_OF_MEM,
  550. ("LoadFieldUnitDDB: failed to allocate buffer"));
  551. }
  552. else
  553. {
  554. MEMCPY(pbTable, pdh, sizeof(DESCRIPTION_HEADER));
  555. pdataTmp->dwDataLen = pdh->Length - sizeof(DESCRIPTION_HEADER);
  556. pdataTmp->pbDataBuff = pbTable + sizeof(DESCRIPTION_HEADER);
  557. if ((rc = ReadObject(pctxt, pdataObj, pdataTmp)) ==
  558. STATUS_SUCCESS)
  559. {
  560. if ((ghValidateTable.pfnHandler != NULL) &&
  561. ((rc = ((PFNVT)ghValidateTable.pfnHandler)(
  562. (PDSDT)pbTable, ghValidateTable.uipParam)) !=
  563. STATUS_SUCCESS))
  564. {
  565. rc = AMLI_LOGERR(AMLIERR_INVALID_TABLE,
  566. ("LoadFieldUnitDDB: table validation failed (rc=%x)",
  567. rc));
  568. }
  569. else
  570. {
  571. rc = LoadDDB(pctxt, (PDSDT)pbTable, pctxt->pnsScope,
  572. ppowner);
  573. }
  574. }
  575. else if (rc == AMLISTA_PENDING)
  576. {
  577. rc = AMLI_LOGERR(AMLIERR_FATAL,
  578. ("LoadFieldUnitDDB: definition block loading cannot block"));
  579. }
  580. FREEBDOBJ(pbTable);
  581. }
  582. }
  583. else if (rc == AMLISTA_PENDING)
  584. {
  585. rc = AMLI_LOGERR(AMLIERR_FATAL,
  586. ("LoadFieldUnitDDB: definition block loading cannot block"));
  587. }
  588. FREEBDOBJ(pdh);
  589. FREEODOBJ(pdataTmp);
  590. }
  591. EXIT(3, ("LoadFieldUnitDDB=%x (powner=%x)\n", rc, *ppowner));
  592. return rc;
  593. } //LoadFieldUnitDDB
  594. /***LP UnloadDDB - Unload Differentiated Definition Block
  595. *
  596. * ENTRY
  597. * powner -> OBJOWNER
  598. *
  599. * EXIT-SUCCESS
  600. * returns STATUS_SUCCESS
  601. * EXIT-FAILURE
  602. * returns AMLIERR_ code
  603. */
  604. VOID LOCAL UnloadDDB(POBJOWNER powner)
  605. {
  606. TRACENAME("UNLOADDDB")
  607. ENTER(3, ("UnloadDDB(powner=%x)\n", powner));
  608. //
  609. // Walk name space and remove all objects belongs to this DDB.
  610. //
  611. FreeObjOwner(powner, TRUE);
  612. #ifdef DEBUG
  613. {
  614. KIRQL oldIrql;
  615. KeAcquireSpinLock( &gdwGHeapSpinLock, &oldIrql );
  616. gdwGHeapSnapshot = gdwGlobalHeapSize;
  617. KeReleaseSpinLock( &gdwGHeapSpinLock, oldIrql );
  618. }
  619. #endif
  620. EXIT(3, ("UnloadDDB!\n"));
  621. } //UnloadDDB
  622. /***LP EvalPackageElement - Evaluate a package element
  623. *
  624. * ENTRY
  625. * ppkg -> package object
  626. * iPkgIndex - package index (0-based)
  627. * pdataResult -> result object
  628. *
  629. * EXIT-SUCCESS
  630. * returns STATUS_SUCCESS
  631. * EXIT-FAILURE
  632. * returns AMLIERR_ code
  633. */
  634. NTSTATUS LOCAL EvalPackageElement(PPACKAGEOBJ ppkg, int iPkgIndex,
  635. POBJDATA pdataResult)
  636. {
  637. TRACENAME("EVALPACKAGEELEMENT")
  638. NTSTATUS rc = STATUS_SUCCESS;
  639. ENTER(3, ("EvalPackageElement(ppkg=%x,Index=%d,pdataResult=%x)\n",
  640. ppkg, iPkgIndex, pdataResult));
  641. ASSERT(pdataResult != NULL);
  642. if (iPkgIndex >= (int)ppkg->dwcElements)
  643. {
  644. rc = AMLIERR_INDEX_TOO_BIG;
  645. }
  646. else
  647. {
  648. rc = DupObjData(gpheapGlobal, pdataResult, &ppkg->adata[iPkgIndex]);
  649. }
  650. EXIT(3, ("EvalPackageElement=%x (Type=%s,Value=%x,Len=%d,Buff=%x)\n",
  651. rc, GetObjectTypeName(pdataResult->dwDataType),
  652. pdataResult->uipDataValue, pdataResult->dwDataLen,
  653. pdataResult->pbDataBuff));
  654. return rc;
  655. } //EvalPackageElement
  656. #ifdef DEBUGGER
  657. /***LP DumpNameSpaceObject - Dump name space object
  658. *
  659. * ENTRY
  660. * pszPath -> name space path string
  661. * fRecursive - TRUE if also dump the subtree recursively
  662. *
  663. * EXIT-SUCCESS
  664. * returns STATUS_SUCCESS
  665. * EXIT-FAILURE
  666. * returns AMLIERR_ code
  667. */
  668. LONG LOCAL DumpNameSpaceObject(PSZ pszPath, BOOLEAN fRecursive)
  669. {
  670. TRACENAME("DUMPNAMESPACEOBJECT")
  671. NTSTATUS rc = STATUS_SUCCESS;
  672. PNSOBJ pns;
  673. char szName[sizeof(NAMESEG) + 1];
  674. ENTER(3, ("DumpNameSpaceObject(Path=%s,fRecursive=%x)\n",
  675. pszPath, fRecursive));
  676. if ((rc = GetNameSpaceObject(pszPath, NULL, &pns,
  677. NSF_LOCAL_SCOPE)) == STATUS_SUCCESS)
  678. {
  679. PRINTF("\nACPI Name Space: %s (%p)\n", pszPath, pns);
  680. if (!fRecursive)
  681. {
  682. STRCPYN(szName, (PSZ)&pns->dwNameSeg, sizeof(NAMESEG));
  683. DumpObject(&pns->ObjData, szName, 0);
  684. }
  685. else
  686. DumpNameSpaceTree(pns, 0);
  687. }
  688. else if (rc == AMLIERR_OBJ_NOT_FOUND)
  689. {
  690. PRINTF(MODNAME "_ERROR: object %s not found\n", pszPath);
  691. }
  692. EXIT(3, ("DumpNameSpaceObject=%x\n", rc));
  693. return rc;
  694. } //DumpNameSpaceObject
  695. /***LP DumpNameSpaceTree - Dump all the name space objects in the subtree
  696. *
  697. * ENTRY
  698. * pnsObj -> name space subtree root
  699. * dwLevel - indent level
  700. *
  701. * EXIT
  702. * None
  703. */
  704. VOID LOCAL DumpNameSpaceTree(PNSOBJ pnsObj, ULONG dwLevel)
  705. {
  706. TRACENAME("DUMPNAMESPACETREE")
  707. PNSOBJ pns, pnsNext;
  708. char szName[sizeof(NAMESEG) + 1];
  709. ENTER(3, ("DumpNameSpaceTree(pns=%x,level=%d)\n", pnsObj, dwLevel));
  710. //
  711. // First, dump myself
  712. //
  713. STRCPYN(szName, (PSZ)&pnsObj->dwNameSeg, sizeof(NAMESEG));
  714. DumpObject(&pnsObj->ObjData, szName, dwLevel);
  715. //
  716. // Then, recursively dump each of my children
  717. //
  718. for (pns = pnsObj->pnsFirstChild; pns != NULL; pns = pnsNext)
  719. {
  720. //
  721. // If this is the last child, we have no more.
  722. //
  723. if ((pnsNext = (PNSOBJ)pns->list.plistNext) == pnsObj->pnsFirstChild)
  724. pnsNext = NULL;
  725. //
  726. // Dump a child
  727. //
  728. DumpNameSpaceTree(pns, dwLevel + 1);
  729. }
  730. EXIT(3, ("DumpNameSpaceTree!\n"));
  731. } //DumpNameSpaceTree
  732. #endif //ifdef DEBUGGER