1 /*******************************************************************************
3 * Module Name: rsio - Acpi_rs_io_resource
4 * Acpi_rs_fixed_io_resource
6 * Acpi_rs_fixed_io_stream
11 ******************************************************************************/
14 * Copyright (C) 2000, 2001 R. Byron Moore
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #define _COMPONENT ACPI_RESOURCES
39 /*******************************************************************************
41 * FUNCTION: Acpi_rs_io_resource
43 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
45 * Bytes_consumed - u32 pointer that is filled with
46 * the number of bytes consumed from
47 * the Byte_stream_buffer
48 * Output_buffer - Pointer to the user's return buffer
49 * Structure_size - u32 pointer that is filled with
50 * the number of bytes in the filled
53 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
55 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
56 * structure pointed to by the Output_buffer. Return the
57 * number of bytes consumed from the byte stream.
59 ******************************************************************************/
63 u8 *byte_stream_buffer,
68 u8 *buffer = byte_stream_buffer;
69 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
72 u32 struct_size = sizeof (IO_RESOURCE) +
73 RESOURCE_LENGTH_NO_DATA;
77 * The number of bytes consumed are Constant
81 output_struct->id = io;
89 output_struct->data.io.io_decode = temp8 & 0x01;
92 * Check Min_base Address
95 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
97 output_struct->data.io.min_base_address = temp16;
100 * Check Max_base Address
103 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
105 output_struct->data.io.max_base_address = temp16;
108 * Check Base alignment
113 output_struct->data.io.alignment = temp8;
121 output_struct->data.io.range_length = temp8;
124 * Set the Length parameter
126 output_struct->length = struct_size;
129 * Return the final size of the structure
131 *structure_size = struct_size;
137 /*******************************************************************************
139 * FUNCTION: Acpi_rs_fixed_io_resource
141 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
143 * Bytes_consumed - u32 pointer that is filled with
144 * the number of bytes consumed from
145 * the Byte_stream_buffer
146 * Output_buffer - Pointer to the user's return buffer
147 * Structure_size - u32 pointer that is filled with
148 * the number of bytes in the filled
151 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
153 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
154 * structure pointed to by the Output_buffer. Return the
155 * number of bytes consumed from the byte stream.
157 ******************************************************************************/
160 acpi_rs_fixed_io_resource (
161 u8 *byte_stream_buffer,
166 u8 *buffer = byte_stream_buffer;
167 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
170 u32 struct_size = sizeof (FIXED_IO_RESOURCE) +
171 RESOURCE_LENGTH_NO_DATA;
175 * The number of bytes consumed are Constant
179 output_struct->id = fixed_io;
182 * Check Range Base Address
185 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
187 output_struct->data.fixed_io.base_address = temp16;
195 output_struct->data.fixed_io.range_length = temp8;
198 * Set the Length parameter
200 output_struct->length = struct_size;
203 * Return the final size of the structure
205 *structure_size = struct_size;
211 /*******************************************************************************
213 * FUNCTION: Acpi_rs_io_stream
215 * PARAMETERS: Linked_list - Pointer to the resource linked list
216 * Output_buffer - Pointer to the user's return buffer
217 * Bytes_consumed - u32 pointer that is filled with
218 * the number of bytes of the
221 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
223 * DESCRIPTION: Take the linked list resource structure and fills in the
224 * the appropriate bytes in a byte stream
226 ******************************************************************************/
230 RESOURCE *linked_list,
234 u8 *buffer = *output_buffer;
240 * The descriptor field is static
246 * Io Information Byte
248 temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
254 * Set the Range minimum base address
256 temp16 = (u16) linked_list->data.io.min_base_address;
258 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
262 * Set the Range maximum base address
264 temp16 = (u16) linked_list->data.io.max_base_address;
266 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
270 * Set the base alignment
272 temp8 = (u8) linked_list->data.io.alignment;
278 * Set the range length
280 temp8 = (u8) linked_list->data.io.range_length;
286 * Return the number of bytes consumed in this operation
288 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
289 (NATIVE_UINT) *output_buffer);
295 /*******************************************************************************
297 * FUNCTION: Acpi_rs_fixed_io_stream
299 * PARAMETERS: Linked_list - Pointer to the resource linked list
300 * Output_buffer - Pointer to the user's return buffer
301 * Bytes_consumed - u32 pointer that is filled with
302 * the number of bytes of the
305 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
307 * DESCRIPTION: Take the linked list resource structure and fills in the
308 * the appropriate bytes in a byte stream
310 ******************************************************************************/
313 acpi_rs_fixed_io_stream (
314 RESOURCE *linked_list,
318 u8 *buffer = *output_buffer;
324 * The descriptor field is static
331 * Set the Range base address
333 temp16 = (u16) linked_list->data.fixed_io.base_address;
335 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
339 * Set the range length
341 temp8 = (u8) linked_list->data.fixed_io.range_length;
347 * Return the number of bytes consumed in this operation
349 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
350 (NATIVE_UINT) *output_buffer);
356 /*******************************************************************************
358 * FUNCTION: Acpi_rs_dma_resource
360 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
362 * Bytes_consumed - u32 pointer that is filled with
363 * the number of bytes consumed from
364 * the Byte_stream_buffer
365 * Output_buffer - Pointer to the user's return buffer
366 * Structure_size - u32 pointer that is filled with
367 * the number of bytes in the filled
370 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
372 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
373 * structure pointed to by the Output_buffer. Return the
374 * number of bytes consumed from the byte stream.
376 ******************************************************************************/
379 acpi_rs_dma_resource (
380 u8 *byte_stream_buffer,
385 u8 *buffer = byte_stream_buffer;
386 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
390 u32 struct_size = sizeof(DMA_RESOURCE) +
391 RESOURCE_LENGTH_NO_DATA;
395 * The number of bytes consumed are Constant
398 output_struct->id = dma;
401 * Point to the 8-bits of Byte 1
406 /* Decode the IRQ bits */
408 for (i = 0, index = 0; index < 8; index++) {
409 if ((temp8 >> index) & 0x01) {
410 output_struct->data.dma.channels[i] = index;
414 output_struct->data.dma.number_of_channels = i;
418 * Calculate the structure size based upon the number of interrupts
420 struct_size += (output_struct->data.dma.number_of_channels - 1) * 4;
429 * Check for transfer preference (Bits[1:0])
431 output_struct->data.dma.transfer = temp8 & 0x03;
433 if (0x03 == output_struct->data.dma.transfer) {
434 return (AE_BAD_DATA);
438 * Get bus master preference (Bit[2])
440 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
443 * Get channel speed support (Bits[6:5])
445 output_struct->data.dma.type = (temp8 >> 5) & 0x03;
448 * Set the Length parameter
450 output_struct->length = struct_size;
453 * Return the final size of the structure
455 *structure_size = struct_size;
461 /*******************************************************************************
463 * FUNCTION: Acpi_rs_dma_stream
465 * PARAMETERS: Linked_list - Pointer to the resource linked list
466 * Output_buffer - Pointer to the user's return buffer
467 * Bytes_consumed - u32 pointer that is filled with
468 * the number of bytes of the
471 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
473 * DESCRIPTION: Take the linked list resource structure and fills in the
474 * the appropriate bytes in a byte stream
476 ******************************************************************************/
480 RESOURCE *linked_list,
484 u8 *buffer = *output_buffer;
491 * The descriptor field is static
498 * Loop through all of the Channels and set the mask bits
501 index < linked_list->data.dma.number_of_channels;
503 temp16 = (u16) linked_list->data.dma.channels[index];
504 temp8 |= 0x1 << temp16;
513 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5);
514 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2);
515 temp8 |= (linked_list->data.dma.transfer & 0x03);
521 * Return the number of bytes consumed in this operation
523 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
524 (NATIVE_UINT) *output_buffer);