diff options
Diffstat (limited to 'drivers/acpi/resources/rsio.c')
-rw-r--r-- | drivers/acpi/resources/rsio.c | 451 |
1 files changed, 147 insertions, 304 deletions
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 6574e2ae2e52..0dab8cdfa800 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c | |||
@@ -49,426 +49,269 @@ ACPI_MODULE_NAME("rsio") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_io_resource | 52 | * FUNCTION: acpi_rs_get_io |
53 | * | 53 | * |
54 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 54 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
55 | * stream | 55 | * aml_resource_length - Length of the resource from the AML header |
56 | * bytes_consumed - Pointer to where the number of bytes | 56 | * Resource - Where the internal resource is returned |
57 | * consumed the byte_stream_buffer is | ||
58 | * returned | ||
59 | * output_buffer - Pointer to the return data buffer | ||
60 | * structure_size - Pointer to where the number of bytes | ||
61 | * in the return data struct is returned | ||
62 | * | 57 | * |
63 | * RETURN: Status | 58 | * RETURN: Status |
64 | * | 59 | * |
65 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 60 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
66 | * structure pointed to by the output_buffer. Return the | 61 | * internal resource descriptor, simplifying bitflags and handling |
67 | * number of bytes consumed from the byte stream. | 62 | * alignment and endian issues if necessary. |
68 | * | 63 | * |
69 | ******************************************************************************/ | 64 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_io_resource(u8 * byte_stream_buffer, | 66 | acpi_rs_get_io(union aml_resource *aml, |
72 | acpi_size * bytes_consumed, | 67 | u16 aml_resource_length, struct acpi_resource *resource) |
73 | u8 ** output_buffer, acpi_size * structure_size) | ||
74 | { | 68 | { |
75 | u8 *buffer = byte_stream_buffer; | 69 | ACPI_FUNCTION_TRACE("rs_get_io"); |
76 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
77 | u16 temp16 = 0; | ||
78 | u8 temp8 = 0; | ||
79 | acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); | ||
80 | 70 | ||
81 | ACPI_FUNCTION_TRACE("rs_io_resource"); | 71 | /* Get the Decode flag */ |
82 | 72 | ||
83 | /* The number of bytes consumed are Constant */ | 73 | resource->data.io.io_decode = aml->io.information & 0x01; |
84 | 74 | ||
85 | *bytes_consumed = 8; | 75 | /* |
76 | * Get the following contiguous fields from the AML descriptor: | ||
77 | * Minimum Base Address | ||
78 | * Maximum Base Address | ||
79 | * Address Alignment | ||
80 | * Length | ||
81 | */ | ||
82 | ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); | ||
83 | ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); | ||
84 | resource->data.io.alignment = aml->io.alignment; | ||
85 | resource->data.io.address_length = aml->io.address_length; | ||
86 | 86 | ||
87 | output_struct->type = ACPI_RSTYPE_IO; | 87 | /* Complete the resource header */ |
88 | 88 | ||
89 | /* Check Decode */ | 89 | resource->type = ACPI_RESOURCE_TYPE_IO; |
90 | 90 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); | |
91 | buffer += 1; | ||
92 | temp8 = *buffer; | ||
93 | |||
94 | output_struct->data.io.io_decode = temp8 & 0x01; | ||
95 | |||
96 | /* Check min_base Address */ | ||
97 | |||
98 | buffer += 1; | ||
99 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
100 | |||
101 | output_struct->data.io.min_base_address = temp16; | ||
102 | |||
103 | /* Check max_base Address */ | ||
104 | |||
105 | buffer += 2; | ||
106 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
107 | |||
108 | output_struct->data.io.max_base_address = temp16; | ||
109 | |||
110 | /* Check Base alignment */ | ||
111 | |||
112 | buffer += 2; | ||
113 | temp8 = *buffer; | ||
114 | |||
115 | output_struct->data.io.alignment = temp8; | ||
116 | |||
117 | /* Check range_length */ | ||
118 | |||
119 | buffer += 1; | ||
120 | temp8 = *buffer; | ||
121 | |||
122 | output_struct->data.io.range_length = temp8; | ||
123 | |||
124 | /* Set the Length parameter */ | ||
125 | |||
126 | output_struct->length = (u32) struct_size; | ||
127 | |||
128 | /* Return the final size of the structure */ | ||
129 | |||
130 | *structure_size = struct_size; | ||
131 | return_ACPI_STATUS(AE_OK); | 91 | return_ACPI_STATUS(AE_OK); |
132 | } | 92 | } |
133 | 93 | ||
134 | /******************************************************************************* | 94 | /******************************************************************************* |
135 | * | 95 | * |
136 | * FUNCTION: acpi_rs_fixed_io_resource | 96 | * FUNCTION: acpi_rs_set_io |
137 | * | 97 | * |
138 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 98 | * PARAMETERS: Resource - Pointer to the resource descriptor |
139 | * stream | 99 | * Aml - Where the AML descriptor is returned |
140 | * bytes_consumed - Pointer to where the number of bytes | ||
141 | * consumed the byte_stream_buffer is | ||
142 | * returned | ||
143 | * output_buffer - Pointer to the return data buffer | ||
144 | * structure_size - Pointer to where the number of bytes | ||
145 | * in the return data struct is returned | ||
146 | * | 100 | * |
147 | * RETURN: Status | 101 | * RETURN: Status |
148 | * | 102 | * |
149 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 103 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
150 | * structure pointed to by the output_buffer. Return the | 104 | * external AML resource descriptor. |
151 | * number of bytes consumed from the byte stream. | ||
152 | * | 105 | * |
153 | ******************************************************************************/ | 106 | ******************************************************************************/ |
154 | 107 | ||
155 | acpi_status | 108 | acpi_status |
156 | acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, | 109 | acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) |
157 | acpi_size * bytes_consumed, | ||
158 | u8 ** output_buffer, acpi_size * structure_size) | ||
159 | { | 110 | { |
160 | u8 *buffer = byte_stream_buffer; | 111 | ACPI_FUNCTION_TRACE("rs_set_io"); |
161 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
162 | u16 temp16 = 0; | ||
163 | u8 temp8 = 0; | ||
164 | acpi_size struct_size = | ||
165 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); | ||
166 | |||
167 | ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); | ||
168 | 112 | ||
169 | /* The number of bytes consumed are Constant */ | 113 | /* I/O Information Byte */ |
170 | 114 | ||
171 | *bytes_consumed = 4; | 115 | aml->io.information = (u8) (resource->data.io.io_decode & 0x01); |
172 | 116 | ||
173 | output_struct->type = ACPI_RSTYPE_FIXED_IO; | 117 | /* |
118 | * Set the following contiguous fields in the AML descriptor: | ||
119 | * Minimum Base Address | ||
120 | * Maximum Base Address | ||
121 | * Address Alignment | ||
122 | * Length | ||
123 | */ | ||
124 | ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); | ||
125 | ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); | ||
126 | aml->io.alignment = (u8) resource->data.io.alignment; | ||
127 | aml->io.address_length = (u8) resource->data.io.address_length; | ||
174 | 128 | ||
175 | /* Check Range Base Address */ | 129 | /* Complete the AML descriptor header */ |
176 | 130 | ||
177 | buffer += 1; | 131 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, |
178 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 132 | sizeof(struct aml_resource_io), aml); |
179 | |||
180 | output_struct->data.fixed_io.base_address = temp16; | ||
181 | |||
182 | /* Check range_length */ | ||
183 | |||
184 | buffer += 2; | ||
185 | temp8 = *buffer; | ||
186 | |||
187 | output_struct->data.fixed_io.range_length = temp8; | ||
188 | |||
189 | /* Set the Length parameter */ | ||
190 | |||
191 | output_struct->length = (u32) struct_size; | ||
192 | |||
193 | /* Return the final size of the structure */ | ||
194 | |||
195 | *structure_size = struct_size; | ||
196 | return_ACPI_STATUS(AE_OK); | 133 | return_ACPI_STATUS(AE_OK); |
197 | } | 134 | } |
198 | 135 | ||
199 | /******************************************************************************* | 136 | /******************************************************************************* |
200 | * | 137 | * |
201 | * FUNCTION: acpi_rs_io_stream | 138 | * FUNCTION: acpi_rs_get_fixed_io |
202 | * | 139 | * |
203 | * PARAMETERS: Resource - Pointer to the resource linked list | 140 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
204 | * output_buffer - Pointer to the user's return buffer | 141 | * aml_resource_length - Length of the resource from the AML header |
205 | * bytes_consumed - Pointer to where the number of bytes | 142 | * Resource - Where the internal resource is returned |
206 | * used in the output_buffer is returned | ||
207 | * | 143 | * |
208 | * RETURN: Status | 144 | * RETURN: Status |
209 | * | 145 | * |
210 | * DESCRIPTION: Take the linked list resource structure and fills in the | 146 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
211 | * the appropriate bytes in a byte stream | 147 | * internal resource descriptor, simplifying bitflags and handling |
148 | * alignment and endian issues if necessary. | ||
212 | * | 149 | * |
213 | ******************************************************************************/ | 150 | ******************************************************************************/ |
214 | 151 | ||
215 | acpi_status | 152 | acpi_status |
216 | acpi_rs_io_stream(struct acpi_resource *resource, | 153 | acpi_rs_get_fixed_io(union aml_resource *aml, |
217 | u8 ** output_buffer, acpi_size * bytes_consumed) | 154 | u16 aml_resource_length, struct acpi_resource *resource) |
218 | { | 155 | { |
219 | u8 *buffer = *output_buffer; | 156 | ACPI_FUNCTION_TRACE("rs_get_fixed_io"); |
220 | u16 temp16 = 0; | ||
221 | u8 temp8 = 0; | ||
222 | |||
223 | ACPI_FUNCTION_TRACE("rs_io_stream"); | ||
224 | |||
225 | /* The Descriptor Type field is static */ | ||
226 | |||
227 | *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07; | ||
228 | buffer += 1; | ||
229 | |||
230 | /* Io Information Byte */ | ||
231 | |||
232 | temp8 = (u8) (resource->data.io.io_decode & 0x01); | ||
233 | |||
234 | *buffer = temp8; | ||
235 | buffer += 1; | ||
236 | |||
237 | /* Set the Range minimum base address */ | ||
238 | |||
239 | temp16 = (u16) resource->data.io.min_base_address; | ||
240 | |||
241 | ACPI_MOVE_16_TO_16(buffer, &temp16); | ||
242 | buffer += 2; | ||
243 | |||
244 | /* Set the Range maximum base address */ | ||
245 | 157 | ||
246 | temp16 = (u16) resource->data.io.max_base_address; | 158 | /* |
159 | * Get the following contiguous fields from the AML descriptor: | ||
160 | * Base Address | ||
161 | * Length | ||
162 | */ | ||
163 | ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, | ||
164 | &aml->fixed_io.address); | ||
165 | resource->data.fixed_io.address_length = aml->fixed_io.address_length; | ||
247 | 166 | ||
248 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 167 | /* Complete the resource header */ |
249 | buffer += 2; | ||
250 | 168 | ||
251 | /* Set the base alignment */ | 169 | resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; |
252 | 170 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); | |
253 | temp8 = (u8) resource->data.io.alignment; | ||
254 | |||
255 | *buffer = temp8; | ||
256 | buffer += 1; | ||
257 | |||
258 | /* Set the range length */ | ||
259 | |||
260 | temp8 = (u8) resource->data.io.range_length; | ||
261 | |||
262 | *buffer = temp8; | ||
263 | buffer += 1; | ||
264 | |||
265 | /* Return the number of bytes consumed in this operation */ | ||
266 | |||
267 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
268 | return_ACPI_STATUS(AE_OK); | 171 | return_ACPI_STATUS(AE_OK); |
269 | } | 172 | } |
270 | 173 | ||
271 | /******************************************************************************* | 174 | /******************************************************************************* |
272 | * | 175 | * |
273 | * FUNCTION: acpi_rs_fixed_io_stream | 176 | * FUNCTION: acpi_rs_set_fixed_io |
274 | * | 177 | * |
275 | * PARAMETERS: Resource - Pointer to the resource linked list | 178 | * PARAMETERS: Resource - Pointer to the resource descriptor |
276 | * output_buffer - Pointer to the user's return buffer | 179 | * Aml - Where the AML descriptor is returned |
277 | * bytes_consumed - Pointer to where the number of bytes | ||
278 | * used in the output_buffer is returned | ||
279 | * | 180 | * |
280 | * RETURN: Status | 181 | * RETURN: Status |
281 | * | 182 | * |
282 | * DESCRIPTION: Take the linked list resource structure and fills in the | 183 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
283 | * the appropriate bytes in a byte stream | 184 | * external AML resource descriptor. |
284 | * | 185 | * |
285 | ******************************************************************************/ | 186 | ******************************************************************************/ |
286 | 187 | ||
287 | acpi_status | 188 | acpi_status |
288 | acpi_rs_fixed_io_stream(struct acpi_resource *resource, | 189 | acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) |
289 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
290 | { | 190 | { |
291 | u8 *buffer = *output_buffer; | 191 | ACPI_FUNCTION_TRACE("rs_set_fixed_io"); |
292 | u16 temp16 = 0; | 192 | |
293 | u8 temp8 = 0; | 193 | /* |
294 | 194 | * Set the following contiguous fields in the AML descriptor: | |
295 | ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); | 195 | * Base Address |
296 | 196 | * Length | |
297 | /* The Descriptor Type field is static */ | 197 | */ |
298 | 198 | ACPI_MOVE_32_TO_16(&aml->fixed_io.address, | |
299 | *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03; | 199 | &resource->data.fixed_io.address); |
300 | buffer += 1; | 200 | aml->fixed_io.address_length = |
301 | 201 | (u8) resource->data.fixed_io.address_length; | |
302 | /* Set the Range base address */ | 202 | |
303 | 203 | /* Complete the AML descriptor header */ | |
304 | temp16 = (u16) resource->data.fixed_io.base_address; | 204 | |
305 | 205 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO, | |
306 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 206 | sizeof(struct aml_resource_fixed_io), aml); |
307 | buffer += 2; | ||
308 | |||
309 | /* Set the range length */ | ||
310 | |||
311 | temp8 = (u8) resource->data.fixed_io.range_length; | ||
312 | |||
313 | *buffer = temp8; | ||
314 | buffer += 1; | ||
315 | |||
316 | /* Return the number of bytes consumed in this operation */ | ||
317 | |||
318 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
319 | return_ACPI_STATUS(AE_OK); | 207 | return_ACPI_STATUS(AE_OK); |
320 | } | 208 | } |
321 | 209 | ||
322 | /******************************************************************************* | 210 | /******************************************************************************* |
323 | * | 211 | * |
324 | * FUNCTION: acpi_rs_dma_resource | 212 | * FUNCTION: acpi_rs_get_dma |
325 | * | 213 | * |
326 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 214 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
327 | * stream | 215 | * aml_resource_length - Length of the resource from the AML header |
328 | * bytes_consumed - Pointer to where the number of bytes | 216 | * Resource - Where the internal resource is returned |
329 | * consumed the byte_stream_buffer is | ||
330 | * returned | ||
331 | * output_buffer - Pointer to the return data buffer | ||
332 | * structure_size - Pointer to where the number of bytes | ||
333 | * in the return data struct is returned | ||
334 | * | 217 | * |
335 | * RETURN: Status | 218 | * RETURN: Status |
336 | * | 219 | * |
337 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 220 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
338 | * structure pointed to by the output_buffer. Return the | 221 | * internal resource descriptor, simplifying bitflags and handling |
339 | * number of bytes consumed from the byte stream. | 222 | * alignment and endian issues if necessary. |
340 | * | 223 | * |
341 | ******************************************************************************/ | 224 | ******************************************************************************/ |
342 | 225 | ||
343 | acpi_status | 226 | acpi_status |
344 | acpi_rs_dma_resource(u8 * byte_stream_buffer, | 227 | acpi_rs_get_dma(union aml_resource *aml, |
345 | acpi_size * bytes_consumed, | 228 | u16 aml_resource_length, struct acpi_resource *resource) |
346 | u8 ** output_buffer, acpi_size * structure_size) | ||
347 | { | 229 | { |
348 | u8 *buffer = byte_stream_buffer; | 230 | u32 channel_count = 0; |
349 | struct acpi_resource *output_struct = (void *)*output_buffer; | 231 | u32 i; |
350 | u8 temp8 = 0; | 232 | u8 temp8; |
351 | u8 index; | ||
352 | u8 i; | ||
353 | acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); | ||
354 | 233 | ||
355 | ACPI_FUNCTION_TRACE("rs_dma_resource"); | 234 | ACPI_FUNCTION_TRACE("rs_get_dma"); |
356 | |||
357 | /* The number of bytes consumed are Constant */ | ||
358 | |||
359 | *bytes_consumed = 3; | ||
360 | output_struct->type = ACPI_RSTYPE_DMA; | ||
361 | |||
362 | /* Point to the 8-bits of Byte 1 */ | ||
363 | |||
364 | buffer += 1; | ||
365 | temp8 = *buffer; | ||
366 | 235 | ||
367 | /* Decode the DMA channel bits */ | 236 | /* Decode the DMA channel bits */ |
368 | 237 | ||
369 | for (i = 0, index = 0; index < 8; index++) { | 238 | for (i = 0; i < 8; i++) { |
370 | if ((temp8 >> index) & 0x01) { | 239 | if ((aml->dma.dma_channel_mask >> i) & 0x01) { |
371 | output_struct->data.dma.channels[i] = index; | 240 | resource->data.dma.channels[channel_count] = i; |
372 | i++; | 241 | channel_count++; |
373 | } | 242 | } |
374 | } | 243 | } |
375 | 244 | ||
376 | /* Zero DMA channels is valid */ | 245 | resource->length = 0; |
377 | 246 | resource->data.dma.channel_count = channel_count; | |
378 | output_struct->data.dma.number_of_channels = i; | ||
379 | if (i > 0) { | ||
380 | /* Calculate the structure size based upon the number of interrupts */ | ||
381 | 247 | ||
382 | struct_size += ((acpi_size) i - 1) * 4; | 248 | /* |
249 | * Calculate the structure size based upon the number of channels | ||
250 | * Note: Zero DMA channels is valid | ||
251 | */ | ||
252 | if (channel_count > 0) { | ||
253 | resource->length = (u32) (channel_count - 1) * 4; | ||
383 | } | 254 | } |
384 | 255 | ||
385 | /* Point to Byte 2 */ | 256 | /* Get the flags: transfer preference, bus mastering, channel speed */ |
386 | 257 | ||
387 | buffer += 1; | 258 | temp8 = aml->dma.flags; |
388 | temp8 = *buffer; | 259 | resource->data.dma.transfer = temp8 & 0x03; |
260 | resource->data.dma.bus_master = (temp8 >> 2) & 0x01; | ||
261 | resource->data.dma.type = (temp8 >> 5) & 0x03; | ||
389 | 262 | ||
390 | /* Check for transfer preference (Bits[1:0]) */ | 263 | if (resource->data.dma.transfer == 0x03) { |
391 | |||
392 | output_struct->data.dma.transfer = temp8 & 0x03; | ||
393 | |||
394 | if (0x03 == output_struct->data.dma.transfer) { | ||
395 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 264 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
396 | "Invalid DMA.Transfer preference (3)\n")); | 265 | "Invalid DMA.Transfer preference (3)\n")); |
397 | return_ACPI_STATUS(AE_BAD_DATA); | 266 | return_ACPI_STATUS(AE_BAD_DATA); |
398 | } | 267 | } |
399 | 268 | ||
400 | /* Get bus master preference (Bit[2]) */ | 269 | /* Complete the resource header */ |
401 | |||
402 | output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; | ||
403 | |||
404 | /* Get channel speed support (Bits[6:5]) */ | ||
405 | 270 | ||
406 | output_struct->data.dma.type = (temp8 >> 5) & 0x03; | 271 | resource->type = ACPI_RESOURCE_TYPE_DMA; |
407 | 272 | resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); | |
408 | /* Set the Length parameter */ | ||
409 | |||
410 | output_struct->length = (u32) struct_size; | ||
411 | |||
412 | /* Return the final size of the structure */ | ||
413 | |||
414 | *structure_size = struct_size; | ||
415 | return_ACPI_STATUS(AE_OK); | 273 | return_ACPI_STATUS(AE_OK); |
416 | } | 274 | } |
417 | 275 | ||
418 | /******************************************************************************* | 276 | /******************************************************************************* |
419 | * | 277 | * |
420 | * FUNCTION: acpi_rs_dma_stream | 278 | * FUNCTION: acpi_rs_set_dma |
421 | * | 279 | * |
422 | * PARAMETERS: Resource - Pointer to the resource linked list | 280 | * PARAMETERS: Resource - Pointer to the resource descriptor |
423 | * output_buffer - Pointer to the user's return buffer | 281 | * Aml - Where the AML descriptor is returned |
424 | * bytes_consumed - Pointer to where the number of bytes | ||
425 | * used in the output_buffer is returned | ||
426 | * | 282 | * |
427 | * RETURN: Status | 283 | * RETURN: Status |
428 | * | 284 | * |
429 | * DESCRIPTION: Take the linked list resource structure and fills in the | 285 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
430 | * the appropriate bytes in a byte stream | 286 | * external AML resource descriptor. |
431 | * | 287 | * |
432 | ******************************************************************************/ | 288 | ******************************************************************************/ |
433 | 289 | ||
434 | acpi_status | 290 | acpi_status |
435 | acpi_rs_dma_stream(struct acpi_resource *resource, | 291 | acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) |
436 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
437 | { | 292 | { |
438 | u8 *buffer = *output_buffer; | 293 | u8 i; |
439 | u16 temp16 = 0; | ||
440 | u8 temp8 = 0; | ||
441 | u8 index; | ||
442 | |||
443 | ACPI_FUNCTION_TRACE("rs_dma_stream"); | ||
444 | |||
445 | /* The Descriptor Type field is static */ | ||
446 | 294 | ||
447 | *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02; | 295 | ACPI_FUNCTION_TRACE("rs_set_dma"); |
448 | buffer += 1; | ||
449 | temp8 = 0; | ||
450 | 296 | ||
451 | /* Loop through all of the Channels and set the mask bits */ | 297 | /* Convert channel list to 8-bit DMA channel bitmask */ |
452 | 298 | ||
453 | for (index = 0; index < resource->data.dma.number_of_channels; index++) { | 299 | aml->dma.dma_channel_mask = 0; |
454 | temp16 = (u16) resource->data.dma.channels[index]; | 300 | for (i = 0; i < resource->data.dma.channel_count; i++) { |
455 | temp8 |= 0x1 << temp16; | 301 | aml->dma.dma_channel_mask |= |
302 | (1 << resource->data.dma.channels[i]); | ||
456 | } | 303 | } |
457 | 304 | ||
458 | *buffer = temp8; | 305 | /* Set the DMA Flag bits */ |
459 | buffer += 1; | ||
460 | |||
461 | /* Set the DMA Info */ | ||
462 | |||
463 | temp8 = (u8) ((resource->data.dma.type & 0x03) << 5); | ||
464 | temp8 |= ((resource->data.dma.bus_master & 0x01) << 2); | ||
465 | temp8 |= (resource->data.dma.transfer & 0x03); | ||
466 | 306 | ||
467 | *buffer = temp8; | 307 | aml->dma.flags = (u8) |
468 | buffer += 1; | 308 | (((resource->data.dma.type & 0x03) << 5) | |
309 | ((resource->data.dma.bus_master & 0x01) << 2) | | ||
310 | (resource->data.dma.transfer & 0x03)); | ||
469 | 311 | ||
470 | /* Return the number of bytes consumed in this operation */ | 312 | /* Complete the AML descriptor header */ |
471 | 313 | ||
472 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 314 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, |
315 | sizeof(struct aml_resource_dma), aml); | ||
473 | return_ACPI_STATUS(AE_OK); | 316 | return_ACPI_STATUS(AE_OK); |
474 | } | 317 | } |