1 /******************************************************************************
3 * Module Name: rsmisc - Acpi_rs_end_tag_resource
4 * Acpi_rs_end_tag_stream
5 * Acpi_rs_vendor_resource
6 * Acpi_rs_vendor_stream
7 * Acpi_rs_start_dependent_functions_resource
8 * Acpi_rs_end_dependent_functions_resource
9 * Acpi_rs_start_dependent_functions_stream
10 * Acpi_rs_end_dependent_functions_stream
12 *****************************************************************************/
15 * Copyright (C) 2000 R. Byron Moore
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #define _COMPONENT RESOURCE_MANAGER
36 MODULE_NAME ("rsmisc");
39 /***************************************************************************
40 * FUNCTION: Acpi_rs_end_tag_resource
43 * Byte_stream_buffer - Pointer to the resource input byte
45 * Bytes_consumed - u32 pointer that is filled with
46 * the number of bytes consumed from
47 * the Byte_stream_buffer
48 * Output_buffer - Pointer to the user's return buffer
49 * Structure_size - u32 pointer that is filled with
50 * the number of bytes in the filled
53 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
55 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
56 * structure pointed to by the Output_buffer. Return the
57 * number of bytes consumed from the byte stream.
59 ***************************************************************************/
62 acpi_rs_end_tag_resource (
63 u8
*byte_stream_buffer
,
68 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
69 u32 struct_size
= RESOURCE_LENGTH
;
73 * The number of bytes consumed is static
78 * Fill out the structure
80 output_struct
->id
= end_tag
;
83 * Set the Length parameter
85 output_struct
->length
= 0;
88 * Return the final size of the structure
90 *structure_size
= struct_size
;
96 /***************************************************************************
97 * FUNCTION: Acpi_rs_end_tag_stream
100 * Linked_list - Pointer to the resource linked list
101 * Output_buffer - Pointer to the user's return buffer
102 * Bytes_consumed - u32 pointer that is filled with
103 * the number of bytes of the
106 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
108 * DESCRIPTION: Take the linked list resource structure and fills in the
109 * the appropriate bytes in a byte stream
111 ***************************************************************************/
114 acpi_rs_end_tag_stream (
115 RESOURCE
*linked_list
,
119 u8
*buffer
= *output_buffer
;
124 * The descriptor field is static
131 * Set the Checksum - zero means that the resource data is treated as if
132 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
141 * Return the number of bytes consumed in this operation
143 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
144 (NATIVE_UINT
) *output_buffer
);
149 /***************************************************************************
150 * FUNCTION: Acpi_rs_vendor_resource
153 * Byte_stream_buffer - Pointer to the resource input byte
155 * Bytes_consumed - u32 pointer that is filled with
156 * the number of bytes consumed from
157 * the Byte_stream_buffer
158 * Output_buffer - Pointer to the user's return buffer
159 * Structure_size - u32 pointer that is filled with
160 * the number of bytes in the filled
163 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
165 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
166 * structure pointed to by the Output_buffer. Return the
167 * number of bytes consumed from the byte stream.
169 ***************************************************************************/
172 acpi_rs_vendor_resource (
173 u8
*byte_stream_buffer
,
178 u8
*buffer
= byte_stream_buffer
;
179 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
183 u32 struct_size
= sizeof (VENDOR_RESOURCE
) +
184 RESOURCE_LENGTH_NO_DATA
;
188 * Dereference the Descriptor to find if this is a large or small item.
196 /* Point to the length field */
202 temp16
= *(u16
*)buffer
;
204 /* Calculate bytes consumed */
206 *bytes_consumed
= temp16
+ 3;
208 /* Point to the first vendor byte */
218 /* Dereference the size */
220 temp16
= (u8
)(*buffer
& 0x07);
222 /* Calculate bytes consumed */
224 *bytes_consumed
= temp16
+ 1;
226 /* Point to the first vendor byte */
231 output_struct
->id
= vendor_specific
;
233 output_struct
->data
.vendor_specific
.length
= temp16
;
235 for (index
= 0; index
< temp16
; index
++) {
236 output_struct
->data
.vendor_specific
.reserved
[index
] = *buffer
;
241 * In order for the Struct_size to fall on a 32-bit boundry,
242 * calculate the length of the vendor string and expand the
243 * Struct_size to the next 32-bit boundry.
245 struct_size
+= ROUND_UP_TO_32_bITS (temp16
);
248 * Set the Length parameter
250 output_struct
->length
= struct_size
;
253 * Return the final size of the structure
255 *structure_size
= struct_size
;
261 /***************************************************************************
262 * FUNCTION: Acpi_rs_vendor_stream
265 * Linked_list - Pointer to the resource linked list
266 * Output_buffer - Pointer to the user's return buffer
267 * Bytes_consumed - u32 pointer that is filled with
268 * the number of bytes of the
271 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
273 * DESCRIPTION: Take the linked list resource structure and fills in the
274 * the appropriate bytes in a byte stream
276 ***************************************************************************/
279 acpi_rs_vendor_stream (
280 RESOURCE
*linked_list
,
284 u8
*buffer
= *output_buffer
;
291 * Dereference the length to find if this is a large or small item.
294 if(linked_list
->data
.vendor_specific
.length
> 7) {
299 * Set the descriptor field and length bytes
305 temp16
= (u16
) linked_list
->data
.vendor_specific
.length
;
307 *(u16
*)buffer
= temp16
;
318 * Set the descriptor field
322 temp8
|= linked_list
->data
.vendor_specific
.length
;
330 * Loop through all of the Vendor Specific fields
332 for (index
= 0; index
< linked_list
->data
.vendor_specific
.length
; index
++) {
333 temp8
= linked_list
->data
.vendor_specific
.reserved
[index
];
339 * Return the number of bytes consumed in this operation
341 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
342 (NATIVE_UINT
) *output_buffer
);
347 /***************************************************************************
348 * FUNCTION: Acpi_rs_start_dependent_functions_resource
351 * Byte_stream_buffer - Pointer to the resource input byte
353 * Bytes_consumed - u32 pointer that is filled with
354 * the number of bytes consumed from
355 * the Byte_stream_buffer
356 * Output_buffer - Pointer to the user's return buffer
357 * Structure_size - u32 pointer that is filled with
358 * the number of bytes in the filled
361 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
363 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
364 * structure pointed to by the Output_buffer. Return the
365 * number of bytes consumed from the byte stream.
367 ***************************************************************************/
370 acpi_rs_start_dependent_functions_resource (
371 u8
*byte_stream_buffer
,
376 u8
*buffer
= byte_stream_buffer
;
377 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
380 sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE
) +
381 RESOURCE_LENGTH_NO_DATA
;
385 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
389 *bytes_consumed
= (temp8
& 0x01) + 1;
391 output_struct
->id
= start_dependent_functions
;
394 * Point to Byte 1 if it is used
396 if (2 == *bytes_consumed
) {
401 * Check Compatibility priority
403 output_struct
->data
.start_dependent_functions
.compatibility_priority
=
406 if (3 == output_struct
->data
.start_dependent_functions
.compatibility_priority
) {
411 * Check Performance/Robustness preference
413 output_struct
->data
.start_dependent_functions
.performance_robustness
=
416 if (3 == output_struct
->data
.start_dependent_functions
.performance_robustness
) {
422 output_struct
->data
.start_dependent_functions
.compatibility_priority
=
423 ACCEPTABLE_CONFIGURATION
;
425 output_struct
->data
.start_dependent_functions
.performance_robustness
=
426 ACCEPTABLE_CONFIGURATION
;
430 * Set the Length parameter
432 output_struct
->length
= struct_size
;
435 * Return the final size of the structure
437 *structure_size
= struct_size
;
443 /***************************************************************************
444 * FUNCTION: Acpi_rs_end_dependent_functions_resource
447 * Byte_stream_buffer - Pointer to the resource input byte
449 * Bytes_consumed - u32 pointer that is filled with
450 * the number of bytes consumed from
451 * the Byte_stream_buffer
452 * Output_buffer - Pointer to the user's return buffer
453 * Structure_size - u32 pointer that is filled with
454 * the number of bytes in the filled
457 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
459 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
460 * structure pointed to by the Output_buffer. Return the
461 * number of bytes consumed from the byte stream.
463 ***************************************************************************/
466 acpi_rs_end_dependent_functions_resource (
467 u8
*byte_stream_buffer
,
472 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
473 u32 struct_size
= RESOURCE_LENGTH
;
477 * The number of bytes consumed is static
482 * Fill out the structure
484 output_struct
->id
= end_dependent_functions
;
487 * Set the Length parameter
489 output_struct
->length
= struct_size
;
492 * Return the final size of the structure
494 *structure_size
= struct_size
;
500 /***************************************************************************
501 * FUNCTION: Acpi_rs_start_dependent_functions_stream
504 * Linked_list - Pointer to the resource linked list
505 * Output_buffer - Pointer to the user's return buffer
506 * Bytes_consumed - u32 pointer that is filled with
507 * the number of bytes of the
510 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
512 * DESCRIPTION: Take the linked list resource structure and fills in the
513 * the appropriate bytes in a byte stream
515 ***************************************************************************/
517 acpi_rs_start_dependent_functions_stream (
518 RESOURCE
*linked_list
,
522 u8
*buffer
= *output_buffer
;
527 * The descriptor field is set based upon whether a byte is needed
528 * to contain Priority data.
530 if (ACCEPTABLE_CONFIGURATION
==
531 linked_list
->data
.start_dependent_functions
.compatibility_priority
&&
532 ACCEPTABLE_CONFIGURATION
==
533 linked_list
->data
.start_dependent_functions
.performance_robustness
)
543 * Set the Priority Byte Definition
548 ((linked_list
->data
.start_dependent_functions
.performance_robustness
&
552 (linked_list
->data
.start_dependent_functions
.compatibility_priority
&
561 * Return the number of bytes consumed in this operation
563 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
564 (NATIVE_UINT
) *output_buffer
);
570 /***************************************************************************
571 * FUNCTION: Acpi_rs_end_dependent_functions_stream
574 * Linked_list - Pointer to the resource linked list
575 * Output_buffer - Pointer to the user's return buffer
576 * Bytes_consumed - u32 pointer that is filled with
577 * the number of bytes of the
580 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
582 * DESCRIPTION: Take the linked list resource structure and fills in the
583 * the appropriate bytes in a byte stream
585 ***************************************************************************/
588 acpi_rs_end_dependent_functions_stream (
589 RESOURCE
*linked_list
,
594 u8
*buffer
= *output_buffer
;
598 * The descriptor field is static
605 * Return the number of bytes consumed in this operation
607 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
608 (NATIVE_UINT
) *output_buffer
);