patch-2.4.22 linux-2.4.22/drivers/acpi/resources/rsio.c
Next file: linux-2.4.22/drivers/acpi/resources/rsirq.c
Previous file: linux-2.4.22/drivers/acpi/resources/rsdump.c
Back to the patch index
Back to the overall index
- Lines: 549
- Date:
2003-08-25 04:44:41.000000000 -0700
- Orig file:
linux-2.4.21/drivers/acpi/resources/rsio.c
- Orig date:
2001-09-23 09:42:32.000000000 -0700
diff -urN linux-2.4.21/drivers/acpi/resources/rsio.c linux-2.4.22/drivers/acpi/resources/rsio.c
@@ -1,73 +1,90 @@
/*******************************************************************************
*
* Module Name: rsio - IO and DMA resource descriptors
- * $Revision: 14 $
*
******************************************************************************/
/*
- * Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
*/
-#include "acpi.h"
-#include "acresrc.h"
+#include <acpi/acpi.h>
+#include <acpi/acresrc.h>
#define _COMPONENT ACPI_RESOURCES
- MODULE_NAME ("rsio")
+ ACPI_MODULE_NAME ("rsio")
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_io_resource
+ * FUNCTION: acpi_rs_io_resource
*
- * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
+ * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
* stream
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes consumed from
- * the Byte_stream_buffer
- * Output_buffer - Pointer to the user's return buffer
- * Structure_size - u32 pointer that is filled with
- * the number of bytes in the filled
- * in structure
+ * bytes_consumed - Pointer to where the number of bytes
+ * consumed the byte_stream_buffer is
+ * returned
+ * output_buffer - Pointer to the return data buffer
+ * structure_size - Pointer to where the number of bytes
+ * in the return data struct is returned
*
* RETURN: Status
*
* DESCRIPTION: Take the resource byte stream and fill out the appropriate
- * structure pointed to by the Output_buffer. Return the
+ * structure pointed to by the output_buffer. Return the
* number of bytes consumed from the byte stream.
*
******************************************************************************/
acpi_status
acpi_rs_io_resource (
- u8 *byte_stream_buffer,
- u32 *bytes_consumed,
- u8 **output_buffer,
- u32 *structure_size)
+ u8 *byte_stream_buffer,
+ acpi_size *bytes_consumed,
+ u8 **output_buffer,
+ acpi_size *structure_size)
{
- u8 *buffer = byte_stream_buffer;
- acpi_resource *output_struct = (acpi_resource *) *output_buffer;
- u16 temp16 = 0;
- u8 temp8 = 0;
- u32 struct_size = SIZEOF_RESOURCE (acpi_resource_io);
+ u8 *buffer = byte_stream_buffer;
+ struct acpi_resource *output_struct = (void *) *output_buffer;
+ u16 temp16 = 0;
+ u8 temp8 = 0;
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io);
- FUNCTION_TRACE ("Rs_io_resource");
+ ACPI_FUNCTION_TRACE ("rs_io_resource");
/*
@@ -86,18 +103,18 @@
output_struct->data.io.io_decode = temp8 & 0x01;
/*
- * Check Min_base Address
+ * Check min_base Address
*/
buffer += 1;
- MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+ ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.io.min_base_address = temp16;
/*
- * Check Max_base Address
+ * Check max_base Address
*/
buffer += 2;
- MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+ ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.io.max_base_address = temp16;
@@ -110,7 +127,7 @@
output_struct->data.io.alignment = temp8;
/*
- * Check Range_length
+ * Check range_length
*/
buffer += 1;
temp8 = *buffer;
@@ -120,7 +137,7 @@
/*
* Set the Length parameter
*/
- output_struct->length = struct_size;
+ output_struct->length = (u32) struct_size;
/*
* Return the final size of the structure
@@ -132,41 +149,40 @@
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_fixed_io_resource
+ * FUNCTION: acpi_rs_fixed_io_resource
*
- * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
+ * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
* stream
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes consumed from
- * the Byte_stream_buffer
- * Output_buffer - Pointer to the user's return buffer
- * Structure_size - u32 pointer that is filled with
- * the number of bytes in the filled
- * in structure
+ * bytes_consumed - Pointer to where the number of bytes
+ * consumed the byte_stream_buffer is
+ * returned
+ * output_buffer - Pointer to the return data buffer
+ * structure_size - Pointer to where the number of bytes
+ * in the return data struct is returned
*
* RETURN: Status
*
* DESCRIPTION: Take the resource byte stream and fill out the appropriate
- * structure pointed to by the Output_buffer. Return the
+ * structure pointed to by the output_buffer. Return the
* number of bytes consumed from the byte stream.
*
******************************************************************************/
acpi_status
acpi_rs_fixed_io_resource (
- u8 *byte_stream_buffer,
- u32 *bytes_consumed,
- u8 **output_buffer,
- u32 *structure_size)
+ u8 *byte_stream_buffer,
+ acpi_size *bytes_consumed,
+ u8 **output_buffer,
+ acpi_size *structure_size)
{
- u8 *buffer = byte_stream_buffer;
- acpi_resource *output_struct = (acpi_resource *) *output_buffer;
- u16 temp16 = 0;
- u8 temp8 = 0;
- u32 struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_io);
+ u8 *buffer = byte_stream_buffer;
+ struct acpi_resource *output_struct = (void *) *output_buffer;
+ u16 temp16 = 0;
+ u8 temp8 = 0;
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io);
- FUNCTION_TRACE ("Rs_fixed_io_resource");
+ ACPI_FUNCTION_TRACE ("rs_fixed_io_resource");
/*
@@ -180,12 +196,12 @@
* Check Range Base Address
*/
buffer += 1;
- MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+ ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.fixed_io.base_address = temp16;
/*
- * Check Range_length
+ * Check range_length
*/
buffer += 2;
temp8 = *buffer;
@@ -195,7 +211,7 @@
/*
* Set the Length parameter
*/
- output_struct->length = struct_size;
+ output_struct->length = (u32) struct_size;
/*
* Return the final size of the structure
@@ -207,13 +223,12 @@
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_io_stream
+ * FUNCTION: acpi_rs_io_stream
*
- * PARAMETERS: Linked_list - Pointer to the resource linked list
- * Output_buffer - Pointer to the user's return buffer
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes of the
- * Output_buffer used
+ * PARAMETERS: linked_list - Pointer to the resource linked list
+ * output_buffer - Pointer to the user's return buffer
+ * bytes_consumed - Pointer to where the number of bytes
+ * used in the output_buffer is returned
*
* RETURN: Status
*
@@ -224,16 +239,16 @@
acpi_status
acpi_rs_io_stream (
- acpi_resource *linked_list,
- u8 **output_buffer,
- u32 *bytes_consumed)
+ struct acpi_resource *linked_list,
+ u8 **output_buffer,
+ acpi_size *bytes_consumed)
{
- u8 *buffer = *output_buffer;
- u16 temp16 = 0;
- u8 temp8 = 0;
+ u8 *buffer = *output_buffer;
+ u16 temp16 = 0;
+ u8 temp8 = 0;
- FUNCTION_TRACE ("Rs_io_stream");
+ ACPI_FUNCTION_TRACE ("rs_io_stream");
/*
@@ -255,7 +270,7 @@
*/
temp16 = (u16) linked_list->data.io.min_base_address;
- MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+ ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
/*
@@ -263,7 +278,7 @@
*/
temp16 = (u16) linked_list->data.io.max_base_address;
- MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+ ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
/*
@@ -285,20 +300,19 @@
/*
* Return the number of bytes consumed in this operation
*/
- *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+ *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_fixed_io_stream
+ * FUNCTION: acpi_rs_fixed_io_stream
*
- * PARAMETERS: Linked_list - Pointer to the resource linked list
- * Output_buffer - Pointer to the user's return buffer
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes of the
- * Output_buffer used
+ * PARAMETERS: linked_list - Pointer to the resource linked list
+ * output_buffer - Pointer to the user's return buffer
+ * bytes_consumed - Pointer to where the number of bytes
+ * used in the output_buffer is returned
*
* RETURN: Status
*
@@ -309,16 +323,16 @@
acpi_status
acpi_rs_fixed_io_stream (
- acpi_resource *linked_list,
- u8 **output_buffer,
- u32 *bytes_consumed)
+ struct acpi_resource *linked_list,
+ u8 **output_buffer,
+ acpi_size *bytes_consumed)
{
- u8 *buffer = *output_buffer;
- u16 temp16 = 0;
- u8 temp8 = 0;
+ u8 *buffer = *output_buffer;
+ u16 temp16 = 0;
+ u8 temp8 = 0;
- FUNCTION_TRACE ("Rs_fixed_io_stream");
+ ACPI_FUNCTION_TRACE ("rs_fixed_io_stream");
/*
@@ -333,7 +347,7 @@
*/
temp16 = (u16) linked_list->data.fixed_io.base_address;
- MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+ ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
/*
@@ -347,49 +361,48 @@
/*
* Return the number of bytes consumed in this operation
*/
- *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+ *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_dma_resource
+ * FUNCTION: acpi_rs_dma_resource
*
- * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
+ * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
* stream
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes consumed from
- * the Byte_stream_buffer
- * Output_buffer - Pointer to the user's return buffer
- * Structure_size - u32 pointer that is filled with
- * the number of bytes in the filled
- * in structure
+ * bytes_consumed - Pointer to where the number of bytes
+ * consumed the byte_stream_buffer is
+ * returned
+ * output_buffer - Pointer to the return data buffer
+ * structure_size - Pointer to where the number of bytes
+ * in the return data struct is returned
*
* RETURN: Status
*
* DESCRIPTION: Take the resource byte stream and fill out the appropriate
- * structure pointed to by the Output_buffer. Return the
+ * structure pointed to by the output_buffer. Return the
* number of bytes consumed from the byte stream.
*
******************************************************************************/
acpi_status
acpi_rs_dma_resource (
- u8 *byte_stream_buffer,
- u32 *bytes_consumed,
- u8 **output_buffer,
- u32 *structure_size)
+ u8 *byte_stream_buffer,
+ acpi_size *bytes_consumed,
+ u8 **output_buffer,
+ acpi_size *structure_size)
{
- u8 *buffer = byte_stream_buffer;
- acpi_resource *output_struct = (acpi_resource *) *output_buffer;
- u8 temp8 = 0;
- u8 index;
- u8 i;
- u32 struct_size = SIZEOF_RESOURCE (acpi_resource_dma);
+ u8 *buffer = byte_stream_buffer;
+ struct acpi_resource *output_struct = (void *) *output_buffer;
+ u8 temp8 = 0;
+ u8 index;
+ u8 i;
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma);
- FUNCTION_TRACE ("Rs_dma_resource");
+ ACPI_FUNCTION_TRACE ("rs_dma_resource");
/*
@@ -404,7 +417,7 @@
buffer += 1;
temp8 = *buffer;
- /* Decode the IRQ bits */
+ /* Decode the DMA channel bits */
for (i = 0, index = 0; index < 8; index++) {
if ((temp8 >> index) & 0x01) {
@@ -412,13 +425,16 @@
i++;
}
}
- output_struct->data.dma.number_of_channels = i;
+ /* Zero DMA channels is valid */
- /*
- * Calculate the structure size based upon the number of interrupts
- */
- struct_size += (output_struct->data.dma.number_of_channels - 1) * 4;
+ output_struct->data.dma.number_of_channels = i;
+ if (i > 0) {
+ /*
+ * Calculate the structure size based upon the number of interrupts
+ */
+ struct_size += ((acpi_size) i - 1) * 4;
+ }
/*
* Point to Byte 2
@@ -432,6 +448,7 @@
output_struct->data.dma.transfer = temp8 & 0x03;
if (0x03 == output_struct->data.dma.transfer) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n"));
return_ACPI_STATUS (AE_BAD_DATA);
}
@@ -448,7 +465,7 @@
/*
* Set the Length parameter
*/
- output_struct->length = struct_size;
+ output_struct->length = (u32) struct_size;
/*
* Return the final size of the structure
@@ -460,13 +477,12 @@
/*******************************************************************************
*
- * FUNCTION: Acpi_rs_dma_stream
+ * FUNCTION: acpi_rs_dma_stream
*
- * PARAMETERS: Linked_list - Pointer to the resource linked list
- * Output_buffer - Pointer to the user's return buffer
- * Bytes_consumed - u32 pointer that is filled with
- * the number of bytes of the
- * Output_buffer used
+ * PARAMETERS: linked_list - Pointer to the resource linked list
+ * output_buffer - Pointer to the user's return buffer
+ * bytes_consumed - Pointer to where the number of bytes
+ * used in the output_buffer is returned
*
* RETURN: Status
*
@@ -477,17 +493,17 @@
acpi_status
acpi_rs_dma_stream (
- acpi_resource *linked_list,
- u8 **output_buffer,
- u32 *bytes_consumed)
+ struct acpi_resource *linked_list,
+ u8 **output_buffer,
+ acpi_size *bytes_consumed)
{
- u8 *buffer = *output_buffer;
- u16 temp16 = 0;
- u8 temp8 = 0;
- u8 index;
+ u8 *buffer = *output_buffer;
+ u16 temp16 = 0;
+ u8 temp8 = 0;
+ u8 index;
- FUNCTION_TRACE ("Rs_dma_stream");
+ ACPI_FUNCTION_TRACE ("rs_dma_stream");
/*
@@ -523,7 +539,7 @@
/*
* Return the number of bytes consumed in this operation
*/
- *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+ *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)