rsmisc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsmisc - Miscellaneous resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2012, 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. ACPI_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) = (u8)
  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) = (u8)
  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) = (u8)
  138. ((ACPI_GET8(source) >> info->value) & 0x07);
  139. break;
  140. case ACPI_RSC_COUNT:
  141. item_count = ACPI_GET8(source);
  142. ACPI_SET8(destination) = (u8) 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) = (u8)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. ACPI_MEMSET(destination, info->aml_offset, info->value);
  262. break;
  263. case ACPI_RSC_DATA8:
  264. target = ACPI_ADD_PTR(char, resource, info->value);
  265. ACPI_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) = (u8) 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) = (u8) 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. ACPI_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_SET8(destination) |= (u8)
  426. ((ACPI_GET8(source) & 0x01) << info->value);
  427. break;
  428. case ACPI_RSC_2BITFLAG:
  429. /*
  430. * Mask and shift the flag bits
  431. */
  432. ACPI_SET8(destination) |= (u8)
  433. ((ACPI_GET8(source) & 0x03) << info->value);
  434. break;
  435. case ACPI_RSC_3BITFLAG:
  436. /*
  437. * Mask and shift the flag bits
  438. */
  439. ACPI_SET8(destination) |= (u8)
  440. ((ACPI_GET8(source) & 0x07) << info->value);
  441. break;
  442. case ACPI_RSC_COUNT:
  443. item_count = ACPI_GET8(source);
  444. ACPI_SET8(destination) = (u8) item_count;
  445. aml_length =
  446. (u16) (aml_length +
  447. (info->value * (item_count - 1)));
  448. break;
  449. case ACPI_RSC_COUNT16:
  450. item_count = ACPI_GET16(source);
  451. aml_length = (u16) (aml_length + item_count);
  452. acpi_rs_set_resource_length(aml_length, aml);
  453. break;
  454. case ACPI_RSC_COUNT_GPIO_PIN:
  455. item_count = ACPI_GET16(source);
  456. ACPI_SET16(destination) = (u16)aml_length;
  457. aml_length = (u16)(aml_length + item_count * 2);
  458. target = ACPI_ADD_PTR(void, aml, info->value);
  459. ACPI_SET16(target) = (u16)aml_length;
  460. acpi_rs_set_resource_length(aml_length, aml);
  461. break;
  462. case ACPI_RSC_COUNT_GPIO_VEN:
  463. item_count = ACPI_GET16(source);
  464. ACPI_SET16(destination) = (u16)item_count;
  465. aml_length =
  466. (u16)(aml_length + (info->value * item_count));
  467. acpi_rs_set_resource_length(aml_length, aml);
  468. break;
  469. case ACPI_RSC_COUNT_GPIO_RES:
  470. /* Set resource source string length */
  471. item_count = ACPI_GET16(source);
  472. ACPI_SET16(destination) = (u16)aml_length;
  473. /* Compute offset for the Vendor Data */
  474. aml_length = (u16)(aml_length + item_count);
  475. target = ACPI_ADD_PTR(void, aml, info->value);
  476. /* Set vendor offset only if there is vendor data */
  477. if (resource->data.gpio.vendor_length) {
  478. ACPI_SET16(target) = (u16)aml_length;
  479. }
  480. acpi_rs_set_resource_length(aml_length, aml);
  481. break;
  482. case ACPI_RSC_COUNT_SERIAL_VEN:
  483. item_count = ACPI_GET16(source);
  484. ACPI_SET16(destination) = item_count + info->value;
  485. aml_length = (u16)(aml_length + item_count);
  486. acpi_rs_set_resource_length(aml_length, aml);
  487. break;
  488. case ACPI_RSC_COUNT_SERIAL_RES:
  489. item_count = ACPI_GET16(source);
  490. aml_length = (u16)(aml_length + item_count);
  491. acpi_rs_set_resource_length(aml_length, aml);
  492. break;
  493. case ACPI_RSC_LENGTH:
  494. acpi_rs_set_resource_length(info->value, aml);
  495. break;
  496. case ACPI_RSC_MOVE8:
  497. case ACPI_RSC_MOVE16:
  498. case ACPI_RSC_MOVE32:
  499. case ACPI_RSC_MOVE64:
  500. if (info->value) {
  501. item_count = info->value;
  502. }
  503. acpi_rs_move_data(destination, source, item_count,
  504. info->opcode);
  505. break;
  506. case ACPI_RSC_MOVE_GPIO_PIN:
  507. destination = (char *)ACPI_ADD_PTR(void, aml,
  508. ACPI_GET16
  509. (destination));
  510. source = *(u16 **)source;
  511. acpi_rs_move_data(destination, source, item_count,
  512. info->opcode);
  513. break;
  514. case ACPI_RSC_MOVE_GPIO_RES:
  515. /* Used for both resource_source string and vendor_data */
  516. destination = (char *)ACPI_ADD_PTR(void, aml,
  517. ACPI_GET16
  518. (destination));
  519. source = *(u8 **)source;
  520. acpi_rs_move_data(destination, source, item_count,
  521. info->opcode);
  522. break;
  523. case ACPI_RSC_MOVE_SERIAL_VEN:
  524. destination = (char *)ACPI_ADD_PTR(void, aml,
  525. (aml_length -
  526. item_count));
  527. source = *(u8 **)source;
  528. acpi_rs_move_data(destination, source, item_count,
  529. info->opcode);
  530. break;
  531. case ACPI_RSC_MOVE_SERIAL_RES:
  532. destination = (char *)ACPI_ADD_PTR(void, aml,
  533. (aml_length -
  534. item_count));
  535. source = *(u8 **)source;
  536. acpi_rs_move_data(destination, source, item_count,
  537. info->opcode);
  538. break;
  539. case ACPI_RSC_ADDRESS:
  540. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  541. acpi_rs_set_address_common(aml, resource);
  542. break;
  543. case ACPI_RSC_SOURCEX:
  544. /*
  545. * Optional resource_source (Index and String)
  546. */
  547. aml_length =
  548. acpi_rs_set_resource_source(aml, (acpi_rs_length)
  549. aml_length, source);
  550. acpi_rs_set_resource_length(aml_length, aml);
  551. break;
  552. case ACPI_RSC_SOURCE:
  553. /*
  554. * Optional resource_source (Index and String). This is the more
  555. * complicated case used by the Interrupt() macro
  556. */
  557. aml_length =
  558. acpi_rs_set_resource_source(aml, info->value,
  559. source);
  560. acpi_rs_set_resource_length(aml_length, aml);
  561. break;
  562. case ACPI_RSC_BITMASK:
  563. /*
  564. * 8-bit encoded bitmask (DMA macro)
  565. */
  566. ACPI_SET8(destination) = (u8)
  567. acpi_rs_encode_bitmask(source,
  568. *ACPI_ADD_PTR(u8, resource,
  569. info->value));
  570. break;
  571. case ACPI_RSC_BITMASK16:
  572. /*
  573. * 16-bit encoded bitmask (IRQ macro)
  574. */
  575. temp16 = acpi_rs_encode_bitmask(source,
  576. *ACPI_ADD_PTR(u8,
  577. resource,
  578. info->
  579. value));
  580. ACPI_MOVE_16_TO_16(destination, &temp16);
  581. break;
  582. case ACPI_RSC_EXIT_LE:
  583. /*
  584. * Control - Exit conversion if less than or equal
  585. */
  586. if (item_count <= info->value) {
  587. goto exit;
  588. }
  589. break;
  590. case ACPI_RSC_EXIT_NE:
  591. /*
  592. * Control - Exit conversion if not equal
  593. */
  594. switch (COMPARE_OPCODE(info)) {
  595. case ACPI_RSC_COMPARE_VALUE:
  596. if (*ACPI_ADD_PTR(u8, resource,
  597. COMPARE_TARGET(info)) !=
  598. COMPARE_VALUE(info)) {
  599. goto exit;
  600. }
  601. break;
  602. default:
  603. ACPI_ERROR((AE_INFO,
  604. "Invalid conversion sub-opcode"));
  605. return_ACPI_STATUS(AE_BAD_PARAMETER);
  606. }
  607. break;
  608. case ACPI_RSC_EXIT_EQ:
  609. /*
  610. * Control - Exit conversion if equal
  611. */
  612. if (*ACPI_ADD_PTR(u8, resource,
  613. COMPARE_TARGET(info)) ==
  614. COMPARE_VALUE(info)) {
  615. goto exit;
  616. }
  617. break;
  618. default:
  619. ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
  620. return_ACPI_STATUS(AE_BAD_PARAMETER);
  621. }
  622. count--;
  623. info++;
  624. }
  625. exit:
  626. return_ACPI_STATUS(AE_OK);
  627. }
  628. #if 0
  629. /* Previous resource validations */
  630. if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
  631. return_ACPI_STATUS(AE_SUPPORT);
  632. }
  633. if (resource->data.start_dpf.performance_robustness >= 3) {
  634. return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
  635. }
  636. if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
  637. /*
  638. * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
  639. * polarity/trigger interrupts are allowed (ACPI spec, section
  640. * "IRQ Format"), so 0x00 and 0x09 are illegal.
  641. */
  642. ACPI_ERROR((AE_INFO,
  643. "Invalid interrupt polarity/trigger in resource list, 0x%X",
  644. aml->irq.flags));
  645. return_ACPI_STATUS(AE_BAD_DATA);
  646. }
  647. resource->data.extended_irq.interrupt_count = temp8;
  648. if (temp8 < 1) {
  649. /* Must have at least one IRQ */
  650. return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
  651. }
  652. if (resource->data.dma.transfer == 0x03) {
  653. ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
  654. return_ACPI_STATUS(AE_BAD_DATA);
  655. }
  656. #endif