rsmemory.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsmem24 - Memory resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, 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. * acpi_rs_convert_memory24
  49. *
  50. ******************************************************************************/
  51. struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = {
  52. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
  53. ACPI_RS_SIZE(struct acpi_resource_memory24),
  54. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)},
  55. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
  56. sizeof(struct aml_resource_memory24),
  57. 0},
  58. /* Read/Write bit */
  59. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect),
  60. AML_OFFSET(memory24.flags),
  61. 0},
  62. /*
  63. * These fields are contiguous in both the source and destination:
  64. * Minimum Base Address
  65. * Maximum Base Address
  66. * Address Base Alignment
  67. * Range Length
  68. */
  69. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum),
  70. AML_OFFSET(memory24.minimum),
  71. 4}
  72. };
  73. /*******************************************************************************
  74. *
  75. * acpi_rs_convert_memory32
  76. *
  77. ******************************************************************************/
  78. struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = {
  79. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
  80. ACPI_RS_SIZE(struct acpi_resource_memory32),
  81. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)},
  82. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
  83. sizeof(struct aml_resource_memory32),
  84. 0},
  85. /* Read/Write bit */
  86. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect),
  87. AML_OFFSET(memory32.flags),
  88. 0},
  89. /*
  90. * These fields are contiguous in both the source and destination:
  91. * Minimum Base Address
  92. * Maximum Base Address
  93. * Address Base Alignment
  94. * Range Length
  95. */
  96. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum),
  97. AML_OFFSET(memory32.minimum),
  98. 4}
  99. };
  100. /*******************************************************************************
  101. *
  102. * acpi_rs_convert_fixed_memory32
  103. *
  104. ******************************************************************************/
  105. struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = {
  106. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
  107. ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
  108. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)},
  109. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
  110. sizeof(struct aml_resource_fixed_memory32),
  111. 0},
  112. /* Read/Write bit */
  113. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect),
  114. AML_OFFSET(fixed_memory32.flags),
  115. 0},
  116. /*
  117. * These fields are contiguous in both the source and destination:
  118. * Base Address
  119. * Range Length
  120. */
  121. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address),
  122. AML_OFFSET(fixed_memory32.address),
  123. 2}
  124. };
  125. /*******************************************************************************
  126. *
  127. * acpi_rs_get_vendor_small
  128. *
  129. ******************************************************************************/
  130. struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
  131. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
  132. ACPI_RS_SIZE(struct acpi_resource_vendor),
  133. ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)},
  134. /* Length of the vendor data (byte count) */
  135. {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
  136. 0,
  137. sizeof(u8)}
  138. ,
  139. /* Vendor data */
  140. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
  141. sizeof(struct aml_resource_small_header),
  142. 0}
  143. };
  144. /*******************************************************************************
  145. *
  146. * acpi_rs_get_vendor_large
  147. *
  148. ******************************************************************************/
  149. struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
  150. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
  151. ACPI_RS_SIZE(struct acpi_resource_vendor),
  152. ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)},
  153. /* Length of the vendor data (byte count) */
  154. {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
  155. 0,
  156. sizeof(u8)}
  157. ,
  158. /* Vendor data */
  159. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
  160. sizeof(struct aml_resource_large_header),
  161. 0}
  162. };
  163. /*******************************************************************************
  164. *
  165. * acpi_rs_set_vendor
  166. *
  167. ******************************************************************************/
  168. struct acpi_rsconvert_info acpi_rs_set_vendor[7] = {
  169. /* Default is a small vendor descriptor */
  170. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
  171. sizeof(struct aml_resource_small_header),
  172. ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)},
  173. /* Get the length and copy the data */
  174. {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
  175. 0,
  176. 0},
  177. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
  178. sizeof(struct aml_resource_small_header),
  179. 0},
  180. /*
  181. * All done if the Vendor byte length is 7 or less, meaning that it will
  182. * fit within a small descriptor
  183. */
  184. {ACPI_RSC_EXIT_LE, 0, 0, 7},
  185. /* Must create a large vendor descriptor */
  186. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
  187. sizeof(struct aml_resource_large_header),
  188. 0},
  189. {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
  190. 0,
  191. 0},
  192. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
  193. sizeof(struct aml_resource_large_header),
  194. 0}
  195. };