1 /*******************************************************************************
3 * Module Name: rsmisc - Miscellaneous resource descriptors
6 ******************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #define _COMPONENT ACPI_RESOURCES
31 MODULE_NAME ("rsmisc")
34 /*******************************************************************************
36 * FUNCTION: Acpi_rs_end_tag_resource
38 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
40 * Bytes_consumed - u32 pointer that is filled with
41 * the number of bytes consumed from
42 * the Byte_stream_buffer
43 * Output_buffer - Pointer to the user's return buffer
44 * Structure_size - u32 pointer that is filled with
45 * the number of bytes in the filled
50 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
51 * structure pointed to by the Output_buffer. Return the
52 * number of bytes consumed from the byte stream.
54 ******************************************************************************/
57 acpi_rs_end_tag_resource (
58 u8 *byte_stream_buffer,
63 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
64 u32 struct_size = ACPI_RESOURCE_LENGTH;
67 FUNCTION_TRACE ("Rs_end_tag_resource");
71 * The number of bytes consumed is static
76 * Fill out the structure
78 output_struct->id = ACPI_RSTYPE_END_TAG;
81 * Set the Length parameter
83 output_struct->length = 0;
86 * Return the final size of the structure
88 *structure_size = struct_size;
89 return_ACPI_STATUS (AE_OK);
93 /*******************************************************************************
95 * FUNCTION: Acpi_rs_end_tag_stream
97 * PARAMETERS: Linked_list - Pointer to the resource linked list
98 * Output_buffer - Pointer to the user's return buffer
99 * Bytes_consumed - u32 pointer that is filled with
100 * the number of bytes of the
105 * DESCRIPTION: Take the linked list resource structure and fills in the
106 * the appropriate bytes in a byte stream
108 ******************************************************************************/
111 acpi_rs_end_tag_stream (
112 acpi_resource *linked_list,
116 u8 *buffer = *output_buffer;
120 FUNCTION_TRACE ("Rs_end_tag_stream");
124 * The descriptor field is static
130 * Set the Checksum - zero means that the resource data is treated as if
131 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
139 * Return the number of bytes consumed in this operation
141 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
142 return_ACPI_STATUS (AE_OK);
146 /*******************************************************************************
148 * FUNCTION: Acpi_rs_vendor_resource
150 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
152 * Bytes_consumed - u32 pointer that is filled with
153 * the number of bytes consumed from
154 * the Byte_stream_buffer
155 * Output_buffer - Pointer to the user's return buffer
156 * Structure_size - u32 pointer that is filled with
157 * the number of bytes in the filled
162 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
163 * structure pointed to by the Output_buffer. Return the
164 * number of bytes consumed from the byte stream.
166 ******************************************************************************/
169 acpi_rs_vendor_resource (
170 u8 *byte_stream_buffer,
175 u8 *buffer = byte_stream_buffer;
176 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
180 u32 struct_size = SIZEOF_RESOURCE (acpi_resource_vendor);
183 FUNCTION_TRACE ("Rs_vendor_resource");
187 * Dereference the Descriptor to find if this is a large or small item.
194 * Point to the length field
200 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
202 /* Calculate bytes consumed */
204 *bytes_consumed = temp16 + 3;
206 /* Point to the first vendor byte */
214 * Dereference the size
216 temp16 = (u8)(*buffer & 0x07);
218 /* Calculate bytes consumed */
220 *bytes_consumed = temp16 + 1;
222 /* Point to the first vendor byte */
227 output_struct->id = ACPI_RSTYPE_VENDOR;
228 output_struct->data.vendor_specific.length = temp16;
230 for (index = 0; index < temp16; index++) {
231 output_struct->data.vendor_specific.reserved[index] = *buffer;
236 * In order for the Struct_size to fall on a 32-bit boundary,
237 * calculate the length of the vendor string and expand the
238 * Struct_size to the next 32-bit boundary.
240 struct_size += ROUND_UP_TO_32_bITS (temp16);
243 * Set the Length parameter
245 output_struct->length = struct_size;
248 * Return the final size of the structure
250 *structure_size = struct_size;
251 return_ACPI_STATUS (AE_OK);
255 /*******************************************************************************
257 * FUNCTION: Acpi_rs_vendor_stream
259 * PARAMETERS: Linked_list - Pointer to the resource linked list
260 * Output_buffer - Pointer to the user's return buffer
261 * Bytes_consumed - u32 pointer that is filled with
262 * the number of bytes of the
267 * DESCRIPTION: Take the linked list resource structure and fills in the
268 * the appropriate bytes in a byte stream
270 ******************************************************************************/
273 acpi_rs_vendor_stream (
274 acpi_resource *linked_list,
278 u8 *buffer = *output_buffer;
284 FUNCTION_TRACE ("Rs_vendor_stream");
288 * Dereference the length to find if this is a large or small item.
290 if(linked_list->data.vendor_specific.length > 7) {
293 * Set the descriptor field and length bytes
298 temp16 = (u16) linked_list->data.vendor_specific.length;
300 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
307 * Set the descriptor field
310 temp8 |= linked_list->data.vendor_specific.length;
317 * Loop through all of the Vendor Specific fields
319 for (index = 0; index < linked_list->data.vendor_specific.length; index++) {
320 temp8 = linked_list->data.vendor_specific.reserved[index];
327 * Return the number of bytes consumed in this operation
329 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
330 return_ACPI_STATUS (AE_OK);
334 /*******************************************************************************
336 * FUNCTION: Acpi_rs_start_dependent_functions_resource
338 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
340 * Bytes_consumed - u32 pointer that is filled with
341 * the number of bytes consumed from
342 * the Byte_stream_buffer
343 * Output_buffer - Pointer to the user's return buffer
344 * Structure_size - u32 pointer that is filled with
345 * the number of bytes in the filled
350 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
351 * structure pointed to by the Output_buffer. Return the
352 * number of bytes consumed from the byte stream.
354 ******************************************************************************/
357 acpi_rs_start_dependent_functions_resource (
358 u8 *byte_stream_buffer,
363 u8 *buffer = byte_stream_buffer;
364 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
366 u32 struct_size = SIZEOF_RESOURCE (acpi_resource_start_dpf);
369 FUNCTION_TRACE ("Rs_start_dependent_functions_resource");
373 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
377 *bytes_consumed = (temp8 & 0x01) + 1;
379 output_struct->id = ACPI_RSTYPE_START_DPF;
382 * Point to Byte 1 if it is used
384 if (2 == *bytes_consumed) {
389 * Check Compatibility priority
391 output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03;
393 if (3 == output_struct->data.start_dpf.compatibility_priority) {
394 return_ACPI_STATUS (AE_AML_ERROR);
398 * Check Performance/Robustness preference
400 output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03;
402 if (3 == output_struct->data.start_dpf.performance_robustness) {
403 return_ACPI_STATUS (AE_AML_ERROR);
408 output_struct->data.start_dpf.compatibility_priority =
409 ACCEPTABLE_CONFIGURATION;
411 output_struct->data.start_dpf.performance_robustness =
412 ACCEPTABLE_CONFIGURATION;
416 * Set the Length parameter
418 output_struct->length = struct_size;
421 * Return the final size of the structure
423 *structure_size = struct_size;
424 return_ACPI_STATUS (AE_OK);
428 /*******************************************************************************
430 * FUNCTION: Acpi_rs_end_dependent_functions_resource
432 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
434 * Bytes_consumed - u32 pointer that is filled with
435 * the number of bytes consumed from
436 * the Byte_stream_buffer
437 * Output_buffer - Pointer to the user's return buffer
438 * Structure_size - u32 pointer that is filled with
439 * the number of bytes in the filled
444 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
445 * structure pointed to by the Output_buffer. Return the
446 * number of bytes consumed from the byte stream.
448 ******************************************************************************/
451 acpi_rs_end_dependent_functions_resource (
452 u8 *byte_stream_buffer,
457 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
458 u32 struct_size = ACPI_RESOURCE_LENGTH;
461 FUNCTION_TRACE ("Rs_end_dependent_functions_resource");
465 * The number of bytes consumed is static
470 * Fill out the structure
472 output_struct->id = ACPI_RSTYPE_END_DPF;
475 * Set the Length parameter
477 output_struct->length = struct_size;
480 * Return the final size of the structure
482 *structure_size = struct_size;
483 return_ACPI_STATUS (AE_OK);
487 /*******************************************************************************
489 * FUNCTION: Acpi_rs_start_dependent_functions_stream
491 * PARAMETERS: Linked_list - Pointer to the resource linked list
492 * Output_buffer - Pointer to the user's return buffer
493 * Bytes_consumed - u32 pointer that is filled with
494 * the number of bytes of the
499 * DESCRIPTION: Take the linked list resource structure and fills in the
500 * the appropriate bytes in a byte stream
502 ******************************************************************************/
505 acpi_rs_start_dependent_functions_stream (
506 acpi_resource *linked_list,
510 u8 *buffer = *output_buffer;
514 FUNCTION_TRACE ("Rs_start_dependent_functions_stream");
518 * The descriptor field is set based upon whether a byte is needed
519 * to contain Priority data.
521 if (ACCEPTABLE_CONFIGURATION ==
522 linked_list->data.start_dpf.compatibility_priority &&
523 ACCEPTABLE_CONFIGURATION ==
524 linked_list->data.start_dpf.performance_robustness) {
532 * Set the Priority Byte Definition
535 temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness &
537 temp8 |= (linked_list->data.start_dpf.compatibility_priority &
545 * Return the number of bytes consumed in this operation
547 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
548 return_ACPI_STATUS (AE_OK);
552 /*******************************************************************************
554 * FUNCTION: Acpi_rs_end_dependent_functions_stream
556 * PARAMETERS: Linked_list - Pointer to the resource linked list
557 * Output_buffer - Pointer to the user's return buffer
558 * Bytes_consumed - u32 pointer that is filled with
559 * the number of bytes of the
564 * DESCRIPTION: Take the linked list resource structure and fills in the
565 * the appropriate bytes in a byte stream
567 ******************************************************************************/
570 acpi_rs_end_dependent_functions_stream (
571 acpi_resource *linked_list,
576 u8 *buffer = *output_buffer;
579 FUNCTION_TRACE ("Rs_end_dependent_functions_stream");
583 * The descriptor field is static
589 * Return the number of bytes consumed in this operation
591 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
592 return_ACPI_STATUS (AE_OK);