Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v2.6.13 526 lines 16 kB view raw
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 44 45#include <acpi/acpi.h> 46#include <acpi/acresrc.h> 47 48#define _COMPONENT ACPI_RESOURCES 49 ACPI_MODULE_NAME ("rsmemory") 50 51 52/******************************************************************************* 53 * 54 * FUNCTION: acpi_rs_memory24_resource 55 * 56 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 57 * stream 58 * bytes_consumed - Pointer to where the number of bytes 59 * consumed the byte_stream_buffer is 60 * returned 61 * output_buffer - Pointer to the return data buffer 62 * structure_size - Pointer to where the number of bytes 63 * in the return data struct is returned 64 * 65 * RETURN: Status 66 * 67 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 68 * structure pointed to by the output_buffer. Return the 69 * number of bytes consumed from the byte stream. 70 * 71 ******************************************************************************/ 72 73acpi_status 74acpi_rs_memory24_resource ( 75 u8 *byte_stream_buffer, 76 acpi_size *bytes_consumed, 77 u8 **output_buffer, 78 acpi_size *structure_size) 79{ 80 u8 *buffer = byte_stream_buffer; 81 struct acpi_resource *output_struct = (void *) *output_buffer; 82 u16 temp16 = 0; 83 u8 temp8 = 0; 84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 85 struct acpi_resource_mem24); 86 87 88 ACPI_FUNCTION_TRACE ("rs_memory24_resource"); 89 90 91 /* Point past the Descriptor to get the number of bytes consumed */ 92 93 buffer += 1; 94 95 ACPI_MOVE_16_TO_16 (&temp16, buffer); 96 buffer += 2; 97 *bytes_consumed = (acpi_size) temp16 + 3; 98 output_struct->id = ACPI_RSTYPE_MEM24; 99 100 /* Check Byte 3 the Read/Write bit */ 101 102 temp8 = *buffer; 103 buffer += 1; 104 output_struct->data.memory24.read_write_attribute = temp8 & 0x01; 105 106 /* Get min_base_address (Bytes 4-5) */ 107 108 ACPI_MOVE_16_TO_16 (&temp16, buffer); 109 buffer += 2; 110 output_struct->data.memory24.min_base_address = temp16; 111 112 /* Get max_base_address (Bytes 6-7) */ 113 114 ACPI_MOVE_16_TO_16 (&temp16, buffer); 115 buffer += 2; 116 output_struct->data.memory24.max_base_address = temp16; 117 118 /* Get Alignment (Bytes 8-9) */ 119 120 ACPI_MOVE_16_TO_16 (&temp16, buffer); 121 buffer += 2; 122 output_struct->data.memory24.alignment = temp16; 123 124 /* Get range_length (Bytes 10-11) */ 125 126 ACPI_MOVE_16_TO_16 (&temp16, buffer); 127 output_struct->data.memory24.range_length = temp16; 128 129 /* Set the Length parameter */ 130 131 output_struct->length = (u32) struct_size; 132 133 /* Return the final size of the structure */ 134 135 *structure_size = struct_size; 136 return_ACPI_STATUS (AE_OK); 137} 138 139 140/******************************************************************************* 141 * 142 * FUNCTION: acpi_rs_memory24_stream 143 * 144 * PARAMETERS: linked_list - Pointer to the resource linked list 145 * output_buffer - Pointer to the user's return buffer 146 * bytes_consumed - Pointer to where the number of bytes 147 * used in the output_buffer is returned 148 * 149 * RETURN: Status 150 * 151 * DESCRIPTION: Take the linked list resource structure and fills in the 152 * the appropriate bytes in a byte stream 153 * 154 ******************************************************************************/ 155 156acpi_status 157acpi_rs_memory24_stream ( 158 struct acpi_resource *linked_list, 159 u8 **output_buffer, 160 acpi_size *bytes_consumed) 161{ 162 u8 *buffer = *output_buffer; 163 u16 temp16 = 0; 164 u8 temp8 = 0; 165 166 167 ACPI_FUNCTION_TRACE ("rs_memory24_stream"); 168 169 170 /* The descriptor field is static */ 171 172 *buffer = 0x81; 173 buffer += 1; 174 175 /* The length field is static */ 176 177 temp16 = 0x09; 178 ACPI_MOVE_16_TO_16 (buffer, &temp16); 179 buffer += 2; 180 181 /* Set the Information Byte */ 182 183 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); 184 *buffer = temp8; 185 buffer += 1; 186 187 /* Set the Range minimum base address */ 188 189 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address); 190 buffer += 2; 191 192 /* Set the Range maximum base address */ 193 194 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address); 195 buffer += 2; 196 197 /* Set the base alignment */ 198 199 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment); 200 buffer += 2; 201 202 /* Set the range length */ 203 204 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length); 205 buffer += 2; 206 207 /* Return the number of bytes consumed in this operation */ 208 209 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 210 return_ACPI_STATUS (AE_OK); 211} 212 213 214/******************************************************************************* 215 * 216 * FUNCTION: acpi_rs_memory32_range_resource 217 * 218 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 219 * stream 220 * bytes_consumed - Pointer to where the number of bytes 221 * consumed the byte_stream_buffer is 222 * returned 223 * output_buffer - Pointer to the return data buffer 224 * structure_size - Pointer to where the number of bytes 225 * in the return data struct is returned 226 * 227 * RETURN: Status 228 * 229 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 230 * structure pointed to by the output_buffer. Return the 231 * number of bytes consumed from the byte stream. 232 * 233 ******************************************************************************/ 234 235acpi_status 236acpi_rs_memory32_range_resource ( 237 u8 *byte_stream_buffer, 238 acpi_size *bytes_consumed, 239 u8 **output_buffer, 240 acpi_size *structure_size) 241{ 242 u8 *buffer = byte_stream_buffer; 243 struct acpi_resource *output_struct = (void *) *output_buffer; 244 u16 temp16 = 0; 245 u8 temp8 = 0; 246 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 247 struct acpi_resource_mem32); 248 249 250 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource"); 251 252 253 /* Point past the Descriptor to get the number of bytes consumed */ 254 255 buffer += 1; 256 257 ACPI_MOVE_16_TO_16 (&temp16, buffer); 258 buffer += 2; 259 *bytes_consumed = (acpi_size) temp16 + 3; 260 261 output_struct->id = ACPI_RSTYPE_MEM32; 262 263 /* 264 * Point to the place in the output buffer where the data portion will 265 * begin. 266 * 1. Set the RESOURCE_DATA * Data to point to its own address, then 267 * 2. Set the pointer to the next address. 268 * 269 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds 270 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) 271 */ 272 273 /* Check Byte 3 the Read/Write bit */ 274 275 temp8 = *buffer; 276 buffer += 1; 277 278 output_struct->data.memory32.read_write_attribute = temp8 & 0x01; 279 280 /* Get min_base_address (Bytes 4-7) */ 281 282 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer); 283 buffer += 4; 284 285 /* Get max_base_address (Bytes 8-11) */ 286 287 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer); 288 buffer += 4; 289 290 /* Get Alignment (Bytes 12-15) */ 291 292 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer); 293 buffer += 4; 294 295 /* Get range_length (Bytes 16-19) */ 296 297 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer); 298 299 /* Set the Length parameter */ 300 301 output_struct->length = (u32) struct_size; 302 303 /* Return the final size of the structure */ 304 305 *structure_size = struct_size; 306 return_ACPI_STATUS (AE_OK); 307} 308 309 310/******************************************************************************* 311 * 312 * FUNCTION: acpi_rs_fixed_memory32_resource 313 * 314 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 315 * stream 316 * bytes_consumed - Pointer to where the number of bytes 317 * consumed the byte_stream_buffer is 318 * returned 319 * output_buffer - Pointer to the return data buffer 320 * structure_size - Pointer to where the number of bytes 321 * in the return data struct is returned 322 * 323 * RETURN: Status 324 * 325 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 326 * structure pointed to by the output_buffer. Return the 327 * number of bytes consumed from the byte stream. 328 * 329 ******************************************************************************/ 330 331acpi_status 332acpi_rs_fixed_memory32_resource ( 333 u8 *byte_stream_buffer, 334 acpi_size *bytes_consumed, 335 u8 **output_buffer, 336 acpi_size *structure_size) 337{ 338 u8 *buffer = byte_stream_buffer; 339 struct acpi_resource *output_struct = (void *) *output_buffer; 340 u16 temp16 = 0; 341 u8 temp8 = 0; 342 acpi_size struct_size = ACPI_SIZEOF_RESOURCE ( 343 struct acpi_resource_fixed_mem32); 344 345 346 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource"); 347 348 349 /* Point past the Descriptor to get the number of bytes consumed */ 350 351 buffer += 1; 352 ACPI_MOVE_16_TO_16 (&temp16, buffer); 353 354 buffer += 2; 355 *bytes_consumed = (acpi_size) temp16 + 3; 356 357 output_struct->id = ACPI_RSTYPE_FIXED_MEM32; 358 359 /* Check Byte 3 the Read/Write bit */ 360 361 temp8 = *buffer; 362 buffer += 1; 363 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; 364 365 /* Get range_base_address (Bytes 4-7) */ 366 367 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, 368 buffer); 369 buffer += 4; 370 371 /* Get range_length (Bytes 8-11) */ 372 373 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer); 374 375 /* Set the Length parameter */ 376 377 output_struct->length = (u32) struct_size; 378 379 /* Return the final size of the structure */ 380 381 *structure_size = struct_size; 382 return_ACPI_STATUS (AE_OK); 383} 384 385 386/******************************************************************************* 387 * 388 * FUNCTION: acpi_rs_memory32_range_stream 389 * 390 * PARAMETERS: linked_list - Pointer to the resource linked list 391 * output_buffer - Pointer to the user's return buffer 392 * bytes_consumed - Pointer to where the number of bytes 393 * used in the output_buffer is returned 394 * 395 * RETURN: Status 396 * 397 * DESCRIPTION: Take the linked list resource structure and fills in the 398 * the appropriate bytes in a byte stream 399 * 400 ******************************************************************************/ 401 402acpi_status 403acpi_rs_memory32_range_stream ( 404 struct acpi_resource *linked_list, 405 u8 **output_buffer, 406 acpi_size *bytes_consumed) 407{ 408 u8 *buffer = *output_buffer; 409 u16 temp16 = 0; 410 u8 temp8 = 0; 411 412 413 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream"); 414 415 416 /* The descriptor field is static */ 417 418 *buffer = 0x85; 419 buffer += 1; 420 421 /* The length field is static */ 422 423 temp16 = 0x11; 424 425 ACPI_MOVE_16_TO_16 (buffer, &temp16); 426 buffer += 2; 427 428 /* Set the Information Byte */ 429 430 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01); 431 *buffer = temp8; 432 buffer += 1; 433 434 /* Set the Range minimum base address */ 435 436 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); 437 buffer += 4; 438 439 /* Set the Range maximum base address */ 440 441 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); 442 buffer += 4; 443 444 /* Set the base alignment */ 445 446 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment); 447 buffer += 4; 448 449 /* Set the range length */ 450 451 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length); 452 buffer += 4; 453 454 /* Return the number of bytes consumed in this operation */ 455 456 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 457 return_ACPI_STATUS (AE_OK); 458} 459 460 461/******************************************************************************* 462 * 463 * FUNCTION: acpi_rs_fixed_memory32_stream 464 * 465 * PARAMETERS: linked_list - Pointer to the resource linked list 466 * output_buffer - Pointer to the user's return buffer 467 * bytes_consumed - Pointer to where the number of bytes 468 * used in the output_buffer is returned 469 * 470 * RETURN: Status 471 * 472 * DESCRIPTION: Take the linked list resource structure and fills in the 473 * the appropriate bytes in a byte stream 474 * 475 ******************************************************************************/ 476 477acpi_status 478acpi_rs_fixed_memory32_stream ( 479 struct acpi_resource *linked_list, 480 u8 **output_buffer, 481 acpi_size *bytes_consumed) 482{ 483 u8 *buffer = *output_buffer; 484 u16 temp16 = 0; 485 u8 temp8 = 0; 486 487 488 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream"); 489 490 491 /* The descriptor field is static */ 492 493 *buffer = 0x86; 494 buffer += 1; 495 496 /* The length field is static */ 497 498 temp16 = 0x09; 499 500 ACPI_MOVE_16_TO_16 (buffer, &temp16); 501 buffer += 2; 502 503 /* Set the Information Byte */ 504 505 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); 506 *buffer = temp8; 507 buffer += 1; 508 509 /* Set the Range base address */ 510 511 ACPI_MOVE_32_TO_32 (buffer, 512 &linked_list->data.fixed_memory32.range_base_address); 513 buffer += 4; 514 515 /* Set the range length */ 516 517 ACPI_MOVE_32_TO_32 (buffer, 518 &linked_list->data.fixed_memory32.range_length); 519 buffer += 4; 520 521 /* Return the number of bytes consumed in this operation */ 522 523 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 524 return_ACPI_STATUS (AE_OK); 525} 526