diff options
Diffstat (limited to 'drivers/acpi/resources/rscreate.c')
| -rw-r--r-- | drivers/acpi/resources/rscreate.c | 231 |
1 files changed, 114 insertions, 117 deletions
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 0911526b7ad8..8c128dea3252 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ******************************************************************************/ | 5 | ******************************************************************************/ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * | 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
| @@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate") | |||
| 53 | * | 53 | * |
| 54 | * FUNCTION: acpi_rs_create_resource_list | 54 | * FUNCTION: acpi_rs_create_resource_list |
| 55 | * | 55 | * |
| 56 | * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream | 56 | * PARAMETERS: aml_buffer - Pointer to the resource byte stream |
| 57 | * output_buffer - Pointer to the user's buffer | 57 | * output_buffer - Pointer to the user's buffer |
| 58 | * | 58 | * |
| 59 | * RETURN: Status - AE_OK if okay, else a valid acpi_status code | 59 | * RETURN: Status: AE_OK if okay, else a valid acpi_status code |
| 60 | * If output_buffer is not large enough, output_buffer_length | 60 | * If output_buffer is not large enough, output_buffer_length |
| 61 | * indicates how large output_buffer should be, else it | 61 | * indicates how large output_buffer should be, else it |
| 62 | * indicates how may u8 elements of output_buffer are valid. | 62 | * indicates how may u8 elements of output_buffer are valid. |
| @@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate") | |||
| 67 | * | 67 | * |
| 68 | ******************************************************************************/ | 68 | ******************************************************************************/ |
| 69 | acpi_status | 69 | acpi_status |
| 70 | acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, | 70 | acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, |
| 71 | struct acpi_buffer *output_buffer) | 71 | struct acpi_buffer *output_buffer) |
| 72 | { | 72 | { |
| 73 | 73 | ||
| 74 | acpi_status status; | 74 | acpi_status status; |
| 75 | u8 *byte_stream_start; | 75 | u8 *aml_start; |
| 76 | acpi_size list_size_needed = 0; | 76 | acpi_size list_size_needed = 0; |
| 77 | u32 byte_stream_buffer_length; | 77 | u32 aml_buffer_length; |
| 78 | 78 | ||
| 79 | ACPI_FUNCTION_TRACE("rs_create_resource_list"); | 79 | ACPI_FUNCTION_TRACE("rs_create_resource_list"); |
| 80 | 80 | ||
| 81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", | 81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer)); |
| 82 | byte_stream_buffer)); | ||
| 83 | 82 | ||
| 84 | /* Params already validated, so we don't re-validate here */ | 83 | /* Params already validated, so we don't re-validate here */ |
| 85 | 84 | ||
| 86 | byte_stream_buffer_length = byte_stream_buffer->buffer.length; | 85 | aml_buffer_length = aml_buffer->buffer.length; |
| 87 | byte_stream_start = byte_stream_buffer->buffer.pointer; | 86 | aml_start = aml_buffer->buffer.pointer; |
| 88 | 87 | ||
| 89 | /* | 88 | /* |
| 90 | * Pass the byte_stream_buffer into a module that can calculate | 89 | * Pass the aml_buffer into a module that can calculate |
| 91 | * the buffer size needed for the linked list | 90 | * the buffer size needed for the linked list |
| 92 | */ | 91 | */ |
| 93 | status = | 92 | status = acpi_rs_get_list_length(aml_start, aml_buffer_length, |
| 94 | acpi_rs_get_list_length(byte_stream_start, | 93 | &list_size_needed); |
| 95 | byte_stream_buffer_length, | ||
| 96 | &list_size_needed); | ||
| 97 | 94 | ||
| 98 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", | 95 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", |
| 99 | status, (u32) list_size_needed)); | 96 | status, (u32) list_size_needed)); |
| @@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, | |||
| 110 | 107 | ||
| 111 | /* Do the conversion */ | 108 | /* Do the conversion */ |
| 112 | 109 | ||
| 113 | status = | 110 | status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, |
| 114 | acpi_rs_byte_stream_to_list(byte_stream_start, | 111 | output_buffer->pointer); |
| 115 | byte_stream_buffer_length, | ||
| 116 | output_buffer->pointer); | ||
| 117 | if (ACPI_FAILURE(status)) { | 112 | if (ACPI_FAILURE(status)) { |
| 118 | return_ACPI_STATUS(status); | 113 | return_ACPI_STATUS(status); |
| 119 | } | 114 | } |
| @@ -212,21 +207,20 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 212 | /* Each element of the top-level package must also be a package */ | 207 | /* Each element of the top-level package must also be a package */ |
| 213 | 208 | ||
| 214 | if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { | 209 | if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { |
| 215 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 210 | ACPI_ERROR((AE_INFO, |
| 216 | "(PRT[%X]) Need sub-package, found %s\n", | 211 | "(PRT[%X]) Need sub-package, found %s", |
| 217 | index, | 212 | index, |
| 218 | acpi_ut_get_object_type_name | 213 | acpi_ut_get_object_type_name |
| 219 | (*top_object_list))); | 214 | (*top_object_list))); |
| 220 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 215 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
| 221 | } | 216 | } |
| 222 | 217 | ||
| 223 | /* Each sub-package must be of length 4 */ | 218 | /* Each sub-package must be of length 4 */ |
| 224 | 219 | ||
| 225 | if ((*top_object_list)->package.count != 4) { | 220 | if ((*top_object_list)->package.count != 4) { |
| 226 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 221 | ACPI_ERROR((AE_INFO, |
| 227 | "(PRT[%X]) Need package of length 4, found length %d\n", | 222 | "(PRT[%X]) Need package of length 4, found length %d", |
| 228 | index, | 223 | index, (*top_object_list)->package.count)); |
| 229 | (*top_object_list)->package.count)); | ||
| 230 | return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); | 224 | return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); |
| 231 | } | 225 | } |
| 232 | 226 | ||
| @@ -243,11 +237,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 243 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 237 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
| 244 | user_prt->address = obj_desc->integer.value; | 238 | user_prt->address = obj_desc->integer.value; |
| 245 | } else { | 239 | } else { |
| 246 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 240 | ACPI_ERROR((AE_INFO, |
| 247 | "(PRT[%X].Address) Need Integer, found %s\n", | 241 | "(PRT[%X].Address) Need Integer, found %s", |
| 248 | index, | 242 | index, |
| 249 | acpi_ut_get_object_type_name | 243 | acpi_ut_get_object_type_name(obj_desc))); |
| 250 | (obj_desc))); | ||
| 251 | return_ACPI_STATUS(AE_BAD_DATA); | 244 | return_ACPI_STATUS(AE_BAD_DATA); |
| 252 | } | 245 | } |
| 253 | 246 | ||
| @@ -257,76 +250,83 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 257 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 250 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
| 258 | user_prt->pin = (u32) obj_desc->integer.value; | 251 | user_prt->pin = (u32) obj_desc->integer.value; |
| 259 | } else { | 252 | } else { |
| 260 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 253 | ACPI_ERROR((AE_INFO, |
| 261 | "(PRT[%X].Pin) Need Integer, found %s\n", | 254 | "(PRT[%X].Pin) Need Integer, found %s", |
| 262 | index, | 255 | index, |
| 263 | acpi_ut_get_object_type_name | 256 | acpi_ut_get_object_type_name(obj_desc))); |
| 264 | (obj_desc))); | ||
| 265 | return_ACPI_STATUS(AE_BAD_DATA); | 257 | return_ACPI_STATUS(AE_BAD_DATA); |
| 266 | } | 258 | } |
| 267 | 259 | ||
| 268 | /* 3) Third subobject: Dereference the PRT.source_name */ | 260 | /* |
| 269 | 261 | * 3) Third subobject: Dereference the PRT.source_name | |
| 262 | * The name may be unresolved (slack mode), so allow a null object | ||
| 263 | */ | ||
| 270 | obj_desc = sub_object_list[2]; | 264 | obj_desc = sub_object_list[2]; |
| 271 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 265 | if (obj_desc) { |
| 272 | case ACPI_TYPE_LOCAL_REFERENCE: | 266 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
| 273 | 267 | case ACPI_TYPE_LOCAL_REFERENCE: | |
| 274 | if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { | 268 | |
| 275 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 269 | if (obj_desc->reference.opcode != |
| 276 | "(PRT[%X].Source) Need name, found reference op %X\n", | 270 | AML_INT_NAMEPATH_OP) { |
| 277 | index, | 271 | ACPI_ERROR((AE_INFO, |
| 278 | obj_desc->reference.opcode)); | 272 | "(PRT[%X].Source) Need name, found reference op %X", |
| 273 | index, | ||
| 274 | obj_desc->reference. | ||
| 275 | opcode)); | ||
| 276 | return_ACPI_STATUS(AE_BAD_DATA); | ||
| 277 | } | ||
| 278 | |||
| 279 | node = obj_desc->reference.node; | ||
| 280 | |||
| 281 | /* Use *remaining* length of the buffer as max for pathname */ | ||
| 282 | |||
| 283 | path_buffer.length = output_buffer->length - | ||
| 284 | (u32) ((u8 *) user_prt->source - | ||
| 285 | (u8 *) output_buffer->pointer); | ||
| 286 | path_buffer.pointer = user_prt->source; | ||
| 287 | |||
| 288 | status = | ||
| 289 | acpi_ns_handle_to_pathname((acpi_handle) | ||
| 290 | node, | ||
| 291 | &path_buffer); | ||
| 292 | |||
| 293 | /* +1 to include null terminator */ | ||
| 294 | |||
| 295 | user_prt->length += | ||
| 296 | (u32) ACPI_STRLEN(user_prt->source) + 1; | ||
| 297 | break; | ||
| 298 | |||
| 299 | case ACPI_TYPE_STRING: | ||
| 300 | |||
| 301 | ACPI_STRCPY(user_prt->source, | ||
| 302 | obj_desc->string.pointer); | ||
| 303 | |||
| 304 | /* | ||
| 305 | * Add to the Length field the length of the string | ||
| 306 | * (add 1 for terminator) | ||
| 307 | */ | ||
| 308 | user_prt->length += obj_desc->string.length + 1; | ||
| 309 | break; | ||
| 310 | |||
| 311 | case ACPI_TYPE_INTEGER: | ||
| 312 | /* | ||
| 313 | * If this is a number, then the Source Name is NULL, since the | ||
| 314 | * entire buffer was zeroed out, we can leave this alone. | ||
| 315 | * | ||
| 316 | * Add to the Length field the length of the u32 NULL | ||
| 317 | */ | ||
| 318 | user_prt->length += sizeof(u32); | ||
| 319 | break; | ||
| 320 | |||
| 321 | default: | ||
| 322 | |||
| 323 | ACPI_ERROR((AE_INFO, | ||
| 324 | "(PRT[%X].Source) Need Ref/String/Integer, found %s", | ||
| 325 | index, | ||
| 326 | acpi_ut_get_object_type_name | ||
| 327 | (obj_desc))); | ||
| 279 | return_ACPI_STATUS(AE_BAD_DATA); | 328 | return_ACPI_STATUS(AE_BAD_DATA); |
| 280 | } | 329 | } |
| 281 | |||
| 282 | node = obj_desc->reference.node; | ||
| 283 | |||
| 284 | /* Use *remaining* length of the buffer as max for pathname */ | ||
| 285 | |||
| 286 | path_buffer.length = output_buffer->length - | ||
| 287 | (u32) ((u8 *) user_prt->source - | ||
| 288 | (u8 *) output_buffer->pointer); | ||
| 289 | path_buffer.pointer = user_prt->source; | ||
| 290 | |||
| 291 | status = | ||
| 292 | acpi_ns_handle_to_pathname((acpi_handle) node, | ||
| 293 | &path_buffer); | ||
| 294 | |||
| 295 | /* +1 to include null terminator */ | ||
| 296 | |||
| 297 | user_prt->length += | ||
| 298 | (u32) ACPI_STRLEN(user_prt->source) + 1; | ||
| 299 | break; | ||
| 300 | |||
| 301 | case ACPI_TYPE_STRING: | ||
| 302 | |||
| 303 | ACPI_STRCPY(user_prt->source, obj_desc->string.pointer); | ||
| 304 | |||
| 305 | /* | ||
| 306 | * Add to the Length field the length of the string | ||
| 307 | * (add 1 for terminator) | ||
| 308 | */ | ||
| 309 | user_prt->length += obj_desc->string.length + 1; | ||
| 310 | break; | ||
| 311 | |||
| 312 | case ACPI_TYPE_INTEGER: | ||
| 313 | /* | ||
| 314 | * If this is a number, then the Source Name is NULL, since the | ||
| 315 | * entire buffer was zeroed out, we can leave this alone. | ||
| 316 | * | ||
| 317 | * Add to the Length field the length of the u32 NULL | ||
| 318 | */ | ||
| 319 | user_prt->length += sizeof(u32); | ||
| 320 | break; | ||
| 321 | |||
| 322 | default: | ||
| 323 | |||
| 324 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
| 325 | "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", | ||
| 326 | index, | ||
| 327 | acpi_ut_get_object_type_name | ||
| 328 | (obj_desc))); | ||
| 329 | return_ACPI_STATUS(AE_BAD_DATA); | ||
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | /* Now align the current length */ | 332 | /* Now align the current length */ |
| @@ -340,11 +340,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 340 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 340 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
| 341 | user_prt->source_index = (u32) obj_desc->integer.value; | 341 | user_prt->source_index = (u32) obj_desc->integer.value; |
| 342 | } else { | 342 | } else { |
| 343 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 343 | ACPI_ERROR((AE_INFO, |
| 344 | "(PRT[%X].source_index) Need Integer, found %s\n", | 344 | "(PRT[%X].source_index) Need Integer, found %s", |
| 345 | index, | 345 | index, |
| 346 | acpi_ut_get_object_type_name | 346 | acpi_ut_get_object_type_name(obj_desc))); |
| 347 | (obj_desc))); | ||
| 348 | return_ACPI_STATUS(AE_BAD_DATA); | 347 | return_ACPI_STATUS(AE_BAD_DATA); |
| 349 | } | 348 | } |
| 350 | 349 | ||
| @@ -360,7 +359,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 360 | 359 | ||
| 361 | /******************************************************************************* | 360 | /******************************************************************************* |
| 362 | * | 361 | * |
| 363 | * FUNCTION: acpi_rs_create_byte_stream | 362 | * FUNCTION: acpi_rs_create_aml_resources |
| 364 | * | 363 | * |
| 365 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list | 364 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list |
| 366 | * output_buffer - Pointer to the user's buffer | 365 | * output_buffer - Pointer to the user's buffer |
| @@ -377,13 +376,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
| 377 | ******************************************************************************/ | 376 | ******************************************************************************/ |
| 378 | 377 | ||
| 379 | acpi_status | 378 | acpi_status |
| 380 | acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | 379 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, |
| 381 | struct acpi_buffer *output_buffer) | 380 | struct acpi_buffer *output_buffer) |
| 382 | { | 381 | { |
| 383 | acpi_status status; | 382 | acpi_status status; |
| 384 | acpi_size byte_stream_size_needed = 0; | 383 | acpi_size aml_size_needed = 0; |
| 385 | 384 | ||
| 386 | ACPI_FUNCTION_TRACE("rs_create_byte_stream"); | 385 | ACPI_FUNCTION_TRACE("rs_create_aml_resources"); |
| 387 | 386 | ||
| 388 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", | 387 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", |
| 389 | linked_list_buffer)); | 388 | linked_list_buffer)); |
| @@ -394,11 +393,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
| 394 | * Pass the linked_list_buffer into a module that calculates | 393 | * Pass the linked_list_buffer into a module that calculates |
| 395 | * the buffer size needed for the byte stream. | 394 | * the buffer size needed for the byte stream. |
| 396 | */ | 395 | */ |
| 397 | status = acpi_rs_get_byte_stream_length(linked_list_buffer, | 396 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); |
| 398 | &byte_stream_size_needed); | ||
| 399 | 397 | ||
| 400 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", | 398 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n", |
| 401 | (u32) byte_stream_size_needed, | 399 | (u32) aml_size_needed, |
| 402 | acpi_format_exception(status))); | 400 | acpi_format_exception(status))); |
| 403 | if (ACPI_FAILURE(status)) { | 401 | if (ACPI_FAILURE(status)) { |
| 404 | return_ACPI_STATUS(status); | 402 | return_ACPI_STATUS(status); |
| @@ -406,8 +404,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
| 406 | 404 | ||
| 407 | /* Validate/Allocate/Clear caller buffer */ | 405 | /* Validate/Allocate/Clear caller buffer */ |
| 408 | 406 | ||
| 409 | status = | 407 | status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed); |
| 410 | acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed); | ||
| 411 | if (ACPI_FAILURE(status)) { | 408 | if (ACPI_FAILURE(status)) { |
| 412 | return_ACPI_STATUS(status); | 409 | return_ACPI_STATUS(status); |
| 413 | } | 410 | } |
| @@ -415,9 +412,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
| 415 | /* Do the conversion */ | 412 | /* Do the conversion */ |
| 416 | 413 | ||
| 417 | status = | 414 | status = |
| 418 | acpi_rs_list_to_byte_stream(linked_list_buffer, | 415 | acpi_rs_convert_resources_to_aml(linked_list_buffer, |
| 419 | byte_stream_size_needed, | 416 | aml_size_needed, |
| 420 | output_buffer->pointer); | 417 | output_buffer->pointer); |
| 421 | if (ACPI_FAILURE(status)) { | 418 | if (ACPI_FAILURE(status)) { |
| 422 | return_ACPI_STATUS(status); | 419 | return_ACPI_STATUS(status); |
| 423 | } | 420 | } |
