aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/events/evgpe.c8
-rw-r--r--drivers/acpi/events/evgpeblk.c10
-rw-r--r--drivers/acpi/events/evxface.c4
-rw-r--r--drivers/acpi/executer/exmisc.c5
-rw-r--r--drivers/acpi/executer/exregion.c4
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/resources/rsaddr.c745
-rw-r--r--drivers/acpi/resources/rscalc.c71
-rw-r--r--drivers/acpi/resources/rsdump.c1207
-rw-r--r--drivers/acpi/resources/rsinfo.c115
-rw-r--r--drivers/acpi/resources/rsio.c333
-rw-r--r--drivers/acpi/resources/rsirq.c393
-rw-r--r--drivers/acpi/resources/rslist.c92
-rw-r--r--drivers/acpi/resources/rsmemory.c303
-rw-r--r--drivers/acpi/resources/rsmisc.c814
-rw-r--r--drivers/acpi/resources/rsutils.c269
-rw-r--r--drivers/acpi/resources/rsxface.c2
-rw-r--r--drivers/acpi/tables/tbutils.c5
-rw-r--r--drivers/acpi/utilities/utalloc.c2
-rw-r--r--drivers/acpi/utilities/utglobal.c64
-rw-r--r--drivers/acpi/utilities/utmisc.c146
21 files changed, 1945 insertions, 2653 deletions
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index f51c3b16c608..bdd86537738e 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -372,14 +372,14 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
372 372
373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
374{ 374{
375 acpi_status status;
376 struct acpi_gpe_block_info *gpe_block;
377 struct acpi_gpe_register_info *gpe_register_info;
375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 378 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
376 u8 enabled_status_byte; 379 u8 enabled_status_byte;
377 struct acpi_gpe_register_info *gpe_register_info;
378 u32 status_reg; 380 u32 status_reg;
379 u32 enable_reg; 381 u32 enable_reg;
380 u32 flags; 382 acpi_native_uint flags;
381 acpi_status status;
382 struct acpi_gpe_block_info *gpe_block;
383 acpi_native_uint i; 383 acpi_native_uint i;
384 acpi_native_uint j; 384 acpi_native_uint j;
385 385
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index b312eb33c43e..7ca10c5f2914 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -136,7 +136,7 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
136 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
138 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
139 u32 flags; 139 acpi_native_uint flags;
140 140
141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
142 142
@@ -479,7 +479,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
479 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 479 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
480 struct acpi_gpe_xrupt_info *gpe_xrupt; 480 struct acpi_gpe_xrupt_info *gpe_xrupt;
481 acpi_status status; 481 acpi_status status;
482 u32 flags; 482 acpi_native_uint flags;
483 483
484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); 484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block");
485 485
@@ -553,7 +553,7 @@ static acpi_status
553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) 553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
554{ 554{
555 acpi_status status; 555 acpi_status status;
556 u32 flags; 556 acpi_native_uint flags;
557 557
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); 558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
559 559
@@ -610,7 +610,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
610 struct acpi_gpe_block_info *next_gpe_block; 610 struct acpi_gpe_block_info *next_gpe_block;
611 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 611 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
612 acpi_status status; 612 acpi_status status;
613 u32 flags; 613 acpi_native_uint flags;
614 614
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 615 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
616 616
@@ -663,7 +663,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) 663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
664{ 664{
665 acpi_status status; 665 acpi_status status;
666 u32 flags; 666 acpi_native_uint flags;
667 667
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 668 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
669 669
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 43b33d19cdf9..57d73299298e 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -562,7 +562,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
562 struct acpi_gpe_event_info *gpe_event_info; 562 struct acpi_gpe_event_info *gpe_event_info;
563 struct acpi_handler_info *handler; 563 struct acpi_handler_info *handler;
564 acpi_status status; 564 acpi_status status;
565 u32 flags; 565 acpi_native_uint flags;
566 566
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); 567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
568 568
@@ -653,7 +653,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
653 struct acpi_gpe_event_info *gpe_event_info; 653 struct acpi_gpe_event_info *gpe_event_info;
654 struct acpi_handler_info *handler; 654 struct acpi_handler_info *handler;
655 acpi_status status; 655 acpi_status status;
656 u32 flags; 656 acpi_native_uint flags;
657 657
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); 658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
659 659
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index a3f4d72bedc9..1899ab251393 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -625,9 +625,8 @@ acpi_ex_do_logical_op(u16 opcode,
625 625
626 /* Lexicographic compare: compare the data bytes */ 626 /* Lexicographic compare: compare the data bytes */
627 627
628 compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, 628 compare = ACPI_MEMCMP(operand0->buffer.pointer,
629 (const char *)local_operand1->buffer. 629 local_operand1->buffer.pointer,
630 pointer,
631 (length0 > length1) ? length1 : length0); 630 (length0 > length1) ? length1 : length0);
632 631
633 switch (opcode) { 632 switch (opcode) {
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 9a2f5bea3afe..1897379b5f90 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -77,7 +77,7 @@ acpi_ex_system_memory_space_handler(u32 function,
77 struct acpi_mem_space_context *mem_info = region_context; 77 struct acpi_mem_space_context *mem_info = region_context;
78 u32 length; 78 u32 length;
79 acpi_size window_size; 79 acpi_size window_size;
80#ifndef ACPI_MISALIGNED_TRANSFERS 80#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
81 u32 remainder; 81 u32 remainder;
82#endif 82#endif
83 83
@@ -109,7 +109,7 @@ acpi_ex_system_memory_space_handler(u32 function,
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
110 } 110 }
111 111
112#ifndef ACPI_MISALIGNED_TRANSFERS 112#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
113 /* 113 /*
114 * Hardware does not support non-aligned data transfers, we must verify 114 * Hardware does not support non-aligned data transfers, we must verify
115 * the request. 115 * the request.
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index e3cd0b16031a..4ece850b2af1 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1058,11 +1058,9 @@ EXPORT_SYMBOL(max_cstate);
1058 * Acquire a spinlock. 1058 * Acquire a spinlock.
1059 * 1059 *
1060 * handle is a pointer to the spinlock_t. 1060 * handle is a pointer to the spinlock_t.
1061 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1062 * that indicates whether we are at interrupt level.
1063 */ 1061 */
1064 1062
1065unsigned long acpi_os_acquire_lock(acpi_handle handle) 1063acpi_native_uint acpi_os_acquire_lock(acpi_handle handle)
1066{ 1064{
1067 unsigned long flags; 1065 unsigned long flags;
1068 spin_lock_irqsave((spinlock_t *) handle, flags); 1066 spin_lock_irqsave((spinlock_t *) handle, flags);
@@ -1073,7 +1071,7 @@ unsigned long acpi_os_acquire_lock(acpi_handle handle)
1073 * Release a spinlock. See above. 1071 * Release a spinlock. See above.
1074 */ 1072 */
1075 1073
1076void acpi_os_release_lock(acpi_handle handle, unsigned long flags) 1074void acpi_os_release_lock(acpi_handle handle, acpi_native_uint flags)
1077{ 1075{
1078 spin_unlock_irqrestore((spinlock_t *) handle, flags); 1076 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1079} 1077}
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 6f48ebf3304e..4ac942badbc0 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -47,683 +47,334 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsaddr") 48ACPI_MODULE_NAME("rsaddr")
49 49
50/* Local prototypes */
51static void
52acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags);
53
54static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource);
55
56static void
57acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
58
59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
60
61static void
62acpi_rs_set_address_common(union aml_resource *aml,
63 struct acpi_resource *resource);
64
65static u8
66acpi_rs_get_address_common(struct acpi_resource *resource,
67 union aml_resource *aml);
68
69/*******************************************************************************
70 *
71 * FUNCTION: acpi_rs_decode_general_flags
72 *
73 * PARAMETERS: Resource - Address resource data struct
74 * Flags - Raw AML flag byte
75 *
76 * RETURN: Decoded flag bits in resource struct
77 *
78 * DESCRIPTION: Decode a general flag byte to an address resource struct
79 *
80 ******************************************************************************/
81
82static void
83acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags)
84{
85 ACPI_FUNCTION_ENTRY();
86
87 /* Producer / Consumer - flag bit[0] */
88
89 resource->address.producer_consumer = (u32) (flags & 0x01);
90
91 /* Decode (_DEC) - flag bit[1] */
92
93 resource->address.decode = (u32) ((flags >> 1) & 0x01);
94
95 /* Min Address Fixed (_MIF) - flag bit[2] */
96
97 resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01);
98
99 /* Max Address Fixed (_MAF) - flag bit[3] */
100
101 resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_rs_encode_general_flags
107 *
108 * PARAMETERS: Resource - Address resource data struct
109 *
110 * RETURN: Encoded general flag byte
111 *
112 * DESCRIPTION: Construct a general flag byte from an address resource struct
113 *
114 ******************************************************************************/
115
116static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
117{
118 ACPI_FUNCTION_ENTRY();
119
120 return ((u8)
121
122 /* Producer / Consumer - flag bit[0] */
123 ((resource->address.producer_consumer & 0x01) |
124 /* Decode (_DEC) - flag bit[1] */
125 ((resource->address.decode & 0x01) << 1) |
126 /* Min Address Fixed (_MIF) - flag bit[2] */
127 ((resource->address.min_address_fixed & 0x01) << 2) |
128 /* Max Address Fixed (_MAF) - flag bit[3] */
129 ((resource->address.max_address_fixed & 0x01) << 3))
130 );
131}
132
133/******************************************************************************* 50/*******************************************************************************
134 * 51 *
135 * FUNCTION: acpi_rs_decode_specific_flags 52 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
136 *
137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Raw AML flag byte
139 *
140 * RETURN: Decoded flag bits in attribute struct
141 *
142 * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
143 * Type-specific flags are only defined for the Memory and IO
144 * resource types.
145 * 53 *
146 ******************************************************************************/ 54 ******************************************************************************/
55struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
57 ACPI_RS_SIZE(struct acpi_resource_address16),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
147 59
148static void 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
149acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) 61 sizeof(struct aml_resource_address16),
150{ 62 0},
151 ACPI_FUNCTION_ENTRY();
152
153 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
154 /* Write Status (_RW) - flag bit[0] */
155
156 resource->address.attribute.memory.read_write_attribute =
157 (u16) (flags & 0x01);
158 63
159 /* Memory Attributes (_MEM) - flag bits[2:1] */ 64 /* Resource Type, General Flags, and Type-Specific Flags */
160 65
161 resource->address.attribute.memory.cache_attribute = 66 {ACPI_RSC_ADDRESS, 0, 0, 0},
162 (u16) ((flags >> 1) & 0x03);
163 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
164 /* Ranges (_RNG) - flag bits[1:0] */
165
166 resource->address.attribute.io.range_attribute =
167 (u16) (flags & 0x03);
168
169 /* Translations (_TTP and _TRS) - flag bits[5:4] */
170
171 resource->address.attribute.io.translation_attribute =
172 (u16) ((flags >> 4) & 0x03);
173 }
174}
175
176/*******************************************************************************
177 *
178 * FUNCTION: acpi_rs_encode_specific_flags
179 *
180 * PARAMETERS: Resource - Address resource data struct
181 *
182 * RETURN: Encoded type-specific flag byte
183 *
184 * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
185 * Type-specific flags are only defined for the Memory and IO
186 * resource types.
187 *
188 ******************************************************************************/
189
190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource)
191{
192 ACPI_FUNCTION_ENTRY();
193
194 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
195 return ((u8)
196
197 /* Write Status (_RW) - flag bit[0] */
198 ((resource->address.attribute.memory.
199 read_write_attribute & 0x01) |
200 /* Memory Attributes (_MEM) - flag bits[2:1] */
201 ((resource->address.attribute.memory.
202 cache_attribute & 0x03) << 1)));
203 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
204 return ((u8)
205
206 /* Ranges (_RNG) - flag bits[1:0] */
207 ((resource->address.attribute.io.
208 range_attribute & 0x03) |
209 /* Translations (_TTP and _TRS) - flag bits[5:4] */
210 ((resource->address.attribute.io.
211 translation_attribute & 0x03) << 4)));
212 }
213
214 return (0);
215}
216
217/*******************************************************************************
218 *
219 * FUNCTION: acpi_rs_set_address_common
220 *
221 * PARAMETERS: Aml - Pointer to the AML resource descriptor
222 * Resource - Pointer to the internal resource struct
223 *
224 * RETURN: None
225 *
226 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
227 * AML descriptor
228 *
229 ******************************************************************************/
230
231static void
232acpi_rs_set_address_common(union aml_resource *aml,
233 struct acpi_resource *resource)
234{
235 ACPI_FUNCTION_ENTRY();
236
237 /* Set the Resource Type (Memory, Io, bus_number, etc.) */
238
239 aml->address.resource_type = (u8) resource->data.address.resource_type;
240
241 /* Set the general flags */
242
243 aml->address.flags = acpi_rs_encode_general_flags(&resource->data);
244
245 /* Set the type-specific flags */
246
247 aml->address.specific_flags =
248 acpi_rs_encode_specific_flags(&resource->data);
249}
250
251/*******************************************************************************
252 *
253 * FUNCTION: acpi_rs_get_address_common
254 *
255 * PARAMETERS: Resource - Pointer to the internal resource struct
256 * Aml - Pointer to the AML resource descriptor
257 *
258 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
259 *
260 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
261 * to an internal resource descriptor
262 *
263 ******************************************************************************/
264
265static u8
266acpi_rs_get_address_common(struct acpi_resource *resource,
267 union aml_resource *aml)
268{
269 ACPI_FUNCTION_ENTRY();
270
271 /* Validate resource type */
272
273 if ((aml->address.resource_type > 2)
274 && (aml->address.resource_type < 0xC0)) {
275 return (FALSE);
276 }
277
278 /* Get the Resource Type (Memory, Io, bus_number, etc.) */
279
280 resource->data.address.resource_type = aml->address.resource_type;
281
282 /* Get the General Flags */
283
284 acpi_rs_decode_general_flags(&resource->data, aml->address.flags);
285
286 /* Get the Type-Specific Flags */
287
288 acpi_rs_decode_specific_flags(&resource->data,
289 aml->address.specific_flags);
290 return (TRUE);
291}
292
293/*******************************************************************************
294 *
295 * FUNCTION: acpi_rs_get_address16
296 *
297 * PARAMETERS: Aml - Pointer to the AML resource descriptor
298 * aml_resource_length - Length of the resource from the AML header
299 * Resource - Where the internal resource is returned
300 *
301 * RETURN: Status
302 *
303 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
304 * internal resource descriptor, simplifying bitflags and handling
305 * alignment and endian issues if necessary.
306 *
307 ******************************************************************************/
308
309acpi_status
310acpi_rs_get_address16(union aml_resource * aml,
311 u16 aml_resource_length, struct acpi_resource * resource)
312{
313 ACPI_FUNCTION_TRACE("rs_get_address16");
314
315 /* Get the Resource Type, general flags, and type-specific flags */
316
317 if (!acpi_rs_get_address_common(resource, aml)) {
318 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
319 }
320 67
321 /* 68 /*
322 * Get the following contiguous fields from the AML descriptor: 69 * These fields are contiguous in both the source and destination:
323 * Address Granularity 70 * Address Granularity
324 * Address Range Minimum 71 * Address Range Minimum
325 * Address Range Maximum 72 * Address Range Maximum
326 * Address Translation Offset 73 * Address Translation Offset
327 * Address Length 74 * Address Length
328 */ 75 */
329 acpi_rs_move_data(&resource->data.address16.granularity, 76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
330 &aml->address16.granularity, 5, 77 AML_OFFSET(address16.granularity),
331 ACPI_MOVE_TYPE_16_TO_32); 78 5},
332
333 /* Get the optional resource_source (index and string) */
334
335 resource->length =
336 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) +
337 acpi_rs_get_resource_source(aml_resource_length,
338 sizeof(struct aml_resource_address16),
339 &resource->data.address16.
340 resource_source, aml, NULL);
341 79
342 /* Complete the resource header */ 80 /* Optional resource_source (Index and String) */
343 81
344 resource->type = ACPI_RESOURCE_TYPE_ADDRESS16; 82 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
345 return_ACPI_STATUS(AE_OK); 83 0,
346} 84 sizeof(struct aml_resource_address16)}
85};
347 86
348/******************************************************************************* 87/*******************************************************************************
349 * 88 *
350 * FUNCTION: acpi_rs_set_address16 89 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
351 *
352 * PARAMETERS: Resource - Pointer to the resource descriptor
353 * Aml - Where the AML descriptor is returned
354 *
355 * RETURN: Status
356 *
357 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
358 * external AML resource descriptor.
359 * 90 *
360 ******************************************************************************/ 91 ******************************************************************************/
361 92
362acpi_status 93struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
363acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml) 94 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
364{ 95 ACPI_RS_SIZE(struct acpi_resource_address32),
365 acpi_size descriptor_length; 96 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
366 97
367 ACPI_FUNCTION_TRACE("rs_set_address16"); 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
99 sizeof(struct aml_resource_address32),
100 0},
368 101
369 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 102 /* Resource Type, General Flags, and Type-Specific Flags */
370 103
371 acpi_rs_set_address_common(aml, resource); 104 {ACPI_RSC_ADDRESS, 0, 0, 0},
372 105
373 /* 106 /*
374 * Set the following contiguous fields in the AML descriptor: 107 * These fields are contiguous in both the source and destination:
375 * Address Granularity 108 * Address Granularity
376 * Address Range Minimum 109 * Address Range Minimum
377 * Address Range Maximum 110 * Address Range Maximum
378 * Address Translation Offset 111 * Address Translation Offset
379 * Address Length 112 * Address Length
380 */ 113 */
381 acpi_rs_move_data(&aml->address16.granularity, 114 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
382 &resource->data.address16.granularity, 5, 115 AML_OFFSET(address32.granularity),
383 ACPI_MOVE_TYPE_32_TO_16); 116 5},
384
385 /* Resource Source Index and Resource Source are optional */
386 117
387 descriptor_length = acpi_rs_set_resource_source(aml, 118 /* Optional resource_source (Index and String) */
388 sizeof(struct
389 aml_resource_address16),
390 &resource->data.
391 address16.
392 resource_source);
393 119
394 /* Complete the AML descriptor header */ 120 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
395 121 0,
396 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16, 122 sizeof(struct aml_resource_address32)}
397 descriptor_length, aml); 123};
398 return_ACPI_STATUS(AE_OK);
399}
400 124
401/******************************************************************************* 125/*******************************************************************************
402 * 126 *
403 * FUNCTION: acpi_rs_get_address32 127 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
404 *
405 * PARAMETERS: Aml - Pointer to the AML resource descriptor
406 * aml_resource_length - Length of the resource from the AML header
407 * Resource - Where the internal resource is returned
408 *
409 * RETURN: Status
410 *
411 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
412 * internal resource descriptor, simplifying bitflags and handling
413 * alignment and endian issues if necessary.
414 * 128 *
415 ******************************************************************************/ 129 ******************************************************************************/
416 130
417acpi_status 131struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
418acpi_rs_get_address32(union aml_resource *aml, 132 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
419 u16 aml_resource_length, struct acpi_resource *resource) 133 ACPI_RS_SIZE(struct acpi_resource_address64),
420{ 134 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
421 135
422 ACPI_FUNCTION_TRACE("rs_get_address32"); 136 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
137 sizeof(struct aml_resource_address64),
138 0},
423 139
424 /* Get the Resource Type, general flags, and type-specific flags */ 140 /* Resource Type, General Flags, and Type-Specific Flags */
425 141
426 if (!acpi_rs_get_address_common(resource, (void *)aml)) { 142 {ACPI_RSC_ADDRESS, 0, 0, 0},
427 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
428 }
429 143
430 /* 144 /*
431 * Get the following contiguous fields from the AML descriptor: 145 * These fields are contiguous in both the source and destination:
432 * Address Granularity 146 * Address Granularity
433 * Address Range Minimum 147 * Address Range Minimum
434 * Address Range Maximum 148 * Address Range Maximum
435 * Address Translation Offset 149 * Address Translation Offset
436 * Address Length 150 * Address Length
437 */ 151 */
438 acpi_rs_move_data(&resource->data.address32.granularity, 152 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
439 &aml->address32.granularity, 5, 153 AML_OFFSET(address64.granularity),
440 ACPI_MOVE_TYPE_32_TO_32); 154 5},
441 155
442 /* Get the optional resource_source (index and string) */ 156 /* Optional resource_source (Index and String) */
443 157
444 resource->length = 158 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
445 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + 159 0,
446 acpi_rs_get_resource_source(aml_resource_length, 160 sizeof(struct aml_resource_address64)}
447 sizeof(struct aml_resource_address32), 161};
448 &resource->data.address32.
449 resource_source, aml, NULL);
450
451 /* Complete the resource header */
452
453 resource->type = ACPI_RESOURCE_TYPE_ADDRESS32;
454 return_ACPI_STATUS(AE_OK);
455}
456 162
457/******************************************************************************* 163/*******************************************************************************
458 * 164 *
459 * FUNCTION: acpi_rs_set_address32 165 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
460 *
461 * PARAMETERS: Resource - Pointer to the resource descriptor
462 * Aml - Where the AML descriptor is returned
463 *
464 * RETURN: Status
465 *
466 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
467 * external AML resource descriptor.
468 * 166 *
469 ******************************************************************************/ 167 ******************************************************************************/
470 168
471acpi_status 169struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
472acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml) 170 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
473{ 171 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
474 acpi_size descriptor_length; 172 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
173
174 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
175 sizeof(struct aml_resource_extended_address64),
176 0},
475 177
476 ACPI_FUNCTION_TRACE("rs_set_address32"); 178 /* Resource Type, General Flags, and Type-Specific Flags */
477 179
478 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 180 {ACPI_RSC_ADDRESS, 0, 0, 0},
479 181
480 acpi_rs_set_address_common(aml, resource); 182 /* Revision ID */
481 183
184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
185 AML_OFFSET(ext_address64.revision_iD),
186 1},
482 /* 187 /*
483 * Set the following contiguous fields in the AML descriptor: 188 * These fields are contiguous in both the source and destination:
484 * Address Granularity 189 * Address Granularity
485 * Address Range Minimum 190 * Address Range Minimum
486 * Address Range Maximum 191 * Address Range Maximum
487 * Address Translation Offset 192 * Address Translation Offset
488 * Address Length 193 * Address Length
194 * Type-Specific Attribute
489 */ 195 */
490 acpi_rs_move_data(&aml->address32.granularity, 196 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
491 &resource->data.address32.granularity, 5, 197 AML_OFFSET(ext_address64.granularity),
492 ACPI_MOVE_TYPE_32_TO_32); 198 6}
493 199};
494 /* Resource Source Index and Resource Source are optional */
495
496 descriptor_length = acpi_rs_set_resource_source(aml,
497 sizeof(struct
498 aml_resource_address32),
499 &resource->data.
500 address32.
501 resource_source);
502
503 /* Complete the AML descriptor header */
504
505 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32,
506 descriptor_length, aml);
507 return_ACPI_STATUS(AE_OK);
508}
509 200
510/******************************************************************************* 201/*******************************************************************************
511 * 202 *
512 * FUNCTION: acpi_rs_get_address64 203 * acpi_rs_convert_general_flags - Flags common to all address descriptors
513 *
514 * PARAMETERS: Aml - Pointer to the AML resource descriptor
515 * aml_resource_length - Length of the resource from the AML header
516 * Resource - Where the internal resource is returned
517 *
518 * RETURN: Status
519 *
520 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
521 * internal resource descriptor, simplifying bitflags and handling
522 * alignment and endian issues if necessary.
523 * 204 *
524 ******************************************************************************/ 205 ******************************************************************************/
525 206
526acpi_status 207static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
527acpi_rs_get_address64(union aml_resource *aml, 208 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
528 u16 aml_resource_length, struct acpi_resource *resource) 209 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
529{
530 ACPI_FUNCTION_TRACE("rs_get_address64");
531 210
532 /* Get the Resource Type, general Flags, and type-specific Flags */ 211 /* Resource Type (Memory, Io, bus_number, etc.) */
533 212
534 if (!acpi_rs_get_address_common(resource, aml)) { 213 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
535 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 214 AML_OFFSET(address.resource_type),
536 } 215 1},
537 216
538 /* 217 /* General Flags - Consume, Decode, min_fixed, max_fixed */
539 * Get the following contiguous fields from the AML descriptor:
540 * Address Granularity
541 * Address Range Minimum
542 * Address Range Maximum
543 * Address Translation Offset
544 * Address Length
545 */
546 acpi_rs_move_data(&resource->data.address64.granularity,
547 &aml->address64.granularity, 5,
548 ACPI_MOVE_TYPE_64_TO_64);
549 218
550 /* Get the optional resource_source (index and string) */ 219 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
220 AML_OFFSET(address.flags),
221 0},
551 222
552 resource->length = 223 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
553 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + 224 AML_OFFSET(address.flags),
554 acpi_rs_get_resource_source(aml_resource_length, 225 1},
555 sizeof(struct aml_resource_address64),
556 &resource->data.address64.
557 resource_source, aml, NULL);
558 226
559 /* Complete the resource header */ 227 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
228 AML_OFFSET(address.flags),
229 2},
560 230
561 resource->type = ACPI_RESOURCE_TYPE_ADDRESS64; 231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
562 return_ACPI_STATUS(AE_OK); 232 AML_OFFSET(address.flags),
563} 233 3}
234};
564 235
565/******************************************************************************* 236/*******************************************************************************
566 * 237 *
567 * FUNCTION: acpi_rs_set_address64 238 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
568 *
569 * PARAMETERS: Resource - Pointer to the resource descriptor
570 * Aml - Where the AML descriptor is returned
571 *
572 * RETURN: Status
573 *
574 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
575 * external AML resource descriptor.
576 * 239 *
577 ******************************************************************************/ 240 ******************************************************************************/
578 241
579acpi_status 242static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
580acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml) 243 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
581{ 244 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
582 acpi_size descriptor_length;
583 245
584 ACPI_FUNCTION_TRACE("rs_set_address64"); 246 /* Memory-specific flags */
585 247
586 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 248 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
249 AML_OFFSET(address.specific_flags),
250 0},
587 251
588 acpi_rs_set_address_common(aml, resource); 252 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
253 AML_OFFSET(address.specific_flags),
254 1},
589 255
590 /* 256 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
591 * Set the following contiguous fields in the AML descriptor: 257 AML_OFFSET(address.specific_flags),
592 * Address Granularity 258 3},
593 * Address Range Minimum 259
594 * Address Range Maximum 260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
595 * Address Translation Offset 261 AML_OFFSET(address.specific_flags),
596 * Address Length 262 5}
597 */ 263};
598 acpi_rs_move_data(&aml->address64.granularity, 264
599 &resource->data.address64.granularity, 5, 265/*******************************************************************************
600 ACPI_MOVE_TYPE_64_TO_64); 266 *
267 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
268 *
269 ******************************************************************************/
601 270
602 /* Resource Source Index and Resource Source are optional */ 271static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
272 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
273 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
603 274
604 descriptor_length = acpi_rs_set_resource_source(aml, 275 /* I/O-specific flags */
605 sizeof(struct
606 aml_resource_address64),
607 &resource->data.
608 address64.
609 resource_source);
610 276
611 /* Complete the AML descriptor header */ 277 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
278 AML_OFFSET(address.specific_flags),
279 0},
612 280
613 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64, 281 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
614 descriptor_length, aml); 282 AML_OFFSET(address.specific_flags),
615 return_ACPI_STATUS(AE_OK); 283 4},
616} 284
285 {ACPI_RSC_1BITFLAG,
286 ACPI_RS_OFFSET(data.address.info.io.translation_type),
287 AML_OFFSET(address.specific_flags),
288 5}
289};
617 290
618/******************************************************************************* 291/*******************************************************************************
619 * 292 *
620 * FUNCTION: acpi_rs_get_ext_address64 293 * FUNCTION: acpi_rs_get_address_common
621 * 294 *
622 * PARAMETERS: Aml - Pointer to the AML resource descriptor 295 * PARAMETERS: Resource - Pointer to the internal resource struct
623 * aml_resource_length - Length of the resource from the AML header 296 * Aml - Pointer to the AML resource descriptor
624 * Resource - Where the internal resource is returned
625 * 297 *
626 * RETURN: Status 298 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
627 * 299 *
628 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 300 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
629 * internal resource descriptor, simplifying bitflags and handling 301 * to an internal resource descriptor
630 * alignment and endian issues if necessary.
631 * 302 *
632 ******************************************************************************/ 303 ******************************************************************************/
633 304
634acpi_status 305u8
635acpi_rs_get_ext_address64(union aml_resource *aml, 306acpi_rs_get_address_common(struct acpi_resource *resource,
636 u16 aml_resource_length, 307 union aml_resource *aml)
637 struct acpi_resource *resource)
638{ 308{
309 ACPI_FUNCTION_ENTRY();
639 310
640 ACPI_FUNCTION_TRACE("rs_get_ext_address64"); 311 /* Validate the Resource Type */
641
642 /* Get the Resource Type, general flags, and type-specific flags */
643 312
644 if (!acpi_rs_get_address_common(resource, aml)) { 313 if ((aml->address.resource_type > 2)
645 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 314 && (aml->address.resource_type < 0xC0)) {
315 return (FALSE);
646 } 316 }
647 317
648 /* 318 /* Get the Resource Type and General Flags */
649 * Get and validate the Revision ID
650 * Note: Only one revision ID is currently supported
651 */
652 resource->data.ext_address64.revision_iD =
653 aml->ext_address64.revision_iD;
654 if (aml->ext_address64.revision_iD !=
655 AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
656 return_ACPI_STATUS(AE_SUPPORT);
657 }
658 319
659 /* 320 (void)acpi_rs_convert_aml_to_resource(resource, aml,
660 * Get the following contiguous fields from the AML descriptor: 321 acpi_rs_convert_general_flags);
661 * Address Granularity 322
662 * Address Range Minimum 323 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
663 * Address Range Maximum
664 * Address Translation Offset
665 * Address Length
666 * Type-Specific Attribute
667 */
668 acpi_rs_move_data(&resource->data.ext_address64.granularity,
669 &aml->ext_address64.granularity, 6,
670 ACPI_MOVE_TYPE_64_TO_64);
671 324
672 /* Complete the resource header */ 325 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
326 (void)acpi_rs_convert_aml_to_resource(resource, aml,
327 acpi_rs_convert_mem_flags);
328 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
329 (void)acpi_rs_convert_aml_to_resource(resource, aml,
330 acpi_rs_convert_io_flags);
331 } else {
332 /* Generic resource type, just grab the type_specific byte */
673 333
674 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64; 334 resource->data.address.info.type_specific =
675 resource->length = 335 aml->address.specific_flags;
676 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64); 336 }
677 return_ACPI_STATUS(AE_OK); 337
338 return (TRUE);
678} 339}
679 340
680/******************************************************************************* 341/*******************************************************************************
681 * 342 *
682 * FUNCTION: acpi_rs_set_ext_address64 343 * FUNCTION: acpi_rs_set_address_common
683 * 344 *
684 * PARAMETERS: Resource - Pointer to the resource descriptor 345 * PARAMETERS: Aml - Pointer to the AML resource descriptor
685 * Aml - Where the AML descriptor is returned 346 * Resource - Pointer to the internal resource struct
686 * 347 *
687 * RETURN: Status 348 * RETURN: None
688 * 349 *
689 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 350 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
690 * external AML resource descriptor. 351 * AML descriptor
691 * 352 *
692 ******************************************************************************/ 353 ******************************************************************************/
693 354
694acpi_status 355void
695acpi_rs_set_ext_address64(struct acpi_resource *resource, 356acpi_rs_set_address_common(union aml_resource *aml,
696 union aml_resource *aml) 357 struct acpi_resource *resource)
697{ 358{
698 ACPI_FUNCTION_TRACE("rs_set_ext_address64"); 359 ACPI_FUNCTION_ENTRY();
699 360
700 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 361 /* Set the Resource Type and General Flags */
701 362
702 acpi_rs_set_address_common(aml, resource); 363 (void)acpi_rs_convert_resource_to_aml(resource, aml,
364 acpi_rs_convert_general_flags);
703 365
704 /* Only one Revision ID is currently supported */ 366 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
705 367
706 aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; 368 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
707 aml->ext_address64.reserved = 0; 369 (void)acpi_rs_convert_resource_to_aml(resource, aml,
370 acpi_rs_convert_mem_flags);
371 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
372 (void)acpi_rs_convert_resource_to_aml(resource, aml,
373 acpi_rs_convert_io_flags);
374 } else {
375 /* Generic resource type, just copy the type_specific byte */
708 376
709 /* 377 aml->address.specific_flags =
710 * Set the following contiguous fields in the AML descriptor: 378 resource->data.address.info.type_specific;
711 * Address Granularity 379 }
712 * Address Range Minimum
713 * Address Range Maximum
714 * Address Translation Offset
715 * Address Length
716 * Type-Specific Attribute
717 */
718 acpi_rs_move_data(&aml->ext_address64.granularity,
719 &resource->data.address64.granularity, 6,
720 ACPI_MOVE_TYPE_64_TO_64);
721
722 /* Complete the AML descriptor header */
723
724 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
725 sizeof(struct
726 aml_resource_extended_address64),
727 aml);
728 return_ACPI_STATUS(AE_OK);
729} 380}
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index d170dee07ce9..c29d3a447278 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -52,7 +52,7 @@ ACPI_MODULE_NAME("rscalc")
52/* Local prototypes */ 52/* Local prototypes */
53static u8 acpi_rs_count_set_bits(u16 bit_field); 53static u8 acpi_rs_count_set_bits(u16 bit_field);
54 54
55static acpi_size 55static acpi_rs_length
56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); 56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
57 57
58static u32 58static u32
@@ -100,7 +100,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
100 * 100 *
101 ******************************************************************************/ 101 ******************************************************************************/
102 102
103static acpi_size 103static acpi_rs_length
104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) 104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
105{ 105{
106 ACPI_FUNCTION_ENTRY(); 106 ACPI_FUNCTION_ENTRY();
@@ -111,7 +111,7 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
111 * resource_source_index (1). 111 * resource_source_index (1).
112 */ 112 */
113 if (resource_source->string_ptr) { 113 if (resource_source->string_ptr) {
114 return ((acpi_size) resource_source->string_length + 1); 114 return ((acpi_rs_length) (resource_source->string_length + 1));
115 } 115 }
116 116
117 return (0); 117 return (0);
@@ -184,7 +184,7 @@ acpi_status
184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) 184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
185{ 185{
186 acpi_size aml_size_needed = 0; 186 acpi_size aml_size_needed = 0;
187 acpi_size segment_size; 187 acpi_rs_length total_size;
188 188
189 ACPI_FUNCTION_TRACE("rs_get_aml_length"); 189 ACPI_FUNCTION_TRACE("rs_get_aml_length");
190 190
@@ -199,7 +199,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
199 199
200 /* Get the base size of the (external stream) resource descriptor */ 200 /* Get the base size of the (external stream) resource descriptor */
201 201
202 segment_size = acpi_gbl_aml_resource_sizes[resource->type]; 202 total_size = acpi_gbl_aml_resource_sizes[resource->type];
203 203
204 /* 204 /*
205 * Augment the base size for descriptors with optional and/or 205 * Augment the base size for descriptors with optional and/or
@@ -216,13 +216,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
216 if (resource->data.vendor.byte_length > 7) { 216 if (resource->data.vendor.byte_length > 7) {
217 /* Base size of a Large resource descriptor */ 217 /* Base size of a Large resource descriptor */
218 218
219 segment_size = 219 total_size =
220 sizeof(struct aml_resource_large_header); 220 sizeof(struct aml_resource_large_header);
221 } 221 }
222 222
223 /* Add the size of the vendor-specific data */ 223 /* Add the size of the vendor-specific data */
224 224
225 segment_size += resource->data.vendor.byte_length; 225 total_size = (acpi_rs_length)
226 (total_size + resource->data.vendor.byte_length);
226 break; 227 break;
227 228
228 case ACPI_RESOURCE_TYPE_END_TAG: 229 case ACPI_RESOURCE_TYPE_END_TAG:
@@ -230,7 +231,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
230 * End Tag: 231 * End Tag:
231 * We are done -- return the accumulated total size. 232 * We are done -- return the accumulated total size.
232 */ 233 */
233 *size_needed = aml_size_needed + segment_size; 234 *size_needed = aml_size_needed + total_size;
234 235
235 /* Normal exit */ 236 /* Normal exit */
236 237
@@ -241,10 +242,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
241 * 16-Bit Address Resource: 242 * 16-Bit Address Resource:
242 * Add the size of the optional resource_source info 243 * Add the size of the optional resource_source info
243 */ 244 */
244 segment_size += 245 total_size = (acpi_rs_length)
245 acpi_rs_struct_option_length(&resource->data. 246 (total_size +
246 address16. 247 acpi_rs_struct_option_length(&resource->data.
247 resource_source); 248 address16.
249 resource_source));
248 break; 250 break;
249 251
250 case ACPI_RESOURCE_TYPE_ADDRESS32: 252 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -252,10 +254,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
252 * 32-Bit Address Resource: 254 * 32-Bit Address Resource:
253 * Add the size of the optional resource_source info 255 * Add the size of the optional resource_source info
254 */ 256 */
255 segment_size += 257 total_size = (acpi_rs_length)
256 acpi_rs_struct_option_length(&resource->data. 258 (total_size +
257 address32. 259 acpi_rs_struct_option_length(&resource->data.
258 resource_source); 260 address32.
261 resource_source));
259 break; 262 break;
260 263
261 case ACPI_RESOURCE_TYPE_ADDRESS64: 264 case ACPI_RESOURCE_TYPE_ADDRESS64:
@@ -263,10 +266,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
263 * 64-Bit Address Resource: 266 * 64-Bit Address Resource:
264 * Add the size of the optional resource_source info 267 * Add the size of the optional resource_source info
265 */ 268 */
266 segment_size += 269 total_size = (acpi_rs_length)
267 acpi_rs_struct_option_length(&resource->data. 270 (total_size +
268 address64. 271 acpi_rs_struct_option_length(&resource->data.
269 resource_source); 272 address64.
273 resource_source));
270 break; 274 break;
271 275
272 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 276 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
@@ -275,16 +279,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
275 * Add the size of each additional optional interrupt beyond the 279 * Add the size of each additional optional interrupt beyond the
276 * required 1 (4 bytes for each u32 interrupt number) 280 * required 1 (4 bytes for each u32 interrupt number)
277 */ 281 */
278 segment_size += (((acpi_size) 282 total_size = (acpi_rs_length)
279 resource->data.extended_irq. 283 (total_size +
280 interrupt_count - 1) * 4); 284 ((resource->data.extended_irq.interrupt_count -
281 285 1) * 4) +
282 /* Add the size of the optional resource_source info */ 286 /* Add the size of the optional resource_source info */
283 287 acpi_rs_struct_option_length(&resource->data.
284 segment_size += 288 extended_irq.
285 acpi_rs_struct_option_length(&resource->data. 289 resource_source));
286 extended_irq.
287 resource_source);
288 break; 290 break;
289 291
290 default: 292 default:
@@ -293,7 +295,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
293 295
294 /* Update the total */ 296 /* Update the total */
295 297
296 aml_size_needed += segment_size; 298 aml_size_needed += total_size;
297 299
298 /* Point to the next object */ 300 /* Point to the next object */
299 301
@@ -341,7 +343,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
341 while (bytes_parsed < aml_buffer_length) { 343 while (bytes_parsed < aml_buffer_length) {
342 /* The next byte in the stream is the resource descriptor type */ 344 /* The next byte in the stream is the resource descriptor type */
343 345
344 resource_type = acpi_rs_get_resource_type(*aml_buffer); 346 resource_type = acpi_ut_get_resource_type(aml_buffer);
345 347
346 /* Get the base stream size and structure sizes for the descriptor */ 348 /* Get the base stream size and structure sizes for the descriptor */
347 349
@@ -352,10 +354,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
352 354
353 /* Get the Length field from the input resource descriptor */ 355 /* Get the Length field from the input resource descriptor */
354 356
355 resource_length = 357 resource_length = acpi_ut_get_resource_length(aml_buffer);
356 acpi_rs_get_resource_length(ACPI_CAST_PTR
357 (union aml_resource,
358 aml_buffer));
359 358
360 /* Augment the size for descriptors with optional fields */ 359 /* Augment the size for descriptors with optional fields */
361 360
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 2f8990845b2d..27172a3d55d7 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -43,6 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
46#include <acpi/acdisasm.h>
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsdump") 49ACPI_MODULE_NAME("rsdump")
@@ -61,108 +62,448 @@ static void acpi_rs_out_integer64(char *title, u64 value);
61 62
62static void acpi_rs_out_title(char *title); 63static void acpi_rs_out_title(char *title);
63 64
64static void acpi_rs_dump_byte_list(u32 length, u8 * data); 65static void acpi_rs_dump_byte_list(u16 length, u8 * data);
65 66
66static void acpi_rs_dump_dword_list(u32 length, u32 * data); 67static void acpi_rs_dump_dword_list(u8 length, u32 * data);
67 68
68static void acpi_rs_dump_short_byte_list(u32 length, u32 * data); 69static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
69 70
70static void 71static void
71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); 72acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
72 73
73static void acpi_rs_dump_address_common(union acpi_resource_data *resource); 74static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
74 75
76static void
77acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
78
79#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
80#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
81#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
82
75/******************************************************************************* 83/*******************************************************************************
76 * 84 *
77 * FUNCTION: acpi_rs_out* 85 * Resource Descriptor info tables
78 *
79 * PARAMETERS: Title - Name of the resource field
80 * Value - Value of the resource field
81 *
82 * RETURN: None
83 * 86 *
84 * DESCRIPTION: Miscellaneous helper functions to consistently format the 87 * Note: The first table entry must be a Title or Literal and must contain
85 * output of the resource dump routines 88 * the table length (number of table entries)
86 * 89 *
87 ******************************************************************************/ 90 ******************************************************************************/
88 91
89static void acpi_rs_out_string(char *title, char *value) 92struct acpi_rsdump_info acpi_rs_dump_irq[6] = {
90{ 93 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
91 acpi_os_printf("%27s : %s\n", title, value); 94 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
92} 95 acpi_gbl_HEdecode},
96 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
97 acpi_gbl_LLdecode},
98 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
99 acpi_gbl_SHRdecode},
100 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
101 "Interrupt Count", NULL},
102 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
103 "Interrupt List", NULL}
104};
105
106struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
107 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
108 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
109 acpi_gbl_TYPdecode},
110 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
111 acpi_gbl_BMdecode},
112 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
113 acpi_gbl_SIZdecode},
114 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
115 NULL},
116 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
117 NULL}
118};
119
120struct acpi_rsdump_info acpi_rs_dump_start_dpf[3] = {
121 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
122 "Start-Dependent-Functions", NULL},
123 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
124 "Compatibility Priority", acpi_gbl_config_decode},
125 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
126 "Performance/Robustness", acpi_gbl_config_decode}
127};
128
129struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
130 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
131 "End-Dependent-Functions", NULL}
132};
133
134struct acpi_rsdump_info acpi_rs_dump_io[6] = {
135 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
136 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
137 acpi_gbl_io_decode},
138 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
139 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
140 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
141 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
142 NULL}
143};
144
145struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
146 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
147 "Fixed I/O", NULL},
148 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
149 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
150 "Address Length", NULL}
151};
152
153struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
154 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
155 "Vendor Specific", NULL},
156 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
157 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
158 NULL}
159};
160
161struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
162 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag",
163 NULL}
164};
165
166struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
167 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
168 "24-Bit Memory Range", NULL},
169 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
170 "Write Protect", acpi_gbl_RWdecode},
171 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
172 NULL},
173 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
174 NULL},
175 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
176 NULL},
177 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
178 "Address Length", NULL}
179};
180
181struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
182 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
183 "32-Bit Memory Range", NULL},
184 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
185 "Write Protect", acpi_gbl_RWdecode},
186 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
187 NULL},
188 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
189 NULL},
190 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
191 NULL},
192 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
193 "Address Length", NULL}
194};
195
196struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
197 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
198 "32-Bit Fixed Memory Range", NULL},
199 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
200 "Write Protect", acpi_gbl_RWdecode},
201 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
202 NULL},
203 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
204 "Address Length", NULL}
205};
206
207struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
208 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
209 "16-Bit WORD Address Space", NULL},
210 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
211 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
212 NULL},
213 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
214 NULL},
215 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
216 NULL},
217 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
218 "Translation Offset", NULL},
219 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
220 "Address Length", NULL},
221 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
222};
223
224struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
225 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
226 "32-Bit DWORD Address Space", NULL},
227 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
228 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
229 NULL},
230 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
231 NULL},
232 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
233 NULL},
234 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
235 "Translation Offset", NULL},
236 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
237 "Address Length", NULL},
238 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
239};
240
241struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
242 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
243 "64-Bit QWORD Address Space", NULL},
244 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
245 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
246 NULL},
247 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
248 NULL},
249 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
250 NULL},
251 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
252 "Translation Offset", NULL},
253 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
254 "Address Length", NULL},
255 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
256};
257
258struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
259 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
260 "64-Bit Extended Address Space", NULL},
261 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
262 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
263 "Granularity", NULL},
264 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
265 "Address Minimum", NULL},
266 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
267 "Address Maximum", NULL},
268 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
269 "Translation Offset", NULL},
270 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
271 "Address Length", NULL},
272 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
273 "Type-Specific Attribute", NULL}
274};
275
276struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
277 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
278 "Extended IRQ", NULL},
279 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
280 "Type", acpi_gbl_consume_decode},
281 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
282 "Triggering", acpi_gbl_HEdecode},
283 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
284 acpi_gbl_LLdecode},
285 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
286 acpi_gbl_SHRdecode},
287 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
288 NULL},
289 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
290 "Interrupt Count", NULL},
291 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
292 "Interrupt List", NULL}
293};
294
295struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
296 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
297 "Generic Register", NULL},
298 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
299 NULL},
300 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
301 NULL},
302 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
303 NULL},
304 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
305 "Access Size", NULL},
306 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
307};
93 308
94static void acpi_rs_out_integer8(char *title, u8 value) 309/*
95{ 310 * Tables used for common address descriptor flag fields
96 acpi_os_printf("%27s : %2.2X\n", title, value); 311 */
97} 312static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
98 313 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
99static void acpi_rs_out_integer16(char *title, u16 value) 314 NULL},
100{ 315 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
101 acpi_os_printf("%27s : %4.4X\n", title, value); 316 "Consumer/Producer", acpi_gbl_consume_decode},
102} 317 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
103 318 acpi_gbl_DECdecode},
104static void acpi_rs_out_integer32(char *title, u32 value) 319 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
105{ 320 "Min Relocatability", acpi_gbl_min_decode},
106 acpi_os_printf("%27s : %8.8X\n", title, value); 321 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
107} 322 "Max Relocatability", acpi_gbl_max_decode}
108 323};
109static void acpi_rs_out_integer64(char *title, u64 value) 324
110{ 325static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
111 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); 326 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
112} 327 "Resource Type", "Memory Range"},
328 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
329 "Write Protect", acpi_gbl_RWdecode},
330 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
331 "Caching", acpi_gbl_MEMdecode},
332 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
333 "Range Type", acpi_gbl_MTPdecode},
334 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
335 "Translation", acpi_gbl_TTPdecode}
336};
337
338static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
339 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
340 "Resource Type", "I/O Range"},
341 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
342 "Range Type", acpi_gbl_RNGdecode},
343 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
344 "Translation", acpi_gbl_TTPdecode},
345 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
346 "Translation Type", acpi_gbl_TRSdecode}
347};
113 348
114static void acpi_rs_out_title(char *title) 349/*
115{ 350 * Table used to dump _PRT contents
116 acpi_os_printf("%27s : ", title); 351 */
117} 352static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
353 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
354 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
355 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
356 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
357 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
358};
118 359
119/******************************************************************************* 360/*******************************************************************************
120 * 361 *
121 * FUNCTION: acpi_rs_dump*List 362 * FUNCTION: acpi_rs_dump_descriptor
122 * 363 *
123 * PARAMETERS: Length - Number of elements in the list 364 * PARAMETERS: Resource
124 * Data - Start of the list
125 * 365 *
126 * RETURN: None 366 * RETURN: None
127 * 367 *
128 * DESCRIPTION: Miscellaneous functions to dump lists of raw data 368 * DESCRIPTION:
129 * 369 *
130 ******************************************************************************/ 370 ******************************************************************************/
131 371
132static void acpi_rs_dump_byte_list(u32 length, u8 * data) 372static void
373acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
133{ 374{
134 u32 i; 375 void *target = NULL;
376 void *previous_target;
377 char *name;
378 u8 count;
379
380 /* First table entry must contain the table length (# of table entries) */
381
382 count = table->offset;
383
384 while (count) {
385 previous_target = target;
386 target = ((u8 *) resource) + table->offset;
387 name = table->name;
388
389 switch (table->opcode) {
390 case ACPI_RSD_TITLE:
391 /*
392 * Optional resource title
393 */
394 if (table->name) {
395 acpi_os_printf("%s Resource\n", name);
396 }
397 break;
135 398
136 for (i = 0; i < length; i++) { 399 /* Strings */
137 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
138 }
139}
140 400
141static void acpi_rs_dump_dword_list(u32 length, u32 * data) 401 case ACPI_RSD_LITERAL:
142{ 402 acpi_rs_out_string(name, (char *)table->pointer);
143 u32 i; 403 break;
144 404
145 for (i = 0; i < length; i++) { 405 case ACPI_RSD_STRING:
146 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); 406 acpi_rs_out_string(name, (char *)target);
147 } 407 break;
148}
149 408
150static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) 409 /* Data items, 8/16/32/64 bit */
151{
152 u32 i;
153 410
154 for (i = 0; i < length; i++) { 411 case ACPI_RSD_UINT8:
155 acpi_os_printf("%X ", data[i]); 412 acpi_rs_out_integer8(name, *(u8 *) target);
156 } 413 break;
157 acpi_os_printf("\n");
158}
159 414
160static void acpi_rs_dump_memory_attribute(u32 read_write_attribute) 415 case ACPI_RSD_UINT16:
161{ 416 acpi_rs_out_integer16(name, *(u16 *) target);
417 break;
418
419 case ACPI_RSD_UINT32:
420 acpi_rs_out_integer32(name, *(u32 *) target);
421 break;
162 422
163 acpi_rs_out_string("Read/Write Attribute", 423 case ACPI_RSD_UINT64:
164 ACPI_READ_WRITE_MEMORY == read_write_attribute ? 424 acpi_rs_out_integer64(name, *(u64 *) target);
165 "Read/Write" : "Read-Only"); 425 break;
426
427 /* Flags: 1-bit and 2-bit flags supported */
428
429 case ACPI_RSD_1BITFLAG:
430 acpi_rs_out_string(name, (char *)
431 ((const char **)table->
432 pointer)[(*(u8 *) target) & 0x01]);
433 break;
434
435 case ACPI_RSD_2BITFLAG:
436 acpi_rs_out_string(name, (char *)
437 ((const char **)table->
438 pointer)[(*(u8 *) target) & 0x03]);
439 break;
440
441 case ACPI_RSD_SHORTLIST:
442 /*
443 * Short byte list (single line output) for DMA and IRQ resources
444 * Note: The list length is obtained from the previous table entry
445 */
446 if (previous_target) {
447 acpi_rs_out_title(name);
448 acpi_rs_dump_short_byte_list(*
449 ((u8 *)
450 previous_target),
451 (u8 *) target);
452 }
453 break;
454
455 case ACPI_RSD_LONGLIST:
456 /*
457 * Long byte list for Vendor resource data
458 * Note: The list length is obtained from the previous table entry
459 */
460 if (previous_target) {
461 acpi_rs_dump_byte_list(*
462 ((u16 *)
463 previous_target),
464 (u8 *) target);
465 }
466 break;
467
468 case ACPI_RSD_DWORDLIST:
469 /*
470 * Dword list for Extended Interrupt resources
471 * Note: The list length is obtained from the previous table entry
472 */
473 if (previous_target) {
474 acpi_rs_dump_dword_list(*
475 ((u8 *)
476 previous_target),
477 (u32 *) target);
478 }
479 break;
480
481 case ACPI_RSD_ADDRESS:
482 /*
483 * Common flags for all Address resources
484 */
485 acpi_rs_dump_address_common((union acpi_resource_data *)
486 target);
487 break;
488
489 case ACPI_RSD_SOURCE:
490 /*
491 * Optional resource_source for Address resources
492 */
493 acpi_rs_dump_resource_source((struct
494 acpi_resource_source *)
495 target);
496 break;
497
498 default:
499 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
500 table->opcode);
501 return;
502 }
503
504 table++;
505 count--;
506 }
166} 507}
167 508
168/******************************************************************************* 509/*******************************************************************************
@@ -187,8 +528,7 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
187 return; 528 return;
188 } 529 }
189 530
190 acpi_rs_out_integer8("Resource Source Index", 531 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
191 (u8) resource_source->index);
192 532
193 acpi_rs_out_string("Resource Source", 533 acpi_rs_out_string("Resource Source",
194 resource_source->string_ptr ? 534 resource_source->string_ptr ?
@@ -217,65 +557,12 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
217 switch (resource->address.resource_type) { 557 switch (resource->address.resource_type) {
218 case ACPI_MEMORY_RANGE: 558 case ACPI_MEMORY_RANGE:
219 559
220 acpi_rs_out_string("Resource Type", "Memory Range"); 560 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
221
222 acpi_rs_out_title("Type-Specific Flags");
223
224 switch (resource->address.attribute.memory.cache_attribute) {
225 case ACPI_NON_CACHEABLE_MEMORY:
226 acpi_os_printf("Noncacheable memory\n");
227 break;
228
229 case ACPI_CACHABLE_MEMORY:
230 acpi_os_printf("Cacheable memory\n");
231 break;
232
233 case ACPI_WRITE_COMBINING_MEMORY:
234 acpi_os_printf("Write-combining memory\n");
235 break;
236
237 case ACPI_PREFETCHABLE_MEMORY:
238 acpi_os_printf("Prefetchable memory\n");
239 break;
240
241 default:
242 acpi_os_printf("Invalid cache attribute\n");
243 break;
244 }
245
246 acpi_rs_dump_memory_attribute(resource->address.attribute.
247 memory.read_write_attribute);
248 break; 561 break;
249 562
250 case ACPI_IO_RANGE: 563 case ACPI_IO_RANGE:
251 564
252 acpi_rs_out_string("Resource Type", "I/O Range"); 565 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
253
254 acpi_rs_out_title("Type-Specific Flags");
255
256 switch (resource->address.attribute.io.range_attribute) {
257 case ACPI_NON_ISA_ONLY_RANGES:
258 acpi_os_printf("Non-ISA I/O Addresses\n");
259 break;
260
261 case ACPI_ISA_ONLY_RANGES:
262 acpi_os_printf("ISA I/O Addresses\n");
263 break;
264
265 case ACPI_ENTIRE_RANGE:
266 acpi_os_printf("ISA and non-ISA I/O Addresses\n");
267 break;
268
269 default:
270 acpi_os_printf("Invalid range attribute\n");
271 break;
272 }
273
274 acpi_rs_out_string("Translation Attribute",
275 ACPI_SPARSE_TRANSLATION ==
276 resource->address.attribute.io.
277 translation_attribute ? "Sparse Translation"
278 : "Dense Translation");
279 break; 566 break;
280 567
281 case ACPI_BUS_NUMBER_RANGE: 568 case ACPI_BUS_NUMBER_RANGE:
@@ -292,24 +579,7 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
292 579
293 /* Decode the general flags */ 580 /* Decode the general flags */
294 581
295 acpi_rs_out_string("Resource", 582 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
296 ACPI_CONSUMER ==
297 resource->address.
298 producer_consumer ? "Consumer" : "Producer");
299
300 acpi_rs_out_string("Decode",
301 ACPI_SUB_DECODE == resource->address.decode ?
302 "Subtractive" : "Positive");
303
304 acpi_rs_out_string("Min Address",
305 ACPI_ADDRESS_FIXED ==
306 resource->address.
307 min_address_fixed ? "Fixed" : "Not Fixed");
308
309 acpi_rs_out_string("Max Address",
310 ACPI_ADDRESS_FIXED ==
311 resource->address.
312 max_address_fixed ? "Fixed" : "Not Fixed");
313} 583}
314 584
315/******************************************************************************* 585/*******************************************************************************
@@ -327,6 +597,7 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
327void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) 597void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
328{ 598{
329 u32 count = 0; 599 u32 count = 0;
600 u32 type;
330 601
331 ACPI_FUNCTION_ENTRY(); 602 ACPI_FUNCTION_ENTRY();
332 603
@@ -335,14 +606,16 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
335 return; 606 return;
336 } 607 }
337 608
338 /* Dump all resource descriptors in the list */ 609 /* Walk list and dump all resource descriptors (END_TAG terminates) */
339 610
340 while (resource_list) { 611 do {
341 acpi_os_printf("\n[%02X] ", count); 612 acpi_os_printf("\n[%02X] ", count);
613 count++;
342 614
343 /* Validate Type before dispatch */ 615 /* Validate Type before dispatch */
344 616
345 if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) { 617 type = resource_list->type;
618 if (type > ACPI_RESOURCE_TYPE_MAX) {
346 acpi_os_printf 619 acpi_os_printf
347 ("Invalid descriptor type (%X) in resource list\n", 620 ("Invalid descriptor type (%X) in resource list\n",
348 resource_list->type); 621 resource_list->type);
@@ -351,665 +624,141 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
351 624
352 /* Dump the resource descriptor */ 625 /* Dump the resource descriptor */
353 626
354 acpi_gbl_dump_resource_dispatch[resource_list-> 627 acpi_rs_dump_descriptor(&resource_list->data,
355 type] (&resource_list->data); 628 acpi_gbl_dump_resource_dispatch[type]);
356
357 /* Exit on end tag */
358
359 if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) {
360 return;
361 }
362 629
363 /* Get the next resource structure */ 630 /* Point to the next resource structure */
364 631
365 resource_list = 632 resource_list =
366 ACPI_PTR_ADD(struct acpi_resource, resource_list, 633 ACPI_PTR_ADD(struct acpi_resource, resource_list,
367 resource_list->length); 634 resource_list->length);
368 count++;
369 }
370}
371 635
372/******************************************************************************* 636 /* Exit when END_TAG descriptor is reached */
373 *
374 * FUNCTION: acpi_rs_dump_irq
375 *
376 * PARAMETERS: Resource - Pointer to an internal resource descriptor
377 *
378 * RETURN: None
379 *
380 * DESCRIPTION: Dump the field names and values of the resource descriptor
381 *
382 ******************************************************************************/
383 637
384void acpi_rs_dump_irq(union acpi_resource_data *resource) 638 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
385{
386 ACPI_FUNCTION_ENTRY();
387
388 acpi_os_printf("IRQ Resource\n");
389
390 acpi_rs_out_string("Triggering",
391 ACPI_LEVEL_SENSITIVE ==
392 resource->irq.triggering ? "Level" : "Edge");
393
394 acpi_rs_out_string("Active",
395 ACPI_ACTIVE_LOW ==
396 resource->irq.polarity ? "Low" : "High");
397
398 acpi_rs_out_string("Sharing",
399 ACPI_SHARED ==
400 resource->irq.sharable ? "Shared" : "Exclusive");
401
402 acpi_rs_out_integer8("Interrupt Count",
403 (u8) resource->irq.interrupt_count);
404
405 acpi_rs_out_title("Interrupt List");
406 acpi_rs_dump_short_byte_list(resource->irq.interrupt_count,
407 resource->irq.interrupts);
408} 639}
409 640
410/******************************************************************************* 641/*******************************************************************************
411 * 642 *
412 * FUNCTION: acpi_rs_dump_dma 643 * FUNCTION: acpi_rs_dump_irq_list
413 * 644 *
414 * PARAMETERS: Resource - Pointer to an internal resource descriptor 645 * PARAMETERS: route_table - Pointer to the routing table to dump.
415 * 646 *
416 * RETURN: None 647 * RETURN: None
417 * 648 *
418 * DESCRIPTION: Dump the field names and values of the resource descriptor 649 * DESCRIPTION: Print IRQ routing table
419 * 650 *
420 ******************************************************************************/ 651 ******************************************************************************/
421 652
422void acpi_rs_dump_dma(union acpi_resource_data *resource) 653void acpi_rs_dump_irq_list(u8 * route_table)
423{ 654{
424 ACPI_FUNCTION_ENTRY(); 655 struct acpi_pci_routing_table *prt_element;
425 656 u8 count;
426 acpi_os_printf("DMA Resource\n");
427
428 acpi_rs_out_title("DMA Type");
429 switch (resource->dma.type) {
430 case ACPI_COMPATIBILITY:
431 acpi_os_printf("Compatibility mode\n");
432 break;
433
434 case ACPI_TYPE_A:
435 acpi_os_printf("Type A\n");
436 break;
437
438 case ACPI_TYPE_B:
439 acpi_os_printf("Type B\n");
440 break;
441
442 case ACPI_TYPE_F:
443 acpi_os_printf("Type F\n");
444 break;
445
446 default:
447 acpi_os_printf("**** Invalid DMA type\n");
448 break;
449 }
450
451 acpi_rs_out_string("Bus Master",
452 ACPI_BUS_MASTER ==
453 resource->dma.bus_master ? "Yes" : "No");
454
455 acpi_rs_out_title("Transfer Type");
456 switch (resource->dma.transfer) {
457 case ACPI_TRANSFER_8:
458 acpi_os_printf("8-bit transfers only\n");
459 break;
460
461 case ACPI_TRANSFER_8_16:
462 acpi_os_printf("8-bit and 16-bit transfers\n");
463 break;
464
465 case ACPI_TRANSFER_16:
466 acpi_os_printf("16-bit transfers only\n");
467 break;
468
469 default:
470 acpi_os_printf("**** Invalid transfer preference\n");
471 break;
472 }
473
474 acpi_rs_out_integer8("DMA Channel Count",
475 (u8) resource->dma.channel_count);
476
477 acpi_rs_out_title("Channel List");
478 acpi_rs_dump_short_byte_list(resource->dma.channel_count,
479 resource->dma.channels);
480}
481
482/*******************************************************************************
483 *
484 * FUNCTION: acpi_rs_dump_start_dpf
485 *
486 * PARAMETERS: Resource - Pointer to an internal resource descriptor
487 *
488 * RETURN: None
489 *
490 * DESCRIPTION: Dump the field names and values of the resource descriptor
491 *
492 ******************************************************************************/
493 657
494void acpi_rs_dump_start_dpf(union acpi_resource_data *resource)
495{
496 ACPI_FUNCTION_ENTRY(); 658 ACPI_FUNCTION_ENTRY();
497 659
498 acpi_os_printf("Start Dependent Functions Resource\n"); 660 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
499 661 || !(_COMPONENT & acpi_dbg_layer)) {
500 acpi_rs_out_title("Compatibility Priority"); 662 return;
501 switch (resource->start_dpf.compatibility_priority) {
502 case ACPI_GOOD_CONFIGURATION:
503 acpi_os_printf("Good configuration\n");
504 break;
505
506 case ACPI_ACCEPTABLE_CONFIGURATION:
507 acpi_os_printf("Acceptable configuration\n");
508 break;
509
510 case ACPI_SUB_OPTIMAL_CONFIGURATION:
511 acpi_os_printf("Sub-optimal configuration\n");
512 break;
513
514 default:
515 acpi_os_printf("**** Invalid compatibility priority\n");
516 break;
517 } 663 }
518 664
519 acpi_rs_out_title("Performance/Robustness"); 665 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
520 switch (resource->start_dpf.performance_robustness) {
521 case ACPI_GOOD_CONFIGURATION:
522 acpi_os_printf("Good configuration\n");
523 break;
524 666
525 case ACPI_ACCEPTABLE_CONFIGURATION: 667 /* Dump all table elements, Exit on zero length element */
526 acpi_os_printf("Acceptable configuration\n");
527 break;
528 668
529 case ACPI_SUB_OPTIMAL_CONFIGURATION: 669 for (count = 0; prt_element->length; count++) {
530 acpi_os_printf("Sub-optimal configuration\n"); 670 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
531 break; 671 count);
672 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
532 673
533 default: 674 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table,
534 acpi_os_printf 675 ((u8 *) prt_element) +
535 ("**** Invalid performance robustness preference\n"); 676 prt_element->length);
536 break;
537 } 677 }
538} 678}
539 679
540/******************************************************************************* 680/*******************************************************************************
541 * 681 *
542 * FUNCTION: acpi_rs_dump_io 682 * FUNCTION: acpi_rs_out*
543 *
544 * PARAMETERS: Resource - Pointer to an internal resource descriptor
545 *
546 * RETURN: None
547 *
548 * DESCRIPTION: Dump the field names and values of the resource descriptor
549 *
550 ******************************************************************************/
551
552void acpi_rs_dump_io(union acpi_resource_data *resource)
553{
554 ACPI_FUNCTION_ENTRY();
555
556 acpi_os_printf("I/O Resource\n");
557
558 acpi_rs_out_string("Decode",
559 ACPI_DECODE_16 ==
560 resource->io.io_decode ? "16-bit" : "10-bit");
561
562 acpi_rs_out_integer32("Address Minimum", resource->io.minimum);
563
564 acpi_rs_out_integer32("Address Maximum", resource->io.maximum);
565
566 acpi_rs_out_integer32("Alignment", resource->io.alignment);
567
568 acpi_rs_out_integer32("Address Length", resource->io.address_length);
569}
570
571/*******************************************************************************
572 *
573 * FUNCTION: acpi_rs_dump_fixed_io
574 *
575 * PARAMETERS: Resource - Pointer to an internal resource descriptor
576 *
577 * RETURN: None
578 *
579 * DESCRIPTION: Dump the field names and values of the resource descriptor
580 *
581 ******************************************************************************/
582
583void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
584{
585 ACPI_FUNCTION_ENTRY();
586
587 acpi_os_printf("Fixed I/O Resource\n");
588
589 acpi_rs_out_integer32("Address", resource->fixed_io.address);
590
591 acpi_rs_out_integer32("Address Length",
592 resource->fixed_io.address_length);
593}
594
595/*******************************************************************************
596 *
597 * FUNCTION: acpi_rs_dump_vendor
598 *
599 * PARAMETERS: Resource - Pointer to an internal resource descriptor
600 *
601 * RETURN: None
602 *
603 * DESCRIPTION: Dump the field names and values of the resource descriptor
604 *
605 ******************************************************************************/
606
607void acpi_rs_dump_vendor(union acpi_resource_data *resource)
608{
609 ACPI_FUNCTION_ENTRY();
610
611 acpi_os_printf("Vendor Specific Resource\n");
612
613 acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length);
614
615 acpi_rs_dump_byte_list(resource->vendor.byte_length,
616 resource->vendor.byte_data);
617}
618
619/*******************************************************************************
620 *
621 * FUNCTION: acpi_rs_dump_memory24
622 *
623 * PARAMETERS: Resource - Pointer to an internal resource descriptor
624 *
625 * RETURN: None
626 *
627 * DESCRIPTION: Dump the field names and values of the resource descriptor
628 *
629 ******************************************************************************/
630
631void acpi_rs_dump_memory24(union acpi_resource_data *resource)
632{
633 ACPI_FUNCTION_ENTRY();
634
635 acpi_os_printf("24-Bit Memory Range Resource\n");
636
637 acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute);
638
639 acpi_rs_out_integer16("Address Minimum",
640 (u16) resource->memory24.minimum);
641
642 acpi_rs_out_integer16("Address Maximum",
643 (u16) resource->memory24.maximum);
644
645 acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment);
646
647 acpi_rs_out_integer16("Address Length",
648 (u16) resource->memory24.address_length);
649}
650
651/*******************************************************************************
652 *
653 * FUNCTION: acpi_rs_dump_memory32
654 *
655 * PARAMETERS: Resource - Pointer to an internal resource descriptor
656 *
657 * RETURN: None
658 *
659 * DESCRIPTION: Dump the field names and values of the resource descriptor
660 *
661 ******************************************************************************/
662
663void acpi_rs_dump_memory32(union acpi_resource_data *resource)
664{
665 ACPI_FUNCTION_ENTRY();
666
667 acpi_os_printf("32-Bit Memory Range Resource\n");
668
669 acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute);
670
671 acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum);
672
673 acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum);
674
675 acpi_rs_out_integer32("Alignment", resource->memory32.alignment);
676
677 acpi_rs_out_integer32("Address Length",
678 resource->memory32.address_length);
679}
680
681/*******************************************************************************
682 *
683 * FUNCTION: acpi_rs_dump_fixed_memory32
684 *
685 * PARAMETERS: Resource - Pointer to an internal resource descriptor
686 *
687 * RETURN:
688 *
689 * DESCRIPTION: Dump the field names and values of the resource descriptor
690 *
691 ******************************************************************************/
692
693void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
694{
695 ACPI_FUNCTION_ENTRY();
696
697 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
698
699 acpi_rs_dump_memory_attribute(resource->fixed_memory32.
700 read_write_attribute);
701
702 acpi_rs_out_integer32("Address", resource->fixed_memory32.address);
703
704 acpi_rs_out_integer32("Address Length",
705 resource->fixed_memory32.address_length);
706}
707
708/*******************************************************************************
709 *
710 * FUNCTION: acpi_rs_dump_address16
711 * 683 *
712 * PARAMETERS: Resource - Pointer to an internal resource descriptor 684 * PARAMETERS: Title - Name of the resource field
685 * Value - Value of the resource field
713 * 686 *
714 * RETURN: None 687 * RETURN: None
715 * 688 *
716 * DESCRIPTION: Dump the field names and values of the resource descriptor 689 * DESCRIPTION: Miscellaneous helper functions to consistently format the
690 * output of the resource dump routines
717 * 691 *
718 ******************************************************************************/ 692 ******************************************************************************/
719 693
720void acpi_rs_dump_address16(union acpi_resource_data *resource) 694static void acpi_rs_out_string(char *title, char *value)
721{ 695{
722 ACPI_FUNCTION_ENTRY(); 696 acpi_os_printf("%27s : %s\n", title, value);
723
724 acpi_os_printf("16-Bit WORD Address Space Resource\n");
725
726 acpi_rs_dump_address_common(resource);
727
728 acpi_rs_out_integer16("Granularity",
729 (u16) resource->address16.granularity);
730
731 acpi_rs_out_integer16("Address Minimum",
732 (u16) resource->address16.minimum);
733
734 acpi_rs_out_integer16("Address Maximum",
735 (u16) resource->address16.maximum);
736
737 acpi_rs_out_integer16("Translation Offset",
738 (u16) resource->address16.translation_offset);
739
740 acpi_rs_out_integer16("Address Length",
741 (u16) resource->address16.address_length);
742
743 acpi_rs_dump_resource_source(&resource->address16.resource_source);
744} 697}
745 698
746/******************************************************************************* 699static void acpi_rs_out_integer8(char *title, u8 value)
747 *
748 * FUNCTION: acpi_rs_dump_address32
749 *
750 * PARAMETERS: Resource - Pointer to an internal resource descriptor
751 *
752 * RETURN: None
753 *
754 * DESCRIPTION: Dump the field names and values of the resource descriptor
755 *
756 ******************************************************************************/
757
758void acpi_rs_dump_address32(union acpi_resource_data *resource)
759{ 700{
760 ACPI_FUNCTION_ENTRY(); 701 acpi_os_printf("%27s : %2.2X\n", title, value);
761
762 acpi_os_printf("32-Bit DWORD Address Space Resource\n");
763
764 acpi_rs_dump_address_common(resource);
765
766 acpi_rs_out_integer32("Granularity", resource->address32.granularity);
767
768 acpi_rs_out_integer32("Address Minimum", resource->address32.minimum);
769
770 acpi_rs_out_integer32("Address Maximum", resource->address32.maximum);
771
772 acpi_rs_out_integer32("Translation Offset",
773 resource->address32.translation_offset);
774
775 acpi_rs_out_integer32("Address Length",
776 resource->address32.address_length);
777
778 acpi_rs_dump_resource_source(&resource->address32.resource_source);
779} 702}
780 703
781/******************************************************************************* 704static void acpi_rs_out_integer16(char *title, u16 value)
782 *
783 * FUNCTION: acpi_rs_dump_address64
784 *
785 * PARAMETERS: Resource - Pointer to an internal resource descriptor
786 *
787 * RETURN: None
788 *
789 * DESCRIPTION: Dump the field names and values of the resource descriptor
790 *
791 ******************************************************************************/
792
793void acpi_rs_dump_address64(union acpi_resource_data *resource)
794{ 705{
795 ACPI_FUNCTION_ENTRY(); 706 acpi_os_printf("%27s : %4.4X\n", title, value);
796
797 acpi_os_printf("64-Bit QWORD Address Space Resource\n");
798
799 acpi_rs_dump_address_common(resource);
800
801 acpi_rs_out_integer64("Granularity", resource->address64.granularity);
802
803 acpi_rs_out_integer64("Address Minimum", resource->address64.minimum);
804
805 acpi_rs_out_integer64("Address Maximum", resource->address64.maximum);
806
807 acpi_rs_out_integer64("Translation Offset",
808 resource->address64.translation_offset);
809
810 acpi_rs_out_integer64("Address Length",
811 resource->address64.address_length);
812
813 acpi_rs_dump_resource_source(&resource->address64.resource_source);
814} 707}
815 708
816/******************************************************************************* 709static void acpi_rs_out_integer32(char *title, u32 value)
817 *
818 * FUNCTION: acpi_rs_dump_ext_address64
819 *
820 * PARAMETERS: Resource - Pointer to an internal resource descriptor
821 *
822 * RETURN: None
823 *
824 * DESCRIPTION: Dump the field names and values of the resource descriptor
825 *
826 ******************************************************************************/
827
828void acpi_rs_dump_ext_address64(union acpi_resource_data *resource)
829{ 710{
830 ACPI_FUNCTION_ENTRY(); 711 acpi_os_printf("%27s : %8.8X\n", title, value);
831
832 acpi_os_printf("64-Bit Extended Address Space Resource\n");
833
834 acpi_rs_dump_address_common(resource);
835
836 acpi_rs_out_integer64("Granularity",
837 resource->ext_address64.granularity);
838
839 acpi_rs_out_integer64("Address Minimum",
840 resource->ext_address64.minimum);
841
842 acpi_rs_out_integer64("Address Maximum",
843 resource->ext_address64.maximum);
844
845 acpi_rs_out_integer64("Translation Offset",
846 resource->ext_address64.translation_offset);
847
848 acpi_rs_out_integer64("Address Length",
849 resource->ext_address64.address_length);
850
851 acpi_rs_out_integer64("Type-Specific Attribute",
852 resource->ext_address64.type_specific_attributes);
853} 712}
854 713
855/******************************************************************************* 714static void acpi_rs_out_integer64(char *title, u64 value)
856 *
857 * FUNCTION: acpi_rs_dump_ext_irq
858 *
859 * PARAMETERS: Resource - Pointer to an internal resource descriptor
860 *
861 * RETURN: None
862 *
863 * DESCRIPTION: Dump the field names and values of the resource descriptor
864 *
865 ******************************************************************************/
866
867void acpi_rs_dump_ext_irq(union acpi_resource_data *resource)
868{ 715{
869 ACPI_FUNCTION_ENTRY(); 716 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
870
871 acpi_os_printf("Extended IRQ Resource\n");
872
873 acpi_rs_out_string("Resource",
874 ACPI_CONSUMER ==
875 resource->extended_irq.
876 producer_consumer ? "Consumer" : "Producer");
877
878 acpi_rs_out_string("Triggering",
879 ACPI_LEVEL_SENSITIVE ==
880 resource->extended_irq.
881 triggering ? "Level" : "Edge");
882
883 acpi_rs_out_string("Active",
884 ACPI_ACTIVE_LOW == resource->extended_irq.polarity ?
885 "Low" : "High");
886
887 acpi_rs_out_string("Sharing",
888 ACPI_SHARED == resource->extended_irq.sharable ?
889 "Shared" : "Exclusive");
890
891 acpi_rs_dump_resource_source(&resource->extended_irq.resource_source);
892
893 acpi_rs_out_integer8("Interrupts",
894 (u8) resource->extended_irq.interrupt_count);
895
896 acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count,
897 resource->extended_irq.interrupts);
898} 717}
899 718
900/******************************************************************************* 719static void acpi_rs_out_title(char *title)
901 *
902 * FUNCTION: acpi_rs_dump_generic_reg
903 *
904 * PARAMETERS: Resource - Pointer to an internal resource descriptor
905 *
906 * RETURN: None
907 *
908 * DESCRIPTION: Dump the field names and values of the resource descriptor
909 *
910 ******************************************************************************/
911
912void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
913{ 720{
914 ACPI_FUNCTION_ENTRY(); 721 acpi_os_printf("%27s : ", title);
915
916 acpi_os_printf("Generic Register Resource\n");
917
918 acpi_rs_out_integer8("Space ID", (u8) resource->generic_reg.space_id);
919
920 acpi_rs_out_integer8("Bit Width", (u8) resource->generic_reg.bit_width);
921
922 acpi_rs_out_integer8("Bit Offset",
923 (u8) resource->generic_reg.bit_offset);
924
925 acpi_rs_out_integer8("Access Size",
926 (u8) resource->generic_reg.access_size);
927
928 acpi_rs_out_integer64("Address", resource->generic_reg.address);
929} 722}
930 723
931/******************************************************************************* 724/*******************************************************************************
932 * 725 *
933 * FUNCTION: acpi_rs_dump_end_dpf 726 * FUNCTION: acpi_rs_dump*List
934 * 727 *
935 * PARAMETERS: Resource - Pointer to an internal resource descriptor 728 * PARAMETERS: Length - Number of elements in the list
729 * Data - Start of the list
936 * 730 *
937 * RETURN: None 731 * RETURN: None
938 * 732 *
939 * DESCRIPTION: Print type, no data. 733 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
940 * 734 *
941 ******************************************************************************/ 735 ******************************************************************************/
942 736
943void acpi_rs_dump_end_dpf(union acpi_resource_data *resource) 737static void acpi_rs_dump_byte_list(u16 length, u8 * data)
944{ 738{
945 ACPI_FUNCTION_ENTRY(); 739 u8 i;
946 740
947 acpi_os_printf("end_dependent_functions Resource\n"); 741 for (i = 0; i < length; i++) {
742 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
743 }
948} 744}
949 745
950/******************************************************************************* 746static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
951 *
952 * FUNCTION: acpi_rs_dump_end_tag
953 *
954 * PARAMETERS: Resource - Pointer to an internal resource descriptor
955 *
956 * RETURN: None
957 *
958 * DESCRIPTION: Print type, no data.
959 *
960 ******************************************************************************/
961
962void acpi_rs_dump_end_tag(union acpi_resource_data *resource)
963{ 747{
964 ACPI_FUNCTION_ENTRY(); 748 u8 i;
965 749
966 acpi_os_printf("end_tag Resource\n"); 750 for (i = 0; i < length; i++) {
751 acpi_os_printf("%X ", data[i]);
752 }
753 acpi_os_printf("\n");
967} 754}
968 755
969/******************************************************************************* 756static void acpi_rs_dump_dword_list(u8 length, u32 * data)
970 *
971 * FUNCTION: acpi_rs_dump_irq_list
972 *
973 * PARAMETERS: route_table - Pointer to the routing table to dump.
974 *
975 * RETURN: None
976 *
977 * DESCRIPTION: Print IRQ routing table
978 *
979 ******************************************************************************/
980
981void acpi_rs_dump_irq_list(u8 * route_table)
982{ 757{
983 u8 *buffer = route_table; 758 u8 i;
984 u8 count = 0;
985 struct acpi_pci_routing_table *prt_element;
986
987 ACPI_FUNCTION_ENTRY();
988 759
989 if (!(acpi_dbg_level & ACPI_LV_RESOURCES) 760 for (i = 0; i < length; i++) {
990 || !(_COMPONENT & acpi_dbg_layer)) { 761 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
991 return;
992 }
993
994 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
995
996 /* Dump all table elements, Exit on null length element */
997
998 while (prt_element->length) {
999 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
1000 count);
1001
1002 acpi_rs_out_integer64("Address", prt_element->address);
1003
1004 acpi_rs_out_integer32("Pin", prt_element->pin);
1005 acpi_rs_out_string("Source", prt_element->source);
1006 acpi_rs_out_integer32("Source Index",
1007 prt_element->source_index);
1008
1009 buffer += prt_element->length;
1010 prt_element =
1011 ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
1012 count++;
1013 } 762 }
1014} 763}
1015 764
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
index b31cb33ec565..973fc2834cbb 100644
--- a/drivers/acpi/resources/rsinfo.c
+++ b/drivers/acpi/resources/rsinfo.c
@@ -58,60 +58,60 @@ ACPI_MODULE_NAME("rsinfo")
58 * descriptors are indexed by the acpi_resource_type field. 58 * descriptors are indexed by the acpi_resource_type field.
59 */ 59 */
60/* Dispatch table for resource-to-AML (Set Resource) conversion functions */ 60/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
61ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[] = { 61struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
62 acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ 62 acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
63 acpi_rs_set_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ 63 acpi_rs_convert_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
64 acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ 64 acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
65 acpi_rs_set_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ 65 acpi_rs_convert_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
66 acpi_rs_set_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */ 66 acpi_rs_convert_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */
67 acpi_rs_set_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ 67 acpi_rs_convert_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
68 acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ 68 acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
69 acpi_rs_set_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ 69 acpi_rs_convert_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
70 acpi_rs_set_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ 70 acpi_rs_convert_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
71 acpi_rs_set_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ 71 acpi_rs_convert_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
72 acpi_rs_set_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ 72 acpi_rs_convert_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
73 acpi_rs_set_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ 73 acpi_rs_convert_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
74 acpi_rs_set_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ 74 acpi_rs_convert_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
75 acpi_rs_set_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ 75 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
76 acpi_rs_set_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 76 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
77 acpi_rs_set_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 77 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
78 acpi_rs_set_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 78 acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
79}; 79};
80 80
81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ 81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
82 82
83ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[] = { 83struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = {
84 NULL, /* 0x00, Reserved */ 84 NULL, /* 0x00, Reserved */
85 NULL, /* 0x01, Reserved */ 85 NULL, /* 0x01, Reserved */
86 NULL, /* 0x02, Reserved */ 86 NULL, /* 0x02, Reserved */
87 NULL, /* 0x03, Reserved */ 87 NULL, /* 0x03, Reserved */
88 acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ 88 acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
89 acpi_rs_get_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ 89 acpi_rs_convert_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
90 acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ 90 acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
91 acpi_rs_get_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ 91 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
92 acpi_rs_get_io, /* 0x08, ACPI_RESOURCE_NAME_IO */ 92 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
93 acpi_rs_get_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ 93 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
94 NULL, /* 0x0A, Reserved */ 94 NULL, /* 0x0A, Reserved */
95 NULL, /* 0x0B, Reserved */ 95 NULL, /* 0x0B, Reserved */
96 NULL, /* 0x0C, Reserved */ 96 NULL, /* 0x0C, Reserved */
97 NULL, /* 0x0D, Reserved */ 97 NULL, /* 0x0D, Reserved */
98 acpi_rs_get_vendor, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ 98 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
99 acpi_rs_get_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ 99 acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
100}; 100};
101 101
102ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = { 102struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = {
103 NULL, /* 0x00, Reserved */ 103 NULL, /* 0x00, Reserved */
104 acpi_rs_get_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ 104 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
105 acpi_rs_get_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ 105 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
106 NULL, /* 0x03, Reserved */ 106 NULL, /* 0x03, Reserved */
107 acpi_rs_get_vendor, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ 107 acpi_rs_get_vendor_large, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
108 acpi_rs_get_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ 108 acpi_rs_convert_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
109 acpi_rs_get_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ 109 acpi_rs_convert_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
110 acpi_rs_get_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ 110 acpi_rs_convert_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
111 acpi_rs_get_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ 111 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
112 acpi_rs_get_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ 112 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
113 acpi_rs_get_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ 113 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
114 acpi_rs_get_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ 114 acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
115}; 115};
116 116
117#ifdef ACPI_FUTURE_USAGE 117#ifdef ACPI_FUTURE_USAGE
@@ -119,7 +119,7 @@ ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = {
119 119
120/* Dispatch table for resource dump functions */ 120/* Dispatch table for resource dump functions */
121 121
122ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = { 122struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
123 acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */ 123 acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */
124 acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */ 124 acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */
125 acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ 125 acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
@@ -136,17 +136,17 @@ ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = {
136 acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ 136 acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
137 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 137 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
138 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 138 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
139 acpi_rs_dump_generic_reg /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 139 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
140}; 140};
141
141#endif 142#endif
142#endif /* ACPI_FUTURE_USAGE */ 143#endif /* ACPI_FUTURE_USAGE */
143
144/* 144/*
145 * Base sizes for external AML resource descriptors, indexed by internal type. 145 * Base sizes for external AML resource descriptors, indexed by internal type.
146 * Includes size of the descriptor header (1 byte for small descriptors, 146 * Includes size of the descriptor header (1 byte for small descriptors,
147 * 3 bytes for large descriptors) 147 * 3 bytes for large descriptors)
148 */ 148 */
149u8 acpi_gbl_aml_resource_sizes[] = { 149const u8 acpi_gbl_aml_resource_sizes[] = {
150 sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ 150 sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
151 sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */ 151 sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */
152 sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ 152 sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
@@ -168,8 +168,8 @@ u8 acpi_gbl_aml_resource_sizes[] = {
168 168
169/* Macros used in the tables below */ 169/* Macros used in the tables below */
170 170
171#define ACPI_RLARGE(r) sizeof (r) - sizeof (struct aml_resource_large_header) 171#define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
172#define ACPI_RSMALL(r) sizeof (r) - sizeof (struct aml_resource_small_header) 172#define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
173 173
174/* 174/*
175 * Base sizes of resource descriptors, both the AML stream resource length 175 * Base sizes of resource descriptors, both the AML stream resource length
@@ -182,47 +182,46 @@ struct acpi_resource_info acpi_gbl_sm_resource_info[] = {
182 {0, 0, 0}, 182 {0, 0, 0},
183 {0, 0, 0}, 183 {0, 0, 0},
184 {2, ACPI_RSMALL(struct aml_resource_irq), 184 {2, ACPI_RSMALL(struct aml_resource_irq),
185 ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, 185 ACPI_RS_SIZE(struct acpi_resource_irq)},
186 {0, ACPI_RSMALL(struct aml_resource_dma), 186 {0, ACPI_RSMALL(struct aml_resource_dma),
187 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, 187 ACPI_RS_SIZE(struct acpi_resource_dma)},
188 {2, ACPI_RSMALL(struct aml_resource_start_dependent), 188 {2, ACPI_RSMALL(struct aml_resource_start_dependent),
189 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent)}, 189 ACPI_RS_SIZE(struct acpi_resource_start_dependent)},
190 {0, ACPI_RSMALL(struct aml_resource_end_dependent), 190 {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN},
191 ACPI_RESOURCE_LENGTH},
192 {0, ACPI_RSMALL(struct aml_resource_io), 191 {0, ACPI_RSMALL(struct aml_resource_io),
193 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, 192 ACPI_RS_SIZE(struct acpi_resource_io)},
194 {0, ACPI_RSMALL(struct aml_resource_fixed_io), 193 {0, ACPI_RSMALL(struct aml_resource_fixed_io),
195 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, 194 ACPI_RS_SIZE(struct acpi_resource_fixed_io)},
196 {0, 0, 0}, 195 {0, 0, 0},
197 {0, 0, 0}, 196 {0, 0, 0},
198 {0, 0, 0}, 197 {0, 0, 0},
199 {0, 0, 0}, 198 {0, 0, 0},
200 {1, ACPI_RSMALL(struct aml_resource_vendor_small), 199 {1, ACPI_RSMALL(struct aml_resource_vendor_small),
201 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, 200 ACPI_RS_SIZE(struct acpi_resource_vendor)},
202 {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RESOURCE_LENGTH} 201 {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN}
203}; 202};
204 203
205struct acpi_resource_info acpi_gbl_lg_resource_info[] = { 204struct acpi_resource_info acpi_gbl_lg_resource_info[] = {
206 {0, 0, 0}, 205 {0, 0, 0},
207 {0, ACPI_RLARGE(struct aml_resource_memory24), 206 {0, ACPI_RLARGE(struct aml_resource_memory24),
208 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, 207 ACPI_RS_SIZE(struct acpi_resource_memory24)},
209 {0, ACPI_RLARGE(struct aml_resource_generic_register), 208 {0, ACPI_RLARGE(struct aml_resource_generic_register),
210 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)}, 209 ACPI_RS_SIZE(struct acpi_resource_generic_register)},
211 {0, 0, 0}, 210 {0, 0, 0},
212 {1, ACPI_RLARGE(struct aml_resource_vendor_large), 211 {1, ACPI_RLARGE(struct aml_resource_vendor_large),
213 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, 212 ACPI_RS_SIZE(struct acpi_resource_vendor)},
214 {0, ACPI_RLARGE(struct aml_resource_memory32), 213 {0, ACPI_RLARGE(struct aml_resource_memory32),
215 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32)}, 214 ACPI_RS_SIZE(struct acpi_resource_memory32)},
216 {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), 215 {0, ACPI_RLARGE(struct aml_resource_fixed_memory32),
217 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32)}, 216 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)},
218 {1, ACPI_RLARGE(struct aml_resource_address32), 217 {1, ACPI_RLARGE(struct aml_resource_address32),
219 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, 218 ACPI_RS_SIZE(struct acpi_resource_address32)},
220 {1, ACPI_RLARGE(struct aml_resource_address16), 219 {1, ACPI_RLARGE(struct aml_resource_address16),
221 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, 220 ACPI_RS_SIZE(struct acpi_resource_address16)},
222 {1, ACPI_RLARGE(struct aml_resource_extended_irq), 221 {1, ACPI_RLARGE(struct aml_resource_extended_irq),
223 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq)}, 222 ACPI_RS_SIZE(struct acpi_resource_extended_irq)},
224 {1, ACPI_RLARGE(struct aml_resource_address64), 223 {1, ACPI_RLARGE(struct aml_resource_address64),
225 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, 224 ACPI_RS_SIZE(struct acpi_resource_address64)},
226 {0, ACPI_RLARGE(struct aml_resource_extended_address64), 225 {0, ACPI_RLARGE(struct aml_resource_extended_address64),
227 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64)} 226 ACPI_RS_SIZE(struct acpi_resource_extended_address64)}
228}; 227};
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index 0dab8cdfa800..ef24ba110c6e 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -49,269 +49,206 @@ ACPI_MODULE_NAME("rsio")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_get_io 52 * acpi_rs_convert_io
53 *
54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
63 * 53 *
64 ******************************************************************************/ 54 ******************************************************************************/
65acpi_status 55struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
66acpi_rs_get_io(union aml_resource *aml, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
67 u16 aml_resource_length, struct acpi_resource *resource) 57 ACPI_RS_SIZE(struct acpi_resource_io),
68{ 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
69 ACPI_FUNCTION_TRACE("rs_get_io");
70 59
71 /* Get the Decode flag */ 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
61 sizeof(struct aml_resource_io),
62 0},
72 63
73 resource->data.io.io_decode = aml->io.information & 0x01; 64 /* Decode flag */
74 65
66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
67 AML_OFFSET(io.flags),
68 0},
75 /* 69 /*
76 * Get the following contiguous fields from the AML descriptor: 70 * These fields are contiguous in both the source and destination:
77 * Minimum Base Address
78 * Maximum Base Address
79 * Address Alignment 71 * Address Alignment
80 * Length 72 * Length
73 * Minimum Base Address
74 * Maximum Base Address
81 */ 75 */
82 ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); 76 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
83 ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); 77 AML_OFFSET(io.alignment),
84 resource->data.io.alignment = aml->io.alignment; 78 2},
85 resource->data.io.address_length = aml->io.address_length;
86
87 /* Complete the resource header */
88 79
89 resource->type = ACPI_RESOURCE_TYPE_IO; 80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
90 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); 81 AML_OFFSET(io.minimum),
91 return_ACPI_STATUS(AE_OK); 82 2}
92} 83};
93 84
94/******************************************************************************* 85/*******************************************************************************
95 * 86 *
96 * FUNCTION: acpi_rs_set_io 87 * acpi_rs_convert_fixed_io
97 *
98 * PARAMETERS: Resource - Pointer to the resource descriptor
99 * Aml - Where the AML descriptor is returned
100 *
101 * RETURN: Status
102 *
103 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
104 * external AML resource descriptor.
105 * 88 *
106 ******************************************************************************/ 89 ******************************************************************************/
107 90
108acpi_status 91struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
109acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) 92 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
110{ 93 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
111 ACPI_FUNCTION_TRACE("rs_set_io"); 94 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
112
113 /* I/O Information Byte */
114
115 aml->io.information = (u8) (resource->data.io.io_decode & 0x01);
116 95
96 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
97 sizeof(struct aml_resource_fixed_io),
98 0},
117 /* 99 /*
118 * Set the following contiguous fields in the AML descriptor: 100 * These fields are contiguous in both the source and destination:
119 * Minimum Base Address 101 * Base Address
120 * Maximum Base Address
121 * Address Alignment
122 * Length 102 * Length
123 */ 103 */
124 ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); 104 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
125 ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); 105 AML_OFFSET(fixed_io.address_length),
126 aml->io.alignment = (u8) resource->data.io.alignment; 106 1},
127 aml->io.address_length = (u8) resource->data.io.address_length;
128
129 /* Complete the AML descriptor header */
130 107
131 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, 108 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
132 sizeof(struct aml_resource_io), aml); 109 AML_OFFSET(fixed_io.address),
133 return_ACPI_STATUS(AE_OK); 110 1}
134} 111};
135 112
136/******************************************************************************* 113/*******************************************************************************
137 * 114 *
138 * FUNCTION: acpi_rs_get_fixed_io 115 * acpi_rs_convert_generic_reg
139 *
140 * PARAMETERS: Aml - Pointer to the AML resource descriptor
141 * aml_resource_length - Length of the resource from the AML header
142 * Resource - Where the internal resource is returned
143 *
144 * RETURN: Status
145 *
146 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
147 * internal resource descriptor, simplifying bitflags and handling
148 * alignment and endian issues if necessary.
149 * 116 *
150 ******************************************************************************/ 117 ******************************************************************************/
151 118
152acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
153acpi_rs_get_fixed_io(union aml_resource *aml, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
154 u16 aml_resource_length, struct acpi_resource *resource) 121 ACPI_RS_SIZE(struct acpi_resource_generic_register),
155{ 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
156 ACPI_FUNCTION_TRACE("rs_get_fixed_io");
157 123
124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
125 sizeof(struct aml_resource_generic_register),
126 0},
158 /* 127 /*
159 * Get the following contiguous fields from the AML descriptor: 128 * These fields are contiguous in both the source and destination:
160 * Base Address 129 * Address Space ID
161 * Length 130 * Register Bit Width
131 * Register Bit Offset
132 * Access Size
162 */ 133 */
163 ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, 134 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
164 &aml->fixed_io.address); 135 AML_OFFSET(generic_reg.address_space_id),
165 resource->data.fixed_io.address_length = aml->fixed_io.address_length; 136 4},
166 137
167 /* Complete the resource header */ 138 /* Get the Register Address */
168 139
169 resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; 140 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
170 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 141 AML_OFFSET(generic_reg.address),
171 return_ACPI_STATUS(AE_OK); 142 1}
172} 143};
173 144
174/******************************************************************************* 145/*******************************************************************************
175 * 146 *
176 * FUNCTION: acpi_rs_set_fixed_io 147 * acpi_rs_convert_end_dpf
177 *
178 * PARAMETERS: Resource - Pointer to the resource descriptor
179 * Aml - Where the AML descriptor is returned
180 * 148 *
181 * RETURN: Status 149 ******************************************************************************/
150
151struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
152 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
153 ACPI_RS_SIZE_MIN,
154 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
155
156 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
157 sizeof(struct aml_resource_end_dependent),
158 0}
159};
160
161/*******************************************************************************
182 * 162 *
183 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 163 * acpi_rs_convert_end_tag
184 * external AML resource descriptor.
185 * 164 *
186 ******************************************************************************/ 165 ******************************************************************************/
187 166
188acpi_status 167struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
189acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) 168 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
190{ 169 ACPI_RS_SIZE_MIN,
191 ACPI_FUNCTION_TRACE("rs_set_fixed_io"); 170 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
192 171
193 /* 172 /*
194 * Set the following contiguous fields in the AML descriptor: 173 * Note: The checksum field is set to zero, meaning that the resource
195 * Base Address 174 * data is treated as if the checksum operation succeeded.
196 * Length 175 * (ACPI Spec 1.0b Section 6.4.2.8)
197 */ 176 */
198 ACPI_MOVE_32_TO_16(&aml->fixed_io.address, 177 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
199 &resource->data.fixed_io.address); 178 sizeof(struct aml_resource_end_tag),
200 aml->fixed_io.address_length = 179 0}
201 (u8) resource->data.fixed_io.address_length; 180};
202
203 /* Complete the AML descriptor header */
204
205 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO,
206 sizeof(struct aml_resource_fixed_io), aml);
207 return_ACPI_STATUS(AE_OK);
208}
209 181
210/******************************************************************************* 182/*******************************************************************************
211 * 183 *
212 * FUNCTION: acpi_rs_get_dma 184 * acpi_rs_get_start_dpf
213 *
214 * PARAMETERS: Aml - Pointer to the AML resource descriptor
215 * aml_resource_length - Length of the resource from the AML header
216 * Resource - Where the internal resource is returned
217 *
218 * RETURN: Status
219 *
220 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
221 * internal resource descriptor, simplifying bitflags and handling
222 * alignment and endian issues if necessary.
223 * 185 *
224 ******************************************************************************/ 186 ******************************************************************************/
225 187
226acpi_status 188struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = {
227acpi_rs_get_dma(union aml_resource *aml, 189 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
228 u16 aml_resource_length, struct acpi_resource *resource) 190 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
229{ 191 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
230 u32 channel_count = 0;
231 u32 i;
232 u8 temp8;
233 192
234 ACPI_FUNCTION_TRACE("rs_get_dma"); 193 /* Defaults for Compatibility and Performance priorities */
235 194
236 /* Decode the DMA channel bits */ 195 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
196 ACPI_ACCEPTABLE_CONFIGURATION,
197 2},
237 198
238 for (i = 0; i < 8; i++) { 199 /* All done if there is no flag byte present in the descriptor */
239 if ((aml->dma.dma_channel_mask >> i) & 0x01) {
240 resource->data.dma.channels[channel_count] = i;
241 channel_count++;
242 }
243 }
244 200
245 resource->length = 0; 201 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
246 resource->data.dma.channel_count = channel_count;
247 202
248 /* 203 /* Flag byte is present, get the flags */
249 * Calculate the structure size based upon the number of channels
250 * Note: Zero DMA channels is valid
251 */
252 if (channel_count > 0) {
253 resource->length = (u32) (channel_count - 1) * 4;
254 }
255
256 /* Get the flags: transfer preference, bus mastering, channel speed */
257 204
258 temp8 = aml->dma.flags; 205 {ACPI_RSC_2BITFLAG,
259 resource->data.dma.transfer = temp8 & 0x03; 206 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
260 resource->data.dma.bus_master = (temp8 >> 2) & 0x01; 207 AML_OFFSET(start_dpf.flags),
261 resource->data.dma.type = (temp8 >> 5) & 0x03; 208 0},
262 209
263 if (resource->data.dma.transfer == 0x03) { 210 {ACPI_RSC_2BITFLAG,
264 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 211 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
265 "Invalid DMA.Transfer preference (3)\n")); 212 AML_OFFSET(start_dpf.flags),
266 return_ACPI_STATUS(AE_BAD_DATA); 213 2}
267 } 214};
268
269 /* Complete the resource header */
270
271 resource->type = ACPI_RESOURCE_TYPE_DMA;
272 resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
273 return_ACPI_STATUS(AE_OK);
274}
275 215
276/******************************************************************************* 216/*******************************************************************************
277 * 217 *
278 * FUNCTION: acpi_rs_set_dma 218 * acpi_rs_set_start_dpf
279 *
280 * PARAMETERS: Resource - Pointer to the resource descriptor
281 * Aml - Where the AML descriptor is returned
282 *
283 * RETURN: Status
284 *
285 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
286 * external AML resource descriptor.
287 * 219 *
288 ******************************************************************************/ 220 ******************************************************************************/
289 221
290acpi_status 222struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = {
291acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) 223 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
292{ 224 sizeof(struct aml_resource_start_dependent),
293 u8 i; 225 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
294
295 ACPI_FUNCTION_TRACE("rs_set_dma");
296 226
297 /* Convert channel list to 8-bit DMA channel bitmask */ 227 /* Set the default flag values */
298 228
299 aml->dma.dma_channel_mask = 0; 229 {ACPI_RSC_2BITFLAG,
300 for (i = 0; i < resource->data.dma.channel_count; i++) { 230 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
301 aml->dma.dma_channel_mask |= 231 AML_OFFSET(start_dpf.flags),
302 (1 << resource->data.dma.channels[i]); 232 0},
303 }
304 233
305 /* Set the DMA Flag bits */ 234 {ACPI_RSC_2BITFLAG,
235 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
236 AML_OFFSET(start_dpf.flags),
237 2},
238 /*
239 * All done if flags byte is necessary -- if either priority value
240 * is not ACPI_ACCEPTABLE_CONFIGURATION
241 */
242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
244 ACPI_ACCEPTABLE_CONFIGURATION},
306 245
307 aml->dma.flags = (u8) 246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
308 (((resource->data.dma.type & 0x03) << 5) | 247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
309 ((resource->data.dma.bus_master & 0x01) << 2) | 248 ACPI_ACCEPTABLE_CONFIGURATION},
310 (resource->data.dma.transfer & 0x03));
311 249
312 /* Complete the AML descriptor header */ 250 /* Flag byte is not necessary */
313 251
314 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, 252 {ACPI_RSC_LENGTH, 0, 0,
315 sizeof(struct aml_resource_dma), aml); 253 sizeof(struct aml_resource_start_dependent_noprio)}
316 return_ACPI_STATUS(AE_OK); 254};
317}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 4e854ba70811..79e71257b69a 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -49,325 +49,182 @@ ACPI_MODULE_NAME("rsirq")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_get_irq 52 * acpi_rs_get_irq
53 *
54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
63 * 53 *
64 ******************************************************************************/ 54 ******************************************************************************/
65acpi_status 55struct acpi_rsconvert_info acpi_rs_get_irq[7] = {
66acpi_rs_get_irq(union aml_resource *aml, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
67 u16 aml_resource_length, struct acpi_resource *resource) 57 ACPI_RS_SIZE(struct acpi_resource_irq),
68{ 58 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
69 u16 temp16 = 0;
70 u32 interrupt_count = 0;
71 u32 i;
72 u32 resource_length;
73
74 ACPI_FUNCTION_TRACE("rs_get_irq");
75 59
76 /* Get the IRQ mask (bytes 1:2) */ 60 /* Get the IRQ mask (bytes 1:2) */
77 61
78 ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); 62 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
79 63 AML_OFFSET(irq.irq_mask),
80 /* Decode the IRQ bits (up to 16 possible) */ 64 ACPI_RS_OFFSET(data.irq.interrupt_count)},
81 65
82 for (i = 0; i < 16; i++) { 66 /* Set default flags (others are zero) */
83 if ((temp16 >> i) & 0x01) { 67
84 resource->data.irq.interrupts[interrupt_count] = i; 68 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
85 interrupt_count++; 69 ACPI_EDGE_SENSITIVE,
86 } 70 1},
87 } 71
88 72 /* All done if no flag byte present in descriptor */
89 /* Zero interrupts is valid */ 73
90 74 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
91 resource_length = 0; 75
92 resource->data.irq.interrupt_count = interrupt_count; 76 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
93 if (interrupt_count > 0) { 77
94 /* Calculate the structure size based upon the number of interrupts */ 78 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
95 79 AML_OFFSET(irq.flags),
96 resource_length = (u32) (interrupt_count - 1) * 4; 80 0},
97 } 81
98 82 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
99 /* Get Flags (Byte 3) if it is used */ 83 AML_OFFSET(irq.flags),
100 84 3},
101 if (aml_resource_length == 3) { 85
102 /* Check for HE, LL interrupts */ 86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
103 87 AML_OFFSET(irq.flags),
104 switch (aml->irq.flags & 0x09) { 88 4}
105 case 0x01: /* HE */ 89};
106 resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
107 resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
108 break;
109
110 case 0x08: /* LL */
111 resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE;
112 resource->data.irq.polarity = ACPI_ACTIVE_LOW;
113 break;
114
115 default:
116 /*
117 * Only _LL and _HE polarity/trigger interrupts
118 * are allowed (ACPI spec, section "IRQ Format")
119 * so 0x00 and 0x09 are illegal.
120 */
121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
122 "Invalid interrupt polarity/trigger in resource list, %X\n",
123 aml->irq.flags));
124 return_ACPI_STATUS(AE_BAD_DATA);
125 }
126
127 /* Get Sharing flag */
128
129 resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01;
130 } else {
131 /*
132 * Default configuration: assume Edge Sensitive, Active High,
133 * Non-Sharable as per the ACPI Specification
134 */
135 resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
136 resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
137 resource->data.irq.sharable = ACPI_EXCLUSIVE;
138 }
139
140 /* Complete the resource header */
141
142 resource->type = ACPI_RESOURCE_TYPE_IRQ;
143 resource->length =
144 resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
145 return_ACPI_STATUS(AE_OK);
146}
147 90
148/******************************************************************************* 91/*******************************************************************************
149 * 92 *
150 * FUNCTION: acpi_rs_set_irq 93 * acpi_rs_set_irq
151 *
152 * PARAMETERS: Resource - Pointer to the resource descriptor
153 * Aml - Where the AML descriptor is returned
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
158 * external AML resource descriptor.
159 * 94 *
160 ******************************************************************************/ 95 ******************************************************************************/
161 96
162acpi_status 97struct acpi_rsconvert_info acpi_rs_set_irq[9] = {
163acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
164{ 99 sizeof(struct aml_resource_irq),
165 acpi_size descriptor_length; 100 ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
166 u16 irq_mask;
167 u8 i;
168
169 ACPI_FUNCTION_TRACE("rs_set_irq");
170 101
171 /* Convert interrupt list to 16-bit IRQ bitmask */ 102 /* Convert interrupt list to 16-bit IRQ bitmask */
172 103
173 irq_mask = 0; 104 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
174 for (i = 0; i < resource->data.irq.interrupt_count; i++) { 105 AML_OFFSET(irq.irq_mask),
175 irq_mask |= (1 << resource->data.irq.interrupts[i]); 106 ACPI_RS_OFFSET(data.irq.interrupt_count)},
176 } 107
108 /* Set the flags byte by default */
177 109
178 /* Set the interrupt mask */ 110 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
111 AML_OFFSET(irq.flags),
112 0},
179 113
180 ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); 114 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
115 AML_OFFSET(irq.flags),
116 3},
181 117
118 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
119 AML_OFFSET(irq.flags),
120 4},
182 /* 121 /*
183 * The descriptor field is set based upon whether a third byte is 122 * Check if the flags byte is necessary. Not needed if the flags are:
184 * needed to contain the IRQ Information. 123 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
185 */ 124 */
186 if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && 125 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
187 (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && 126 ACPI_RS_OFFSET(data.irq.triggering),
188 (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { 127 ACPI_EDGE_SENSITIVE},
189 /* irq_no_flags() descriptor can be used */
190
191 descriptor_length = sizeof(struct aml_resource_irq_noflags);
192 } else {
193 /* Irq() descriptor must be used */
194
195 descriptor_length = sizeof(struct aml_resource_irq);
196
197 /* Set the IRQ Info byte */
198 128
199 aml->irq.flags = (u8) 129 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
200 ((resource->data.irq.sharable & 0x01) << 4); 130 ACPI_RS_OFFSET(data.irq.polarity),
131 ACPI_ACTIVE_HIGH},
201 132
202 if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && 133 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
203 ACPI_ACTIVE_LOW == resource->data.irq.polarity) { 134 ACPI_RS_OFFSET(data.irq.sharable),
204 aml->irq.flags |= 0x08; 135 ACPI_EXCLUSIVE},
205 } else {
206 aml->irq.flags |= 0x01;
207 }
208 }
209 136
210 /* Complete the AML descriptor header */ 137 /* irq_no_flags() descriptor can be used */
211 138
212 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, 139 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
213 aml); 140};
214 return_ACPI_STATUS(AE_OK);
215}
216 141
217/******************************************************************************* 142/*******************************************************************************
218 * 143 *
219 * FUNCTION: acpi_rs_get_ext_irq 144 * acpi_rs_convert_ext_irq
220 *
221 * PARAMETERS: Aml - Pointer to the AML resource descriptor
222 * aml_resource_length - Length of the resource from the AML header
223 * Resource - Where the internal resource is returned
224 *
225 * RETURN: Status
226 *
227 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
228 * internal resource descriptor, simplifying bitflags and handling
229 * alignment and endian issues if necessary.
230 * 145 *
231 ******************************************************************************/ 146 ******************************************************************************/
232 147
233acpi_status 148struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
234acpi_rs_get_ext_irq(union aml_resource *aml, 149 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
235 u16 aml_resource_length, struct acpi_resource *resource) 150 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
236{ 151 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
237 char *out_resource_string;
238 u8 temp8;
239
240 ACPI_FUNCTION_TRACE("rs_get_ext_irq");
241
242 /* Get the flag bits */
243 152
244 temp8 = aml->extended_irq.flags; 153 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
245 resource->data.extended_irq.producer_consumer = temp8 & 0x01; 154 sizeof(struct aml_resource_extended_irq),
246 resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; 155 0},
247 resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01;
248 156
249 /* 157 /* Flag bits */
250 * Check for Interrupt Mode
251 *
252 * The definition of an Extended IRQ changed between ACPI spec v1.0b
253 * and ACPI spec 2.0 (section 6.4.3.6 in both).
254 *
255 * - Edge/Level are defined opposite in the table vs the headers
256 */
257 resource->data.extended_irq.triggering =
258 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
259 158
260 /* Get the IRQ Table length (Byte4) */ 159 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
160 AML_OFFSET(extended_irq.flags),
161 0},
261 162
262 temp8 = aml->extended_irq.table_length; 163 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
263 resource->data.extended_irq.interrupt_count = temp8; 164 AML_OFFSET(extended_irq.flags),
264 if (temp8 < 1) { 165 1},
265 /* Must have at least one IRQ */
266 166
267 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
268 } 168 AML_OFFSET(extended_irq.flags),
169 2},
269 170
270 /* 171 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
271 * Add any additional structure size to properly calculate 172 AML_OFFSET(extended_irq.flags),
272 * the next pointer at the end of this function 173 3},
273 */
274 resource->length = (temp8 - 1) * 4;
275 out_resource_string = ACPI_CAST_PTR(char,
276 (&resource->data.extended_irq.
277 interrupts[0] + temp8));
278 174
279 /* Get every IRQ in the table, each is 32 bits */ 175 /* IRQ Table length (Byte4) */
280 176
281 acpi_rs_move_data(resource->data.extended_irq.interrupts, 177 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
282 aml->extended_irq.interrupt_number, 178 AML_OFFSET(extended_irq.interrupt_count),
283 (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); 179 sizeof(u32)}
180 ,
284 181
285 /* Get the optional resource_source (index and string) */ 182 /* Copy every IRQ in the table, each is 32 bits */
286 183
287 resource->length += 184 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
288 acpi_rs_get_resource_source(aml_resource_length, 185 AML_OFFSET(extended_irq.interrupts[0]),
289 (acpi_size) resource->length + 186 0}
290 sizeof(struct 187 ,
291 aml_resource_extended_irq),
292 &resource->data.extended_irq.
293 resource_source, aml,
294 out_resource_string);
295 188
296 /* Complete the resource header */ 189 /* Optional resource_source (Index and String) */
297 190
298 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; 191 {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
299 resource->length += 192 ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
300 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); 193 sizeof(struct aml_resource_extended_irq)}
301 return_ACPI_STATUS(AE_OK); 194};
302}
303 195
304/******************************************************************************* 196/*******************************************************************************
305 * 197 *
306 * FUNCTION: acpi_rs_set_ext_irq 198 * acpi_rs_convert_dma
307 *
308 * PARAMETERS: Resource - Pointer to the resource descriptor
309 * Aml - Where the AML descriptor is returned
310 *
311 * RETURN: Status
312 *
313 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
314 * external AML resource descriptor.
315 * 199 *
316 ******************************************************************************/ 200 ******************************************************************************/
317 201
318acpi_status 202struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
319acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) 203 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
320{ 204 ACPI_RS_SIZE(struct acpi_resource_dma),
321 acpi_size descriptor_length; 205 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
322
323 ACPI_FUNCTION_TRACE("rs_set_ext_irq");
324
325 /* Set the Interrupt vector flags */
326
327 aml->extended_irq.flags = (u8)
328 ((resource->data.extended_irq.producer_consumer & 0x01) |
329 ((resource->data.extended_irq.sharable & 0x01) << 3) |
330 ((resource->data.extended_irq.polarity & 0x1) << 2));
331
332 /*
333 * Set the Interrupt Mode
334 *
335 * The definition of an Extended IRQ changed between ACPI spec v1.0b
336 * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not
337 * implement the more restrictive definition of 1.0b
338 *
339 * - Edge/Level are defined opposite in the table vs the headers
340 */
341 if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) {
342 aml->extended_irq.flags |= 0x02;
343 }
344
345 /* Set the Interrupt table length */
346
347 aml->extended_irq.table_length = (u8)
348 resource->data.extended_irq.interrupt_count;
349 206
350 descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + 207 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
351 ((acpi_size) resource->data.extended_irq.interrupt_count * 208 sizeof(struct aml_resource_dma),
352 sizeof(u32)); 209 0},
353 210
354 /* Set each interrupt value */ 211 /* Flags: transfer preference, bus mastering, channel speed */
355 212
356 acpi_rs_move_data(aml->extended_irq.interrupt_number, 213 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
357 resource->data.extended_irq.interrupts, 214 AML_OFFSET(dma.flags),
358 (u16) resource->data.extended_irq.interrupt_count, 215 0},
359 ACPI_MOVE_TYPE_32_TO_32);
360 216
361 /* Resource Source Index and Resource Source are optional */ 217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
218 AML_OFFSET(dma.flags),
219 2},
362 220
363 descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, 221 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
364 &resource->data. 222 AML_OFFSET(dma.flags),
365 extended_irq. 223 5},
366 resource_source);
367 224
368 /* Complete the AML descriptor header */ 225 /* DMA channel mask bits */
369 226
370 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, 227 {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
371 descriptor_length, aml); 228 AML_OFFSET(dma.dma_channel_mask),
372 return_ACPI_STATUS(AE_OK); 229 ACPI_RS_OFFSET(data.dma.channel_count)}
373} 230};
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index f72d42e0927b..ee17ef3315f8 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -48,7 +48,8 @@
48ACPI_MODULE_NAME("rslist") 48ACPI_MODULE_NAME("rslist")
49 49
50/* Local prototypes */ 50/* Local prototypes */
51static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); 51static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8
52 resource_type);
52 53
53static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); 54static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml);
54 55
@@ -83,7 +84,7 @@ static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml)
83 return (AE_AML_INVALID_RESOURCE_TYPE); 84 return (AE_AML_INVALID_RESOURCE_TYPE);
84 } 85 }
85 86
86 resource_length = acpi_rs_get_resource_length(aml); 87 resource_length = acpi_ut_get_resource_length(aml);
87 minimum_aml_resource_length = 88 minimum_aml_resource_length =
88 resource_info->minimum_aml_resource_length; 89 resource_info->minimum_aml_resource_length;
89 90
@@ -115,18 +116,17 @@ static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml)
115 116
116/******************************************************************************* 117/*******************************************************************************
117 * 118 *
118 * FUNCTION: acpi_rs_get_resource_handler 119 * FUNCTION: acpi_rs_get_conversion_info
119 * 120 *
120 * PARAMETERS: resource_type - Byte 0 of a resource descriptor 121 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
121 * 122 *
122 * RETURN: Pointer to the resource conversion handler 123 * RETURN: Pointer to the resource conversion info table
123 * 124 *
124 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 125 * DESCRIPTION: Get the conversion table associated with this resource type
125 * a resource descriptor.
126 * 126 *
127 ******************************************************************************/ 127 ******************************************************************************/
128 128
129static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) 129static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type)
130{ 130{
131 ACPI_FUNCTION_ENTRY(); 131 ACPI_FUNCTION_ENTRY();
132 132
@@ -174,33 +174,24 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
174 acpi_status status; 174 acpi_status status;
175 acpi_size bytes_parsed = 0; 175 acpi_size bytes_parsed = 0;
176 struct acpi_resource *resource; 176 struct acpi_resource *resource;
177 u16 resource_length; 177 acpi_rsdesc_size descriptor_length;
178 u32 descriptor_length; 178 struct acpi_rsconvert_info *info;
179 ACPI_GET_RESOURCE_HANDLER handler;
180 179
181 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); 180 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
182 181
183 /* Loop until end-of-buffer or an end_tag is found */ 182 /* Loop until end-of-buffer or an end_tag is found */
184 183
185 while (bytes_parsed < aml_buffer_length) { 184 while (bytes_parsed < aml_buffer_length) {
186 /* Get the handler associated with this Descriptor Type */ 185 /* Get the conversion table associated with this Descriptor Type */
187 186
188 handler = acpi_rs_get_resource_handler(*aml_buffer); 187 info = acpi_rs_get_conversion_info(*aml_buffer);
189 if (!handler) { 188 if (!info) {
190 /* No handler indicates invalid resource type */ 189 /* No table indicates an invalid resource type */
191 190
192 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 191 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
193 } 192 }
194 193
195 resource_length = 194 descriptor_length = acpi_ut_get_descriptor_length(aml_buffer);
196 acpi_rs_get_resource_length(ACPI_CAST_PTR
197 (union aml_resource,
198 aml_buffer));
199
200 descriptor_length =
201 acpi_rs_get_descriptor_length(ACPI_CAST_PTR
202 (union aml_resource,
203 aml_buffer));
204 195
205 /* 196 /*
206 * Perform limited validation of the resource length, based upon 197 * Perform limited validation of the resource length, based upon
@@ -214,11 +205,16 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
214 return_ACPI_STATUS(status); 205 return_ACPI_STATUS(status);
215 } 206 }
216 207
217 /* Convert a byte stream resource to local resource struct */ 208 /* Convert the AML byte stream resource to a local resource struct */
218 209
219 status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer), 210 status =
220 resource_length, 211 acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR
221 ACPI_CAST_PTR(struct acpi_resource, buffer)); 212 (struct acpi_resource,
213 buffer),
214 ACPI_CAST_PTR(union
215 aml_resource,
216 aml_buffer),
217 info);
222 if (ACPI_FAILURE(status)) { 218 if (ACPI_FAILURE(status)) {
223 ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); 219 ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status)));
224 return_ACPI_STATUS(status); 220 return_ACPI_STATUS(status);
@@ -232,7 +228,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
232 228
233 /* Normal exit on completion of an end_tag resource descriptor */ 229 /* Normal exit on completion of an end_tag resource descriptor */
234 230
235 if (acpi_rs_get_resource_type(*aml_buffer) == 231 if (acpi_ut_get_resource_type(aml_buffer) ==
236 ACPI_RESOURCE_NAME_END_TAG) { 232 ACPI_RESOURCE_NAME_END_TAG) {
237 return_ACPI_STATUS(AE_OK); 233 return_ACPI_STATUS(AE_OK);
238 } 234 }
@@ -276,14 +272,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
276 acpi_size aml_size_needed, u8 * output_buffer) 272 acpi_size aml_size_needed, u8 * output_buffer)
277{ 273{
278 u8 *aml_buffer = output_buffer; 274 u8 *aml_buffer = output_buffer;
275 u8 *end_aml_buffer = output_buffer + aml_size_needed;
279 acpi_status status; 276 acpi_status status;
280 277
281 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); 278 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
282 279
283 /* Convert each resource descriptor in the list */ 280 /* Walk the resource descriptor list, convert each descriptor */
284 281
285 while (1) { 282 while (aml_buffer < end_aml_buffer) {
286 /* Validate Resource Descriptor Type before dispatch */ 283 /* Validate the Resource Type */
287 284
288 if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 285 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -292,14 +289,14 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
292 return_ACPI_STATUS(AE_BAD_DATA); 289 return_ACPI_STATUS(AE_BAD_DATA);
293 } 290 }
294 291
295 /* Perform the conversion per resource type */ 292 /* Perform the conversion */
296 293
297 status = 294 status = acpi_rs_convert_resource_to_aml(resource,
298 acpi_gbl_set_resource_dispatch[resource->type] (resource, 295 ACPI_CAST_PTR(union
299 ACPI_CAST_PTR 296 aml_resource,
300 (union 297 aml_buffer),
301 aml_resource, 298 acpi_gbl_set_resource_dispatch
302 aml_buffer)); 299 [resource->type]);
303 if (ACPI_FAILURE(status)) { 300 if (ACPI_FAILURE(status)) {
304 ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); 301 ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status)));
305 return_ACPI_STATUS(status); 302 return_ACPI_STATUS(status);
@@ -323,18 +320,23 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
323 return_ACPI_STATUS(AE_OK); 320 return_ACPI_STATUS(AE_OK);
324 } 321 }
325 322
326 /* Extract the total length of the new descriptor */ 323 /*
327 /* Set the aml_buffer to point to the next (output) resource descriptor */ 324 * Extract the total length of the new descriptor and set the
328 325 * aml_buffer to point to the next (output) resource descriptor
329 aml_buffer += 326 */
330 acpi_rs_get_descriptor_length(ACPI_CAST_PTR 327 aml_buffer += acpi_ut_get_descriptor_length(aml_buffer);
331 (union aml_resource,
332 aml_buffer));
333 328
334 /* Point to the next input resource descriptor */ 329 /* Point to the next input resource descriptor */
335 330
336 resource = 331 resource =
337 ACPI_PTR_ADD(struct acpi_resource, resource, 332 ACPI_PTR_ADD(struct acpi_resource, resource,
338 resource->length); 333 resource->length);
334
335 /* Check for end-of-list, normal exit */
336
339 } 337 }
338
339 /* Completed buffer, but did not find an end_tag resource descriptor */
340
341 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
340} 342}
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index 47e979e7ba35..418a3fb64077 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -49,260 +49,187 @@ ACPI_MODULE_NAME("rsmemory")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_get_memory24 52 * acpi_rs_convert_memory24
53 *
54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
63 * 53 *
64 ******************************************************************************/ 54 ******************************************************************************/
65acpi_status 55struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = {
66acpi_rs_get_memory24(union aml_resource * aml, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
67 u16 aml_resource_length, struct acpi_resource * resource) 57 ACPI_RS_SIZE(struct acpi_resource_memory24),
68{ 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)},
69 ACPI_FUNCTION_TRACE("rs_get_memory24");
70 59
71 /* Get the Read/Write bit */ 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
61 sizeof(struct aml_resource_memory24),
62 0},
72 63
73 resource->data.memory24.read_write_attribute = 64 /* Read/Write bit */
74 (aml->memory24.information & 0x01);
75 65
66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect),
67 AML_OFFSET(memory24.flags),
68 0},
76 /* 69 /*
77 * Get the following contiguous fields from the AML descriptor: 70 * These fields are contiguous in both the source and destination:
78 * Minimum Base Address 71 * Minimum Base Address
79 * Maximum Base Address 72 * Maximum Base Address
80 * Address Base Alignment 73 * Address Base Alignment
81 * Range Length 74 * Range Length
82 */ 75 */
83 acpi_rs_move_data(&resource->data.memory24.minimum, 76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum),
84 &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); 77 AML_OFFSET(memory24.minimum),
85 78 4}
86 /* Complete the resource header */ 79};
87
88 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
89 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24);
90 return_ACPI_STATUS(AE_OK);
91}
92 80
93/******************************************************************************* 81/*******************************************************************************
94 * 82 *
95 * FUNCTION: acpi_rs_set_memory24 83 * acpi_rs_convert_memory32
96 *
97 * PARAMETERS: Resource - Pointer to the resource descriptor
98 * Aml - Where the AML descriptor is returned
99 *
100 * RETURN: Status
101 *
102 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
103 * external AML resource descriptor.
104 * 84 *
105 ******************************************************************************/ 85 ******************************************************************************/
106 86
107acpi_status 87struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = {
108acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) 88 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
109{ 89 ACPI_RS_SIZE(struct acpi_resource_memory32),
110 ACPI_FUNCTION_TRACE("rs_set_memory24"); 90 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)},
111 91
112 /* Set the Information Byte */ 92 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
93 sizeof(struct aml_resource_memory32),
94 0},
113 95
114 aml->memory24.information = (u8) 96 /* Read/Write bit */
115 (resource->data.memory24.read_write_attribute & 0x01);
116 97
98 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect),
99 AML_OFFSET(memory32.flags),
100 0},
117 /* 101 /*
118 * Set the following contiguous fields in the AML descriptor: 102 * These fields are contiguous in both the source and destination:
119 * Minimum Base Address 103 * Minimum Base Address
120 * Maximum Base Address 104 * Maximum Base Address
121 * Address Base Alignment 105 * Address Base Alignment
122 * Range Length 106 * Range Length
123 */ 107 */
124 acpi_rs_move_data(&aml->memory24.minimum, 108 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum),
125 &resource->data.memory24.minimum, 4, 109 AML_OFFSET(memory32.minimum),
126 ACPI_MOVE_TYPE_32_TO_16); 110 4}
127 111};
128 /* Complete the AML descriptor header */
129
130 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24,
131 sizeof(struct aml_resource_memory24), aml);
132 return_ACPI_STATUS(AE_OK);
133}
134 112
135/******************************************************************************* 113/*******************************************************************************
136 * 114 *
137 * FUNCTION: acpi_rs_get_memory32 115 * acpi_rs_convert_fixed_memory32
138 *
139 * PARAMETERS: Aml - Pointer to the AML resource descriptor
140 * aml_resource_length - Length of the resource from the AML header
141 * Resource - Where the internal resource is returned
142 *
143 * RETURN: Status
144 *
145 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
146 * internal resource descriptor, simplifying bitflags and handling
147 * alignment and endian issues if necessary.
148 * 116 *
149 ******************************************************************************/ 117 ******************************************************************************/
150 118
151acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = {
152acpi_rs_get_memory32(union aml_resource *aml, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
153 u16 aml_resource_length, struct acpi_resource *resource) 121 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
154{ 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)},
155 ACPI_FUNCTION_TRACE("rs_get_memory32");
156 123
157 /* Get the Read/Write bit */ 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
125 sizeof(struct aml_resource_fixed_memory32),
126 0},
158 127
159 resource->data.memory32.read_write_attribute = 128 /* Read/Write bit */
160 (aml->memory32.information & 0x01);
161 129
130 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect),
131 AML_OFFSET(fixed_memory32.flags),
132 0},
162 /* 133 /*
163 * Get the following contiguous fields from the AML descriptor: 134 * These fields are contiguous in both the source and destination:
164 * Minimum Base Address 135 * Base Address
165 * Maximum Base Address
166 * Address Base Alignment
167 * Range Length 136 * Range Length
168 */ 137 */
169 acpi_rs_move_data(&resource->data.memory32.minimum, 138 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address),
170 &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); 139 AML_OFFSET(fixed_memory32.address),
171 140 2}
172 /* Complete the resource header */ 141};
173
174 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
175 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32);
176 return_ACPI_STATUS(AE_OK);
177}
178 142
179/******************************************************************************* 143/*******************************************************************************
180 * 144 *
181 * FUNCTION: acpi_rs_set_memory32 145 * acpi_rs_get_vendor_small
182 *
183 * PARAMETERS: Resource - Pointer to the resource descriptor
184 * Aml - Where the AML descriptor is returned
185 *
186 * RETURN: Status
187 *
188 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
189 * external AML resource descriptor.
190 * 146 *
191 ******************************************************************************/ 147 ******************************************************************************/
192 148
193acpi_status 149struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
194acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) 150 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
195{ 151 ACPI_RS_SIZE(struct acpi_resource_vendor),
196 ACPI_FUNCTION_TRACE("rs_set_memory32"); 152 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)},
197
198 /* Set the Information Byte */
199 153
200 aml->memory32.information = (u8) 154 /* Length of the vendor data (byte count) */
201 (resource->data.memory32.read_write_attribute & 0x01);
202 155
203 /* 156 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
204 * Set the following contiguous fields in the AML descriptor: 157 0,
205 * Minimum Base Address 158 sizeof(u8)}
206 * Maximum Base Address 159 ,
207 * Address Base Alignment
208 * Range Length
209 */
210 acpi_rs_move_data(&aml->memory32.minimum,
211 &resource->data.memory32.minimum, 4,
212 ACPI_MOVE_TYPE_32_TO_32);
213 160
214 /* Complete the AML descriptor header */ 161 /* Vendor data */
215 162
216 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, 163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
217 sizeof(struct aml_resource_memory32), aml); 164 sizeof(struct aml_resource_small_header),
218 return_ACPI_STATUS(AE_OK); 165 0}
219} 166};
220 167
221/******************************************************************************* 168/*******************************************************************************
222 * 169 *
223 * FUNCTION: acpi_rs_get_fixed_memory32 170 * acpi_rs_get_vendor_large
224 *
225 * PARAMETERS: Aml - Pointer to the AML resource descriptor
226 * aml_resource_length - Length of the resource from the AML header
227 * Resource - Where the internal resource is returned
228 *
229 * RETURN: Status
230 *
231 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
232 * internal resource descriptor, simplifying bitflags and handling
233 * alignment and endian issues if necessary.
234 * 171 *
235 ******************************************************************************/ 172 ******************************************************************************/
236 173
237acpi_status 174struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
238acpi_rs_get_fixed_memory32(union aml_resource *aml, 175 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
239 u16 aml_resource_length, 176 ACPI_RS_SIZE(struct acpi_resource_vendor),
240 struct acpi_resource *resource) 177 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)},
241{
242 ACPI_FUNCTION_TRACE("rs_get_fixed_memory32");
243
244 /* Get the Read/Write bit */
245 178
246 resource->data.fixed_memory32.read_write_attribute = 179 /* Length of the vendor data (byte count) */
247 (aml->fixed_memory32.information & 0x01);
248 180
249 /* 181 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
250 * Get the following contiguous fields from the AML descriptor: 182 0,
251 * Base Address 183 sizeof(u8)}
252 * Range Length 184 ,
253 */
254 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address,
255 &aml->fixed_memory32.address);
256 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length,
257 &aml->fixed_memory32.address_length);
258 185
259 /* Complete the resource header */ 186 /* Vendor data */
260 187
261 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; 188 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
262 resource->length = 189 sizeof(struct aml_resource_large_header),
263 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); 190 0}
264 return_ACPI_STATUS(AE_OK); 191};
265}
266 192
267/******************************************************************************* 193/*******************************************************************************
268 * 194 *
269 * FUNCTION: acpi_rs_set_fixed_memory32 195 * acpi_rs_set_vendor
270 *
271 * PARAMETERS: Resource - Pointer to the resource descriptor
272 * Aml - Where the AML descriptor is returned
273 *
274 * RETURN: Status
275 *
276 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
277 * external AML resource descriptor.
278 * 196 *
279 ******************************************************************************/ 197 ******************************************************************************/
280 198
281acpi_status 199struct acpi_rsconvert_info acpi_rs_set_vendor[7] = {
282acpi_rs_set_fixed_memory32(struct acpi_resource *resource, 200 /* Default is a small vendor descriptor */
283 union aml_resource *aml) 201
284{ 202 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
285 ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); 203 sizeof(struct aml_resource_small_header),
204 ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)},
205
206 /* Get the length and copy the data */
286 207
287 /* Set the Information Byte */ 208 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
209 0,
210 0},
288 211
289 aml->fixed_memory32.information = (u8) 212 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
290 (resource->data.fixed_memory32.read_write_attribute & 0x01); 213 sizeof(struct aml_resource_small_header),
214 0},
291 215
292 /* 216 /*
293 * Set the following contiguous fields in the AML descriptor: 217 * All done if the Vendor byte length is 7 or less, meaning that it will
294 * Base Address 218 * fit within a small descriptor
295 * Range Length
296 */ 219 */
297 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, 220 {ACPI_RSC_EXIT_LE, 0, 0, 7},
298 &resource->data.fixed_memory32.address); 221
299 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, 222 /* Must create a large vendor descriptor */
300 &resource->data.fixed_memory32.address_length); 223
301 224 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
302 /* Complete the AML descriptor header */ 225 sizeof(struct aml_resource_large_header),
303 226 0},
304 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, 227
305 sizeof(struct aml_resource_fixed_memory32), 228 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
306 aml); 229 0,
307 return_ACPI_STATUS(AE_OK); 230 0},
308} 231
232 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
233 sizeof(struct aml_resource_large_header),
234 0}
235};
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index 337a0f01cb23..16ad3bfbee2a 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -47,156 +47,267 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmisc") 48ACPI_MODULE_NAME("rsmisc")
49 49
50#define INIT_RESOURCE_TYPE(i) i->resource_offset
51#define INIT_RESOURCE_LENGTH(i) i->aml_offset
52#define INIT_TABLE_LENGTH(i) i->value
53#define COMPARE_OPCODE(i) i->resource_offset
54#define COMPARE_TARGET(i) i->aml_offset
55#define COMPARE_VALUE(i) i->value
50/******************************************************************************* 56/*******************************************************************************
51 * 57 *
52 * FUNCTION: acpi_rs_get_generic_reg 58 * FUNCTION: acpi_rs_convert_aml_to_resource
53 *
54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
63 *
64 ******************************************************************************/
65acpi_status
66acpi_rs_get_generic_reg(union aml_resource *aml,
67 u16 aml_resource_length, struct acpi_resource *resource)
68{
69 ACPI_FUNCTION_TRACE("rs_get_generic_reg");
70
71 /*
72 * Get the following fields from the AML descriptor:
73 * Address Space ID
74 * Register Bit Width
75 * Register Bit Offset
76 * Access Size
77 * Register Address
78 */
79 resource->data.generic_reg.space_id = aml->generic_reg.address_space_id;
80 resource->data.generic_reg.bit_width = aml->generic_reg.bit_width;
81 resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset;
82 resource->data.generic_reg.access_size = aml->generic_reg.access_size;
83 ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address,
84 &aml->generic_reg.address);
85
86 /* Complete the resource header */
87
88 resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER;
89 resource->length =
90 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register);
91 return_ACPI_STATUS(AE_OK);
92}
93
94/*******************************************************************************
95 *
96 * FUNCTION: acpi_rs_set_generic_reg
97 * 59 *
98 * PARAMETERS: Resource - Pointer to the resource descriptor 60 * PARAMETERS: Resource - Pointer to the resource descriptor
99 * Aml - Where the AML descriptor is returned 61 * Aml - Where the AML descriptor is returned
62 * Info - Pointer to appropriate conversion table
100 * 63 *
101 * RETURN: Status 64 * RETURN: Status
102 * 65 *
103 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 66 * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
104 * external AML resource descriptor. 67 * internal resource descriptor
105 *
106 ******************************************************************************/
107
108acpi_status
109acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml)
110{
111 ACPI_FUNCTION_TRACE("rs_set_generic_reg");
112
113 /*
114 * Set the following fields in the AML descriptor:
115 * Address Space ID
116 * Register Bit Width
117 * Register Bit Offset
118 * Access Size
119 * Register Address
120 */
121 aml->generic_reg.address_space_id =
122 (u8) resource->data.generic_reg.space_id;
123 aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width;
124 aml->generic_reg.bit_offset =
125 (u8) resource->data.generic_reg.bit_offset;
126 aml->generic_reg.access_size =
127 (u8) resource->data.generic_reg.access_size;
128 ACPI_MOVE_64_TO_64(&aml->generic_reg.address,
129 &resource->data.generic_reg.address);
130
131 /* Complete the AML descriptor header */
132
133 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER,
134 sizeof(struct
135 aml_resource_generic_register), aml);
136 return_ACPI_STATUS(AE_OK);
137}
138
139/*******************************************************************************
140 *
141 * FUNCTION: acpi_rs_get_vendor
142 *
143 * PARAMETERS: Aml - Pointer to the AML resource descriptor
144 * aml_resource_length - Length of the resource from the AML header
145 * Resource - Where the internal resource is returned
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
150 * internal resource descriptor, simplifying bitflags and handling
151 * alignment and endian issues if necessary.
152 * 68 *
153 ******************************************************************************/ 69 ******************************************************************************/
154
155acpi_status 70acpi_status
156acpi_rs_get_vendor(union aml_resource *aml, 71acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
157 u16 aml_resource_length, struct acpi_resource *resource) 72 union aml_resource *aml,
73 struct acpi_rsconvert_info *info)
158{ 74{
159 u8 *aml_byte_data; 75 acpi_rs_length aml_resource_length;
160 76 void *source;
161 ACPI_FUNCTION_TRACE("rs_get_vendor"); 77 void *destination;
78 char *target;
79 u8 count;
80 u8 flags_mode = FALSE;
81 u16 item_count = 0;
82 u16 temp16 = 0;
83
84 ACPI_FUNCTION_TRACE("rs_get_resource");
85
86 if (((acpi_native_uint) resource) & 0x3) {
87 acpi_os_printf
88 ("**** GET: Misaligned resource pointer: %p Type %2.2X Len %X\n",
89 resource, resource->type, resource->length);
90 }
162 91
163 /* Determine if this is a large or small vendor specific item */ 92 /* Extract the resource Length field (does not include header length) */
164 93
165 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 94 aml_resource_length = acpi_ut_get_resource_length(aml);
166 /* Large item, Point to the first vendor byte */
167 95
168 aml_byte_data = 96 /*
169 ((u8 *) aml) + sizeof(struct aml_resource_large_header); 97 * First table entry must be ACPI_RSC_INITxxx and must contain the
170 } else { 98 * table length (# of table entries)
171 /* Small item, Point to the first vendor byte */ 99 */
100 count = INIT_TABLE_LENGTH(info);
101
102 while (count) {
103 /*
104 * Source is the external AML byte stream buffer,
105 * destination is the internal resource descriptor
106 */
107 source = ((u8 *) aml) + info->aml_offset;
108 destination = ((u8 *) resource) + info->resource_offset;
109
110 switch (info->opcode) {
111 case ACPI_RSC_INITGET:
112 /*
113 * Get the resource type and the initial (minimum) length
114 */
115 ACPI_MEMSET(resource, 0, INIT_RESOURCE_LENGTH(info));
116 resource->type = INIT_RESOURCE_TYPE(info);
117 resource->length = INIT_RESOURCE_LENGTH(info);
118 break;
119
120 case ACPI_RSC_INITSET:
121 break;
122
123 case ACPI_RSC_FLAGINIT:
124
125 flags_mode = TRUE;
126 break;
127
128 case ACPI_RSC_1BITFLAG:
129 /*
130 * Mask and shift the flag bit
131 */
132 *((u8 *) destination) = (u8)
133 ((*((u8 *) source) >> info->value) & 0x01);
134 break;
135
136 case ACPI_RSC_2BITFLAG:
137 /*
138 * Mask and shift the flag bits
139 */
140 *((u8 *) destination) = (u8)
141 ((*((u8 *) source) >> info->value) & 0x03);
142 break;
143
144 case ACPI_RSC_COUNT:
145
146 item_count = *((u8 *) source);
147 *((u8 *) destination) = (u8) item_count;
148
149 resource->length = resource->length +
150 (info->value * (item_count - 1));
151 break;
152
153 case ACPI_RSC_COUNT16:
154
155 item_count = aml_resource_length;
156 *((u16 *) destination) = item_count;
157
158 resource->length = resource->length +
159 (info->value * (item_count - 1));
160 break;
161
162 case ACPI_RSC_LENGTH:
163
164 resource->length = resource->length + info->value;
165 break;
166
167 case ACPI_RSC_MOVE8:
168 case ACPI_RSC_MOVE16:
169 case ACPI_RSC_MOVE32:
170 case ACPI_RSC_MOVE64:
171 /*
172 * Raw data move. Use the Info value field unless item_count has
173 * been previously initialized via a COUNT opcode
174 */
175 if (info->value) {
176 item_count = info->value;
177 }
178 acpi_rs_move_data(destination, source, item_count,
179 info->opcode);
180 break;
181
182 case ACPI_RSC_SET8:
183
184 ACPI_MEMSET(destination, info->aml_offset, info->value);
185 break;
186
187 case ACPI_RSC_DATA8:
188
189 target = ((char *)resource) + info->value;
190 ACPI_MEMCPY(destination, source,
191 *(ACPI_CAST_PTR(u16, target)));
192 break;
193
194 case ACPI_RSC_ADDRESS:
195 /*
196 * Common handler for address descriptor flags
197 */
198 if (!acpi_rs_get_address_common(resource, aml)) {
199 return_ACPI_STATUS
200 (AE_AML_INVALID_RESOURCE_TYPE);
201 }
202 break;
203
204 case ACPI_RSC_SOURCE:
205 /*
206 * Optional resource_source (Index and String)
207 */
208 resource->length +=
209 acpi_rs_get_resource_source(aml_resource_length,
210 info->value,
211 destination, aml, NULL);
212 break;
213
214 case ACPI_RSC_SOURCEX:
215 /*
216 * Optional resource_source (Index and String). This is the more
217 * complicated case used by the Interrupt() macro
218 */
219 target =
220 ((char *)resource) + info->aml_offset +
221 (item_count * 4);
222
223 resource->length +=
224 acpi_rs_get_resource_source(aml_resource_length,
225 (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target);
226 break;
227
228 case ACPI_RSC_BITMASK:
229 /*
230 * 8-bit encoded bitmask (DMA macro)
231 */
232 item_count =
233 acpi_rs_decode_bitmask(*((u8 *) source),
234 destination);
235 if (item_count) {
236 resource->length +=
237 resource->length + (item_count - 1);
238 }
239
240 target = ((char *)resource) + info->value;
241 *((u8 *) target) = (u8) item_count;
242 break;
243
244 case ACPI_RSC_BITMASK16:
245 /*
246 * 16-bit encoded bitmask (IRQ macro)
247 */
248 ACPI_MOVE_16_TO_16(&temp16, source);
249
250 item_count =
251 acpi_rs_decode_bitmask(temp16, destination);
252 if (item_count) {
253 resource->length =
254 resource->length + (item_count - 1);
255 }
256
257 target = ((char *)resource) + info->value;
258 *((u8 *) target) = (u8) item_count;
259 break;
260
261 case ACPI_RSC_EXIT_NE:
262 /*
263 * Control - Exit conversion if not equal
264 */
265 switch (info->resource_offset) {
266 case ACPI_RSC_COMPARE_AML_LENGTH:
267 if (aml_resource_length != info->value) {
268 goto exit;
269 }
270 break;
271
272 case ACPI_RSC_COMPARE_VALUE:
273 if (*((u8 *) source) != info->value) {
274 goto exit;
275 }
276 break;
277
278 default:
279 acpi_os_printf
280 ("*** Invalid conversion sub-opcode\n");
281 return_ACPI_STATUS(AE_BAD_PARAMETER);
282 }
283 break;
284
285 default:
286
287 acpi_os_printf("*** Invalid conversion opcode\n");
288 return_ACPI_STATUS(AE_BAD_PARAMETER);
289 }
172 290
173 aml_byte_data = 291 count--;
174 ((u8 *) aml) + sizeof(struct aml_resource_small_header); 292 info++;
175 } 293 }
176 294
177 /* Copy the vendor-specific bytes */ 295 exit:
178 296 if (!flags_mode) {
179 ACPI_MEMCPY(resource->data.vendor.byte_data, 297 /* Round the resource struct length up to the next 32-bit boundary */
180 aml_byte_data, aml_resource_length);
181 resource->data.vendor.byte_length = aml_resource_length;
182 298
183 /* 299 resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length);
184 * In order for the struct_size to fall on a 32-bit boundary, 300 }
185 * calculate the length of the vendor string and expand the
186 * struct_size to the next 32-bit boundary.
187 */
188 resource->type = ACPI_RESOURCE_TYPE_VENDOR;
189 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
190 ACPI_ROUND_UP_to_32_bITS(aml_resource_length);
191 return_ACPI_STATUS(AE_OK); 301 return_ACPI_STATUS(AE_OK);
192} 302}
193 303
194/******************************************************************************* 304/*******************************************************************************
195 * 305 *
196 * FUNCTION: acpi_rs_set_vendor 306 * FUNCTION: acpi_rs_convert_resource_to_aml
197 * 307 *
198 * PARAMETERS: Resource - Pointer to the resource descriptor 308 * PARAMETERS: Resource - Pointer to the resource descriptor
199 * Aml - Where the AML descriptor is returned 309 * Aml - Where the AML descriptor is returned
310 * Info - Pointer to appropriate conversion table
200 * 311 *
201 * RETURN: Status 312 * RETURN: Status
202 * 313 *
@@ -206,275 +317,236 @@ acpi_rs_get_vendor(union aml_resource *aml,
206 ******************************************************************************/ 317 ******************************************************************************/
207 318
208acpi_status 319acpi_status
209acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) 320acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
321 union aml_resource *aml,
322 struct acpi_rsconvert_info *info)
210{ 323{
211 u32 resource_length; 324 void *source = NULL;
212 u8 *source; 325 void *destination;
213 u8 *destination; 326 acpi_rsdesc_size aml_length = 0;
214 327 u8 count;
215 ACPI_FUNCTION_TRACE("rs_set_vendor"); 328 u16 temp16 = 0;
216 329 u16 item_count = 0;
217 resource_length = resource->data.vendor.byte_length;
218 source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data);
219
220 /* Length determines if this is a large or small resource */
221 330
222 if (resource_length > 7) { 331 ACPI_FUNCTION_TRACE("rs_convert_resource_to_aml");
223 /* Large item, get pointer to the data part of the descriptor */
224 332
225 destination = 333 /* Validate the Resource pointer, must be 32-bit aligned */
226 ((u8 *) aml) + sizeof(struct aml_resource_large_header);
227 334
228 /* Complete the AML descriptor header */ 335 if (((acpi_native_uint) resource) & 0x3) {
229 336 acpi_os_printf
230 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, 337 ("**** SET: Misaligned resource pointer: %p Type %2.2X Len %X\n",
231 (u32) (resource_length + 338 resource, resource->type, resource->length);
232 sizeof(struct
233 aml_resource_large_header)),
234 aml);
235 } else {
236 /* Small item, get pointer to the data part of the descriptor */
237
238 destination =
239 ((u8 *) aml) + sizeof(struct aml_resource_small_header);
240
241 /* Complete the AML descriptor header */
242
243 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL,
244 (u32) (resource_length +
245 sizeof(struct
246 aml_resource_small_header)),
247 aml);
248 } 339 }
249 340
250 /* Copy the vendor-specific bytes */ 341 /*
251 342 * First table entry must be ACPI_RSC_INITxxx and must contain the
252 ACPI_MEMCPY(destination, source, resource_length); 343 * table length (# of table entries)
253 return_ACPI_STATUS(AE_OK); 344 */
254} 345 count = INIT_TABLE_LENGTH(info);
255 346
256/******************************************************************************* 347 while (count) {
257 * 348 /*
258 * FUNCTION: acpi_rs_get_start_dpf 349 * Source is the internal resource descriptor,
259 * 350 * destination is the external AML byte stream buffer
260 * PARAMETERS: Aml - Pointer to the AML resource descriptor 351 */
261 * aml_resource_length - Length of the resource from the AML header 352 source = ((u8 *) resource) + info->resource_offset;
262 * Resource - Where the internal resource is returned 353 destination = ((u8 *) aml) + info->aml_offset;
263 * 354
264 * RETURN: Status 355 switch (info->opcode) {
265 * 356 case ACPI_RSC_INITSET:
266 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 357
267 * internal resource descriptor, simplifying bitflags and handling 358 ACPI_MEMSET(aml, 0, INIT_RESOURCE_LENGTH(info));
268 * alignment and endian issues if necessary. 359 aml_length = INIT_RESOURCE_LENGTH(info);
269 * 360 acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
270 ******************************************************************************/ 361 aml_length, aml);
271 362 break;
272acpi_status 363
273acpi_rs_get_start_dpf(union aml_resource *aml, 364 case ACPI_RSC_INITGET:
274 u16 aml_resource_length, struct acpi_resource *resource) 365 break;
275{ 366
276 ACPI_FUNCTION_TRACE("rs_get_start_dpf"); 367 case ACPI_RSC_FLAGINIT:
277 368 /*
278 /* Get the flags byte if present */ 369 * Clear the flag byte
279 370 */
280 if (aml_resource_length == 1) { 371 *((u8 *) destination) = 0;
281 /* Get the Compatibility priority */ 372 break;
282 373
283 resource->data.start_dpf.compatibility_priority = 374 case ACPI_RSC_1BITFLAG:
284 (aml->start_dpf.flags & 0x03); 375 /*
285 376 * Mask and shift the flag bit
286 if (resource->data.start_dpf.compatibility_priority >= 3) { 377 */
287 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 378 *((u8 *) destination) |= (u8)
288 } 379 ((*((u8 *) source) & 0x01) << info->value);
289 380 break;
290 /* Get the Performance/Robustness preference */ 381
291 382 case ACPI_RSC_2BITFLAG:
292 resource->data.start_dpf.performance_robustness = 383 /*
293 ((aml->start_dpf.flags >> 2) & 0x03); 384 * Mask and shift the flag bits
294 385 */
295 if (resource->data.start_dpf.performance_robustness >= 3) { 386 *((u8 *) destination) |= (u8)
296 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 387 ((*((u8 *) source) & 0x03) << info->value);
388 break;
389
390 case ACPI_RSC_COUNT:
391
392 item_count = *((u8 *) source);
393 *((u8 *) destination) = (u8) item_count;
394
395 aml_length = (u16) (aml_length +
396 (info->value * (item_count - 1)));
397 break;
398
399 case ACPI_RSC_COUNT16:
400
401 item_count = *((u16 *) source);
402 aml_length = (u16) (aml_length + item_count);
403 acpi_rs_set_resource_length(aml_length, aml);
404 break;
405
406 case ACPI_RSC_LENGTH:
407
408 acpi_rs_set_resource_length(info->value, aml);
409 break;
410
411 case ACPI_RSC_MOVE8:
412 case ACPI_RSC_MOVE16:
413 case ACPI_RSC_MOVE32:
414 case ACPI_RSC_MOVE64:
415
416 if (info->value) {
417 item_count = info->value;
418 }
419 acpi_rs_move_data(destination, source, item_count,
420 info->opcode);
421 break;
422
423 case ACPI_RSC_ADDRESS:
424
425 /* Set the Resource Type, General Flags, and Type-Specific Flags */
426
427 acpi_rs_set_address_common(aml, resource);
428 break;
429
430 case ACPI_RSC_SOURCEX:
431 /*
432 * Optional resource_source (Index and String)
433 */
434 aml_length =
435 acpi_rs_set_resource_source(aml,
436 (acpi_rs_length)
437 aml_length, source);
438 acpi_rs_set_resource_length(aml_length, aml);
439 break;
440
441 case ACPI_RSC_SOURCE:
442 /*
443 * Optional resource_source (Index and String). This is the more
444 * complicated case used by the Interrupt() macro
445 */
446 aml_length =
447 acpi_rs_set_resource_source(aml, info->value,
448 source);
449 acpi_rs_set_resource_length(aml_length, aml);
450 break;
451
452 case ACPI_RSC_BITMASK:
453 /*
454 * 8-bit encoded bitmask (DMA macro)
455 */
456 *((u8 *) destination) = (u8)
457 acpi_rs_encode_bitmask(source,
458 *(((u8 *) resource) +
459 info->value));
460 break;
461
462 case ACPI_RSC_BITMASK16:
463 /*
464 * 16-bit encoded bitmask (IRQ macro)
465 */
466 temp16 =
467 acpi_rs_encode_bitmask(source,
468 *(((u8 *) resource) +
469 info->value));
470 ACPI_MOVE_16_TO_16(destination, &temp16);
471 break;
472
473 case ACPI_RSC_EXIT_LE:
474 /*
475 * Control - Exit conversion if less than or equal
476 */
477 if (item_count <= info->value) {
478 goto exit;
479 }
480 break;
481
482 case ACPI_RSC_EXIT_NE:
483 /*
484 * Control - Exit conversion if not equal
485 */
486 switch (COMPARE_OPCODE(info)) {
487 case ACPI_RSC_COMPARE_VALUE:
488 if (*
489 ((u8 *) (((u8 *) resource) +
490 COMPARE_TARGET(info))) !=
491 COMPARE_VALUE(info)) {
492 goto exit;
493 }
494 break;
495
496 default:
497 acpi_os_printf
498 ("*** Invalid conversion sub-opcode\n");
499 return_ACPI_STATUS(AE_BAD_PARAMETER);
500 }
501 break;
502
503 default:
504
505 acpi_os_printf("*** Invalid conversion opcode\n");
506 return_ACPI_STATUS(AE_BAD_PARAMETER);
297 } 507 }
298 } else {
299 /* start_dependent_no_pri(), no flags byte, set defaults */
300
301 resource->data.start_dpf.compatibility_priority =
302 ACPI_ACCEPTABLE_CONFIGURATION;
303 508
304 resource->data.start_dpf.performance_robustness = 509 count--;
305 ACPI_ACCEPTABLE_CONFIGURATION; 510 info++;
306 } 511 }
307 512
308 /* Complete the resource header */ 513 exit:
309
310 resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT;
311 resource->length =
312 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent);
313 return_ACPI_STATUS(AE_OK); 514 return_ACPI_STATUS(AE_OK);
314} 515}
315 516
316/******************************************************************************* 517#if 0
317 * 518/* Previous resource validations */
318 * FUNCTION: acpi_rs_set_start_dpf
319 *
320 * PARAMETERS: Resource - Pointer to the resource descriptor
321 * Aml - Where the AML descriptor is returned
322 *
323 * RETURN: Status
324 *
325 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
326 * external AML resource descriptor.
327 *
328 ******************************************************************************/
329
330acpi_status
331acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml)
332{
333 ACPI_FUNCTION_TRACE("rs_set_start_dpf");
334 519
335 /* 520if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
336 * The descriptor type field is set based upon whether a byte is needed 521 return_ACPI_STATUS(AE_SUPPORT);
337 * to contain Priority data.
338 */
339 if (ACPI_ACCEPTABLE_CONFIGURATION ==
340 resource->data.start_dpf.compatibility_priority &&
341 ACPI_ACCEPTABLE_CONFIGURATION ==
342 resource->data.start_dpf.performance_robustness) {
343 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
344 sizeof(struct
345 aml_resource_start_dependent_noprio),
346 aml);
347 } else {
348 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
349 sizeof(struct
350 aml_resource_start_dependent),
351 aml);
352
353 /* Set the Flags byte */
354
355 aml->start_dpf.flags = (u8)
356 (((resource->data.start_dpf.
357 performance_robustness & 0x03) << 2) | (resource->data.
358 start_dpf.
359 compatibility_priority
360 & 0x03));
361 }
362 return_ACPI_STATUS(AE_OK);
363} 522}
364 523
365/******************************************************************************* 524if (resource->data.start_dpf.performance_robustness >= 3) {
366 * 525 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
367 * FUNCTION: acpi_rs_get_end_dpf
368 *
369 * PARAMETERS: Aml - Pointer to the AML resource descriptor
370 * aml_resource_length - Length of the resource from the AML header
371 * Resource - Where the internal resource is returned
372 *
373 * RETURN: Status
374 *
375 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
376 * internal resource descriptor, simplifying bitflags and handling
377 * alignment and endian issues if necessary.
378 *
379 ******************************************************************************/
380
381acpi_status
382acpi_rs_get_end_dpf(union aml_resource *aml,
383 u16 aml_resource_length, struct acpi_resource *resource)
384{
385 ACPI_FUNCTION_TRACE("rs_get_end_dpf");
386
387 /* Complete the resource header */
388
389 resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT;
390 resource->length = (u32) ACPI_RESOURCE_LENGTH;
391 return_ACPI_STATUS(AE_OK);
392} 526}
393 527
394/******************************************************************************* 528if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
395 * 529 /*
396 * FUNCTION: acpi_rs_set_end_dpf 530 * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
397 * 531 * polarity/trigger interrupts are allowed (ACPI spec, section
398 * PARAMETERS: Resource - Pointer to the resource descriptor 532 * "IRQ Format"), so 0x00 and 0x09 are illegal.
399 * Aml - Where the AML descriptor is returned 533 */
400 * 534 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
401 * RETURN: Status 535 "Invalid interrupt polarity/trigger in resource list, %X\n",
402 * 536 aml->irq.flags));
403 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 537 return_ACPI_STATUS(AE_BAD_DATA);
404 * external AML resource descriptor.
405 *
406 ******************************************************************************/
407
408acpi_status
409acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml)
410{
411 ACPI_FUNCTION_TRACE("rs_set_end_dpf");
412
413 /* Complete the AML descriptor header */
414
415 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT,
416 sizeof(struct aml_resource_end_dependent),
417 aml);
418 return_ACPI_STATUS(AE_OK);
419} 538}
420 539
421/******************************************************************************* 540resource->data.extended_irq.interrupt_count = temp8;
422 * 541if (temp8 < 1) {
423 * FUNCTION: acpi_rs_get_end_tag 542 /* Must have at least one IRQ */
424 *
425 * PARAMETERS: Aml - Pointer to the AML resource descriptor
426 * aml_resource_length - Length of the resource from the AML header
427 * Resource - Where the internal resource is returned
428 *
429 * RETURN: Status
430 *
431 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
432 * internal resource descriptor, simplifying bitflags and handling
433 * alignment and endian issues if necessary.
434 *
435 ******************************************************************************/
436
437acpi_status
438acpi_rs_get_end_tag(union aml_resource *aml,
439 u16 aml_resource_length, struct acpi_resource *resource)
440{
441 ACPI_FUNCTION_TRACE("rs_get_end_tag");
442
443 /* Complete the resource header */
444 543
445 resource->type = ACPI_RESOURCE_TYPE_END_TAG; 544 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
446 resource->length = ACPI_RESOURCE_LENGTH;
447 return_ACPI_STATUS(AE_OK);
448} 545}
449 546
450/******************************************************************************* 547if (resource->data.dma.transfer == 0x03) {
451 * 548 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
452 * FUNCTION: acpi_rs_set_end_tag 549 "Invalid DMA.Transfer preference (3)\n"));
453 * 550 return_ACPI_STATUS(AE_BAD_DATA);
454 * PARAMETERS: Resource - Pointer to the resource descriptor
455 * Aml - Where the AML descriptor is returned
456 *
457 * RETURN: Status
458 *
459 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
460 * external AML resource descriptor.
461 *
462 ******************************************************************************/
463
464acpi_status
465acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml)
466{
467 ACPI_FUNCTION_TRACE("rs_set_end_tag");
468
469 /*
470 * Set the Checksum - zero means that the resource data is treated as if
471 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
472 */
473 aml->end_tag.checksum = 0;
474
475 /* Complete the AML descriptor header */
476
477 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG,
478 sizeof(struct aml_resource_end_tag), aml);
479 return_ACPI_STATUS(AE_OK);
480} 551}
552#endif
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 9d503de1a349..7613033f5dcf 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -50,6 +50,64 @@ ACPI_MODULE_NAME("rsutils")
50 50
51/******************************************************************************* 51/*******************************************************************************
52 * 52 *
53 * FUNCTION: acpi_rs_decode_bitmask
54 *
55 * PARAMETERS: Mask - Bitmask to decode
56 * List - Where the converted list is returned
57 *
58 * RETURN: Count of bits set (length of list)
59 *
60 * DESCRIPTION: Convert a bit mask into a list of values
61 *
62 ******************************************************************************/
63u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
64{
65 acpi_native_uint i;
66 u8 bit_count;
67
68 /* Decode the mask bits */
69
70 for (i = 0, bit_count = 0; mask; i++) {
71 if (mask & 0x0001) {
72 list[bit_count] = (u8) i;
73 bit_count++;
74 }
75
76 mask >>= 1;
77 }
78
79 return (bit_count);
80}
81
82/*******************************************************************************
83 *
84 * FUNCTION: acpi_rs_encode_bitmask
85 *
86 * PARAMETERS: List - List of values to encode
87 * Count - Length of list
88 *
89 * RETURN: Encoded bitmask
90 *
91 * DESCRIPTION: Convert a list of values to an encoded bitmask
92 *
93 ******************************************************************************/
94
95u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
96{
97 acpi_native_uint i;
98 u16 mask;
99
100 /* Encode the list into a single bitmask */
101
102 for (i = 0, mask = 0; i < count; i++) {
103 mask |= (0x0001 << list[i]);
104 }
105
106 return (mask);
107}
108
109/*******************************************************************************
110 *
53 * FUNCTION: acpi_rs_move_data 111 * FUNCTION: acpi_rs_move_data
54 * 112 *
55 * PARAMETERS: Destination - Pointer to the destination descriptor 113 * PARAMETERS: Destination - Pointer to the destination descriptor
@@ -64,6 +122,7 @@ ACPI_MODULE_NAME("rsutils")
64 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 122 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
65 * 123 *
66 ******************************************************************************/ 124 ******************************************************************************/
125
67void 126void
68acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) 127acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
69{ 128{
@@ -73,22 +132,30 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
73 132
74 for (i = 0; i < item_count; i++) { 133 for (i = 0; i < item_count; i++) {
75 switch (move_type) { 134 switch (move_type) {
76 case ACPI_MOVE_TYPE_16_TO_32: 135 /*
77 ACPI_MOVE_16_TO_32(&((u32 *) destination)[i], 136 * For the 8-bit case, we can perform the move all at once
78 &((u16 *) source)[i]); 137 * since there are no alignment or endian issues
79 break; 138 */
139 case ACPI_RSC_MOVE8:
140 ACPI_MEMCPY(destination, source, item_count);
141 return;
80 142
81 case ACPI_MOVE_TYPE_32_TO_16: 143 /*
82 ACPI_MOVE_32_TO_16(&((u16 *) destination)[i], 144 * 16-, 32-, and 64-bit cases must use the move macros that perform
83 &((u32 *) source)[i]); 145 * endian conversion and/or accomodate hardware that cannot perform
146 * misaligned memory transfers
147 */
148 case ACPI_RSC_MOVE16:
149 ACPI_MOVE_16_TO_16(&((u16 *) destination)[i],
150 &((u16 *) source)[i]);
84 break; 151 break;
85 152
86 case ACPI_MOVE_TYPE_32_TO_32: 153 case ACPI_RSC_MOVE32:
87 ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], 154 ACPI_MOVE_32_TO_32(&((u32 *) destination)[i],
88 &((u32 *) source)[i]); 155 &((u32 *) source)[i]);
89 break; 156 break;
90 157
91 case ACPI_MOVE_TYPE_64_TO_64: 158 case ACPI_RSC_MOVE64:
92 ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], 159 ACPI_MOVE_64_TO_64(&((u64 *) destination)[i],
93 &((u64 *) source)[i]); 160 &((u64 *) source)[i]);
94 break; 161 break;
@@ -148,80 +215,57 @@ struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type)
148 215
149/******************************************************************************* 216/*******************************************************************************
150 * 217 *
151 * FUNCTION: acpi_rs_get_resource_length 218 * FUNCTION: acpi_rs_set_resource_length
152 * 219 *
153 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 220 * PARAMETERS: total_length - Length of the AML descriptor, including
221 * the header and length fields.
222 * Aml - Pointer to the raw AML descriptor
154 * 223 *
155 * RETURN: Byte Length 224 * RETURN: None
156 * 225 *
157 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 226 * DESCRIPTION: Set the resource_length field of an AML
158 * definition, this does not include the size of the descriptor 227 * resource descriptor, both Large and Small descriptors are
159 * header or the length field itself. 228 * supported automatically. Note: Descriptor Type field must
229 * be valid.
160 * 230 *
161 ******************************************************************************/ 231 ******************************************************************************/
162 232
163u16 acpi_rs_get_resource_length(union aml_resource * aml) 233void
234acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
235 union aml_resource *aml)
164{ 236{
165 u16 resource_length; 237 acpi_rs_length resource_length;
166 238
167 ACPI_FUNCTION_ENTRY(); 239 ACPI_FUNCTION_ENTRY();
168 240
169 /* Determine if this is a small or large resource */ 241 /* Determine if this is a small or large resource */
170 242
171 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 243 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
172 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 244 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
173 245
174 ACPI_MOVE_16_TO_16(&resource_length, 246 resource_length = (acpi_rs_length)
175 &aml->large_header.resource_length); 247 (total_length - sizeof(struct aml_resource_large_header));
248
249 /* Insert length into the Large descriptor length field */
176 250
251 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
252 &resource_length);
177 } else { 253 } else {
178 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 254 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
179 255
180 resource_length = (u16) (aml->small_header.descriptor_type & 256 resource_length = (acpi_rs_length)
181 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 257 (total_length - sizeof(struct aml_resource_small_header));
182 }
183
184 return (resource_length);
185}
186 258
187/******************************************************************************* 259 /* Insert length into the descriptor type byte */
188 *
189 * FUNCTION: acpi_rs_get_descriptor_length
190 *
191 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
192 *
193 * RETURN: Byte length
194 *
195 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
196 * length of the descriptor header and the length field itself.
197 * Used to walk descriptor lists.
198 *
199 ******************************************************************************/
200
201u32 acpi_rs_get_descriptor_length(union aml_resource * aml)
202{
203 u32 descriptor_length;
204
205 ACPI_FUNCTION_ENTRY();
206
207 /* Determine if this is a small or large resource */
208
209 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
210 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
211 260
212 ACPI_MOVE_16_TO_32(&descriptor_length, 261 aml->small_header.descriptor_type = (u8)
213 &aml->large_header.resource_length);
214 descriptor_length += sizeof(struct aml_resource_large_header);
215 262
216 } else { 263 /* Clear any existing length, preserving descriptor type bits */
217 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 264 ((aml->small_header.
265 descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
218 266
219 descriptor_length = (u32) (aml->small_header.descriptor_type & 267 | resource_length);
220 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
221 descriptor_length += sizeof(struct aml_resource_small_header);
222 } 268 }
223
224 return (descriptor_length);
225} 269}
226 270
227/******************************************************************************* 271/*******************************************************************************
@@ -243,71 +287,18 @@ u32 acpi_rs_get_descriptor_length(union aml_resource * aml)
243 287
244void 288void
245acpi_rs_set_resource_header(u8 descriptor_type, 289acpi_rs_set_resource_header(u8 descriptor_type,
246 acpi_size total_length, union aml_resource *aml) 290 acpi_rsdesc_size total_length,
291 union aml_resource *aml)
247{ 292{
248 u16 resource_length;
249
250 ACPI_FUNCTION_ENTRY(); 293 ACPI_FUNCTION_ENTRY();
251 294
252 /* Set the descriptor type */ 295 /* Set the Descriptor Type */
253 296
254 aml->small_header.descriptor_type = descriptor_type; 297 aml->small_header.descriptor_type = descriptor_type;
255 298
256 /* Determine if this is a small or large resource */ 299 /* Set the Resource Length */
257
258 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
259 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
260
261 resource_length =
262 (u16) (total_length -
263 sizeof(struct aml_resource_large_header));
264
265 /* Insert length into the Large descriptor length field */
266
267 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
268 &resource_length);
269 } else {
270 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
271
272 resource_length =
273 (u16) (total_length -
274 sizeof(struct aml_resource_small_header));
275
276 /* Insert length into the descriptor type byte */
277
278 aml->small_header.descriptor_type |= (u8) resource_length;
279 }
280}
281
282/*******************************************************************************
283 *
284 * FUNCTION: acpi_rs_get_resource_type
285 *
286 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
287 *
288 * RETURN: The Resource Type with no extraneous bits (except the
289 * Large/Small descriptor bit -- this is left alone)
290 *
291 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
292 * a resource descriptor.
293 *
294 ******************************************************************************/
295
296u8 acpi_rs_get_resource_type(u8 resource_type)
297{
298 ACPI_FUNCTION_ENTRY();
299 300
300 /* Determine if this is a small or large resource */ 301 acpi_rs_set_resource_length(total_length, aml);
301
302 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
303 /* Large Resource Type -- bits 6:0 contain the name */
304
305 return (resource_type);
306 } else {
307 /* Small Resource Type -- bits 6:3 contain the name */
308
309 return ((u8) (resource_type & ACPI_RESOURCE_NAME_SMALL_MASK));
310 }
311} 302}
312 303
313/******************************************************************************* 304/*******************************************************************************
@@ -360,13 +351,13 @@ static u16 acpi_rs_strcpy(char *destination, char *source)
360 * 351 *
361 ******************************************************************************/ 352 ******************************************************************************/
362 353
363u16 354acpi_rs_length
364acpi_rs_get_resource_source(u16 resource_length, 355acpi_rs_get_resource_source(acpi_rs_length resource_length,
365 acpi_size minimum_length, 356 acpi_rs_length minimum_length,
366 struct acpi_resource_source * resource_source, 357 struct acpi_resource_source * resource_source,
367 union aml_resource * aml, char *string_ptr) 358 union aml_resource * aml, char *string_ptr)
368{ 359{
369 acpi_size total_length; 360 acpi_rsdesc_size total_length;
370 u8 *aml_resource_source; 361 u8 *aml_resource_source;
371 362
372 ACPI_FUNCTION_ENTRY(); 363 ACPI_FUNCTION_ENTRY();
@@ -382,7 +373,7 @@ acpi_rs_get_resource_source(u16 resource_length,
382 * Note: Some resource descriptors will have an additional null, so 373 * Note: Some resource descriptors will have an additional null, so
383 * we add 1 to the minimum length. 374 * we add 1 to the minimum length.
384 */ 375 */
385 if (total_length > (minimum_length + 1)) { 376 if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
386 /* Get the resource_source_index */ 377 /* Get the resource_source_index */
387 378
388 resource_source->index = aml_resource_source[0]; 379 resource_source->index = aml_resource_source[0];
@@ -398,20 +389,26 @@ acpi_rs_get_resource_source(u16 resource_length,
398 sizeof(struct acpi_resource_source); 389 sizeof(struct acpi_resource_source);
399 } 390 }
400 391
392 /*
393 * In order for the struct_size to fall on a 32-bit boundary, calculate
394 * the length of the string (+1 for the NULL terminator) and expand the
395 * struct_size to the next 32-bit boundary.
396 *
397 * Zero the entire area of the buffer.
398 */
399 total_length =
400 ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN
401 ((char *)&aml_resource_source[1]) +
402 1);
403 ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
404
401 /* Copy the resource_source string to the destination */ 405 /* Copy the resource_source string to the destination */
402 406
403 resource_source->string_length = 407 resource_source->string_length =
404 acpi_rs_strcpy(resource_source->string_ptr, 408 acpi_rs_strcpy(resource_source->string_ptr,
405 (char *)&aml_resource_source[1]); 409 (char *)&aml_resource_source[1]);
406 410
407 /* 411 return ((acpi_rs_length) total_length);
408 * In order for the struct_size to fall on a 32-bit boundary,
409 * calculate the length of the string and expand the
410 * struct_size to the next 32-bit boundary.
411 */
412 return ((u16)
413 ACPI_ROUND_UP_to_32_bITS(resource_source->
414 string_length));
415 } else { 412 } else {
416 /* resource_source is not present */ 413 /* resource_source is not present */
417 414
@@ -434,18 +431,18 @@ acpi_rs_get_resource_source(u16 resource_length,
434 * 431 *
435 * RETURN: Total length of the AML descriptor 432 * RETURN: Total length of the AML descriptor
436 * 433 *
437 * DESCRIPTION: Convert an optoinal resource_source from internal format to a 434 * DESCRIPTION: Convert an optional resource_source from internal format to a
438 * raw AML resource descriptor 435 * raw AML resource descriptor
439 * 436 *
440 ******************************************************************************/ 437 ******************************************************************************/
441 438
442acpi_size 439acpi_rsdesc_size
443acpi_rs_set_resource_source(union aml_resource * aml, 440acpi_rs_set_resource_source(union aml_resource * aml,
444 acpi_size minimum_length, 441 acpi_rs_length minimum_length,
445 struct acpi_resource_source * resource_source) 442 struct acpi_resource_source * resource_source)
446{ 443{
447 u8 *aml_resource_source; 444 u8 *aml_resource_source;
448 acpi_size descriptor_length; 445 acpi_rsdesc_size descriptor_length;
449 446
450 ACPI_FUNCTION_ENTRY(); 447 ACPI_FUNCTION_ENTRY();
451 448
@@ -472,7 +469,7 @@ acpi_rs_set_resource_source(union aml_resource * aml,
472 * final descriptor length 469 * final descriptor length
473 */ 470 */
474 descriptor_length += 471 descriptor_length +=
475 ((acpi_size) resource_source->string_length + 1); 472 ((acpi_rsdesc_size) resource_source->string_length + 1);
476 } 473 }
477 474
478 /* Return the new total length of the AML descriptor */ 475 /* Return the new total length of the AML descriptor */
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index 9d179beb17ae..09d250ab9872 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -57,7 +57,7 @@ ACPI_MODULE_NAME("rsxface")
57 ACPI_COPY_FIELD(out, in, decode); \ 57 ACPI_COPY_FIELD(out, in, decode); \
58 ACPI_COPY_FIELD(out, in, min_address_fixed); \ 58 ACPI_COPY_FIELD(out, in, min_address_fixed); \
59 ACPI_COPY_FIELD(out, in, max_address_fixed); \ 59 ACPI_COPY_FIELD(out, in, max_address_fixed); \
60 ACPI_COPY_FIELD(out, in, attribute); \ 60 ACPI_COPY_FIELD(out, in, info); \
61 ACPI_COPY_FIELD(out, in, granularity); \ 61 ACPI_COPY_FIELD(out, in, granularity); \
62 ACPI_COPY_FIELD(out, in, minimum); \ 62 ACPI_COPY_FIELD(out, in, minimum); \
63 ACPI_COPY_FIELD(out, in, maximum); \ 63 ACPI_COPY_FIELD(out, in, maximum); \
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 4b2fbb592f49..e6dfe688b76b 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -94,9 +94,8 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
94 new_table_desc->pointer->length) 94 new_table_desc->pointer->length)
95 && 95 &&
96 (!ACPI_MEMCMP 96 (!ACPI_MEMCMP
97 ((const char *)table_desc->pointer, 97 (table_desc->pointer, new_table_desc->pointer,
98 (const char *)new_table_desc->pointer, 98 new_table_desc->pointer->length))) {
99 (acpi_size) new_table_desc->pointer->length))) {
100 /* Match: this table is already installed */ 99 /* Match: this table is already installed */
101 100
102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 101 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index dc7f24b3a1c0..e04b6119a4d7 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -866,7 +866,7 @@ void acpi_ut_dump_allocations(u32 component, char *module)
866 866
867 if (!num_outstanding) { 867 if (!num_outstanding) {
868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
869 "No outstanding allocations.\n")); 869 "No outstanding allocations\n"));
870 } else { 870 } else {
871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
872 "%d(%X) Outstanding allocations\n", 872 "%d(%X) Outstanding allocations\n",
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 7f72839841ca..413e1dd8ae36 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -217,23 +217,23 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
218 * perform a Notify() operation on it. 218 * perform a Notify() operation on it.
219 */ 219 */
220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = 220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
221 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 221 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
222{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 222 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
223{"_SB_", ACPI_TYPE_DEVICE, NULL}, 223 {"_SB_", ACPI_TYPE_DEVICE, NULL},
224{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 224 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
225{"_TZ_", ACPI_TYPE_THERMAL, NULL}, 225 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
226{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, 226 {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
227{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 227 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
228{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, 228 {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
229 229
230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
231{"_OSI", ACPI_TYPE_METHOD, (char *)1}, 231 {"_OSI", ACPI_TYPE_METHOD, (char *)1},
232#endif 232#endif
233 233
234 /* Table terminator */ 234 /* Table terminator */
235 235
236{NULL, ACPI_TYPE_ANY, NULL} 236 {NULL, ACPI_TYPE_ANY, NULL}
237}; 237};
238 238
239/* 239/*
@@ -503,11 +503,13 @@ char *acpi_ut_get_region_name(u8 space_id)
503/* Event type decoding */ 503/* Event type decoding */
504 504
505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { 505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
506/*! [Begin] no source code translation (keep these strings as-is) */
506 "PM_Timer", 507 "PM_Timer",
507 "global_lock", 508 "GlobalLock",
508 "power_button", 509 "PowerButton",
509 "sleep_button", 510 "SleepButton",
510 "real_time_clock", 511 "RealTimeClock",
512/*! [End] no source code translation !*/
511}; 513};
512 514
513char *acpi_ut_get_event_name(u32 event_id) 515char *acpi_ut_get_event_name(u32 event_id)
@@ -545,12 +547,13 @@ static const char acpi_gbl_bad_type[] = "UNDEFINED";
545/* Printable names of the ACPI object types */ 547/* Printable names of the ACPI object types */
546 548
547static const char *acpi_gbl_ns_type_names[] = { 549static const char *acpi_gbl_ns_type_names[] = {
550/*! [Begin] no source code translation (keep these strings as-is) */
548 /* 00 */ "Untyped", 551 /* 00 */ "Untyped",
549 /* 01 */ "Integer", 552 /* 01 */ "Integer",
550 /* 02 */ "String", 553 /* 02 */ "String",
551 /* 03 */ "Buffer", 554 /* 03 */ "Buffer",
552 /* 04 */ "Package", 555 /* 04 */ "Package",
553 /* 05 */ "field_unit", 556 /* 05 */ "FieldUnit",
554 /* 06 */ "Device", 557 /* 06 */ "Device",
555 /* 07 */ "Event", 558 /* 07 */ "Event",
556 /* 08 */ "Method", 559 /* 08 */ "Method",
@@ -559,23 +562,24 @@ static const char *acpi_gbl_ns_type_names[] = {
559 /* 11 */ "Power", 562 /* 11 */ "Power",
560 /* 12 */ "Processor", 563 /* 12 */ "Processor",
561 /* 13 */ "Thermal", 564 /* 13 */ "Thermal",
562 /* 14 */ "buffer_field", 565 /* 14 */ "BufferField",
563 /* 15 */ "ddb_handle", 566 /* 15 */ "DdbHandle",
564 /* 16 */ "debug_object", 567 /* 16 */ "DebugObject",
565 /* 17 */ "region_field", 568 /* 17 */ "RegionField",
566 /* 18 */ "bank_field", 569 /* 18 */ "BankField",
567 /* 19 */ "index_field", 570 /* 19 */ "IndexField",
568 /* 20 */ "Reference", 571 /* 20 */ "Reference",
569 /* 21 */ "Alias", 572 /* 21 */ "Alias",
570 /* 22 */ "method_alias", 573 /* 22 */ "MethodAlias",
571 /* 23 */ "Notify", 574 /* 23 */ "Notify",
572 /* 24 */ "addr_handler", 575 /* 24 */ "AddrHandler",
573 /* 25 */ "resource_desc", 576 /* 25 */ "ResourceDesc",
574 /* 26 */ "resource_fld", 577 /* 26 */ "ResourceFld",
575 /* 27 */ "Scope", 578 /* 27 */ "Scope",
576 /* 28 */ "Extra", 579 /* 28 */ "Extra",
577 /* 29 */ "Data", 580 /* 29 */ "Data",
578 /* 30 */ "Invalid" 581 /* 30 */ "Invalid"
582/*! [End] no source code translation !*/
579}; 583};
580 584
581char *acpi_ut_get_type_name(acpi_object_type type) 585char *acpi_ut_get_type_name(acpi_object_type type)
@@ -658,15 +662,16 @@ char *acpi_ut_get_node_name(void *object)
658/* Printable names of object descriptor types */ 662/* Printable names of object descriptor types */
659 663
660static const char *acpi_gbl_desc_type_names[] = { 664static const char *acpi_gbl_desc_type_names[] = {
665/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
661 /* 00 */ "Invalid", 666 /* 00 */ "Invalid",
662 /* 01 */ "Cached", 667 /* 01 */ "Cached",
663 /* 02 */ "State-Generic", 668 /* 02 */ "State-Generic",
664 /* 03 */ "State-Update", 669 /* 03 */ "State-Update",
665 /* 04 */ "State-Package", 670 /* 04 */ "State-Package",
666 /* 05 */ "State-Control", 671 /* 05 */ "State-Control",
667 /* 06 */ "State-root_parse_scope", 672 /* 06 */ "State-RootParseScope",
668 /* 07 */ "State-parse_scope", 673 /* 07 */ "State-ParseScope",
669 /* 08 */ "State-walk_scope", 674 /* 08 */ "State-WalkScope",
670 /* 09 */ "State-Result", 675 /* 09 */ "State-Result",
671 /* 10 */ "State-Notify", 676 /* 10 */ "State-Notify",
672 /* 11 */ "State-Thread", 677 /* 11 */ "State-Thread",
@@ -674,6 +679,7 @@ static const char *acpi_gbl_desc_type_names[] = {
674 /* 13 */ "Parser", 679 /* 13 */ "Parser",
675 /* 14 */ "Operand", 680 /* 14 */ "Operand",
676 /* 15 */ "Node" 681 /* 15 */ "Node"
682/*! [End] no source code translation !*/
677}; 683};
678 684
679char *acpi_ut_get_descriptor_name(void *object) 685char *acpi_ut_get_descriptor_name(void *object)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index b57afa7421e8..e9058d4da122 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -43,6 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/amlresrc.h>
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmisc") 49ACPI_MODULE_NAME("utmisc")
@@ -790,48 +791,147 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
790 791
791/******************************************************************************* 792/*******************************************************************************
792 * 793 *
794 * FUNCTION: acpi_ut_get_resource_type
795 *
796 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
797 *
798 * RETURN: The Resource Type with no extraneous bits (except the
799 * Large/Small descriptor bit -- this is left alone)
800 *
801 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
802 * a resource descriptor.
803 *
804 ******************************************************************************/
805
806u8 acpi_ut_get_resource_type(void *aml)
807{
808 ACPI_FUNCTION_ENTRY();
809
810 /*
811 * Byte 0 contains the descriptor name (Resource Type)
812 * Determine if this is a small or large resource
813 */
814 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
815 /* Large Resource Type -- bits 6:0 contain the name */
816
817 return (*((u8 *) aml));
818 } else {
819 /* Small Resource Type -- bits 6:3 contain the name */
820
821 return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
822 }
823}
824
825/*******************************************************************************
826 *
827 * FUNCTION: acpi_ut_get_resource_length
828 *
829 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
830 *
831 * RETURN: Byte Length
832 *
833 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
834 * definition, this does not include the size of the descriptor
835 * header or the length field itself.
836 *
837 ******************************************************************************/
838
839u16 acpi_ut_get_resource_length(void *aml)
840{
841 u16 resource_length;
842
843 ACPI_FUNCTION_ENTRY();
844
845 /*
846 * Byte 0 contains the descriptor name (Resource Type)
847 * Determine if this is a small or large resource
848 */
849 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
850 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
851
852 ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]);
853
854 } else {
855 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
856
857 resource_length = (u16) (*((u8 *) aml) &
858 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
859 }
860
861 return (resource_length);
862}
863
864/*******************************************************************************
865 *
866 * FUNCTION: acpi_ut_get_descriptor_length
867 *
868 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
869 *
870 * RETURN: Byte length
871 *
872 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
873 * length of the descriptor header and the length field itself.
874 * Used to walk descriptor lists.
875 *
876 ******************************************************************************/
877
878u32 acpi_ut_get_descriptor_length(void *aml)
879{
880 u32 descriptor_length;
881
882 ACPI_FUNCTION_ENTRY();
883
884 /* First get the Resource Length (Does not include header length) */
885
886 descriptor_length = acpi_ut_get_resource_length(aml);
887
888 /* Determine if this is a small or large resource */
889
890 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
891 descriptor_length += sizeof(struct aml_resource_large_header);
892 } else {
893 descriptor_length += sizeof(struct aml_resource_small_header);
894 }
895
896 return (descriptor_length);
897}
898
899/*******************************************************************************
900 *
793 * FUNCTION: acpi_ut_get_resource_end_tag 901 * FUNCTION: acpi_ut_get_resource_end_tag
794 * 902 *
795 * PARAMETERS: obj_desc - The resource template buffer object 903 * PARAMETERS: obj_desc - The resource template buffer object
796 * 904 *
797 * RETURN: Pointer to the end tag 905 * RETURN: Pointer to the end tag
798 * 906 *
799 * DESCRIPTION: Find the END_TAG resource descriptor in a resource template 907 * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template
800 * 908 *
801 ******************************************************************************/ 909 ******************************************************************************/
802 910
803u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) 911u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
804{ 912{
805 u8 buffer_byte; 913 u8 *aml;
806 u8 *buffer; 914 u8 *end_aml;
807 u8 *end_buffer;
808
809 buffer = obj_desc->buffer.pointer;
810 end_buffer = buffer + obj_desc->buffer.length;
811 915
812 while (buffer < end_buffer) { 916 aml = obj_desc->buffer.pointer;
813 buffer_byte = *buffer; 917 end_aml = aml + obj_desc->buffer.length;
814 if (buffer_byte & ACPI_RESOURCE_NAME_LARGE) {
815 /* Large Descriptor - Length is next 2 bytes */
816 918
817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); 919 /* Walk the resource template, one descriptor per loop */
818 } else {
819 /* Small Descriptor. End Tag will be found here */
820 920
821 if ((buffer_byte & ACPI_RESOURCE_NAME_SMALL_MASK) == 921 while (aml < end_aml) {
822 ACPI_RESOURCE_NAME_END_TAG) { 922 if (acpi_ut_get_resource_type(aml) ==
823 /* Found the end tag descriptor, all done. */ 923 ACPI_RESOURCE_NAME_END_TAG) {
924 /* Found the end_tag descriptor, all done */
824 925
825 return (buffer); 926 return (aml);
826 } 927 }
827 928
828 /* Length is in the header */ 929 /* Point to the next resource descriptor */
829 930
830 buffer += ((buffer_byte & 0x07) + 1); 931 aml += acpi_ut_get_resource_length(aml);
831 }
832 } 932 }
833 933
834 /* End tag not found */ 934 /* End tag was not found */
835 935
836 return (NULL); 936 return (NULL);
837} 937}