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.
45 #include <acpi/acpi.h>
46 #include <acpi/acresrc.h>
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsmisc")
52 /*******************************************************************************
54 * FUNCTION: acpi_rs_end_tag_resource
56 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
58 * bytes_consumed - Pointer to where the number of bytes
59 * consumed the byte_stream_buffer is
61 * output_buffer - Pointer to the return data buffer
62 * structure_size - Pointer to where the number of bytes
63 * in the return data struct is returned
67 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
68 * structure pointed to by the output_buffer. Return the
69 * number of bytes consumed from the byte stream.
71 ******************************************************************************/
74 acpi_rs_end_tag_resource (
75 u8
*byte_stream_buffer
,
76 acpi_size
*bytes_consumed
,
78 acpi_size
*structure_size
)
80 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
81 acpi_size struct_size
= ACPI_RESOURCE_LENGTH
;
84 ACPI_FUNCTION_TRACE ("rs_end_tag_resource");
88 * The number of bytes consumed is static
93 * Fill out the structure
95 output_struct
->id
= ACPI_RSTYPE_END_TAG
;
98 * Set the Length parameter
100 output_struct
->length
= 0;
103 * Return the final size of the structure
105 *structure_size
= struct_size
;
106 return_ACPI_STATUS (AE_OK
);
110 /*******************************************************************************
112 * FUNCTION: acpi_rs_end_tag_stream
114 * PARAMETERS: linked_list - Pointer to the resource linked list
115 * output_buffer - Pointer to the user's return buffer
116 * bytes_consumed - Pointer to where the number of bytes
117 * used in the output_buffer is returned
121 * DESCRIPTION: Take the linked list resource structure and fills in the
122 * the appropriate bytes in a byte stream
124 ******************************************************************************/
127 acpi_rs_end_tag_stream (
128 struct acpi_resource
*linked_list
,
130 acpi_size
*bytes_consumed
)
132 u8
*buffer
= *output_buffer
;
136 ACPI_FUNCTION_TRACE ("rs_end_tag_stream");
140 * The descriptor field is static
146 * Set the Checksum - zero means that the resource data is treated as if
147 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
155 * Return the number of bytes consumed in this operation
157 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
158 return_ACPI_STATUS (AE_OK
);
162 /*******************************************************************************
164 * FUNCTION: acpi_rs_vendor_resource
166 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
168 * bytes_consumed - Pointer to where the number of bytes
169 * consumed the byte_stream_buffer is
171 * output_buffer - Pointer to the return data buffer
172 * structure_size - Pointer to where the number of bytes
173 * in the return data struct is returned
177 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
178 * structure pointed to by the output_buffer. Return the
179 * number of bytes consumed from the byte stream.
181 ******************************************************************************/
184 acpi_rs_vendor_resource (
185 u8
*byte_stream_buffer
,
186 acpi_size
*bytes_consumed
,
188 acpi_size
*structure_size
)
190 u8
*buffer
= byte_stream_buffer
;
191 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
195 acpi_size struct_size
= ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor
);
198 ACPI_FUNCTION_TRACE ("rs_vendor_resource");
202 * Dereference the Descriptor to find if this is a large or small item.
208 * Large Item, point to the length field
214 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
216 /* Calculate bytes consumed */
218 *bytes_consumed
= (acpi_size
) temp16
+ 3;
220 /* Point to the first vendor byte */
226 * Small Item, dereference the size
228 temp16
= (u8
)(*buffer
& 0x07);
230 /* Calculate bytes consumed */
232 *bytes_consumed
= (acpi_size
) temp16
+ 1;
234 /* Point to the first vendor byte */
239 output_struct
->id
= ACPI_RSTYPE_VENDOR
;
240 output_struct
->data
.vendor_specific
.length
= temp16
;
242 for (index
= 0; index
< temp16
; index
++) {
243 output_struct
->data
.vendor_specific
.reserved
[index
] = *buffer
;
248 * In order for the struct_size to fall on a 32-bit boundary,
249 * calculate the length of the vendor string and expand the
250 * struct_size to the next 32-bit boundary.
252 struct_size
+= ACPI_ROUND_UP_to_32_bITS (temp16
);
255 * Set the Length parameter
257 output_struct
->length
= (u32
) struct_size
;
260 * Return the final size of the structure
262 *structure_size
= struct_size
;
263 return_ACPI_STATUS (AE_OK
);
267 /*******************************************************************************
269 * FUNCTION: acpi_rs_vendor_stream
271 * PARAMETERS: linked_list - Pointer to the resource linked list
272 * output_buffer - Pointer to the user's return buffer
273 * bytes_consumed - Pointer to where the number of bytes
274 * used in the output_buffer is returned
278 * DESCRIPTION: Take the linked list resource structure and fills in the
279 * the appropriate bytes in a byte stream
281 ******************************************************************************/
284 acpi_rs_vendor_stream (
285 struct acpi_resource
*linked_list
,
287 acpi_size
*bytes_consumed
)
289 u8
*buffer
= *output_buffer
;
295 ACPI_FUNCTION_TRACE ("rs_vendor_stream");
299 * Dereference the length to find if this is a large or small item.
301 if(linked_list
->data
.vendor_specific
.length
> 7) {
303 * Large Item, Set the descriptor field and length bytes
308 temp16
= (u16
) linked_list
->data
.vendor_specific
.length
;
310 ACPI_MOVE_16_TO_16 (buffer
, &temp16
);
315 * Small Item, Set the descriptor field
318 temp8
|= (u8
) linked_list
->data
.vendor_specific
.length
;
325 * Loop through all of the Vendor Specific fields
327 for (index
= 0; index
< linked_list
->data
.vendor_specific
.length
; index
++) {
328 temp8
= linked_list
->data
.vendor_specific
.reserved
[index
];
335 * Return the number of bytes consumed in this operation
337 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
338 return_ACPI_STATUS (AE_OK
);
342 /*******************************************************************************
344 * FUNCTION: acpi_rs_start_depend_fns_resource
346 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
348 * bytes_consumed - Pointer to where the number of bytes
349 * consumed the byte_stream_buffer is
351 * output_buffer - Pointer to the return data buffer
352 * structure_size - Pointer to where the number of bytes
353 * in the return data struct is returned
357 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
358 * structure pointed to by the output_buffer. Return the
359 * number of bytes consumed from the byte stream.
361 ******************************************************************************/
364 acpi_rs_start_depend_fns_resource (
365 u8
*byte_stream_buffer
,
366 acpi_size
*bytes_consumed
,
368 acpi_size
*structure_size
)
370 u8
*buffer
= byte_stream_buffer
;
371 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
373 acpi_size struct_size
= ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf
);
376 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource");
380 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
384 *bytes_consumed
= (temp8
& 0x01) + 1;
386 output_struct
->id
= ACPI_RSTYPE_START_DPF
;
389 * Point to Byte 1 if it is used
391 if (2 == *bytes_consumed
) {
396 * Check Compatibility priority
398 output_struct
->data
.start_dpf
.compatibility_priority
= temp8
& 0x03;
400 if (3 == output_struct
->data
.start_dpf
.compatibility_priority
) {
401 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE
);
405 * Check Performance/Robustness preference
407 output_struct
->data
.start_dpf
.performance_robustness
= (temp8
>> 2) & 0x03;
409 if (3 == output_struct
->data
.start_dpf
.performance_robustness
) {
410 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE
);
414 output_struct
->data
.start_dpf
.compatibility_priority
=
415 ACPI_ACCEPTABLE_CONFIGURATION
;
417 output_struct
->data
.start_dpf
.performance_robustness
=
418 ACPI_ACCEPTABLE_CONFIGURATION
;
422 * Set the Length parameter
424 output_struct
->length
= (u32
) struct_size
;
427 * Return the final size of the structure
429 *structure_size
= struct_size
;
430 return_ACPI_STATUS (AE_OK
);
434 /*******************************************************************************
436 * FUNCTION: acpi_rs_end_depend_fns_resource
438 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
440 * bytes_consumed - Pointer to where the number of bytes
441 * consumed the byte_stream_buffer is
443 * output_buffer - Pointer to the return data buffer
444 * structure_size - Pointer to where the number of bytes
445 * in the return data struct is returned
449 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
450 * structure pointed to by the output_buffer. Return the
451 * number of bytes consumed from the byte stream.
453 ******************************************************************************/
456 acpi_rs_end_depend_fns_resource (
457 u8
*byte_stream_buffer
,
458 acpi_size
*bytes_consumed
,
460 acpi_size
*structure_size
)
462 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
463 acpi_size struct_size
= ACPI_RESOURCE_LENGTH
;
466 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource");
470 * The number of bytes consumed is static
475 * Fill out the structure
477 output_struct
->id
= ACPI_RSTYPE_END_DPF
;
480 * Set the Length parameter
482 output_struct
->length
= (u32
) struct_size
;
485 * Return the final size of the structure
487 *structure_size
= struct_size
;
488 return_ACPI_STATUS (AE_OK
);
492 /*******************************************************************************
494 * FUNCTION: acpi_rs_start_depend_fns_stream
496 * PARAMETERS: linked_list - Pointer to the resource linked list
497 * output_buffer - Pointer to the user's return buffer
498 * bytes_consumed - u32 pointer that is filled with
499 * the number of bytes of the
504 * DESCRIPTION: Take the linked list resource structure and fills in the
505 * the appropriate bytes in a byte stream
507 ******************************************************************************/
510 acpi_rs_start_depend_fns_stream (
511 struct acpi_resource
*linked_list
,
513 acpi_size
*bytes_consumed
)
515 u8
*buffer
= *output_buffer
;
519 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_stream");
523 * The descriptor field is set based upon whether a byte is needed
524 * to contain Priority data.
526 if (ACPI_ACCEPTABLE_CONFIGURATION
==
527 linked_list
->data
.start_dpf
.compatibility_priority
&&
528 ACPI_ACCEPTABLE_CONFIGURATION
==
529 linked_list
->data
.start_dpf
.performance_robustness
) {
537 * Set the Priority Byte Definition
540 temp8
= (u8
) ((linked_list
->data
.start_dpf
.performance_robustness
&
542 temp8
|= (linked_list
->data
.start_dpf
.compatibility_priority
&
550 * Return the number of bytes consumed in this operation
552 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
553 return_ACPI_STATUS (AE_OK
);
557 /*******************************************************************************
559 * FUNCTION: acpi_rs_end_depend_fns_stream
561 * PARAMETERS: linked_list - Pointer to the resource linked list
562 * output_buffer - Pointer to the user's return buffer
563 * bytes_consumed - Pointer to where the number of bytes
564 * used in the output_buffer is returned
568 * DESCRIPTION: Take the linked list resource structure and fills in the
569 * the appropriate bytes in a byte stream
571 ******************************************************************************/
574 acpi_rs_end_depend_fns_stream (
575 struct acpi_resource
*linked_list
,
577 acpi_size
*bytes_consumed
)
579 u8
*buffer
= *output_buffer
;
582 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream");
586 * The descriptor field is static
592 * Return the number of bytes consumed in this operation
594 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
595 return_ACPI_STATUS (AE_OK
);