blob: fa7f5a85b61d91f43e428a037234209190e1b463 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsmisc - Miscellaneous resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("rsmisc")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*******************************************************************************
51 *
Robert Moorebda663d2005-09-16 16:51:15 -040052 * FUNCTION: acpi_rs_generic_register_resource
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
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 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 *
69 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070070acpi_status
Robert Moorebda663d2005-09-16 16:51:15 -040071acpi_rs_generic_register_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed,
73 u8 ** output_buffer,
74 acpi_size * structure_size)
75{
76 u8 *buffer = byte_stream_buffer;
77 struct acpi_resource *output_struct = (void *)*output_buffer;
78 u16 temp16;
79 u8 temp8;
80 acpi_size struct_size =
81 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg);
82
83 ACPI_FUNCTION_TRACE("rs_generic_register_resource");
84
85 /* Byte 0 is the Descriptor Type */
86
87 buffer += 1;
88
89 /* Get the Descriptor Length field (Bytes 1-2) */
90
91 ACPI_MOVE_16_TO_16(&temp16, buffer);
92 buffer += 2;
93
94 /* Validate the descriptor length */
95
96 if (temp16 != 12) {
97 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
98 }
99
100 /* The number of bytes consumed is fixed (12 + 3) */
101
102 *bytes_consumed = 15;
103
104 /* Fill out the structure */
105
106 output_struct->type = ACPI_RSTYPE_GENERIC_REG;
107
108 /* Get space_id (Byte 3) */
109
110 temp8 = *buffer;
111 output_struct->data.generic_reg.space_id = temp8;
112 buffer += 1;
113
114 /* Get register_bit_width (Byte 4) */
115
116 temp8 = *buffer;
117 output_struct->data.generic_reg.bit_width = temp8;
118 buffer += 1;
119
120 /* Get register_bit_offset (Byte 5) */
121
122 temp8 = *buffer;
123 output_struct->data.generic_reg.bit_offset = temp8;
124 buffer += 1;
125
126 /* Get address_size (Byte 6) */
127
128 temp8 = *buffer;
129 output_struct->data.generic_reg.address_size = temp8;
130 buffer += 1;
131
132 /* Get register_address (Bytes 7-14) */
133
134 ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer);
135
136 /* Set the Length parameter */
137
138 output_struct->length = (u32) struct_size;
139
140 /* Return the final size of the structure */
141
142 *structure_size = struct_size;
143 return_ACPI_STATUS(AE_OK);
144}
145
146/*******************************************************************************
147 *
148 * FUNCTION: acpi_rs_generic_register_stream
149 *
150 * PARAMETERS: Resource - Pointer to the resource linked list
151 * output_buffer - Pointer to the user's return buffer
152 * bytes_consumed - Pointer to where the number of bytes
153 * used in the output_buffer is returned
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Take the linked list resource structure and fills in the
158 * the appropriate bytes in a byte stream
159 *
160 ******************************************************************************/
161
162acpi_status
163acpi_rs_generic_register_stream(struct acpi_resource *resource,
164 u8 ** output_buffer, acpi_size * bytes_consumed)
165{
166 u8 *buffer = *output_buffer;
167 u16 temp16;
168
169 ACPI_FUNCTION_TRACE("rs_generic_register_stream");
170
171 /* Set the Descriptor Type (Byte 0) */
172
173 *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER;
174 buffer += 1;
175
176 /* Set the Descriptor Length (Bytes 1-2) */
177
178 temp16 = 12;
179 ACPI_MOVE_16_TO_16(buffer, &temp16);
180 buffer += 2;
181
182 /* Set space_id (Byte 3) */
183
184 *buffer = (u8) resource->data.generic_reg.space_id;
185 buffer += 1;
186
187 /* Set register_bit_width (Byte 4) */
188
189 *buffer = (u8) resource->data.generic_reg.bit_width;
190 buffer += 1;
191
192 /* Set register_bit_offset (Byte 5) */
193
194 *buffer = (u8) resource->data.generic_reg.bit_offset;
195 buffer += 1;
196
197 /* Set address_size (Byte 6) */
198
199 *buffer = (u8) resource->data.generic_reg.address_size;
200 buffer += 1;
201
202 /* Set register_address (Bytes 7-14) */
203
204 ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address);
205 buffer += 8;
206
207 /* Return the number of bytes consumed in this operation */
208
209 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
210 return_ACPI_STATUS(AE_OK);
211}
212
213/*******************************************************************************
214 *
215 * FUNCTION: acpi_rs_end_tag_resource
216 *
217 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
218 * stream
219 * bytes_consumed - Pointer to where the number of bytes
220 * consumed the byte_stream_buffer is
221 * returned
222 * output_buffer - Pointer to the return data buffer
223 * structure_size - Pointer to where the number of bytes
224 * in the return data struct is returned
225 *
226 * RETURN: Status
227 *
228 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
229 * structure pointed to by the output_buffer. Return the
230 * number of bytes consumed from the byte stream.
231 *
232 ******************************************************************************/
233
234acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400235acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
236 acpi_size * bytes_consumed,
237 u8 ** output_buffer, acpi_size * structure_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
Len Brown4be44fc2005-08-05 00:44:28 -0400239 struct acpi_resource *output_struct = (void *)*output_buffer;
240 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Len Brown4be44fc2005-08-05 00:44:28 -0400242 ACPI_FUNCTION_TRACE("rs_end_tag_resource");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Robert Moore44f6c012005-04-18 22:49:35 -0400244 /* The number of bytes consumed is static */
245
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 *bytes_consumed = 2;
247
Robert Moorebda663d2005-09-16 16:51:15 -0400248 /* Fill out the structure */
Robert Moore44f6c012005-04-18 22:49:35 -0400249
Robert Moorebda663d2005-09-16 16:51:15 -0400250 output_struct->type = ACPI_RSTYPE_END_TAG;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Robert Moore44f6c012005-04-18 22:49:35 -0400252 /* Set the Length parameter */
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 output_struct->length = 0;
255
Robert Moore44f6c012005-04-18 22:49:35 -0400256 /* Return the final size of the structure */
257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 *structure_size = struct_size;
Len Brown4be44fc2005-08-05 00:44:28 -0400259 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260}
261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262/*******************************************************************************
263 *
264 * FUNCTION: acpi_rs_end_tag_stream
265 *
Robert Moorebda663d2005-09-16 16:51:15 -0400266 * PARAMETERS: Resource - Pointer to the resource linked list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 * output_buffer - Pointer to the user's return buffer
268 * bytes_consumed - Pointer to where the number of bytes
269 * used in the output_buffer is returned
270 *
271 * RETURN: Status
272 *
273 * DESCRIPTION: Take the linked list resource structure and fills in the
274 * the appropriate bytes in a byte stream
275 *
276 ******************************************************************************/
277
278acpi_status
Robert Moorebda663d2005-09-16 16:51:15 -0400279acpi_rs_end_tag_stream(struct acpi_resource *resource,
Len Brown4be44fc2005-08-05 00:44:28 -0400280 u8 ** output_buffer, acpi_size * bytes_consumed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
Len Brown4be44fc2005-08-05 00:44:28 -0400282 u8 *buffer = *output_buffer;
283 u8 temp8 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Len Brown4be44fc2005-08-05 00:44:28 -0400285 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Robert Moorebda663d2005-09-16 16:51:15 -0400287 /* The Descriptor Type field is static */
Robert Moore44f6c012005-04-18 22:49:35 -0400288
Robert Moorebda663d2005-09-16 16:51:15 -0400289 *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 buffer += 1;
291
292 /*
293 * Set the Checksum - zero means that the resource data is treated as if
294 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
295 */
296 temp8 = 0;
297
298 *buffer = temp8;
299 buffer += 1;
300
Robert Moore44f6c012005-04-18 22:49:35 -0400301 /* Return the number of bytes consumed in this operation */
302
Len Brown4be44fc2005-08-05 00:44:28 -0400303 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
304 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307/*******************************************************************************
308 *
309 * FUNCTION: acpi_rs_vendor_resource
310 *
311 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
312 * stream
313 * bytes_consumed - Pointer to where the number of bytes
314 * consumed the byte_stream_buffer is
315 * returned
316 * output_buffer - Pointer to the return data buffer
317 * structure_size - Pointer to where the number of bytes
318 * in the return data struct is returned
319 *
320 * RETURN: Status
321 *
322 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
323 * structure pointed to by the output_buffer. Return the
324 * number of bytes consumed from the byte stream.
325 *
326 ******************************************************************************/
327
328acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400329acpi_rs_vendor_resource(u8 * byte_stream_buffer,
330 acpi_size * bytes_consumed,
331 u8 ** output_buffer, acpi_size * structure_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
Len Brown4be44fc2005-08-05 00:44:28 -0400333 u8 *buffer = byte_stream_buffer;
334 struct acpi_resource *output_struct = (void *)*output_buffer;
335 u16 temp16 = 0;
336 u8 temp8 = 0;
337 u8 index;
338 acpi_size struct_size =
339 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Len Brown4be44fc2005-08-05 00:44:28 -0400341 ACPI_FUNCTION_TRACE("rs_vendor_resource");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342
Robert Moore44f6c012005-04-18 22:49:35 -0400343 /* Dereference the Descriptor to find if this is a large or small item. */
344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 temp8 = *buffer;
346
Robert Moorebda663d2005-09-16 16:51:15 -0400347 if (temp8 & ACPI_RDESC_TYPE_LARGE) {
Robert Moore44f6c012005-04-18 22:49:35 -0400348 /* Large Item, point to the length field */
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 buffer += 1;
351
352 /* Dereference */
353
Len Brown4be44fc2005-08-05 00:44:28 -0400354 ACPI_MOVE_16_TO_16(&temp16, buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356 /* Calculate bytes consumed */
357
358 *bytes_consumed = (acpi_size) temp16 + 3;
359
360 /* Point to the first vendor byte */
361
362 buffer += 2;
Len Brown4be44fc2005-08-05 00:44:28 -0400363 } else {
Robert Moore44f6c012005-04-18 22:49:35 -0400364 /* Small Item, dereference the size */
365
Len Brown4be44fc2005-08-05 00:44:28 -0400366 temp16 = (u8) (*buffer & 0x07);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
368 /* Calculate bytes consumed */
369
370 *bytes_consumed = (acpi_size) temp16 + 1;
371
372 /* Point to the first vendor byte */
373
374 buffer += 1;
375 }
376
Robert Moorebda663d2005-09-16 16:51:15 -0400377 output_struct->type = ACPI_RSTYPE_VENDOR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 output_struct->data.vendor_specific.length = temp16;
379
380 for (index = 0; index < temp16; index++) {
381 output_struct->data.vendor_specific.reserved[index] = *buffer;
382 buffer += 1;
383 }
384
385 /*
386 * In order for the struct_size to fall on a 32-bit boundary,
387 * calculate the length of the vendor string and expand the
388 * struct_size to the next 32-bit boundary.
389 */
Len Brown4be44fc2005-08-05 00:44:28 -0400390 struct_size += ACPI_ROUND_UP_to_32_bITS(temp16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Robert Moore44f6c012005-04-18 22:49:35 -0400392 /* Set the Length parameter */
393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 output_struct->length = (u32) struct_size;
395
Robert Moore44f6c012005-04-18 22:49:35 -0400396 /* Return the final size of the structure */
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 *structure_size = struct_size;
Len Brown4be44fc2005-08-05 00:44:28 -0400399 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402/*******************************************************************************
403 *
404 * FUNCTION: acpi_rs_vendor_stream
405 *
Robert Moorebda663d2005-09-16 16:51:15 -0400406 * PARAMETERS: Resource - Pointer to the resource linked list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 * output_buffer - Pointer to the user's return buffer
408 * bytes_consumed - Pointer to where the number of bytes
409 * used in the output_buffer is returned
410 *
411 * RETURN: Status
412 *
413 * DESCRIPTION: Take the linked list resource structure and fills in the
414 * the appropriate bytes in a byte stream
415 *
416 ******************************************************************************/
417
418acpi_status
Robert Moorebda663d2005-09-16 16:51:15 -0400419acpi_rs_vendor_stream(struct acpi_resource *resource,
Len Brown4be44fc2005-08-05 00:44:28 -0400420 u8 ** output_buffer, acpi_size * bytes_consumed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
Len Brown4be44fc2005-08-05 00:44:28 -0400422 u8 *buffer = *output_buffer;
423 u16 temp16 = 0;
424 u8 temp8 = 0;
425 u8 index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Len Brown4be44fc2005-08-05 00:44:28 -0400427 ACPI_FUNCTION_TRACE("rs_vendor_stream");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Robert Moore44f6c012005-04-18 22:49:35 -0400429 /* Dereference the length to find if this is a large or small item. */
430
Robert Moorebda663d2005-09-16 16:51:15 -0400431 if (resource->data.vendor_specific.length > 7) {
Robert Moore44f6c012005-04-18 22:49:35 -0400432 /* Large Item, Set the descriptor field and length bytes */
433
Robert Moorebda663d2005-09-16 16:51:15 -0400434 *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 buffer += 1;
436
Robert Moorebda663d2005-09-16 16:51:15 -0400437 temp16 = (u16) resource->data.vendor_specific.length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Len Brown4be44fc2005-08-05 00:44:28 -0400439 ACPI_MOVE_16_TO_16(buffer, &temp16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 buffer += 2;
Len Brown4be44fc2005-08-05 00:44:28 -0400441 } else {
Robert Moore44f6c012005-04-18 22:49:35 -0400442 /* Small Item, Set the descriptor field */
443
Robert Moorebda663d2005-09-16 16:51:15 -0400444 temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR;
445 temp8 |= (u8) resource->data.vendor_specific.length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
447 *buffer = temp8;
448 buffer += 1;
449 }
450
Robert Moore44f6c012005-04-18 22:49:35 -0400451 /* Loop through all of the Vendor Specific fields */
452
Robert Moorebda663d2005-09-16 16:51:15 -0400453 for (index = 0; index < resource->data.vendor_specific.length; index++) {
454 temp8 = resource->data.vendor_specific.reserved[index];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 *buffer = temp8;
457 buffer += 1;
458 }
459
Robert Moore44f6c012005-04-18 22:49:35 -0400460 /* Return the number of bytes consumed in this operation */
461
Len Brown4be44fc2005-08-05 00:44:28 -0400462 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
463 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466/*******************************************************************************
467 *
468 * FUNCTION: acpi_rs_start_depend_fns_resource
469 *
470 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
471 * stream
472 * bytes_consumed - Pointer to where the number of bytes
473 * consumed the byte_stream_buffer is
474 * returned
475 * output_buffer - Pointer to the return data buffer
476 * structure_size - Pointer to where the number of bytes
477 * in the return data struct is returned
478 *
479 * RETURN: Status
480 *
481 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
482 * structure pointed to by the output_buffer. Return the
483 * number of bytes consumed from the byte stream.
484 *
485 ******************************************************************************/
486
487acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400488acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer,
489 acpi_size * bytes_consumed,
490 u8 ** output_buffer,
491 acpi_size * structure_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
Len Brown4be44fc2005-08-05 00:44:28 -0400493 u8 *buffer = byte_stream_buffer;
494 struct acpi_resource *output_struct = (void *)*output_buffer;
495 u8 temp8 = 0;
496 acpi_size struct_size =
497 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Len Brown4be44fc2005-08-05 00:44:28 -0400499 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Robert Moore44f6c012005-04-18 22:49:35 -0400501 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 temp8 = *buffer;
504
505 *bytes_consumed = (temp8 & 0x01) + 1;
506
Robert Moorebda663d2005-09-16 16:51:15 -0400507 output_struct->type = ACPI_RSTYPE_START_DPF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Robert Moore44f6c012005-04-18 22:49:35 -0400509 /* Point to Byte 1 if it is used */
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 if (2 == *bytes_consumed) {
512 buffer += 1;
513 temp8 = *buffer;
514
Robert Moore44f6c012005-04-18 22:49:35 -0400515 /* Check Compatibility priority */
516
Len Brown4be44fc2005-08-05 00:44:28 -0400517 output_struct->data.start_dpf.compatibility_priority =
518 temp8 & 0x03;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
520 if (3 == output_struct->data.start_dpf.compatibility_priority) {
Len Brown4be44fc2005-08-05 00:44:28 -0400521 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 }
523
Robert Moore44f6c012005-04-18 22:49:35 -0400524 /* Check Performance/Robustness preference */
525
Len Brown4be44fc2005-08-05 00:44:28 -0400526 output_struct->data.start_dpf.performance_robustness =
527 (temp8 >> 2) & 0x03;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
529 if (3 == output_struct->data.start_dpf.performance_robustness) {
Len Brown4be44fc2005-08-05 00:44:28 -0400530 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 }
Len Brown4be44fc2005-08-05 00:44:28 -0400532 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 output_struct->data.start_dpf.compatibility_priority =
Len Brown4be44fc2005-08-05 00:44:28 -0400534 ACPI_ACCEPTABLE_CONFIGURATION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535
536 output_struct->data.start_dpf.performance_robustness =
Len Brown4be44fc2005-08-05 00:44:28 -0400537 ACPI_ACCEPTABLE_CONFIGURATION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 }
539
Robert Moore44f6c012005-04-18 22:49:35 -0400540 /* Set the Length parameter */
541
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 output_struct->length = (u32) struct_size;
543
Robert Moore44f6c012005-04-18 22:49:35 -0400544 /* Return the final size of the structure */
545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 *structure_size = struct_size;
Len Brown4be44fc2005-08-05 00:44:28 -0400547 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/*******************************************************************************
551 *
552 * FUNCTION: acpi_rs_end_depend_fns_resource
553 *
554 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
555 * stream
556 * bytes_consumed - Pointer to where the number of bytes
557 * consumed the byte_stream_buffer is
558 * returned
559 * output_buffer - Pointer to the return data buffer
560 * structure_size - Pointer to where the number of bytes
561 * in the return data struct is returned
562 *
563 * RETURN: Status
564 *
565 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
566 * structure pointed to by the output_buffer. Return the
567 * number of bytes consumed from the byte stream.
568 *
569 ******************************************************************************/
570
571acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400572acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
573 acpi_size * bytes_consumed,
574 u8 ** output_buffer, acpi_size * structure_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575{
Len Brown4be44fc2005-08-05 00:44:28 -0400576 struct acpi_resource *output_struct = (void *)*output_buffer;
577 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578
Len Brown4be44fc2005-08-05 00:44:28 -0400579 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580
Robert Moore44f6c012005-04-18 22:49:35 -0400581 /* The number of bytes consumed is static */
582
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 *bytes_consumed = 1;
584
Robert Moore44f6c012005-04-18 22:49:35 -0400585 /* Fill out the structure */
586
Robert Moorebda663d2005-09-16 16:51:15 -0400587 output_struct->type = ACPI_RSTYPE_END_DPF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588
Robert Moore44f6c012005-04-18 22:49:35 -0400589 /* Set the Length parameter */
590
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 output_struct->length = (u32) struct_size;
592
Robert Moore44f6c012005-04-18 22:49:35 -0400593 /* Return the final size of the structure */
594
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 *structure_size = struct_size;
Len Brown4be44fc2005-08-05 00:44:28 -0400596 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597}
598
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599/*******************************************************************************
600 *
601 * FUNCTION: acpi_rs_start_depend_fns_stream
602 *
Robert Moorebda663d2005-09-16 16:51:15 -0400603 * PARAMETERS: Resource - Pointer to the resource linked list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 * output_buffer - Pointer to the user's return buffer
605 * bytes_consumed - u32 pointer that is filled with
606 * the number of bytes of the
607 * output_buffer used
608 *
609 * RETURN: Status
610 *
611 * DESCRIPTION: Take the linked list resource structure and fills in the
612 * the appropriate bytes in a byte stream
613 *
614 ******************************************************************************/
615
616acpi_status
Robert Moorebda663d2005-09-16 16:51:15 -0400617acpi_rs_start_depend_fns_stream(struct acpi_resource *resource,
Len Brown4be44fc2005-08-05 00:44:28 -0400618 u8 ** output_buffer, acpi_size * bytes_consumed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619{
Len Brown4be44fc2005-08-05 00:44:28 -0400620 u8 *buffer = *output_buffer;
621 u8 temp8 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Len Brown4be44fc2005-08-05 00:44:28 -0400623 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625 /*
Robert Moorebda663d2005-09-16 16:51:15 -0400626 * The descriptor type field is set based upon whether a byte is needed
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 * to contain Priority data.
628 */
629 if (ACPI_ACCEPTABLE_CONFIGURATION ==
Robert Moorebda663d2005-09-16 16:51:15 -0400630 resource->data.start_dpf.compatibility_priority &&
Len Brown4be44fc2005-08-05 00:44:28 -0400631 ACPI_ACCEPTABLE_CONFIGURATION ==
Robert Moorebda663d2005-09-16 16:51:15 -0400632 resource->data.start_dpf.performance_robustness) {
633 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT;
Len Brown4be44fc2005-08-05 00:44:28 -0400634 } else {
Robert Moorebda663d2005-09-16 16:51:15 -0400635 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 buffer += 1;
637
Robert Moore44f6c012005-04-18 22:49:35 -0400638 /* Set the Priority Byte Definition */
639
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 temp8 = 0;
Robert Moorebda663d2005-09-16 16:51:15 -0400641 temp8 = (u8) ((resource->data.start_dpf.performance_robustness &
642 0x03) << 2);
643 temp8 |= (resource->data.start_dpf.compatibility_priority &
644 0x03);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 *buffer = temp8;
646 }
647
648 buffer += 1;
649
Robert Moore44f6c012005-04-18 22:49:35 -0400650 /* Return the number of bytes consumed in this operation */
651
Len Brown4be44fc2005-08-05 00:44:28 -0400652 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
653 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654}
655
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656/*******************************************************************************
657 *
658 * FUNCTION: acpi_rs_end_depend_fns_stream
659 *
Robert Moorebda663d2005-09-16 16:51:15 -0400660 * PARAMETERS: Resource - Pointer to the resource linked list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 * output_buffer - Pointer to the user's return buffer
662 * bytes_consumed - Pointer to where the number of bytes
663 * used in the output_buffer is returned
664 *
665 * RETURN: Status
666 *
667 * DESCRIPTION: Take the linked list resource structure and fills in the
668 * the appropriate bytes in a byte stream
669 *
670 ******************************************************************************/
671
672acpi_status
Robert Moorebda663d2005-09-16 16:51:15 -0400673acpi_rs_end_depend_fns_stream(struct acpi_resource *resource,
Len Brown4be44fc2005-08-05 00:44:28 -0400674 u8 ** output_buffer, acpi_size * bytes_consumed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675{
Len Brown4be44fc2005-08-05 00:44:28 -0400676 u8 *buffer = *output_buffer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677
Len Brown4be44fc2005-08-05 00:44:28 -0400678 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679
Robert Moorebda663d2005-09-16 16:51:15 -0400680 /* The Descriptor Type field is static */
Robert Moore44f6c012005-04-18 22:49:35 -0400681
Robert Moorebda663d2005-09-16 16:51:15 -0400682 *buffer = ACPI_RDESC_TYPE_END_DEPENDENT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 buffer += 1;
684
Robert Moore44f6c012005-04-18 22:49:35 -0400685 /* Return the number of bytes consumed in this operation */
686
Len Brown4be44fc2005-08-05 00:44:28 -0400687 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
688 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689}