aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utresrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities/utresrc.c')
-rw-r--r--drivers/acpi/utilities/utresrc.c256
1 files changed, 159 insertions, 97 deletions
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
index 16461317113f..5a2de92831d3 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/utilities/utresrc.c
@@ -45,113 +45,113 @@
45#include <acpi/amlresrc.h> 45#include <acpi/amlresrc.h>
46 46
47#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmisc") 48ACPI_MODULE_NAME("utresrc")
49 49
50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) 50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
51/* 51/*
52 * Strings used to decode resource descriptors. 52 * Strings used to decode resource descriptors.
53 * Used by both the disasssembler and the debugger resource dump routines 53 * Used by both the disasssembler and the debugger resource dump routines
54 */ 54 */
55const char *acpi_gbl_BMdecode[2] = { 55const char *acpi_gbl_bm_decode[] = {
56 "not_bus_master", 56 "NotBusMaster",
57 "bus_master" 57 "BusMaster"
58}; 58};
59 59
60const char *acpi_gbl_config_decode[4] = { 60const char *acpi_gbl_config_decode[] = {
61 "0 - Good Configuration", 61 "0 - Good Configuration",
62 "1 - Acceptable Configuration", 62 "1 - Acceptable Configuration",
63 "2 - Suboptimal Configuration", 63 "2 - Suboptimal Configuration",
64 "3 - ***Invalid Configuration***", 64 "3 - ***Invalid Configuration***",
65}; 65};
66 66
67const char *acpi_gbl_consume_decode[2] = { 67const char *acpi_gbl_consume_decode[] = {
68 "resource_producer", 68 "ResourceProducer",
69 "resource_consumer" 69 "ResourceConsumer"
70}; 70};
71 71
72const char *acpi_gbl_DECdecode[2] = { 72const char *acpi_gbl_dec_decode[] = {
73 "pos_decode", 73 "PosDecode",
74 "sub_decode" 74 "SubDecode"
75}; 75};
76 76
77const char *acpi_gbl_HEdecode[2] = { 77const char *acpi_gbl_he_decode[] = {
78 "Level", 78 "Level",
79 "Edge" 79 "Edge"
80}; 80};
81 81
82const char *acpi_gbl_io_decode[2] = { 82const char *acpi_gbl_io_decode[] = {
83 "Decode10", 83 "Decode10",
84 "Decode16" 84 "Decode16"
85}; 85};
86 86
87const char *acpi_gbl_LLdecode[2] = { 87const char *acpi_gbl_ll_decode[] = {
88 "active_high", 88 "ActiveHigh",
89 "active_low" 89 "ActiveLow"
90}; 90};
91 91
92const char *acpi_gbl_max_decode[2] = { 92const char *acpi_gbl_max_decode[] = {
93 "max_not_fixed", 93 "MaxNotFixed",
94 "max_fixed" 94 "MaxFixed"
95}; 95};
96 96
97const char *acpi_gbl_MEMdecode[4] = { 97const char *acpi_gbl_mem_decode[] = {
98 "non_cacheable", 98 "NonCacheable",
99 "Cacheable", 99 "Cacheable",
100 "write_combining", 100 "WriteCombining",
101 "Prefetchable" 101 "Prefetchable"
102}; 102};
103 103
104const char *acpi_gbl_min_decode[2] = { 104const char *acpi_gbl_min_decode[] = {
105 "min_not_fixed", 105 "MinNotFixed",
106 "min_fixed" 106 "MinFixed"
107}; 107};
108 108
109const char *acpi_gbl_MTPdecode[4] = { 109const char *acpi_gbl_mtp_decode[] = {
110 "address_range_memory", 110 "AddressRangeMemory",
111 "address_range_reserved", 111 "AddressRangeReserved",
112 "address_range_aCPI", 112 "AddressRangeACPI",
113 "address_range_nVS" 113 "AddressRangeNVS"
114}; 114};
115 115
116const char *acpi_gbl_RNGdecode[4] = { 116const char *acpi_gbl_rng_decode[] = {
117 "invalid_ranges", 117 "InvalidRanges",
118 "non_iSAonly_ranges", 118 "NonISAOnlyRanges",
119 "ISAonly_ranges", 119 "ISAOnlyRanges",
120 "entire_range" 120 "EntireRange"
121}; 121};
122 122
123const char *acpi_gbl_RWdecode[2] = { 123const char *acpi_gbl_rw_decode[] = {
124 "read_only", 124 "ReadOnly",
125 "read_write" 125 "ReadWrite"
126}; 126};
127 127
128const char *acpi_gbl_SHRdecode[2] = { 128const char *acpi_gbl_shr_decode[] = {
129 "Exclusive", 129 "Exclusive",
130 "Shared" 130 "Shared"
131}; 131};
132 132
133const char *acpi_gbl_SIZdecode[4] = { 133const char *acpi_gbl_siz_decode[] = {
134 "Transfer8", 134 "Transfer8",
135 "Transfer8_16", 135 "Transfer8_16",
136 "Transfer16", 136 "Transfer16",
137 "invalid_size" 137 "InvalidSize"
138}; 138};
139 139
140const char *acpi_gbl_TRSdecode[2] = { 140const char *acpi_gbl_trs_decode[] = {
141 "dense_translation", 141 "DenseTranslation",
142 "sparse_translation" 142 "SparseTranslation"
143}; 143};
144 144
145const char *acpi_gbl_TTPdecode[2] = { 145const char *acpi_gbl_ttp_decode[] = {
146 "type_static", 146 "TypeStatic",
147 "type_translation" 147 "TypeTranslation"
148}; 148};
149 149
150const char *acpi_gbl_TYPdecode[4] = { 150const char *acpi_gbl_typ_decode[] = {
151 "Compatibility", 151 "Compatibility",
152 "type_a", 152 "TypeA",
153 "type_b", 153 "TypeB",
154 "type_f" 154 "TypeF"
155}; 155};
156 156
157#endif 157#endif
@@ -240,6 +240,104 @@ static const u8 acpi_gbl_resource_types[] = {
240 240
241/******************************************************************************* 241/*******************************************************************************
242 * 242 *
243 * FUNCTION: acpi_ut_walk_aml_resources
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource template
246 * aml_length - Length of the entire template
247 * user_function - Called once for each descriptor found. If
248 * NULL, a pointer to the end_tag is returned
249 * Context - Passed to user_function
250 *
251 * RETURN: Status
252 *
253 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
254 * once for each resource found.
255 *
256 ******************************************************************************/
257
258acpi_status
259acpi_ut_walk_aml_resources(u8 * aml,
260 acpi_size aml_length,
261 acpi_walk_aml_callback user_function, void **context)
262{
263 acpi_status status;
264 u8 *end_aml;
265 u8 resource_index;
266 u32 length;
267 u32 offset = 0;
268
269 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);
270
271 /* The absolute minimum resource template is one end_tag descriptor */
272
273 if (aml_length < sizeof(struct aml_resource_end_tag)) {
274 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
275 }
276
277 /* Point to the end of the resource template buffer */
278
279 end_aml = aml + aml_length;
280
281 /* Walk the byte list, abort on any invalid descriptor type or length */
282
283 while (aml < end_aml) {
284
285 /* Validate the Resource Type and Resource Length */
286
287 status = acpi_ut_validate_resource(aml, &resource_index);
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291
292 /* Get the length of this descriptor */
293
294 length = acpi_ut_get_descriptor_length(aml);
295
296 /* Invoke the user function */
297
298 if (user_function) {
299 status =
300 user_function(aml, length, offset, resource_index,
301 context);
302 if (ACPI_FAILURE(status)) {
303 return (status);
304 }
305 }
306
307 /* An end_tag descriptor terminates this resource template */
308
309 if (acpi_ut_get_resource_type(aml) ==
310 ACPI_RESOURCE_NAME_END_TAG) {
311 /*
312 * There must be at least one more byte in the buffer for
313 * the 2nd byte of the end_tag
314 */
315 if ((aml + 1) >= end_aml) {
316 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
317 }
318
319 /* Return the pointer to the end_tag if requested */
320
321 if (!user_function) {
322 *context = aml;
323 }
324
325 /* Normal exit */
326
327 return_ACPI_STATUS(AE_OK);
328 }
329
330 aml += length;
331 offset += length;
332 }
333
334 /* Did not find an end_tag descriptor */
335
336 return (AE_AML_NO_RESOURCE_END_TAG);
337}
338
339/*******************************************************************************
340 *
243 * FUNCTION: acpi_ut_validate_resource 341 * FUNCTION: acpi_ut_validate_resource
244 * 342 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
@@ -273,6 +371,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
273 * Examine the large/small bit in the resource header 371 * Examine the large/small bit in the resource header
274 */ 372 */
275 if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 373 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
374
276 /* Verify the large resource type (name) against the max */ 375 /* Verify the large resource type (name) against the max */
277 376
278 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
@@ -376,6 +475,7 @@ u8 acpi_ut_get_resource_type(void *aml)
376 * Examine the large/small bit in the resource header 475 * Examine the large/small bit in the resource header
377 */ 476 */
378 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { 477 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
478
379 /* Large Resource Type -- bits 6:0 contain the name */ 479 /* Large Resource Type -- bits 6:0 contain the name */
380 480
381 return (ACPI_GET8(aml)); 481 return (ACPI_GET8(aml));
@@ -411,6 +511,7 @@ u16 acpi_ut_get_resource_length(void *aml)
411 * Examine the large/small bit in the resource header 511 * Examine the large/small bit in the resource header
412 */ 512 */
413 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { 513 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
514
414 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 515 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
415 516
416 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1)); 517 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
@@ -495,60 +596,21 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
495 u8 ** end_tag) 596 u8 ** end_tag)
496{ 597{
497 acpi_status status; 598 acpi_status status;
498 u8 *aml;
499 u8 *end_aml;
500
501 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag");
502 599
503 /* Get start and end pointers */ 600 ACPI_FUNCTION_TRACE(ut_get_resource_end_tag);
504
505 aml = obj_desc->buffer.pointer;
506 end_aml = aml + obj_desc->buffer.length;
507 601
508 /* Allow a buffer length of zero */ 602 /* Allow a buffer length of zero */
509 603
510 if (!obj_desc->buffer.length) { 604 if (!obj_desc->buffer.length) {
511 *end_tag = aml; 605 *end_tag = obj_desc->buffer.pointer;
512 return_ACPI_STATUS(AE_OK); 606 return_ACPI_STATUS(AE_OK);
513 } 607 }
514 608
515 /* Walk the resource template, one descriptor per iteration */ 609 /* Validate the template and get a pointer to the end_tag */
516
517 while (aml < end_aml) {
518 /* Validate the Resource Type and Resource Length */
519
520 status = acpi_ut_validate_resource(aml, NULL);
521 if (ACPI_FAILURE(status)) {
522 return_ACPI_STATUS(status);
523 }
524
525 /* end_tag resource indicates the end of the resource template */
526
527 if (acpi_ut_get_resource_type(aml) ==
528 ACPI_RESOURCE_NAME_END_TAG) {
529 /*
530 * There must be at least one more byte in the buffer for
531 * the 2nd byte of the end_tag
532 */
533 if ((aml + 1) >= end_aml) {
534 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
535 }
536
537 /* Return the pointer to the end_tag */
538
539 *end_tag = aml;
540 return_ACPI_STATUS(AE_OK);
541 }
542
543 /*
544 * Point to the next resource descriptor in the AML buffer. The
545 * descriptor length is guaranteed to be non-zero by resource
546 * validation above.
547 */
548 aml += acpi_ut_get_descriptor_length(aml);
549 }
550 610
551 /* Did not find an end_tag resource descriptor */ 611 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer,
612 obj_desc->buffer.length, NULL,
613 (void **)end_tag);
552 614
553 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 615 return_ACPI_STATUS(status);
554} 616}