diff options
Diffstat (limited to 'drivers/acpi/resources/rsmemory.c')
-rw-r--r-- | drivers/acpi/resources/rsmemory.c | 303 |
1 files changed, 115 insertions, 188 deletions
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 47e979e7ba35..418a3fb64077 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c | |||
@@ -49,260 +49,187 @@ ACPI_MODULE_NAME("rsmemory") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_get_memory24 | 52 | * acpi_rs_convert_memory24 |
53 | * | ||
54 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
55 | * aml_resource_length - Length of the resource from the AML header | ||
56 | * Resource - Where the internal resource is returned | ||
57 | * | ||
58 | * RETURN: Status | ||
59 | * | ||
60 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding | ||
61 | * internal resource descriptor, simplifying bitflags and handling | ||
62 | * alignment and endian issues if necessary. | ||
63 | * | 53 | * |
64 | ******************************************************************************/ | 54 | ******************************************************************************/ |
65 | acpi_status | 55 | struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = { |
66 | acpi_rs_get_memory24(union aml_resource * aml, | 56 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, |
67 | u16 aml_resource_length, struct acpi_resource * resource) | 57 | ACPI_RS_SIZE(struct acpi_resource_memory24), |
68 | { | 58 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)}, |
69 | ACPI_FUNCTION_TRACE("rs_get_memory24"); | ||
70 | 59 | ||
71 | /* Get the Read/Write bit */ | 60 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, |
61 | sizeof(struct aml_resource_memory24), | ||
62 | 0}, | ||
72 | 63 | ||
73 | resource->data.memory24.read_write_attribute = | 64 | /* Read/Write bit */ |
74 | (aml->memory24.information & 0x01); | ||
75 | 65 | ||
66 | {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect), | ||
67 | AML_OFFSET(memory24.flags), | ||
68 | 0}, | ||
76 | /* | 69 | /* |
77 | * Get the following contiguous fields from the AML descriptor: | 70 | * These fields are contiguous in both the source and destination: |
78 | * Minimum Base Address | 71 | * Minimum Base Address |
79 | * Maximum Base Address | 72 | * Maximum Base Address |
80 | * Address Base Alignment | 73 | * Address Base Alignment |
81 | * Range Length | 74 | * Range Length |
82 | */ | 75 | */ |
83 | acpi_rs_move_data(&resource->data.memory24.minimum, | 76 | {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum), |
84 | &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); | 77 | AML_OFFSET(memory24.minimum), |
85 | 78 | 4} | |
86 | /* Complete the resource header */ | 79 | }; |
87 | |||
88 | resource->type = ACPI_RESOURCE_TYPE_MEMORY24; | ||
89 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24); | ||
90 | return_ACPI_STATUS(AE_OK); | ||
91 | } | ||
92 | 80 | ||
93 | /******************************************************************************* | 81 | /******************************************************************************* |
94 | * | 82 | * |
95 | * FUNCTION: acpi_rs_set_memory24 | 83 | * acpi_rs_convert_memory32 |
96 | * | ||
97 | * PARAMETERS: Resource - Pointer to the resource descriptor | ||
98 | * Aml - Where the AML descriptor is returned | ||
99 | * | ||
100 | * RETURN: Status | ||
101 | * | ||
102 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding | ||
103 | * external AML resource descriptor. | ||
104 | * | 84 | * |
105 | ******************************************************************************/ | 85 | ******************************************************************************/ |
106 | 86 | ||
107 | acpi_status | 87 | struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = { |
108 | acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) | 88 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, |
109 | { | 89 | ACPI_RS_SIZE(struct acpi_resource_memory32), |
110 | ACPI_FUNCTION_TRACE("rs_set_memory24"); | 90 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)}, |
111 | 91 | ||
112 | /* Set the Information Byte */ | 92 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, |
93 | sizeof(struct aml_resource_memory32), | ||
94 | 0}, | ||
113 | 95 | ||
114 | aml->memory24.information = (u8) | 96 | /* Read/Write bit */ |
115 | (resource->data.memory24.read_write_attribute & 0x01); | ||
116 | 97 | ||
98 | {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect), | ||
99 | AML_OFFSET(memory32.flags), | ||
100 | 0}, | ||
117 | /* | 101 | /* |
118 | * Set the following contiguous fields in the AML descriptor: | 102 | * These fields are contiguous in both the source and destination: |
119 | * Minimum Base Address | 103 | * Minimum Base Address |
120 | * Maximum Base Address | 104 | * Maximum Base Address |
121 | * Address Base Alignment | 105 | * Address Base Alignment |
122 | * Range Length | 106 | * Range Length |
123 | */ | 107 | */ |
124 | acpi_rs_move_data(&aml->memory24.minimum, | 108 | {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum), |
125 | &resource->data.memory24.minimum, 4, | 109 | AML_OFFSET(memory32.minimum), |
126 | ACPI_MOVE_TYPE_32_TO_16); | 110 | 4} |
127 | 111 | }; | |
128 | /* Complete the AML descriptor header */ | ||
129 | |||
130 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24, | ||
131 | sizeof(struct aml_resource_memory24), aml); | ||
132 | return_ACPI_STATUS(AE_OK); | ||
133 | } | ||
134 | 112 | ||
135 | /******************************************************************************* | 113 | /******************************************************************************* |
136 | * | 114 | * |
137 | * FUNCTION: acpi_rs_get_memory32 | 115 | * acpi_rs_convert_fixed_memory32 |
138 | * | ||
139 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
140 | * aml_resource_length - Length of the resource from the AML header | ||
141 | * Resource - Where the internal resource is returned | ||
142 | * | ||
143 | * RETURN: Status | ||
144 | * | ||
145 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding | ||
146 | * internal resource descriptor, simplifying bitflags and handling | ||
147 | * alignment and endian issues if necessary. | ||
148 | * | 116 | * |
149 | ******************************************************************************/ | 117 | ******************************************************************************/ |
150 | 118 | ||
151 | acpi_status | 119 | struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = { |
152 | acpi_rs_get_memory32(union aml_resource *aml, | 120 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, |
153 | u16 aml_resource_length, struct acpi_resource *resource) | 121 | ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), |
154 | { | 122 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)}, |
155 | ACPI_FUNCTION_TRACE("rs_get_memory32"); | ||
156 | 123 | ||
157 | /* Get the Read/Write bit */ | 124 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, |
125 | sizeof(struct aml_resource_fixed_memory32), | ||
126 | 0}, | ||
158 | 127 | ||
159 | resource->data.memory32.read_write_attribute = | 128 | /* Read/Write bit */ |
160 | (aml->memory32.information & 0x01); | ||
161 | 129 | ||
130 | {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect), | ||
131 | AML_OFFSET(fixed_memory32.flags), | ||
132 | 0}, | ||
162 | /* | 133 | /* |
163 | * Get the following contiguous fields from the AML descriptor: | 134 | * These fields are contiguous in both the source and destination: |
164 | * Minimum Base Address | 135 | * Base Address |
165 | * Maximum Base Address | ||
166 | * Address Base Alignment | ||
167 | * Range Length | 136 | * Range Length |
168 | */ | 137 | */ |
169 | acpi_rs_move_data(&resource->data.memory32.minimum, | 138 | {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address), |
170 | &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); | 139 | AML_OFFSET(fixed_memory32.address), |
171 | 140 | 2} | |
172 | /* Complete the resource header */ | 141 | }; |
173 | |||
174 | resource->type = ACPI_RESOURCE_TYPE_MEMORY32; | ||
175 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32); | ||
176 | return_ACPI_STATUS(AE_OK); | ||
177 | } | ||
178 | 142 | ||
179 | /******************************************************************************* | 143 | /******************************************************************************* |
180 | * | 144 | * |
181 | * FUNCTION: acpi_rs_set_memory32 | 145 | * acpi_rs_get_vendor_small |
182 | * | ||
183 | * PARAMETERS: Resource - Pointer to the resource descriptor | ||
184 | * Aml - Where the AML descriptor is returned | ||
185 | * | ||
186 | * RETURN: Status | ||
187 | * | ||
188 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding | ||
189 | * external AML resource descriptor. | ||
190 | * | 146 | * |
191 | ******************************************************************************/ | 147 | ******************************************************************************/ |
192 | 148 | ||
193 | acpi_status | 149 | struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = { |
194 | acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) | 150 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, |
195 | { | 151 | ACPI_RS_SIZE(struct acpi_resource_vendor), |
196 | ACPI_FUNCTION_TRACE("rs_set_memory32"); | 152 | ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)}, |
197 | |||
198 | /* Set the Information Byte */ | ||
199 | 153 | ||
200 | aml->memory32.information = (u8) | 154 | /* Length of the vendor data (byte count) */ |
201 | (resource->data.memory32.read_write_attribute & 0x01); | ||
202 | 155 | ||
203 | /* | 156 | {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), |
204 | * Set the following contiguous fields in the AML descriptor: | 157 | 0, |
205 | * Minimum Base Address | 158 | sizeof(u8)} |
206 | * Maximum Base Address | 159 | , |
207 | * Address Base Alignment | ||
208 | * Range Length | ||
209 | */ | ||
210 | acpi_rs_move_data(&aml->memory32.minimum, | ||
211 | &resource->data.memory32.minimum, 4, | ||
212 | ACPI_MOVE_TYPE_32_TO_32); | ||
213 | 160 | ||
214 | /* Complete the AML descriptor header */ | 161 | /* Vendor data */ |
215 | 162 | ||
216 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, | 163 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), |
217 | sizeof(struct aml_resource_memory32), aml); | 164 | sizeof(struct aml_resource_small_header), |
218 | return_ACPI_STATUS(AE_OK); | 165 | 0} |
219 | } | 166 | }; |
220 | 167 | ||
221 | /******************************************************************************* | 168 | /******************************************************************************* |
222 | * | 169 | * |
223 | * FUNCTION: acpi_rs_get_fixed_memory32 | 170 | * acpi_rs_get_vendor_large |
224 | * | ||
225 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
226 | * aml_resource_length - Length of the resource from the AML header | ||
227 | * Resource - Where the internal resource is returned | ||
228 | * | ||
229 | * RETURN: Status | ||
230 | * | ||
231 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding | ||
232 | * internal resource descriptor, simplifying bitflags and handling | ||
233 | * alignment and endian issues if necessary. | ||
234 | * | 171 | * |
235 | ******************************************************************************/ | 172 | ******************************************************************************/ |
236 | 173 | ||
237 | acpi_status | 174 | struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = { |
238 | acpi_rs_get_fixed_memory32(union aml_resource *aml, | 175 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, |
239 | u16 aml_resource_length, | 176 | ACPI_RS_SIZE(struct acpi_resource_vendor), |
240 | struct acpi_resource *resource) | 177 | ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)}, |
241 | { | ||
242 | ACPI_FUNCTION_TRACE("rs_get_fixed_memory32"); | ||
243 | |||
244 | /* Get the Read/Write bit */ | ||
245 | 178 | ||
246 | resource->data.fixed_memory32.read_write_attribute = | 179 | /* Length of the vendor data (byte count) */ |
247 | (aml->fixed_memory32.information & 0x01); | ||
248 | 180 | ||
249 | /* | 181 | {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), |
250 | * Get the following contiguous fields from the AML descriptor: | 182 | 0, |
251 | * Base Address | 183 | sizeof(u8)} |
252 | * Range Length | 184 | , |
253 | */ | ||
254 | ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address, | ||
255 | &aml->fixed_memory32.address); | ||
256 | ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length, | ||
257 | &aml->fixed_memory32.address_length); | ||
258 | 185 | ||
259 | /* Complete the resource header */ | 186 | /* Vendor data */ |
260 | 187 | ||
261 | resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; | 188 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), |
262 | resource->length = | 189 | sizeof(struct aml_resource_large_header), |
263 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); | 190 | 0} |
264 | return_ACPI_STATUS(AE_OK); | 191 | }; |
265 | } | ||
266 | 192 | ||
267 | /******************************************************************************* | 193 | /******************************************************************************* |
268 | * | 194 | * |
269 | * FUNCTION: acpi_rs_set_fixed_memory32 | 195 | * acpi_rs_set_vendor |
270 | * | ||
271 | * PARAMETERS: Resource - Pointer to the resource descriptor | ||
272 | * Aml - Where the AML descriptor is returned | ||
273 | * | ||
274 | * RETURN: Status | ||
275 | * | ||
276 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding | ||
277 | * external AML resource descriptor. | ||
278 | * | 196 | * |
279 | ******************************************************************************/ | 197 | ******************************************************************************/ |
280 | 198 | ||
281 | acpi_status | 199 | struct acpi_rsconvert_info acpi_rs_set_vendor[7] = { |
282 | acpi_rs_set_fixed_memory32(struct acpi_resource *resource, | 200 | /* Default is a small vendor descriptor */ |
283 | union aml_resource *aml) | 201 | |
284 | { | 202 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, |
285 | ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); | 203 | sizeof(struct aml_resource_small_header), |
204 | ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)}, | ||
205 | |||
206 | /* Get the length and copy the data */ | ||
286 | 207 | ||
287 | /* Set the Information Byte */ | 208 | {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), |
209 | 0, | ||
210 | 0}, | ||
288 | 211 | ||
289 | aml->fixed_memory32.information = (u8) | 212 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), |
290 | (resource->data.fixed_memory32.read_write_attribute & 0x01); | 213 | sizeof(struct aml_resource_small_header), |
214 | 0}, | ||
291 | 215 | ||
292 | /* | 216 | /* |
293 | * Set the following contiguous fields in the AML descriptor: | 217 | * All done if the Vendor byte length is 7 or less, meaning that it will |
294 | * Base Address | 218 | * fit within a small descriptor |
295 | * Range Length | ||
296 | */ | 219 | */ |
297 | ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, | 220 | {ACPI_RSC_EXIT_LE, 0, 0, 7}, |
298 | &resource->data.fixed_memory32.address); | 221 | |
299 | ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, | 222 | /* Must create a large vendor descriptor */ |
300 | &resource->data.fixed_memory32.address_length); | 223 | |
301 | 224 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, | |
302 | /* Complete the AML descriptor header */ | 225 | sizeof(struct aml_resource_large_header), |
303 | 226 | 0}, | |
304 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, | 227 | |
305 | sizeof(struct aml_resource_fixed_memory32), | 228 | {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), |
306 | aml); | 229 | 0, |
307 | return_ACPI_STATUS(AE_OK); | 230 | 0}, |
308 | } | 231 | |
232 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), | ||
233 | sizeof(struct aml_resource_large_header), | ||
234 | 0} | ||
235 | }; | ||