Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: rsmem24 - Memory resource descriptors |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acresrc.h> |
| 46 | |
| 47 | #define _COMPONENT ACPI_RESOURCES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 48 | ACPI_MODULE_NAME("rsmemory") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /******************************************************************************* |
| 51 | * |
| 52 | * FUNCTION: acpi_rs_memory24_resource |
| 53 | * |
| 54 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 55 | * stream |
| 56 | * bytes_consumed - Pointer to where the number of bytes |
| 57 | * consumed the byte_stream_buffer is |
| 58 | * returned |
| 59 | * output_buffer - Pointer to the return data buffer |
| 60 | * structure_size - Pointer to where the number of bytes |
| 61 | * in the return data struct is returned |
| 62 | * |
| 63 | * RETURN: Status |
| 64 | * |
| 65 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 66 | * structure pointed to by the output_buffer. Return the |
| 67 | * number of bytes consumed from the byte stream. |
| 68 | * |
| 69 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 71 | acpi_rs_memory24_resource(u8 * byte_stream_buffer, |
| 72 | acpi_size * bytes_consumed, |
| 73 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 75 | u8 *buffer = byte_stream_buffer; |
| 76 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 77 | u16 temp16 = 0; |
| 78 | u8 temp8 = 0; |
| 79 | acpi_size struct_size = |
| 80 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 82 | ACPI_FUNCTION_TRACE("rs_memory24_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 84 | /* Point past the Descriptor to get the number of bytes consumed */ |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | buffer += 1; |
| 87 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 88 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | buffer += 2; |
| 90 | *bytes_consumed = (acpi_size) temp16 + 3; |
| 91 | output_struct->id = ACPI_RSTYPE_MEM24; |
| 92 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 93 | /* Check Byte 3 the Read/Write bit */ |
| 94 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | temp8 = *buffer; |
| 96 | buffer += 1; |
| 97 | output_struct->data.memory24.read_write_attribute = temp8 & 0x01; |
| 98 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 99 | /* Get min_base_address (Bytes 4-5) */ |
| 100 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 101 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | buffer += 2; |
| 103 | output_struct->data.memory24.min_base_address = temp16; |
| 104 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 105 | /* Get max_base_address (Bytes 6-7) */ |
| 106 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 107 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | buffer += 2; |
| 109 | output_struct->data.memory24.max_base_address = temp16; |
| 110 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 111 | /* Get Alignment (Bytes 8-9) */ |
| 112 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 113 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | buffer += 2; |
| 115 | output_struct->data.memory24.alignment = temp16; |
| 116 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 117 | /* Get range_length (Bytes 10-11) */ |
| 118 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 119 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | output_struct->data.memory24.range_length = temp16; |
| 121 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 122 | /* Set the Length parameter */ |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | output_struct->length = (u32) struct_size; |
| 125 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 126 | /* Return the final size of the structure */ |
| 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 129 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /******************************************************************************* |
| 133 | * |
| 134 | * FUNCTION: acpi_rs_memory24_stream |
| 135 | * |
| 136 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 137 | * output_buffer - Pointer to the user's return buffer |
| 138 | * bytes_consumed - Pointer to where the number of bytes |
| 139 | * used in the output_buffer is returned |
| 140 | * |
| 141 | * RETURN: Status |
| 142 | * |
| 143 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 144 | * the appropriate bytes in a byte stream |
| 145 | * |
| 146 | ******************************************************************************/ |
| 147 | |
| 148 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 149 | acpi_rs_memory24_stream(struct acpi_resource *linked_list, |
| 150 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 152 | u8 *buffer = *output_buffer; |
| 153 | u16 temp16 = 0; |
| 154 | u8 temp8 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 156 | ACPI_FUNCTION_TRACE("rs_memory24_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 158 | /* The descriptor field is static */ |
| 159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | *buffer = 0x81; |
| 161 | buffer += 1; |
| 162 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 163 | /* The length field is static */ |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | temp16 = 0x09; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 166 | ACPI_MOVE_16_TO_16(buffer, &temp16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | buffer += 2; |
| 168 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 169 | /* Set the Information Byte */ |
| 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); |
| 172 | *buffer = temp8; |
| 173 | buffer += 1; |
| 174 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 175 | /* Set the Range minimum base address */ |
| 176 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 177 | ACPI_MOVE_32_TO_16(buffer, |
| 178 | &linked_list->data.memory24.min_base_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | buffer += 2; |
| 180 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 181 | /* Set the Range maximum base address */ |
| 182 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 183 | ACPI_MOVE_32_TO_16(buffer, |
| 184 | &linked_list->data.memory24.max_base_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | buffer += 2; |
| 186 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 187 | /* Set the base alignment */ |
| 188 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 189 | ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | buffer += 2; |
| 191 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 192 | /* Set the range length */ |
| 193 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 194 | ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | buffer += 2; |
| 196 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 197 | /* Return the number of bytes consumed in this operation */ |
| 198 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 199 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 200 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | /******************************************************************************* |
| 204 | * |
| 205 | * FUNCTION: acpi_rs_memory32_range_resource |
| 206 | * |
| 207 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 208 | * stream |
| 209 | * bytes_consumed - Pointer to where the number of bytes |
| 210 | * consumed the byte_stream_buffer is |
| 211 | * returned |
| 212 | * output_buffer - Pointer to the return data buffer |
| 213 | * structure_size - Pointer to where the number of bytes |
| 214 | * in the return data struct is returned |
| 215 | * |
| 216 | * RETURN: Status |
| 217 | * |
| 218 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 219 | * structure pointed to by the output_buffer. Return the |
| 220 | * number of bytes consumed from the byte stream. |
| 221 | * |
| 222 | ******************************************************************************/ |
| 223 | |
| 224 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 225 | acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, |
| 226 | acpi_size * bytes_consumed, |
| 227 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 229 | u8 *buffer = byte_stream_buffer; |
| 230 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 231 | u16 temp16 = 0; |
| 232 | u8 temp8 = 0; |
| 233 | acpi_size struct_size = |
| 234 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 236 | ACPI_FUNCTION_TRACE("rs_memory32_range_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 238 | /* Point past the Descriptor to get the number of bytes consumed */ |
| 239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | buffer += 1; |
| 241 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 242 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | buffer += 2; |
| 244 | *bytes_consumed = (acpi_size) temp16 + 3; |
| 245 | |
| 246 | output_struct->id = ACPI_RSTYPE_MEM32; |
| 247 | |
| 248 | /* |
| 249 | * Point to the place in the output buffer where the data portion will |
| 250 | * begin. |
| 251 | * 1. Set the RESOURCE_DATA * Data to point to its own address, then |
| 252 | * 2. Set the pointer to the next address. |
| 253 | * |
| 254 | * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds |
| 255 | * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) |
| 256 | */ |
| 257 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 258 | /* Check Byte 3 the Read/Write bit */ |
| 259 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | temp8 = *buffer; |
| 261 | buffer += 1; |
| 262 | |
| 263 | output_struct->data.memory32.read_write_attribute = temp8 & 0x01; |
| 264 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 265 | /* Get min_base_address (Bytes 4-7) */ |
| 266 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 267 | ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address, |
| 268 | buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | buffer += 4; |
| 270 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 271 | /* Get max_base_address (Bytes 8-11) */ |
| 272 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 273 | ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address, |
| 274 | buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | buffer += 4; |
| 276 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 277 | /* Get Alignment (Bytes 12-15) */ |
| 278 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 279 | ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | buffer += 4; |
| 281 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 282 | /* Get range_length (Bytes 16-19) */ |
| 283 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 284 | ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 286 | /* Set the Length parameter */ |
| 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | output_struct->length = (u32) struct_size; |
| 289 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 290 | /* Return the final size of the structure */ |
| 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 293 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | /******************************************************************************* |
| 297 | * |
| 298 | * FUNCTION: acpi_rs_fixed_memory32_resource |
| 299 | * |
| 300 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 301 | * stream |
| 302 | * bytes_consumed - Pointer to where the number of bytes |
| 303 | * consumed the byte_stream_buffer is |
| 304 | * returned |
| 305 | * output_buffer - Pointer to the return data buffer |
| 306 | * structure_size - Pointer to where the number of bytes |
| 307 | * in the return data struct is returned |
| 308 | * |
| 309 | * RETURN: Status |
| 310 | * |
| 311 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 312 | * structure pointed to by the output_buffer. Return the |
| 313 | * number of bytes consumed from the byte stream. |
| 314 | * |
| 315 | ******************************************************************************/ |
| 316 | |
| 317 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 318 | acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, |
| 319 | acpi_size * bytes_consumed, |
| 320 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 322 | u8 *buffer = byte_stream_buffer; |
| 323 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 324 | u16 temp16 = 0; |
| 325 | u8 temp8 = 0; |
| 326 | acpi_size struct_size = |
| 327 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 329 | ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 331 | /* Point past the Descriptor to get the number of bytes consumed */ |
| 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | buffer += 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 334 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
| 336 | buffer += 2; |
| 337 | *bytes_consumed = (acpi_size) temp16 + 3; |
| 338 | |
| 339 | output_struct->id = ACPI_RSTYPE_FIXED_MEM32; |
| 340 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 341 | /* Check Byte 3 the Read/Write bit */ |
| 342 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | temp8 = *buffer; |
| 344 | buffer += 1; |
| 345 | output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; |
| 346 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 347 | /* Get range_base_address (Bytes 4-7) */ |
| 348 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 349 | ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32. |
| 350 | range_base_address, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | buffer += 4; |
| 352 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 353 | /* Get range_length (Bytes 8-11) */ |
| 354 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 355 | ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length, |
| 356 | buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 358 | /* Set the Length parameter */ |
| 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | output_struct->length = (u32) struct_size; |
| 361 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 362 | /* Return the final size of the structure */ |
| 363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 365 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | /******************************************************************************* |
| 369 | * |
| 370 | * FUNCTION: acpi_rs_memory32_range_stream |
| 371 | * |
| 372 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 373 | * output_buffer - Pointer to the user's return buffer |
| 374 | * bytes_consumed - Pointer to where the number of bytes |
| 375 | * used in the output_buffer is returned |
| 376 | * |
| 377 | * RETURN: Status |
| 378 | * |
| 379 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 380 | * the appropriate bytes in a byte stream |
| 381 | * |
| 382 | ******************************************************************************/ |
| 383 | |
| 384 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 385 | acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, |
| 386 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 388 | u8 *buffer = *output_buffer; |
| 389 | u16 temp16 = 0; |
| 390 | u8 temp8 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 392 | ACPI_FUNCTION_TRACE("rs_memory32_range_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 394 | /* The descriptor field is static */ |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | *buffer = 0x85; |
| 397 | buffer += 1; |
| 398 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 399 | /* The length field is static */ |
| 400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | temp16 = 0x11; |
| 402 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 403 | ACPI_MOVE_16_TO_16(buffer, &temp16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | buffer += 2; |
| 405 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 406 | /* Set the Information Byte */ |
| 407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01); |
| 409 | *buffer = temp8; |
| 410 | buffer += 1; |
| 411 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 412 | /* Set the Range minimum base address */ |
| 413 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 414 | ACPI_MOVE_32_TO_32(buffer, |
| 415 | &linked_list->data.memory32.min_base_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | buffer += 4; |
| 417 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 418 | /* Set the Range maximum base address */ |
| 419 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 420 | ACPI_MOVE_32_TO_32(buffer, |
| 421 | &linked_list->data.memory32.max_base_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | buffer += 4; |
| 423 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 424 | /* Set the base alignment */ |
| 425 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 426 | ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | buffer += 4; |
| 428 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 429 | /* Set the range length */ |
| 430 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 431 | ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | buffer += 4; |
| 433 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 434 | /* Return the number of bytes consumed in this operation */ |
| 435 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 436 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 437 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | /******************************************************************************* |
| 441 | * |
| 442 | * FUNCTION: acpi_rs_fixed_memory32_stream |
| 443 | * |
| 444 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 445 | * output_buffer - Pointer to the user's return buffer |
| 446 | * bytes_consumed - Pointer to where the number of bytes |
| 447 | * used in the output_buffer is returned |
| 448 | * |
| 449 | * RETURN: Status |
| 450 | * |
| 451 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 452 | * the appropriate bytes in a byte stream |
| 453 | * |
| 454 | ******************************************************************************/ |
| 455 | |
| 456 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 457 | acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, |
| 458 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 460 | u8 *buffer = *output_buffer; |
| 461 | u16 temp16 = 0; |
| 462 | u8 temp8 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 464 | ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 466 | /* The descriptor field is static */ |
| 467 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | *buffer = 0x86; |
| 469 | buffer += 1; |
| 470 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 471 | /* The length field is static */ |
| 472 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | temp16 = 0x09; |
| 474 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 475 | ACPI_MOVE_16_TO_16(buffer, &temp16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | buffer += 2; |
| 477 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 478 | /* Set the Information Byte */ |
| 479 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 480 | temp8 = |
| 481 | (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | *buffer = temp8; |
| 483 | buffer += 1; |
| 484 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 485 | /* Set the Range base address */ |
| 486 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 487 | ACPI_MOVE_32_TO_32(buffer, |
| 488 | &linked_list->data.fixed_memory32. |
| 489 | range_base_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | buffer += 4; |
| 491 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 492 | /* Set the range length */ |
| 493 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 494 | ACPI_MOVE_32_TO_32(buffer, |
| 495 | &linked_list->data.fixed_memory32.range_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | buffer += 4; |
| 497 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 498 | /* Return the number of bytes consumed in this operation */ |
| 499 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 500 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 501 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | } |