1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
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("rsaddr")
50 /* Local prototypes */
52 acpi_rs_decode_general_flags(union acpi_resource_data
*resource
, u8 flags
);
54 static u8
acpi_rs_encode_general_flags(union acpi_resource_data
*resource
);
57 acpi_rs_decode_specific_flags(union acpi_resource_data
*resource
, u8 flags
);
59 static u8
acpi_rs_encode_specific_flags(union acpi_resource_data
*resource
);
61 /*******************************************************************************
63 * FUNCTION: acpi_rs_decode_general_flags
65 * PARAMETERS: Resource - Address resource data struct
66 * Flags - Actual flag byte
68 * RETURN: Decoded flag bits in resource struct
70 * DESCRIPTION: Decode a general flag byte to an address resource struct
72 ******************************************************************************/
75 acpi_rs_decode_general_flags(union acpi_resource_data
*resource
, u8 flags
)
77 ACPI_FUNCTION_ENTRY();
79 /* Producer / Consumer - flag bit[0] */
81 resource
->address
.producer_consumer
= (u32
) (flags
& 0x01);
83 /* Decode (_DEC) - flag bit[1] */
85 resource
->address
.decode
= (u32
) ((flags
>> 1) & 0x01);
87 /* Min Address Fixed (_MIF) - flag bit[2] */
89 resource
->address
.min_address_fixed
= (u32
) ((flags
>> 2) & 0x01);
91 /* Max Address Fixed (_MAF) - flag bit[3] */
93 resource
->address
.max_address_fixed
= (u32
) ((flags
>> 3) & 0x01);
96 /*******************************************************************************
98 * FUNCTION: acpi_rs_encode_general_flags
100 * PARAMETERS: Resource - Address resource data struct
102 * RETURN: Encoded general flag byte
104 * DESCRIPTION: Construct a general flag byte from an address resource struct
106 ******************************************************************************/
108 static u8
acpi_rs_encode_general_flags(union acpi_resource_data
*resource
)
112 ACPI_FUNCTION_ENTRY();
114 /* Producer / Consumer - flag bit[0] */
116 flags
= (u8
) (resource
->address
.producer_consumer
& 0x01);
118 /* Decode (_DEC) - flag bit[1] */
120 flags
|= (u8
) ((resource
->address
.decode
& 0x01) << 1);
122 /* Min Address Fixed (_MIF) - flag bit[2] */
124 flags
|= (u8
) ((resource
->address
.min_address_fixed
& 0x01) << 2);
126 /* Max Address Fixed (_MAF) - flag bit[3] */
128 flags
|= (u8
) ((resource
->address
.max_address_fixed
& 0x01) << 3);
133 /*******************************************************************************
135 * FUNCTION: acpi_rs_decode_specific_flags
137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Actual flag byte
140 * RETURN: Decoded flag bits in attribute struct
142 * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
143 * Type-specific flags are only defined for the Memory and IO
146 ******************************************************************************/
149 acpi_rs_decode_specific_flags(union acpi_resource_data
*resource
, u8 flags
)
151 ACPI_FUNCTION_ENTRY();
153 if (resource
->address
.resource_type
== ACPI_MEMORY_RANGE
) {
154 /* Write Status (_RW) - flag bit[0] */
156 resource
->address
.attribute
.memory
.read_write_attribute
=
157 (u16
) (flags
& 0x01);
159 /* Memory Attributes (_MEM) - flag bits[2:1] */
161 resource
->address
.attribute
.memory
.cache_attribute
=
162 (u16
) ((flags
>> 1) & 0x03);
163 } else if (resource
->address
.resource_type
== ACPI_IO_RANGE
) {
164 /* Ranges (_RNG) - flag bits[1:0] */
166 resource
->address
.attribute
.io
.range_attribute
=
167 (u16
) (flags
& 0x03);
169 /* Translations (_TTP and _TRS) - flag bits[5:4] */
171 resource
->address
.attribute
.io
.translation_attribute
=
172 (u16
) ((flags
>> 4) & 0x03);
176 /*******************************************************************************
178 * FUNCTION: acpi_rs_encode_specific_flags
180 * PARAMETERS: Resource - Address resource data struct
182 * RETURN: Encoded type-specific flag byte
184 * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
185 * Type-specific flags are only defined for the Memory and IO
188 ******************************************************************************/
190 static u8
acpi_rs_encode_specific_flags(union acpi_resource_data
*resource
)
194 ACPI_FUNCTION_ENTRY();
196 if (resource
->address
.resource_type
== ACPI_MEMORY_RANGE
) {
197 /* Write Status (_RW) - flag bit[0] */
200 (resource
->address
.attribute
.memory
.
201 read_write_attribute
& 0x01);
203 /* Memory Attributes (_MEM) - flag bits[2:1] */
206 ((resource
->address
.attribute
.memory
.
207 cache_attribute
& 0x03) << 1);
208 } else if (resource
->address
.resource_type
== ACPI_IO_RANGE
) {
209 /* Ranges (_RNG) - flag bits[1:0] */
212 (resource
->address
.attribute
.io
.range_attribute
& 0x03);
214 /* Translations (_TTP and _TRS) - flag bits[5:4] */
217 ((resource
->address
.attribute
.io
.
218 translation_attribute
& 0x03) << 4);
224 /*******************************************************************************
226 * FUNCTION: acpi_rs_address16_resource
228 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
230 * bytes_consumed - Pointer to where the number of bytes
231 * consumed the byte_stream_buffer is
233 * output_buffer - Pointer to the return data buffer
234 * structure_size - Pointer to where the number of bytes
235 * in the return data struct is returned
239 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
240 * structure pointed to by the output_buffer. Return the
241 * number of bytes consumed from the byte stream.
243 ******************************************************************************/
246 acpi_rs_address16_resource(u8
* byte_stream_buffer
,
247 acpi_size
* bytes_consumed
,
248 u8
** output_buffer
, acpi_size
* structure_size
)
254 u8
*buffer
= byte_stream_buffer
;
255 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
256 acpi_size struct_size
=
257 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16
);
259 ACPI_FUNCTION_TRACE("rs_address16_resource");
261 /* Get the Descriptor Length field */
264 ACPI_MOVE_16_TO_16(&temp16
, buffer
);
266 /* Validate minimum descriptor length */
269 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH
);
272 *bytes_consumed
= temp16
+ 3;
273 output_struct
->type
= ACPI_RSTYPE_ADDRESS16
;
275 /* Get the Resource Type (Byte3) */
280 /* Values 0-2 and 0xC0-0xFF are valid */
282 if ((temp8
> 2) && (temp8
< 0xC0)) {
283 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE
);
286 output_struct
->data
.address16
.resource_type
= temp8
;
288 /* Get the General Flags (Byte4) */
291 acpi_rs_decode_general_flags(&output_struct
->data
, *buffer
);
293 /* Get the Type Specific Flags (Byte5) */
296 acpi_rs_decode_specific_flags(&output_struct
->data
, *buffer
);
298 /* Get Granularity (Bytes 6-7) */
301 ACPI_MOVE_16_TO_32(&output_struct
->data
.address16
.granularity
, buffer
);
303 /* Get min_address_range (Bytes 8-9) */
306 ACPI_MOVE_16_TO_32(&output_struct
->data
.address16
.min_address_range
,
309 /* Get max_address_range (Bytes 10-11) */
312 ACPI_MOVE_16_TO_32(&output_struct
->data
.address16
.max_address_range
,
315 /* Get address_translation_offset (Bytes 12-13) */
318 ACPI_MOVE_16_TO_32(&output_struct
->data
.address16
.
319 address_translation_offset
, buffer
);
321 /* Get address_length (Bytes 14-15) */
324 ACPI_MOVE_16_TO_32(&output_struct
->data
.address16
.address_length
,
327 /* Resource Source Index (if present) */
332 * This will leave us pointing to the Resource Source Index
333 * If it is present, then save it off and calculate the
334 * pointer to where the null terminated string goes:
335 * Each Interrupt takes 32-bits + the 5 bytes of the
336 * stream that are default.
338 * Note: Some resource descriptors will have an additional null, so
339 * we add 1 to the length.
341 if (*bytes_consumed
> (16 + 1)) {
342 /* Dereference the Index */
344 output_struct
->data
.address16
.resource_source
.index
=
347 /* Point to the String */
351 /* Point the String pointer to the end of this structure */
353 output_struct
->data
.address16
.resource_source
.string_ptr
=
354 (char *)((u8
*) output_struct
+ struct_size
);
357 output_struct
->data
.address16
.resource_source
.string_ptr
;
359 /* Copy the resource_source string into the buffer */
370 /* Add the terminating null and set the string length */
373 output_struct
->data
.address16
.resource_source
.string_length
=
377 * In order for the struct_size to fall on a 32-bit boundary,
378 * calculate the length of the string and expand the
379 * struct_size to the next 32-bit boundary.
381 temp8
= (u8
) (index
+ 1);
382 struct_size
+= ACPI_ROUND_UP_to_32_bITS(temp8
);
384 output_struct
->data
.address16
.resource_source
.index
= 0;
385 output_struct
->data
.address16
.resource_source
.string_length
= 0;
386 output_struct
->data
.address16
.resource_source
.string_ptr
= NULL
;
389 /* Set the Length parameter */
391 output_struct
->length
= (u32
) struct_size
;
393 /* Return the final size of the structure */
395 *structure_size
= struct_size
;
396 return_ACPI_STATUS(AE_OK
);
399 /*******************************************************************************
401 * FUNCTION: acpi_rs_address16_stream
403 * PARAMETERS: Resource - Pointer to the resource linked list
404 * output_buffer - Pointer to the user's return buffer
405 * bytes_consumed - Pointer to where the number of bytes
406 * used in the output_buffer is returned
410 * DESCRIPTION: Take the linked list resource structure and fills in the
411 * the appropriate bytes in a byte stream
413 ******************************************************************************/
416 acpi_rs_address16_stream(struct acpi_resource
*resource
,
417 u8
** output_buffer
, acpi_size
* bytes_consumed
)
419 u8
*buffer
= *output_buffer
;
421 acpi_size actual_bytes
;
423 ACPI_FUNCTION_TRACE("rs_address16_stream");
425 /* Set the Descriptor Type field */
427 *buffer
= ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE
;
430 /* Save a pointer to the Length field - to be filled in later */
432 length_field
= buffer
;
435 /* Set the Resource Type (Memory, Io, bus_number) */
437 *buffer
= (u8
) (resource
->data
.address16
.resource_type
& 0x03);
440 /* Set the general flags */
442 *buffer
= acpi_rs_encode_general_flags(&resource
->data
);
445 /* Set the type specific flags */
447 *buffer
= acpi_rs_encode_specific_flags(&resource
->data
);
450 /* Set the address space granularity */
452 ACPI_MOVE_32_TO_16(buffer
, &resource
->data
.address16
.granularity
);
455 /* Set the address range minimum */
457 ACPI_MOVE_32_TO_16(buffer
, &resource
->data
.address16
.min_address_range
);
460 /* Set the address range maximum */
462 ACPI_MOVE_32_TO_16(buffer
, &resource
->data
.address16
.max_address_range
);
465 /* Set the address translation offset */
467 ACPI_MOVE_32_TO_16(buffer
,
468 &resource
->data
.address16
.
469 address_translation_offset
);
472 /* Set the address length */
474 ACPI_MOVE_32_TO_16(buffer
, &resource
->data
.address16
.address_length
);
477 /* Resource Source Index and Resource Source are optional */
479 if (resource
->data
.address16
.resource_source
.string_length
) {
480 *buffer
= (u8
) resource
->data
.address16
.resource_source
.index
;
483 /* Copy the resource_source string */
485 ACPI_STRCPY((char *)buffer
,
486 resource
->data
.address16
.resource_source
.
490 * Buffer needs to be set to the length of the string + one for the
494 (acpi_size
) (ACPI_STRLEN
495 (resource
->data
.address16
.resource_source
.
499 /* Return the number of bytes consumed in this operation */
501 actual_bytes
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
502 *bytes_consumed
= actual_bytes
;
505 * Set the length field to the number of bytes consumed
506 * minus the header size (3 bytes)
509 ACPI_MOVE_SIZE_TO_16(length_field
, &actual_bytes
);
510 return_ACPI_STATUS(AE_OK
);
513 /*******************************************************************************
515 * FUNCTION: acpi_rs_address32_resource
517 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
519 * bytes_consumed - Pointer to where the number of bytes
520 * consumed the byte_stream_buffer is
522 * output_buffer - Pointer to the return data buffer
523 * structure_size - Pointer to where the number of bytes
524 * in the return data struct is returned
528 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
529 * structure pointed to by the output_buffer. Return the
530 * number of bytes consumed from the byte stream.
532 ******************************************************************************/
535 acpi_rs_address32_resource(u8
* byte_stream_buffer
,
536 acpi_size
* bytes_consumed
,
537 u8
** output_buffer
, acpi_size
* structure_size
)
543 u8
*buffer
= byte_stream_buffer
;
544 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
545 acpi_size struct_size
=
546 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32
);
548 ACPI_FUNCTION_TRACE("rs_address32_resource");
550 /* Get the Descriptor Length field */
553 ACPI_MOVE_16_TO_16(&temp16
, buffer
);
555 /* Validate minimum descriptor length */
558 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH
);
561 *bytes_consumed
= temp16
+ 3;
562 output_struct
->type
= ACPI_RSTYPE_ADDRESS32
;
564 /* Get the Resource Type (Byte3) */
569 /* Values 0-2 and 0xC0-0xFF are valid */
571 if ((temp8
> 2) && (temp8
< 0xC0)) {
572 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE
);
575 output_struct
->data
.address32
.resource_type
= temp8
;
577 /* Get the General Flags (Byte4) */
580 acpi_rs_decode_general_flags(&output_struct
->data
, *buffer
);
582 /* Get the Type Specific Flags (Byte5) */
585 acpi_rs_decode_specific_flags(&output_struct
->data
, *buffer
);
587 /* Get Granularity (Bytes 6-9) */
590 ACPI_MOVE_32_TO_32(&output_struct
->data
.address32
.granularity
, buffer
);
592 /* Get min_address_range (Bytes 10-13) */
595 ACPI_MOVE_32_TO_32(&output_struct
->data
.address32
.min_address_range
,
598 /* Get max_address_range (Bytes 14-17) */
601 ACPI_MOVE_32_TO_32(&output_struct
->data
.address32
.max_address_range
,
604 /* Get address_translation_offset (Bytes 18-21) */
607 ACPI_MOVE_32_TO_32(&output_struct
->data
.address32
.
608 address_translation_offset
, buffer
);
610 /* Get address_length (Bytes 22-25) */
613 ACPI_MOVE_32_TO_32(&output_struct
->data
.address32
.address_length
,
616 /* Resource Source Index (if present) */
621 * This will leave us pointing to the Resource Source Index
622 * If it is present, then save it off and calculate the
623 * pointer to where the null terminated string goes:
625 * Note: Some resource descriptors will have an additional null, so
626 * we add 1 to the length.
628 if (*bytes_consumed
> (26 + 1)) {
629 /* Dereference the Index */
631 output_struct
->data
.address32
.resource_source
.index
=
634 /* Point to the String */
638 /* Point the String pointer to the end of this structure */
640 output_struct
->data
.address32
.resource_source
.string_ptr
=
641 (char *)((u8
*) output_struct
+ struct_size
);
644 output_struct
->data
.address32
.resource_source
.string_ptr
;
646 /* Copy the resource_source string into the buffer */
657 /* Add the terminating null and set the string length */
660 output_struct
->data
.address32
.resource_source
.string_length
=
664 * In order for the struct_size to fall on a 32-bit boundary,
665 * calculate the length of the string and expand the
666 * struct_size to the next 32-bit boundary.
668 temp8
= (u8
) (index
+ 1);
669 struct_size
+= ACPI_ROUND_UP_to_32_bITS(temp8
);
671 output_struct
->data
.address32
.resource_source
.index
= 0;
672 output_struct
->data
.address32
.resource_source
.string_length
= 0;
673 output_struct
->data
.address32
.resource_source
.string_ptr
= NULL
;
676 /* Set the Length parameter */
678 output_struct
->length
= (u32
) struct_size
;
680 /* Return the final size of the structure */
682 *structure_size
= struct_size
;
683 return_ACPI_STATUS(AE_OK
);
686 /*******************************************************************************
688 * FUNCTION: acpi_rs_address32_stream
690 * PARAMETERS: Resource - Pointer to the resource linked list
691 * output_buffer - Pointer to the user's return buffer
692 * bytes_consumed - Pointer to where the number of bytes
693 * used in the output_buffer is returned
697 * DESCRIPTION: Take the linked list resource structure and fills in the
698 * the appropriate bytes in a byte stream
700 ******************************************************************************/
703 acpi_rs_address32_stream(struct acpi_resource
*resource
,
704 u8
** output_buffer
, acpi_size
* bytes_consumed
)
709 ACPI_FUNCTION_TRACE("rs_address32_stream");
711 buffer
= *output_buffer
;
713 /* Set the Descriptor Type field */
715 *buffer
= ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE
;
718 /* Save a pointer to the Length field - to be filled in later */
720 length_field
= ACPI_CAST_PTR(u16
, buffer
);
723 /* Set the Resource Type (Memory, Io, bus_number) */
725 *buffer
= (u8
) (resource
->data
.address32
.resource_type
& 0x03);
728 /* Set the general flags */
730 *buffer
= acpi_rs_encode_general_flags(&resource
->data
);
733 /* Set the type specific flags */
735 *buffer
= acpi_rs_encode_specific_flags(&resource
->data
);
738 /* Set the address space granularity */
740 ACPI_MOVE_32_TO_32(buffer
, &resource
->data
.address32
.granularity
);
743 /* Set the address range minimum */
745 ACPI_MOVE_32_TO_32(buffer
, &resource
->data
.address32
.min_address_range
);
748 /* Set the address range maximum */
750 ACPI_MOVE_32_TO_32(buffer
, &resource
->data
.address32
.max_address_range
);
753 /* Set the address translation offset */
755 ACPI_MOVE_32_TO_32(buffer
,
756 &resource
->data
.address32
.
757 address_translation_offset
);
760 /* Set the address length */
762 ACPI_MOVE_32_TO_32(buffer
, &resource
->data
.address32
.address_length
);
765 /* Resource Source Index and Resource Source are optional */
767 if (resource
->data
.address32
.resource_source
.string_length
) {
768 *buffer
= (u8
) resource
->data
.address32
.resource_source
.index
;
771 /* Copy the resource_source string */
773 ACPI_STRCPY((char *)buffer
,
774 resource
->data
.address32
.resource_source
.
778 * Buffer needs to be set to the length of the string + one for the
782 (acpi_size
) (ACPI_STRLEN
783 (resource
->data
.address32
.resource_source
.
787 /* Return the number of bytes consumed in this operation */
789 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
792 * Set the length field to the number of bytes consumed
793 * minus the header size (3 bytes)
795 *length_field
= (u16
) (*bytes_consumed
- 3);
796 return_ACPI_STATUS(AE_OK
);
799 /*******************************************************************************
801 * FUNCTION: acpi_rs_address64_resource
803 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
805 * bytes_consumed - Pointer to where the number of bytes
806 * consumed the byte_stream_buffer is
808 * output_buffer - Pointer to the return data buffer
809 * structure_size - Pointer to where the number of bytes
810 * in the return data struct is returned
814 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
815 * structure pointed to by the output_buffer. Return the
816 * number of bytes consumed from the byte stream.
818 ******************************************************************************/
821 acpi_rs_address64_resource(u8
* byte_stream_buffer
,
822 acpi_size
* bytes_consumed
,
823 u8
** output_buffer
, acpi_size
* structure_size
)
830 u8
*buffer
= byte_stream_buffer
;
831 struct acpi_resource
*output_struct
= (void *)*output_buffer
;
832 acpi_size struct_size
=
833 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64
);
835 ACPI_FUNCTION_TRACE("rs_address64_resource");
837 /* Get the Descriptor Type */
839 resource_type
= *buffer
;
841 /* Get the Descriptor Length field */
844 ACPI_MOVE_16_TO_16(&temp16
, buffer
);
846 /* Validate minimum descriptor length */
849 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH
);
852 *bytes_consumed
= temp16
+ 3;
853 output_struct
->type
= ACPI_RSTYPE_ADDRESS64
;
855 /* Get the Resource Type (Byte3) */
860 /* Values 0-2 and 0xC0-0xFF are valid */
862 if ((temp8
> 2) && (temp8
< 0xC0)) {
863 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE
);
866 output_struct
->data
.address64
.resource_type
= temp8
;
868 /* Get the General Flags (Byte4) */
871 acpi_rs_decode_general_flags(&output_struct
->data
, *buffer
);
873 /* Get the Type Specific Flags (Byte5) */
876 acpi_rs_decode_specific_flags(&output_struct
->data
, *buffer
);
878 if (resource_type
== ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE
) {
879 /* Move past revision_id and Reserved byte */
884 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
887 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.granularity
, buffer
);
889 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
892 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.min_address_range
,
895 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
898 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.max_address_range
,
901 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
904 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.
905 address_translation_offset
, buffer
);
907 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
910 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.address_length
,
913 output_struct
->data
.address64
.resource_source
.index
= 0;
914 output_struct
->data
.address64
.resource_source
.string_length
= 0;
915 output_struct
->data
.address64
.resource_source
.string_ptr
= NULL
;
917 if (resource_type
== ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE
) {
918 /* Get type_specific_attribute (Bytes 48-55) */
921 ACPI_MOVE_64_TO_64(&output_struct
->data
.address64
.
922 type_specific_attributes
, buffer
);
924 output_struct
->data
.address64
.type_specific_attributes
= 0;
926 /* Resource Source Index (if present) */
931 * This will leave us pointing to the Resource Source Index
932 * If it is present, then save it off and calculate the
933 * pointer to where the null terminated string goes:
934 * Each Interrupt takes 32-bits + the 5 bytes of the
935 * stream that are default.
937 * Note: Some resource descriptors will have an additional null, so
938 * we add 1 to the length.
940 if (*bytes_consumed
> (46 + 1)) {
941 /* Dereference the Index */
943 output_struct
->data
.address64
.resource_source
.index
=
946 /* Point to the String */
950 /* Point the String pointer to the end of this structure */
952 output_struct
->data
.address64
.resource_source
.
954 (char *)((u8
*) output_struct
+ struct_size
);
957 output_struct
->data
.address64
.resource_source
.
960 /* Copy the resource_source string into the buffer */
972 * Add the terminating null and set the string length
975 output_struct
->data
.address64
.resource_source
.
976 string_length
= index
+ 1;
979 * In order for the struct_size to fall on a 32-bit boundary,
980 * calculate the length of the string and expand the
981 * struct_size to the next 32-bit boundary.
983 temp8
= (u8
) (index
+ 1);
984 struct_size
+= ACPI_ROUND_UP_to_32_bITS(temp8
);
988 /* Set the Length parameter */
990 output_struct
->length
= (u32
) struct_size
;
992 /* Return the final size of the structure */
994 *structure_size
= struct_size
;
995 return_ACPI_STATUS(AE_OK
);
998 /*******************************************************************************
1000 * FUNCTION: acpi_rs_address64_stream
1002 * PARAMETERS: Resource - Pointer to the resource linked list
1003 * output_buffer - Pointer to the user's return buffer
1004 * bytes_consumed - Pointer to where the number of bytes
1005 * used in the output_buffer is returned
1009 * DESCRIPTION: Take the linked list resource structure and fills in the
1010 * the appropriate bytes in a byte stream
1012 ******************************************************************************/
1015 acpi_rs_address64_stream(struct acpi_resource
*resource
,
1016 u8
** output_buffer
, acpi_size
* bytes_consumed
)
1021 ACPI_FUNCTION_TRACE("rs_address64_stream");
1023 buffer
= *output_buffer
;
1025 /* Set the Descriptor Type field */
1027 *buffer
= ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE
;
1030 /* Save a pointer to the Length field - to be filled in later */
1032 length_field
= ACPI_CAST_PTR(u16
, buffer
);
1035 /* Set the Resource Type (Memory, Io, bus_number) */
1037 *buffer
= (u8
) (resource
->data
.address64
.resource_type
& 0x03);
1040 /* Set the general flags */
1042 *buffer
= acpi_rs_encode_general_flags(&resource
->data
);
1045 /* Set the type specific flags */
1047 *buffer
= acpi_rs_encode_specific_flags(&resource
->data
);
1050 /* Set the address space granularity */
1052 ACPI_MOVE_64_TO_64(buffer
, &resource
->data
.address64
.granularity
);
1055 /* Set the address range minimum */
1057 ACPI_MOVE_64_TO_64(buffer
, &resource
->data
.address64
.min_address_range
);
1060 /* Set the address range maximum */
1062 ACPI_MOVE_64_TO_64(buffer
, &resource
->data
.address64
.max_address_range
);
1065 /* Set the address translation offset */
1067 ACPI_MOVE_64_TO_64(buffer
,
1068 &resource
->data
.address64
.
1069 address_translation_offset
);
1072 /* Set the address length */
1074 ACPI_MOVE_64_TO_64(buffer
, &resource
->data
.address64
.address_length
);
1077 /* Resource Source Index and Resource Source are optional */
1079 if (resource
->data
.address64
.resource_source
.string_length
) {
1080 *buffer
= (u8
) resource
->data
.address64
.resource_source
.index
;
1083 /* Copy the resource_source string */
1085 ACPI_STRCPY((char *)buffer
,
1086 resource
->data
.address64
.resource_source
.
1090 * Buffer needs to be set to the length of the string + one for the
1094 (acpi_size
) (ACPI_STRLEN
1095 (resource
->data
.address64
.resource_source
.
1099 /* Return the number of bytes consumed in this operation */
1101 *bytes_consumed
= ACPI_PTR_DIFF(buffer
, *output_buffer
);
1104 * Set the length field to the number of bytes consumed
1105 * minus the header size (3 bytes)
1107 *length_field
= (u16
) (*bytes_consumed
- 3);
1108 return_ACPI_STATUS(AE_OK
);