rsmisc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsmisc - Miscellaneous resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acresrc.h"
  45. #define _COMPONENT ACPI_RESOURCES
  46. ACPI_MODULE_NAME("rsmisc")
  47. #define INIT_RESOURCE_TYPE(i) i->resource_offset
  48. #define INIT_RESOURCE_LENGTH(i) i->aml_offset
  49. #define INIT_TABLE_LENGTH(i) i->value
  50. #define COMPARE_OPCODE(i) i->resource_offset
  51. #define COMPARE_TARGET(i) i->aml_offset
  52. #define COMPARE_VALUE(i) i->value
  53. /*******************************************************************************
  54. *
  55. * FUNCTION: acpi_rs_convert_aml_to_resource
  56. *
  57. * PARAMETERS: resource - Pointer to the resource descriptor
  58. * aml - Where the AML descriptor is returned
  59. * info - Pointer to appropriate conversion table
  60. *
  61. * RETURN: Status
  62. *
  63. * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
  64. * internal resource descriptor
  65. *
  66. ******************************************************************************/
  67. acpi_status
  68. acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
  69. union aml_resource *aml,
  70. struct acpi_rsconvert_info *info)
  71. {
  72. acpi_rs_length aml_resource_length;
  73. void *source;
  74. void *destination;
  75. char *target;
  76. u8 count;
  77. u8 flags_mode = FALSE;
  78. u16 item_count = 0;
  79. u16 temp16 = 0;
  80. ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);
  81. if (!info) {
  82. return_ACPI_STATUS(AE_BAD_PARAMETER);
  83. }
  84. if (((acpi_size) resource) & 0x3) {
  85. /* Each internal resource struct is expected to be 32-bit aligned */
  86. ACPI_WARNING((AE_INFO,
  87. "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
  88. resource, resource->type, resource->length));
  89. }
  90. /* Extract the resource Length field (does not include header length) */
  91. aml_resource_length = acpi_ut_get_resource_length(aml);
  92. /*
  93. * First table entry must be ACPI_RSC_INITxxx and must contain the
  94. * table length (# of table entries)
  95. */
  96. count = INIT_TABLE_LENGTH(info);
  97. while (count) {
  98. /*
  99. * Source is the external AML byte stream buffer,
  100. * destination is the internal resource descriptor
  101. */
  102. source = ACPI_ADD_PTR(void, aml, info->aml_offset);
  103. destination =
  104. ACPI_ADD_PTR(void, resource, info->resource_offset);
  105. switch (info->opcode) {
  106. case ACPI_RSC_INITGET:
  107. /*
  108. * Get the resource type and the initial (minimum) length
  109. */
  110. memset(resource, 0, INIT_RESOURCE_LENGTH(info));
  111. resource->type = INIT_RESOURCE_TYPE(info);
  112. resource->length = INIT_RESOURCE_LENGTH(info);
  113. break;
  114. case ACPI_RSC_INITSET:
  115. break;
  116. case ACPI_RSC_FLAGINIT:
  117. flags_mode = TRUE;
  118. break;
  119. case ACPI_RSC_1BITFLAG:
  120. /*
  121. * Mask and shift the flag bit
  122. */
  123. ACPI_SET8(destination,
  124. ((ACPI_GET8(source) >> info->value) & 0x01));
  125. break;
  126. case ACPI_RSC_2BITFLAG:
  127. /*
  128. * Mask and shift the flag bits
  129. */
  130. ACPI_SET8(destination,
  131. ((ACPI_GET8(source) >> info->value) & 0x03));
  132. break;
  133. case ACPI_RSC_3BITFLAG:
  134. /*
  135. * Mask and shift the flag bits
  136. */
  137. ACPI_SET8(destination,
  138. ((ACPI_GET8(source) >> info->value) & 0x07));
  139. break;
  140. case ACPI_RSC_COUNT:
  141. item_count = ACPI_GET8(source);
  142. ACPI_SET8(destination, item_count);
  143. resource->length = resource->length +
  144. (info->value * (item_count - 1));
  145. break;
  146. case ACPI_RSC_COUNT16:
  147. item_count = aml_resource_length;
  148. ACPI_SET16(destination, item_count);
  149. resource->length = resource->length +
  150. (info->value * (item_count - 1));
  151. break;
  152. case ACPI_RSC_COUNT_GPIO_PIN:
  153. target = ACPI_ADD_PTR(void, aml, info->value);
  154. item_count = ACPI_GET16(target) - ACPI_GET16(source);
  155. resource->length = resource->length + item_count;
  156. item_count = item_count / 2;
  157. ACPI_SET16(destination, item_count);
  158. break;
  159. case ACPI_RSC_COUNT_GPIO_VEN:
  160. item_count = ACPI_GET8(source);
  161. ACPI_SET8(destination, item_count);
  162. resource->length = resource->length +
  163. (info->value * item_count);
  164. break;
  165. case ACPI_RSC_COUNT_GPIO_RES:
  166. /*
  167. * Vendor data is optional (length/offset may both be zero)
  168. * Examine vendor data length field first
  169. */
  170. target = ACPI_ADD_PTR(void, aml, (info->value + 2));
  171. if (ACPI_GET16(target)) {
  172. /* Use vendor offset to get resource source length */
  173. target = ACPI_ADD_PTR(void, aml, info->value);
  174. item_count =
  175. ACPI_GET16(target) - ACPI_GET16(source);
  176. } else {
  177. /* No vendor data to worry about */
  178. item_count = aml->large_header.resource_length +
  179. sizeof(struct aml_resource_large_header) -
  180. ACPI_GET16(source);
  181. }
  182. resource->length = resource->length + item_count;
  183. ACPI_SET16(destination, item_count);
  184. break;
  185. case ACPI_RSC_COUNT_SERIAL_VEN:
  186. item_count = ACPI_GET16(source) - info->value;
  187. resource->length = resource->length + item_count;
  188. ACPI_SET16(destination, item_count);
  189. break;
  190. case ACPI_RSC_COUNT_SERIAL_RES:
  191. item_count = (aml_resource_length +
  192. sizeof(struct aml_resource_large_header))
  193. - ACPI_GET16(source) - info->value;
  194. resource->length = resource->length + item_count;
  195. ACPI_SET16(destination, item_count);
  196. break;
  197. case ACPI_RSC_LENGTH:
  198. resource->length = resource->length + info->value;
  199. break;
  200. case ACPI_RSC_MOVE8:
  201. case ACPI_RSC_MOVE16:
  202. case ACPI_RSC_MOVE32:
  203. case ACPI_RSC_MOVE64:
  204. /*
  205. * Raw data move. Use the Info value field unless item_count has
  206. * been previously initialized via a COUNT opcode
  207. */
  208. if (info->value) {
  209. item_count = info->value;
  210. }
  211. acpi_rs_move_data(destination, source, item_count,
  212. info->opcode);
  213. break;
  214. case ACPI_RSC_MOVE_GPIO_PIN:
  215. /* Generate and set the PIN data pointer */
  216. target = (char *)ACPI_ADD_PTR(void, resource,
  217. (resource->length -
  218. item_count * 2));
  219. *(u16 **)destination = ACPI_CAST_PTR(u16, target);
  220. /* Copy the PIN data */
  221. source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
  222. acpi_rs_move_data(target, source, item_count,
  223. info->opcode);
  224. break;
  225. case ACPI_RSC_MOVE_GPIO_RES:
  226. /* Generate and set the resource_source string pointer */
  227. target = (char *)ACPI_ADD_PTR(void, resource,
  228. (resource->length -
  229. item_count));
  230. *(u8 **)destination = ACPI_CAST_PTR(u8, target);
  231. /* Copy the resource_source string */
  232. source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
  233. acpi_rs_move_data(target, source, item_count,
  234. info->opcode);
  235. break;
  236. case ACPI_RSC_MOVE_SERIAL_VEN:
  237. /* Generate and set the Vendor Data pointer */
  238. target = (char *)ACPI_ADD_PTR(void, resource,
  239. (resource->length -
  240. item_count));
  241. *(u8 **)destination = ACPI_CAST_PTR(u8, target);
  242. /* Copy the Vendor Data */
  243. source = ACPI_ADD_PTR(void, aml, info->value);
  244. acpi_rs_move_data(target, source, item_count,
  245. info->opcode);
  246. break;
  247. case ACPI_RSC_MOVE_SERIAL_RES:
  248. /* Generate and set the resource_source string pointer */
  249. target = (char *)ACPI_ADD_PTR(void, resource,
  250. (resource->length -
  251. item_count));
  252. *(u8 **)destination = ACPI_CAST_PTR(u8, target);
  253. /* Copy the resource_source string */
  254. source =
  255. ACPI_ADD_PTR(void, aml,
  256. (ACPI_GET16(source) + info->value));
  257. acpi_rs_move_data(target, source, item_count,
  258. info->opcode);
  259. break;
  260. case ACPI_RSC_SET8:
  261. memset(destination, info->aml_offset, info->value);
  262. break;
  263. case ACPI_RSC_DATA8:
  264. target = ACPI_ADD_PTR(char, resource, info->value);
  265. memcpy(destination, source, ACPI_GET16(target));
  266. break;
  267. case ACPI_RSC_ADDRESS:
  268. /*
  269. * Common handler for address descriptor flags
  270. */
  271. if (!acpi_rs_get_address_common(resource, aml)) {
  272. return_ACPI_STATUS
  273. (AE_AML_INVALID_RESOURCE_TYPE);
  274. }
  275. break;
  276. case ACPI_RSC_SOURCE:
  277. /*
  278. * Optional resource_source (Index and String)
  279. */
  280. resource->length +=
  281. acpi_rs_get_resource_source(aml_resource_length,
  282. info->value,
  283. destination, aml, NULL);
  284. break;
  285. case ACPI_RSC_SOURCEX:
  286. /*
  287. * Optional resource_source (Index and String). This is the more
  288. * complicated case used by the Interrupt() macro
  289. */
  290. target = ACPI_ADD_PTR(char, resource,
  291. info->aml_offset +
  292. (item_count * 4));
  293. resource->length +=
  294. acpi_rs_get_resource_source(aml_resource_length,
  295. (acpi_rs_length)
  296. (((item_count -
  297. 1) * sizeof(u32)) +
  298. info->value),
  299. destination, aml,
  300. target);
  301. break;
  302. case ACPI_RSC_BITMASK:
  303. /*
  304. * 8-bit encoded bitmask (DMA macro)
  305. */
  306. item_count =
  307. acpi_rs_decode_bitmask(ACPI_GET8(source),
  308. destination);
  309. if (item_count) {
  310. resource->length += (item_count - 1);
  311. }
  312. target = ACPI_ADD_PTR(char, resource, info->value);
  313. ACPI_SET8(target, item_count);
  314. break;
  315. case ACPI_RSC_BITMASK16:
  316. /*
  317. * 16-bit encoded bitmask (IRQ macro)
  318. */
  319. ACPI_MOVE_16_TO_16(&temp16, source);
  320. item_count =
  321. acpi_rs_decode_bitmask(temp16, destination);
  322. if (item_count) {
  323. resource->length += (item_count - 1);
  324. }
  325. target = ACPI_ADD_PTR(char, resource, info->value);
  326. ACPI_SET8(target, item_count);
  327. break;
  328. case ACPI_RSC_EXIT_NE:
  329. /*
  330. * control - Exit conversion if not equal
  331. */
  332. switch (info->resource_offset) {
  333. case ACPI_RSC_COMPARE_AML_LENGTH:
  334. if (aml_resource_length != info->value) {
  335. goto exit;
  336. }
  337. break;
  338. case ACPI_RSC_COMPARE_VALUE:
  339. if (ACPI_GET8(source) != info->value) {
  340. goto exit;
  341. }
  342. break;
  343. default:
  344. ACPI_ERROR((AE_INFO,
  345. "Invalid conversion sub-opcode"));
  346. return_ACPI_STATUS(AE_BAD_PARAMETER);
  347. }
  348. break;
  349. default:
  350. ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
  351. return_ACPI_STATUS(AE_BAD_PARAMETER);
  352. }
  353. count--;
  354. info++;
  355. }
  356. exit:
  357. if (!flags_mode) {
  358. /* Round the resource struct length up to the next boundary (32 or 64) */
  359. resource->length =
  360. (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length);
  361. }
  362. return_ACPI_STATUS(AE_OK);
  363. }
  364. /*******************************************************************************
  365. *
  366. * FUNCTION: acpi_rs_convert_resource_to_aml
  367. *
  368. * PARAMETERS: resource - Pointer to the resource descriptor
  369. * aml - Where the AML descriptor is returned
  370. * info - Pointer to appropriate conversion table
  371. *
  372. * RETURN: Status
  373. *
  374. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  375. * external AML resource descriptor.
  376. *
  377. ******************************************************************************/
  378. acpi_status
  379. acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
  380. union aml_resource *aml,
  381. struct acpi_rsconvert_info *info)
  382. {
  383. void *source = NULL;
  384. void *destination;
  385. char *target;
  386. acpi_rsdesc_size aml_length = 0;
  387. u8 count;
  388. u16 temp16 = 0;
  389. u16 item_count = 0;
  390. ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
  391. if (!info) {
  392. return_ACPI_STATUS(AE_BAD_PARAMETER);
  393. }
  394. /*
  395. * First table entry must be ACPI_RSC_INITxxx and must contain the
  396. * table length (# of table entries)
  397. */
  398. count = INIT_TABLE_LENGTH(info);
  399. while (count) {
  400. /*
  401. * Source is the internal resource descriptor,
  402. * destination is the external AML byte stream buffer
  403. */
  404. source = ACPI_ADD_PTR(void, resource, info->resource_offset);
  405. destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
  406. switch (info->opcode) {
  407. case ACPI_RSC_INITSET:
  408. memset(aml, 0, INIT_RESOURCE_LENGTH(info));
  409. aml_length = INIT_RESOURCE_LENGTH(info);
  410. acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
  411. aml_length, aml);
  412. break;
  413. case ACPI_RSC_INITGET:
  414. break;
  415. case ACPI_RSC_FLAGINIT:
  416. /*
  417. * Clear the flag byte
  418. */
  419. ACPI_SET8(destination, 0);
  420. break;
  421. case ACPI_RSC_1BITFLAG:
  422. /*
  423. * Mask and shift the flag bit
  424. */
  425. ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
  426. ((ACPI_GET8(source) & 0x01) << info->
  427. value));
  428. break;
  429. case ACPI_RSC_2BITFLAG:
  430. /*
  431. * Mask and shift the flag bits
  432. */
  433. ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
  434. ((ACPI_GET8(source) & 0x03) << info->
  435. value));
  436. break;
  437. case ACPI_RSC_3BITFLAG:
  438. /*
  439. * Mask and shift the flag bits
  440. */
  441. ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
  442. ((ACPI_GET8(source) & 0x07) << info->
  443. value));
  444. break;
  445. case ACPI_RSC_COUNT:
  446. item_count = ACPI_GET8(source);
  447. ACPI_SET8(destination, item_count);
  448. aml_length =
  449. (u16) (aml_length +
  450. (info->value * (item_count - 1)));
  451. break;
  452. case ACPI_RSC_COUNT16:
  453. item_count = ACPI_GET16(source);
  454. aml_length = (u16) (aml_length + item_count);
  455. acpi_rs_set_resource_length(aml_length, aml);
  456. break;
  457. case ACPI_RSC_COUNT_GPIO_PIN:
  458. item_count = ACPI_GET16(source);
  459. ACPI_SET16(destination, aml_length);
  460. aml_length = (u16)(aml_length + item_count * 2);
  461. target = ACPI_ADD_PTR(void, aml, info->value);
  462. ACPI_SET16(target, aml_length);
  463. acpi_rs_set_resource_length(aml_length, aml);
  464. break;
  465. case ACPI_RSC_COUNT_GPIO_VEN:
  466. item_count = ACPI_GET16(source);
  467. ACPI_SET16(destination, item_count);
  468. aml_length =
  469. (u16)(aml_length + (info->value * item_count));
  470. acpi_rs_set_resource_length(aml_length, aml);
  471. break;
  472. case ACPI_RSC_COUNT_GPIO_RES:
  473. /* Set resource source string length */
  474. item_count = ACPI_GET16(source);
  475. ACPI_SET16(destination, aml_length);
  476. /* Compute offset for the Vendor Data */
  477. aml_length = (u16)(aml_length + item_count);
  478. target = ACPI_ADD_PTR(void, aml, info->value);
  479. /* Set vendor offset only if there is vendor data */
  480. if (resource->data.gpio.vendor_length) {
  481. ACPI_SET16(target, aml_length);
  482. }
  483. acpi_rs_set_resource_length(aml_length, aml);
  484. break;
  485. case ACPI_RSC_COUNT_SERIAL_VEN:
  486. item_count = ACPI_GET16(source);
  487. ACPI_SET16(destination, item_count + info->value);
  488. aml_length = (u16)(aml_length + item_count);
  489. acpi_rs_set_resource_length(aml_length, aml);
  490. break;
  491. case ACPI_RSC_COUNT_SERIAL_RES:
  492. item_count = ACPI_GET16(source);
  493. aml_length = (u16)(aml_length + item_count);
  494. acpi_rs_set_resource_length(aml_length, aml);
  495. break;
  496. case ACPI_RSC_LENGTH:
  497. acpi_rs_set_resource_length(info->value, aml);
  498. break;
  499. case ACPI_RSC_MOVE8:
  500. case ACPI_RSC_MOVE16:
  501. case ACPI_RSC_MOVE32:
  502. case ACPI_RSC_MOVE64:
  503. if (info->value) {
  504. item_count = info->value;
  505. }
  506. acpi_rs_move_data(destination, source, item_count,
  507. info->opcode);
  508. break;
  509. case ACPI_RSC_MOVE_GPIO_PIN:
  510. destination = (char *)ACPI_ADD_PTR(void, aml,
  511. ACPI_GET16
  512. (destination));
  513. source = *(u16 **)source;
  514. acpi_rs_move_data(destination, source, item_count,
  515. info->opcode);
  516. break;
  517. case ACPI_RSC_MOVE_GPIO_RES:
  518. /* Used for both resource_source string and vendor_data */
  519. destination = (char *)ACPI_ADD_PTR(void, aml,
  520. ACPI_GET16
  521. (destination));
  522. source = *(u8 **)source;
  523. acpi_rs_move_data(destination, source, item_count,
  524. info->opcode);
  525. break;
  526. case ACPI_RSC_MOVE_SERIAL_VEN:
  527. destination = (char *)ACPI_ADD_PTR(void, aml,
  528. (aml_length -
  529. item_count));
  530. source = *(u8 **)source;
  531. acpi_rs_move_data(destination, source, item_count,
  532. info->opcode);
  533. break;
  534. case ACPI_RSC_MOVE_SERIAL_RES:
  535. destination = (char *)ACPI_ADD_PTR(void, aml,
  536. (aml_length -
  537. item_count));
  538. source = *(u8 **)source;
  539. acpi_rs_move_data(destination, source, item_count,
  540. info->opcode);
  541. break;
  542. case ACPI_RSC_ADDRESS:
  543. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  544. acpi_rs_set_address_common(aml, resource);
  545. break;
  546. case ACPI_RSC_SOURCEX:
  547. /*
  548. * Optional resource_source (Index and String)
  549. */
  550. aml_length =
  551. acpi_rs_set_resource_source(aml,
  552. (acpi_rs_length)
  553. aml_length, source);
  554. acpi_rs_set_resource_length(aml_length, aml);
  555. break;
  556. case ACPI_RSC_SOURCE:
  557. /*
  558. * Optional resource_source (Index and String). This is the more
  559. * complicated case used by the Interrupt() macro
  560. */
  561. aml_length =
  562. acpi_rs_set_resource_source(aml, info->value,
  563. source);
  564. acpi_rs_set_resource_length(aml_length, aml);
  565. break;
  566. case ACPI_RSC_BITMASK:
  567. /*
  568. * 8-bit encoded bitmask (DMA macro)
  569. */
  570. ACPI_SET8(destination,
  571. acpi_rs_encode_bitmask(source,
  572. *ACPI_ADD_PTR(u8,
  573. resource,
  574. info->
  575. value)));
  576. break;
  577. case ACPI_RSC_BITMASK16:
  578. /*
  579. * 16-bit encoded bitmask (IRQ macro)
  580. */
  581. temp16 = acpi_rs_encode_bitmask(source,
  582. *ACPI_ADD_PTR(u8,
  583. resource,
  584. info->
  585. value));
  586. ACPI_MOVE_16_TO_16(destination, &temp16);
  587. break;
  588. case ACPI_RSC_EXIT_LE:
  589. /*
  590. * control - Exit conversion if less than or equal
  591. */
  592. if (item_count <= info->value) {
  593. goto exit;
  594. }
  595. break;
  596. case ACPI_RSC_EXIT_NE:
  597. /*
  598. * control - Exit conversion if not equal
  599. */
  600. switch (COMPARE_OPCODE(info)) {
  601. case ACPI_RSC_COMPARE_VALUE:
  602. if (*ACPI_ADD_PTR(u8, resource,
  603. COMPARE_TARGET(info)) !=
  604. COMPARE_VALUE(info)) {
  605. goto exit;
  606. }
  607. break;
  608. default:
  609. ACPI_ERROR((AE_INFO,
  610. "Invalid conversion sub-opcode"));
  611. return_ACPI_STATUS(AE_BAD_PARAMETER);
  612. }
  613. break;
  614. case ACPI_RSC_EXIT_EQ:
  615. /*
  616. * control - Exit conversion if equal
  617. */
  618. if (*ACPI_ADD_PTR(u8, resource,
  619. COMPARE_TARGET(info)) ==
  620. COMPARE_VALUE(info)) {
  621. goto exit;
  622. }
  623. break;
  624. default:
  625. ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
  626. return_ACPI_STATUS(AE_BAD_PARAMETER);
  627. }
  628. count--;
  629. info++;
  630. }
  631. exit:
  632. return_ACPI_STATUS(AE_OK);
  633. }
  634. #if 0
  635. /* Previous resource validations */
  636. if (aml->ext_address64.revision_ID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
  637. return_ACPI_STATUS(AE_SUPPORT);
  638. }
  639. if (resource->data.start_dpf.performance_robustness >= 3) {
  640. return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
  641. }
  642. if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
  643. /*
  644. * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
  645. * polarity/trigger interrupts are allowed (ACPI spec, section
  646. * "IRQ Format"), so 0x00 and 0x09 are illegal.
  647. */
  648. ACPI_ERROR((AE_INFO,
  649. "Invalid interrupt polarity/trigger in resource list, 0x%X",
  650. aml->irq.flags));
  651. return_ACPI_STATUS(AE_BAD_DATA);
  652. }
  653. resource->data.extended_irq.interrupt_count = temp8;
  654. if (temp8 < 1) {
  655. /* Must have at least one IRQ */
  656. return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
  657. }
  658. if (resource->data.dma.transfer == 0x03) {
  659. ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
  660. return_ACPI_STATUS(AE_BAD_DATA);
  661. }
  662. #endif