1 /*******************************************************************************
3 * Module Name: rslist - Acpi_rs_byte_stream_to_list
4 * Acpi_list_to_byte_stream
7 ******************************************************************************/
10 * Copyright (C) 2000 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
31 #define _COMPONENT RESOURCE_MANAGER
32 MODULE_NAME ("rslist")
35 /*******************************************************************************
37 * FUNCTION: Acpi_rs_byte_stream_to_list
39 * PARAMETERS: Byte_stream_buffer - Pointer to the resource byte stream
40 * Byte_stream_buffer_length - Length of Byte_stream_buffer
41 * Output_buffer - Pointer to the buffer that will
42 * contain the output structures
44 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
46 * DESCRIPTION: Takes the resource byte stream and parses it, creating a
47 * linked list of resources in the caller's output buffer
49 ******************************************************************************/
52 acpi_rs_byte_stream_to_list (
53 u8
*byte_stream_buffer
,
54 u32 byte_stream_buffer_length
,
60 u32 bytes_consumed
= 0;
61 u8
**buffer
= output_buffer
;
62 u32 structure_size
= 0;
63 u8 end_tag_processed
= FALSE
;
66 while (bytes_parsed
< byte_stream_buffer_length
&&
67 FALSE
== end_tag_processed
)
70 * Look at the next byte in the stream
72 resource_type
= *byte_stream_buffer
;
75 * See if this is a small or large resource
77 if(resource_type
& 0x80) {
81 switch (resource_type
)
85 * 24-Bit Memory Resource
87 status
= acpi_rs_memory24_resource(byte_stream_buffer
,
94 case LARGE_VENDOR_DEFINED
:
96 * Vendor Defined Resource
98 status
= acpi_rs_vendor_resource(byte_stream_buffer
,
105 case MEMORY_RANGE_32
:
107 * 32-Bit Memory Range Resource
109 status
= acpi_rs_memory32_range_resource(byte_stream_buffer
,
116 case FIXED_MEMORY_RANGE_32
:
118 * 32-Bit Fixed Memory Resource
120 status
= acpi_rs_fixed_memory32_resource(byte_stream_buffer
,
127 case DWORD_ADDRESS_SPACE
:
129 * 32-Bit Address Resource
131 status
= acpi_rs_address32_resource(byte_stream_buffer
,
138 case WORD_ADDRESS_SPACE
:
140 * 16-Bit Address Resource
142 status
= acpi_rs_address16_resource(byte_stream_buffer
,
153 status
= acpi_rs_extended_irq_resource(byte_stream_buffer
,
160 /* TBD: [Future] 64-bit not currently supported */
168 * If we get here, everything is out of sync,
169 * so exit with an error
171 return (AE_AML_ERROR
);
178 * Small Resource Type
179 * Only bits 7:3 are valid
183 switch(resource_type
)
189 status
= acpi_rs_irq_resource(byte_stream_buffer
,
200 status
= acpi_rs_dma_resource(byte_stream_buffer
,
207 case START_DEPENDENT_TAG
:
209 * Start Dependent Functions Resource
211 status
= acpi_rs_start_dependent_functions_resource(byte_stream_buffer
,
218 case END_DEPENDENT_TAG
:
220 * End Dependent Functions Resource
222 status
= acpi_rs_end_dependent_functions_resource(byte_stream_buffer
,
229 case IO_PORT_DESCRIPTOR
:
233 status
= acpi_rs_io_resource(byte_stream_buffer
,
240 case FIXED_LOCATION_IO_DESCRIPTOR
:
242 * Fixed IO Port Resource
244 status
= acpi_rs_fixed_io_resource(byte_stream_buffer
,
251 case SMALL_VENDOR_DEFINED
:
253 * Vendor Specific Resource
255 status
= acpi_rs_vendor_resource(byte_stream_buffer
,
266 status
= acpi_rs_end_tag_resource(byte_stream_buffer
,
270 end_tag_processed
= TRUE
;
276 * If we get here, everything is out of sync,
277 * so exit with an error
279 return (AE_AML_ERROR
);
286 * Update the return value and counter
288 bytes_parsed
+= bytes_consumed
;
291 * Set the byte stream to point to the next resource
293 byte_stream_buffer
+= bytes_consumed
;
296 * Set the Buffer to the next structure
298 *buffer
+= structure_size
;
303 * Check the reason for exiting the while loop
305 if (!(byte_stream_buffer_length
== bytes_parsed
) ||
306 (TRUE
!= end_tag_processed
))
308 return (AE_AML_ERROR
);
315 /*******************************************************************************
317 * FUNCTION: Acpi_rs_list_to_byte_stream
319 * PARAMETERS: Linked_list - Pointer to the resource linked list
320 * Byte_steam_size_needed - Calculated size of the byte stream
321 * needed from calling
322 * Acpi_rs_calculate_byte_stream_length()
323 * The size of the Output_buffer is
324 * guaranteed to be >=
325 * Byte_stream_size_needed
326 * Output_buffer - Pointer to the buffer that will
327 * contain the byte stream
329 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
331 * DESCRIPTION: Takes the resource linked list and parses it, creating a
332 * byte stream of resources in the caller's output buffer
334 ******************************************************************************/
337 acpi_rs_list_to_byte_stream (
338 RESOURCE
*linked_list
,
339 u32 byte_stream_size_needed
,
343 u8
*buffer
= *output_buffer
;
344 u32 bytes_consumed
= 0;
349 switch (linked_list
->id
)
355 status
= acpi_rs_irq_stream (linked_list
,
364 status
= acpi_rs_dma_stream (linked_list
,
369 case start_dependent_functions
:
371 * Start Dependent Functions Resource
373 status
= acpi_rs_start_dependent_functions_stream (linked_list
,
378 case end_dependent_functions
:
380 * End Dependent Functions Resource
382 status
= acpi_rs_end_dependent_functions_stream (linked_list
,
391 status
= acpi_rs_io_stream (linked_list
,
398 * Fixed IO Port Resource
400 status
= acpi_rs_fixed_io_stream (linked_list
,
405 case vendor_specific
:
407 * Vendor Defined Resource
409 status
= acpi_rs_vendor_stream (linked_list
,
418 status
= acpi_rs_end_tag_stream (linked_list
,
423 * An End Tag indicates the end of the Resource Template
430 * 24-Bit Memory Resource
432 status
= acpi_rs_memory24_stream (linked_list
,
439 * 32-Bit Memory Range Resource
441 status
= acpi_rs_memory32_range_stream (linked_list
,
448 * 32-Bit Fixed Memory Resource
450 status
= acpi_rs_fixed_memory32_stream (linked_list
,
457 * 16-Bit Address Descriptor Resource
459 status
= acpi_rs_address16_stream (linked_list
,
466 * 32-Bit Address Descriptor Resource
468 status
= acpi_rs_address32_stream (linked_list
,
475 * Extended IRQ Resource
477 status
= acpi_rs_extended_irq_stream (linked_list
,
484 * If we get here, everything is out of sync,
485 * so exit with an error
487 return (AE_BAD_DATA
);
490 } /* switch (Linked_list->Id) */
493 * Set the Buffer to point to the open byte
495 buffer
+= bytes_consumed
;
498 * Point to the next object
500 linked_list
= (RESOURCE
*) ((NATIVE_UINT
) linked_list
+
501 (NATIVE_UINT
) linked_list
->length
);