diff options
author | Robert Moore <Robert.Moore@intel.com> | 2005-09-02 17:24:17 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-09-03 00:15:11 -0400 |
commit | aff8c2777d1a9edf97f26bf60579f9c931443eb1 (patch) | |
tree | fcd5bfe84e0e3aeb328d60ec41776522b9b7d122 /drivers/acpi/resources/rsaddr.c | |
parent | a94f18810f52d3a6de0a09bee0c7258b62eca262 (diff) |
[ACPI] ACPICA 20050902
Fixed a problem with the internal Owner ID allocation and
deallocation mechanisms for control method execution and
recursive method invocation. This should eliminate the
OWNER_ID_LIMIT exceptions and "Invalid OwnerId" messages
seen on some systems. Recursive method invocation depth
is currently limited to 255. (Alexey Starikovskiy)
http://bugzilla.kernel.org/show_bug.cgi?id=4892
Completely eliminated all vestiges of support for the
"module-level executable code" until this support is
fully implemented and debugged. This should eliminate the
NO_RETURN_VALUE exceptions seen during table load on some
systems that invoke this support.
http://bugzilla.kernel.org/show_bug.cgi?id=5162
Fixed a problem within the resource manager code where
the transaction flags for a 64-bit address descriptor were
handled incorrectly in the type-specific flag byte.
Consolidated duplicate code within the address descriptor
resource manager code, reducing overall subsystem code size.
Signed-off-by: Robert Moore <Robert.Moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources/rsaddr.c')
-rw-r--r-- | drivers/acpi/resources/rsaddr.c | 542 |
1 files changed, 257 insertions, 285 deletions
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 4cf46e1ee01b..23b54baa0cb2 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c | |||
@@ -47,6 +47,180 @@ | |||
47 | #define _COMPONENT ACPI_RESOURCES | 47 | #define _COMPONENT ACPI_RESOURCES |
48 | ACPI_MODULE_NAME("rsaddr") | 48 | ACPI_MODULE_NAME("rsaddr") |
49 | 49 | ||
50 | /* Local prototypes */ | ||
51 | static void | ||
52 | acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags); | ||
53 | |||
54 | static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource); | ||
55 | |||
56 | static void | ||
57 | acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags); | ||
58 | |||
59 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); | ||
60 | |||
61 | /******************************************************************************* | ||
62 | * | ||
63 | * FUNCTION: acpi_rs_decode_general_flags | ||
64 | * | ||
65 | * PARAMETERS: Resource - Address resource data struct | ||
66 | * Flags - Actual flag byte | ||
67 | * | ||
68 | * RETURN: Decoded flag bits in resource struct | ||
69 | * | ||
70 | * DESCRIPTION: Decode a general flag byte to an address resource struct | ||
71 | * | ||
72 | ******************************************************************************/ | ||
73 | |||
74 | static void | ||
75 | acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) | ||
76 | { | ||
77 | ACPI_FUNCTION_ENTRY(); | ||
78 | |||
79 | /* Producer / Consumer - flag bit[0] */ | ||
80 | |||
81 | resource->address.producer_consumer = (u32) (flags & 0x01); | ||
82 | |||
83 | /* Decode (_DEC) - flag bit[1] */ | ||
84 | |||
85 | resource->address.decode = (u32) ((flags >> 1) & 0x01); | ||
86 | |||
87 | /* Min Address Fixed (_MIF) - flag bit[2] */ | ||
88 | |||
89 | resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01); | ||
90 | |||
91 | /* Max Address Fixed (_MAF) - flag bit[3] */ | ||
92 | |||
93 | resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01); | ||
94 | } | ||
95 | |||
96 | /******************************************************************************* | ||
97 | * | ||
98 | * FUNCTION: acpi_rs_encode_general_flags | ||
99 | * | ||
100 | * PARAMETERS: Resource - Address resource data struct | ||
101 | * | ||
102 | * RETURN: Encoded general flag byte | ||
103 | * | ||
104 | * DESCRIPTION: Construct a general flag byte from an address resource struct | ||
105 | * | ||
106 | ******************************************************************************/ | ||
107 | |||
108 | static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) | ||
109 | { | ||
110 | u8 flags; | ||
111 | |||
112 | ACPI_FUNCTION_ENTRY(); | ||
113 | |||
114 | /* Producer / Consumer - flag bit[0] */ | ||
115 | |||
116 | flags = (u8) (resource->address.producer_consumer & 0x01); | ||
117 | |||
118 | /* Decode (_DEC) - flag bit[1] */ | ||
119 | |||
120 | flags |= (u8) ((resource->address.decode & 0x01) << 1); | ||
121 | |||
122 | /* Min Address Fixed (_MIF) - flag bit[2] */ | ||
123 | |||
124 | flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); | ||
125 | |||
126 | /* Max Address Fixed (_MAF) - flag bit[3] */ | ||
127 | |||
128 | flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); | ||
129 | |||
130 | return (flags); | ||
131 | } | ||
132 | |||
133 | /******************************************************************************* | ||
134 | * | ||
135 | * FUNCTION: acpi_rs_decode_specific_flags | ||
136 | * | ||
137 | * PARAMETERS: Resource - Address resource data struct | ||
138 | * Flags - Actual 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 | * | ||
146 | ******************************************************************************/ | ||
147 | |||
148 | static void | ||
149 | acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) | ||
150 | { | ||
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 | |||
159 | /* Memory Attributes (_MEM) - flag bits[2:1] */ | ||
160 | |||
161 | resource->address.attribute.memory.cache_attribute = | ||
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 | |||
190 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) | ||
191 | { | ||
192 | u8 flags = 0; | ||
193 | |||
194 | ACPI_FUNCTION_ENTRY(); | ||
195 | |||
196 | if (resource->address.resource_type == ACPI_MEMORY_RANGE) { | ||
197 | /* Write Status (_RW) - flag bit[0] */ | ||
198 | |||
199 | flags = (u8) | ||
200 | (resource->address.attribute.memory. | ||
201 | read_write_attribute & 0x01); | ||
202 | |||
203 | /* Memory Attributes (_MEM) - flag bits[2:1] */ | ||
204 | |||
205 | flags |= (u8) | ||
206 | ((resource->address.attribute.memory. | ||
207 | cache_attribute & 0x03) << 1); | ||
208 | } else if (resource->address.resource_type == ACPI_IO_RANGE) { | ||
209 | /* Ranges (_RNG) - flag bits[1:0] */ | ||
210 | |||
211 | flags = (u8) | ||
212 | (resource->address.attribute.io.range_attribute & 0x03); | ||
213 | |||
214 | /* Translations (_TTP and _TRS) - flag bits[5:4] */ | ||
215 | |||
216 | flags |= (u8) | ||
217 | ((resource->address.attribute.io. | ||
218 | translation_attribute & 0x03) << 4); | ||
219 | } | ||
220 | |||
221 | return (flags); | ||
222 | } | ||
223 | |||
50 | /******************************************************************************* | 224 | /******************************************************************************* |
51 | * | 225 | * |
52 | * FUNCTION: acpi_rs_address16_resource | 226 | * FUNCTION: acpi_rs_address16_resource |
@@ -67,6 +241,7 @@ ACPI_MODULE_NAME("rsaddr") | |||
67 | * number of bytes consumed from the byte stream. | 241 | * number of bytes consumed from the byte stream. |
68 | * | 242 | * |
69 | ******************************************************************************/ | 243 | ******************************************************************************/ |
244 | |||
70 | acpi_status | 245 | acpi_status |
71 | acpi_rs_address16_resource(u8 * byte_stream_buffer, | 246 | acpi_rs_address16_resource(u8 * byte_stream_buffer, |
72 | acpi_size * bytes_consumed, | 247 | acpi_size * bytes_consumed, |
@@ -83,7 +258,7 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, | |||
83 | 258 | ||
84 | ACPI_FUNCTION_TRACE("rs_address16_resource"); | 259 | ACPI_FUNCTION_TRACE("rs_address16_resource"); |
85 | 260 | ||
86 | /* Point past the Descriptor to get the number of bytes consumed */ | 261 | /* Get the Descriptor Length field */ |
87 | 262 | ||
88 | buffer += 1; | 263 | buffer += 1; |
89 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 264 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
@@ -113,46 +288,12 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, | |||
113 | /* Get the General Flags (Byte4) */ | 288 | /* Get the General Flags (Byte4) */ |
114 | 289 | ||
115 | buffer += 1; | 290 | buffer += 1; |
116 | temp8 = *buffer; | 291 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); |
117 | |||
118 | /* Producer / Consumer */ | ||
119 | |||
120 | output_struct->data.address16.producer_consumer = temp8 & 0x01; | ||
121 | |||
122 | /* Decode */ | ||
123 | |||
124 | output_struct->data.address16.decode = (temp8 >> 1) & 0x01; | ||
125 | |||
126 | /* Min Address Fixed */ | ||
127 | |||
128 | output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01; | ||
129 | |||
130 | /* Max Address Fixed */ | ||
131 | |||
132 | output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01; | ||
133 | 292 | ||
134 | /* Get the Type Specific Flags (Byte5) */ | 293 | /* Get the Type Specific Flags (Byte5) */ |
135 | 294 | ||
136 | buffer += 1; | 295 | buffer += 1; |
137 | temp8 = *buffer; | 296 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); |
138 | |||
139 | if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) { | ||
140 | output_struct->data.address16.attribute.memory. | ||
141 | read_write_attribute = (u16) (temp8 & 0x01); | ||
142 | output_struct->data.address16.attribute.memory.cache_attribute = | ||
143 | (u16) ((temp8 >> 1) & 0x03); | ||
144 | } else { | ||
145 | if (ACPI_IO_RANGE == | ||
146 | output_struct->data.address16.resource_type) { | ||
147 | output_struct->data.address16.attribute.io. | ||
148 | range_attribute = (u16) (temp8 & 0x03); | ||
149 | output_struct->data.address16.attribute.io. | ||
150 | translation_attribute = (u16) ((temp8 >> 4) & 0x03); | ||
151 | } else { | ||
152 | /* BUS_NUMBER_RANGE == Address16.Data->resource_type */ | ||
153 | /* Nothing needs to be filled in */ | ||
154 | } | ||
155 | } | ||
156 | 297 | ||
157 | /* Get Granularity (Bytes 6-7) */ | 298 | /* Get Granularity (Bytes 6-7) */ |
158 | 299 | ||
@@ -200,9 +341,8 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, | |||
200 | if (*bytes_consumed > (16 + 1)) { | 341 | if (*bytes_consumed > (16 + 1)) { |
201 | /* Dereference the Index */ | 342 | /* Dereference the Index */ |
202 | 343 | ||
203 | temp8 = *buffer; | ||
204 | output_struct->data.address16.resource_source.index = | 344 | output_struct->data.address16.resource_source.index = |
205 | (u32) temp8; | 345 | (u32) * buffer; |
206 | 346 | ||
207 | /* Point to the String */ | 347 | /* Point to the String */ |
208 | 348 | ||
@@ -216,22 +356,20 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, | |||
216 | temp_ptr = (u8 *) | 356 | temp_ptr = (u8 *) |
217 | output_struct->data.address16.resource_source.string_ptr; | 357 | output_struct->data.address16.resource_source.string_ptr; |
218 | 358 | ||
219 | /* Copy the string into the buffer */ | 359 | /* Copy the resource_source string into the buffer */ |
220 | 360 | ||
221 | index = 0; | 361 | index = 0; |
222 | 362 | while (*buffer) { | |
223 | while (0x00 != *buffer) { | ||
224 | *temp_ptr = *buffer; | 363 | *temp_ptr = *buffer; |
225 | 364 | ||
226 | temp_ptr += 1; | 365 | temp_ptr++; |
227 | buffer += 1; | 366 | buffer++; |
228 | index += 1; | 367 | index++; |
229 | } | 368 | } |
230 | 369 | ||
231 | /* Add the terminating null */ | 370 | /* Add the terminating null and set the string length */ |
232 | |||
233 | *temp_ptr = 0x00; | ||
234 | 371 | ||
372 | *temp_ptr = 0; | ||
235 | output_struct->data.address16.resource_source.string_length = | 373 | output_struct->data.address16.resource_source.string_length = |
236 | index + 1; | 374 | index + 1; |
237 | 375 | ||
@@ -243,7 +381,7 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, | |||
243 | temp8 = (u8) (index + 1); | 381 | temp8 = (u8) (index + 1); |
244 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | 382 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); |
245 | } else { | 383 | } else { |
246 | output_struct->data.address16.resource_source.index = 0x00; | 384 | output_struct->data.address16.resource_source.index = 0; |
247 | output_struct->data.address16.resource_source.string_length = 0; | 385 | output_struct->data.address16.resource_source.string_length = 0; |
248 | output_struct->data.address16.resource_source.string_ptr = NULL; | 386 | output_struct->data.address16.resource_source.string_ptr = NULL; |
249 | } | 387 | } |
@@ -280,15 +418,13 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, | |||
280 | { | 418 | { |
281 | u8 *buffer = *output_buffer; | 419 | u8 *buffer = *output_buffer; |
282 | u8 *length_field; | 420 | u8 *length_field; |
283 | u8 temp8; | ||
284 | char *temp_pointer = NULL; | ||
285 | acpi_size actual_bytes; | 421 | acpi_size actual_bytes; |
286 | 422 | ||
287 | ACPI_FUNCTION_TRACE("rs_address16_stream"); | 423 | ACPI_FUNCTION_TRACE("rs_address16_stream"); |
288 | 424 | ||
289 | /* The descriptor field is static */ | 425 | /* Set the Descriptor Type field */ |
290 | 426 | ||
291 | *buffer = 0x88; | 427 | *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; |
292 | buffer += 1; | 428 | buffer += 1; |
293 | 429 | ||
294 | /* Save a pointer to the Length field - to be filled in later */ | 430 | /* Save a pointer to the Length field - to be filled in later */ |
@@ -298,43 +434,17 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, | |||
298 | 434 | ||
299 | /* Set the Resource Type (Memory, Io, bus_number) */ | 435 | /* Set the Resource Type (Memory, Io, bus_number) */ |
300 | 436 | ||
301 | temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); | 437 | *buffer = (u8) (linked_list->data.address16.resource_type & 0x03); |
302 | *buffer = temp8; | ||
303 | buffer += 1; | 438 | buffer += 1; |
304 | 439 | ||
305 | /* Set the general flags */ | 440 | /* Set the general flags */ |
306 | 441 | ||
307 | temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); | 442 | *buffer = acpi_rs_encode_general_flags(&linked_list->data); |
308 | |||
309 | temp8 |= (linked_list->data.address16.decode & 0x01) << 1; | ||
310 | temp8 |= (linked_list->data.address16.min_address_fixed & 0x01) << 2; | ||
311 | temp8 |= (linked_list->data.address16.max_address_fixed & 0x01) << 3; | ||
312 | |||
313 | *buffer = temp8; | ||
314 | buffer += 1; | 443 | buffer += 1; |
315 | 444 | ||
316 | /* Set the type specific flags */ | 445 | /* Set the type specific flags */ |
317 | 446 | ||
318 | temp8 = 0; | 447 | *buffer = acpi_rs_encode_specific_flags(&linked_list->data); |
319 | |||
320 | if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { | ||
321 | temp8 = (u8) | ||
322 | (linked_list->data.address16.attribute.memory. | ||
323 | read_write_attribute & 0x01); | ||
324 | |||
325 | temp8 |= | ||
326 | (linked_list->data.address16.attribute.memory. | ||
327 | cache_attribute & 0x03) << 1; | ||
328 | } else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) { | ||
329 | temp8 = (u8) | ||
330 | (linked_list->data.address16.attribute.io.range_attribute & | ||
331 | 0x03); | ||
332 | temp8 |= | ||
333 | (linked_list->data.address16.attribute.io. | ||
334 | translation_attribute & 0x03) << 4; | ||
335 | } | ||
336 | |||
337 | *buffer = temp8; | ||
338 | buffer += 1; | 448 | buffer += 1; |
339 | 449 | ||
340 | /* Set the address space granularity */ | 450 | /* Set the address space granularity */ |
@@ -368,22 +478,19 @@ acpi_rs_address16_stream(struct acpi_resource *linked_list, | |||
368 | 478 | ||
369 | /* Resource Source Index and Resource Source are optional */ | 479 | /* Resource Source Index and Resource Source are optional */ |
370 | 480 | ||
371 | if (0 != linked_list->data.address16.resource_source.string_length) { | 481 | if (linked_list->data.address16.resource_source.string_length) { |
372 | temp8 = (u8) linked_list->data.address16.resource_source.index; | 482 | *buffer = |
373 | 483 | (u8) linked_list->data.address16.resource_source.index; | |
374 | *buffer = temp8; | ||
375 | buffer += 1; | 484 | buffer += 1; |
376 | 485 | ||
377 | temp_pointer = (char *)buffer; | 486 | /* Copy the resource_source string */ |
378 | |||
379 | /* Copy the string */ | ||
380 | 487 | ||
381 | ACPI_STRCPY(temp_pointer, | 488 | ACPI_STRCPY((char *)buffer, |
382 | linked_list->data.address16.resource_source. | 489 | linked_list->data.address16.resource_source. |
383 | string_ptr); | 490 | string_ptr); |
384 | 491 | ||
385 | /* | 492 | /* |
386 | * Buffer needs to be set to the length of the sting + one for the | 493 | * Buffer needs to be set to the length of the string + one for the |
387 | * terminating null | 494 | * terminating null |
388 | */ | 495 | */ |
389 | buffer += | 496 | buffer += |
@@ -432,20 +539,18 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, | |||
432 | acpi_size * bytes_consumed, | 539 | acpi_size * bytes_consumed, |
433 | u8 ** output_buffer, acpi_size * structure_size) | 540 | u8 ** output_buffer, acpi_size * structure_size) |
434 | { | 541 | { |
435 | u8 *buffer; | ||
436 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
437 | u16 temp16; | 542 | u16 temp16; |
438 | u8 temp8; | 543 | u8 temp8; |
439 | u8 *temp_ptr; | 544 | u8 *temp_ptr; |
440 | acpi_size struct_size; | ||
441 | u32 index; | 545 | u32 index; |
546 | u8 *buffer = byte_stream_buffer; | ||
547 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
548 | acpi_size struct_size = | ||
549 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); | ||
442 | 550 | ||
443 | ACPI_FUNCTION_TRACE("rs_address32_resource"); | 551 | ACPI_FUNCTION_TRACE("rs_address32_resource"); |
444 | 552 | ||
445 | buffer = byte_stream_buffer; | 553 | /* Get the Descriptor Length field */ |
446 | struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); | ||
447 | |||
448 | /* Point past the Descriptor to get the number of bytes consumed */ | ||
449 | 554 | ||
450 | buffer += 1; | 555 | buffer += 1; |
451 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 556 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
@@ -475,47 +580,12 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, | |||
475 | /* Get the General Flags (Byte4) */ | 580 | /* Get the General Flags (Byte4) */ |
476 | 581 | ||
477 | buffer += 1; | 582 | buffer += 1; |
478 | temp8 = *buffer; | 583 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); |
479 | |||
480 | /* Producer / Consumer */ | ||
481 | |||
482 | output_struct->data.address32.producer_consumer = temp8 & 0x01; | ||
483 | |||
484 | /* Decode */ | ||
485 | |||
486 | output_struct->data.address32.decode = (temp8 >> 1) & 0x01; | ||
487 | |||
488 | /* Min Address Fixed */ | ||
489 | |||
490 | output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01; | ||
491 | |||
492 | /* Max Address Fixed */ | ||
493 | |||
494 | output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01; | ||
495 | 584 | ||
496 | /* Get the Type Specific Flags (Byte5) */ | 585 | /* Get the Type Specific Flags (Byte5) */ |
497 | 586 | ||
498 | buffer += 1; | 587 | buffer += 1; |
499 | temp8 = *buffer; | 588 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); |
500 | |||
501 | if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) { | ||
502 | output_struct->data.address32.attribute.memory. | ||
503 | read_write_attribute = (u16) (temp8 & 0x01); | ||
504 | |||
505 | output_struct->data.address32.attribute.memory.cache_attribute = | ||
506 | (u16) ((temp8 >> 1) & 0x03); | ||
507 | } else { | ||
508 | if (ACPI_IO_RANGE == | ||
509 | output_struct->data.address32.resource_type) { | ||
510 | output_struct->data.address32.attribute.io. | ||
511 | range_attribute = (u16) (temp8 & 0x03); | ||
512 | output_struct->data.address32.attribute.io. | ||
513 | translation_attribute = (u16) ((temp8 >> 4) & 0x03); | ||
514 | } else { | ||
515 | /* BUS_NUMBER_RANGE == output_struct->Data.Address32.resource_type */ | ||
516 | /* Nothing needs to be filled in */ | ||
517 | } | ||
518 | } | ||
519 | 589 | ||
520 | /* Get Granularity (Bytes 6-9) */ | 590 | /* Get Granularity (Bytes 6-9) */ |
521 | 591 | ||
@@ -561,9 +631,8 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, | |||
561 | if (*bytes_consumed > (26 + 1)) { | 631 | if (*bytes_consumed > (26 + 1)) { |
562 | /* Dereference the Index */ | 632 | /* Dereference the Index */ |
563 | 633 | ||
564 | temp8 = *buffer; | ||
565 | output_struct->data.address32.resource_source.index = | 634 | output_struct->data.address32.resource_source.index = |
566 | (u32) temp8; | 635 | (u32) * buffer; |
567 | 636 | ||
568 | /* Point to the String */ | 637 | /* Point to the String */ |
569 | 638 | ||
@@ -577,20 +646,20 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, | |||
577 | temp_ptr = (u8 *) | 646 | temp_ptr = (u8 *) |
578 | output_struct->data.address32.resource_source.string_ptr; | 647 | output_struct->data.address32.resource_source.string_ptr; |
579 | 648 | ||
580 | /* Copy the string into the buffer */ | 649 | /* Copy the resource_source string into the buffer */ |
581 | 650 | ||
582 | index = 0; | 651 | index = 0; |
583 | while (0x00 != *buffer) { | 652 | while (*buffer) { |
584 | *temp_ptr = *buffer; | 653 | *temp_ptr = *buffer; |
585 | 654 | ||
586 | temp_ptr += 1; | 655 | temp_ptr++; |
587 | buffer += 1; | 656 | buffer++; |
588 | index += 1; | 657 | index++; |
589 | } | 658 | } |
590 | 659 | ||
591 | /* Add the terminating null */ | 660 | /* Add the terminating null and set the string length */ |
592 | 661 | ||
593 | *temp_ptr = 0x00; | 662 | *temp_ptr = 0; |
594 | output_struct->data.address32.resource_source.string_length = | 663 | output_struct->data.address32.resource_source.string_length = |
595 | index + 1; | 664 | index + 1; |
596 | 665 | ||
@@ -602,7 +671,7 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, | |||
602 | temp8 = (u8) (index + 1); | 671 | temp8 = (u8) (index + 1); |
603 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | 672 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); |
604 | } else { | 673 | } else { |
605 | output_struct->data.address32.resource_source.index = 0x00; | 674 | output_struct->data.address32.resource_source.index = 0; |
606 | output_struct->data.address32.resource_source.string_length = 0; | 675 | output_struct->data.address32.resource_source.string_length = 0; |
607 | output_struct->data.address32.resource_source.string_ptr = NULL; | 676 | output_struct->data.address32.resource_source.string_ptr = NULL; |
608 | } | 677 | } |
@@ -639,62 +708,34 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, | |||
639 | { | 708 | { |
640 | u8 *buffer; | 709 | u8 *buffer; |
641 | u16 *length_field; | 710 | u16 *length_field; |
642 | u8 temp8; | ||
643 | char *temp_pointer; | ||
644 | 711 | ||
645 | ACPI_FUNCTION_TRACE("rs_address32_stream"); | 712 | ACPI_FUNCTION_TRACE("rs_address32_stream"); |
646 | 713 | ||
647 | buffer = *output_buffer; | 714 | buffer = *output_buffer; |
648 | 715 | ||
649 | /* The descriptor field is static */ | 716 | /* Set the Descriptor Type field */ |
650 | 717 | ||
651 | *buffer = 0x87; | 718 | *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; |
652 | buffer += 1; | 719 | buffer += 1; |
653 | 720 | ||
654 | /* Set a pointer to the Length field - to be filled in later */ | 721 | /* Save a pointer to the Length field - to be filled in later */ |
655 | 722 | ||
656 | length_field = ACPI_CAST_PTR(u16, buffer); | 723 | length_field = ACPI_CAST_PTR(u16, buffer); |
657 | buffer += 2; | 724 | buffer += 2; |
658 | 725 | ||
659 | /* Set the Resource Type (Memory, Io, bus_number) */ | 726 | /* Set the Resource Type (Memory, Io, bus_number) */ |
660 | 727 | ||
661 | temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); | 728 | *buffer = (u8) (linked_list->data.address32.resource_type & 0x03); |
662 | |||
663 | *buffer = temp8; | ||
664 | buffer += 1; | 729 | buffer += 1; |
665 | 730 | ||
666 | /* Set the general flags */ | 731 | /* Set the general flags */ |
667 | 732 | ||
668 | temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); | 733 | *buffer = acpi_rs_encode_general_flags(&linked_list->data); |
669 | temp8 |= (linked_list->data.address32.decode & 0x01) << 1; | ||
670 | temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2; | ||
671 | temp8 |= (linked_list->data.address32.max_address_fixed & 0x01) << 3; | ||
672 | |||
673 | *buffer = temp8; | ||
674 | buffer += 1; | 734 | buffer += 1; |
675 | 735 | ||
676 | /* Set the type specific flags */ | 736 | /* Set the type specific flags */ |
677 | 737 | ||
678 | temp8 = 0; | 738 | *buffer = acpi_rs_encode_specific_flags(&linked_list->data); |
679 | |||
680 | if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { | ||
681 | temp8 = (u8) | ||
682 | (linked_list->data.address32.attribute.memory. | ||
683 | read_write_attribute & 0x01); | ||
684 | |||
685 | temp8 |= | ||
686 | (linked_list->data.address32.attribute.memory. | ||
687 | cache_attribute & 0x03) << 1; | ||
688 | } else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) { | ||
689 | temp8 = (u8) | ||
690 | (linked_list->data.address32.attribute.io.range_attribute & | ||
691 | 0x03); | ||
692 | temp8 |= | ||
693 | (linked_list->data.address32.attribute.io. | ||
694 | translation_attribute & 0x03) << 4; | ||
695 | } | ||
696 | |||
697 | *buffer = temp8; | ||
698 | buffer += 1; | 739 | buffer += 1; |
699 | 740 | ||
700 | /* Set the address space granularity */ | 741 | /* Set the address space granularity */ |
@@ -728,22 +769,19 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, | |||
728 | 769 | ||
729 | /* Resource Source Index and Resource Source are optional */ | 770 | /* Resource Source Index and Resource Source are optional */ |
730 | 771 | ||
731 | if (0 != linked_list->data.address32.resource_source.string_length) { | 772 | if (linked_list->data.address32.resource_source.string_length) { |
732 | temp8 = (u8) linked_list->data.address32.resource_source.index; | 773 | *buffer = |
733 | 774 | (u8) linked_list->data.address32.resource_source.index; | |
734 | *buffer = temp8; | ||
735 | buffer += 1; | 775 | buffer += 1; |
736 | 776 | ||
737 | temp_pointer = (char *)buffer; | 777 | /* Copy the resource_source string */ |
738 | |||
739 | /* Copy the string */ | ||
740 | 778 | ||
741 | ACPI_STRCPY(temp_pointer, | 779 | ACPI_STRCPY((char *)buffer, |
742 | linked_list->data.address32.resource_source. | 780 | linked_list->data.address32.resource_source. |
743 | string_ptr); | 781 | string_ptr); |
744 | 782 | ||
745 | /* | 783 | /* |
746 | * Buffer needs to be set to the length of the sting + one for the | 784 | * Buffer needs to be set to the length of the string + one for the |
747 | * terminating null | 785 | * terminating null |
748 | */ | 786 | */ |
749 | buffer += | 787 | buffer += |
@@ -758,7 +796,7 @@ acpi_rs_address32_stream(struct acpi_resource *linked_list, | |||
758 | 796 | ||
759 | /* | 797 | /* |
760 | * Set the length field to the number of bytes consumed | 798 | * Set the length field to the number of bytes consumed |
761 | * minus the header size (3 bytes) | 799 | * minus the header size (3 bytes) |
762 | */ | 800 | */ |
763 | *length_field = (u16) (*bytes_consumed - 3); | 801 | *length_field = (u16) (*bytes_consumed - 3); |
764 | return_ACPI_STATUS(AE_OK); | 802 | return_ACPI_STATUS(AE_OK); |
@@ -790,22 +828,23 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, | |||
790 | acpi_size * bytes_consumed, | 828 | acpi_size * bytes_consumed, |
791 | u8 ** output_buffer, acpi_size * structure_size) | 829 | u8 ** output_buffer, acpi_size * structure_size) |
792 | { | 830 | { |
793 | u8 *buffer; | ||
794 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
795 | u16 temp16; | 831 | u16 temp16; |
796 | u8 temp8; | 832 | u8 temp8; |
797 | u8 resource_type; | 833 | u8 resource_type; |
798 | u8 *temp_ptr; | 834 | u8 *temp_ptr; |
799 | acpi_size struct_size; | ||
800 | u32 index; | 835 | u32 index; |
836 | u8 *buffer = byte_stream_buffer; | ||
837 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
838 | acpi_size struct_size = | ||
839 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); | ||
801 | 840 | ||
802 | ACPI_FUNCTION_TRACE("rs_address64_resource"); | 841 | ACPI_FUNCTION_TRACE("rs_address64_resource"); |
803 | 842 | ||
804 | buffer = byte_stream_buffer; | 843 | /* Get the Descriptor Type */ |
805 | struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); | 844 | |
806 | resource_type = *buffer; | 845 | resource_type = *buffer; |
807 | 846 | ||
808 | /* Point past the Descriptor to get the number of bytes consumed */ | 847 | /* Get the Descriptor Length field */ |
809 | 848 | ||
810 | buffer += 1; | 849 | buffer += 1; |
811 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 850 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
@@ -835,47 +874,12 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, | |||
835 | /* Get the General Flags (Byte4) */ | 874 | /* Get the General Flags (Byte4) */ |
836 | 875 | ||
837 | buffer += 1; | 876 | buffer += 1; |
838 | temp8 = *buffer; | 877 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); |
839 | |||
840 | /* Producer / Consumer */ | ||
841 | |||
842 | output_struct->data.address64.producer_consumer = temp8 & 0x01; | ||
843 | |||
844 | /* Decode */ | ||
845 | |||
846 | output_struct->data.address64.decode = (temp8 >> 1) & 0x01; | ||
847 | |||
848 | /* Min Address Fixed */ | ||
849 | |||
850 | output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01; | ||
851 | |||
852 | /* Max Address Fixed */ | ||
853 | |||
854 | output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01; | ||
855 | 878 | ||
856 | /* Get the Type Specific Flags (Byte5) */ | 879 | /* Get the Type Specific Flags (Byte5) */ |
857 | 880 | ||
858 | buffer += 1; | 881 | buffer += 1; |
859 | temp8 = *buffer; | 882 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); |
860 | |||
861 | if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) { | ||
862 | output_struct->data.address64.attribute.memory. | ||
863 | read_write_attribute = (u16) (temp8 & 0x01); | ||
864 | |||
865 | output_struct->data.address64.attribute.memory.cache_attribute = | ||
866 | (u16) ((temp8 >> 1) & 0x03); | ||
867 | } else { | ||
868 | if (ACPI_IO_RANGE == | ||
869 | output_struct->data.address64.resource_type) { | ||
870 | output_struct->data.address64.attribute.io. | ||
871 | range_attribute = (u16) (temp8 & 0x03); | ||
872 | output_struct->data.address64.attribute.io. | ||
873 | translation_attribute = (u16) ((temp8 >> 4) & 0x03); | ||
874 | } else { | ||
875 | /* BUS_NUMBER_RANGE == output_struct->Data.Address64.resource_type */ | ||
876 | /* Nothing needs to be filled in */ | ||
877 | } | ||
878 | } | ||
879 | 883 | ||
880 | if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { | 884 | if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { |
881 | /* Move past revision_id and Reserved byte */ | 885 | /* Move past revision_id and Reserved byte */ |
@@ -912,7 +916,7 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, | |||
912 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, | 916 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, |
913 | buffer); | 917 | buffer); |
914 | 918 | ||
915 | output_struct->data.address64.resource_source.index = 0x00; | 919 | output_struct->data.address64.resource_source.index = 0; |
916 | output_struct->data.address64.resource_source.string_length = 0; | 920 | output_struct->data.address64.resource_source.string_length = 0; |
917 | output_struct->data.address64.resource_source.string_ptr = NULL; | 921 | output_struct->data.address64.resource_source.string_ptr = NULL; |
918 | 922 | ||
@@ -942,9 +946,8 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, | |||
942 | if (*bytes_consumed > (46 + 1)) { | 946 | if (*bytes_consumed > (46 + 1)) { |
943 | /* Dereference the Index */ | 947 | /* Dereference the Index */ |
944 | 948 | ||
945 | temp8 = *buffer; | ||
946 | output_struct->data.address64.resource_source.index = | 949 | output_struct->data.address64.resource_source.index = |
947 | (u32) temp8; | 950 | (u32) * buffer; |
948 | 951 | ||
949 | /* Point to the String */ | 952 | /* Point to the String */ |
950 | 953 | ||
@@ -960,21 +963,21 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, | |||
960 | output_struct->data.address64.resource_source. | 963 | output_struct->data.address64.resource_source. |
961 | string_ptr; | 964 | string_ptr; |
962 | 965 | ||
963 | /* Copy the string into the buffer */ | 966 | /* Copy the resource_source string into the buffer */ |
964 | 967 | ||
965 | index = 0; | 968 | index = 0; |
966 | while (0x00 != *buffer) { | 969 | while (*buffer) { |
967 | *temp_ptr = *buffer; | 970 | *temp_ptr = *buffer; |
968 | 971 | ||
969 | temp_ptr += 1; | 972 | temp_ptr++; |
970 | buffer += 1; | 973 | buffer++; |
971 | index += 1; | 974 | index++; |
972 | } | 975 | } |
973 | 976 | ||
974 | /* | 977 | /* |
975 | * Add the terminating null | 978 | * Add the terminating null and set the string length |
976 | */ | 979 | */ |
977 | *temp_ptr = 0x00; | 980 | *temp_ptr = 0; |
978 | output_struct->data.address64.resource_source. | 981 | output_struct->data.address64.resource_source. |
979 | string_length = index + 1; | 982 | string_length = index + 1; |
980 | 983 | ||
@@ -1020,62 +1023,34 @@ acpi_rs_address64_stream(struct acpi_resource *linked_list, | |||
1020 | { | 1023 | { |
1021 | u8 *buffer; | 1024 | u8 *buffer; |
1022 | u16 *length_field; | 1025 | u16 *length_field; |
1023 | u8 temp8; | ||
1024 | char *temp_pointer; | ||
1025 | 1026 | ||
1026 | ACPI_FUNCTION_TRACE("rs_address64_stream"); | 1027 | ACPI_FUNCTION_TRACE("rs_address64_stream"); |
1027 | 1028 | ||
1028 | buffer = *output_buffer; | 1029 | buffer = *output_buffer; |
1029 | 1030 | ||
1030 | /* The descriptor field is static */ | 1031 | /* Set the Descriptor Type field */ |
1031 | 1032 | ||
1032 | *buffer = 0x8A; | 1033 | *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; |
1033 | buffer += 1; | 1034 | buffer += 1; |
1034 | 1035 | ||
1035 | /* Set a pointer to the Length field - to be filled in later */ | 1036 | /* Save a pointer to the Length field - to be filled in later */ |
1036 | 1037 | ||
1037 | length_field = ACPI_CAST_PTR(u16, buffer); | 1038 | length_field = ACPI_CAST_PTR(u16, buffer); |
1038 | buffer += 2; | 1039 | buffer += 2; |
1039 | 1040 | ||
1040 | /* Set the Resource Type (Memory, Io, bus_number) */ | 1041 | /* Set the Resource Type (Memory, Io, bus_number) */ |
1041 | 1042 | ||
1042 | temp8 = (u8) (linked_list->data.address64.resource_type & 0x03); | 1043 | *buffer = (u8) (linked_list->data.address64.resource_type & 0x03); |
1043 | |||
1044 | *buffer = temp8; | ||
1045 | buffer += 1; | 1044 | buffer += 1; |
1046 | 1045 | ||
1047 | /* Set the general flags */ | 1046 | /* Set the general flags */ |
1048 | 1047 | ||
1049 | temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01); | 1048 | *buffer = acpi_rs_encode_general_flags(&linked_list->data); |
1050 | temp8 |= (linked_list->data.address64.decode & 0x01) << 1; | ||
1051 | temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2; | ||
1052 | temp8 |= (linked_list->data.address64.max_address_fixed & 0x01) << 3; | ||
1053 | |||
1054 | *buffer = temp8; | ||
1055 | buffer += 1; | 1049 | buffer += 1; |
1056 | 1050 | ||
1057 | /* Set the type specific flags */ | 1051 | /* Set the type specific flags */ |
1058 | 1052 | ||
1059 | temp8 = 0; | 1053 | *buffer = acpi_rs_encode_specific_flags(&linked_list->data); |
1060 | |||
1061 | if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { | ||
1062 | temp8 = (u8) | ||
1063 | (linked_list->data.address64.attribute.memory. | ||
1064 | read_write_attribute & 0x01); | ||
1065 | |||
1066 | temp8 |= | ||
1067 | (linked_list->data.address64.attribute.memory. | ||
1068 | cache_attribute & 0x03) << 1; | ||
1069 | } else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) { | ||
1070 | temp8 = (u8) | ||
1071 | (linked_list->data.address64.attribute.io.range_attribute & | ||
1072 | 0x03); | ||
1073 | temp8 |= | ||
1074 | (linked_list->data.address64.attribute.io.range_attribute & | ||
1075 | 0x03) << 4; | ||
1076 | } | ||
1077 | |||
1078 | *buffer = temp8; | ||
1079 | buffer += 1; | 1054 | buffer += 1; |
1080 | 1055 | ||
1081 | /* Set the address space granularity */ | 1056 | /* Set the address space granularity */ |
@@ -1109,22 +1084,19 @@ acpi_rs_address64_stream(struct acpi_resource *linked_list, | |||
1109 | 1084 | ||
1110 | /* Resource Source Index and Resource Source are optional */ | 1085 | /* Resource Source Index and Resource Source are optional */ |
1111 | 1086 | ||
1112 | if (0 != linked_list->data.address64.resource_source.string_length) { | 1087 | if (linked_list->data.address64.resource_source.string_length) { |
1113 | temp8 = (u8) linked_list->data.address64.resource_source.index; | 1088 | *buffer = |
1114 | 1089 | (u8) linked_list->data.address64.resource_source.index; | |
1115 | *buffer = temp8; | ||
1116 | buffer += 1; | 1090 | buffer += 1; |
1117 | 1091 | ||
1118 | temp_pointer = (char *)buffer; | 1092 | /* Copy the resource_source string */ |
1119 | |||
1120 | /* Copy the string */ | ||
1121 | 1093 | ||
1122 | ACPI_STRCPY(temp_pointer, | 1094 | ACPI_STRCPY((char *)buffer, |
1123 | linked_list->data.address64.resource_source. | 1095 | linked_list->data.address64.resource_source. |
1124 | string_ptr); | 1096 | string_ptr); |
1125 | 1097 | ||
1126 | /* | 1098 | /* |
1127 | * Buffer needs to be set to the length of the sting + one for the | 1099 | * Buffer needs to be set to the length of the string + one for the |
1128 | * terminating null | 1100 | * terminating null |
1129 | */ | 1101 | */ |
1130 | buffer += | 1102 | buffer += |