1 /*******************************************************************************
3 * Module Name: rslist - Acpi_rs_byte_stream_to_list
4 * Acpi_list_to_byte_stream
7 ******************************************************************************/
10 * Copyright (C) 2000, 2001 R. Byron Moore
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #define _COMPONENT ACPI_RESOURCES
31 MODULE_NAME ("rslist")
34 /*******************************************************************************
36 * FUNCTION: Acpi_rs_byte_stream_to_list
38 * PARAMETERS: Byte_stream_buffer - Pointer to the resource byte stream
39 * Byte_stream_buffer_length - Length of Byte_stream_buffer
40 * Output_buffer - Pointer to the buffer that will
41 * contain the output structures
43 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
45 * DESCRIPTION: Takes the resource byte stream and parses it, creating a
46 * linked list of resources in the caller's output buffer
48 ******************************************************************************/
51 acpi_rs_byte_stream_to_list (
52 u8
*byte_stream_buffer
,
53 u32 byte_stream_buffer_length
,
59 u32 bytes_consumed
= 0;
60 u8
**buffer
= output_buffer
;
61 u32 structure_size
= 0;
62 u8 end_tag_processed
= FALSE
;
65 while (bytes_parsed
< byte_stream_buffer_length
&&
66 FALSE
== end_tag_processed
) {
68 * Look at the next byte in the stream
70 resource_type
= *byte_stream_buffer
;
73 * See if this is a small or large resource
75 if(resource_type
& 0x80) {
79 switch (resource_type
) {
82 * 24-Bit Memory Resource
84 status
= acpi_rs_memory24_resource(byte_stream_buffer
,
91 case LARGE_VENDOR_DEFINED
:
93 * Vendor Defined Resource
95 status
= acpi_rs_vendor_resource(byte_stream_buffer
,
102 case MEMORY_RANGE_32
:
104 * 32-Bit Memory Range Resource
106 status
= acpi_rs_memory32_range_resource(byte_stream_buffer
,
113 case FIXED_MEMORY_RANGE_32
:
115 * 32-Bit Fixed Memory Resource
117 status
= acpi_rs_fixed_memory32_resource(byte_stream_buffer
,
124 case DWORD_ADDRESS_SPACE
:
126 * 32-Bit Address Resource
128 status
= acpi_rs_address32_resource(byte_stream_buffer
,
135 case WORD_ADDRESS_SPACE
:
137 * 16-Bit Address Resource
139 status
= acpi_rs_address16_resource(byte_stream_buffer
,
150 status
= acpi_rs_extended_irq_resource(byte_stream_buffer
,
157 /* TBD: [Future] 64-bit not currently supported */
165 * If we get here, everything is out of sync,
166 * so exit with an error
168 return (AE_AML_ERROR
);
175 * Small Resource Type
176 * Only bits 7:3 are valid
180 switch(resource_type
) {
185 status
= acpi_rs_irq_resource(byte_stream_buffer
,
196 status
= acpi_rs_dma_resource(byte_stream_buffer
,
203 case START_DEPENDENT_TAG
:
205 * Start Dependent Functions Resource
207 status
= acpi_rs_start_dependent_functions_resource(byte_stream_buffer
,
214 case END_DEPENDENT_TAG
:
216 * End Dependent Functions Resource
218 status
= acpi_rs_end_dependent_functions_resource(byte_stream_buffer
,
225 case IO_PORT_DESCRIPTOR
:
229 status
= acpi_rs_io_resource(byte_stream_buffer
,
236 case FIXED_LOCATION_IO_DESCRIPTOR
:
238 * Fixed IO Port Resource
240 status
= acpi_rs_fixed_io_resource(byte_stream_buffer
,
247 case SMALL_VENDOR_DEFINED
:
249 * Vendor Specific Resource
251 status
= acpi_rs_vendor_resource(byte_stream_buffer
,
262 status
= acpi_rs_end_tag_resource(byte_stream_buffer
,
266 end_tag_processed
= TRUE
;
272 * If we get here, everything is out of sync,
273 * so exit with an error
275 return (AE_AML_ERROR
);
282 * Update the return value and counter
284 bytes_parsed
+= bytes_consumed
;
287 * Set the byte stream to point to the next resource
289 byte_stream_buffer
+= bytes_consumed
;
292 * Set the Buffer to the next structure
294 *buffer
+= structure_size
;
299 * Check the reason for exiting the while loop
301 if (TRUE
!= end_tag_processed
) {
302 return (AE_AML_ERROR
);
309 /*******************************************************************************
311 * FUNCTION: Acpi_rs_list_to_byte_stream
313 * PARAMETERS: Linked_list - Pointer to the resource linked list
314 * Byte_steam_size_needed - Calculated size of the byte stream
315 * needed from calling
316 * Acpi_rs_calculate_byte_stream_length()
317 * The size of the Output_buffer is
318 * guaranteed to be >=
319 * Byte_stream_size_needed
320 * Output_buffer - Pointer to the buffer that will
321 * contain the byte stream
323 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
325 * DESCRIPTION: Takes the resource linked list and parses it, creating a
326 * byte stream of resources in the caller's output buffer
328 ******************************************************************************/
331 acpi_rs_list_to_byte_stream (
332 RESOURCE
*linked_list
,
333 u32 byte_stream_size_needed
,
337 u8
*buffer
= *output_buffer
;
338 u32 bytes_consumed
= 0;
343 switch (linked_list
->id
) {
348 status
= acpi_rs_irq_stream (linked_list
,
357 status
= acpi_rs_dma_stream (linked_list
,
362 case start_dependent_functions
:
364 * Start Dependent Functions Resource
366 status
= acpi_rs_start_dependent_functions_stream (linked_list
,
371 case end_dependent_functions
:
373 * End Dependent Functions Resource
375 status
= acpi_rs_end_dependent_functions_stream (linked_list
,
384 status
= acpi_rs_io_stream (linked_list
,
391 * Fixed IO Port Resource
393 status
= acpi_rs_fixed_io_stream (linked_list
,
398 case vendor_specific
:
400 * Vendor Defined Resource
402 status
= acpi_rs_vendor_stream (linked_list
,
411 status
= acpi_rs_end_tag_stream (linked_list
,
416 * An End Tag indicates the end of the Resource Template
423 * 24-Bit Memory Resource
425 status
= acpi_rs_memory24_stream (linked_list
,
432 * 32-Bit Memory Range Resource
434 status
= acpi_rs_memory32_range_stream (linked_list
,
441 * 32-Bit Fixed Memory Resource
443 status
= acpi_rs_fixed_memory32_stream (linked_list
,
450 * 16-Bit Address Descriptor Resource
452 status
= acpi_rs_address16_stream (linked_list
,
459 * 32-Bit Address Descriptor Resource
461 status
= acpi_rs_address32_stream (linked_list
,
468 * Extended IRQ Resource
470 status
= acpi_rs_extended_irq_stream (linked_list
,
477 * If we get here, everything is out of sync,
478 * so exit with an error
480 return (AE_BAD_DATA
);
483 } /* switch (Linked_list->Id) */
486 * Set the Buffer to point to the open byte
488 buffer
+= bytes_consumed
;
491 * Point to the next object
493 linked_list
= (RESOURCE
*) ((NATIVE_UINT
) linked_list
+
494 (NATIVE_UINT
) linked_list
->length
);