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.

1701 lines
48 KiB

  1. /*** pnpmacro.c - Parse PNP Macro terms
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created: 05/05/97
  6. *
  7. * MODIFICATION HISTORY
  8. */
  9. #include "pch.h"
  10. RESFIELD IRQFields[] =
  11. {
  12. "_INT", 1*8 + 0, 16,
  13. "_HE", 3*8 + 0, 1,
  14. "_LL", 3*8 + 3, 1,
  15. "_SHR", 3*8 + 4, 1,
  16. NULL, 0, 0
  17. };
  18. RESFIELD IRQNoFlagsFields[] =
  19. {
  20. "_INT", 1*8 + 0, 16,
  21. NULL, 0, 0
  22. };
  23. RESFIELD DMAFields[] =
  24. {
  25. "_DMA", 1*8 + 0, 8,
  26. "_SIZ", 2*8 + 0, 2,
  27. "_BM", 2*8 + 2, 1,
  28. "_TYP", 2*8 + 5, 2,
  29. NULL, 0, 0
  30. };
  31. RESFIELD IOFields[] =
  32. {
  33. "_DEC", 1*8 + 0, 1,
  34. "_MIN", 2*8 + 0, 16,
  35. "_MAX", 4*8 + 0, 16,
  36. "_ALN", 6*8 + 0, 8,
  37. "_LEN", 7*8 + 0, 8,
  38. NULL, 0, 0
  39. };
  40. RESFIELD FixedIOFields[] =
  41. {
  42. "_BAS", 1*8 + 0, 16,
  43. "_LEN", 3*8 + 0, 8,
  44. NULL, 0, 0
  45. };
  46. RESFIELD Mem24Fields[] =
  47. {
  48. "_RW", 3*8 + 0, 1,
  49. "_MIN", 4*8 + 0, 16,
  50. "_MAX", 6*8 + 0, 16,
  51. "_ALN", 8*8 + 0, 16,
  52. "_LEN", 10*8+ 0, 16,
  53. NULL, 0, 0
  54. };
  55. RESFIELD Mem32Fields[] =
  56. {
  57. "_RW", 3*8 + 0, 1,
  58. "_MIN", 4*8 + 0, 32,
  59. "_MAX", 8*8 + 0, 32,
  60. "_ALN", 12*8+ 0, 32,
  61. "_LEN", 16*8+ 0, 32,
  62. NULL, 0, 0
  63. };
  64. RESFIELD FixedMem32Fields[] =
  65. {
  66. "_RW", 3*8 + 0, 1,
  67. "_BAS", 4*8 + 0, 32,
  68. "_LEN", 8*8 + 0, 32,
  69. NULL, 0, 0
  70. };
  71. RESFIELD GenFlagFields[] =
  72. {
  73. "_DEC", 4*8 + 1, 1,
  74. "_MIF", 4*8 + 2, 1,
  75. "_MAF", 4*8 + 3, 1,
  76. NULL, 0, 0
  77. };
  78. RESFIELD MemTypeFields[] =
  79. {
  80. "_RW", 5*8 + 0, 1,
  81. "_MEM", 5*8 + 1, 3,
  82. NULL, 0, 0
  83. };
  84. RESFIELD IOTypeFields[] =
  85. {
  86. "_RNG", 5*8 + 0, 2,
  87. NULL, 0, 0
  88. };
  89. RESFIELD DWordFields[] =
  90. {
  91. "_GRA", 6*8 + 0, 32,
  92. "_MIN", 10*8+ 0, 32,
  93. "_MAX", 14*8+ 0, 32,
  94. "_TRA", 18*8+ 0, 32,
  95. "_LEN", 22*8+ 0, 32,
  96. NULL, 0, 0
  97. };
  98. RESFIELD WordFields[] =
  99. {
  100. "_GRA", 6*8 + 0, 16,
  101. "_MIN", 8*8 + 0, 16,
  102. "_MAX", 10*8+ 0, 16,
  103. "_TRA", 12*8+ 0, 16,
  104. "_LEN", 14*8+ 0, 16,
  105. NULL, 0, 0
  106. };
  107. RESFIELD QWordFields[] =
  108. {
  109. "_GRA", 6*8 + 0, 64,
  110. "_MIN", 14*8+ 0, 64,
  111. "_MAX", 22*8+ 0, 64,
  112. "_TRA", 30*8+ 0, 64,
  113. "_LEN", 38*8+ 0, 64,
  114. NULL, 0, 0
  115. };
  116. RESFIELD IRQExFields[] =
  117. {
  118. "_HE", 3*8 + 1, 1,
  119. "_LL", 3*8 + 2, 1,
  120. "_SHR", 3*8 + 3, 1,
  121. NULL, 0, 0
  122. };
  123. ULONG dwResBitOffset = 0;
  124. /***LP XferCodeToBuff - Transfer code object tree to buffer
  125. *
  126. * ENTRY
  127. * pbBuff -> buffer
  128. * pdwcb -> length
  129. * pcCode -> code object tree
  130. *
  131. * EXIT-SUCCESS
  132. * returns ASLERR_NONE
  133. * EXIT-FAILURE
  134. * returns negative error code
  135. */
  136. int LOCAL XferCodeToBuff(PBYTE pbBuff, PDWORD pdwcb, PCODEOBJ pcCode)
  137. {
  138. int rc = ASLERR_NONE;
  139. DWORD dwLen;
  140. int iLen;
  141. PCODEOBJ pc, pcNext;
  142. ENTER((2, "XferCodeToBuff(pbBuff=%x,Len=%x,pcCode=%x,CodeType=%x)\n",
  143. pbBuff, *pdwcb, pcCode, pcCode->dwCodeType));
  144. switch (pcCode->dwCodeType)
  145. {
  146. case CODETYPE_ASLTERM:
  147. if (pcCode->dwCodeValue != OP_NONE)
  148. {
  149. iLen = OPCODELEN(pcCode->dwCodeValue);
  150. memcpy(&pbBuff[*pdwcb], &pcCode->dwCodeValue, iLen);
  151. *pdwcb += (DWORD)iLen;
  152. if ((TermTable[pcCode->dwTermIndex].dwfTerm & TF_PACKAGE_LEN) &&
  153. ((rc = EncodePktLen(pcCode->dwCodeLen, &dwLen, &iLen)) ==
  154. ASLERR_NONE))
  155. {
  156. memcpy(&pbBuff[*pdwcb], &dwLen, iLen);
  157. *pdwcb += (DWORD)iLen;
  158. }
  159. if ((rc == ASLERR_NONE) && (pcCode->pbDataBuff != NULL))
  160. {
  161. int i;
  162. for (i = 0, pc = (PCODEOBJ)pcCode->pbDataBuff;
  163. i < (int)pcCode->dwDataLen;
  164. ++i)
  165. {
  166. if ((rc = XferCodeToBuff(pbBuff, pdwcb, &pc[i])) !=
  167. ASLERR_NONE)
  168. {
  169. break;
  170. }
  171. }
  172. if (rc == ASLERR_NONE)
  173. {
  174. MEMFREE(pcCode->pbDataBuff);
  175. pcCode->pbDataBuff = NULL;
  176. }
  177. }
  178. }
  179. if (rc == ASLERR_NONE)
  180. {
  181. for (pc = pcCode->pcFirstChild; pc != NULL; pc = pcNext)
  182. {
  183. if ((rc = XferCodeToBuff(pbBuff, pdwcb, pc)) != ASLERR_NONE)
  184. break;
  185. //
  186. // Am I the only one left in the list?
  187. //
  188. if (pc->list.plistNext == &pc->list)
  189. pcNext = NULL;
  190. else
  191. pcNext = (PCODEOBJ)pc->list.plistNext;
  192. ListRemoveEntry(&pc->list,
  193. (PPLIST)&pcCode->pcFirstChild);
  194. MEMFREE(pc);
  195. }
  196. }
  197. break;
  198. case CODETYPE_DATAOBJ:
  199. case CODETYPE_STRING:
  200. case CODETYPE_QWORD:
  201. memcpy(&pbBuff[*pdwcb], pcCode->pbDataBuff, pcCode->dwDataLen);
  202. *pdwcb += pcCode->dwDataLen;
  203. break;
  204. case CODETYPE_INTEGER:
  205. memcpy(&pbBuff[*pdwcb], &pcCode->dwCodeValue, pcCode->dwDataLen);
  206. *pdwcb += pcCode->dwDataLen;
  207. break;
  208. case CODETYPE_KEYWORD:
  209. case CODETYPE_UNKNOWN:
  210. break;
  211. default:
  212. ERROR(("XferCodeToBuff: unexpected code object type - %d",
  213. pcCode->dwCodeType));
  214. rc = ASLERR_INTERNAL_ERROR;
  215. }
  216. EXIT((2, "XferCodeToBuff=%x (Len=%x)\n", rc, *pdwcb));
  217. return rc;
  218. } //XferCodeToBuff
  219. /***LP ResourceTemplate - Start of PNP Resource Template
  220. *
  221. * ENTRY
  222. * ptoken -> token stream
  223. * fActionFL - TRUE if this is a fixed list action
  224. *
  225. * EXIT-SUCCESS
  226. * returns ASLERR_NONE
  227. * EXIT-FAILURE
  228. * returns negative error code
  229. */
  230. int LOCAL ResourceTemplate(PTOKEN ptoken, BOOL fActionFL)
  231. {
  232. int rc = ASLERR_NONE;
  233. PCODEOBJ pcData;
  234. ENTER((1, "ResourceTemplate(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  235. DEREF(ptoken);
  236. if (fActionFL)
  237. {
  238. dwResBitOffset = 0;
  239. }
  240. else
  241. {
  242. if ((pcData = (PCODEOBJ)MEMALLOC(sizeof(CODEOBJ))) == NULL)
  243. {
  244. ERROR(("ResourceTemplate: failed to allocate buffer object"));
  245. rc = ASLERR_OUT_OF_MEM;
  246. }
  247. else
  248. {
  249. memset(pcData, 0, sizeof(CODEOBJ));
  250. pcData->dwCodeType = CODETYPE_DATAOBJ;
  251. if (gpcodeScope->dwCodeLen <= 0x3f)
  252. pcData->dwDataLen = gpcodeScope->dwCodeLen - 1;
  253. else if (gpcodeScope->dwCodeLen <= 0xfff)
  254. pcData->dwDataLen = gpcodeScope->dwCodeLen - 2;
  255. else if (gpcodeScope->dwCodeLen <= 0xfffff)
  256. pcData->dwDataLen = gpcodeScope->dwCodeLen - 3;
  257. else
  258. pcData->dwDataLen = gpcodeScope->dwCodeLen - 4;
  259. pcData->dwDataLen += 2; //add length of EndTag
  260. if ((pcData->pbDataBuff = MEMALLOC(pcData->dwDataLen)) == NULL)
  261. {
  262. ERROR(("ResourceTemplate: failed to allocate data buffer"));
  263. rc = ASLERR_OUT_OF_MEM;
  264. }
  265. else
  266. {
  267. PCODEOBJ pc, pcNext;
  268. DWORD dwcb = 0;
  269. for (pc = gpcodeScope->pcFirstChild; pc != NULL; pc = pcNext)
  270. {
  271. if ((rc = XferCodeToBuff(pcData->pbDataBuff, &dwcb, pc)) !=
  272. ASLERR_NONE)
  273. {
  274. break;
  275. }
  276. //
  277. // Am I the only one left in the list?
  278. //
  279. if (pc->list.plistNext == &pc->list)
  280. pcNext = NULL;
  281. else
  282. pcNext = (PCODEOBJ)pc->list.plistNext;
  283. ListRemoveEntry(&pc->list,
  284. (PPLIST)&gpcodeScope->pcFirstChild);
  285. MEMFREE(pc);
  286. }
  287. if (rc == ASLERR_NONE)
  288. {
  289. pcData->pbDataBuff[dwcb] = 0x79; //EndTag
  290. dwcb++;
  291. //
  292. // Generate a zero-checksum EndTag because the ASL code
  293. // will probably change the resources anyway.
  294. //
  295. pcData->pbDataBuff[dwcb] = 0;
  296. pcData->pcParent = gpcodeScope;
  297. ListInsertTail(&pcData->list,
  298. (PPLIST)&gpcodeScope->pcFirstChild);
  299. ASSERT(dwcb + 1 == pcData->dwDataLen);
  300. pcData->dwCodeLen = pcData->dwDataLen;
  301. pcData->bCodeChkSum = ComputeDataChkSum(pcData->pbDataBuff,
  302. pcData->dwDataLen);
  303. if ((gpcodeScope->pbDataBuff = MEMALLOC(sizeof(CODEOBJ))) ==
  304. NULL)
  305. {
  306. ERROR(("ResourceTemplate: failed to allocate buffer argument object"));
  307. rc = ASLERR_OUT_OF_MEM;
  308. }
  309. else
  310. {
  311. memset(gpcodeScope->pbDataBuff, 0, sizeof(CODEOBJ));
  312. if ((rc = MakeIntData(pcData->dwDataLen,
  313. (PCODEOBJ)gpcodeScope->pbDataBuff))
  314. == ASLERR_NONE)
  315. {
  316. gpcodeScope->dwDataLen = 1;
  317. gpcodeScope->dwCodeLen = 0;
  318. gpcodeScope->bCodeChkSum = 0;
  319. ComputeChkSumLen(gpcodeScope);
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. EXIT((1, "ResourceTemplate=%d\n", rc));
  327. return rc;
  328. } //ResourceTemplate
  329. /***LP AddSmallOffset - Add code length to cumulative bit offset
  330. *
  331. * ENTRY
  332. * ptoken -> token stream
  333. * fActionFL - TRUE if this is a fixed list action
  334. *
  335. * EXIT-SUCCESS
  336. * returns ASLERR_NONE
  337. * EXIT-FAILURE
  338. * returns negative error code
  339. */
  340. int LOCAL AddSmallOffset(PTOKEN ptoken, BOOL fActionFL)
  341. {
  342. int rc = ASLERR_NONE;
  343. ENTER((1, "AddSmallOffset(ptoken=%p,fActionFL=%d)\n",
  344. ptoken, fActionFL));
  345. DEREF(ptoken);
  346. DEREF(fActionFL);
  347. ASSERT(fActionFL == TRUE);
  348. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  349. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  350. EXIT((1, "AddSmallOffset=%d\n", rc));
  351. return rc;
  352. } //AddSmallOffset
  353. /***LP StartDependentFn - Start of Dependent Function
  354. *
  355. * ENTRY
  356. * ptoken -> token stream
  357. * fActionFL - TRUE if this is a fixed list action
  358. *
  359. * EXIT-SUCCESS
  360. * returns ASLERR_NONE
  361. * EXIT-FAILURE
  362. * returns negative error code
  363. */
  364. int LOCAL StartDependentFn(PTOKEN ptoken, BOOL fActionFL)
  365. {
  366. int rc = ASLERR_NONE;
  367. PCODEOBJ pArgs;
  368. ENTER((1, "StartDependentFn(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  369. DEREF(fActionFL);
  370. ASSERT(fActionFL == TRUE);
  371. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  372. if (pArgs[0].dwCodeValue > 2)
  373. {
  374. PrintTokenErr(ptoken, "Arg0 should be between 0-2", TRUE);
  375. rc = ASLERR_SYNTAX;
  376. }
  377. else if (pArgs[1].dwCodeValue > 2)
  378. {
  379. PrintTokenErr(ptoken, "Arg1 should be between 0-2", TRUE);
  380. rc = ASLERR_SYNTAX;
  381. }
  382. else
  383. {
  384. pArgs[0].dwCodeValue |= pArgs[1].dwCodeValue << 2;
  385. pArgs[0].bCodeChkSum = (BYTE)pArgs[0].dwCodeValue;
  386. gpcodeScope->dwDataLen = 1;
  387. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  388. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  389. }
  390. EXIT((1, "StartDependentFn=%d\n", rc));
  391. return rc;
  392. } //StartDependentFn
  393. /***LP IRQDesc - IRQ resource descriptor
  394. *
  395. * ENTRY
  396. * ptoken -> token stream
  397. * fActionFL - TRUE if this is a fixed list action
  398. *
  399. * EXIT-SUCCESS
  400. * returns ASLERR_NONE
  401. * EXIT-FAILURE
  402. * returns negative error code
  403. */
  404. int LOCAL IRQDesc(PTOKEN ptoken, BOOL fActionFL)
  405. {
  406. int rc = ASLERR_NONE;
  407. PCODEOBJ pArgs;
  408. DWORD dwLen, dwIRQ = 0, dw;
  409. PCODEOBJ pc;
  410. #define MAX_IRQ 0x0f
  411. ENTER((1, "IRQDesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  412. DEREF(fActionFL);
  413. ASSERT(fActionFL == FALSE);
  414. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  415. if (gpcodeScope->dwDataLen == 4) //IRQ
  416. {
  417. dwLen = 3;
  418. if ((rc = SetDefMissingKW(&pArgs[2], ID_EXCLUSIVE)) == ASLERR_NONE)
  419. {
  420. EncodeKeywords(pArgs, 0x07, 0);
  421. if ((pArgs[0].dwCodeValue & (_LL | _HE)) == (_LL | _HE))
  422. {
  423. PrintTokenErr(ptoken,
  424. "Illegal combination of interrupt level and trigger mode",
  425. TRUE);
  426. rc = ASLERR_SYNTAX;
  427. }
  428. }
  429. }
  430. else //IRQNoFlags
  431. {
  432. ASSERT(gpcodeScope->dwDataLen == 1);
  433. dwLen = 2;
  434. }
  435. if (rc == ASLERR_NONE)
  436. {
  437. pc = gpcodeScope->pcFirstChild;
  438. if (pc != NULL)
  439. {
  440. ASSERT(pc->dwCodeType == CODETYPE_DATAOBJ);
  441. for (dw = 0; dw < pc->dwDataLen; ++dw)
  442. {
  443. if (pc->pbDataBuff[dw] > MAX_IRQ)
  444. {
  445. PrintTokenErr(ptoken, "Invalid IRQ number", TRUE);
  446. rc = ASLERR_SYNTAX;
  447. break;
  448. }
  449. else
  450. {
  451. dwIRQ |= 1 << pc->pbDataBuff[dw];
  452. }
  453. }
  454. if (rc == ASLERR_NONE)
  455. {
  456. MEMFREE(pc->pbDataBuff);
  457. pc->pbDataBuff = NULL;
  458. }
  459. }
  460. else if ((pc = MEMALLOC(sizeof(CODEOBJ))) != NULL)
  461. {
  462. memset(pc, 0, sizeof(CODEOBJ));
  463. pc->pcParent = gpcodeScope;
  464. ListInsertTail(&pc->list, (PPLIST)&gpcodeScope->pcFirstChild);
  465. }
  466. else
  467. {
  468. ERROR(("IRQDesc: failed to allocate DMA descriptor"));
  469. rc = ASLERR_OUT_OF_MEM;
  470. }
  471. if (rc == ASLERR_NONE)
  472. {
  473. PCODEOBJ pa;
  474. if (dwLen == 3)
  475. dwIRQ |= (pArgs[0].dwCodeValue & 0xff) << 16;
  476. SetIntObject(pc, dwIRQ, dwLen);
  477. pa = &pArgs[gpcodeScope->dwDataLen == 4? 3: 0];
  478. if (pa->dwCodeType == CODETYPE_STRING)
  479. {
  480. PNSOBJ pns;
  481. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pa->pbDataBuff,
  482. gpnsCurrentScope, gpnsCurrentOwner,
  483. &pns, NSF_EXIST_ERR)) ==
  484. ASLERR_NONE)
  485. {
  486. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  487. rc = CreateResFields(ptoken, pns,
  488. gpcodeScope->dwDataLen == 4?
  489. IRQFields: IRQNoFlagsFields);
  490. }
  491. MEMFREE(pa->pbDataBuff);
  492. memset(pa, 0, sizeof(CODEOBJ));
  493. }
  494. if (rc == ASLERR_NONE)
  495. {
  496. gpcodeScope->dwDataLen = 0;
  497. MEMFREE(gpcodeScope->pbDataBuff);
  498. gpcodeScope->pbDataBuff = NULL;
  499. gpcodeScope->dwCodeLen = 0;
  500. gpcodeScope->bCodeChkSum = 0;
  501. ComputeChkSumLen(gpcodeScope);
  502. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  503. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  504. }
  505. }
  506. }
  507. EXIT((1, "IRQDesc=%d\n", rc));
  508. return rc;
  509. } //IRQDesc
  510. /***LP DMADesc - DMA resource descriptor
  511. *
  512. * ENTRY
  513. * ptoken -> token stream
  514. * fActionFL - TRUE if this is a fixed list action
  515. *
  516. * EXIT-SUCCESS
  517. * returns ASLERR_NONE
  518. * EXIT-FAILURE
  519. * returns negative error code
  520. */
  521. int LOCAL DMADesc(PTOKEN ptoken, BOOL fActionFL)
  522. {
  523. int rc = ASLERR_NONE;
  524. PCODEOBJ pArgs;
  525. DWORD dwDMA = 0, dw;
  526. PCODEOBJ pc;
  527. #define MAX_DMA 0x07
  528. ENTER((1, "DMADesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  529. DEREF(fActionFL);
  530. ASSERT(fActionFL == FALSE);
  531. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  532. EncodeKeywords(pArgs, 0x07, 0);
  533. pc = gpcodeScope->pcFirstChild;
  534. if (pc != NULL)
  535. {
  536. ASSERT(pc->dwCodeType == CODETYPE_DATAOBJ);
  537. for (dw = 0; dw < pc->dwDataLen; ++dw)
  538. {
  539. if (pc->pbDataBuff[dw] > MAX_DMA)
  540. {
  541. PrintTokenErr(ptoken, "Invalid DMA number", TRUE);
  542. rc = ASLERR_SYNTAX;
  543. break;
  544. }
  545. else
  546. {
  547. dwDMA |= 1 << pc->pbDataBuff[dw];
  548. }
  549. }
  550. if (rc == ASLERR_NONE)
  551. {
  552. MEMFREE(pc->pbDataBuff);
  553. pc->pbDataBuff = NULL;
  554. }
  555. }
  556. else if ((pc = MEMALLOC(sizeof(CODEOBJ))) != NULL)
  557. {
  558. memset(pc, 0, sizeof(CODEOBJ));
  559. pc->pcParent = gpcodeScope;
  560. ListInsertTail(&pc->list, (PPLIST)&gpcodeScope->pcFirstChild);
  561. }
  562. else
  563. {
  564. ERROR(("DMADesc: failed to allocate DMA descriptor"));
  565. rc = ASLERR_OUT_OF_MEM;
  566. }
  567. if (rc == ASLERR_NONE)
  568. {
  569. dwDMA |= (pArgs[0].dwCodeValue & 0xff) << 8;
  570. SetIntObject(pc, dwDMA, sizeof(WORD));
  571. if (pArgs[3].dwCodeType == CODETYPE_STRING)
  572. {
  573. PNSOBJ pns;
  574. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[3].pbDataBuff,
  575. gpnsCurrentScope, gpnsCurrentOwner,
  576. &pns, NSF_EXIST_ERR)) ==
  577. ASLERR_NONE)
  578. {
  579. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  580. rc = CreateResFields(ptoken, pns, DMAFields);
  581. }
  582. MEMFREE(pArgs[3].pbDataBuff);
  583. memset(&pArgs[3], 0, sizeof(CODEOBJ));
  584. }
  585. if (rc == ASLERR_NONE)
  586. {
  587. gpcodeScope->dwDataLen = 0;
  588. MEMFREE(gpcodeScope->pbDataBuff);
  589. gpcodeScope->pbDataBuff = NULL;
  590. gpcodeScope->dwCodeLen = 0;
  591. gpcodeScope->bCodeChkSum = 0;
  592. ComputeChkSumLen(gpcodeScope);
  593. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  594. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  595. }
  596. }
  597. EXIT((1, "DMADesc=%d\n", rc));
  598. return rc;
  599. } //DMADesc
  600. /***LP IODesc - IO resource descriptor
  601. *
  602. * ENTRY
  603. * ptoken -> token stream
  604. * fActionFL - TRUE if this is a fixed list action
  605. *
  606. * EXIT-SUCCESS
  607. * returns ASLERR_NONE
  608. * EXIT-FAILURE
  609. * returns negative error code
  610. */
  611. int LOCAL IODesc(PTOKEN ptoken, BOOL fActionFL)
  612. {
  613. int rc = ASLERR_NONE;
  614. PCODEOBJ pArgs;
  615. ENTER((1, "IODesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  616. DEREF(ptoken);
  617. DEREF(fActionFL);
  618. ASSERT(fActionFL == TRUE);
  619. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  620. EncodeKeywords(pArgs, 0x01, 0);
  621. if (pArgs[5].dwCodeType == CODETYPE_STRING)
  622. {
  623. PNSOBJ pns;
  624. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[5].pbDataBuff,
  625. gpnsCurrentScope, gpnsCurrentOwner,
  626. &pns, NSF_EXIST_ERR)) ==
  627. ASLERR_NONE)
  628. {
  629. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  630. rc = CreateResFields(ptoken, pns, IOFields);
  631. }
  632. MEMFREE(pArgs[5].pbDataBuff);
  633. memset(&pArgs[5], 0, sizeof(CODEOBJ));
  634. }
  635. if (rc == ASLERR_NONE)
  636. {
  637. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  638. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  639. }
  640. EXIT((1, "IODesc=%d\n", rc));
  641. return rc;
  642. } //IODesc
  643. /***LP FixedIODesc - FixedIO resource descriptor
  644. *
  645. * ENTRY
  646. * ptoken -> token stream
  647. * fActionFL - TRUE if this is a fixed list action
  648. *
  649. * EXIT-SUCCESS
  650. * returns ASLERR_NONE
  651. * EXIT-FAILURE
  652. * returns negative error code
  653. */
  654. int LOCAL FixedIODesc(PTOKEN ptoken, BOOL fActionFL)
  655. {
  656. int rc = ASLERR_NONE;
  657. PCODEOBJ pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  658. ENTER((1, "FixedIODesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  659. DEREF(ptoken);
  660. DEREF(fActionFL);
  661. ASSERT(fActionFL == TRUE);
  662. if (pArgs[2].dwCodeType == CODETYPE_STRING)
  663. {
  664. PNSOBJ pns;
  665. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[2].pbDataBuff,
  666. gpnsCurrentScope, gpnsCurrentOwner,
  667. &pns, NSF_EXIST_ERR)) ==
  668. ASLERR_NONE)
  669. {
  670. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  671. rc = CreateResFields(ptoken, pns, FixedIOFields);
  672. }
  673. MEMFREE(pArgs[2].pbDataBuff);
  674. memset(&pArgs[2], 0, sizeof(CODEOBJ));
  675. }
  676. if (rc == ASLERR_NONE)
  677. {
  678. ASSERT((gpcodeScope->dwCodeValue & 0x80) == 0);
  679. dwResBitOffset += ((gpcodeScope->dwCodeValue & 0x07) + 1)*8;
  680. }
  681. EXIT((1, "FixedIODesc=%d\n", rc));
  682. return rc;
  683. } //FixedIODesc
  684. /***LP VendorDesc - Vendor-defined resource
  685. *
  686. * ENTRY
  687. * ptoken -> token stream
  688. * dwMaxSize - 0x07 if short resource, 0xffff if long resource
  689. *
  690. * EXIT-SUCCESS
  691. * returns ASLERR_NONE
  692. * EXIT-FAILURE
  693. * returns negative error code
  694. */
  695. int LOCAL VendorDesc(PTOKEN ptoken, DWORD dwMaxSize)
  696. {
  697. int rc = ASLERR_NONE;
  698. PCODEOBJ pc;
  699. PBYTE pbOldBuff = NULL;
  700. DWORD dwOldLen = 0;
  701. #define SHORT_MAX_SIZE 0x07
  702. #define LONG_MAX_SIZE 0xffff
  703. ENTER((1, "VendorDesc(ptoken=%p,MaxSize=%d)\n", ptoken, dwMaxSize));
  704. ASSERT((dwMaxSize == SHORT_MAX_SIZE) || (dwMaxSize == LONG_MAX_SIZE));
  705. pc = gpcodeScope->pcFirstChild;
  706. if (pc != NULL)
  707. {
  708. ASSERT(pc->dwCodeType == CODETYPE_DATAOBJ);
  709. if (pc->dwDataLen > dwMaxSize)
  710. {
  711. PrintTokenErr(ptoken, "Vendor resource data can only be up to "
  712. "7 bytes for short descriptor and 64K-1 bytes for "
  713. "long descriptor", TRUE);
  714. rc = ASLERR_SYNTAX;
  715. }
  716. else
  717. {
  718. pbOldBuff = pc->pbDataBuff;
  719. dwOldLen = pc->dwDataLen;
  720. }
  721. }
  722. else if ((pc = MEMALLOC(sizeof(CODEOBJ))) != NULL)
  723. {
  724. memset(pc, 0, sizeof(CODEOBJ));
  725. pc->pcParent = gpcodeScope;
  726. ListInsertTail(&pc->list, (PPLIST)&gpcodeScope->pcFirstChild);
  727. }
  728. else
  729. {
  730. ERROR(("VendorDesc: failed to allocate vendor-defined resource object"));
  731. rc = ASLERR_OUT_OF_MEM;
  732. }
  733. if (rc == ASLERR_NONE)
  734. {
  735. int i;
  736. pc->dwCodeType = CODETYPE_DATAOBJ;
  737. if (dwMaxSize == SHORT_MAX_SIZE)
  738. pc->dwDataLen = dwOldLen + 1;
  739. else
  740. pc->dwDataLen = dwOldLen + sizeof(WORD);
  741. if ((pc->pbDataBuff = MEMALLOC(pc->dwDataLen)) != NULL)
  742. {
  743. PCODEOBJ pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  744. if (dwMaxSize == SHORT_MAX_SIZE)
  745. {
  746. pc->pbDataBuff[0] = (BYTE)(0x70 | dwOldLen);
  747. i = 1;
  748. }
  749. else
  750. {
  751. *((PWORD)&pc->pbDataBuff[0]) = (WORD)dwOldLen;
  752. i = sizeof(WORD);
  753. }
  754. if (pbOldBuff != NULL)
  755. {
  756. memcpy(&pc->pbDataBuff[i], pbOldBuff, dwOldLen);
  757. MEMFREE(pbOldBuff);
  758. }
  759. pc->dwCodeLen = pc->dwDataLen;
  760. pc->bCodeChkSum = ComputeDataChkSum((PBYTE)&pc->pbDataBuff,
  761. pc->dwCodeLen);
  762. if (pArgs[0].dwCodeType == CODETYPE_STRING)
  763. {
  764. PNSOBJ pns;
  765. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[0].pbDataBuff,
  766. gpnsCurrentScope, gpnsCurrentOwner,
  767. &pns, NSF_EXIST_ERR)) ==
  768. ASLERR_NONE)
  769. {
  770. pns->ObjData.dwDataType = OBJTYPE_RES_FIELD;
  771. pns->ObjData.uipDataValue = dwResBitOffset +
  772. (dwMaxSize == SHORT_MAX_SIZE?
  773. 8: 8*3);
  774. pns->ObjData.dwDataLen = 8*dwOldLen;
  775. }
  776. MEMFREE(pArgs[0].pbDataBuff);
  777. memset(&pArgs[0], 0, sizeof(CODEOBJ));
  778. }
  779. if (rc == ASLERR_NONE)
  780. {
  781. gpcodeScope->dwDataLen = 0;
  782. MEMFREE(gpcodeScope->pbDataBuff);
  783. gpcodeScope->pbDataBuff = NULL;
  784. gpcodeScope->dwCodeLen = 0;
  785. gpcodeScope->bCodeChkSum = 0;
  786. ComputeChkSumLen(gpcodeScope);
  787. if (dwMaxSize == SHORT_MAX_SIZE)
  788. {
  789. dwResBitOffset += ((pc->pbDataBuff[0] & 0x07) + 1)*8;
  790. }
  791. else
  792. {
  793. dwResBitOffset += (*((PWORD)&pc->pbDataBuff[0]) + 3)*8;
  794. }
  795. }
  796. }
  797. else
  798. {
  799. ERROR(("VendorDesc: failed to allocate vendor-defined resource buffer"));
  800. rc = ASLERR_OUT_OF_MEM;
  801. }
  802. }
  803. EXIT((1, "VendorDesc=%d\n", rc));
  804. return rc;
  805. } //VendorDesc
  806. /***LP VendorShort - Vendor-defined short resource
  807. *
  808. * ENTRY
  809. * ptoken -> token stream
  810. * fActionFL - TRUE if this is a fixed list action
  811. *
  812. * EXIT-SUCCESS
  813. * returns ASLERR_NONE
  814. * EXIT-FAILURE
  815. * returns negative error code
  816. */
  817. int LOCAL VendorShort(PTOKEN ptoken, BOOL fActionFL)
  818. {
  819. int rc;
  820. ENTER((1, "VendorShort(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  821. DEREF(fActionFL);
  822. ASSERT(fActionFL == FALSE);
  823. rc = VendorDesc(ptoken, 0x07);
  824. EXIT((1, "VendorShort=%d\n", rc));
  825. return rc;
  826. } //VendorShort
  827. /***LP InsertDescLength - Insert long descriptor length
  828. *
  829. * ENTRY
  830. * pcode -> code object
  831. * dwDescLen - length of descriptor
  832. *
  833. * EXIT-SUCCESS
  834. * returns ASLERR_NONE
  835. * EXIT-FAILURE
  836. * returns negative error code
  837. */
  838. int LOCAL InsertDescLength(PCODEOBJ pcode, DWORD dwDescLen)
  839. {
  840. int rc;
  841. PCODEOBJ pNewArgs;
  842. ENTER((2, "InsertDescLength(pcode=%x,DescLen=%d)\n", pcode, dwDescLen));
  843. if ((pNewArgs = MEMALLOC((pcode->dwDataLen + 1)*sizeof(CODEOBJ))) != NULL)
  844. {
  845. memcpy(&pNewArgs[1], pcode->pbDataBuff,
  846. pcode->dwDataLen*sizeof(CODEOBJ));
  847. memset(&pNewArgs[0], 0, sizeof(CODEOBJ));
  848. SetIntObject(&pNewArgs[0], dwDescLen, sizeof(WORD));
  849. MEMFREE(pcode->pbDataBuff);
  850. pcode->dwDataLen++;
  851. pcode->pbDataBuff = (PBYTE)pNewArgs;
  852. rc = ASLERR_NONE;
  853. }
  854. else
  855. {
  856. ERROR(("InsertDescLength: failed to allocate new argument objects"));
  857. rc = ASLERR_OUT_OF_MEM;
  858. }
  859. EXIT((2, "InsertDescLength=%d\n", rc));
  860. return rc;
  861. } //InsertDescLength
  862. /***LP Memory24Desc - 24-bit memory resource descriptor
  863. *
  864. * ENTRY
  865. * ptoken -> token stream
  866. * fActionFL - TRUE if this is a fixed list action
  867. *
  868. * EXIT-SUCCESS
  869. * returns ASLERR_NONE
  870. * EXIT-FAILURE
  871. * returns negative error code
  872. */
  873. int LOCAL Memory24Desc(PTOKEN ptoken, BOOL fActionFL)
  874. {
  875. int rc = ASLERR_NONE;
  876. PCODEOBJ pArgs;
  877. ENTER((1, "Memory24Desc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  878. DEREF(ptoken);
  879. DEREF(fActionFL);
  880. ASSERT(fActionFL == TRUE);
  881. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  882. EncodeKeywords(pArgs, 0x01, 0);
  883. if (pArgs[5].dwCodeType == CODETYPE_STRING)
  884. {
  885. PNSOBJ pns;
  886. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[5].pbDataBuff,
  887. gpnsCurrentScope, gpnsCurrentOwner,
  888. &pns, NSF_EXIST_ERR)) ==
  889. ASLERR_NONE)
  890. {
  891. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  892. rc = CreateResFields(ptoken, pns, Mem24Fields);
  893. }
  894. MEMFREE(pArgs[5].pbDataBuff);
  895. memset(&pArgs[5], 0, sizeof(CODEOBJ));
  896. }
  897. if ((rc == ASLERR_NONE) &&
  898. ((rc = InsertDescLength(gpcodeScope, 9)) == ASLERR_NONE))
  899. {
  900. dwResBitOffset += 12*8;
  901. }
  902. EXIT((1, "Memory24Desc=%d\n", rc));
  903. return rc;
  904. } //Memory24Desc
  905. /***LP VendorLong - Vendor-defined long resource
  906. *
  907. * ENTRY
  908. * ptoken -> token stream
  909. * fActionFL - TRUE if this is a fixed list action
  910. *
  911. * EXIT-SUCCESS
  912. * returns ASLERR_NONE
  913. * EXIT-FAILURE
  914. * returns negative error code
  915. */
  916. int LOCAL VendorLong(PTOKEN ptoken, BOOL fActionFL)
  917. {
  918. int rc;
  919. ENTER((1, "VendorLong(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  920. DEREF(fActionFL);
  921. ASSERT(fActionFL == FALSE);
  922. rc = VendorDesc(ptoken, 0xffff);
  923. EXIT((1, "VendorLong=%d\n", rc));
  924. return rc;
  925. } //VendorLong
  926. /***LP Memory32Desc - 32-bit memory resource descriptor
  927. *
  928. * ENTRY
  929. * ptoken -> token stream
  930. * fActionFL - TRUE if this is a fixed list action
  931. *
  932. * EXIT-SUCCESS
  933. * returns ASLERR_NONE
  934. * EXIT-FAILURE
  935. * returns negative error code
  936. */
  937. int LOCAL Memory32Desc(PTOKEN ptoken, BOOL fActionFL)
  938. {
  939. int rc = ASLERR_NONE;
  940. PCODEOBJ pArgs;
  941. ENTER((1, "Memory32Desc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  942. DEREF(ptoken);
  943. DEREF(fActionFL);
  944. ASSERT(fActionFL == TRUE);
  945. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  946. EncodeKeywords(pArgs, 0x01, 0);
  947. if (pArgs[5].dwCodeType == CODETYPE_STRING)
  948. {
  949. PNSOBJ pns;
  950. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[5].pbDataBuff,
  951. gpnsCurrentScope, gpnsCurrentOwner,
  952. &pns, NSF_EXIST_ERR)) ==
  953. ASLERR_NONE)
  954. {
  955. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  956. rc = CreateResFields(ptoken, pns, Mem32Fields);
  957. }
  958. MEMFREE(pArgs[5].pbDataBuff);
  959. memset(&pArgs[5], 0, sizeof(CODEOBJ));
  960. }
  961. if ((rc == ASLERR_NONE) &&
  962. ((rc = InsertDescLength(gpcodeScope, 17)) == ASLERR_NONE))
  963. {
  964. dwResBitOffset += 20*8;
  965. }
  966. EXIT((1, "Memory32Desc=%d\n", rc));
  967. return rc;
  968. } //Memory32Desc
  969. /***LP FixedMemory32Desc - 32-bit fixed memory resource descriptor
  970. *
  971. * ENTRY
  972. * ptoken -> token stream
  973. * fActionFL - TRUE if this is a fixed list action
  974. *
  975. * EXIT-SUCCESS
  976. * returns ASLERR_NONE
  977. * EXIT-FAILURE
  978. * returns negative error code
  979. */
  980. int LOCAL FixedMemory32Desc(PTOKEN ptoken, BOOL fActionFL)
  981. {
  982. int rc = ASLERR_NONE;
  983. PCODEOBJ pArgs;
  984. ENTER((1, "FixedMemory32Desc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  985. DEREF(ptoken);
  986. DEREF(fActionFL);
  987. ASSERT(fActionFL == TRUE);
  988. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  989. EncodeKeywords(pArgs, 0x01, 0);
  990. if (pArgs[3].dwCodeType == CODETYPE_STRING)
  991. {
  992. PNSOBJ pns;
  993. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[3].pbDataBuff,
  994. gpnsCurrentScope, gpnsCurrentOwner,
  995. &pns, NSF_EXIST_ERR)) ==
  996. ASLERR_NONE)
  997. {
  998. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  999. rc = CreateResFields(ptoken, pns, FixedMem32Fields);
  1000. }
  1001. MEMFREE(pArgs[3].pbDataBuff);
  1002. memset(&pArgs[3], 0, sizeof(CODEOBJ));
  1003. }
  1004. if ((rc == ASLERR_NONE) &&
  1005. ((rc = InsertDescLength(gpcodeScope, 9)) == ASLERR_NONE))
  1006. {
  1007. dwResBitOffset += 12*8;
  1008. }
  1009. EXIT((1, "FixedMemory32Desc=%d\n", rc));
  1010. return rc;
  1011. } //FixedMemory32Desc
  1012. #define RESTYPE_MEM 0
  1013. #define RESTYPE_IO 1
  1014. #define RESTYPE_BUSNUM 2
  1015. /***LP MemSpaceDesc - Memory space descriptor
  1016. *
  1017. * ENTRY
  1018. * ptoken -> TOKEN
  1019. * dwMinLen - minimum descriptor length
  1020. * ResFields -> resource fields table
  1021. *
  1022. * EXIT-SUCCESS
  1023. * returns ASLERR_NONE
  1024. * EXIT-FAILURE
  1025. * returns negative error code
  1026. */
  1027. int LOCAL MemSpaceDesc(PTOKEN ptoken, DWORD dwMinLen, PRESFIELD ResFields)
  1028. {
  1029. int rc;
  1030. PCODEOBJ pArgs;
  1031. ENTER((1, "MemSpaceDesc(ptoken=%p,MinLen=%d,ResFields=%p)\n",
  1032. ptoken, dwMinLen, ResFields));
  1033. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  1034. if (((rc = SetDefMissingKW(&pArgs[0], ID_RESCONSUMER)) == ASLERR_NONE) &&
  1035. ((rc = SetDefMissingKW(&pArgs[1], ID_POSDECODE)) == ASLERR_NONE) &&
  1036. ((rc = SetDefMissingKW(&pArgs[2], ID_MINNOTFIXED)) == ASLERR_NONE) &&
  1037. ((rc = SetDefMissingKW(&pArgs[3], ID_MAXNOTFIXED)) == ASLERR_NONE) &&
  1038. ((rc = SetDefMissingKW(&pArgs[4], ID_NONCACHEABLE)) == ASLERR_NONE))
  1039. {
  1040. EncodeKeywords(pArgs, 0x0f, 2);
  1041. EncodeKeywords(pArgs, 0x30, 3);
  1042. SetIntObject(&pArgs[1], RESTYPE_MEM, sizeof(BYTE));
  1043. if (!(pArgs[11].dwfCode & CF_MISSING_ARG))
  1044. dwMinLen++;
  1045. if (!(pArgs[12].dwfCode & CF_MISSING_ARG))
  1046. {
  1047. ASSERT(pArgs[12].dwCodeType == CODETYPE_STRING);
  1048. dwMinLen += pArgs[12].dwDataLen;
  1049. }
  1050. SetIntObject(&pArgs[0], dwMinLen, sizeof(WORD));
  1051. if (pArgs[13].dwCodeType == CODETYPE_STRING)
  1052. {
  1053. PNSOBJ pns;
  1054. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[13].pbDataBuff,
  1055. gpnsCurrentScope, gpnsCurrentOwner,
  1056. &pns, NSF_EXIST_ERR)) ==
  1057. ASLERR_NONE)
  1058. {
  1059. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  1060. if (((rc = CreateResFields(ptoken, pns, GenFlagFields)) ==
  1061. ASLERR_NONE) &&
  1062. ((rc = CreateResFields(ptoken, pns, MemTypeFields)) ==
  1063. ASLERR_NONE))
  1064. {
  1065. rc = CreateResFields(ptoken, pns, ResFields);
  1066. }
  1067. }
  1068. MEMFREE(pArgs[13].pbDataBuff);
  1069. memset(&pArgs[13], 0, sizeof(CODEOBJ));
  1070. }
  1071. if (rc == ASLERR_NONE)
  1072. {
  1073. dwResBitOffset += (dwMinLen + 3)*8;
  1074. }
  1075. }
  1076. EXIT((1, "MemSpaceDesc=%d\n", rc));
  1077. return rc;
  1078. } //MemSpaceDesc
  1079. /***LP IOSpaceDesc - IO space descriptor
  1080. *
  1081. * ENTRY
  1082. * ptoken -> TOKEN
  1083. * dwMinLen - minimum descriptor length
  1084. * ResFields -> resource fields table
  1085. *
  1086. * EXIT-SUCCESS
  1087. * returns ASLERR_NONE
  1088. * EXIT-FAILURE
  1089. * returns negative error code
  1090. */
  1091. int LOCAL IOSpaceDesc(PTOKEN ptoken, DWORD dwMinLen, PRESFIELD ResFields)
  1092. {
  1093. int rc;
  1094. PCODEOBJ pArgs;
  1095. ENTER((2, "IOSpaceDesc(ptoken=%p,MinLen=%d,ResFields=%p)\n",
  1096. ptoken, dwMinLen, ResFields));
  1097. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  1098. if (((rc = SetDefMissingKW(&pArgs[0], ID_RESCONSUMER)) == ASLERR_NONE) &&
  1099. ((rc = SetDefMissingKW(&pArgs[1], ID_MINNOTFIXED)) == ASLERR_NONE) &&
  1100. ((rc = SetDefMissingKW(&pArgs[2], ID_MAXNOTFIXED)) == ASLERR_NONE) &&
  1101. ((rc = SetDefMissingKW(&pArgs[3], ID_POSDECODE)) == ASLERR_NONE) &&
  1102. ((rc = SetDefMissingKW(&pArgs[4], ID_ENTIRERNG)) == ASLERR_NONE))
  1103. {
  1104. EncodeKeywords(pArgs, 0x0f, 2);
  1105. EncodeKeywords(pArgs, 0x10, 3);
  1106. SetIntObject(&pArgs[1], RESTYPE_IO, sizeof(BYTE));
  1107. if (!(pArgs[10].dwfCode & CF_MISSING_ARG))
  1108. dwMinLen++;
  1109. if (!(pArgs[11].dwfCode & CF_MISSING_ARG))
  1110. {
  1111. ASSERT(pArgs[11].dwCodeType == CODETYPE_STRING);
  1112. dwMinLen += pArgs[11].dwDataLen;
  1113. }
  1114. SetIntObject(&pArgs[0], dwMinLen, sizeof(WORD));
  1115. if (pArgs[12].dwCodeType == CODETYPE_STRING)
  1116. {
  1117. PNSOBJ pns;
  1118. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[12].pbDataBuff,
  1119. gpnsCurrentScope, gpnsCurrentOwner,
  1120. &pns, NSF_EXIST_ERR)) ==
  1121. ASLERR_NONE)
  1122. {
  1123. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  1124. if (((rc = CreateResFields(ptoken, pns, GenFlagFields)) ==
  1125. ASLERR_NONE) &&
  1126. ((rc = CreateResFields(ptoken, pns, MemTypeFields)) ==
  1127. ASLERR_NONE))
  1128. {
  1129. rc = CreateResFields(ptoken, pns, ResFields);
  1130. }
  1131. }
  1132. MEMFREE(pArgs[12].pbDataBuff);
  1133. memset(&pArgs[12], 0, sizeof(CODEOBJ));
  1134. }
  1135. if (rc == ASLERR_NONE)
  1136. {
  1137. dwResBitOffset += (dwMinLen + 3)*8;
  1138. }
  1139. }
  1140. EXIT((2, "IOSpaceDesc=%d\n", rc));
  1141. return rc;
  1142. } //IOSpaceDesc
  1143. /***LP DWordMemDesc - DWord memory descriptor
  1144. *
  1145. * ENTRY
  1146. * ptoken -> token stream
  1147. * fActionFL - TRUE if this is a fixed list action
  1148. *
  1149. * EXIT-SUCCESS
  1150. * returns ASLERR_NONE
  1151. * EXIT-FAILURE
  1152. * returns negative error code
  1153. */
  1154. int LOCAL DWordMemDesc(PTOKEN ptoken, BOOL fActionFL)
  1155. {
  1156. int rc;
  1157. ENTER((1, "DWordMemDesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1158. DEREF(ptoken);
  1159. DEREF(fActionFL);
  1160. ASSERT(fActionFL == TRUE);
  1161. rc = MemSpaceDesc(ptoken, 23, DWordFields);
  1162. EXIT((1, "DWordMemDesc=%d\n", rc));
  1163. return rc;
  1164. } //DWordMemDesc
  1165. /***LP DWordIODesc - DWord IO descriptor
  1166. *
  1167. * ENTRY
  1168. * ptoken -> token stream
  1169. * fActionFL - TRUE if this is a fixed list action
  1170. *
  1171. * EXIT-SUCCESS
  1172. * returns ASLERR_NONE
  1173. * EXIT-FAILURE
  1174. * returns negative error code
  1175. */
  1176. int LOCAL DWordIODesc(PTOKEN ptoken, BOOL fActionFL)
  1177. {
  1178. int rc;
  1179. ENTER((1, "DWordIODesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1180. DEREF(ptoken);
  1181. DEREF(fActionFL);
  1182. ASSERT(fActionFL == TRUE);
  1183. rc = IOSpaceDesc(ptoken, 23, DWordFields);
  1184. EXIT((1, "DWordIODesc=%d\n", rc));
  1185. return rc;
  1186. } //DWordIODesc
  1187. /***LP WordIODesc - Word IO descriptor
  1188. *
  1189. * ENTRY
  1190. * ptoken -> token stream
  1191. * fActionFL - TRUE if this is a fixed list action
  1192. *
  1193. * EXIT-SUCCESS
  1194. * returns ASLERR_NONE
  1195. * EXIT-FAILURE
  1196. * returns negative error code
  1197. */
  1198. int LOCAL WordIODesc(PTOKEN ptoken, BOOL fActionFL)
  1199. {
  1200. int rc;
  1201. ENTER((1, "WordIODesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1202. DEREF(ptoken);
  1203. DEREF(fActionFL);
  1204. ASSERT(fActionFL == TRUE);
  1205. rc = IOSpaceDesc(ptoken, 13, WordFields);
  1206. EXIT((1, "WordIODesc=%d\n", rc));
  1207. return rc;
  1208. } //WordIODesc
  1209. /***LP WordBusNumDesc - Word BusNum descriptor
  1210. *
  1211. * ENTRY
  1212. * ptoken -> token stream
  1213. * fActionFL - TRUE if this is a fixed list action
  1214. *
  1215. * EXIT-SUCCESS
  1216. * returns ASLERR_NONE
  1217. * EXIT-FAILURE
  1218. * returns negative error code
  1219. */
  1220. int LOCAL WordBusNumDesc(PTOKEN ptoken, BOOL fActionFL)
  1221. {
  1222. int rc;
  1223. PCODEOBJ pArgs;
  1224. ENTER((1, "WordBusNumDesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1225. DEREF(ptoken);
  1226. DEREF(fActionFL);
  1227. ASSERT(fActionFL == TRUE);
  1228. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  1229. if (((rc = SetDefMissingKW(&pArgs[0], ID_RESCONSUMER)) == ASLERR_NONE) &&
  1230. ((rc = SetDefMissingKW(&pArgs[1], ID_MINNOTFIXED)) == ASLERR_NONE) &&
  1231. ((rc = SetDefMissingKW(&pArgs[2], ID_MAXNOTFIXED)) == ASLERR_NONE) &&
  1232. ((rc = SetDefMissingKW(&pArgs[3], ID_POSDECODE)) == ASLERR_NONE))
  1233. {
  1234. DWORD dwLen;
  1235. EncodeKeywords(pArgs, 0x0f, 2);
  1236. SetIntObject(&pArgs[1], RESTYPE_BUSNUM, sizeof(BYTE));
  1237. SetIntObject(&pArgs[3], 0, sizeof(BYTE));
  1238. dwLen = 13;
  1239. if (!(pArgs[9].dwfCode & CF_MISSING_ARG))
  1240. dwLen++;
  1241. if (!(pArgs[10].dwfCode & CF_MISSING_ARG))
  1242. {
  1243. ASSERT(pArgs[10].dwCodeType == CODETYPE_STRING);
  1244. dwLen += pArgs[10].dwDataLen;
  1245. }
  1246. SetIntObject(&pArgs[0], dwLen, sizeof(WORD));
  1247. if (pArgs[11].dwCodeType == CODETYPE_STRING)
  1248. {
  1249. PNSOBJ pns;
  1250. if ((rc = CreateNameSpaceObj(ptoken, (PSZ)pArgs[11].pbDataBuff,
  1251. gpnsCurrentScope, gpnsCurrentOwner,
  1252. &pns, NSF_EXIST_ERR)) ==
  1253. ASLERR_NONE)
  1254. {
  1255. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  1256. if ((rc = CreateResFields(ptoken, pns, GenFlagFields)) ==
  1257. ASLERR_NONE)
  1258. {
  1259. rc = CreateResFields(ptoken, pns, WordFields);
  1260. }
  1261. }
  1262. MEMFREE(pArgs[11].pbDataBuff);
  1263. memset(&pArgs[11], 0, sizeof(CODEOBJ));
  1264. }
  1265. if (rc == ASLERR_NONE)
  1266. {
  1267. dwResBitOffset += (dwLen + 3)*8;
  1268. }
  1269. }
  1270. EXIT((1, "WordBusNumDesc=%d\n", rc));
  1271. return rc;
  1272. } //WordBusNumDesc
  1273. /***LP InterruptDesc - Extended Interrupt resource descriptor
  1274. *
  1275. * ENTRY
  1276. * ptoken -> token stream
  1277. * fActionFL - TRUE if this is a fixed list action
  1278. *
  1279. * EXIT-SUCCESS
  1280. * returns ASLERR_NONE
  1281. * EXIT-FAILURE
  1282. * returns negative error code
  1283. */
  1284. int LOCAL InterruptDesc(PTOKEN ptoken, BOOL fActionFL)
  1285. {
  1286. int rc = ASLERR_NONE;
  1287. PCODEOBJ pArgs;
  1288. PCODEOBJ pc;
  1289. ENTER((1, "InterruptDesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1290. DEREF(fActionFL);
  1291. ASSERT(fActionFL == FALSE);
  1292. pArgs = (PCODEOBJ)gpcodeScope->pbDataBuff;
  1293. pc = gpcodeScope->pcFirstChild;
  1294. if (((rc = SetDefMissingKW(&pArgs[0], ID_RESCONSUMER)) == ASLERR_NONE) &&
  1295. ((rc = SetDefMissingKW(&pArgs[3], ID_EXCLUSIVE)) == ASLERR_NONE))
  1296. {
  1297. if (pArgs[1].dwCodeValue == ID_EDGE)
  1298. pArgs[1].dwCodeValue = ID_EXT_EDGE;
  1299. else if (pArgs[1].dwCodeValue == ID_LEVEL)
  1300. pArgs[1].dwCodeValue = ID_EXT_LEVEL;
  1301. if (pArgs[2].dwCodeValue == ID_ACTIVEHI)
  1302. pArgs[2].dwCodeValue = ID_EXT_ACTIVEHI;
  1303. else if (pArgs[2].dwCodeValue == ID_ACTIVELO)
  1304. pArgs[2].dwCodeValue = ID_EXT_ACTIVELO;
  1305. if (pArgs[3].dwCodeValue == ID_SHARED)
  1306. pArgs[3].dwCodeValue = ID_EXT_SHARED;
  1307. else if (pArgs[3].dwCodeValue == ID_EXCLUSIVE)
  1308. pArgs[3].dwCodeValue = ID_EXT_EXCLUSIVE;
  1309. if (((rc = LookupIDIndex(pArgs[1].dwCodeValue, &pArgs[1].dwTermIndex))
  1310. == ASLERR_NONE) &&
  1311. ((rc = LookupIDIndex(pArgs[2].dwCodeValue, &pArgs[2].dwTermIndex))
  1312. == ASLERR_NONE) &&
  1313. ((rc = LookupIDIndex(pArgs[3].dwCodeValue, &pArgs[3].dwTermIndex))
  1314. == ASLERR_NONE))
  1315. {
  1316. EncodeKeywords(pArgs, 0x0f, 1);
  1317. {
  1318. DWORD dwNumIRQs = 0;
  1319. DWORD dwLen;
  1320. if (pc != NULL)
  1321. {
  1322. ASSERT(pc->dwCodeType == CODETYPE_DATAOBJ);
  1323. dwNumIRQs = pc->dwDataLen/sizeof(DWORD);
  1324. }
  1325. SetIntObject(&pArgs[2], dwNumIRQs, sizeof(BYTE));
  1326. memcpy(&pArgs[3], pc, sizeof(CODEOBJ));
  1327. MEMFREE(pc);
  1328. gpcodeScope->pcFirstChild = NULL;
  1329. dwLen = 2 + dwNumIRQs*sizeof(DWORD);
  1330. if (!(pArgs[4].dwfCode & CF_MISSING_ARG))
  1331. dwLen++;
  1332. if (!(pArgs[5].dwfCode & CF_MISSING_ARG))
  1333. {
  1334. ASSERT(pArgs[5].dwCodeType == CODETYPE_STRING);
  1335. dwLen += pArgs[5].dwDataLen;
  1336. }
  1337. SetIntObject(&pArgs[0], dwLen, sizeof(WORD));
  1338. if (pArgs[6].dwCodeType == CODETYPE_STRING)
  1339. {
  1340. PNSOBJ pns;
  1341. static RESFIELD IRQTabFields[] =
  1342. {
  1343. "_INT", 5*8 + 0, 0,
  1344. NULL, 0, 0
  1345. };
  1346. IRQTabFields[0].dwBitSize = dwNumIRQs*32;
  1347. if ((rc = CreateNameSpaceObj(ptoken,
  1348. (PSZ)pArgs[6].pbDataBuff,
  1349. gpnsCurrentScope,
  1350. gpnsCurrentOwner,
  1351. &pns, NSF_EXIST_ERR)) ==
  1352. ASLERR_NONE)
  1353. {
  1354. pns->ObjData.dwDataType = OBJTYPE_PNP_RES;
  1355. if ((rc = CreateResFields(ptoken, pns, IRQExFields)) ==
  1356. ASLERR_NONE)
  1357. {
  1358. rc = CreateResFields(ptoken, pns, IRQTabFields);
  1359. }
  1360. }
  1361. MEMFREE(pArgs[6].pbDataBuff);
  1362. memset(&pArgs[6], 0, sizeof(CODEOBJ));
  1363. }
  1364. if (rc == ASLERR_NONE)
  1365. {
  1366. gpcodeScope->dwCodeLen = 0;
  1367. gpcodeScope->bCodeChkSum = 0;
  1368. ComputeChkSumLen(gpcodeScope);
  1369. dwResBitOffset = (dwLen + 3)*8;
  1370. }
  1371. }
  1372. }
  1373. }
  1374. EXIT((1, "InterruptDesc=%d\n", rc));
  1375. return rc;
  1376. } //InterruptDesc
  1377. /***LP QWordMemDesc - QWord memory descriptor
  1378. *
  1379. * ENTRY
  1380. * ptoken -> token stream
  1381. * fActionFL - TRUE if this is a fixed list action
  1382. *
  1383. * EXIT-SUCCESS
  1384. * returns ASLERR_NONE
  1385. * EXIT-FAILURE
  1386. * returns negative error code
  1387. */
  1388. int LOCAL QWordMemDesc(PTOKEN ptoken, BOOL fActionFL)
  1389. {
  1390. int rc;
  1391. ENTER((1, "QWordMemDesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1392. DEREF(ptoken);
  1393. DEREF(fActionFL);
  1394. ASSERT(fActionFL == TRUE);
  1395. rc = MemSpaceDesc(ptoken, 43, QWordFields);
  1396. EXIT((1, "QWordMemDesc=%d\n", rc));
  1397. return rc;
  1398. } //QWordMemDesc
  1399. /***LP QWordIODesc - QWord IO descriptor
  1400. *
  1401. * ENTRY
  1402. * ptoken -> token stream
  1403. * fActionFL - TRUE if this is a fixed list action
  1404. *
  1405. * EXIT-SUCCESS
  1406. * returns ASLERR_NONE
  1407. * EXIT-FAILURE
  1408. * returns negative error code
  1409. */
  1410. int LOCAL QWordIODesc(PTOKEN ptoken, BOOL fActionFL)
  1411. {
  1412. int rc;
  1413. ENTER((1, "QWordIODesc(ptoken=%p,fActionFL=%d)\n", ptoken, fActionFL));
  1414. DEREF(ptoken);
  1415. DEREF(fActionFL);
  1416. ASSERT(fActionFL == TRUE);
  1417. rc = IOSpaceDesc(ptoken, 43, QWordFields);
  1418. EXIT((1, "QWordIODesc=%d\n", rc));
  1419. return rc;
  1420. } //QWordIODesc
  1421. /***LP CreateResFields - Create resource fields
  1422. *
  1423. * ENTRY
  1424. * ptoken -> TOKEN
  1425. * pnsParent -> parent object
  1426. * prf -> resource fields table
  1427. *
  1428. * EXIT-SUCCESS
  1429. * returns ASLERR_NONE
  1430. * EXIT-FAILURE
  1431. * returns negative error code
  1432. */
  1433. int LOCAL CreateResFields(PTOKEN ptoken, PNSOBJ pnsParent, PRESFIELD prf)
  1434. {
  1435. int rc = ASLERR_NONE;
  1436. int i;
  1437. PNSOBJ pns;
  1438. ENTER((2, "CreateResFields(ptoken=%p,pnsParent=%s,prf=%p)\n",
  1439. ptoken, GetObjectPath(pnsParent), prf));
  1440. for (i = 0; prf[i].pszName != NULL; ++i)
  1441. {
  1442. if ((rc = CreateNameSpaceObj(ptoken, prf[i].pszName, pnsParent,
  1443. gpnsCurrentOwner, &pns, NSF_EXIST_ERR))
  1444. == ASLERR_NONE)
  1445. {
  1446. pns->ObjData.dwDataType = OBJTYPE_RES_FIELD;
  1447. pns->ObjData.uipDataValue = dwResBitOffset + prf[i].dwBitOffset;
  1448. pns->ObjData.dwDataLen = prf[i].dwBitSize;
  1449. }
  1450. }
  1451. EXIT((2, "CreateResFields=%d\n", rc));
  1452. return rc;
  1453. } //CreateResFields