aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rsio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resources/rsio.c')
-rw-r--r--drivers/acpi/resources/rsio.c544
1 files changed, 161 insertions, 383 deletions
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index d53bbe89e851..ea567167c4f2 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,428 +49,206 @@ ACPI_MODULE_NAME("rsio")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_io_resource 52 * acpi_rs_convert_io
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 ******************************************************************************/
55 * stream 55struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
56 * bytes_consumed - Pointer to where the number of bytes 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
57 * consumed the byte_stream_buffer is 57 ACPI_RS_SIZE(struct acpi_resource_io),
58 * returned 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
59 * output_buffer - Pointer to the return data buffer 59
60 * structure_size - Pointer to where the number of bytes 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
61 * in the return data struct is returned 61 sizeof(struct aml_resource_io),
62 * 62 0},
63 * RETURN: Status 63
64 /* Decode flag */
65
66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
67 AML_OFFSET(io.flags),
68 0},
69 /*
70 * These fields are contiguous in both the source and destination:
71 * Address Alignment
72 * Length
73 * Minimum Base Address
74 * Maximum Base Address
75 */
76 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
77 AML_OFFSET(io.alignment),
78 2},
79
80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
81 AML_OFFSET(io.minimum),
82 2}
83};
84
85/*******************************************************************************
64 * 86 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 87 * acpi_rs_convert_fixed_io
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 88 *
69 ******************************************************************************/ 89 ******************************************************************************/
70acpi_status
71acpi_rs_io_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed,
73 u8 ** output_buffer, acpi_size * structure_size)
74{
75 u8 *buffer = byte_stream_buffer;
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
81 ACPI_FUNCTION_TRACE("rs_io_resource");
82
83 /* The number of bytes consumed are Constant */
84
85 *bytes_consumed = 8;
86
87 output_struct->id = ACPI_RSTYPE_IO;
88
89 /* Check Decode */
90
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 90
105 buffer += 2; 91struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
106 ACPI_MOVE_16_TO_16(&temp16, buffer); 92 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
107 93 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
108 output_struct->data.io.max_base_address = temp16; 94 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
109 95
110 /* Check Base alignment */ 96 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
111 97 sizeof(struct aml_resource_fixed_io),
112 buffer += 2; 98 0},
113 temp8 = *buffer; 99 /*
114 100 * These fields are contiguous in both the source and destination:
115 output_struct->data.io.alignment = temp8; 101 * Base Address
116 102 * Length
117 /* Check range_length */ 103 */
118 104 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
119 buffer += 1; 105 AML_OFFSET(fixed_io.address_length),
120 temp8 = *buffer; 106 1},
121 107
122 output_struct->data.io.range_length = temp8; 108 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
123 109 AML_OFFSET(fixed_io.address),
124 /* Set the Length parameter */ 110 1}
125 111};
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);
132}
133 112
134/******************************************************************************* 113/*******************************************************************************
135 * 114 *
136 * FUNCTION: acpi_rs_fixed_io_resource 115 * acpi_rs_convert_generic_reg
137 *
138 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
139 * stream
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 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
150 * structure pointed to by the output_buffer. Return the
151 * number of bytes consumed from the byte stream.
152 * 116 *
153 ******************************************************************************/ 117 ******************************************************************************/
154 118
155acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
156acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
157 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_generic_register),
158 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
159{ 123
160 u8 *buffer = byte_stream_buffer; 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
161 struct acpi_resource *output_struct = (void *)*output_buffer; 125 sizeof(struct aml_resource_generic_register),
162 u16 temp16 = 0; 126 0},
163 u8 temp8 = 0; 127 /*
164 acpi_size struct_size = 128 * These fields are contiguous in both the source and destination:
165 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 129 * Address Space ID
166 130 * Register Bit Width
167 ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); 131 * Register Bit Offset
168 132 * Access Size
169 /* The number of bytes consumed are Constant */ 133 */
170 134 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
171 *bytes_consumed = 4; 135 AML_OFFSET(generic_reg.address_space_id),
172 136 4},
173 output_struct->id = ACPI_RSTYPE_FIXED_IO; 137
174 138 /* Get the Register Address */
175 /* Check Range Base Address */ 139
176 140 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
177 buffer += 1; 141 AML_OFFSET(generic_reg.address),
178 ACPI_MOVE_16_TO_16(&temp16, buffer); 142 1}
179 143};
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);
197}
198 144
199/******************************************************************************* 145/*******************************************************************************
200 * 146 *
201 * FUNCTION: acpi_rs_io_stream 147 * acpi_rs_convert_end_dpf
202 *
203 * PARAMETERS: linked_list - Pointer to the resource linked list
204 * output_buffer - Pointer to the user's return buffer
205 * bytes_consumed - Pointer to where the number of bytes
206 * used in the output_buffer is returned
207 *
208 * RETURN: Status
209 *
210 * DESCRIPTION: Take the linked list resource structure and fills in the
211 * the appropriate bytes in a byte stream
212 * 148 *
213 ******************************************************************************/ 149 ******************************************************************************/
214 150
215acpi_status 151struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
216acpi_rs_io_stream(struct acpi_resource *linked_list, 152 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
217 u8 ** output_buffer, acpi_size * bytes_consumed) 153 ACPI_RS_SIZE_MIN,
218{ 154 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
219 u8 *buffer = *output_buffer;
220 u16 temp16 = 0;
221 u8 temp8 = 0;
222
223 ACPI_FUNCTION_TRACE("rs_io_stream");
224
225 /* The descriptor field is static */
226
227 *buffer = 0x47;
228 buffer += 1;
229
230 /* Io Information Byte */
231
232 temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
233
234 *buffer = temp8;
235 buffer += 1;
236
237 /* Set the Range minimum base address */
238
239 temp16 = (u16) linked_list->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
246 temp16 = (u16) linked_list->data.io.max_base_address;
247 155
248 ACPI_MOVE_16_TO_16(buffer, &temp16); 156 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
249 buffer += 2; 157 sizeof(struct aml_resource_end_dependent),
250 158 0}
251 /* Set the base alignment */ 159};
252
253 temp8 = (u8) linked_list->data.io.alignment;
254
255 *buffer = temp8;
256 buffer += 1;
257
258 /* Set the range length */
259
260 temp8 = (u8) linked_list->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);
269}
270 160
271/******************************************************************************* 161/*******************************************************************************
272 * 162 *
273 * FUNCTION: acpi_rs_fixed_io_stream 163 * acpi_rs_convert_end_tag
274 *
275 * PARAMETERS: linked_list - Pointer to the resource linked list
276 * output_buffer - Pointer to the user's return buffer
277 * bytes_consumed - Pointer to where the number of bytes
278 * used in the output_buffer is returned
279 *
280 * RETURN: Status
281 *
282 * DESCRIPTION: Take the linked list resource structure and fills in the
283 * the appropriate bytes in a byte stream
284 * 164 *
285 ******************************************************************************/ 165 ******************************************************************************/
286 166
287acpi_status 167struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
288acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, 168 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
289 u8 ** output_buffer, acpi_size * bytes_consumed) 169 ACPI_RS_SIZE_MIN,
290{ 170 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
291 u8 *buffer = *output_buffer; 171
292 u16 temp16 = 0; 172 /*
293 u8 temp8 = 0; 173 * Note: The checksum field is set to zero, meaning that the resource
294 174 * data is treated as if the checksum operation succeeded.
295 ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); 175 * (ACPI Spec 1.0b Section 6.4.2.8)
296 176 */
297 /* The descriptor field is static */ 177 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
298 178 sizeof(struct aml_resource_end_tag),
299 *buffer = 0x4B; 179 0}
300 180};
301 buffer += 1;
302
303 /* Set the Range base address */
304
305 temp16 = (u16) linked_list->data.fixed_io.base_address;
306
307 ACPI_MOVE_16_TO_16(buffer, &temp16);
308 buffer += 2;
309
310 /* Set the range length */
311
312 temp8 = (u8) linked_list->data.fixed_io.range_length;
313
314 *buffer = temp8;
315 buffer += 1;
316
317 /* Return the number of bytes consumed in this operation */
318
319 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
320 return_ACPI_STATUS(AE_OK);
321}
322 181
323/******************************************************************************* 182/*******************************************************************************
324 * 183 *
325 * FUNCTION: acpi_rs_dma_resource 184 * acpi_rs_get_start_dpf
326 *
327 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
328 * stream
329 * bytes_consumed - Pointer to where the number of bytes
330 * consumed the byte_stream_buffer is
331 * returned
332 * output_buffer - Pointer to the return data buffer
333 * structure_size - Pointer to where the number of bytes
334 * in the return data struct is returned
335 *
336 * RETURN: Status
337 *
338 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
339 * structure pointed to by the output_buffer. Return the
340 * number of bytes consumed from the byte stream.
341 * 185 *
342 ******************************************************************************/ 186 ******************************************************************************/
343 187
344acpi_status 188struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = {
345acpi_rs_dma_resource(u8 * byte_stream_buffer, 189 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
346 acpi_size * bytes_consumed, 190 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
347 u8 ** output_buffer, acpi_size * structure_size) 191 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
348{
349 u8 *buffer = byte_stream_buffer;
350 struct acpi_resource *output_struct = (void *)*output_buffer;
351 u8 temp8 = 0;
352 u8 index;
353 u8 i;
354 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
355
356 ACPI_FUNCTION_TRACE("rs_dma_resource");
357
358 /* The number of bytes consumed are Constant */
359 192
360 *bytes_consumed = 3; 193 /* Defaults for Compatibility and Performance priorities */
361 output_struct->id = ACPI_RSTYPE_DMA;
362 194
363 /* Point to the 8-bits of Byte 1 */ 195 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
196 ACPI_ACCEPTABLE_CONFIGURATION,
197 2},
364 198
365 buffer += 1; 199 /* All done if there is no flag byte present in the descriptor */
366 temp8 = *buffer;
367 200
368 /* Decode the DMA channel bits */ 201 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
369 202
370 for (i = 0, index = 0; index < 8; index++) { 203 /* Flag byte is present, get the flags */
371 if ((temp8 >> index) & 0x01) {
372 output_struct->data.dma.channels[i] = index;
373 i++;
374 }
375 }
376 204
377 /* Zero DMA channels is valid */ 205 {ACPI_RSC_2BITFLAG,
206 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
207 AML_OFFSET(start_dpf.flags),
208 0},
378 209
379 output_struct->data.dma.number_of_channels = i; 210 {ACPI_RSC_2BITFLAG,
380 if (i > 0) { 211 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
381 /* Calculate the structure size based upon the number of interrupts */ 212 AML_OFFSET(start_dpf.flags),
382 213 2}
383 struct_size += ((acpi_size) i - 1) * 4; 214};
384 }
385
386 /* Point to Byte 2 */
387
388 buffer += 1;
389 temp8 = *buffer;
390
391 /* Check for transfer preference (Bits[1:0]) */
392
393 output_struct->data.dma.transfer = temp8 & 0x03;
394
395 if (0x03 == output_struct->data.dma.transfer) {
396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
397 "Invalid DMA.Transfer preference (3)\n"));
398 return_ACPI_STATUS(AE_BAD_DATA);
399 }
400
401 /* Get bus master preference (Bit[2]) */
402
403 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
404
405 /* Get channel speed support (Bits[6:5]) */
406
407 output_struct->data.dma.type = (temp8 >> 5) & 0x03;
408
409 /* Set the Length parameter */
410
411 output_struct->length = (u32) struct_size;
412
413 /* Return the final size of the structure */
414
415 *structure_size = struct_size;
416 return_ACPI_STATUS(AE_OK);
417}
418 215
419/******************************************************************************* 216/*******************************************************************************
420 * 217 *
421 * FUNCTION: acpi_rs_dma_stream 218 * acpi_rs_set_start_dpf
422 *
423 * PARAMETERS: linked_list - Pointer to the resource linked list
424 * output_buffer - Pointer to the user's return buffer
425 * bytes_consumed - Pointer to where the number of bytes
426 * used in the output_buffer is returned
427 *
428 * RETURN: Status
429 *
430 * DESCRIPTION: Take the linked list resource structure and fills in the
431 * the appropriate bytes in a byte stream
432 * 219 *
433 ******************************************************************************/ 220 ******************************************************************************/
434 221
435acpi_status 222struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = {
436acpi_rs_dma_stream(struct acpi_resource *linked_list, 223 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
437 u8 ** output_buffer, acpi_size * bytes_consumed) 224 sizeof(struct aml_resource_start_dependent),
438{ 225 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
439 u8 *buffer = *output_buffer; 226
440 u16 temp16 = 0; 227 /* Set the default flag values */
441 u8 temp8 = 0; 228
442 u8 index; 229 {ACPI_RSC_2BITFLAG,
443 230 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
444 ACPI_FUNCTION_TRACE("rs_dma_stream"); 231 AML_OFFSET(start_dpf.flags),
445 232 0},
446 /* The descriptor field is static */ 233
447 234 {ACPI_RSC_2BITFLAG,
448 *buffer = 0x2A; 235 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
449 buffer += 1; 236 AML_OFFSET(start_dpf.flags),
450 temp8 = 0; 237 2},
451 238 /*
452 /* Loop through all of the Channels and set the mask bits */ 239 * All done if flags byte is necessary -- if either priority value
453 240 * is not ACPI_ACCEPTABLE_CONFIGURATION
454 for (index = 0; 241 */
455 index < linked_list->data.dma.number_of_channels; index++) { 242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
456 temp16 = (u16) linked_list->data.dma.channels[index]; 243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
457 temp8 |= 0x1 << temp16; 244 ACPI_ACCEPTABLE_CONFIGURATION},
458 } 245
459 246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
460 *buffer = temp8; 247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
461 buffer += 1; 248 ACPI_ACCEPTABLE_CONFIGURATION},
462 249
463 /* Set the DMA Info */ 250 /* Flag byte is not necessary */
464 251
465 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); 252 {ACPI_RSC_LENGTH, 0, 0,
466 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); 253 sizeof(struct aml_resource_start_dependent_noprio)}
467 temp8 |= (linked_list->data.dma.transfer & 0x03); 254};
468
469 *buffer = temp8;
470 buffer += 1;
471
472 /* Return the number of bytes consumed in this operation */
473
474 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
475 return_ACPI_STATUS(AE_OK);
476}