rsmemory.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsmem24 - Memory resource descriptors
  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("rsmemory")
  46. /*******************************************************************************
  47. *
  48. * FUNCTION: acpi_rs_get_memory24
  49. *
  50. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  51. * aml_resource_length - Length of the resource from the AML header
  52. * Resource - Where the internal resource is returned
  53. *
  54. * RETURN: Status
  55. *
  56. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  57. * internal resource descriptor, simplifying bitflags and handling
  58. * alignment and endian issues if necessary.
  59. *
  60. ******************************************************************************/
  61. acpi_status
  62. acpi_rs_get_memory24(union aml_resource * aml,
  63. u16 aml_resource_length, struct acpi_resource * resource)
  64. {
  65. ACPI_FUNCTION_TRACE("rs_get_memory24");
  66. /* Get the Read/Write bit */
  67. resource->data.memory24.read_write_attribute =
  68. (aml->memory24.information & 0x01);
  69. /*
  70. * Get the following contiguous fields from the AML descriptor:
  71. * Minimum Base Address
  72. * Maximum Base Address
  73. * Address Base Alignment
  74. * Range Length
  75. */
  76. acpi_rs_move_data(&resource->data.memory24.minimum,
  77. &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32);
  78. /* Complete the resource header */
  79. resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
  80. resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24);
  81. return_ACPI_STATUS(AE_OK);
  82. }
  83. /*******************************************************************************
  84. *
  85. * FUNCTION: acpi_rs_set_memory24
  86. *
  87. * PARAMETERS: Resource - Pointer to the resource descriptor
  88. * Aml - Where the AML descriptor is returned
  89. *
  90. * RETURN: Status
  91. *
  92. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  93. * external AML resource descriptor.
  94. *
  95. ******************************************************************************/
  96. acpi_status
  97. acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml)
  98. {
  99. ACPI_FUNCTION_TRACE("rs_set_memory24");
  100. /* Set the Information Byte */
  101. aml->memory24.information = (u8)
  102. (resource->data.memory24.read_write_attribute & 0x01);
  103. /*
  104. * Set the following contiguous fields in the AML descriptor:
  105. * Minimum Base Address
  106. * Maximum Base Address
  107. * Address Base Alignment
  108. * Range Length
  109. */
  110. acpi_rs_move_data(&aml->memory24.minimum,
  111. &resource->data.memory24.minimum, 4,
  112. ACPI_MOVE_TYPE_32_TO_16);
  113. /* Complete the AML descriptor header */
  114. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24,
  115. sizeof(struct aml_resource_memory24), aml);
  116. return_ACPI_STATUS(AE_OK);
  117. }
  118. /*******************************************************************************
  119. *
  120. * FUNCTION: acpi_rs_get_memory32
  121. *
  122. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  123. * aml_resource_length - Length of the resource from the AML header
  124. * Resource - Where the internal resource is returned
  125. *
  126. * RETURN: Status
  127. *
  128. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  129. * internal resource descriptor, simplifying bitflags and handling
  130. * alignment and endian issues if necessary.
  131. *
  132. ******************************************************************************/
  133. acpi_status
  134. acpi_rs_get_memory32(union aml_resource *aml,
  135. u16 aml_resource_length, struct acpi_resource *resource)
  136. {
  137. ACPI_FUNCTION_TRACE("rs_get_memory32");
  138. /* Get the Read/Write bit */
  139. resource->data.memory32.read_write_attribute =
  140. (aml->memory32.information & 0x01);
  141. /*
  142. * Get the following contiguous fields from the AML descriptor:
  143. * Minimum Base Address
  144. * Maximum Base Address
  145. * Address Base Alignment
  146. * Range Length
  147. */
  148. acpi_rs_move_data(&resource->data.memory32.minimum,
  149. &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32);
  150. /* Complete the resource header */
  151. resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
  152. resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32);
  153. return_ACPI_STATUS(AE_OK);
  154. }
  155. /*******************************************************************************
  156. *
  157. * FUNCTION: acpi_rs_set_memory32
  158. *
  159. * PARAMETERS: Resource - Pointer to the resource descriptor
  160. * Aml - Where the AML descriptor is returned
  161. *
  162. * RETURN: Status
  163. *
  164. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  165. * external AML resource descriptor.
  166. *
  167. ******************************************************************************/
  168. acpi_status
  169. acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml)
  170. {
  171. ACPI_FUNCTION_TRACE("rs_set_memory32");
  172. /* Set the Information Byte */
  173. aml->memory32.information = (u8)
  174. (resource->data.memory32.read_write_attribute & 0x01);
  175. /*
  176. * Set the following contiguous fields in the AML descriptor:
  177. * Minimum Base Address
  178. * Maximum Base Address
  179. * Address Base Alignment
  180. * Range Length
  181. */
  182. acpi_rs_move_data(&aml->memory32.minimum,
  183. &resource->data.memory32.minimum, 4,
  184. ACPI_MOVE_TYPE_32_TO_32);
  185. /* Complete the AML descriptor header */
  186. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32,
  187. sizeof(struct aml_resource_memory32), aml);
  188. return_ACPI_STATUS(AE_OK);
  189. }
  190. /*******************************************************************************
  191. *
  192. * FUNCTION: acpi_rs_get_fixed_memory32
  193. *
  194. * PARAMETERS: Aml - Pointer to the AML resource descriptor
  195. * aml_resource_length - Length of the resource from the AML header
  196. * Resource - Where the internal resource is returned
  197. *
  198. * RETURN: Status
  199. *
  200. * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
  201. * internal resource descriptor, simplifying bitflags and handling
  202. * alignment and endian issues if necessary.
  203. *
  204. ******************************************************************************/
  205. acpi_status
  206. acpi_rs_get_fixed_memory32(union aml_resource *aml,
  207. u16 aml_resource_length,
  208. struct acpi_resource *resource)
  209. {
  210. ACPI_FUNCTION_TRACE("rs_get_fixed_memory32");
  211. /* Get the Read/Write bit */
  212. resource->data.fixed_memory32.read_write_attribute =
  213. (aml->fixed_memory32.information & 0x01);
  214. /*
  215. * Get the following contiguous fields from the AML descriptor:
  216. * Base Address
  217. * Range Length
  218. */
  219. ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address,
  220. &aml->fixed_memory32.address);
  221. ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length,
  222. &aml->fixed_memory32.address_length);
  223. /* Complete the resource header */
  224. resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
  225. resource->length =
  226. ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32);
  227. return_ACPI_STATUS(AE_OK);
  228. }
  229. /*******************************************************************************
  230. *
  231. * FUNCTION: acpi_rs_set_fixed_memory32
  232. *
  233. * PARAMETERS: Resource - Pointer to the resource descriptor
  234. * Aml - Where the AML descriptor is returned
  235. *
  236. * RETURN: Status
  237. *
  238. * DESCRIPTION: Convert an internal resource descriptor to the corresponding
  239. * external AML resource descriptor.
  240. *
  241. ******************************************************************************/
  242. acpi_status
  243. acpi_rs_set_fixed_memory32(struct acpi_resource *resource,
  244. union aml_resource *aml)
  245. {
  246. ACPI_FUNCTION_TRACE("rs_set_fixed_memory32");
  247. /* Set the Information Byte */
  248. aml->fixed_memory32.information = (u8)
  249. (resource->data.fixed_memory32.read_write_attribute & 0x01);
  250. /*
  251. * Set the following contiguous fields in the AML descriptor:
  252. * Base Address
  253. * Range Length
  254. */
  255. ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address,
  256. &resource->data.fixed_memory32.address);
  257. ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length,
  258. &resource->data.fixed_memory32.address_length);
  259. /* Complete the AML descriptor header */
  260. acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32,
  261. sizeof(struct aml_resource_fixed_memory32),
  262. aml);
  263. return_ACPI_STATUS(AE_OK);
  264. }