rsaddr.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsaddr - Address resource descriptors (16/32/64)
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, R. Byron Moore
  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 <acpi/acresrc.h>
  44. #define _COMPONENT ACPI_RESOURCES
  45. ACPI_MODULE_NAME("rsaddr")
  46. /* Local prototypes */
  47. static void
  48. acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags);
  49. static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource);
  50. static void
  51. acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
  52. static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
  53. static void
  54. acpi_rs_set_address_common(union aml_resource *aml,
  55. struct acpi_resource *resource);
  56. static u8
  57. acpi_rs_get_address_common(struct acpi_resource *resource,
  58. union aml_resource *aml);
  59. /*******************************************************************************
  60. *
  61. * FUNCTION: acpi_rs_decode_general_flags
  62. *
  63. * PARAMETERS: Resource - Address resource data struct
  64. * Flags - Raw AML flag byte
  65. *
  66. * RETURN: Decoded flag bits in resource struct
  67. *
  68. * DESCRIPTION: Decode a general flag byte to an address resource struct
  69. *
  70. ******************************************************************************/
  71. static void
  72. acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags)
  73. {
  74. ACPI_FUNCTION_ENTRY();
  75. /* Producer / Consumer - flag bit[0] */
  76. resource->address.producer_consumer = (u32) (flags & 0x01);
  77. /* Decode (_DEC) - flag bit[1] */
  78. resource->address.decode = (u32) ((flags >> 1) & 0x01);
  79. /* Min Address Fixed (_MIF) - flag bit[2] */
  80. resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01);
  81. /* Max Address Fixed (_MAF) - flag bit[3] */
  82. resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01);
  83. }
  84. /*******************************************************************************
  85. *
  86. * FUNCTION: acpi_rs_encode_general_flags
  87. *
  88. * PARAMETERS: Resource - Address resource data struct
  89. *
  90. * RETURN: Encoded general flag byte
  91. *
  92. * DESCRIPTION: Construct a general flag byte from an address resource struct
  93. *
  94. ******************************************************************************/
  95. static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
  96. {
  97. ACPI_FUNCTION_ENTRY();
  98. return ((u8)
  99. /* Producer / Consumer - flag bit[0] */
  100. ((resource->address.producer_consumer & 0x01) |
  101. /* Decode (_DEC) - flag bit[1] */
  102. ((resource->address.decode & 0x01) << 1) |
  103. /* Min Address Fixed (_MIF) - flag bit[2] */
  104. ((resource->address.min_address_fixed & 0x01) << 2) |
  105. /* Max Address Fixed (_MAF) - flag bit[3] */
  106. ((resource->address.max_address_fixed & 0x01) << 3))
  107. );
  108. }
  109. /*******************************************************************************
  110. *
  111. * FUNCTION: acpi_rs_decode_specific_flags
  112. *
  113. * PARAMETERS: Resource - Address resource data struct
  114. * Flags - Raw AML flag byte
  115. *
  116. * RETURN: Decoded flag bits in attribute struct
  117. *
  118. * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
  119. * Type-specific flags are only defined for the Memory and IO
  120. * resource types.
  121. *
  122. ******************************************************************************/
  123. static void
  124. acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags)
  125. {
  126. ACPI_FUNCTION_ENTRY();
  127. if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
  128. /* Write Status (_RW) - flag bit[0] */
  129. resource->address.attribute.memory.read_write_attribute =
  130. (u16) (flags & 0x01);
  131. /* Memory Attributes (_MEM) - flag bits[2:1] */
  132. resource->address.attribute.memory.cache_attribute =
  133. (u16) ((flags >> 1) & 0x03);
  134. } else if (resource->address.resource_type == ACPI_IO_RANGE) {
  135. /* Ranges (_RNG) - flag bits[1:0] */
  136. resource->address.attribute.io.range_attribute =
  137. (u16) (flags & 0x03);
  138. /* Translations (_TTP and _TRS) - flag bits[5:4] */
  139. resource->address.attribute.io.translation_attribute =
  140. (u16) ((flags >> 4) & 0x03);
  141. }
  142. }
  143. /*******************************************************************************
  144. *
  145. * FUNCTION: acpi_rs_encode_specific_flags
  146. *
  147. * PARAMETERS: Resource - Address resource data struct
  148. *
  149. * RETURN: Encoded type-specific flag byte
  150. *
  151. * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
  152. * Type-specific flags are only defined for the Memory and IO
  153. * resource types.
  154. *
  155. ******************************************************************************/
  156. static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource)
  157. {
  158. ACPI_FUNCTION_ENTRY();
  159. if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
  160. return ((u8)
  161. /* Write Status (_RW) - flag bit[0] */
  162. ((resource->address.attribute.memory.
  163. read_write_attribute & 0x01) |
  164. /* Memory Attributes (_MEM) - flag bits[2:1] */
  165. ((resource->address.attribute.memory.
  166. cache_attribute & 0x03) << 1)));
  167. } else if (resource->address.resource_type == ACPI_IO_RANGE) {
  168. return ((u8)
  169. /* Ranges (_RNG) - flag bits[1:0] */
  170. ((resource->address.attribute.io.
  171. range_attribute & 0x03) |
  172. /* Translations (_TTP and _TRS) - flag bits[5:4] */
  173. ((resource->address.attribute.io.
  174. translation_attribute & 0x03) << 4)));
  175. }
  176. return (0);
  177. }
  178. /*******************************************************************************
  179. *
  180. * FUNCTION: acpi_rs_set_address_common
  181. *
  182. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  183. * Resource - Pointer to the internal resource struct
  184. *
  185. * RETURN: None
  186. *
  187. * DESCRIPTION: Convert common flag fields from a resource descriptor to an
  188. * AML descriptor
  189. *
  190. ******************************************************************************/
  191. static void
  192. acpi_rs_set_address_common(union aml_resource *aml,
  193. struct acpi_resource *resource)
  194. {
  195. ACPI_FUNCTION_ENTRY();
  196. /* Set the Resource Type (Memory, Io, bus_number, etc.) */
  197. aml->address.resource_type = (u8) resource->data.address.resource_type;
  198. /* Set the general flags */
  199. aml->address.flags = acpi_rs_encode_general_flags(&resource->data);
  200. /* Set the type-specific flags */
  201. aml->address.specific_flags =
  202. acpi_rs_encode_specific_flags(&resource->data);
  203. }
  204. /*******************************************************************************
  205. *
  206. * FUNCTION: acpi_rs_get_address_common
  207. *
  208. * PARAMETERS: Resource - Pointer to the internal resource struct
  209. * Aml - Pointer to the AML resource descriptor
  210. *
  211. * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
  212. *
  213. * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
  214. * to an internal resource descriptor
  215. *
  216. ******************************************************************************/
  217. static u8
  218. acpi_rs_get_address_common(struct acpi_resource *resource,
  219. union aml_resource *aml)
  220. {
  221. ACPI_FUNCTION_ENTRY();
  222. /* Validate resource type */
  223. if ((aml->address.resource_type > 2)
  224. && (aml->address.resource_type < 0xC0)) {
  225. return (FALSE);
  226. }
  227. /* Get the Resource Type (Memory, Io, bus_number, etc.) */
  228. resource->data.address.resource_type = aml->address.resource_type;
  229. /* Get the General Flags */
  230. acpi_rs_decode_general_flags(&resource->data, aml->address.flags);
  231. /* Get the Type-Specific Flags */
  232. acpi_rs_decode_specific_flags(&resource->data,
  233. aml->address.specific_flags);
  234. return (TRUE);
  235. }
  236. /*******************************************************************************
  237. *
  238. * FUNCTION: acpi_rs_get_address16
  239. *
  240. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  241. * aml_resource_length - Length of the resource from the AML header
  242. * Resource - Where the internal resource is returned
  243. *
  244. * RETURN: Status
  245. *
  246. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  247. * internal resource descriptor, simplifying bitflags and handling
  248. * alignment and endian issues if necessary.
  249. *
  250. ******************************************************************************/
  251. acpi_status
  252. acpi_rs_get_address16(union aml_resource * aml,
  253. u16 aml_resource_length, struct acpi_resource * resource)
  254. {
  255. ACPI_FUNCTION_TRACE("rs_get_address16");
  256. /* Get the Resource Type, general flags, and type-specific flags */
  257. if (!acpi_rs_get_address_common(resource, aml)) {
  258. return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
  259. }
  260. /*
  261. * Get the following contiguous fields from the AML descriptor:
  262. * Address Granularity
  263. * Address Range Minimum
  264. * Address Range Maximum
  265. * Address Translation Offset
  266. * Address Length
  267. */
  268. acpi_rs_move_data(&resource->data.address16.granularity,
  269. &aml->address16.granularity, 5,
  270. ACPI_MOVE_TYPE_16_TO_32);
  271. /* Get the optional resource_source (index and string) */
  272. resource->length =
  273. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) +
  274. acpi_rs_get_resource_source(aml_resource_length,
  275. sizeof(struct aml_resource_address16),
  276. &resource->data.address16.
  277. resource_source, aml, NULL);
  278. /* Complete the resource header */
  279. resource->type = ACPI_RESOURCE_TYPE_ADDRESS16;
  280. return_ACPI_STATUS(AE_OK);
  281. }
  282. /*******************************************************************************
  283. *
  284. * FUNCTION: acpi_rs_set_address16
  285. *
  286. * PARAMETERS: Resource - Pointer to the resource descriptor
  287. * Aml - Where the AML descriptor is returned
  288. *
  289. * RETURN: Status
  290. *
  291. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  292. * external AML resource descriptor.
  293. *
  294. ******************************************************************************/
  295. acpi_status
  296. acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml)
  297. {
  298. acpi_size descriptor_length;
  299. ACPI_FUNCTION_TRACE("rs_set_address16");
  300. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  301. acpi_rs_set_address_common(aml, resource);
  302. /*
  303. * Set the following contiguous fields in the AML descriptor:
  304. * Address Granularity
  305. * Address Range Minimum
  306. * Address Range Maximum
  307. * Address Translation Offset
  308. * Address Length
  309. */
  310. acpi_rs_move_data(&aml->address16.granularity,
  311. &resource->data.address16.granularity, 5,
  312. ACPI_MOVE_TYPE_32_TO_16);
  313. /* Resource Source Index and Resource Source are optional */
  314. descriptor_length = acpi_rs_set_resource_source(aml,
  315. sizeof(struct
  316. aml_resource_address16),
  317. &resource->data.
  318. address16.
  319. resource_source);
  320. /* Complete the AML descriptor header */
  321. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16,
  322. descriptor_length, aml);
  323. return_ACPI_STATUS(AE_OK);
  324. }
  325. /*******************************************************************************
  326. *
  327. * FUNCTION: acpi_rs_get_address32
  328. *
  329. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  330. * aml_resource_length - Length of the resource from the AML header
  331. * Resource - Where the internal resource is returned
  332. *
  333. * RETURN: Status
  334. *
  335. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  336. * internal resource descriptor, simplifying bitflags and handling
  337. * alignment and endian issues if necessary.
  338. *
  339. ******************************************************************************/
  340. acpi_status
  341. acpi_rs_get_address32(union aml_resource *aml,
  342. u16 aml_resource_length, struct acpi_resource *resource)
  343. {
  344. ACPI_FUNCTION_TRACE("rs_get_address32");
  345. /* Get the Resource Type, general flags, and type-specific flags */
  346. if (!acpi_rs_get_address_common(resource, (void *)aml)) {
  347. return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
  348. }
  349. /*
  350. * Get the following contiguous fields from the AML descriptor:
  351. * Address Granularity
  352. * Address Range Minimum
  353. * Address Range Maximum
  354. * Address Translation Offset
  355. * Address Length
  356. */
  357. acpi_rs_move_data(&resource->data.address32.granularity,
  358. &aml->address32.granularity, 5,
  359. ACPI_MOVE_TYPE_32_TO_32);
  360. /* Get the optional resource_source (index and string) */
  361. resource->length =
  362. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) +
  363. acpi_rs_get_resource_source(aml_resource_length,
  364. sizeof(struct aml_resource_address32),
  365. &resource->data.address32.
  366. resource_source, aml, NULL);
  367. /* Complete the resource header */
  368. resource->type = ACPI_RESOURCE_TYPE_ADDRESS32;
  369. return_ACPI_STATUS(AE_OK);
  370. }
  371. /*******************************************************************************
  372. *
  373. * FUNCTION: acpi_rs_set_address32
  374. *
  375. * PARAMETERS: Resource - Pointer to the resource descriptor
  376. * Aml - Where the AML descriptor is returned
  377. *
  378. * RETURN: Status
  379. *
  380. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  381. * external AML resource descriptor.
  382. *
  383. ******************************************************************************/
  384. acpi_status
  385. acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml)
  386. {
  387. acpi_size descriptor_length;
  388. ACPI_FUNCTION_TRACE("rs_set_address32");
  389. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  390. acpi_rs_set_address_common(aml, resource);
  391. /*
  392. * Set the following contiguous fields in the AML descriptor:
  393. * Address Granularity
  394. * Address Range Minimum
  395. * Address Range Maximum
  396. * Address Translation Offset
  397. * Address Length
  398. */
  399. acpi_rs_move_data(&aml->address32.granularity,
  400. &resource->data.address32.granularity, 5,
  401. ACPI_MOVE_TYPE_32_TO_32);
  402. /* Resource Source Index and Resource Source are optional */
  403. descriptor_length = acpi_rs_set_resource_source(aml,
  404. sizeof(struct
  405. aml_resource_address32),
  406. &resource->data.
  407. address32.
  408. resource_source);
  409. /* Complete the AML descriptor header */
  410. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32,
  411. descriptor_length, aml);
  412. return_ACPI_STATUS(AE_OK);
  413. }
  414. /*******************************************************************************
  415. *
  416. * FUNCTION: acpi_rs_get_address64
  417. *
  418. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  419. * aml_resource_length - Length of the resource from the AML header
  420. * Resource - Where the internal resource is returned
  421. *
  422. * RETURN: Status
  423. *
  424. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  425. * internal resource descriptor, simplifying bitflags and handling
  426. * alignment and endian issues if necessary.
  427. *
  428. ******************************************************************************/
  429. acpi_status
  430. acpi_rs_get_address64(union aml_resource *aml,
  431. u16 aml_resource_length, struct acpi_resource *resource)
  432. {
  433. ACPI_FUNCTION_TRACE("rs_get_address64");
  434. /* Get the Resource Type, general Flags, and type-specific Flags */
  435. if (!acpi_rs_get_address_common(resource, aml)) {
  436. return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
  437. }
  438. /*
  439. * Get the following contiguous fields from the AML descriptor:
  440. * Address Granularity
  441. * Address Range Minimum
  442. * Address Range Maximum
  443. * Address Translation Offset
  444. * Address Length
  445. */
  446. acpi_rs_move_data(&resource->data.address64.granularity,
  447. &aml->address64.granularity, 5,
  448. ACPI_MOVE_TYPE_64_TO_64);
  449. /* Get the optional resource_source (index and string) */
  450. resource->length =
  451. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) +
  452. acpi_rs_get_resource_source(aml_resource_length,
  453. sizeof(struct aml_resource_address64),
  454. &resource->data.address64.
  455. resource_source, aml, NULL);
  456. /* Complete the resource header */
  457. resource->type = ACPI_RESOURCE_TYPE_ADDRESS64;
  458. return_ACPI_STATUS(AE_OK);
  459. }
  460. /*******************************************************************************
  461. *
  462. * FUNCTION: acpi_rs_set_address64
  463. *
  464. * PARAMETERS: Resource - Pointer to the resource descriptor
  465. * Aml - Where the AML descriptor is returned
  466. *
  467. * RETURN: Status
  468. *
  469. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  470. * external AML resource descriptor.
  471. *
  472. ******************************************************************************/
  473. acpi_status
  474. acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml)
  475. {
  476. acpi_size descriptor_length;
  477. ACPI_FUNCTION_TRACE("rs_set_address64");
  478. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  479. acpi_rs_set_address_common(aml, resource);
  480. /*
  481. * Set the following contiguous fields in the AML descriptor:
  482. * Address Granularity
  483. * Address Range Minimum
  484. * Address Range Maximum
  485. * Address Translation Offset
  486. * Address Length
  487. */
  488. acpi_rs_move_data(&aml->address64.granularity,
  489. &resource->data.address64.granularity, 5,
  490. ACPI_MOVE_TYPE_64_TO_64);
  491. /* Resource Source Index and Resource Source are optional */
  492. descriptor_length = acpi_rs_set_resource_source(aml,
  493. sizeof(struct
  494. aml_resource_address64),
  495. &resource->data.
  496. address64.
  497. resource_source);
  498. /* Complete the AML descriptor header */
  499. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64,
  500. descriptor_length, aml);
  501. return_ACPI_STATUS(AE_OK);
  502. }
  503. /*******************************************************************************
  504. *
  505. * FUNCTION: acpi_rs_get_ext_address64
  506. *
  507. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  508. * aml_resource_length - Length of the resource from the AML header
  509. * Resource - Where the internal resource is returned
  510. *
  511. * RETURN: Status
  512. *
  513. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  514. * internal resource descriptor, simplifying bitflags and handling
  515. * alignment and endian issues if necessary.
  516. *
  517. ******************************************************************************/
  518. acpi_status
  519. acpi_rs_get_ext_address64(union aml_resource *aml,
  520. u16 aml_resource_length,
  521. struct acpi_resource *resource)
  522. {
  523. ACPI_FUNCTION_TRACE("rs_get_ext_address64");
  524. /* Get the Resource Type, general flags, and type-specific flags */
  525. if (!acpi_rs_get_address_common(resource, aml)) {
  526. return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
  527. }
  528. /*
  529. * Get and validate the Revision ID
  530. * Note: Only one revision ID is currently supported
  531. */
  532. resource->data.ext_address64.revision_iD =
  533. aml->ext_address64.revision_iD;
  534. if (aml->ext_address64.revision_iD !=
  535. AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
  536. return_ACPI_STATUS(AE_SUPPORT);
  537. }
  538. /*
  539. * Get the following contiguous fields from the AML descriptor:
  540. * Address Granularity
  541. * Address Range Minimum
  542. * Address Range Maximum
  543. * Address Translation Offset
  544. * Address Length
  545. * Type-Specific Attribute
  546. */
  547. acpi_rs_move_data(&resource->data.ext_address64.granularity,
  548. &aml->ext_address64.granularity, 6,
  549. ACPI_MOVE_TYPE_64_TO_64);
  550. /* Complete the resource header */
  551. resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64;
  552. resource->length =
  553. ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64);
  554. return_ACPI_STATUS(AE_OK);
  555. }
  556. /*******************************************************************************
  557. *
  558. * FUNCTION: acpi_rs_set_ext_address64
  559. *
  560. * PARAMETERS: Resource - Pointer to the resource descriptor
  561. * Aml - Where the AML descriptor is returned
  562. *
  563. * RETURN: Status
  564. *
  565. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  566. * external AML resource descriptor.
  567. *
  568. ******************************************************************************/
  569. acpi_status
  570. acpi_rs_set_ext_address64(struct acpi_resource *resource,
  571. union aml_resource *aml)
  572. {
  573. ACPI_FUNCTION_TRACE("rs_set_ext_address64");
  574. /* Set the Resource Type, General Flags, and Type-Specific Flags */
  575. acpi_rs_set_address_common(aml, resource);
  576. /* Only one Revision ID is currently supported */
  577. aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
  578. aml->ext_address64.reserved = 0;
  579. /*
  580. * Set the following contiguous fields in the AML descriptor:
  581. * Address Granularity
  582. * Address Range Minimum
  583. * Address Range Maximum
  584. * Address Translation Offset
  585. * Address Length
  586. * Type-Specific Attribute
  587. */
  588. acpi_rs_move_data(&aml->ext_address64.granularity,
  589. &resource->data.address64.granularity, 6,
  590. ACPI_MOVE_TYPE_64_TO_64);
  591. /* Complete the AML descriptor header */
  592. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
  593. sizeof(struct
  594. aml_resource_extended_address64),
  595. aml);
  596. return_ACPI_STATUS(AE_OK);
  597. }