1 /*******************************************************************************
3 * Module Name: rsmisc - Miscellaneous resource descriptors
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
47 #define _COMPONENT ACPI_RESOURCES
48 ACPI_MODULE_NAME("rsmisc")
50 /*******************************************************************************
52 * FUNCTION: acpi_rs_end_tag_resource
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
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
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.
69 ******************************************************************************/
71 acpi_rs_end_tag_resource(u8
* byte_stream_buffer
,
72 acpi_size
* bytes_consumed
,
73 u8
** output_buffer
, acpi_size
* structure_size
)
75 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
76 acpi_size struct_size
= ACPI_RESOURCE_LENGTH
;
78 ACPI_FUNCTION_TRACE("rs_end_tag_resource");
80 /* The number of bytes consumed is static */
84 /* Fill out the structure */
86 output_struct
->id
= ACPI_RSTYPE_END_TAG
;
88 /* Set the Length parameter */
90 output_struct
->length
= 0;
92 /* Return the final size of the structure */
94 *structure_size
= struct_size
;
95 return_ACPI_STATUS(AE_OK
);
98 /*******************************************************************************
100 * FUNCTION: acpi_rs_end_tag_stream
102 * PARAMETERS: linked_list - Pointer to the resource linked list
103 * output_buffer - Pointer to the user's return buffer
104 * bytes_consumed - Pointer to where the number of bytes
105 * used in the output_buffer is returned
109 * DESCRIPTION: Take the linked list resource structure and fills in the
110 * the appropriate bytes in a byte stream
112 ******************************************************************************/
115 acpi_rs_end_tag_stream(struct acpi_resource
*linked_list
,
116 u8
** output_buffer
, acpi_size
* bytes_consumed
)
118 u8
*buffer
= *output_buffer
;
121 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
123 /* The descriptor field is static */
129 * Set the Checksum - zero means that the resource data is treated as if
130 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
137 /* Return the number of bytes consumed in this operation */
139 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
140 return_ACPI_STATUS(AE_OK
);
143 /*******************************************************************************
145 * FUNCTION: acpi_rs_vendor_resource
147 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
149 * bytes_consumed - Pointer to where the number of bytes
150 * consumed the byte_stream_buffer is
152 * output_buffer - Pointer to the return data buffer
153 * structure_size - Pointer to where the number of bytes
154 * in the return data struct is returned
158 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
159 * structure pointed to by the output_buffer. Return the
160 * number of bytes consumed from the byte stream.
162 ******************************************************************************/
165 acpi_rs_vendor_resource(u8
* byte_stream_buffer
,
166 acpi_size
* bytes_consumed
,
167 u8
** output_buffer
, acpi_size
* structure_size
)
169 u8
*buffer
= byte_stream_buffer
;
170 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
174 acpi_size struct_size
=
175 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor
);
177 ACPI_FUNCTION_TRACE("rs_vendor_resource");
179 /* Dereference the Descriptor to find if this is a large or small item. */
184 /* Large Item, point to the length field */
190 ACPI_MOVE_16_TO_16(&temp16
, buffer
);
192 /* Calculate bytes consumed */
194 *bytes_consumed
= (acpi_size
) temp16
+ 3;
196 /* Point to the first vendor byte */
200 /* Small Item, dereference the size */
202 temp16
= (u8
) (*buffer
& 0x07);
204 /* Calculate bytes consumed */
206 *bytes_consumed
= (acpi_size
) temp16
+ 1;
208 /* Point to the first vendor byte */
213 output_struct
->id
= ACPI_RSTYPE_VENDOR
;
214 output_struct
->data
.vendor_specific
.length
= temp16
;
216 for (index
= 0; index
< temp16
; index
++) {
217 output_struct
->data
.vendor_specific
.reserved
[index
] = *buffer
;
222 * In order for the struct_size to fall on a 32-bit boundary,
223 * calculate the length of the vendor string and expand the
224 * struct_size to the next 32-bit boundary.
226 struct_size
+= ACPI_ROUND_UP_to_32_bITS(temp16
);
228 /* Set the Length parameter */
230 output_struct
->length
= (u32
) struct_size
;
232 /* Return the final size of the structure */
234 *structure_size
= struct_size
;
235 return_ACPI_STATUS(AE_OK
);
238 /*******************************************************************************
240 * FUNCTION: acpi_rs_vendor_stream
242 * PARAMETERS: linked_list - Pointer to the resource linked list
243 * output_buffer - Pointer to the user's return buffer
244 * bytes_consumed - Pointer to where the number of bytes
245 * used in the output_buffer is returned
249 * DESCRIPTION: Take the linked list resource structure and fills in the
250 * the appropriate bytes in a byte stream
252 ******************************************************************************/
255 acpi_rs_vendor_stream(struct acpi_resource
*linked_list
,
256 u8
** output_buffer
, acpi_size
* bytes_consumed
)
258 u8
*buffer
= *output_buffer
;
263 ACPI_FUNCTION_TRACE("rs_vendor_stream");
265 /* Dereference the length to find if this is a large or small item. */
267 if (linked_list
->data
.vendor_specific
.length
> 7) {
268 /* Large Item, Set the descriptor field and length bytes */
273 temp16
= (u16
) linked_list
->data
.vendor_specific
.length
;
275 ACPI_MOVE_16_TO_16(buffer
, &temp16
);
278 /* Small Item, Set the descriptor field */
281 temp8
|= (u8
) linked_list
->data
.vendor_specific
.length
;
287 /* Loop through all of the Vendor Specific fields */
289 for (index
= 0; index
< linked_list
->data
.vendor_specific
.length
;
291 temp8
= linked_list
->data
.vendor_specific
.reserved
[index
];
297 /* Return the number of bytes consumed in this operation */
299 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
300 return_ACPI_STATUS(AE_OK
);
303 /*******************************************************************************
305 * FUNCTION: acpi_rs_start_depend_fns_resource
307 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
309 * bytes_consumed - Pointer to where the number of bytes
310 * consumed the byte_stream_buffer is
312 * output_buffer - Pointer to the return data buffer
313 * structure_size - Pointer to where the number of bytes
314 * in the return data struct is returned
318 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
319 * structure pointed to by the output_buffer. Return the
320 * number of bytes consumed from the byte stream.
322 ******************************************************************************/
325 acpi_rs_start_depend_fns_resource(u8
* byte_stream_buffer
,
326 acpi_size
* bytes_consumed
,
328 acpi_size
* structure_size
)
330 u8
*buffer
= byte_stream_buffer
;
331 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
333 acpi_size struct_size
=
334 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf
);
336 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
338 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
342 *bytes_consumed
= (temp8
& 0x01) + 1;
344 output_struct
->id
= ACPI_RSTYPE_START_DPF
;
346 /* Point to Byte 1 if it is used */
348 if (2 == *bytes_consumed
) {
352 /* Check Compatibility priority */
354 output_struct
->data
.start_dpf
.compatibility_priority
=
357 if (3 == output_struct
->data
.start_dpf
.compatibility_priority
) {
358 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE
);
361 /* Check Performance/Robustness preference */
363 output_struct
->data
.start_dpf
.performance_robustness
=
366 if (3 == output_struct
->data
.start_dpf
.performance_robustness
) {
367 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE
);
370 output_struct
->data
.start_dpf
.compatibility_priority
=
371 ACPI_ACCEPTABLE_CONFIGURATION
;
373 output_struct
->data
.start_dpf
.performance_robustness
=
374 ACPI_ACCEPTABLE_CONFIGURATION
;
377 /* Set the Length parameter */
379 output_struct
->length
= (u32
) struct_size
;
381 /* Return the final size of the structure */
383 *structure_size
= struct_size
;
384 return_ACPI_STATUS(AE_OK
);
387 /*******************************************************************************
389 * FUNCTION: acpi_rs_end_depend_fns_resource
391 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
393 * bytes_consumed - Pointer to where the number of bytes
394 * consumed the byte_stream_buffer is
396 * output_buffer - Pointer to the return data buffer
397 * structure_size - Pointer to where the number of bytes
398 * in the return data struct is returned
402 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
403 * structure pointed to by the output_buffer. Return the
404 * number of bytes consumed from the byte stream.
406 ******************************************************************************/
409 acpi_rs_end_depend_fns_resource(u8
* byte_stream_buffer
,
410 acpi_size
* bytes_consumed
,
411 u8
** output_buffer
, acpi_size
* structure_size
)
413 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
414 acpi_size struct_size
= ACPI_RESOURCE_LENGTH
;
416 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
418 /* The number of bytes consumed is static */
422 /* Fill out the structure */
424 output_struct
->id
= ACPI_RSTYPE_END_DPF
;
426 /* Set the Length parameter */
428 output_struct
->length
= (u32
) struct_size
;
430 /* Return the final size of the structure */
432 *structure_size
= struct_size
;
433 return_ACPI_STATUS(AE_OK
);
436 /*******************************************************************************
438 * FUNCTION: acpi_rs_start_depend_fns_stream
440 * PARAMETERS: linked_list - Pointer to the resource linked list
441 * output_buffer - Pointer to the user's return buffer
442 * bytes_consumed - u32 pointer that is filled with
443 * the number of bytes of the
448 * DESCRIPTION: Take the linked list resource structure and fills in the
449 * the appropriate bytes in a byte stream
451 ******************************************************************************/
454 acpi_rs_start_depend_fns_stream(struct acpi_resource
*linked_list
,
455 u8
** output_buffer
, acpi_size
* bytes_consumed
)
457 u8
*buffer
= *output_buffer
;
460 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
463 * The descriptor field is set based upon whether a byte is needed
464 * to contain Priority data.
466 if (ACPI_ACCEPTABLE_CONFIGURATION
==
467 linked_list
->data
.start_dpf
.compatibility_priority
&&
468 ACPI_ACCEPTABLE_CONFIGURATION
==
469 linked_list
->data
.start_dpf
.performance_robustness
) {
475 /* Set the Priority Byte Definition */
479 (u8
) ((linked_list
->data
.start_dpf
.
480 performance_robustness
& 0x03) << 2);
482 (linked_list
->data
.start_dpf
.compatibility_priority
& 0x03);
488 /* Return the number of bytes consumed in this operation */
490 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
491 return_ACPI_STATUS(AE_OK
);
494 /*******************************************************************************
496 * FUNCTION: acpi_rs_end_depend_fns_stream
498 * PARAMETERS: linked_list - Pointer to the resource linked list
499 * output_buffer - Pointer to the user's return buffer
500 * bytes_consumed - Pointer to where the number of bytes
501 * used in the output_buffer is returned
505 * DESCRIPTION: Take the linked list resource structure and fills in the
506 * the appropriate bytes in a byte stream
508 ******************************************************************************/
511 acpi_rs_end_depend_fns_stream(struct acpi_resource
*linked_list
,
512 u8
** output_buffer
, acpi_size
* bytes_consumed
)
514 u8
*buffer
= *output_buffer
;
516 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
518 /* The descriptor field is static */
523 /* Return the number of bytes consumed in this operation */
525 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
526 return_ACPI_STATUS(AE_OK
);