diff options
Diffstat (limited to 'drivers/acpi/resources')
-rw-r--r-- | drivers/acpi/resources/rsaddr.c | 480 | ||||
-rw-r--r-- | drivers/acpi/resources/rscalc.c | 144 | ||||
-rw-r--r-- | drivers/acpi/resources/rscreate.c | 45 | ||||
-rw-r--r-- | drivers/acpi/resources/rsdump.c | 402 | ||||
-rw-r--r-- | drivers/acpi/resources/rsio.c | 197 | ||||
-rw-r--r-- | drivers/acpi/resources/rsirq.c | 167 | ||||
-rw-r--r-- | drivers/acpi/resources/rslist.c | 68 | ||||
-rw-r--r-- | drivers/acpi/resources/rsmemory.c | 236 | ||||
-rw-r--r-- | drivers/acpi/resources/rsmisc.c | 160 | ||||
-rw-r--r-- | drivers/acpi/resources/rsutils.c | 53 | ||||
-rw-r--r-- | drivers/acpi/resources/rsxface.c | 43 |
11 files changed, 897 insertions, 1098 deletions
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 4788c079735..55d264771c4 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -77,21 +77,21 @@ acpi_rs_address16_resource ( u8 **output_buffer, acpi_size *structure_size) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *) *output_buffer; - u8 *temp_ptr; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16); u32 index; u16 temp16; u8 temp8; + u8 *temp_ptr; + u8 *buffer = byte_stream_buffer; + struct acpi_resource *output_struct = (void *) *output_buffer; + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_address16); ACPI_FUNCTION_TRACE ("rs_address16_resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -104,9 +104,8 @@ acpi_rs_address16_resource ( *bytes_consumed = temp16 + 3; output_struct->id = ACPI_RSTYPE_ADDRESS16; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + buffer += 2; temp8 = *buffer; @@ -118,9 +117,8 @@ acpi_rs_address16_resource ( output_struct->data.address16.resource_type = temp8; - /* - * Get the General Flags (Byte4) - */ + /* Get the General Flags (Byte4) */ + buffer += 1; temp8 = *buffer; @@ -140,9 +138,8 @@ acpi_rs_address16_resource ( output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + buffer += 1; temp8 = *buffer; @@ -165,39 +162,34 @@ acpi_rs_address16_resource ( } } - /* - * Get Granularity (Bytes 6-7) - */ + /* Get Granularity (Bytes 6-7) */ + buffer += 1; ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer); - /* - * Get min_address_range (Bytes 8-9) - */ + /* Get min_address_range (Bytes 8-9) */ + buffer += 2; ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer); - /* - * Get max_address_range (Bytes 10-11) - */ + /* Get max_address_range (Bytes 10-11) */ + buffer += 2; ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer); - /* - * Get address_translation_offset (Bytes 12-13) - */ + /* Get address_translation_offset (Bytes 12-13) */ + buffer += 2; - ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, buffer); + ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, + buffer); + + /* Get address_length (Bytes 14-15) */ - /* - * Get address_length (Bytes 14-15) - */ buffer += 2; ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer); - /* - * Resource Source Index (if present) - */ + /* Resource Source Index (if present) */ + buffer += 2; /* @@ -225,7 +217,8 @@ acpi_rs_address16_resource ( output_struct->data.address16.resource_source.string_ptr = (char *)((u8 * )output_struct + struct_size); - temp_ptr = (u8 *) output_struct->data.address16.resource_source.string_ptr; + temp_ptr = (u8 *) + output_struct->data.address16.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -239,9 +232,8 @@ acpi_rs_address16_resource ( index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *temp_ptr = 0x00; output_struct->data.address16.resource_source.string_length = index + 1; @@ -260,14 +252,12 @@ acpi_rs_address16_resource ( output_struct->data.address16.resource_source.string_ptr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -305,28 +295,24 @@ acpi_rs_address16_stream ( ACPI_FUNCTION_TRACE ("rs_address16_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x88; buffer += 1; - /* - * Save a pointer to the Length field - to be filled in later - */ + /* Save a pointer to the Length field - to be filled in later */ + length_field = buffer; buffer += 2; - /* - * Set the Resource Type (Memory, Io, bus_number) - */ + /* Set the Resource Type (Memory, Io, bus_number) */ + temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); *buffer = temp8; buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); temp8 |= (linked_list->data.address16.decode & 0x01) << 1; @@ -336,9 +322,8 @@ acpi_rs_address16_stream ( *buffer = temp8; buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + temp8 = 0; if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { @@ -362,39 +347,34 @@ acpi_rs_address16_stream ( *buffer = temp8; buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity); buffer += 2; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range); buffer += 2; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range); buffer += 2; - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_translation_offset); + /* Set the address translation offset */ + + ACPI_MOVE_32_TO_16 (buffer, + &linked_list->data.address16.address_translation_offset); buffer += 2; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length); buffer += 2; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != linked_list->data.address16.resource_source.string_length) { temp8 = (u8) linked_list->data.address16.resource_source.index; @@ -403,9 +383,8 @@ acpi_rs_address16_stream ( temp_pointer = (char *) buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (temp_pointer, linked_list->data.address16.resource_source.string_ptr); @@ -413,12 +392,12 @@ acpi_rs_address16_stream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1); + buffer += (acpi_size)(ACPI_STRLEN ( + linked_list->data.address16.resource_source.string_ptr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer); *bytes_consumed = actual_bytes; @@ -475,9 +454,8 @@ acpi_rs_address32_resource ( buffer = byte_stream_buffer; struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -490,9 +468,8 @@ acpi_rs_address32_resource ( *bytes_consumed = temp16 + 3; output_struct->id = ACPI_RSTYPE_ADDRESS32; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + buffer += 2; temp8 = *buffer; @@ -504,35 +481,29 @@ acpi_rs_address32_resource ( output_struct->data.address32.resource_type = temp8; - /* - * Get the General Flags (Byte4) - */ + /* Get the General Flags (Byte4) */ + buffer += 1; temp8 = *buffer; - /* - * Producer / Consumer - */ + /* Producer / Consumer */ + output_struct->data.address32.producer_consumer = temp8 & 0x01; - /* - * Decode - */ + /* Decode */ + output_struct->data.address32.decode = (temp8 >> 1) & 0x01; - /* - * Min Address Fixed - */ + /* Min Address Fixed */ + output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01; - /* - * Max Address Fixed - */ + /* Max Address Fixed */ + output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + buffer += 1; temp8 = *buffer; @@ -556,39 +527,34 @@ acpi_rs_address32_resource ( } } - /* - * Get Granularity (Bytes 6-9) - */ + /* Get Granularity (Bytes 6-9) */ + buffer += 1; ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer); - /* - * Get min_address_range (Bytes 10-13) - */ + /* Get min_address_range (Bytes 10-13) */ + buffer += 4; ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer); - /* - * Get max_address_range (Bytes 14-17) - */ + /* Get max_address_range (Bytes 14-17) */ + buffer += 4; ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer); - /* - * Get address_translation_offset (Bytes 18-21) - */ + /* Get address_translation_offset (Bytes 18-21) */ + buffer += 4; - ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, buffer); + ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, + buffer); + + /* Get address_length (Bytes 22-25) */ - /* - * Get address_length (Bytes 22-25) - */ buffer += 4; ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer); - /* - * Resource Source Index (if present) - */ + /* Resource Source Index (if present) */ + buffer += 4; /* @@ -615,7 +581,8 @@ acpi_rs_address32_resource ( output_struct->data.address32.resource_source.string_ptr = (char *)((u8 *)output_struct + struct_size); - temp_ptr = (u8 *) output_struct->data.address32.resource_source.string_ptr; + temp_ptr = (u8 *) + output_struct->data.address32.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -628,9 +595,8 @@ acpi_rs_address32_resource ( index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *temp_ptr = 0x00; output_struct->data.address32.resource_source.string_length = index + 1; @@ -648,14 +614,12 @@ acpi_rs_address32_resource ( output_struct->data.address32.resource_source.string_ptr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -694,29 +658,25 @@ acpi_rs_address32_stream ( buffer = *output_buffer; - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x87; buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + length_field = ACPI_CAST_PTR (u16, buffer); buffer += 2; - /* - * Set the Resource Type (Memory, Io, bus_number) - */ + /* Set the Resource Type (Memory, Io, bus_number) */ + temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); *buffer = temp8; buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); temp8 |= (linked_list->data.address32.decode & 0x01) << 1; temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2; @@ -725,9 +685,8 @@ acpi_rs_address32_stream ( *buffer = temp8; buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + temp8 = 0; if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { @@ -751,39 +710,34 @@ acpi_rs_address32_stream ( *buffer = temp8; buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity); buffer += 4; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range); buffer += 4; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range); buffer += 4; - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_translation_offset); + /* Set the address translation offset */ + + ACPI_MOVE_32_TO_32 (buffer, + &linked_list->data.address32.address_translation_offset); buffer += 4; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length); buffer += 4; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != linked_list->data.address32.resource_source.string_length) { temp8 = (u8) linked_list->data.address32.resource_source.index; @@ -792,9 +746,8 @@ acpi_rs_address32_stream ( temp_pointer = (char *) buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (temp_pointer, linked_list->data.address32.resource_source.string_ptr); @@ -802,12 +755,12 @@ acpi_rs_address32_stream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1); + buffer += (acpi_size)(ACPI_STRLEN ( + linked_list->data.address32.resource_source.string_ptr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); /* @@ -864,9 +817,8 @@ acpi_rs_address64_resource ( struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); resource_type = *buffer; - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -879,9 +831,8 @@ acpi_rs_address64_resource ( *bytes_consumed = temp16 + 3; output_struct->id = ACPI_RSTYPE_ADDRESS64; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + buffer += 2; temp8 = *buffer; @@ -893,35 +844,29 @@ acpi_rs_address64_resource ( output_struct->data.address64.resource_type = temp8; - /* - * Get the General Flags (Byte4) - */ + /* Get the General Flags (Byte4) */ + buffer += 1; temp8 = *buffer; - /* - * Producer / Consumer - */ + /* Producer / Consumer */ + output_struct->data.address64.producer_consumer = temp8 & 0x01; - /* - * Decode - */ + /* Decode */ + output_struct->data.address64.decode = (temp8 >> 1) & 0x01; - /* - * Min Address Fixed - */ + /* Min Address Fixed */ + output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01; - /* - * Max Address Fixed - */ + /* Max Address Fixed */ + output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + buffer += 1; temp8 = *buffer; @@ -951,33 +896,29 @@ acpi_rs_address64_resource ( buffer += 2; } - /* - * Get Granularity (Bytes 6-13) or (Bytes 8-15) - */ + /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ + buffer += 1; ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer); - /* - * Get min_address_range (Bytes 14-21) or (Bytes 16-23) - */ + /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ + buffer += 8; ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer); - /* - * Get max_address_range (Bytes 22-29) or (Bytes 24-31) - */ + /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ + buffer += 8; ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer); - /* - * Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) - */ + /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ + buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, buffer); + ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, + buffer); + + /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ - /* - * Get address_length (Bytes 38-45) or (Bytes 40-47) - */ buffer += 8; ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer); @@ -989,14 +930,15 @@ acpi_rs_address64_resource ( /* Get type_specific_attribute (Bytes 48-55) */ buffer += 8; - ACPI_MOVE_64_TO_64 (&output_struct->data.address64.type_specific_attributes, buffer); + ACPI_MOVE_64_TO_64 ( + &output_struct->data.address64.type_specific_attributes, + buffer); } else { output_struct->data.address64.type_specific_attributes = 0; - /* - * Resource Source Index (if present) - */ + /* Resource Source Index (if present) */ + buffer += 8; /* @@ -1025,7 +967,8 @@ acpi_rs_address64_resource ( output_struct->data.address64.resource_source.string_ptr = (char *)((u8 *)output_struct + struct_size); - temp_ptr = (u8 *) output_struct->data.address64.resource_source.string_ptr; + temp_ptr = (u8 *) + output_struct->data.address64.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -1042,7 +985,8 @@ acpi_rs_address64_resource ( * Add the terminating null */ *temp_ptr = 0x00; - output_struct->data.address64.resource_source.string_length = index + 1; + output_struct->data.address64.resource_source.string_length = + index + 1; /* * In order for the struct_size to fall on a 32-bit boundary, @@ -1054,14 +998,12 @@ acpi_rs_address64_resource ( } } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -1100,29 +1042,25 @@ acpi_rs_address64_stream ( buffer = *output_buffer; - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x8A; buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + length_field = ACPI_CAST_PTR (u16, buffer); buffer += 2; - /* - * Set the Resource Type (Memory, Io, bus_number) - */ + /* Set the Resource Type (Memory, Io, bus_number) */ + temp8 = (u8) (linked_list->data.address64.resource_type & 0x03); *buffer = temp8; buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01); temp8 |= (linked_list->data.address64.decode & 0x01) << 1; temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2; @@ -1131,9 +1069,8 @@ acpi_rs_address64_stream ( *buffer = temp8; buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + temp8 = 0; if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { @@ -1157,39 +1094,34 @@ acpi_rs_address64_stream ( *buffer = temp8; buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity); buffer += 8; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range); buffer += 8; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range); buffer += 8; - /* - * Set the address translation offset - */ - ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_translation_offset); + /* Set the address translation offset */ + + ACPI_MOVE_64_TO_64 (buffer, + &linked_list->data.address64.address_translation_offset); buffer += 8; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length); buffer += 8; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != linked_list->data.address64.resource_source.string_length) { temp8 = (u8) linked_list->data.address64.resource_source.index; @@ -1198,21 +1130,21 @@ acpi_rs_address64_stream ( temp_pointer = (char *) buffer; - /* - * Copy the string - */ - ACPI_STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr); + /* Copy the string */ + + ACPI_STRCPY (temp_pointer, + linked_list->data.address64.resource_source.string_ptr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1); + buffer += (acpi_size)(ACPI_STRLEN ( + linked_list->data.address64.resource_source.string_ptr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); /* diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 8a5f0a52371..98176f2fcb5 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -81,9 +81,8 @@ acpi_rs_get_byte_stream_length ( while (!done) { - /* - * Init the variable that will hold the size to add to the total. - */ + /* Init the variable that will hold the size to add to the total. */ + segment_size = 0; switch (linked_list->id) { @@ -196,7 +195,8 @@ acpi_rs_get_byte_stream_length ( segment_size = 16; if (linked_list->data.address16.resource_source.string_ptr) { - segment_size += linked_list->data.address16.resource_source.string_length; + segment_size += + linked_list->data.address16.resource_source.string_length; segment_size++; } break; @@ -212,7 +212,8 @@ acpi_rs_get_byte_stream_length ( segment_size = 26; if (linked_list->data.address32.resource_source.string_ptr) { - segment_size += linked_list->data.address32.resource_source.string_length; + segment_size += + linked_list->data.address32.resource_source.string_length; segment_size++; } break; @@ -227,7 +228,8 @@ acpi_rs_get_byte_stream_length ( segment_size = 46; if (linked_list->data.address64.resource_source.string_ptr) { - segment_size += linked_list->data.address64.resource_source.string_length; + segment_size += + linked_list->data.address64.resource_source.string_length; segment_size++; } break; @@ -241,38 +243,36 @@ acpi_rs_get_byte_stream_length ( * Index + the length of the null terminated string * Resource Source + 1 for the null. */ - segment_size = 9 + - (((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4); + segment_size = 9 + (((acpi_size) + linked_list->data.extended_irq.number_of_interrupts - 1) * 4); if (linked_list->data.extended_irq.resource_source.string_ptr) { - segment_size += linked_list->data.extended_irq.resource_source.string_length; + segment_size += + linked_list->data.extended_irq.resource_source.string_length; segment_size++; } break; default: - /* - * If we get here, everything is out of sync, exit with error - */ + + /* If we get here, everything is out of sync, exit with error */ + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } /* switch (linked_list->Id) */ - /* - * Update the total - */ + /* Update the total */ + byte_stream_size_needed += segment_size; - /* - * Point to the next object - */ + /* Point to the next object */ + linked_list = ACPI_PTR_ADD (struct acpi_resource, linked_list, linked_list->length); } - /* - * This is the data the caller needs - */ + /* This is the data the caller needs */ + *size_needed = byte_stream_size_needed; return_ACPI_STATUS (AE_OK); } @@ -320,9 +320,8 @@ acpi_rs_get_list_length ( while (bytes_parsed < byte_stream_buffer_length) { - /* - * The next byte in the stream is the resource type - */ + /* The next byte in the stream is the resource type */ + resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); switch (resource_type) { @@ -346,9 +345,8 @@ acpi_rs_get_list_length ( ACPI_MOVE_16_TO_16 (&temp16, buffer); bytes_consumed = temp16 + 3; - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + @@ -416,9 +414,8 @@ acpi_rs_get_list_length ( temp8 = 0; } - /* - * Ensure a 64-bit boundary for the structure - */ + /* Ensure a 64-bit boundary for the structure */ + temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) + @@ -452,9 +449,8 @@ acpi_rs_get_list_length ( temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) + @@ -488,9 +484,8 @@ acpi_rs_get_list_length ( temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) + @@ -537,9 +532,8 @@ acpi_rs_get_list_length ( temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) + @@ -567,9 +561,8 @@ acpi_rs_get_list_length ( ++buffer; - /* - * Look at the number of bits set - */ + /* Look at the number of bits set */ + ACPI_MOVE_16_TO_16 (&temp16, buffer); for (index = 0; index < 16; index++) { @@ -596,9 +589,8 @@ acpi_rs_get_list_length ( ++buffer; - /* - * Look at the number of bits set - */ + /* Look at the number of bits set */ + temp8 = *buffer; for(index = 0; index < 8; index++) { @@ -670,9 +662,8 @@ acpi_rs_get_list_length ( temp8 = (u8) (temp8 & 0x7); bytes_consumed = temp8 + 1; - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + (temp8 * sizeof (u8)); @@ -697,21 +688,18 @@ acpi_rs_get_list_length ( return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } - /* - * Update the return value and counter - */ + /* Update the return value and counter */ + buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size); bytes_parsed += bytes_consumed; - /* - * Set the byte stream to point to the next resource - */ + /* Set the byte stream to point to the next resource */ + byte_stream_buffer += bytes_consumed; } - /* - * This is the data the caller needs - */ + /* This is the data the caller needs */ + *size_needed = buffer_size; return_ACPI_STATUS (AE_OK); } @@ -767,9 +755,8 @@ acpi_rs_get_pci_routing_table_length ( top_object_list = package_object->package.elements; for (index = 0; index < number_of_elements; index++) { - /* - * Dereference the sub-package - */ + /* Dereference the sub-package */ + package_element = *top_object_list; /* @@ -778,37 +765,40 @@ acpi_rs_get_pci_routing_table_length ( */ sub_object_list = package_element->package.elements; - /* - * Scan the irq_table_elements for the Source Name String - */ + /* Scan the irq_table_elements for the Source Name String */ + name_found = FALSE; for (table_index = 0; table_index < 4 && !name_found; table_index++) { - if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*sub_object_list)) || - ((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*sub_object_list)) && - ((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) { + if ((ACPI_TYPE_STRING == + ACPI_GET_OBJECT_TYPE (*sub_object_list)) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + ACPI_GET_OBJECT_TYPE (*sub_object_list)) && + + ((*sub_object_list)->reference.opcode == + AML_INT_NAMEPATH_OP))) { name_found = TRUE; } else { - /* - * Look at the next element - */ + /* Look at the next element */ + sub_object_list++; } } temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4); - /* - * Was a String type found? - */ + /* Was a String type found? */ + if (name_found) { if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) { /* * The length String.Length field does not include the * terminating NULL, add 1 */ - temp_size_needed += ((acpi_size) (*sub_object_list)->string.length + 1); + temp_size_needed += ((acpi_size) + (*sub_object_list)->string.length + 1); } else { temp_size_needed += acpi_ns_get_pathname_length ( @@ -827,14 +817,14 @@ acpi_rs_get_pci_routing_table_length ( temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed); - /* - * Point to the next union acpi_operand_object - */ + /* Point to the next union acpi_operand_object */ + top_object_list++; } /* - * Adding an extra element to the end of the list, essentially a NULL terminator + * Adding an extra element to the end of the list, essentially a + * NULL terminator */ *buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table); return_ACPI_STATUS (AE_OK); diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index a3a0cbfda68..8e0eae0d50b 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -87,9 +87,8 @@ acpi_rs_create_resource_list ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n", byte_stream_buffer)); - /* - * Params already validated, so we don't re-validate here - */ + /* Params already validated, so we don't re-validate here */ + byte_stream_buffer_length = byte_stream_buffer->buffer.length; byte_stream_start = byte_stream_buffer->buffer.pointer; @@ -171,9 +170,8 @@ acpi_rs_create_pci_routing_table ( /* Params already validated, so we don't re-validate here */ - /* - * Get the required buffer length - */ + /* Get the required buffer length */ + status = acpi_rs_get_pci_routing_table_length (package_object, &buffer_size_needed); if (ACPI_FAILURE (status)) { @@ -217,9 +215,8 @@ acpi_rs_create_pci_routing_table ( */ user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4); - /* - * Each element of the top-level package must also be a package - */ + /* Each element of the top-level package must also be a package */ + if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(PRT[%X]) Need sub-package, found %s\n", @@ -243,9 +240,8 @@ acpi_rs_create_pci_routing_table ( */ sub_object_list = (*top_object_list)->package.elements; - /* - * 1) First subobject: Dereference the PRT.Address - */ + /* 1) First subobject: Dereference the PRT.Address */ + obj_desc = sub_object_list[0]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->address = obj_desc->integer.value; @@ -257,9 +253,8 @@ acpi_rs_create_pci_routing_table ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 2) Second subobject: Dereference the PRT.Pin - */ + /* 2) Second subobject: Dereference the PRT.Pin */ + obj_desc = sub_object_list[1]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->pin = (u32) obj_desc->integer.value; @@ -271,9 +266,8 @@ acpi_rs_create_pci_routing_table ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 3) Third subobject: Dereference the PRT.source_name - */ + /* 3) Third subobject: Dereference the PRT.source_name */ + obj_desc = sub_object_list[2]; switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { case ACPI_TYPE_LOCAL_REFERENCE: @@ -296,7 +290,9 @@ acpi_rs_create_pci_routing_table ( status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer); - user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; /* include null terminator */ + /* +1 to include null terminator */ + + user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; break; @@ -304,8 +300,10 @@ acpi_rs_create_pci_routing_table ( ACPI_STRCPY (user_prt->source, obj_desc->string.pointer); - /* Add to the Length field the length of the string (add 1 for terminator) */ - + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ user_prt->length += obj_desc->string.length + 1; break; @@ -333,9 +331,8 @@ acpi_rs_create_pci_routing_table ( user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length); - /* - * 4) Fourth subobject: Dereference the PRT.source_index - */ + /* 4) Fourth subobject: Dereference the PRT.source_index */ + obj_desc = sub_object_list[3]; if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { user_prt->source_index = (u32) obj_desc->integer.value; diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index eef1b1f2c68..1935dab2ab5 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -48,9 +48,62 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsdump") +/* Local prototypes */ -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +static void +acpi_rs_dump_irq ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_address16 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_address32 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_address64 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_dma ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_io ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_extended_irq ( + union acpi_resource_data *data); +static void +acpi_rs_dump_fixed_io ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_fixed_memory32 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_memory24 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_memory32 ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_start_depend_fns ( + union acpi_resource_data *data); + +static void +acpi_rs_dump_vendor_specific ( + union acpi_resource_data *data); + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * * FUNCTION: acpi_rs_dump_irq @@ -63,7 +116,7 @@ * ******************************************************************************/ -void +static void acpi_rs_dump_irq ( union acpi_resource_data *data) { @@ -77,13 +130,13 @@ acpi_rs_dump_irq ( acpi_os_printf ("IRQ Resource\n"); acpi_os_printf (" %s Triggered\n", - ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); + ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); acpi_os_printf (" Active %s\n", - ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); + ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); acpi_os_printf (" %s\n", - ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); + ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts); @@ -108,7 +161,7 @@ acpi_rs_dump_irq ( * ******************************************************************************/ -void +static void acpi_rs_dump_dma ( union acpi_resource_data *data) { @@ -144,7 +197,7 @@ acpi_rs_dump_dma ( } acpi_os_printf (" %sBus Master\n", - ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); + ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); switch (dma_data->transfer) { @@ -165,7 +218,8 @@ acpi_rs_dump_dma ( break; } - acpi_os_printf (" Number of Channels: %X ( ", dma_data->number_of_channels); + acpi_os_printf (" Number of Channels: %X ( ", + dma_data->number_of_channels); for (index = 0; index < dma_data->number_of_channels; index++) { acpi_os_printf ("%X ", dma_data->channels[index]); @@ -188,7 +242,7 @@ acpi_rs_dump_dma ( * ******************************************************************************/ -void +static void acpi_rs_dump_start_depend_fns ( union acpi_resource_data *data) { @@ -232,8 +286,7 @@ acpi_rs_dump_start_depend_fns ( break; default: - acpi_os_printf (" Invalid performance " - "robustness preference\n"); + acpi_os_printf (" Invalid performance robustness preference\n"); break; } @@ -253,7 +306,7 @@ acpi_rs_dump_start_depend_fns ( * ******************************************************************************/ -void +static void acpi_rs_dump_io ( union acpi_resource_data *data) { @@ -266,19 +319,15 @@ acpi_rs_dump_io ( acpi_os_printf ("Io Resource\n"); acpi_os_printf (" %d bit decode\n", - ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); + ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); - acpi_os_printf (" Range minimum base: %08X\n", - io_data->min_base_address); + acpi_os_printf (" Range minimum base: %08X\n", io_data->min_base_address); - acpi_os_printf (" Range maximum base: %08X\n", - io_data->max_base_address); + acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address); - acpi_os_printf (" Alignment: %08X\n", - io_data->alignment); + acpi_os_printf (" Alignment: %08X\n", io_data->alignment); - acpi_os_printf (" Range Length: %08X\n", - io_data->range_length); + acpi_os_printf (" Range Length: %08X\n", io_data->range_length); return; } @@ -296,7 +345,7 @@ acpi_rs_dump_io ( * ******************************************************************************/ -void +static void acpi_rs_dump_fixed_io ( union acpi_resource_data *data) { @@ -307,11 +356,9 @@ acpi_rs_dump_fixed_io ( acpi_os_printf ("Fixed Io Resource\n"); - acpi_os_printf (" Range base address: %08X", - fixed_io_data->base_address); + acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address); - acpi_os_printf (" Range length: %08X", - fixed_io_data->range_length); + acpi_os_printf (" Range length: %08X", fixed_io_data->range_length); return; } @@ -329,7 +376,7 @@ acpi_rs_dump_fixed_io ( * ******************************************************************************/ -void +static void acpi_rs_dump_vendor_specific ( union acpi_resource_data *data) { @@ -346,7 +393,7 @@ acpi_rs_dump_vendor_specific ( for (index = 0; index < vendor_data->length; index++) { acpi_os_printf (" Byte %X: %08X\n", - index, vendor_data->reserved[index]); + index, vendor_data->reserved[index]); } return; @@ -365,7 +412,7 @@ acpi_rs_dump_vendor_specific ( * ******************************************************************************/ -void +static void acpi_rs_dump_memory24 ( union acpi_resource_data *data) { @@ -378,21 +425,19 @@ acpi_rs_dump_memory24 ( acpi_os_printf ("24-Bit Memory Range Resource\n"); acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - memory24_data->read_write_attribute ? - "/Write" : " only"); + ACPI_READ_WRITE_MEMORY == + memory24_data->read_write_attribute ? + "/Write" : " only"); acpi_os_printf (" Range minimum base: %08X\n", - memory24_data->min_base_address); + memory24_data->min_base_address); acpi_os_printf (" Range maximum base: %08X\n", - memory24_data->max_base_address); + memory24_data->max_base_address); - acpi_os_printf (" Alignment: %08X\n", - memory24_data->alignment); + acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment); - acpi_os_printf (" Range length: %08X\n", - memory24_data->range_length); + acpi_os_printf (" Range length: %08X\n", memory24_data->range_length); return; } @@ -410,7 +455,7 @@ acpi_rs_dump_memory24 ( * ******************************************************************************/ -void +static void acpi_rs_dump_memory32 ( union acpi_resource_data *data) { @@ -423,21 +468,19 @@ acpi_rs_dump_memory32 ( acpi_os_printf ("32-Bit Memory Range Resource\n"); acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - memory32_data->read_write_attribute ? - "/Write" : " only"); + ACPI_READ_WRITE_MEMORY == + memory32_data->read_write_attribute ? + "/Write" : " only"); acpi_os_printf (" Range minimum base: %08X\n", - memory32_data->min_base_address); + memory32_data->min_base_address); acpi_os_printf (" Range maximum base: %08X\n", - memory32_data->max_base_address); + memory32_data->max_base_address); - acpi_os_printf (" Alignment: %08X\n", - memory32_data->alignment); + acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment); - acpi_os_printf (" Range length: %08X\n", - memory32_data->range_length); + acpi_os_printf (" Range length: %08X\n", memory32_data->range_length); return; } @@ -455,11 +498,12 @@ acpi_rs_dump_memory32 ( * ******************************************************************************/ -void +static void acpi_rs_dump_fixed_memory32 ( union acpi_resource_data *data) { - struct acpi_resource_fixed_mem32 *fixed_memory32_data = (struct acpi_resource_fixed_mem32 *) data; + struct acpi_resource_fixed_mem32 *fixed_memory32_data = + (struct acpi_resource_fixed_mem32 *) data; ACPI_FUNCTION_ENTRY (); @@ -468,15 +512,14 @@ acpi_rs_dump_fixed_memory32 ( acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n"); acpi_os_printf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - fixed_memory32_data->read_write_attribute ? - "/Write" : " Only"); + ACPI_READ_WRITE_MEMORY == + fixed_memory32_data->read_write_attribute ? "/Write" : " Only"); acpi_os_printf (" Range base address: %08X\n", - fixed_memory32_data->range_base_address); + fixed_memory32_data->range_base_address); acpi_os_printf (" Range length: %08X\n", - fixed_memory32_data->range_length); + fixed_memory32_data->range_length); return; } @@ -494,7 +537,7 @@ acpi_rs_dump_fixed_memory32 ( * ******************************************************************************/ -void +static void acpi_rs_dump_address16 ( union acpi_resource_data *data) { @@ -514,35 +557,30 @@ acpi_rs_dump_address16 ( switch (address16_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Noncacheable memory\n"); + acpi_os_printf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Cacheable memory\n"); + acpi_os_printf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: " - "Write-combining memory\n"); + acpi_os_printf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Prefetchable memory\n"); + acpi_os_printf (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid cache attribute\n"); + acpi_os_printf (" Type Specific: Invalid cache attribute\n"); break; } acpi_os_printf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - address16_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + address16_data->attribute.memory.read_write_attribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -551,30 +589,26 @@ acpi_rs_dump_address16 ( switch (address16_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "Non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid range attribute\n"); + acpi_os_printf (" Type Specific: Invalid range attribute\n"); break; } acpi_os_printf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - address16_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + address16_data->attribute.io.translation_attribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -589,41 +623,42 @@ acpi_rs_dump_address16 ( } acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address16_data->producer_consumer ? + ACPI_CONSUMER == address16_data->producer_consumer ? "Consumer" : "Producer"); acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address16_data->decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == address16_data->decode ? + "Subtractive" : "Positive"); acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? - "" : "not"); + ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? + "" : "not"); acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? - "" : "not"); + ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? + "" : "not"); acpi_os_printf (" Granularity: %08X\n", - address16_data->granularity); + address16_data->granularity); acpi_os_printf (" Address range min: %08X\n", - address16_data->min_address_range); + address16_data->min_address_range); acpi_os_printf (" Address range max: %08X\n", - address16_data->max_address_range); + address16_data->max_address_range); acpi_os_printf (" Address translation offset: %08X\n", - address16_data->address_translation_offset); + address16_data->address_translation_offset); acpi_os_printf (" Address Length: %08X\n", - address16_data->address_length); + address16_data->address_length); if (0xFF != address16_data->resource_source.index) { acpi_os_printf (" Resource Source Index: %X\n", - address16_data->resource_source.index); + address16_data->resource_source.index); + acpi_os_printf (" Resource Source: %s\n", - address16_data->resource_source.string_ptr); + address16_data->resource_source.string_ptr); } return; @@ -642,7 +677,7 @@ acpi_rs_dump_address16 ( * ******************************************************************************/ -void +static void acpi_rs_dump_address32 ( union acpi_resource_data *data) { @@ -661,35 +696,30 @@ acpi_rs_dump_address32 ( switch (address32_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Noncacheable memory\n"); + acpi_os_printf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Cacheable memory\n"); + acpi_os_printf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: " - "Write-combining memory\n"); + acpi_os_printf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Prefetchable memory\n"); + acpi_os_printf (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid cache attribute\n"); + acpi_os_printf (" Type Specific: Invalid cache attribute\n"); break; } acpi_os_printf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - address32_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + address32_data->attribute.memory.read_write_attribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -698,30 +728,26 @@ acpi_rs_dump_address32 ( switch (address32_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "Non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid Range attribute"); + acpi_os_printf (" Type Specific: Invalid Range attribute"); break; } acpi_os_printf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - address32_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + address32_data->attribute.io.translation_attribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -731,46 +757,48 @@ acpi_rs_dump_address32 ( default: - acpi_os_printf (" Resource Type: 0x%2.2X\n", address32_data->resource_type); + acpi_os_printf (" Resource Type: 0x%2.2X\n", + address32_data->resource_type); break; } acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address32_data->producer_consumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == address32_data->producer_consumer ? + "Consumer" : "Producer"); acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address32_data->decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == address32_data->decode ? + "Subtractive" : "Positive"); acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? + "" : "not "); acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? + "" : "not "); acpi_os_printf (" Granularity: %08X\n", - address32_data->granularity); + address32_data->granularity); acpi_os_printf (" Address range min: %08X\n", - address32_data->min_address_range); + address32_data->min_address_range); acpi_os_printf (" Address range max: %08X\n", - address32_data->max_address_range); + address32_data->max_address_range); acpi_os_printf (" Address translation offset: %08X\n", - address32_data->address_translation_offset); + address32_data->address_translation_offset); acpi_os_printf (" Address Length: %08X\n", - address32_data->address_length); + address32_data->address_length); if(0xFF != address32_data->resource_source.index) { acpi_os_printf (" Resource Source Index: %X\n", - address32_data->resource_source.index); + address32_data->resource_source.index); + acpi_os_printf (" Resource Source: %s\n", - address32_data->resource_source.string_ptr); + address32_data->resource_source.string_ptr); } return; @@ -789,7 +817,7 @@ acpi_rs_dump_address32 ( * ******************************************************************************/ -void +static void acpi_rs_dump_address64 ( union acpi_resource_data *data) { @@ -808,35 +836,30 @@ acpi_rs_dump_address64 ( switch (address64_data->attribute.memory.cache_attribute) { case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Noncacheable memory\n"); + acpi_os_printf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Cacheable memory\n"); + acpi_os_printf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf (" Type Specific: " - "Write-combining memory\n"); + acpi_os_printf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf (" Type Specific: " - "Prefetchable memory\n"); + acpi_os_printf (" Type Specific: Prefetchable memory\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid cache attribute\n"); + acpi_os_printf (" Type Specific: Invalid cache attribute\n"); break; } acpi_os_printf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - address64_data->attribute.memory.read_write_attribute ? - "/Write" : " Only"); + address64_data->attribute.memory.read_write_attribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -845,30 +868,26 @@ acpi_rs_dump_address64 ( switch (address64_data->attribute.io.range_attribute) { case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "Non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - acpi_os_printf (" Type Specific: " - "ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - acpi_os_printf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - acpi_os_printf (" Type Specific: " - "Invalid Range attribute"); + acpi_os_printf (" Type Specific: Invalid Range attribute"); break; } acpi_os_printf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - address64_data->attribute.io.translation_attribute ? - "Sparse" : "Dense"); + address64_data->attribute.io.translation_attribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -878,49 +897,51 @@ acpi_rs_dump_address64 ( default: - acpi_os_printf (" Resource Type: 0x%2.2X\n", address64_data->resource_type); + acpi_os_printf (" Resource Type: 0x%2.2X\n", + address64_data->resource_type); break; } acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == address64_data->producer_consumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == address64_data->producer_consumer ? + "Consumer" : "Producer"); acpi_os_printf (" %s decode\n", - ACPI_SUB_DECODE == address64_data->decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == address64_data->decode ? + "Subtractive" : "Positive"); acpi_os_printf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? + "" : "not "); acpi_os_printf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? + "" : "not "); acpi_os_printf (" Granularity: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->granularity)); + ACPI_FORMAT_UINT64 (address64_data->granularity)); acpi_os_printf (" Address range min: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->min_address_range)); + ACPI_FORMAT_UINT64 (address64_data->min_address_range)); acpi_os_printf (" Address range max: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->max_address_range)); + ACPI_FORMAT_UINT64 (address64_data->max_address_range)); acpi_os_printf (" Address translation offset: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); + ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); acpi_os_printf (" Address Length: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->address_length)); + ACPI_FORMAT_UINT64 (address64_data->address_length)); acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); + ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); if (0xFF != address64_data->resource_source.index) { acpi_os_printf (" Resource Source Index: %X\n", - address64_data->resource_source.index); + address64_data->resource_source.index); + acpi_os_printf (" Resource Source: %s\n", - address64_data->resource_source.string_ptr); + address64_data->resource_source.string_ptr); } return; @@ -939,7 +960,7 @@ acpi_rs_dump_address64 ( * ******************************************************************************/ -void +static void acpi_rs_dump_extended_irq ( union acpi_resource_data *data) { @@ -953,23 +974,22 @@ acpi_rs_dump_extended_irq ( acpi_os_printf ("Extended IRQ Resource\n"); acpi_os_printf (" Resource %s\n", - ACPI_CONSUMER == ext_irq_data->producer_consumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == ext_irq_data->producer_consumer ? + "Consumer" : "Producer"); acpi_os_printf (" %s\n", - ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? - "Level" : "Edge"); + ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? + "Level" : "Edge"); acpi_os_printf (" Active %s\n", - ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? - "low" : "high"); + ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? + "low" : "high"); acpi_os_printf (" %s\n", - ACPI_SHARED == ext_irq_data->shared_exclusive ? - "Shared" : "Exclusive"); + ACPI_SHARED == ext_irq_data->shared_exclusive ? + "Shared" : "Exclusive"); - acpi_os_printf (" Interrupts : %X ( ", - ext_irq_data->number_of_interrupts); + acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts); for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); @@ -979,9 +999,10 @@ acpi_rs_dump_extended_irq ( if(0xFF != ext_irq_data->resource_source.index) { acpi_os_printf (" Resource Source Index: %X", - ext_irq_data->resource_source.index); + ext_irq_data->resource_source.index); + acpi_os_printf (" Resource Source: %s", - ext_irq_data->resource_source.string_ptr); + ext_irq_data->resource_source.string_ptr); } return; @@ -992,7 +1013,7 @@ acpi_rs_dump_extended_irq ( * * FUNCTION: acpi_rs_dump_resource_list * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Resource - pointer to the resource structure to dump. * * RETURN: None * @@ -1096,7 +1117,7 @@ acpi_rs_dump_resource_list ( * * FUNCTION: acpi_rs_dump_irq_list * - * PARAMETERS: Data - pointer to the routing table to dump. + * PARAMETERS: route_table - pointer to the routing table to dump. * * RETURN: None * @@ -1124,20 +1145,17 @@ acpi_rs_dump_irq_list ( acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++); acpi_os_printf (" Address: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (prt_element->address)); + ACPI_FORMAT_UINT64 (prt_element->address)); acpi_os_printf (" Pin: %X\n", prt_element->pin); acpi_os_printf (" Source: %s\n", prt_element->source); - acpi_os_printf (" source_index: %X\n", - prt_element->source_index); + acpi_os_printf (" source_index: %X\n", prt_element->source_index); buffer += prt_element->length; - prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); - - if(0 == prt_element->length) { + if (0 == prt_element->length) { done = TRUE; } } diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 972c746d37e..23a4d149fac 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c @@ -81,67 +81,60 @@ acpi_rs_io_resource ( 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); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_io); ACPI_FUNCTION_TRACE ("rs_io_resource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *bytes_consumed = 8; output_struct->id = ACPI_RSTYPE_IO; - /* - * Check Decode - */ + /* Check Decode */ + buffer += 1; temp8 = *buffer; output_struct->data.io.io_decode = temp8 & 0x01; - /* - * Check min_base Address - */ + /* Check min_base Address */ + buffer += 1; 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; ACPI_MOVE_16_TO_16 (&temp16, buffer); output_struct->data.io.max_base_address = temp16; - /* - * Check Base alignment - */ + /* Check Base alignment */ + buffer += 2; temp8 = *buffer; output_struct->data.io.alignment = temp8; - /* - * Check range_length - */ + /* Check range_length */ + buffer += 1; temp8 = *buffer; output_struct->data.io.range_length = temp8; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -179,43 +172,39 @@ acpi_rs_fixed_io_resource ( 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); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_fixed_io); ACPI_FUNCTION_TRACE ("rs_fixed_io_resource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *bytes_consumed = 4; output_struct->id = ACPI_RSTYPE_FIXED_IO; - /* - * Check Range Base Address - */ + /* Check Range Base Address */ + buffer += 1; 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; output_struct->data.fixed_io.range_length = temp8; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -251,55 +240,48 @@ acpi_rs_io_stream ( ACPI_FUNCTION_TRACE ("rs_io_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x47; buffer += 1; - /* - * Io Information Byte - */ + /* Io Information Byte */ + temp8 = (u8) (linked_list->data.io.io_decode & 0x01); *buffer = temp8; buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + temp16 = (u16) linked_list->data.io.min_base_address; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + temp16 = (u16) linked_list->data.io.max_base_address; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the base alignment - */ + /* Set the base alignment */ + temp8 = (u8) linked_list->data.io.alignment; *buffer = temp8; buffer += 1; - /* - * Set the range length - */ + /* Set the range length */ + temp8 = (u8) linked_list->data.io.range_length; *buffer = temp8; buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -335,32 +317,28 @@ acpi_rs_fixed_io_stream ( ACPI_FUNCTION_TRACE ("rs_fixed_io_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x4B; buffer += 1; - /* - * Set the Range base address - */ + /* Set the Range base address */ + temp16 = (u16) linked_list->data.fixed_io.base_address; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the range length - */ + /* Set the range length */ + temp8 = (u8) linked_list->data.fixed_io.range_length; *buffer = temp8; buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -399,21 +377,20 @@ acpi_rs_dma_resource ( u8 temp8 = 0; u8 index; u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_dma); ACPI_FUNCTION_TRACE ("rs_dma_resource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *bytes_consumed = 3; output_struct->id = ACPI_RSTYPE_DMA; - /* - * Point to the 8-bits of Byte 1 - */ + /* Point to the 8-bits of Byte 1 */ + buffer += 1; temp8 = *buffer; @@ -430,46 +407,40 @@ acpi_rs_dma_resource ( output_struct->data.dma.number_of_channels = i; if (i > 0) { - /* - * Calculate the structure size based upon the number of interrupts - */ + /* Calculate the structure size based upon the number of interrupts */ + struct_size += ((acpi_size) i - 1) * 4; } - /* - * Point to Byte 2 - */ + /* Point to Byte 2 */ + buffer += 1; temp8 = *buffer; - /* - * Check for transfer preference (Bits[1:0]) - */ + /* Check for transfer preference (Bits[1:0]) */ + 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")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid DMA.Transfer preference (3)\n")); return_ACPI_STATUS (AE_BAD_DATA); } - /* - * Get bus master preference (Bit[2]) - */ + /* Get bus master preference (Bit[2]) */ + output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; - /* - * Get channel speed support (Bits[6:5]) - */ + /* Get channel speed support (Bits[6:5]) */ + output_struct->data.dma.type = (temp8 >> 5) & 0x03; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -506,16 +477,14 @@ acpi_rs_dma_stream ( ACPI_FUNCTION_TRACE ("rs_dma_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x2A; buffer += 1; temp8 = 0; - /* - * Loop through all of the Channels and set the mask bits - */ + /* Loop through all of the Channels and set the mask bits */ + for (index = 0; index < linked_list->data.dma.number_of_channels; index++) { @@ -526,9 +495,8 @@ acpi_rs_dma_stream ( *buffer = temp8; buffer += 1; - /* - * Set the DMA Info - */ + /* Set the DMA Info */ + temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); temp8 |= (linked_list->data.dma.transfer & 0x03); @@ -536,9 +504,8 @@ acpi_rs_dma_stream ( *buffer = temp8; buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index fd07a8702fb..8a2b630be45 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -83,7 +83,8 @@ acpi_rs_irq_resource ( u8 temp8 = 0; u8 index; u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_irq); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_irq); ACPI_FUNCTION_TRACE ("rs_irq_resource"); @@ -91,15 +92,14 @@ acpi_rs_irq_resource ( /* * The number of bytes consumed are contained in the descriptor - * (Bits:0-1) + * (Bits:0-1) */ temp8 = *buffer; *bytes_consumed = (temp8 & 0x03) + 1; output_struct->id = ACPI_RSTYPE_IRQ; - /* - * Point to the 16-bits of Bytes 1 and 2 - */ + /* Point to the 16-bits of Bytes 1 and 2 */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -118,22 +118,19 @@ acpi_rs_irq_resource ( output_struct->data.irq.number_of_interrupts = i; if (i > 0) { - /* - * Calculate the structure size based upon the number of interrupts - */ + /* Calculate the structure size based upon the number of interrupts */ + struct_size += ((acpi_size) i - 1) * 4; } - /* - * Point to Byte 3 if it is used - */ + /* Point to Byte 3 if it is used */ + if (4 == *bytes_consumed) { buffer += 2; temp8 = *buffer; - /* - * Check for HE, LL interrupts - */ + /* Check for HE, LL interrupts */ + switch (temp8 & 0x09) { case 0x01: /* HE */ output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; @@ -152,13 +149,13 @@ acpi_rs_irq_resource ( * so 0x00 and 0x09 are illegal. */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", temp8)); + "Invalid interrupt polarity/trigger in resource list, %X\n", + temp8)); return_ACPI_STATUS (AE_BAD_DATA); } - /* - * Check for sharable - */ + /* Check for sharable */ + output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; } else { @@ -171,14 +168,12 @@ acpi_rs_irq_resource ( output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -234,9 +229,8 @@ acpi_rs_irq_stream ( buffer += 1; temp16 = 0; - /* - * Loop through all of the interrupts and set the mask bits - */ + /* Loop through all of the interrupts and set the mask bits */ + for(index = 0; index < linked_list->data.irq.number_of_interrupts; index++) { @@ -247,9 +241,8 @@ acpi_rs_irq_stream ( ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the IRQ Info byte if needed. - */ + /* Set the IRQ Info byte if needed. */ + if (IRqinfo_byte_needed) { temp8 = 0; temp8 = (u8) ((linked_list->data.irq.shared_exclusive & @@ -267,9 +260,8 @@ acpi_rs_irq_stream ( buffer += 1; } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -309,15 +301,15 @@ acpi_rs_extended_irq_resource ( u8 temp8 = 0; u8 *temp_ptr; u8 index; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_ext_irq); ACPI_FUNCTION_TRACE ("rs_extended_irq_resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -330,9 +322,8 @@ acpi_rs_extended_irq_resource ( *bytes_consumed = temp16 + 3; output_struct->id = ACPI_RSTYPE_EXT_IRQ; - /* - * Point to the Byte3 - */ + /* Point to the Byte3 */ + buffer += 2; temp8 = *buffer; @@ -347,21 +338,18 @@ acpi_rs_extended_irq_resource ( * - Edge/Level are defined opposite in the table vs the headers */ output_struct->data.extended_irq.edge_level = - (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + + /* Check Interrupt Polarity */ - /* - * Check Interrupt Polarity - */ output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; - /* - * Check for sharable - */ + /* Check for sharable */ + output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; - /* - * Point to Byte4 (IRQ Table length) - */ + /* Point to Byte4 (IRQ Table length) */ + buffer += 1; temp8 = *buffer; @@ -379,14 +367,12 @@ acpi_rs_extended_irq_resource ( */ struct_size += (temp8 - 1) * 4; - /* - * Point to Byte5 (First IRQ Number) - */ + /* Point to Byte5 (First IRQ Number) */ + buffer += 1; - /* - * Cycle through every IRQ in the table - */ + /* Cycle through every IRQ in the table */ + for (index = 0; index < temp8; index++) { ACPI_MOVE_32_TO_32 ( &output_struct->data.extended_irq.interrupts[index], buffer); @@ -407,7 +393,8 @@ acpi_rs_extended_irq_resource ( * we add 1 to the length. */ if (*bytes_consumed > - ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + (5 + 1)) { + ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + + (5 + 1)) { /* Dereference the Index */ temp8 = *buffer; @@ -417,13 +404,13 @@ acpi_rs_extended_irq_resource ( buffer += 1; - /* - * Point the String pointer to the end of this structure. - */ + /* Point the String pointer to the end of this structure. */ + output_struct->data.extended_irq.resource_source.string_ptr = (char *)((char *) output_struct + struct_size); - temp_ptr = (u8 *) output_struct->data.extended_irq.resource_source.string_ptr; + temp_ptr = (u8 *) + output_struct->data.extended_irq.resource_source.string_ptr; /* Copy the string into the buffer */ @@ -436,9 +423,8 @@ acpi_rs_extended_irq_resource ( index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *temp_ptr = 0x00; output_struct->data.extended_irq.resource_source.string_length = index + 1; @@ -456,14 +442,12 @@ acpi_rs_extended_irq_resource ( output_struct->data.extended_irq.resource_source.string_ptr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -501,21 +485,18 @@ acpi_rs_extended_irq_stream ( ACPI_FUNCTION_TRACE ("rs_extended_irq_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x89; buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + length_field = ACPI_CAST_PTR (u16, buffer); buffer += 2; - /* - * Set the Interrupt vector flags - */ + /* Set the Interrupt vector flags */ + temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); @@ -532,17 +513,15 @@ acpi_rs_extended_irq_stream ( temp8 |= 0x2; } - /* - * Set the Interrupt Polarity - */ + /* Set the Interrupt Polarity */ + temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2); *buffer = temp8; buffer += 1; - /* - * Set the Interrupt table length - */ + /* Set the Interrupt table length */ + temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; *buffer = temp8; @@ -555,18 +534,16 @@ acpi_rs_extended_irq_stream ( buffer += 4; } - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != linked_list->data.extended_irq.resource_source.string_length) { *buffer = (u8) linked_list->data.extended_irq.resource_source.index; buffer += 1; temp_pointer = (char *) buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (temp_pointer, linked_list->data.extended_irq.resource_source.string_ptr); @@ -574,12 +551,12 @@ acpi_rs_extended_irq_stream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1); + buffer += (acpi_size) (ACPI_STRLEN ( + linked_list->data.extended_irq.resource_source.string_ptr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); /* diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index e49c1e030f9..db7bcb4e60e 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -55,7 +55,7 @@ * * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor * - * RETURN: The Resource Type (Name) with no extraneous bits + * RETURN: The Resource Type with no extraneous bits * * DESCRIPTION: Extract the Resource Type/Name from the first byte of * a resource descriptor. @@ -70,28 +70,25 @@ acpi_rs_get_resource_type ( ACPI_FUNCTION_ENTRY (); - /* - * Determine if this is a small or large resource - */ + /* Determine if this is a small or large resource */ + switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) { case ACPI_RDESC_TYPE_SMALL: - /* - * Small Resource Type -- Only bits 6:3 are valid - */ + /* Small Resource Type -- Only bits 6:3 are valid */ + return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK)); case ACPI_RDESC_TYPE_LARGE: - /* - * Large Resource Type -- All bits are valid - */ + /* Large Resource Type -- All bits are valid */ + return (resource_start_byte); default: - /* No other types of resource descriptor */ + /* Invalid type */ break; } @@ -135,9 +132,8 @@ acpi_rs_byte_stream_to_list ( while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) { - /* - * The next byte in the stream is the resource type - */ + /* The next byte in the stream is the resource type */ + resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); switch (resource_type) { @@ -299,28 +295,23 @@ acpi_rs_byte_stream_to_list ( return_ACPI_STATUS (status); } - /* - * Update the return value and counter - */ + /* Update the return value and counter */ + bytes_parsed += bytes_consumed; - /* - * Set the byte stream to point to the next resource - */ + /* Set the byte stream to point to the next resource */ + byte_stream_buffer += bytes_consumed; - /* - * Set the Buffer to the next structure - */ + /* Set the Buffer to the next structure */ + resource = ACPI_CAST_PTR (struct acpi_resource, buffer); resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length); buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size); + } - } /* end while */ + /* Check the reason for exiting the while loop */ - /* - * Check the reason for exiting the while loop - */ if (!end_tag_processed) { return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); } @@ -424,9 +415,8 @@ acpi_rs_list_to_byte_stream ( */ status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed); - /* - * An End Tag indicates the end of the Resource Template - */ + /* An End Tag indicates the end of the Resource Template */ + done = TRUE; break; @@ -488,27 +478,25 @@ acpi_rs_list_to_byte_stream ( default: /* * If we get here, everything is out of sync, - * so exit with an error + * so exit with an error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid descriptor type (%X) in resource list\n", linked_list->id)); status = AE_BAD_DATA; break; - - } /* switch (linked_list->Id) */ + } if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } - /* - * Set the Buffer to point to the open byte - */ + /* Set the Buffer to point to the open byte */ + buffer += bytes_consumed; - /* - * Point to the next object - */ + /* Point to the next object */ + linked_list = ACPI_PTR_ADD (struct acpi_resource, linked_list, linked_list->length); } diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 7c935aecf07..91d0207f01a 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c @@ -81,15 +81,15 @@ acpi_rs_memory24_resource ( struct acpi_resource *output_struct = (void *) *output_buffer; u16 temp16 = 0; u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_mem24); ACPI_FUNCTION_TRACE ("rs_memory24_resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -97,48 +97,41 @@ acpi_rs_memory24_resource ( *bytes_consumed = (acpi_size) temp16 + 3; output_struct->id = ACPI_RSTYPE_MEM24; - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + temp8 = *buffer; buffer += 1; output_struct->data.memory24.read_write_attribute = temp8 & 0x01; - /* - * Get min_base_address (Bytes 4-5) - */ + /* Get min_base_address (Bytes 4-5) */ + ACPI_MOVE_16_TO_16 (&temp16, buffer); buffer += 2; output_struct->data.memory24.min_base_address = temp16; - /* - * Get max_base_address (Bytes 6-7) - */ + /* Get max_base_address (Bytes 6-7) */ + ACPI_MOVE_16_TO_16 (&temp16, buffer); buffer += 2; output_struct->data.memory24.max_base_address = temp16; - /* - * Get Alignment (Bytes 8-9) - */ + /* Get Alignment (Bytes 8-9) */ + ACPI_MOVE_16_TO_16 (&temp16, buffer); buffer += 2; output_struct->data.memory24.alignment = temp16; - /* - * Get range_length (Bytes 10-11) - */ + /* Get range_length (Bytes 10-11) */ + ACPI_MOVE_16_TO_16 (&temp16, buffer); output_struct->data.memory24.range_length = temp16; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -174,53 +167,45 @@ acpi_rs_memory24_stream ( ACPI_FUNCTION_TRACE ("rs_memory24_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x81; buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + temp16 = 0x09; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); *buffer = temp8; buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address); buffer += 2; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address); buffer += 2; - /* - * Set the base alignment - */ + /* Set the base alignment */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment); buffer += 2; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length); buffer += 2; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -258,15 +243,15 @@ acpi_rs_memory32_range_resource ( struct acpi_resource *output_struct = (void *) *output_buffer; u16 temp16 = 0; u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_mem32); ACPI_FUNCTION_TRACE ("rs_memory32_range_resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -285,45 +270,38 @@ acpi_rs_memory32_range_resource ( * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) */ - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + temp8 = *buffer; buffer += 1; output_struct->data.memory32.read_write_attribute = temp8 & 0x01; - /* - * Get min_base_address (Bytes 4-7) - */ + /* Get min_base_address (Bytes 4-7) */ + ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer); buffer += 4; - /* - * Get max_base_address (Bytes 8-11) - */ + /* Get max_base_address (Bytes 8-11) */ + ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer); buffer += 4; - /* - * Get Alignment (Bytes 12-15) - */ + /* Get Alignment (Bytes 12-15) */ + ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer); buffer += 4; - /* - * Get range_length (Bytes 16-19) - */ + /* Get range_length (Bytes 16-19) */ + ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -361,15 +339,15 @@ acpi_rs_fixed_memory32_resource ( 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_mem32); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_fixed_mem32); ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + buffer += 1; ACPI_MOVE_16_TO_16 (&temp16, buffer); @@ -378,32 +356,28 @@ acpi_rs_fixed_memory32_resource ( output_struct->id = ACPI_RSTYPE_FIXED_MEM32; - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + temp8 = *buffer; buffer += 1; output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; - /* - * Get range_base_address (Bytes 4-7) - */ - ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, buffer); + /* Get range_base_address (Bytes 4-7) */ + + ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, + buffer); buffer += 4; - /* - * Get range_length (Bytes 8-11) - */ + /* Get range_length (Bytes 8-11) */ + ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -439,54 +413,46 @@ acpi_rs_memory32_range_stream ( ACPI_FUNCTION_TRACE ("rs_memory32_range_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x85; buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + temp16 = 0x11; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01); *buffer = temp8; buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); buffer += 4; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); buffer += 4; - /* - * Set the base alignment - */ + /* Set the base alignment */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment); buffer += 4; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length); buffer += 4; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -522,44 +488,38 @@ acpi_rs_fixed_memory32_stream ( ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x86; buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + temp16 = 0x09; ACPI_MOVE_16_TO_16 (buffer, &temp16); buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); *buffer = temp8; buffer += 1; - /* - * Set the Range base address - */ + /* Set the Range base address */ + ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_base_address); + &linked_list->data.fixed_memory32.range_base_address); buffer += 4; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_32 (buffer, - &linked_list->data.fixed_memory32.range_length); + &linked_list->data.fixed_memory32.range_length); buffer += 4; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index d16be44b5df..a1f1741f0d8 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -84,24 +84,20 @@ acpi_rs_end_tag_resource ( ACPI_FUNCTION_TRACE ("rs_end_tag_resource"); - /* - * The number of bytes consumed is static - */ + /* The number of bytes consumed is static */ + *bytes_consumed = 2; - /* - * Fill out the structure - */ + /* Fill out the structure */ + output_struct->id = ACPI_RSTYPE_END_TAG; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = 0; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -136,9 +132,8 @@ acpi_rs_end_tag_stream ( ACPI_FUNCTION_TRACE ("rs_end_tag_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x79; buffer += 1; @@ -151,9 +146,8 @@ acpi_rs_end_tag_stream ( *buffer = temp8; buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -192,21 +186,20 @@ acpi_rs_vendor_resource ( u16 temp16 = 0; u8 temp8 = 0; u8 index; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_vendor); ACPI_FUNCTION_TRACE ("rs_vendor_resource"); - /* - * Dereference the Descriptor to find if this is a large or small item. - */ + /* Dereference the Descriptor to find if this is a large or small item. */ + temp8 = *buffer; if (temp8 & 0x80) { - /* - * Large Item, point to the length field - */ + /* Large Item, point to the length field */ + buffer += 1; /* Dereference */ @@ -222,9 +215,8 @@ acpi_rs_vendor_resource ( buffer += 2; } else { - /* - * Small Item, dereference the size - */ + /* Small Item, dereference the size */ + temp16 = (u8)(*buffer & 0x07); /* Calculate bytes consumed */ @@ -251,14 +243,12 @@ acpi_rs_vendor_resource ( */ struct_size += ACPI_ROUND_UP_to_32_bITS (temp16); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -295,13 +285,11 @@ acpi_rs_vendor_stream ( ACPI_FUNCTION_TRACE ("rs_vendor_stream"); - /* - * Dereference the length to find if this is a large or small item. - */ + /* Dereference the length to find if this is a large or small item. */ + if(linked_list->data.vendor_specific.length > 7) { - /* - * Large Item, Set the descriptor field and length bytes - */ + /* Large Item, Set the descriptor field and length bytes */ + *buffer = 0x84; buffer += 1; @@ -311,9 +299,8 @@ acpi_rs_vendor_stream ( buffer += 2; } else { - /* - * Small Item, Set the descriptor field - */ + /* Small Item, Set the descriptor field */ + temp8 = 0x70; temp8 |= (u8) linked_list->data.vendor_specific.length; @@ -321,9 +308,8 @@ acpi_rs_vendor_stream ( buffer += 1; } - /* - * Loop through all of the Vendor Specific fields - */ + /* Loop through all of the Vendor Specific fields */ + for (index = 0; index < linked_list->data.vendor_specific.length; index++) { temp8 = linked_list->data.vendor_specific.reserved[index]; @@ -331,9 +317,8 @@ acpi_rs_vendor_stream ( buffer += 1; } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -370,40 +355,37 @@ acpi_rs_start_depend_fns_resource ( u8 *buffer = byte_stream_buffer; struct acpi_resource *output_struct = (void *) *output_buffer; u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf); + acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( + struct acpi_resource_start_dpf); ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource"); - /* - * The number of bytes consumed are contained in the descriptor (Bits:0-1) - */ + /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ + temp8 = *buffer; *bytes_consumed = (temp8 & 0x01) + 1; output_struct->id = ACPI_RSTYPE_START_DPF; - /* - * Point to Byte 1 if it is used - */ + /* Point to Byte 1 if it is used */ + if (2 == *bytes_consumed) { buffer += 1; temp8 = *buffer; - /* - * Check Compatibility priority - */ + /* Check Compatibility priority */ + output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03; if (3 == output_struct->data.start_dpf.compatibility_priority) { return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); } - /* - * Check Performance/Robustness preference - */ + /* Check Performance/Robustness preference */ + output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03; if (3 == output_struct->data.start_dpf.performance_robustness) { @@ -412,20 +394,18 @@ acpi_rs_start_depend_fns_resource ( } else { output_struct->data.start_dpf.compatibility_priority = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; output_struct->data.start_dpf.performance_robustness = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -466,24 +446,20 @@ acpi_rs_end_depend_fns_resource ( ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource"); - /* - * The number of bytes consumed is static - */ + /* The number of bytes consumed is static */ + *bytes_consumed = 1; - /* - * Fill out the structure - */ + /* Fill out the structure */ + output_struct->id = ACPI_RSTYPE_END_DPF; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + output_struct->length = (u32) struct_size; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *structure_size = struct_size; return_ACPI_STATUS (AE_OK); } @@ -533,9 +509,8 @@ acpi_rs_start_depend_fns_stream ( *buffer = 0x31; buffer += 1; - /* - * Set the Priority Byte Definition - */ + /* Set the Priority Byte Definition */ + temp8 = 0; temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness & 0x03) << 2); @@ -546,9 +521,8 @@ acpi_rs_start_depend_fns_stream ( buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } @@ -582,15 +556,13 @@ acpi_rs_end_depend_fns_stream ( ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *buffer = 0x38; buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); return_ACPI_STATUS (AE_OK); } diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index ee9ce13c053..700cf7d65d7 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -83,10 +83,10 @@ acpi_rs_get_prt_method_data ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc); + /* Execute the method, no parameters */ + + status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &obj_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -136,10 +136,10 @@ acpi_rs_get_crs_method_data ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc); + /* Execute the method, no parameters */ + + status = acpi_ut_evaluate_object (handle, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -175,6 +175,7 @@ acpi_rs_get_crs_method_data ( * and the contents of the callers buffer is undefined. * ******************************************************************************/ + #ifdef ACPI_FUTURE_USAGE acpi_status acpi_rs_get_prs_method_data ( @@ -190,10 +191,10 @@ acpi_rs_get_prs_method_data ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc); + /* Execute the method, no parameters */ + + status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -218,6 +219,7 @@ acpi_rs_get_prs_method_data ( * FUNCTION: acpi_rs_get_method_data * * PARAMETERS: Handle - a handle to the containing object + * Path - Path to method, relative to Handle * ret_buffer - a pointer to a buffer structure for the * results * @@ -246,9 +248,8 @@ acpi_rs_get_method_data ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ + /* Execute the method, no parameters */ + status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -314,18 +315,16 @@ acpi_rs_set_srs_method_data ( return_ACPI_STATUS (status); } - /* - * Init the param object - */ + /* Init the param object */ + params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); if (!params[0]) { acpi_os_free (buffer.pointer); return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Set up the parameter object - */ + /* Set up the parameter object */ + params[0]->buffer.length = (u32) buffer.length; params[0]->buffer.pointer = buffer.pointer; params[0]->common.flags = AOPOBJ_DATA_VALID; @@ -335,10 +334,9 @@ acpi_rs_set_srs_method_data ( info.parameters = params; info.parameter_type = ACPI_PARAM_ARGS; - /* - * Execute the method, no return value - */ - status = acpi_ns_evaluate_relative ("_SRS", &info); + /* Execute the method, no return value */ + + status = acpi_ns_evaluate_relative (METHOD_NAME__SRS, &info); if (ACPI_SUCCESS (status)) { /* Delete any return object (especially if implicit_return is enabled) */ @@ -347,9 +345,8 @@ acpi_rs_set_srs_method_data ( } } - /* - * Clean up and return the status from acpi_ns_evaluate_relative - */ + /* Clean up and return the status from acpi_ns_evaluate_relative */ + acpi_ut_remove_reference (params[0]); return_ACPI_STATUS (status); } diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index a9cdcbeb343..83c944b8b09 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -49,6 +49,23 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsxface") +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field) +#define ACPI_COPY_ADDRESS(out, in) \ + ACPI_COPY_FIELD(out, in, resource_type); \ + ACPI_COPY_FIELD(out, in, producer_consumer); \ + ACPI_COPY_FIELD(out, in, decode); \ + ACPI_COPY_FIELD(out, in, min_address_fixed); \ + ACPI_COPY_FIELD(out, in, max_address_fixed); \ + ACPI_COPY_FIELD(out, in, attribute); \ + ACPI_COPY_FIELD(out, in, granularity); \ + ACPI_COPY_FIELD(out, in, min_address_range); \ + ACPI_COPY_FIELD(out, in, max_address_range); \ + ACPI_COPY_FIELD(out, in, address_translation_offset); \ + ACPI_COPY_FIELD(out, in, address_length); \ + ACPI_COPY_FIELD(out, in, resource_source); + /******************************************************************************* * @@ -180,6 +197,7 @@ EXPORT_SYMBOL(acpi_get_current_resources); * and the value of ret_buffer is undefined. * ******************************************************************************/ + #ifdef ACPI_FUTURE_USAGE acpi_status acpi_get_possible_resources ( @@ -346,9 +364,8 @@ acpi_set_current_resources ( ACPI_FUNCTION_TRACE ("acpi_set_current_resources"); - /* - * Must have a valid handle and buffer - */ + /* Must have a valid handle and buffer */ + if ((!device_handle) || (!in_buffer) || (!in_buffer->pointer) || @@ -362,21 +379,6 @@ acpi_set_current_resources ( EXPORT_SYMBOL(acpi_set_current_resources); -#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field) -#define ACPI_COPY_ADDRESS(out, in) \ - ACPI_COPY_FIELD(out, in, resource_type); \ - ACPI_COPY_FIELD(out, in, producer_consumer); \ - ACPI_COPY_FIELD(out, in, decode); \ - ACPI_COPY_FIELD(out, in, min_address_fixed); \ - ACPI_COPY_FIELD(out, in, max_address_fixed); \ - ACPI_COPY_FIELD(out, in, attribute); \ - ACPI_COPY_FIELD(out, in, granularity); \ - ACPI_COPY_FIELD(out, in, min_address_range); \ - ACPI_COPY_FIELD(out, in, max_address_range); \ - ACPI_COPY_FIELD(out, in, address_translation_offset); \ - ACPI_COPY_FIELD(out, in, address_length); \ - ACPI_COPY_FIELD(out, in, resource_source); - /****************************************************************************** * * FUNCTION: acpi_resource_to_address64 @@ -408,14 +410,14 @@ acpi_resource_to_address64 ( case ACPI_RSTYPE_ADDRESS16: address16 = (struct acpi_resource_address16 *) &resource->data; - ACPI_COPY_ADDRESS(out, address16); + ACPI_COPY_ADDRESS (out, address16); break; case ACPI_RSTYPE_ADDRESS32: address32 = (struct acpi_resource_address32 *) &resource->data; - ACPI_COPY_ADDRESS(out, address32); + ACPI_COPY_ADDRESS (out, address32); break; @@ -434,4 +436,3 @@ acpi_resource_to_address64 ( return (AE_OK); } EXPORT_SYMBOL(acpi_resource_to_address64); - |