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
13 ******************************************************************************/
16 * Copyright (C) 2000, 2001 R. Byron Moore
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 #define _COMPONENT ACPI_RESOURCES
38 MODULE_NAME ("rsmisc")
41 /*******************************************************************************
43 * FUNCTION: Acpi_rs_end_tag_resource
45 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
47 * Bytes_consumed - u32 pointer that is filled with
48 * the number of bytes consumed from
49 * the Byte_stream_buffer
50 * Output_buffer - Pointer to the user's return buffer
51 * Structure_size - u32 pointer that is filled with
52 * the number of bytes in the filled
55 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
57 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
58 * structure pointed to by the Output_buffer. Return the
59 * number of bytes consumed from the byte stream.
61 ******************************************************************************/
64 acpi_rs_end_tag_resource (
65 u8 *byte_stream_buffer,
70 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
71 u32 struct_size = RESOURCE_LENGTH;
75 * The number of bytes consumed is static
80 * Fill out the structure
82 output_struct->id = end_tag;
85 * Set the Length parameter
87 output_struct->length = 0;
90 * Return the final size of the structure
92 *structure_size = struct_size;
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 - u32 pointer that is filled with
105 * the number of bytes of the
108 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
110 * DESCRIPTION: Take the linked list resource structure and fills in the
111 * the appropriate bytes in a byte stream
113 ******************************************************************************/
116 acpi_rs_end_tag_stream (
117 RESOURCE *linked_list,
121 u8 *buffer = *output_buffer;
126 * The descriptor field is static
132 * Set the Checksum - zero means that the resource data is treated as if
133 * 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);
150 /*******************************************************************************
152 * FUNCTION: Acpi_rs_vendor_resource
154 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
156 * Bytes_consumed - u32 pointer that is filled with
157 * the number of bytes consumed from
158 * the Byte_stream_buffer
159 * Output_buffer - Pointer to the user's return buffer
160 * Structure_size - u32 pointer that is filled with
161 * the number of bytes in the filled
164 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
166 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
167 * structure pointed to by the Output_buffer. Return the
168 * number of bytes consumed from the byte stream.
170 ******************************************************************************/
173 acpi_rs_vendor_resource (
174 u8 *byte_stream_buffer,
179 u8 *buffer = byte_stream_buffer;
180 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
184 u32 struct_size = sizeof (VENDOR_RESOURCE) +
185 RESOURCE_LENGTH_NO_DATA;
189 * Dereference the Descriptor to find if this is a large or small item.
197 /* Point to the length field */
203 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
205 /* Calculate bytes consumed */
207 *bytes_consumed = temp16 + 3;
209 /* Point to the first vendor byte */
219 /* Dereference the size */
221 temp16 = (u8)(*buffer & 0x07);
223 /* Calculate bytes consumed */
225 *bytes_consumed = temp16 + 1;
227 /* Point to the first vendor byte */
232 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 /*******************************************************************************
263 * FUNCTION: Acpi_rs_vendor_stream
265 * PARAMETERS: 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
304 temp16 = (u16) linked_list->data.vendor_specific.length;
306 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
316 * Set the descriptor field
319 temp8 |= linked_list->data.vendor_specific.length;
326 * Loop through all of the Vendor Specific fields
328 for (index = 0; index < linked_list->data.vendor_specific.length; index++) {
329 temp8 = linked_list->data.vendor_specific.reserved[index];
336 * Return the number of bytes consumed in this operation
338 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
339 (NATIVE_UINT) *output_buffer);
345 /*******************************************************************************
347 * FUNCTION: Acpi_rs_start_dependent_functions_resource
349 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
351 * Bytes_consumed - u32 pointer that is filled with
352 * the number of bytes consumed from
353 * the Byte_stream_buffer
354 * Output_buffer - Pointer to the user's return buffer
355 * Structure_size - u32 pointer that is filled with
356 * the number of bytes in the filled
359 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
361 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
362 * structure pointed to by the Output_buffer. Return the
363 * number of bytes consumed from the byte stream.
365 ******************************************************************************/
368 acpi_rs_start_dependent_functions_resource (
369 u8 *byte_stream_buffer,
374 u8 *buffer = byte_stream_buffer;
375 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
378 sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE) +
379 RESOURCE_LENGTH_NO_DATA;
383 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
387 *bytes_consumed = (temp8 & 0x01) + 1;
389 output_struct->id = start_dependent_functions;
392 * Point to Byte 1 if it is used
394 if (2 == *bytes_consumed) {
399 * Check Compatibility priority
401 output_struct->data.start_dependent_functions.compatibility_priority =
404 if (3 == output_struct->data.start_dependent_functions.compatibility_priority) {
405 return (AE_AML_ERROR);
409 * Check Performance/Robustness preference
411 output_struct->data.start_dependent_functions.performance_robustness =
414 if (3 == output_struct->data.start_dependent_functions.performance_robustness) {
415 return (AE_AML_ERROR);
420 output_struct->data.start_dependent_functions.compatibility_priority =
421 ACCEPTABLE_CONFIGURATION;
423 output_struct->data.start_dependent_functions.performance_robustness =
424 ACCEPTABLE_CONFIGURATION;
428 * Set the Length parameter
430 output_struct->length = struct_size;
433 * Return the final size of the structure
435 *structure_size = struct_size;
441 /*******************************************************************************
443 * FUNCTION: Acpi_rs_end_dependent_functions_resource
445 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
447 * Bytes_consumed - u32 pointer that is filled with
448 * the number of bytes consumed from
449 * the Byte_stream_buffer
450 * Output_buffer - Pointer to the user's return buffer
451 * Structure_size - u32 pointer that is filled with
452 * the number of bytes in the filled
455 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
457 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
458 * structure pointed to by the Output_buffer. Return the
459 * number of bytes consumed from the byte stream.
461 ******************************************************************************/
464 acpi_rs_end_dependent_functions_resource (
465 u8 *byte_stream_buffer,
470 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
471 u32 struct_size = RESOURCE_LENGTH;
475 * The number of bytes consumed is static
480 * Fill out the structure
482 output_struct->id = end_dependent_functions;
485 * Set the Length parameter
487 output_struct->length = struct_size;
490 * Return the final size of the structure
492 *structure_size = struct_size;
498 /*******************************************************************************
500 * FUNCTION: Acpi_rs_start_dependent_functions_stream
502 * PARAMETERS: Linked_list - Pointer to the resource linked list
503 * Output_buffer - Pointer to the user's return buffer
504 * Bytes_consumed - u32 pointer that is filled with
505 * the number of bytes of the
508 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
510 * DESCRIPTION: Take the linked list resource structure and fills in the
511 * the appropriate bytes in a byte stream
513 ******************************************************************************/
516 acpi_rs_start_dependent_functions_stream (
517 RESOURCE *linked_list,
521 u8 *buffer = *output_buffer;
526 * The descriptor field is set based upon whether a byte is needed
527 * to contain Priority data.
529 if (ACCEPTABLE_CONFIGURATION ==
530 linked_list->data.start_dependent_functions.compatibility_priority &&
531 ACCEPTABLE_CONFIGURATION ==
532 linked_list->data.start_dependent_functions.performance_robustness) {
540 * Set the Priority Byte Definition
544 ((linked_list->data.start_dependent_functions.performance_robustness &
547 (linked_list->data.start_dependent_functions.compatibility_priority &
556 * Return the number of bytes consumed in this operation
558 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
559 (NATIVE_UINT) *output_buffer);
565 /*******************************************************************************
567 * FUNCTION: Acpi_rs_end_dependent_functions_stream
569 * PARAMETERS: Linked_list - Pointer to the resource linked list
570 * Output_buffer - Pointer to the user's return buffer
571 * Bytes_consumed - u32 pointer that is filled with
572 * the number of bytes of the
575 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
577 * DESCRIPTION: Take the linked list resource structure and fills in the
578 * the appropriate bytes in a byte stream
580 ******************************************************************************/
583 acpi_rs_end_dependent_functions_stream (
584 RESOURCE *linked_list,
589 u8 *buffer = *output_buffer;
593 * The descriptor field is static
599 * Return the number of bytes consumed in this operation
601 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
602 (NATIVE_UINT) *output_buffer);