aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2005-09-30 19:03:00 -0400
committerLen Brown <len.brown@intel.com>2005-12-10 00:20:25 -0500
commit50eca3eb89d73d9f0aa070b126c7ee6a616016ab (patch)
treeb2d06d21b34b9bd17eea4c53cff1f3866fa1b21d /drivers
parent3d5271f9883cba7b54762bc4fe027d4172f06db7 (diff)
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code - specifically, optimizations in the area of the AML/internal resource conversion code. The code has been optimized to simplify and eliminate duplicated code, CPU stack use has been decreased by optimizing function parameters and local variables, and naming conventions across the manager have been standardized for clarity and ease of maintenance (this includes function, parameter, variable, and struct/typedef names.) All Resource Manager dispatch and information tables have been moved to a single location for clarity and ease of maintenance. One new file was created, named "rsinfo.c". The ACPI return macros (return_ACPI_STATUS, etc.) have been modified to guarantee that the argument is not evaluated twice, making them less prone to macro side-effects. However, since there exists the possibility of additional stack use if a particular compiler cannot optimize them (such as in the debug generation case), the original macros are optionally available. Note that some invocations of the return_VALUE macro may now cause size mismatch warnings; the return_UINT8 and return_UINT32 macros are provided to eliminate these. (From Randy Dunlap) Implemented a new mechanism to enable debug tracing for individual control methods. A new external interface, acpi_debug_trace(), is provided to enable this mechanism. The intent is to allow the host OS to easily enable and disable tracing for problematic control methods. This interface can be easily exposed to a user or debugger interface if desired. See the file psxface.c for details. acpi_ut_callocate() will now return a valid pointer if a length of zero is specified - a length of one is used and a warning is issued. This matches the behavior of acpi_ut_allocate(). Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpi_memhotplug.c4
-rw-r--r--drivers/acpi/dispatcher/dsutils.c12
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/events/evgpe.c10
-rw-r--r--drivers/acpi/events/evsci.c4
-rw-r--r--drivers/acpi/executer/exdump.c10
-rw-r--r--drivers/acpi/executer/exnames.c4
-rw-r--r--drivers/acpi/executer/exprep.c4
-rw-r--r--drivers/acpi/executer/exresop.c2
-rw-r--r--drivers/acpi/executer/exutils.c6
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/acpi/hardware/hwacpi.c8
-rw-r--r--drivers/acpi/motherboard.c30
-rw-r--r--drivers/acpi/namespace/nsaccess.c2
-rw-r--r--drivers/acpi/namespace/nsnames.c2
-rw-r--r--drivers/acpi/namespace/nsutils.c12
-rw-r--r--drivers/acpi/parser/psargs.c2
-rw-r--r--drivers/acpi/parser/psxface.c142
-rw-r--r--drivers/acpi/pci_irq.c48
-rw-r--r--drivers/acpi/pci_link.c92
-rw-r--r--drivers/acpi/pci_root.c8
-rw-r--r--drivers/acpi/resources/Makefile2
-rw-r--r--drivers/acpi/resources/rsaddr.c1132
-rw-r--r--drivers/acpi/resources/rscalc.c282
-rw-r--r--drivers/acpi/resources/rscreate.c59
-rw-r--r--drivers/acpi/resources/rsdump.c313
-rw-r--r--drivers/acpi/resources/rsinfo.c2
-rw-r--r--drivers/acpi/resources/rsio.c451
-rw-r--r--drivers/acpi/resources/rsirq.c494
-rw-r--r--drivers/acpi/resources/rslist.c290
-rw-r--r--drivers/acpi/resources/rsmemory.c472
-rw-r--r--drivers/acpi/resources/rsmisc.c711
-rw-r--r--drivers/acpi/resources/rsutils.c437
-rw-r--r--drivers/acpi/resources/rsxface.c14
-rw-r--r--drivers/acpi/tables/tbrsdt.c2
-rw-r--r--drivers/acpi/tables/tbxfroot.c2
-rw-r--r--drivers/acpi/utilities/utalloc.c6
-rw-r--r--drivers/acpi/utilities/utglobal.c3
-rw-r--r--drivers/acpi/utilities/utmisc.c6
-rw-r--r--drivers/char/hpet.c26
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c364
-rw-r--r--drivers/serial/8250_acpi.c22
42 files changed, 2388 insertions, 3116 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 2143609d2936..b12946ccd135 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -101,8 +101,8 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
101 address64.attribute.memory.cache_attribute; 101 address64.attribute.memory.cache_attribute;
102 mem_device->read_write_attribute = 102 mem_device->read_write_attribute =
103 address64.attribute.memory.read_write_attribute; 103 address64.attribute.memory.read_write_attribute;
104 mem_device->start_addr = address64.min_address_range; 104 mem_device->start_addr = address64.minimum;
105 mem_device->end_addr = address64.max_address_range; 105 mem_device->end_addr = address64.maximum;
106 } 106 }
107 } 107 }
108 108
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 83ae1c1aa286..2cc53da5c0bd 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -177,7 +177,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
177 177
178 if (!op) { 178 if (!op) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
180 return_VALUE(TRUE); 180 return_UINT8(TRUE);
181 } 181 }
182 182
183 /* 183 /*
@@ -208,7 +208,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
208 "At Method level, result of [%s] not used\n", 208 "At Method level, result of [%s] not used\n",
209 acpi_ps_get_opcode_name(op->common. 209 acpi_ps_get_opcode_name(op->common.
210 aml_opcode))); 210 aml_opcode)));
211 return_VALUE(FALSE); 211 return_UINT8(FALSE);
212 } 212 }
213 213
214 /* Get info on the parent. The root_op is AML_SCOPE */ 214 /* Get info on the parent. The root_op is AML_SCOPE */
@@ -218,7 +218,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
218 if (parent_info->class == AML_CLASS_UNKNOWN) { 218 if (parent_info->class == AML_CLASS_UNKNOWN) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
220 "Unknown parent opcode. Op=%p\n", op)); 220 "Unknown parent opcode. Op=%p\n", op));
221 return_VALUE(FALSE); 221 return_UINT8(FALSE);
222 } 222 }
223 223
224 /* 224 /*
@@ -304,7 +304,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
304 acpi_ps_get_opcode_name(op->common.parent->common. 304 acpi_ps_get_opcode_name(op->common.parent->common.
305 aml_opcode), op)); 305 aml_opcode), op));
306 306
307 return_VALUE(TRUE); 307 return_UINT8(TRUE);
308 308
309 result_not_used: 309 result_not_used:
310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -313,7 +313,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
313 acpi_ps_get_opcode_name(op->common.parent->common. 313 acpi_ps_get_opcode_name(op->common.parent->common.
314 aml_opcode), op)); 314 aml_opcode), op));
315 315
316 return_VALUE(FALSE); 316 return_UINT8(FALSE);
317} 317}
318 318
319/******************************************************************************* 319/*******************************************************************************
@@ -616,7 +616,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
616 616
617 if (op_info->flags & AML_HAS_RETVAL) { 617 if (op_info->flags & AML_HAS_RETVAL) {
618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
619 "Argument previously created, already stacked \n")); 619 "Argument previously created, already stacked\n"));
620 620
621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object 621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
622 (walk_state-> 622 (walk_state->
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index c33bfba5df8f..0ecbfa5db1ba 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1151,7 +1151,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1151 union acpi_ec *ec = (union acpi_ec *)context; 1151 union acpi_ec *ec = (union acpi_ec *)context;
1152 struct acpi_generic_address *addr; 1152 struct acpi_generic_address *addr;
1153 1153
1154 if (resource->type != ACPI_RSTYPE_IO) { 1154 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
1155 return AE_OK; 1155 return AE_OK;
1156 } 1156 }
1157 1157
@@ -1171,7 +1171,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1171 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 1171 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1172 addr->register_bit_width = 8; 1172 addr->register_bit_width = 8;
1173 addr->register_bit_offset = 0; 1173 addr->register_bit_offset = 0;
1174 addr->address = resource->data.io.min_base_address; 1174 addr->address = resource->data.io.minimum;
1175 1175
1176 return AE_OK; 1176 return AE_OK;
1177} 1177}
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index b2f232df13d8..f51c3b16c608 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -600,7 +600,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
600 status = acpi_hw_clear_gpe(gpe_event_info); 600 status = acpi_hw_clear_gpe(gpe_event_info);
601 if (ACPI_FAILURE(status)) { 601 if (ACPI_FAILURE(status)) {
602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 603 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
604 } 604 }
605 } 605 }
606 606
@@ -638,7 +638,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
638 status = acpi_hw_clear_gpe(gpe_event_info); 638 status = acpi_hw_clear_gpe(gpe_event_info);
639 if (ACPI_FAILURE(status)) { 639 if (ACPI_FAILURE(status)) {
640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 641 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
642 } 642 }
643 } 643 }
644 break; 644 break;
@@ -652,7 +652,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
652 status = acpi_ev_disable_gpe(gpe_event_info); 652 status = acpi_ev_disable_gpe(gpe_event_info);
653 if (ACPI_FAILURE(status)) { 653 if (ACPI_FAILURE(status)) {
654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 655 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
656 } 656 }
657 657
658 /* 658 /*
@@ -680,12 +680,12 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
680 status = acpi_ev_disable_gpe(gpe_event_info); 680 status = acpi_ev_disable_gpe(gpe_event_info);
681 if (ACPI_FAILURE(status)) { 681 if (ACPI_FAILURE(status)) {
682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 683 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
684 } 684 }
685 break; 685 break;
686 } 686 }
687 687
688 return_VALUE(ACPI_INTERRUPT_HANDLED); 688 return_UINT32(ACPI_INTERRUPT_HANDLED);
689} 689}
690 690
691#ifdef ACPI_GPE_NOTIFY_CHECK 691#ifdef ACPI_GPE_NOTIFY_CHECK
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index 141835977002..e2c0b48a7e9f 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -88,7 +88,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
88 */ 88 */
89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
90 90
91 return_VALUE(interrupt_handled); 91 return_UINT32(interrupt_handled);
92} 92}
93 93
94/******************************************************************************* 94/*******************************************************************************
@@ -121,7 +121,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
121 */ 121 */
122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
123 123
124 return_VALUE(interrupt_handled); 124 return_UINT32(interrupt_handled);
125} 125}
126 126
127/****************************************************************************** 127/******************************************************************************
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index bc2fa996047e..4477a62fed56 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -214,7 +214,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
214 214
215 case ACPI_TYPE_BUFFER: 215 case ACPI_TYPE_BUFFER:
216 216
217 acpi_os_printf("Buffer len %X @ %p \n", 217 acpi_os_printf("Buffer len %X @ %p\n",
218 obj_desc->buffer.length, 218 obj_desc->buffer.length,
219 obj_desc->buffer.pointer); 219 obj_desc->buffer.pointer);
220 220
@@ -320,17 +320,17 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
320 320
321 case ACPI_TYPE_BUFFER_FIELD: 321 case ACPI_TYPE_BUFFER_FIELD:
322 322
323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", 323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n",
324 obj_desc->buffer_field.bit_length, 324 obj_desc->buffer_field.bit_length,
325 obj_desc->buffer_field.base_byte_offset, 325 obj_desc->buffer_field.base_byte_offset,
326 obj_desc->buffer_field.start_field_bit_offset); 326 obj_desc->buffer_field.start_field_bit_offset);
327 327
328 if (!obj_desc->buffer_field.buffer_obj) { 328 if (!obj_desc->buffer_field.buffer_obj) {
329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); 329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
330 } else 330 } else
331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) 331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
332 != ACPI_TYPE_BUFFER) { 332 != ACPI_TYPE_BUFFER) {
333 acpi_os_printf("*not a Buffer* \n"); 333 acpi_os_printf("*not a Buffer*\n");
334 } else { 334 } else {
335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, 335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
336 depth + 1); 336 depth + 1);
@@ -618,7 +618,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
618 618
619 case ACPI_TYPE_PACKAGE: 619 case ACPI_TYPE_PACKAGE:
620 620
621 acpi_os_printf("[Package] Contains %d Elements: \n", 621 acpi_os_printf("[Package] Contains %d Elements:\n",
622 obj_desc->package.count); 622 obj_desc->package.count);
623 623
624 for (i = 0; i < obj_desc->package.count; i++) { 624 for (i = 0; i < obj_desc->package.count; i++) {
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 239d8473e9a5..dff41121a304 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -191,10 +191,10 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
191 if (name_string) { 191 if (name_string) {
192 ACPI_STRCAT(name_string, char_buf); 192 ACPI_STRCAT(name_string, char_buf);
193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
194 "Appended to - %s \n", name_string)); 194 "Appended to - %s\n", name_string));
195 } else { 195 } else {
196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
197 "No Name string - %s \n", char_buf)); 197 "No Name string - %s\n", char_buf));
198 } 198 }
199 } else if (index == 0) { 199 } else if (index == 0) {
200 /* 200 /*
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index 7476c363e407..88ccbf3b29d0 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
276 276
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
278 "Unknown field access type %X\n", access)); 278 "Unknown field access type %X\n", access));
279 return_VALUE(0); 279 return_UINT32(0);
280 } 280 }
281 281
282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
@@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
289 } 289 }
290 290
291 *return_byte_alignment = byte_alignment; 291 *return_byte_alignment = byte_alignment;
292 return_VALUE(bit_length); 292 return_UINT32(bit_length);
293} 293}
294 294
295/******************************************************************************* 295/*******************************************************************************
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index ff064e79ab90..b04e4a3707a1 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -157,7 +157,7 @@ acpi_ex_resolve_operands(u16 opcode,
157 } 157 }
158 158
159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
160 "Opcode %X [%s] required_operand_types=%8.8X \n", 160 "Opcode %X [%s] required_operand_types=%8.8X\n",
161 opcode, op_info->name, arg_types)); 161 opcode, op_info->name, arg_types));
162 162
163 /* 163 /*
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 1ee79d8c8f88..9f4e547d7734 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -206,7 +206,7 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags)
206 } 206 }
207 } 207 }
208 208
209 return_VALUE(locked); 209 return_UINT8(locked);
210} 210}
211 211
212/******************************************************************************* 212/*******************************************************************************
@@ -268,7 +268,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
269 269
270 if (value == 0) { 270 if (value == 0) {
271 return_VALUE(1); 271 return_UINT32(1);
272 } 272 }
273 273
274 current_value = value; 274 current_value = value;
@@ -282,7 +282,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
282 num_digits++; 282 num_digits++;
283 } 283 }
284 284
285 return_VALUE(num_digits); 285 return_UINT32(num_digits);
286} 286}
287 287
288/******************************************************************************* 288/*******************************************************************************
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index fcb881db5b0b..8daef57b994c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -99,15 +99,15 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
99 unsigned long *busnr = (unsigned long *)data; 99 unsigned long *busnr = (unsigned long *)data;
100 struct acpi_resource_address64 address; 100 struct acpi_resource_address64 address;
101 101
102 if (resource->type != ACPI_RSTYPE_ADDRESS16 && 102 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
103 resource->type != ACPI_RSTYPE_ADDRESS32 && 103 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
104 resource->type != ACPI_RSTYPE_ADDRESS64) 104 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
105 return AE_OK; 105 return AE_OK;
106 106
107 acpi_resource_to_address64(resource, &address); 107 acpi_resource_to_address64(resource, &address);
108 if ((address.address_length > 0) && 108 if ((address.address_length > 0) &&
109 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 109 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
110 *busnr = address.min_address_range; 110 *busnr = address.minimum;
111 111
112 return AE_OK; 112 return AE_OK;
113} 113}
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index 1bb3463d7040..20a335cc9bea 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -204,18 +204,18 @@ u32 acpi_hw_get_mode(void)
204 * system does not support mode transition. 204 * system does not support mode transition.
205 */ 205 */
206 if (!acpi_gbl_FADT->smi_cmd) { 206 if (!acpi_gbl_FADT->smi_cmd) {
207 return_VALUE(ACPI_SYS_MODE_ACPI); 207 return_UINT32(ACPI_SYS_MODE_ACPI);
208 } 208 }
209 209
210 status = 210 status =
211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
212 if (ACPI_FAILURE(status)) { 212 if (ACPI_FAILURE(status)) {
213 return_VALUE(ACPI_SYS_MODE_LEGACY); 213 return_UINT32(ACPI_SYS_MODE_LEGACY);
214 } 214 }
215 215
216 if (value) { 216 if (value) {
217 return_VALUE(ACPI_SYS_MODE_ACPI); 217 return_UINT32(ACPI_SYS_MODE_ACPI);
218 } else { 218 } else {
219 return_VALUE(ACPI_SYS_MODE_LEGACY); 219 return_UINT32(ACPI_SYS_MODE_LEGACY);
220 } 220 }
221} 221}
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index 85c1fb5c9a5a..468244147ec1 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -54,36 +54,36 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
54 54
55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); 55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
56 56
57 if (res->type == ACPI_RSTYPE_IO) { 57 if (res->type == ACPI_RESOURCE_TYPE_IO) {
58 struct acpi_resource_io *io_res = &res->data.io; 58 struct acpi_resource_io *io_res = &res->data.io;
59 59
60 if (io_res->min_base_address != io_res->max_base_address) 60 if (io_res->minimum != io_res->maximum)
61 return_VALUE(AE_OK); 61 return_VALUE(AE_OK);
62 if (IS_RESERVED_ADDR 62 if (IS_RESERVED_ADDR
63 (io_res->min_base_address, io_res->range_length)) { 63 (io_res->minimum, io_res->address_length)) {
64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 64 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
65 "Motherboard resources 0x%08x - 0x%08x\n", 65 "Motherboard resources 0x%08x - 0x%08x\n",
66 io_res->min_base_address, 66 io_res->minimum,
67 io_res->min_base_address + 67 io_res->minimum +
68 io_res->range_length)); 68 io_res->address_length));
69 requested_res = 69 requested_res =
70 request_region(io_res->min_base_address, 70 request_region(io_res->minimum,
71 io_res->range_length, "motherboard"); 71 io_res->address_length, "motherboard");
72 } 72 }
73 } else if (res->type == ACPI_RSTYPE_FIXED_IO) { 73 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) {
74 struct acpi_resource_fixed_io *fixed_io_res = 74 struct acpi_resource_fixed_io *fixed_io_res =
75 &res->data.fixed_io; 75 &res->data.fixed_io;
76 76
77 if (IS_RESERVED_ADDR 77 if (IS_RESERVED_ADDR
78 (fixed_io_res->base_address, fixed_io_res->range_length)) { 78 (fixed_io_res->address, fixed_io_res->address_length)) {
79 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
80 "Motherboard resources 0x%08x - 0x%08x\n", 80 "Motherboard resources 0x%08x - 0x%08x\n",
81 fixed_io_res->base_address, 81 fixed_io_res->address,
82 fixed_io_res->base_address + 82 fixed_io_res->address +
83 fixed_io_res->range_length)); 83 fixed_io_res->address_length));
84 requested_res = 84 requested_res =
85 request_region(fixed_io_res->base_address, 85 request_region(fixed_io_res->address,
86 fixed_io_res->range_length, 86 fixed_io_res->address_length,
87 "motherboard"); 87 "motherboard");
88 } 88 }
89 } else { 89 } else {
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index edfbe34600f5..6923059ba3c7 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -498,7 +498,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
498 path++; 498 path++;
499 499
500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
501 "Multi Pathname (%d Segments, Flags=%X) \n", 501 "Multi Pathname (%d Segments, Flags=%X)\n",
502 num_segments, flags)); 502 num_segments, flags));
503 break; 503 break;
504 504
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d5e8dea61c27..5400728eb791 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -241,7 +241,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
241 241
242 acpi_ns_build_external_path(node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
243 243
244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
245 (char *)buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
246 return_ACPI_STATUS(AE_OK); 246 return_ACPI_STATUS(AE_OK);
247} 247}
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index ebec036423c9..549075fb9f88 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -249,10 +249,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
249 249
250 if (!node) { 250 if (!node) {
251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); 251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n"));
252 return_VALUE(ACPI_TYPE_ANY); 252 return_UINT32(ACPI_TYPE_ANY);
253 } 253 }
254 254
255 return_VALUE((acpi_object_type) node->type); 255 return_UINT32((acpi_object_type) node->type);
256} 256}
257 257
258/******************************************************************************* 258/*******************************************************************************
@@ -276,10 +276,10 @@ u32 acpi_ns_local(acpi_object_type type)
276 /* Type code out of range */ 276 /* Type code out of range */
277 277
278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); 278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n"));
279 return_VALUE(ACPI_NS_NORMAL); 279 return_UINT32(ACPI_NS_NORMAL);
280 } 280 }
281 281
282 return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 282 return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
283} 283}
284 284
285/******************************************************************************* 285/*******************************************************************************
@@ -805,10 +805,10 @@ u32 acpi_ns_opens_scope(acpi_object_type type)
805 805
806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", 806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n",
807 type)); 807 type));
808 return_VALUE(ACPI_NS_NORMAL); 808 return_UINT32(ACPI_NS_NORMAL);
809 } 809 }
810 810
811 return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 811 return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
812} 812}
813 813
814/******************************************************************************* 814/*******************************************************************************
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index 5858188f94a6..562d0f822ab1 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -116,7 +116,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
116 break; 116 break;
117 } 117 }
118 118
119 return_VALUE(length); 119 return_UINT32(length);
120} 120}
121 121
122/******************************************************************************* 122/*******************************************************************************
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index 4dcbd443160e..4c426f4c6af6 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -50,6 +50,10 @@
50ACPI_MODULE_NAME("psxface") 50ACPI_MODULE_NAME("psxface")
51 51
52/* Local Prototypes */ 52/* Local Prototypes */
53static void acpi_ps_start_trace(struct acpi_parameter_info *info);
54
55static void acpi_ps_stop_trace(struct acpi_parameter_info *info);
56
53static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); 57static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
54 58
55static void 59static void
@@ -57,6 +61,136 @@ acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
57 61
58/******************************************************************************* 62/*******************************************************************************
59 * 63 *
64 * FUNCTION: acpi_debug_trace
65 *
66 * PARAMETERS: method_name - Valid ACPI name string
67 * debug_level - Optional level mask. 0 to use default
68 * debug_layer - Optional layer mask. 0 to use default
69 * Flags - bit 1: one shot(1) or persistent(0)
70 *
71 * RETURN: Status
72 *
73 * DESCRIPTION: External interface to enable debug tracing during control
74 * method execution
75 *
76 ******************************************************************************/
77
78acpi_status
79acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
80{
81 acpi_status status;
82
83 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
84 if (ACPI_FAILURE(status)) {
85 return (status);
86 }
87
88 /* TBDs: Validate name, allow full path or just nameseg */
89
90 acpi_gbl_trace_method_name = *(u32 *) name;
91 acpi_gbl_trace_flags = flags;
92
93 if (debug_level) {
94 acpi_gbl_trace_dbg_level = debug_level;
95 }
96 if (debug_layer) {
97 acpi_gbl_trace_dbg_layer = debug_layer;
98 }
99
100 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
101 return (AE_OK);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_ps_start_trace
107 *
108 * PARAMETERS: Info - Method info struct
109 *
110 * RETURN: None
111 *
112 * DESCRIPTION: Start control method execution trace
113 *
114 ******************************************************************************/
115
116static void acpi_ps_start_trace(struct acpi_parameter_info *info)
117{
118 acpi_status status;
119
120 ACPI_FUNCTION_ENTRY();
121
122 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE(status)) {
124 return;
125 }
126
127 if ((!acpi_gbl_trace_method_name) ||
128 (acpi_gbl_trace_method_name != info->node->name.integer)) {
129 goto exit;
130 }
131
132 acpi_gbl_original_dbg_level = acpi_dbg_level;
133 acpi_gbl_original_dbg_layer = acpi_dbg_layer;
134
135 acpi_dbg_level = 0x00FFFFFF;
136 acpi_dbg_layer = ACPI_UINT32_MAX;
137
138 if (acpi_gbl_trace_dbg_level) {
139 acpi_dbg_level = acpi_gbl_trace_dbg_level;
140 }
141 if (acpi_gbl_trace_dbg_layer) {
142 acpi_dbg_layer = acpi_gbl_trace_dbg_layer;
143 }
144
145 exit:
146 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ps_stop_trace
152 *
153 * PARAMETERS: Info - Method info struct
154 *
155 * RETURN: None
156 *
157 * DESCRIPTION: Stop control method execution trace
158 *
159 ******************************************************************************/
160
161static void acpi_ps_stop_trace(struct acpi_parameter_info *info)
162{
163 acpi_status status;
164
165 ACPI_FUNCTION_ENTRY();
166
167 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
168 if (ACPI_FAILURE(status)) {
169 return;
170 }
171
172 if ((!acpi_gbl_trace_method_name) ||
173 (acpi_gbl_trace_method_name != info->node->name.integer)) {
174 goto exit;
175 }
176
177 /* Disable further tracing if type is one-shot */
178
179 if (acpi_gbl_trace_flags & 1) {
180 acpi_gbl_trace_method_name = 0;
181 acpi_gbl_trace_dbg_level = 0;
182 acpi_gbl_trace_dbg_layer = 0;
183 }
184
185 acpi_dbg_level = acpi_gbl_original_dbg_level;
186 acpi_dbg_layer = acpi_gbl_original_dbg_layer;
187
188 exit:
189 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
190}
191
192/*******************************************************************************
193 *
60 * FUNCTION: acpi_ps_execute_method 194 * FUNCTION: acpi_ps_execute_method
61 * 195 *
62 * PARAMETERS: Info - Method info block, contains: 196 * PARAMETERS: Info - Method info block, contains:
@@ -104,6 +238,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
104 */ 238 */
105 acpi_ps_update_parameter_list(info, REF_INCREMENT); 239 acpi_ps_update_parameter_list(info, REF_INCREMENT);
106 240
241 /* Begin tracing if requested */
242
243 acpi_ps_start_trace(info);
244
107 /* 245 /*
108 * 1) Perform the first pass parse of the method to enter any 246 * 1) Perform the first pass parse of the method to enter any
109 * named objects that it creates into the namespace 247 * named objects that it creates into the namespace
@@ -129,6 +267,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
129 status = acpi_ps_execute_pass(info); 267 status = acpi_ps_execute_pass(info);
130 268
131 cleanup: 269 cleanup:
270 /* End optional tracing */
271
272 acpi_ps_stop_trace(info);
273
132 /* Take away the extra reference that we gave the parameters above */ 274 /* Take away the extra reference that we gave the parameters above */
133 275
134 acpi_ps_update_parameter_list(info, REF_DECREMENT); 276 acpi_ps_update_parameter_list(info, REF_DECREMENT);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 09567c2edcfb..726dda1fce1c 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -258,7 +258,7 @@ typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
258 258
259static int 259static int
260acpi_pci_allocate_irq(struct acpi_prt_entry *entry, 260acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
261 int *edge_level, int *active_high_low, char **link) 261 int *triggering, int *polarity, char **link)
262{ 262{
263 int irq; 263 int irq;
264 264
@@ -266,8 +266,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
266 266
267 if (entry->link.handle) { 267 if (entry->link.handle) {
268 irq = acpi_pci_link_allocate_irq(entry->link.handle, 268 irq = acpi_pci_link_allocate_irq(entry->link.handle,
269 entry->link.index, edge_level, 269 entry->link.index, triggering,
270 active_high_low, link); 270 polarity, link);
271 if (irq < 0) { 271 if (irq < 0) {
272 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 272 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
273 "Invalid IRQ link routing entry\n")); 273 "Invalid IRQ link routing entry\n"));
@@ -275,8 +275,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
275 } 275 }
276 } else { 276 } else {
277 irq = entry->link.index; 277 irq = entry->link.index;
278 *edge_level = ACPI_LEVEL_SENSITIVE; 278 *triggering = ACPI_LEVEL_SENSITIVE;
279 *active_high_low = ACPI_ACTIVE_LOW; 279 *polarity = ACPI_ACTIVE_LOW;
280 } 280 }
281 281
282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); 282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
@@ -285,7 +285,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
285 285
286static int 286static int
287acpi_pci_free_irq(struct acpi_prt_entry *entry, 287acpi_pci_free_irq(struct acpi_prt_entry *entry,
288 int *edge_level, int *active_high_low, char **link) 288 int *triggering, int *polarity, char **link)
289{ 289{
290 int irq; 290 int irq;
291 291
@@ -307,8 +307,8 @@ static int
307acpi_pci_irq_lookup(struct pci_bus *bus, 307acpi_pci_irq_lookup(struct pci_bus *bus,
308 int device, 308 int device,
309 int pin, 309 int pin,
310 int *edge_level, 310 int *triggering,
311 int *active_high_low, char **link, irq_lookup_func func) 311 int *polarity, char **link, irq_lookup_func func)
312{ 312{
313 struct acpi_prt_entry *entry = NULL; 313 struct acpi_prt_entry *entry = NULL;
314 int segment = pci_domain_nr(bus); 314 int segment = pci_domain_nr(bus);
@@ -327,7 +327,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
327 return_VALUE(-1); 327 return_VALUE(-1);
328 } 328 }
329 329
330 ret = func(entry, edge_level, active_high_low, link); 330 ret = func(entry, triggering, polarity, link);
331 return_VALUE(ret); 331 return_VALUE(ret);
332} 332}
333 333
@@ -339,8 +339,8 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
339static int 339static int
340acpi_pci_irq_derive(struct pci_dev *dev, 340acpi_pci_irq_derive(struct pci_dev *dev,
341 int pin, 341 int pin,
342 int *edge_level, 342 int *triggering,
343 int *active_high_low, char **link, irq_lookup_func func) 343 int *polarity, char **link, irq_lookup_func func)
344{ 344{
345 struct pci_dev *bridge = dev; 345 struct pci_dev *bridge = dev;
346 int irq = -1; 346 int irq = -1;
@@ -375,7 +375,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
375 } 375 }
376 376
377 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 377 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
378 pin, edge_level, active_high_low, 378 pin, triggering, polarity,
379 link, func); 379 link, func);
380 } 380 }
381 381
@@ -402,8 +402,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
402{ 402{
403 int irq = 0; 403 int irq = 0;
404 u8 pin = 0; 404 u8 pin = 0;
405 int edge_level = ACPI_LEVEL_SENSITIVE; 405 int triggering = ACPI_LEVEL_SENSITIVE;
406 int active_high_low = ACPI_ACTIVE_LOW; 406 int polarity = ACPI_ACTIVE_LOW;
407 char *link = NULL; 407 char *link = NULL;
408 int rc; 408 int rc;
409 409
@@ -432,7 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
432 * values override any BIOS-assigned IRQs set during boot. 432 * values override any BIOS-assigned IRQs set during boot.
433 */ 433 */
434 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 434 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
435 &edge_level, &active_high_low, &link, 435 &triggering, &polarity, &link,
436 acpi_pci_allocate_irq); 436 acpi_pci_allocate_irq);
437 437
438 /* 438 /*
@@ -440,8 +440,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
440 * device's parent bridge. 440 * device's parent bridge.
441 */ 441 */
442 if (irq < 0) 442 if (irq < 0)
443 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 443 irq = acpi_pci_irq_derive(dev, pin, &triggering,
444 &active_high_low, &link, 444 &polarity, &link,
445 acpi_pci_allocate_irq); 445 acpi_pci_allocate_irq);
446 446
447 /* 447 /*
@@ -463,7 +463,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
463 } 463 }
464 } 464 }
465 465
466 rc = acpi_register_gsi(irq, edge_level, active_high_low); 466 rc = acpi_register_gsi(irq, triggering, polarity);
467 if (rc < 0) { 467 if (rc < 0) {
468 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 468 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
469 "to register GSI\n", pci_name(dev), ('A' + pin)); 469 "to register GSI\n", pci_name(dev), ('A' + pin));
@@ -478,8 +478,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
478 printk("Link [%s] -> ", link); 478 printk("Link [%s] -> ", link);
479 479
480 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 480 printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
481 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 481 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
482 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 482 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
483 483
484 return_VALUE(0); 484 return_VALUE(0);
485} 485}
@@ -495,8 +495,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
495{ 495{
496 int gsi = 0; 496 int gsi = 0;
497 u8 pin = 0; 497 u8 pin = 0;
498 int edge_level = ACPI_LEVEL_SENSITIVE; 498 int triggering = ACPI_LEVEL_SENSITIVE;
499 int active_high_low = ACPI_ACTIVE_LOW; 499 int polarity = ACPI_ACTIVE_LOW;
500 500
501 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 501 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
502 502
@@ -512,7 +512,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
512 * First we check the PCI IRQ routing table (PRT) for an IRQ. 512 * First we check the PCI IRQ routing table (PRT) for an IRQ.
513 */ 513 */
514 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 514 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
515 &edge_level, &active_high_low, NULL, 515 &triggering, &polarity, NULL,
516 acpi_pci_free_irq); 516 acpi_pci_free_irq);
517 /* 517 /*
518 * If no PRT entry was found, we'll try to derive an IRQ from the 518 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -520,7 +520,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
520 */ 520 */
521 if (gsi < 0) 521 if (gsi < 0)
522 gsi = acpi_pci_irq_derive(dev, pin, 522 gsi = acpi_pci_irq_derive(dev, pin,
523 &edge_level, &active_high_low, NULL, 523 &triggering, &polarity, NULL,
524 acpi_pci_free_irq); 524 acpi_pci_free_irq);
525 if (gsi < 0) 525 if (gsi < 0)
526 return_VOID; 526 return_VOID;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index d8956c0bf143..492170373494 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -70,8 +70,8 @@ static struct acpi_driver acpi_pci_link_driver = {
70 */ 70 */
71struct acpi_pci_link_irq { 71struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 72 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 73 u8 triggering; /* All IRQs */
74 u8 active_high_low; /* All IRQs */ 74 u8 polarity; /* All IRQs */
75 u8 resource_type; 75 u8 resource_type;
76 u8 possible_count; 76 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
@@ -109,18 +109,18 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); 109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
110 110
111 switch (resource->type) { 111 switch (resource->type) {
112 case ACPI_RSTYPE_START_DPF: 112 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
113 return_ACPI_STATUS(AE_OK); 113 return_ACPI_STATUS(AE_OK);
114 case ACPI_RSTYPE_IRQ: 114 case ACPI_RESOURCE_TYPE_IRQ:
115 { 115 {
116 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
117 if (!p || !p->number_of_interrupts) { 117 if (!p || !p->interrupt_count) {
118 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 118 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
119 "Blank IRQ resource\n")); 119 "Blank IRQ resource\n"));
120 return_ACPI_STATUS(AE_OK); 120 return_ACPI_STATUS(AE_OK);
121 } 121 }
122 for (i = 0; 122 for (i = 0;
123 (i < p->number_of_interrupts 123 (i < p->interrupt_count
124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
125 if (!p->interrupts[i]) { 125 if (!p->interrupts[i]) {
126 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 126 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -131,22 +131,22 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
131 link->irq.possible[i] = p->interrupts[i]; 131 link->irq.possible[i] = p->interrupts[i];
132 link->irq.possible_count++; 132 link->irq.possible_count++;
133 } 133 }
134 link->irq.edge_level = p->edge_level; 134 link->irq.triggering = p->triggering;
135 link->irq.active_high_low = p->active_high_low; 135 link->irq.polarity = p->polarity;
136 link->irq.resource_type = ACPI_RSTYPE_IRQ; 136 link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ;
137 break; 137 break;
138 } 138 }
139 case ACPI_RSTYPE_EXT_IRQ: 139 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
140 { 140 {
141 struct acpi_resource_ext_irq *p = 141 struct acpi_resource_extended_irq *p =
142 &resource->data.extended_irq; 142 &resource->data.extended_irq;
143 if (!p || !p->number_of_interrupts) { 143 if (!p || !p->interrupt_count) {
144 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 144 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
145 "Blank EXT IRQ resource\n")); 145 "Blank EXT IRQ resource\n"));
146 return_ACPI_STATUS(AE_OK); 146 return_ACPI_STATUS(AE_OK);
147 } 147 }
148 for (i = 0; 148 for (i = 0;
149 (i < p->number_of_interrupts 149 (i < p->interrupt_count
150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
151 if (!p->interrupts[i]) { 151 if (!p->interrupts[i]) {
152 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 152 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -157,9 +157,9 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
157 link->irq.possible[i] = p->interrupts[i]; 157 link->irq.possible[i] = p->interrupts[i];
158 link->irq.possible_count++; 158 link->irq.possible_count++;
159 } 159 }
160 link->irq.edge_level = p->edge_level; 160 link->irq.triggering = p->triggering;
161 link->irq.active_high_low = p->active_high_low; 161 link->irq.polarity = p->polarity;
162 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; 162 link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
163 break; 163 break;
164 } 164 }
165 default: 165 default:
@@ -202,10 +202,10 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); 202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
203 203
204 switch (resource->type) { 204 switch (resource->type) {
205 case ACPI_RSTYPE_IRQ: 205 case ACPI_RESOURCE_TYPE_IRQ:
206 { 206 {
207 struct acpi_resource_irq *p = &resource->data.irq; 207 struct acpi_resource_irq *p = &resource->data.irq;
208 if (!p || !p->number_of_interrupts) { 208 if (!p || !p->interrupt_count) {
209 /* 209 /*
210 * IRQ descriptors may have no IRQ# bits set, 210 * IRQ descriptors may have no IRQ# bits set,
211 * particularly those those w/ _STA disabled 211 * particularly those those w/ _STA disabled
@@ -217,11 +217,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
217 *irq = p->interrupts[0]; 217 *irq = p->interrupts[0];
218 break; 218 break;
219 } 219 }
220 case ACPI_RSTYPE_EXT_IRQ: 220 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
221 { 221 {
222 struct acpi_resource_ext_irq *p = 222 struct acpi_resource_extended_irq *p =
223 &resource->data.extended_irq; 223 &resource->data.extended_irq;
224 if (!p || !p->number_of_interrupts) { 224 if (!p || !p->interrupt_count) {
225 /* 225 /*
226 * extended IRQ descriptors must 226 * extended IRQ descriptors must
227 * return at least 1 IRQ 227 * return at least 1 IRQ
@@ -325,36 +325,36 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
325 buffer.pointer = resource; 325 buffer.pointer = resource;
326 326
327 switch (link->irq.resource_type) { 327 switch (link->irq.resource_type) {
328 case ACPI_RSTYPE_IRQ: 328 case ACPI_RESOURCE_TYPE_IRQ:
329 resource->res.type = ACPI_RSTYPE_IRQ; 329 resource->res.type = ACPI_RESOURCE_TYPE_IRQ;
330 resource->res.length = sizeof(struct acpi_resource); 330 resource->res.length = sizeof(struct acpi_resource);
331 resource->res.data.irq.edge_level = link->irq.edge_level; 331 resource->res.data.irq.triggering = link->irq.triggering;
332 resource->res.data.irq.active_high_low = 332 resource->res.data.irq.polarity =
333 link->irq.active_high_low; 333 link->irq.polarity;
334 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 334 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
335 resource->res.data.irq.shared_exclusive = 335 resource->res.data.irq.sharable =
336 ACPI_EXCLUSIVE; 336 ACPI_EXCLUSIVE;
337 else 337 else
338 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 338 resource->res.data.irq.sharable = ACPI_SHARED;
339 resource->res.data.irq.number_of_interrupts = 1; 339 resource->res.data.irq.interrupt_count = 1;
340 resource->res.data.irq.interrupts[0] = irq; 340 resource->res.data.irq.interrupts[0] = irq;
341 break; 341 break;
342 342
343 case ACPI_RSTYPE_EXT_IRQ: 343 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
344 resource->res.type = ACPI_RSTYPE_EXT_IRQ; 344 resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
345 resource->res.length = sizeof(struct acpi_resource); 345 resource->res.length = sizeof(struct acpi_resource);
346 resource->res.data.extended_irq.producer_consumer = 346 resource->res.data.extended_irq.producer_consumer =
347 ACPI_CONSUMER; 347 ACPI_CONSUMER;
348 resource->res.data.extended_irq.edge_level = 348 resource->res.data.extended_irq.triggering =
349 link->irq.edge_level; 349 link->irq.triggering;
350 resource->res.data.extended_irq.active_high_low = 350 resource->res.data.extended_irq.polarity =
351 link->irq.active_high_low; 351 link->irq.polarity;
352 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 352 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
353 resource->res.data.irq.shared_exclusive = 353 resource->res.data.irq.sharable =
354 ACPI_EXCLUSIVE; 354 ACPI_EXCLUSIVE;
355 else 355 else
356 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 356 resource->res.data.irq.sharable = ACPI_SHARED;
357 resource->res.data.extended_irq.number_of_interrupts = 1; 357 resource->res.data.extended_irq.interrupt_count = 1;
358 resource->res.data.extended_irq.interrupts[0] = irq; 358 resource->res.data.extended_irq.interrupts[0] = irq;
359 /* ignore resource_source, it's optional */ 359 /* ignore resource_source, it's optional */
360 break; 360 break;
@@ -364,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
364 goto end; 364 goto end;
365 365
366 } 366 }
367 resource->end.type = ACPI_RSTYPE_END_TAG; 367 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
368 368
369 /* Attempt to set the resource */ 369 /* Attempt to set the resource */
370 status = acpi_set_current_resources(link->handle, &buffer); 370 status = acpi_set_current_resources(link->handle, &buffer);
@@ -613,7 +613,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
613int 613int
614acpi_pci_link_allocate_irq(acpi_handle handle, 614acpi_pci_link_allocate_irq(acpi_handle handle,
615 int index, 615 int index,
616 int *edge_level, int *active_high_low, char **name) 616 int *triggering, int *polarity, char **name)
617{ 617{
618 int result = 0; 618 int result = 0;
619 struct acpi_device *device = NULL; 619 struct acpi_device *device = NULL;
@@ -653,10 +653,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
653 link->refcnt++; 653 link->refcnt++;
654 up(&acpi_link_lock); 654 up(&acpi_link_lock);
655 655
656 if (edge_level) 656 if (triggering)
657 *edge_level = link->irq.edge_level; 657 *triggering = link->irq.triggering;
658 if (active_high_low) 658 if (polarity)
659 *active_high_low = link->irq.active_high_low; 659 *polarity = link->irq.polarity;
660 if (name) 660 if (name)
661 *name = acpi_device_bid(link->device); 661 *name = acpi_device_bid(link->device);
662 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 662 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 5d6bc815fe72..4c313eab6313 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -122,15 +122,15 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
122 int *busnr = (int *)data; 122 int *busnr = (int *)data;
123 struct acpi_resource_address64 address; 123 struct acpi_resource_address64 address;
124 124
125 if (resource->type != ACPI_RSTYPE_ADDRESS16 && 125 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
126 resource->type != ACPI_RSTYPE_ADDRESS32 && 126 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
127 resource->type != ACPI_RSTYPE_ADDRESS64) 127 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
128 return AE_OK; 128 return AE_OK;
129 129
130 acpi_resource_to_address64(resource, &address); 130 acpi_resource_to_address64(resource, &address);
131 if ((address.address_length > 0) && 131 if ((address.address_length > 0) &&
132 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 132 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
133 *busnr = address.min_address_range; 133 *busnr = address.minimum;
134 134
135 return AE_OK; 135 return AE_OK;
136} 136}
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
index 2130b74170c3..8de4f69dfa09 100644
--- a/drivers/acpi/resources/Makefile
+++ b/drivers/acpi/resources/Makefile
@@ -2,7 +2,7 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ 5obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
6 rscalc.o rsirq.o rsmemory.o rsutils.o 6 rscalc.o rsirq.o rsmemory.o rsutils.o
7 7
8obj-$(ACPI_FUTURE_USAGE) += rsdump.o 8obj-$(ACPI_FUTURE_USAGE) += rsdump.o
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 798778261fb9..6f48ebf3304e 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -58,12 +58,20 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
58 58
59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); 59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
60 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
61/******************************************************************************* 69/*******************************************************************************
62 * 70 *
63 * FUNCTION: acpi_rs_decode_general_flags 71 * FUNCTION: acpi_rs_decode_general_flags
64 * 72 *
65 * PARAMETERS: Resource - Address resource data struct 73 * PARAMETERS: Resource - Address resource data struct
66 * Flags - Actual flag byte 74 * Flags - Raw AML flag byte
67 * 75 *
68 * RETURN: Decoded flag bits in resource struct 76 * RETURN: Decoded flag bits in resource struct
69 * 77 *
@@ -107,27 +115,19 @@ acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags)
107 115
108static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) 116static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
109{ 117{
110 u8 flags;
111
112 ACPI_FUNCTION_ENTRY(); 118 ACPI_FUNCTION_ENTRY();
113 119
114 /* Producer / Consumer - flag bit[0] */ 120 return ((u8)
115 121
116 flags = (u8) (resource->address.producer_consumer & 0x01); 122 /* Producer / Consumer - flag bit[0] */
117 123 ((resource->address.producer_consumer & 0x01) |
118 /* Decode (_DEC) - flag bit[1] */ 124 /* Decode (_DEC) - flag bit[1] */
119 125 ((resource->address.decode & 0x01) << 1) |
120 flags |= (u8) ((resource->address.decode & 0x01) << 1); 126 /* Min Address Fixed (_MIF) - flag bit[2] */
121 127 ((resource->address.min_address_fixed & 0x01) << 2) |
122 /* Min Address Fixed (_MIF) - flag bit[2] */ 128 /* Max Address Fixed (_MAF) - flag bit[3] */
123 129 ((resource->address.max_address_fixed & 0x01) << 3))
124 flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); 130 );
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} 131}
132 132
133/******************************************************************************* 133/*******************************************************************************
@@ -135,7 +135,7 @@ static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
135 * FUNCTION: acpi_rs_decode_specific_flags 135 * FUNCTION: acpi_rs_decode_specific_flags
136 * 136 *
137 * PARAMETERS: Resource - Address resource data struct 137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Actual flag byte 138 * Flags - Raw AML flag byte
139 * 139 *
140 * RETURN: Decoded flag bits in attribute struct 140 * RETURN: Decoded flag bits in attribute struct
141 * 141 *
@@ -189,921 +189,541 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags)
189 189
190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) 190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource)
191{ 191{
192 u8 flags = 0;
193
194 ACPI_FUNCTION_ENTRY(); 192 ACPI_FUNCTION_ENTRY();
195 193
196 if (resource->address.resource_type == ACPI_MEMORY_RANGE) { 194 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
197 /* Write Status (_RW) - flag bit[0] */ 195 return ((u8)
198 196
199 flags = (u8) 197 /* Write Status (_RW) - flag bit[0] */
200 (resource->address.attribute.memory. 198 ((resource->address.attribute.memory.
201 read_write_attribute & 0x01); 199 read_write_attribute & 0x01) |
202 200 /* Memory Attributes (_MEM) - flag bits[2:1] */
203 /* Memory Attributes (_MEM) - flag bits[2:1] */ 201 ((resource->address.attribute.memory.
204 202 cache_attribute & 0x03) << 1)));
205 flags |= (u8)
206 ((resource->address.attribute.memory.
207 cache_attribute & 0x03) << 1);
208 } else if (resource->address.resource_type == ACPI_IO_RANGE) { 203 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
209 /* Ranges (_RNG) - flag bits[1:0] */ 204 return ((u8)
210 205
211 flags = (u8) 206 /* Ranges (_RNG) - flag bits[1:0] */
212 (resource->address.attribute.io.range_attribute & 0x03); 207 ((resource->address.attribute.io.
213 208 range_attribute & 0x03) |
214 /* Translations (_TTP and _TRS) - flag bits[5:4] */ 209 /* Translations (_TTP and _TRS) - flag bits[5:4] */
215 210 ((resource->address.attribute.io.
216 flags |= (u8) 211 translation_attribute & 0x03) << 4)));
217 ((resource->address.attribute.io.
218 translation_attribute & 0x03) << 4);
219 } 212 }
220 213
221 return (flags); 214 return (0);
222} 215}
223 216
224/******************************************************************************* 217/*******************************************************************************
225 * 218 *
226 * FUNCTION: acpi_rs_address16_resource 219 * FUNCTION: acpi_rs_set_address_common
227 * 220 *
228 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 221 * PARAMETERS: Aml - Pointer to the AML resource descriptor
229 * stream 222 * Resource - Pointer to the internal resource struct
230 * bytes_consumed - Pointer to where the number of bytes
231 * consumed the byte_stream_buffer is
232 * returned
233 * output_buffer - Pointer to the return data buffer
234 * structure_size - Pointer to where the number of bytes
235 * in the return data struct is returned
236 * 223 *
237 * RETURN: Status 224 * RETURN: None
238 * 225 *
239 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 226 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
240 * structure pointed to by the output_buffer. Return the 227 * AML descriptor
241 * number of bytes consumed from the byte stream.
242 * 228 *
243 ******************************************************************************/ 229 ******************************************************************************/
244 230
245acpi_status 231static void
246acpi_rs_address16_resource(u8 * byte_stream_buffer, 232acpi_rs_set_address_common(union aml_resource *aml,
247 acpi_size * bytes_consumed, 233 struct acpi_resource *resource)
248 u8 ** output_buffer, acpi_size * structure_size)
249{ 234{
250 u32 index; 235 ACPI_FUNCTION_ENTRY();
251 u16 temp16;
252 u8 temp8;
253 u8 *temp_ptr;
254 u8 *buffer = byte_stream_buffer;
255 struct acpi_resource *output_struct = (void *)*output_buffer;
256 acpi_size struct_size =
257 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
258 236
259 ACPI_FUNCTION_TRACE("rs_address16_resource"); 237 /* Set the Resource Type (Memory, Io, bus_number, etc.) */
260 238
261 /* Get the Descriptor Length field */ 239 aml->address.resource_type = (u8) resource->data.address.resource_type;
262 240
263 buffer += 1; 241 /* Set the general flags */
264 ACPI_MOVE_16_TO_16(&temp16, buffer);
265 242
266 /* Validate minimum descriptor length */ 243 aml->address.flags = acpi_rs_encode_general_flags(&resource->data);
267 244
268 if (temp16 < 13) { 245 /* Set the type-specific flags */
269 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
270 }
271 246
272 *bytes_consumed = temp16 + 3; 247 aml->address.specific_flags =
273 output_struct->type = ACPI_RSTYPE_ADDRESS16; 248 acpi_rs_encode_specific_flags(&resource->data);
249}
274 250
275 /* Get the Resource Type (Byte3) */ 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 ******************************************************************************/
276 264
277 buffer += 2; 265static u8
278 temp8 = *buffer; 266acpi_rs_get_address_common(struct acpi_resource *resource,
267 union aml_resource *aml)
268{
269 ACPI_FUNCTION_ENTRY();
279 270
280 /* Values 0-2 and 0xC0-0xFF are valid */ 271 /* Validate resource type */
281 272
282 if ((temp8 > 2) && (temp8 < 0xC0)) { 273 if ((aml->address.resource_type > 2)
283 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 274 && (aml->address.resource_type < 0xC0)) {
275 return (FALSE);
284 } 276 }
285 277
286 output_struct->data.address16.resource_type = temp8; 278 /* Get the Resource Type (Memory, Io, bus_number, etc.) */
287
288 /* Get the General Flags (Byte4) */
289
290 buffer += 1;
291 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
292
293 /* Get the Type Specific Flags (Byte5) */
294
295 buffer += 1;
296 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
297
298 /* Get Granularity (Bytes 6-7) */
299
300 buffer += 1;
301 ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
302 279
303 /* Get min_address_range (Bytes 8-9) */ 280 resource->data.address.resource_type = aml->address.resource_type;
304 281
305 buffer += 2; 282 /* Get the General Flags */
306 ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
307 buffer);
308 283
309 /* Get max_address_range (Bytes 10-11) */ 284 acpi_rs_decode_general_flags(&resource->data, aml->address.flags);
310 285
311 buffer += 2; 286 /* Get the Type-Specific Flags */
312 ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
313 buffer);
314 287
315 /* Get address_translation_offset (Bytes 12-13) */ 288 acpi_rs_decode_specific_flags(&resource->data,
316 289 aml->address.specific_flags);
317 buffer += 2; 290 return (TRUE);
318 ACPI_MOVE_16_TO_32(&output_struct->data.address16. 291}
319 address_translation_offset, buffer);
320 292
321 /* Get address_length (Bytes 14-15) */ 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 ******************************************************************************/
322 308
323 buffer += 2; 309acpi_status
324 ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length, 310acpi_rs_get_address16(union aml_resource * aml,
325 buffer); 311 u16 aml_resource_length, struct acpi_resource * resource)
312{
313 ACPI_FUNCTION_TRACE("rs_get_address16");
326 314
327 /* Resource Source Index (if present) */ 315 /* Get the Resource Type, general flags, and type-specific flags */
328 316
329 buffer += 2; 317 if (!acpi_rs_get_address_common(resource, aml)) {
318 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
319 }
330 320
331 /* 321 /*
332 * This will leave us pointing to the Resource Source Index 322 * Get the following contiguous fields from the AML descriptor:
333 * If it is present, then save it off and calculate the 323 * Address Granularity
334 * pointer to where the null terminated string goes: 324 * Address Range Minimum
335 * Each Interrupt takes 32-bits + the 5 bytes of the 325 * Address Range Maximum
336 * stream that are default. 326 * Address Translation Offset
337 * 327 * Address Length
338 * Note: Some resource descriptors will have an additional null, so
339 * we add 1 to the length.
340 */ 328 */
341 if (*bytes_consumed > (16 + 1)) { 329 acpi_rs_move_data(&resource->data.address16.granularity,
342 /* Dereference the Index */ 330 &aml->address16.granularity, 5,
343 331 ACPI_MOVE_TYPE_16_TO_32);
344 output_struct->data.address16.resource_source.index =
345 (u32) * buffer;
346
347 /* Point to the String */
348 332
349 buffer += 1; 333 /* Get the optional resource_source (index and string) */
350 334
351 /* Point the String pointer to the end of this structure */ 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);
352 341
353 output_struct->data.address16.resource_source.string_ptr = 342 /* Complete the resource header */
354 (char *)((u8 *) output_struct + struct_size);
355 343
356 temp_ptr = (u8 *) 344 resource->type = ACPI_RESOURCE_TYPE_ADDRESS16;
357 output_struct->data.address16.resource_source.string_ptr;
358
359 /* Copy the resource_source string into the buffer */
360
361 index = 0;
362 while (*buffer) {
363 *temp_ptr = *buffer;
364
365 temp_ptr++;
366 buffer++;
367 index++;
368 }
369
370 /* Add the terminating null and set the string length */
371
372 *temp_ptr = 0;
373 output_struct->data.address16.resource_source.string_length =
374 index + 1;
375
376 /*
377 * In order for the struct_size to fall on a 32-bit boundary,
378 * calculate the length of the string and expand the
379 * struct_size to the next 32-bit boundary.
380 */
381 temp8 = (u8) (index + 1);
382 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
383 } else {
384 output_struct->data.address16.resource_source.index = 0;
385 output_struct->data.address16.resource_source.string_length = 0;
386 output_struct->data.address16.resource_source.string_ptr = NULL;
387 }
388
389 /* Set the Length parameter */
390
391 output_struct->length = (u32) struct_size;
392
393 /* Return the final size of the structure */
394
395 *structure_size = struct_size;
396 return_ACPI_STATUS(AE_OK); 345 return_ACPI_STATUS(AE_OK);
397} 346}
398 347
399/******************************************************************************* 348/*******************************************************************************
400 * 349 *
401 * FUNCTION: acpi_rs_address16_stream 350 * FUNCTION: acpi_rs_set_address16
402 * 351 *
403 * PARAMETERS: Resource - Pointer to the resource linked list 352 * PARAMETERS: Resource - Pointer to the resource descriptor
404 * output_buffer - Pointer to the user's return buffer 353 * Aml - Where the AML descriptor is returned
405 * bytes_consumed - Pointer to where the number of bytes
406 * used in the output_buffer is returned
407 * 354 *
408 * RETURN: Status 355 * RETURN: Status
409 * 356 *
410 * DESCRIPTION: Take the linked list resource structure and fills in the 357 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
411 * the appropriate bytes in a byte stream 358 * external AML resource descriptor.
412 * 359 *
413 ******************************************************************************/ 360 ******************************************************************************/
414 361
415acpi_status 362acpi_status
416acpi_rs_address16_stream(struct acpi_resource *resource, 363acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml)
417 u8 ** output_buffer, acpi_size * bytes_consumed)
418{ 364{
419 u8 *buffer = *output_buffer; 365 acpi_size descriptor_length;
420 u8 *length_field;
421 acpi_size actual_bytes;
422
423 ACPI_FUNCTION_TRACE("rs_address16_stream");
424
425 /* Set the Descriptor Type field */
426 366
427 *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; 367 ACPI_FUNCTION_TRACE("rs_set_address16");
428 buffer += 1;
429 368
430 /* Save a pointer to the Length field - to be filled in later */ 369 /* Set the Resource Type, General Flags, and Type-Specific Flags */
431 370
432 length_field = buffer; 371 acpi_rs_set_address_common(aml, resource);
433 buffer += 2;
434
435 /* Set the Resource Type (Memory, Io, bus_number) */
436
437 *buffer = (u8) (resource->data.address16.resource_type & 0x03);
438 buffer += 1;
439
440 /* Set the general flags */
441 372
442 *buffer = acpi_rs_encode_general_flags(&resource->data); 373 /*
443 buffer += 1; 374 * Set the following contiguous fields in the AML descriptor:
444 375 * Address Granularity
445 /* Set the type specific flags */ 376 * Address Range Minimum
446 377 * Address Range Maximum
447 *buffer = acpi_rs_encode_specific_flags(&resource->data); 378 * Address Translation Offset
448 buffer += 1; 379 * Address Length
449 380 */
450 /* Set the address space granularity */ 381 acpi_rs_move_data(&aml->address16.granularity,
451 382 &resource->data.address16.granularity, 5,
452 ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.granularity); 383 ACPI_MOVE_TYPE_32_TO_16);
453 buffer += 2;
454
455 /* Set the address range minimum */
456
457 ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.min_address_range);
458 buffer += 2;
459
460 /* Set the address range maximum */
461
462 ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.max_address_range);
463 buffer += 2;
464
465 /* Set the address translation offset */
466
467 ACPI_MOVE_32_TO_16(buffer,
468 &resource->data.address16.
469 address_translation_offset);
470 buffer += 2;
471
472 /* Set the address length */
473
474 ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.address_length);
475 buffer += 2;
476 384
477 /* Resource Source Index and Resource Source are optional */ 385 /* Resource Source Index and Resource Source are optional */
478 386
479 if (resource->data.address16.resource_source.string_length) { 387 descriptor_length = acpi_rs_set_resource_source(aml,
480 *buffer = (u8) resource->data.address16.resource_source.index; 388 sizeof(struct
481 buffer += 1; 389 aml_resource_address16),
390 &resource->data.
391 address16.
392 resource_source);
482 393
483 /* Copy the resource_source string */ 394 /* Complete the AML descriptor header */
484 395
485 ACPI_STRCPY((char *)buffer, 396 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16,
486 resource->data.address16.resource_source. 397 descriptor_length, aml);
487 string_ptr);
488
489 /*
490 * Buffer needs to be set to the length of the string + one for the
491 * terminating null
492 */
493 buffer +=
494 (acpi_size) (ACPI_STRLEN
495 (resource->data.address16.resource_source.
496 string_ptr) + 1);
497 }
498
499 /* Return the number of bytes consumed in this operation */
500
501 actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
502 *bytes_consumed = actual_bytes;
503
504 /*
505 * Set the length field to the number of bytes consumed
506 * minus the header size (3 bytes)
507 */
508 actual_bytes -= 3;
509 ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
510 return_ACPI_STATUS(AE_OK); 398 return_ACPI_STATUS(AE_OK);
511} 399}
512 400
513/******************************************************************************* 401/*******************************************************************************
514 * 402 *
515 * FUNCTION: acpi_rs_address32_resource 403 * FUNCTION: acpi_rs_get_address32
516 * 404 *
517 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 405 * PARAMETERS: Aml - Pointer to the AML resource descriptor
518 * stream 406 * aml_resource_length - Length of the resource from the AML header
519 * bytes_consumed - Pointer to where the number of bytes 407 * Resource - Where the internal resource is returned
520 * consumed the byte_stream_buffer is
521 * returned
522 * output_buffer - Pointer to the return data buffer
523 * structure_size - Pointer to where the number of bytes
524 * in the return data struct is returned
525 * 408 *
526 * RETURN: Status 409 * RETURN: Status
527 * 410 *
528 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 411 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
529 * structure pointed to by the output_buffer. Return the 412 * internal resource descriptor, simplifying bitflags and handling
530 * number of bytes consumed from the byte stream. 413 * alignment and endian issues if necessary.
531 * 414 *
532 ******************************************************************************/ 415 ******************************************************************************/
533 416
534acpi_status 417acpi_status
535acpi_rs_address32_resource(u8 * byte_stream_buffer, 418acpi_rs_get_address32(union aml_resource *aml,
536 acpi_size * bytes_consumed, 419 u16 aml_resource_length, struct acpi_resource *resource)
537 u8 ** output_buffer, acpi_size * structure_size)
538{ 420{
539 u16 temp16;
540 u8 temp8;
541 u8 *temp_ptr;
542 u32 index;
543 u8 *buffer = byte_stream_buffer;
544 struct acpi_resource *output_struct = (void *)*output_buffer;
545 acpi_size struct_size =
546 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
547
548 ACPI_FUNCTION_TRACE("rs_address32_resource");
549
550 /* Get the Descriptor Length field */
551
552 buffer += 1;
553 ACPI_MOVE_16_TO_16(&temp16, buffer);
554 421
555 /* Validate minimum descriptor length */ 422 ACPI_FUNCTION_TRACE("rs_get_address32");
556 423
557 if (temp16 < 23) { 424 /* Get the Resource Type, general flags, and type-specific flags */
558 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
559 }
560
561 *bytes_consumed = temp16 + 3;
562 output_struct->type = ACPI_RSTYPE_ADDRESS32;
563
564 /* Get the Resource Type (Byte3) */
565
566 buffer += 2;
567 temp8 = *buffer;
568 425
569 /* Values 0-2 and 0xC0-0xFF are valid */ 426 if (!acpi_rs_get_address_common(resource, (void *)aml)) {
570
571 if ((temp8 > 2) && (temp8 < 0xC0)) {
572 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 427 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
573 } 428 }
574 429
575 output_struct->data.address32.resource_type = temp8;
576
577 /* Get the General Flags (Byte4) */
578
579 buffer += 1;
580 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
581
582 /* Get the Type Specific Flags (Byte5) */
583
584 buffer += 1;
585 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
586
587 /* Get Granularity (Bytes 6-9) */
588
589 buffer += 1;
590 ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
591
592 /* Get min_address_range (Bytes 10-13) */
593
594 buffer += 4;
595 ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
596 buffer);
597
598 /* Get max_address_range (Bytes 14-17) */
599
600 buffer += 4;
601 ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
602 buffer);
603
604 /* Get address_translation_offset (Bytes 18-21) */
605
606 buffer += 4;
607 ACPI_MOVE_32_TO_32(&output_struct->data.address32.
608 address_translation_offset, buffer);
609
610 /* Get address_length (Bytes 22-25) */
611
612 buffer += 4;
613 ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
614 buffer);
615
616 /* Resource Source Index (if present) */
617
618 buffer += 4;
619
620 /* 430 /*
621 * This will leave us pointing to the Resource Source Index 431 * Get the following contiguous fields from the AML descriptor:
622 * If it is present, then save it off and calculate the 432 * Address Granularity
623 * pointer to where the null terminated string goes: 433 * Address Range Minimum
624 * 434 * Address Range Maximum
625 * Note: Some resource descriptors will have an additional null, so 435 * Address Translation Offset
626 * we add 1 to the length. 436 * Address Length
627 */ 437 */
628 if (*bytes_consumed > (26 + 1)) { 438 acpi_rs_move_data(&resource->data.address32.granularity,
629 /* Dereference the Index */ 439 &aml->address32.granularity, 5,
630 440 ACPI_MOVE_TYPE_32_TO_32);
631 output_struct->data.address32.resource_source.index =
632 (u32) * buffer;
633
634 /* Point to the String */
635 441
636 buffer += 1; 442 /* Get the optional resource_source (index and string) */
637 443
638 /* Point the String pointer to the end of this structure */ 444 resource->length =
445 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) +
446 acpi_rs_get_resource_source(aml_resource_length,
447 sizeof(struct aml_resource_address32),
448 &resource->data.address32.
449 resource_source, aml, NULL);
639 450
640 output_struct->data.address32.resource_source.string_ptr = 451 /* Complete the resource header */
641 (char *)((u8 *) output_struct + struct_size);
642 452
643 temp_ptr = (u8 *) 453 resource->type = ACPI_RESOURCE_TYPE_ADDRESS32;
644 output_struct->data.address32.resource_source.string_ptr;
645
646 /* Copy the resource_source string into the buffer */
647
648 index = 0;
649 while (*buffer) {
650 *temp_ptr = *buffer;
651
652 temp_ptr++;
653 buffer++;
654 index++;
655 }
656
657 /* Add the terminating null and set the string length */
658
659 *temp_ptr = 0;
660 output_struct->data.address32.resource_source.string_length =
661 index + 1;
662
663 /*
664 * In order for the struct_size to fall on a 32-bit boundary,
665 * calculate the length of the string and expand the
666 * struct_size to the next 32-bit boundary.
667 */
668 temp8 = (u8) (index + 1);
669 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
670 } else {
671 output_struct->data.address32.resource_source.index = 0;
672 output_struct->data.address32.resource_source.string_length = 0;
673 output_struct->data.address32.resource_source.string_ptr = NULL;
674 }
675
676 /* Set the Length parameter */
677
678 output_struct->length = (u32) struct_size;
679
680 /* Return the final size of the structure */
681
682 *structure_size = struct_size;
683 return_ACPI_STATUS(AE_OK); 454 return_ACPI_STATUS(AE_OK);
684} 455}
685 456
686/******************************************************************************* 457/*******************************************************************************
687 * 458 *
688 * FUNCTION: acpi_rs_address32_stream 459 * FUNCTION: acpi_rs_set_address32
689 * 460 *
690 * PARAMETERS: Resource - Pointer to the resource linked list 461 * PARAMETERS: Resource - Pointer to the resource descriptor
691 * output_buffer - Pointer to the user's return buffer 462 * Aml - Where the AML descriptor is returned
692 * bytes_consumed - Pointer to where the number of bytes
693 * used in the output_buffer is returned
694 * 463 *
695 * RETURN: Status 464 * RETURN: Status
696 * 465 *
697 * DESCRIPTION: Take the linked list resource structure and fills in the 466 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
698 * the appropriate bytes in a byte stream 467 * external AML resource descriptor.
699 * 468 *
700 ******************************************************************************/ 469 ******************************************************************************/
701 470
702acpi_status 471acpi_status
703acpi_rs_address32_stream(struct acpi_resource *resource, 472acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml)
704 u8 ** output_buffer, acpi_size * bytes_consumed)
705{ 473{
706 u8 *buffer; 474 acpi_size descriptor_length;
707 u16 *length_field;
708
709 ACPI_FUNCTION_TRACE("rs_address32_stream");
710
711 buffer = *output_buffer;
712 475
713 /* Set the Descriptor Type field */ 476 ACPI_FUNCTION_TRACE("rs_set_address32");
714 477
715 *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; 478 /* Set the Resource Type, General Flags, and Type-Specific Flags */
716 buffer += 1;
717 479
718 /* Save a pointer to the Length field - to be filled in later */ 480 acpi_rs_set_address_common(aml, resource);
719 481
720 length_field = ACPI_CAST_PTR(u16, buffer); 482 /*
721 buffer += 2; 483 * Set the following contiguous fields in the AML descriptor:
722 484 * Address Granularity
723 /* Set the Resource Type (Memory, Io, bus_number) */ 485 * Address Range Minimum
724 486 * Address Range Maximum
725 *buffer = (u8) (resource->data.address32.resource_type & 0x03); 487 * Address Translation Offset
726 buffer += 1; 488 * Address Length
727 489 */
728 /* Set the general flags */ 490 acpi_rs_move_data(&aml->address32.granularity,
729 491 &resource->data.address32.granularity, 5,
730 *buffer = acpi_rs_encode_general_flags(&resource->data); 492 ACPI_MOVE_TYPE_32_TO_32);
731 buffer += 1;
732
733 /* Set the type specific flags */
734
735 *buffer = acpi_rs_encode_specific_flags(&resource->data);
736 buffer += 1;
737
738 /* Set the address space granularity */
739
740 ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.granularity);
741 buffer += 4;
742
743 /* Set the address range minimum */
744
745 ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.min_address_range);
746 buffer += 4;
747
748 /* Set the address range maximum */
749
750 ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.max_address_range);
751 buffer += 4;
752
753 /* Set the address translation offset */
754
755 ACPI_MOVE_32_TO_32(buffer,
756 &resource->data.address32.
757 address_translation_offset);
758 buffer += 4;
759
760 /* Set the address length */
761
762 ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.address_length);
763 buffer += 4;
764 493
765 /* Resource Source Index and Resource Source are optional */ 494 /* Resource Source Index and Resource Source are optional */
766 495
767 if (resource->data.address32.resource_source.string_length) { 496 descriptor_length = acpi_rs_set_resource_source(aml,
768 *buffer = (u8) resource->data.address32.resource_source.index; 497 sizeof(struct
769 buffer += 1; 498 aml_resource_address32),
770 499 &resource->data.
771 /* Copy the resource_source string */ 500 address32.
501 resource_source);
772 502
773 ACPI_STRCPY((char *)buffer, 503 /* Complete the AML descriptor header */
774 resource->data.address32.resource_source.
775 string_ptr);
776 504
777 /* 505 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32,
778 * Buffer needs to be set to the length of the string + one for the 506 descriptor_length, aml);
779 * terminating null
780 */
781 buffer +=
782 (acpi_size) (ACPI_STRLEN
783 (resource->data.address32.resource_source.
784 string_ptr) + 1);
785 }
786
787 /* Return the number of bytes consumed in this operation */
788
789 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
790
791 /*
792 * Set the length field to the number of bytes consumed
793 * minus the header size (3 bytes)
794 */
795 *length_field = (u16) (*bytes_consumed - 3);
796 return_ACPI_STATUS(AE_OK); 507 return_ACPI_STATUS(AE_OK);
797} 508}
798 509
799/******************************************************************************* 510/*******************************************************************************
800 * 511 *
801 * FUNCTION: acpi_rs_address64_resource 512 * FUNCTION: acpi_rs_get_address64
802 * 513 *
803 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 514 * PARAMETERS: Aml - Pointer to the AML resource descriptor
804 * stream 515 * aml_resource_length - Length of the resource from the AML header
805 * bytes_consumed - Pointer to where the number of bytes 516 * Resource - Where the internal resource is returned
806 * consumed the byte_stream_buffer is
807 * returned
808 * output_buffer - Pointer to the return data buffer
809 * structure_size - Pointer to where the number of bytes
810 * in the return data struct is returned
811 * 517 *
812 * RETURN: Status 518 * RETURN: Status
813 * 519 *
814 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 520 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
815 * structure pointed to by the output_buffer. Return the 521 * internal resource descriptor, simplifying bitflags and handling
816 * number of bytes consumed from the byte stream. 522 * alignment and endian issues if necessary.
817 * 523 *
818 ******************************************************************************/ 524 ******************************************************************************/
819 525
820acpi_status 526acpi_status
821acpi_rs_address64_resource(u8 * byte_stream_buffer, 527acpi_rs_get_address64(union aml_resource *aml,
822 acpi_size * bytes_consumed, 528 u16 aml_resource_length, struct acpi_resource *resource)
823 u8 ** output_buffer, acpi_size * structure_size)
824{ 529{
825 u16 temp16; 530 ACPI_FUNCTION_TRACE("rs_get_address64");
826 u8 temp8;
827 u8 resource_type;
828 u8 *temp_ptr;
829 u32 index;
830 u8 *buffer = byte_stream_buffer;
831 struct acpi_resource *output_struct = (void *)*output_buffer;
832 acpi_size struct_size =
833 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
834
835 ACPI_FUNCTION_TRACE("rs_address64_resource");
836
837 /* Get the Descriptor Type */
838
839 resource_type = *buffer;
840
841 /* Get the Descriptor Length field */
842
843 buffer += 1;
844 ACPI_MOVE_16_TO_16(&temp16, buffer);
845
846 /* Validate minimum descriptor length */
847
848 if (temp16 < 43) {
849 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
850 }
851
852 *bytes_consumed = temp16 + 3;
853 output_struct->type = ACPI_RSTYPE_ADDRESS64;
854
855 /* Get the Resource Type (Byte3) */
856 531
857 buffer += 2; 532 /* Get the Resource Type, general Flags, and type-specific Flags */
858 temp8 = *buffer;
859 533
860 /* Values 0-2 and 0xC0-0xFF are valid */ 534 if (!acpi_rs_get_address_common(resource, aml)) {
861
862 if ((temp8 > 2) && (temp8 < 0xC0)) {
863 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 535 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
864 } 536 }
865 537
866 output_struct->data.address64.resource_type = temp8; 538 /*
867 539 * Get the following contiguous fields from the AML descriptor:
868 /* Get the General Flags (Byte4) */ 540 * Address Granularity
869 541 * Address Range Minimum
870 buffer += 1; 542 * Address Range Maximum
871 acpi_rs_decode_general_flags(&output_struct->data, *buffer); 543 * Address Translation Offset
872 544 * Address Length
873 /* Get the Type Specific Flags (Byte5) */ 545 */
874 546 acpi_rs_move_data(&resource->data.address64.granularity,
875 buffer += 1; 547 &aml->address64.granularity, 5,
876 acpi_rs_decode_specific_flags(&output_struct->data, *buffer); 548 ACPI_MOVE_TYPE_64_TO_64);
877
878 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) {
879 /* Move past revision_id and Reserved byte */
880
881 buffer += 2;
882 }
883
884 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
885
886 buffer += 1;
887 ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
888
889 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
890
891 buffer += 8;
892 ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
893 buffer);
894
895 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
896
897 buffer += 8;
898 ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
899 buffer);
900
901 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
902
903 buffer += 8;
904 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
905 address_translation_offset, buffer);
906 549
907 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 550 /* Get the optional resource_source (index and string) */
908 551
909 buffer += 8; 552 resource->length =
910 ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, 553 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) +
911 buffer); 554 acpi_rs_get_resource_source(aml_resource_length,
555 sizeof(struct aml_resource_address64),
556 &resource->data.address64.
557 resource_source, aml, NULL);
912 558
913 output_struct->data.address64.resource_source.index = 0; 559 /* Complete the resource header */
914 output_struct->data.address64.resource_source.string_length = 0;
915 output_struct->data.address64.resource_source.string_ptr = NULL;
916 560
917 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 561 resource->type = ACPI_RESOURCE_TYPE_ADDRESS64;
918 /* Get type_specific_attribute (Bytes 48-55) */ 562 return_ACPI_STATUS(AE_OK);
563}
919 564
920 buffer += 8; 565/*******************************************************************************
921 ACPI_MOVE_64_TO_64(&output_struct->data.address64. 566 *
922 type_specific_attributes, buffer); 567 * FUNCTION: acpi_rs_set_address64
923 } else { 568 *
924 output_struct->data.address64.type_specific_attributes = 0; 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 *
577 ******************************************************************************/
925 578
926 /* Resource Source Index (if present) */ 579acpi_status
580acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml)
581{
582 acpi_size descriptor_length;
927 583
928 buffer += 8; 584 ACPI_FUNCTION_TRACE("rs_set_address64");
929 585
930 /* 586 /* Set the Resource Type, General Flags, and Type-Specific Flags */
931 * This will leave us pointing to the Resource Source Index
932 * If it is present, then save it off and calculate the
933 * pointer to where the null terminated string goes:
934 * Each Interrupt takes 32-bits + the 5 bytes of the
935 * stream that are default.
936 *
937 * Note: Some resource descriptors will have an additional null, so
938 * we add 1 to the length.
939 */
940 if (*bytes_consumed > (46 + 1)) {
941 /* Dereference the Index */
942 587
943 output_struct->data.address64.resource_source.index = 588 acpi_rs_set_address_common(aml, resource);
944 (u32) * buffer;
945 589
946 /* Point to the String */ 590 /*
591 * Set the following contiguous fields in the AML descriptor:
592 * Address Granularity
593 * Address Range Minimum
594 * Address Range Maximum
595 * Address Translation Offset
596 * Address Length
597 */
598 acpi_rs_move_data(&aml->address64.granularity,
599 &resource->data.address64.granularity, 5,
600 ACPI_MOVE_TYPE_64_TO_64);
947 601
948 buffer += 1; 602 /* Resource Source Index and Resource Source are optional */
949 603
950 /* Point the String pointer to the end of this structure */ 604 descriptor_length = acpi_rs_set_resource_source(aml,
605 sizeof(struct
606 aml_resource_address64),
607 &resource->data.
608 address64.
609 resource_source);
951 610
952 output_struct->data.address64.resource_source. 611 /* Complete the AML descriptor header */
953 string_ptr =
954 (char *)((u8 *) output_struct + struct_size);
955 612
956 temp_ptr = (u8 *) 613 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64,
957 output_struct->data.address64.resource_source. 614 descriptor_length, aml);
958 string_ptr; 615 return_ACPI_STATUS(AE_OK);
616}
959 617
960 /* Copy the resource_source string into the buffer */ 618/*******************************************************************************
619 *
620 * FUNCTION: acpi_rs_get_ext_address64
621 *
622 * PARAMETERS: Aml - Pointer to the AML resource descriptor
623 * aml_resource_length - Length of the resource from the AML header
624 * Resource - Where the internal resource is returned
625 *
626 * RETURN: Status
627 *
628 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
629 * internal resource descriptor, simplifying bitflags and handling
630 * alignment and endian issues if necessary.
631 *
632 ******************************************************************************/
961 633
962 index = 0; 634acpi_status
963 while (*buffer) { 635acpi_rs_get_ext_address64(union aml_resource *aml,
964 *temp_ptr = *buffer; 636 u16 aml_resource_length,
637 struct acpi_resource *resource)
638{
965 639
966 temp_ptr++; 640 ACPI_FUNCTION_TRACE("rs_get_ext_address64");
967 buffer++;
968 index++;
969 }
970 641
971 /* 642 /* Get the Resource Type, general flags, and type-specific flags */
972 * Add the terminating null and set the string length
973 */
974 *temp_ptr = 0;
975 output_struct->data.address64.resource_source.
976 string_length = index + 1;
977 643
978 /* 644 if (!acpi_rs_get_address_common(resource, aml)) {
979 * In order for the struct_size to fall on a 32-bit boundary, 645 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
980 * calculate the length of the string and expand the
981 * struct_size to the next 32-bit boundary.
982 */
983 temp8 = (u8) (index + 1);
984 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
985 }
986 } 646 }
987 647
988 /* Set the Length parameter */ 648 /*
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 }
989 658
990 output_struct->length = (u32) struct_size; 659 /*
660 * Get the following contiguous fields from the AML descriptor:
661 * Address Granularity
662 * Address Range Minimum
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);
991 671
992 /* Return the final size of the structure */ 672 /* Complete the resource header */
993 673
994 *structure_size = struct_size; 674 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64;
675 resource->length =
676 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64);
995 return_ACPI_STATUS(AE_OK); 677 return_ACPI_STATUS(AE_OK);
996} 678}
997 679
998/******************************************************************************* 680/*******************************************************************************
999 * 681 *
1000 * FUNCTION: acpi_rs_address64_stream 682 * FUNCTION: acpi_rs_set_ext_address64
1001 * 683 *
1002 * PARAMETERS: Resource - Pointer to the resource linked list 684 * PARAMETERS: Resource - Pointer to the resource descriptor
1003 * output_buffer - Pointer to the user's return buffer 685 * Aml - Where the AML descriptor is returned
1004 * bytes_consumed - Pointer to where the number of bytes
1005 * used in the output_buffer is returned
1006 * 686 *
1007 * RETURN: Status 687 * RETURN: Status
1008 * 688 *
1009 * DESCRIPTION: Take the linked list resource structure and fills in the 689 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
1010 * the appropriate bytes in a byte stream 690 * external AML resource descriptor.
1011 * 691 *
1012 ******************************************************************************/ 692 ******************************************************************************/
1013 693
1014acpi_status 694acpi_status
1015acpi_rs_address64_stream(struct acpi_resource *resource, 695acpi_rs_set_ext_address64(struct acpi_resource *resource,
1016 u8 ** output_buffer, acpi_size * bytes_consumed) 696 union aml_resource *aml)
1017{ 697{
1018 u8 *buffer; 698 ACPI_FUNCTION_TRACE("rs_set_ext_address64");
1019 u16 *length_field;
1020
1021 ACPI_FUNCTION_TRACE("rs_address64_stream");
1022
1023 buffer = *output_buffer;
1024
1025 /* Set the Descriptor Type field */
1026
1027 *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
1028 buffer += 1;
1029
1030 /* Save a pointer to the Length field - to be filled in later */
1031
1032 length_field = ACPI_CAST_PTR(u16, buffer);
1033 buffer += 2;
1034
1035 /* Set the Resource Type (Memory, Io, bus_number) */
1036
1037 *buffer = (u8) (resource->data.address64.resource_type & 0x03);
1038 buffer += 1;
1039
1040 /* Set the general flags */
1041
1042 *buffer = acpi_rs_encode_general_flags(&resource->data);
1043 buffer += 1;
1044
1045 /* Set the type specific flags */
1046
1047 *buffer = acpi_rs_encode_specific_flags(&resource->data);
1048 buffer += 1;
1049
1050 /* Set the address space granularity */
1051 699
1052 ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.granularity); 700 /* Set the Resource Type, General Flags, and Type-Specific Flags */
1053 buffer += 8;
1054 701
1055 /* Set the address range minimum */ 702 acpi_rs_set_address_common(aml, resource);
1056 703
1057 ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.min_address_range); 704 /* Only one Revision ID is currently supported */
1058 buffer += 8;
1059 705
1060 /* Set the address range maximum */ 706 aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
1061 707 aml->ext_address64.reserved = 0;
1062 ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.max_address_range);
1063 buffer += 8;
1064
1065 /* Set the address translation offset */
1066
1067 ACPI_MOVE_64_TO_64(buffer,
1068 &resource->data.address64.
1069 address_translation_offset);
1070 buffer += 8;
1071
1072 /* Set the address length */
1073
1074 ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.address_length);
1075 buffer += 8;
1076
1077 /* Resource Source Index and Resource Source are optional */
1078
1079 if (resource->data.address64.resource_source.string_length) {
1080 *buffer = (u8) resource->data.address64.resource_source.index;
1081 buffer += 1;
1082
1083 /* Copy the resource_source string */
1084
1085 ACPI_STRCPY((char *)buffer,
1086 resource->data.address64.resource_source.
1087 string_ptr);
1088
1089 /*
1090 * Buffer needs to be set to the length of the string + one for the
1091 * terminating null
1092 */
1093 buffer +=
1094 (acpi_size) (ACPI_STRLEN
1095 (resource->data.address64.resource_source.
1096 string_ptr) + 1);
1097 }
1098
1099 /* Return the number of bytes consumed in this operation */
1100
1101 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
1102 708
1103 /* 709 /*
1104 * Set the length field to the number of bytes consumed 710 * Set the following contiguous fields in the AML descriptor:
1105 * minus the header size (3 bytes) 711 * Address Granularity
712 * Address Range Minimum
713 * Address Range Maximum
714 * Address Translation Offset
715 * Address Length
716 * Type-Specific Attribute
1106 */ 717 */
1107 *length_field = (u16) (*bytes_consumed - 3); 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);
1108 return_ACPI_STATUS(AE_OK); 728 return_ACPI_STATUS(AE_OK);
1109} 729}
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 2da7c6a8182e..d170dee07ce9 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -44,87 +44,14 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/amlresrc.h>
48#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
51ACPI_MODULE_NAME("rscalc") 50ACPI_MODULE_NAME("rscalc")
52 51
53/*
54 * Base sizes for external resource descriptors, indexed by internal type.
55 * Includes size of the descriptor header (1 byte for small descriptors,
56 * 3 bytes for large descriptors)
57 */
58static u8 acpi_gbl_stream_sizes[] = {
59 4, /* ACPI_RSTYPE_IRQ (Byte 3 is optional, but always created) */
60 3, /* ACPI_RSTYPE_DMA */
61 2, /* ACPI_RSTYPE_START_DPF (Byte 1 is optional, but always created) */
62 1, /* ACPI_RSTYPE_END_DPF */
63 8, /* ACPI_RSTYPE_IO */
64 4, /* ACPI_RSTYPE_FIXED_IO */
65 1, /* ACPI_RSTYPE_VENDOR */
66 2, /* ACPI_RSTYPE_END_TAG */
67 12, /* ACPI_RSTYPE_MEM24 */
68 20, /* ACPI_RSTYPE_MEM32 */
69 12, /* ACPI_RSTYPE_FIXED_MEM32 */
70 16, /* ACPI_RSTYPE_ADDRESS16 */
71 26, /* ACPI_RSTYPE_ADDRESS32 */
72 46, /* ACPI_RSTYPE_ADDRESS64 */
73 9, /* ACPI_RSTYPE_EXT_IRQ */
74 15 /* ACPI_RSTYPE_GENERIC_REG */
75};
76
77/*
78 * Base sizes of resource descriptors, both the actual AML stream length and
79 * size of the internal struct representation.
80 */
81struct acpi_resource_sizes {
82 u8 minimum_stream_size;
83 u8 minimum_struct_size;
84};
85
86static struct acpi_resource_sizes acpi_gbl_sm_resource_sizes[] = {
87 {0, 0}, /* 0x00, Reserved */
88 {0, 0}, /* 0x01, Reserved */
89 {0, 0}, /* 0x02, Reserved */
90 {0, 0}, /* 0x03, Reserved */
91 {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, /* ACPI_RDESC_TYPE_IRQ_FORMAT */
92 {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, /* ACPI_RDESC_TYPE_DMA_FORMAT */
93 {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf)}, /* ACPI_RDESC_TYPE_START_DEPENDENT */
94 {1, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_DEPENDENT */
95 {8, ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, /* ACPI_RDESC_TYPE_IO_PORT */
96 {4, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */
97 {0, 0}, /* 0x0A, Reserved */
98 {0, 0}, /* 0x0B, Reserved */
99 {0, 0}, /* 0x0C, Reserved */
100 {0, 0}, /* 0x0D, Reserved */
101 {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_SMALL_VENDOR */
102 {2, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_TAG */
103};
104
105static struct acpi_resource_sizes acpi_gbl_lg_resource_sizes[] = {
106 {0, 0}, /* 0x00, Reserved */
107 {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24)}, /* ACPI_RDESC_TYPE_MEMORY_24 */
108 {15, ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg)}, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */
109 {0, 0}, /* 0x03, Reserved */
110 {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_LARGE_VENDOR */
111 {20, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32)}, /* ACPI_RDESC_TYPE_MEMORY_32 */
112 {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32)}, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */
113 {26, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */
114 {16, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */
115 {9, ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq)}, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */
116 {46, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */
117 {56, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */
118};
119
120/* Local prototypes */ 52/* Local prototypes */
121
122static u8 acpi_rs_count_set_bits(u16 bit_field); 53static u8 acpi_rs_count_set_bits(u16 bit_field);
123 54
124static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type);
125
126static u16 acpi_rs_get_resource_length(u8 * resource);
127
128static acpi_size 55static acpi_size
129acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); 56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
130 57
@@ -161,90 +88,6 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
161 88
162/******************************************************************************* 89/*******************************************************************************
163 * 90 *
164 * FUNCTION: acpi_rs_get_resource_sizes
165 *
166 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
167 *
168 * RETURN: Pointer to the resource conversion handler
169 *
170 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
171 * a resource descriptor.
172 *
173 ******************************************************************************/
174
175static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type)
176{
177 struct acpi_resource_sizes *size_info;
178
179 ACPI_FUNCTION_ENTRY();
180
181 /* Determine if this is a small or large resource */
182
183 if (resource_type & ACPI_RDESC_TYPE_LARGE) {
184 /* Large Resource Type -- bits 6:0 contain the name */
185
186 if (resource_type > ACPI_RDESC_LARGE_MAX) {
187 return (NULL);
188 }
189
190 size_info = &acpi_gbl_lg_resource_sizes[(resource_type &
191 ACPI_RDESC_LARGE_MASK)];
192 } else {
193 /* Small Resource Type -- bits 6:3 contain the name */
194
195 size_info = &acpi_gbl_sm_resource_sizes[((resource_type &
196 ACPI_RDESC_SMALL_MASK)
197 >> 3)];
198 }
199
200 /* Zero entry indicates an invalid resource type */
201
202 if (!size_info->minimum_stream_size) {
203 return (NULL);
204 }
205
206 return (size_info);
207}
208
209/*******************************************************************************
210 *
211 * FUNCTION: acpi_rs_get_resource_length
212 *
213 * PARAMETERS: Resource - Pointer to the resource descriptor
214 *
215 * RETURN: Byte length of the (AML byte stream) descriptor. By definition,
216 * this does not include the size of the descriptor header and the
217 * length field itself.
218 *
219 * DESCRIPTION: Extract the length of a resource descriptor.
220 *
221 ******************************************************************************/
222
223static u16 acpi_rs_get_resource_length(u8 * resource)
224{
225 u16 resource_length;
226
227 ACPI_FUNCTION_ENTRY();
228
229 /* Determine if this is a small or large resource */
230
231 if (*resource & ACPI_RDESC_TYPE_LARGE) {
232 /* Large Resource type -- length is in bytes 1-2 */
233
234 ACPI_MOVE_16_TO_16(&resource_length, (resource + 1));
235
236 } else {
237 /* Small Resource Type -- bits 2:0 of byte 0 contain the length */
238
239 resource_length =
240 (u16) (*resource & ACPI_RDESC_SMALL_LENGTH_MASK);
241 }
242
243 return (resource_length);
244}
245
246/*******************************************************************************
247 *
248 * FUNCTION: acpi_rs_struct_option_length 91 * FUNCTION: acpi_rs_struct_option_length
249 * 92 *
250 * PARAMETERS: resource_source - Pointer to optional descriptor field 93 * PARAMETERS: resource_source - Pointer to optional descriptor field
@@ -291,10 +134,10 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
291 ******************************************************************************/ 134 ******************************************************************************/
292 135
293static u32 136static u32
294acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) 137acpi_rs_stream_option_length(u32 resource_length,
138 u32 minimum_aml_resource_length)
295{ 139{
296 u32 string_length = 0; 140 u32 string_length = 0;
297 u32 minimum_resource_length;
298 141
299 ACPI_FUNCTION_ENTRY(); 142 ACPI_FUNCTION_ENTRY();
300 143
@@ -303,11 +146,6 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
303 * Large-type resource descriptors. 146 * Large-type resource descriptors.
304 */ 147 */
305 148
306 /* Compute minimum size of the data part of the resource descriptor */
307
308 minimum_resource_length =
309 minimum_total_length - sizeof(struct asl_large_header);
310
311 /* 149 /*
312 * If the length of the actual resource descriptor is greater than the ACPI 150 * If the length of the actual resource descriptor is greater than the ACPI
313 * spec-defined minimum length, it means that a resource_source_index exists 151 * spec-defined minimum length, it means that a resource_source_index exists
@@ -315,10 +153,11 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
315 * (including the null terminator) is the resource length minus the minimum 153 * (including the null terminator) is the resource length minus the minimum
316 * length, minus one byte for the resource_source_index itself. 154 * length, minus one byte for the resource_source_index itself.
317 */ 155 */
318 if (resource_length > minimum_resource_length) { 156 if (resource_length > minimum_aml_resource_length) {
319 /* Compute the length of the optional string */ 157 /* Compute the length of the optional string */
320 158
321 string_length = resource_length - minimum_resource_length - 1; 159 string_length =
160 resource_length - minimum_aml_resource_length - 1;
322 } 161 }
323 162
324 /* Round up length to 32 bits for internal structure alignment */ 163 /* Round up length to 32 bits for internal structure alignment */
@@ -328,7 +167,7 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
328 167
329/******************************************************************************* 168/*******************************************************************************
330 * 169 *
331 * FUNCTION: acpi_rs_get_byte_stream_length 170 * FUNCTION: acpi_rs_get_aml_length
332 * 171 *
333 * PARAMETERS: Resource - Pointer to the resource linked list 172 * PARAMETERS: Resource - Pointer to the resource linked list
334 * size_needed - Where the required size is returned 173 * size_needed - Where the required size is returned
@@ -342,62 +181,62 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
342 ******************************************************************************/ 181 ******************************************************************************/
343 182
344acpi_status 183acpi_status
345acpi_rs_get_byte_stream_length(struct acpi_resource * resource, 184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
346 acpi_size * size_needed)
347{ 185{
348 acpi_size byte_stream_size_needed = 0; 186 acpi_size aml_size_needed = 0;
349 acpi_size segment_size; 187 acpi_size segment_size;
350 188
351 ACPI_FUNCTION_TRACE("rs_get_byte_stream_length"); 189 ACPI_FUNCTION_TRACE("rs_get_aml_length");
352 190
353 /* Traverse entire list of internal resource descriptors */ 191 /* Traverse entire list of internal resource descriptors */
354 192
355 while (resource) { 193 while (resource) {
356 /* Validate the descriptor type */ 194 /* Validate the descriptor type */
357 195
358 if (resource->type > ACPI_RSTYPE_MAX) { 196 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
359 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 197 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
360 } 198 }
361 199
362 /* Get the base size of the (external stream) resource descriptor */ 200 /* Get the base size of the (external stream) resource descriptor */
363 201
364 segment_size = acpi_gbl_stream_sizes[resource->type]; 202 segment_size = acpi_gbl_aml_resource_sizes[resource->type];
365 203
366 /* 204 /*
367 * Augment the base size for descriptors with optional and/or 205 * Augment the base size for descriptors with optional and/or
368 * variable-length fields 206 * variable-length fields
369 */ 207 */
370 switch (resource->type) { 208 switch (resource->type) {
371 case ACPI_RSTYPE_VENDOR: 209 case ACPI_RESOURCE_TYPE_VENDOR:
372 /* 210 /*
373 * Vendor Defined Resource: 211 * Vendor Defined Resource:
374 * For a Vendor Specific resource, if the Length is between 1 and 7 212 * For a Vendor Specific resource, if the Length is between 1 and 7
375 * it will be created as a Small Resource data type, otherwise it 213 * it will be created as a Small Resource data type, otherwise it
376 * is a Large Resource data type. 214 * is a Large Resource data type.
377 */ 215 */
378 if (resource->data.vendor_specific.length > 7) { 216 if (resource->data.vendor.byte_length > 7) {
379 /* Base size of a Large resource descriptor */ 217 /* Base size of a Large resource descriptor */
380 218
381 segment_size = 3; 219 segment_size =
220 sizeof(struct aml_resource_large_header);
382 } 221 }
383 222
384 /* Add the size of the vendor-specific data */ 223 /* Add the size of the vendor-specific data */
385 224
386 segment_size += resource->data.vendor_specific.length; 225 segment_size += resource->data.vendor.byte_length;
387 break; 226 break;
388 227
389 case ACPI_RSTYPE_END_TAG: 228 case ACPI_RESOURCE_TYPE_END_TAG:
390 /* 229 /*
391 * End Tag: 230 * End Tag:
392 * We are done -- return the accumulated total size. 231 * We are done -- return the accumulated total size.
393 */ 232 */
394 *size_needed = byte_stream_size_needed + segment_size; 233 *size_needed = aml_size_needed + segment_size;
395 234
396 /* Normal exit */ 235 /* Normal exit */
397 236
398 return_ACPI_STATUS(AE_OK); 237 return_ACPI_STATUS(AE_OK);
399 238
400 case ACPI_RSTYPE_ADDRESS16: 239 case ACPI_RESOURCE_TYPE_ADDRESS16:
401 /* 240 /*
402 * 16-Bit Address Resource: 241 * 16-Bit Address Resource:
403 * Add the size of the optional resource_source info 242 * Add the size of the optional resource_source info
@@ -408,7 +247,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
408 resource_source); 247 resource_source);
409 break; 248 break;
410 249
411 case ACPI_RSTYPE_ADDRESS32: 250 case ACPI_RESOURCE_TYPE_ADDRESS32:
412 /* 251 /*
413 * 32-Bit Address Resource: 252 * 32-Bit Address Resource:
414 * Add the size of the optional resource_source info 253 * Add the size of the optional resource_source info
@@ -419,7 +258,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
419 resource_source); 258 resource_source);
420 break; 259 break;
421 260
422 case ACPI_RSTYPE_ADDRESS64: 261 case ACPI_RESOURCE_TYPE_ADDRESS64:
423 /* 262 /*
424 * 64-Bit Address Resource: 263 * 64-Bit Address Resource:
425 * Add the size of the optional resource_source info 264 * Add the size of the optional resource_source info
@@ -430,7 +269,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
430 resource_source); 269 resource_source);
431 break; 270 break;
432 271
433 case ACPI_RSTYPE_EXT_IRQ: 272 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
434 /* 273 /*
435 * Extended IRQ Resource: 274 * Extended IRQ Resource:
436 * Add the size of each additional optional interrupt beyond the 275 * Add the size of each additional optional interrupt beyond the
@@ -438,7 +277,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
438 */ 277 */
439 segment_size += (((acpi_size) 278 segment_size += (((acpi_size)
440 resource->data.extended_irq. 279 resource->data.extended_irq.
441 number_of_interrupts - 1) * 4); 280 interrupt_count - 1) * 4);
442 281
443 /* Add the size of the optional resource_source info */ 282 /* Add the size of the optional resource_source info */
444 283
@@ -454,7 +293,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
454 293
455 /* Update the total */ 294 /* Update the total */
456 295
457 byte_stream_size_needed += segment_size; 296 aml_size_needed += segment_size;
458 297
459 /* Point to the next object */ 298 /* Point to the next object */
460 299
@@ -471,9 +310,9 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
471 * 310 *
472 * FUNCTION: acpi_rs_get_list_length 311 * FUNCTION: acpi_rs_get_list_length
473 * 312 *
474 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 313 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
475 * byte_stream_buffer_length - Size of byte_stream_buffer 314 * aml_buffer_length - Size of aml_buffer
476 * size_needed - Where the size needed is returned 315 * size_needed - Where the size needed is returned
477 * 316 *
478 * RETURN: Status 317 * RETURN: Status
479 * 318 *
@@ -484,11 +323,11 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
484 ******************************************************************************/ 323 ******************************************************************************/
485 324
486acpi_status 325acpi_status
487acpi_rs_get_list_length(u8 * byte_stream_buffer, 326acpi_rs_get_list_length(u8 * aml_buffer,
488 u32 byte_stream_buffer_length, acpi_size * size_needed) 327 u32 aml_buffer_length, acpi_size * size_needed)
489{ 328{
490 u8 *buffer; 329 u8 *buffer;
491 struct acpi_resource_sizes *resource_info; 330 struct acpi_resource_info *resource_info;
492 u32 buffer_size = 0; 331 u32 buffer_size = 0;
493 u32 bytes_parsed = 0; 332 u32 bytes_parsed = 0;
494 u8 resource_type; 333 u8 resource_type;
@@ -499,14 +338,14 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
499 338
500 ACPI_FUNCTION_TRACE("rs_get_list_length"); 339 ACPI_FUNCTION_TRACE("rs_get_list_length");
501 340
502 while (bytes_parsed < byte_stream_buffer_length) { 341 while (bytes_parsed < aml_buffer_length) {
503 /* The next byte in the stream is the resource descriptor type */ 342 /* The next byte in the stream is the resource descriptor type */
504 343
505 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); 344 resource_type = acpi_rs_get_resource_type(*aml_buffer);
506 345
507 /* Get the base stream size and structure sizes for the descriptor */ 346 /* Get the base stream size and structure sizes for the descriptor */
508 347
509 resource_info = acpi_rs_get_resource_sizes(resource_type); 348 resource_info = acpi_rs_get_resource_info(resource_type);
510 if (!resource_info) { 349 if (!resource_info) {
511 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 350 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
512 } 351 }
@@ -514,43 +353,46 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
514 /* Get the Length field from the input resource descriptor */ 353 /* Get the Length field from the input resource descriptor */
515 354
516 resource_length = 355 resource_length =
517 acpi_rs_get_resource_length(byte_stream_buffer); 356 acpi_rs_get_resource_length(ACPI_CAST_PTR
357 (union aml_resource,
358 aml_buffer));
518 359
519 /* Augment the size for descriptors with optional fields */ 360 /* Augment the size for descriptors with optional fields */
520 361
521 extra_struct_bytes = 0; 362 extra_struct_bytes = 0;
522 363
523 if (!(resource_type & ACPI_RDESC_TYPE_LARGE)) { 364 if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) {
524 /* 365 /*
525 * Small resource descriptors 366 * Small resource descriptors
526 */ 367 */
527 header_length = 1; 368 header_length =
528 buffer = byte_stream_buffer + header_length; 369 sizeof(struct aml_resource_small_header);
370 buffer = aml_buffer + header_length;
529 371
530 switch (resource_type) { 372 switch (resource_type) {
531 case ACPI_RDESC_TYPE_IRQ_FORMAT: 373 case ACPI_RESOURCE_NAME_IRQ:
532 /* 374 /*
533 * IRQ Resource: 375 * IRQ Resource:
534 * Get the number of bits set in the IRQ word 376 * Get the number of bits set in the IRQ word
535 */ 377 */
536 ACPI_MOVE_16_TO_16(&temp16, buffer); 378 ACPI_MOVE_16_TO_16(&temp16, buffer);
537
538 extra_struct_bytes = 379 extra_struct_bytes =
539 (acpi_rs_count_set_bits(temp16) * 380 (acpi_rs_count_set_bits(temp16) *
540 sizeof(u32)); 381 sizeof(u32));
541 break; 382 break;
542 383
543 case ACPI_RDESC_TYPE_DMA_FORMAT: 384 case ACPI_RESOURCE_NAME_DMA:
544 /* 385 /*
545 * DMA Resource: 386 * DMA Resource:
546 * Get the number of bits set in the DMA channels byte 387 * Get the number of bits set in the DMA channels byte
547 */ 388 */
389 ACPI_MOVE_16_TO_16(&temp16, buffer);
548 extra_struct_bytes = 390 extra_struct_bytes =
549 (acpi_rs_count_set_bits((u16) * buffer) * 391 (acpi_rs_count_set_bits(temp16) *
550 sizeof(u32)); 392 sizeof(u32));
551 break; 393 break;
552 394
553 case ACPI_RDESC_TYPE_SMALL_VENDOR: 395 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
554 /* 396 /*
555 * Vendor Specific Resource: 397 * Vendor Specific Resource:
556 * Ensure a 32-bit boundary for the structure 398 * Ensure a 32-bit boundary for the structure
@@ -559,12 +401,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
559 ACPI_ROUND_UP_to_32_bITS(resource_length); 401 ACPI_ROUND_UP_to_32_bITS(resource_length);
560 break; 402 break;
561 403
562 case ACPI_RDESC_TYPE_END_TAG: 404 case ACPI_RESOURCE_NAME_END_TAG:
563 /* 405 /*
564 * End Tag: 406 * End Tag:
565 * Terminate the loop now 407 * Terminate the loop now
566 */ 408 */
567 byte_stream_buffer_length = bytes_parsed; 409 aml_buffer_length = bytes_parsed;
568 break; 410 break;
569 411
570 default: 412 default:
@@ -574,11 +416,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
574 /* 416 /*
575 * Large resource descriptors 417 * Large resource descriptors
576 */ 418 */
577 header_length = sizeof(struct asl_large_header); 419 header_length =
578 buffer = byte_stream_buffer + header_length; 420 sizeof(struct aml_resource_large_header);
421 buffer = aml_buffer + header_length;
579 422
580 switch (resource_type) { 423 switch (resource_type) {
581 case ACPI_RDESC_TYPE_LARGE_VENDOR: 424 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
582 /* 425 /*
583 * Vendor Defined Resource: 426 * Vendor Defined Resource:
584 * Add vendor data and ensure a 32-bit boundary for the structure 427 * Add vendor data and ensure a 32-bit boundary for the structure
@@ -587,8 +430,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
587 ACPI_ROUND_UP_to_32_bITS(resource_length); 430 ACPI_ROUND_UP_to_32_bITS(resource_length);
588 break; 431 break;
589 432
590 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 433 case ACPI_RESOURCE_NAME_ADDRESS32:
591 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 434 case ACPI_RESOURCE_NAME_ADDRESS16:
592 /* 435 /*
593 * 32-Bit or 16-bit Address Resource: 436 * 32-Bit or 16-bit Address Resource:
594 * Add the size of any optional data (resource_source) 437 * Add the size of any optional data (resource_source)
@@ -596,10 +439,11 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
596 extra_struct_bytes = 439 extra_struct_bytes =
597 acpi_rs_stream_option_length 440 acpi_rs_stream_option_length
598 (resource_length, 441 (resource_length,
599 resource_info->minimum_stream_size); 442 resource_info->
443 minimum_aml_resource_length);
600 break; 444 break;
601 445
602 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 446 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
603 /* 447 /*
604 * Extended IRQ: 448 * Extended IRQ:
605 * Point past the interrupt_vector_flags to get the 449 * Point past the interrupt_vector_flags to get the
@@ -622,10 +466,10 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
622 - 466 -
623 extra_struct_bytes, 467 extra_struct_bytes,
624 resource_info-> 468 resource_info->
625 minimum_stream_size); 469 minimum_aml_resource_length);
626 break; 470 break;
627 471
628 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 472 case ACPI_RESOURCE_NAME_ADDRESS64:
629 /* 473 /*
630 * 64-Bit Address Resource: 474 * 64-Bit Address Resource:
631 * Add the size of any optional data (resource_source) 475 * Add the size of any optional data (resource_source)
@@ -635,7 +479,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
635 ACPI_ROUND_UP_to_64_bITS 479 ACPI_ROUND_UP_to_64_bITS
636 (acpi_rs_stream_option_length 480 (acpi_rs_stream_option_length
637 (resource_length, 481 (resource_length,
638 resource_info->minimum_stream_size)); 482 resource_info->
483 minimum_aml_resource_length));
639 break; 484 break;
640 485
641 default: 486 default:
@@ -646,7 +491,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
646 /* Update the required buffer size for the internal descriptor structs */ 491 /* Update the required buffer size for the internal descriptor structs */
647 492
648 temp16 = 493 temp16 =
649 (u16) (resource_info->minimum_struct_size + 494 (u16) (resource_info->minimum_internal_struct_length +
650 extra_struct_bytes); 495 extra_struct_bytes);
651 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); 496 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16);
652 497
@@ -656,7 +501,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
656 */ 501 */
657 temp16 = (u16) (header_length + resource_length); 502 temp16 = (u16) (header_length + resource_length);
658 bytes_parsed += temp16; 503 bytes_parsed += temp16;
659 byte_stream_buffer += temp16; 504 aml_buffer += temp16;
660 } 505 }
661 506
662 /* This is the data the caller needs */ 507 /* This is the data the caller needs */
@@ -758,8 +603,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
758 (*sub_object_list)->string. 603 (*sub_object_list)->string.
759 length + 1); 604 length + 1);
760 } else { 605 } else {
761 temp_size_needed += 606 temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
762 acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
763 } 607 }
764 } else { 608 } else {
765 /* 609 /*
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 0911526b7ad8..6c7c6c560635 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate")
53 * 53 *
54 * FUNCTION: acpi_rs_create_resource_list 54 * FUNCTION: acpi_rs_create_resource_list
55 * 55 *
56 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 56 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
57 * output_buffer - Pointer to the user's buffer 57 * output_buffer - Pointer to the user's buffer
58 * 58 *
59 * RETURN: Status - AE_OK if okay, else a valid acpi_status code 59 * RETURN: Status: AE_OK if okay, else a valid acpi_status code
60 * If output_buffer is not large enough, output_buffer_length 60 * If output_buffer is not large enough, output_buffer_length
61 * indicates how large output_buffer should be, else it 61 * indicates how large output_buffer should be, else it
62 * indicates how may u8 elements of output_buffer are valid. 62 * indicates how may u8 elements of output_buffer are valid.
@@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate")
67 * 67 *
68 ******************************************************************************/ 68 ******************************************************************************/
69acpi_status 69acpi_status
70acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 70acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
71 struct acpi_buffer *output_buffer) 71 struct acpi_buffer *output_buffer)
72{ 72{
73 73
74 acpi_status status; 74 acpi_status status;
75 u8 *byte_stream_start; 75 u8 *aml_start;
76 acpi_size list_size_needed = 0; 76 acpi_size list_size_needed = 0;
77 u32 byte_stream_buffer_length; 77 u32 aml_buffer_length;
78 78
79 ACPI_FUNCTION_TRACE("rs_create_resource_list"); 79 ACPI_FUNCTION_TRACE("rs_create_resource_list");
80 80
81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", 81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer));
82 byte_stream_buffer));
83 82
84 /* Params already validated, so we don't re-validate here */ 83 /* Params already validated, so we don't re-validate here */
85 84
86 byte_stream_buffer_length = byte_stream_buffer->buffer.length; 85 aml_buffer_length = aml_buffer->buffer.length;
87 byte_stream_start = byte_stream_buffer->buffer.pointer; 86 aml_start = aml_buffer->buffer.pointer;
88 87
89 /* 88 /*
90 * Pass the byte_stream_buffer into a module that can calculate 89 * Pass the aml_buffer into a module that can calculate
91 * the buffer size needed for the linked list 90 * the buffer size needed for the linked list
92 */ 91 */
93 status = 92 status = acpi_rs_get_list_length(aml_start, aml_buffer_length,
94 acpi_rs_get_list_length(byte_stream_start, 93 &list_size_needed);
95 byte_stream_buffer_length,
96 &list_size_needed);
97 94
98 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", 95 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
99 status, (u32) list_size_needed)); 96 status, (u32) list_size_needed));
@@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
110 107
111 /* Do the conversion */ 108 /* Do the conversion */
112 109
113 status = 110 status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length,
114 acpi_rs_byte_stream_to_list(byte_stream_start, 111 output_buffer->pointer);
115 byte_stream_buffer_length,
116 output_buffer->pointer);
117 if (ACPI_FAILURE(status)) { 112 if (ACPI_FAILURE(status)) {
118 return_ACPI_STATUS(status); 113 return_ACPI_STATUS(status);
119 } 114 }
@@ -360,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
360 355
361/******************************************************************************* 356/*******************************************************************************
362 * 357 *
363 * FUNCTION: acpi_rs_create_byte_stream 358 * FUNCTION: acpi_rs_create_aml_resources
364 * 359 *
365 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list 360 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list
366 * output_buffer - Pointer to the user's buffer 361 * output_buffer - Pointer to the user's buffer
@@ -377,13 +372,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
377 ******************************************************************************/ 372 ******************************************************************************/
378 373
379acpi_status 374acpi_status
380acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 375acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
381 struct acpi_buffer *output_buffer) 376 struct acpi_buffer *output_buffer)
382{ 377{
383 acpi_status status; 378 acpi_status status;
384 acpi_size byte_stream_size_needed = 0; 379 acpi_size aml_size_needed = 0;
385 380
386 ACPI_FUNCTION_TRACE("rs_create_byte_stream"); 381 ACPI_FUNCTION_TRACE("rs_create_aml_resources");
387 382
388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", 383 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n",
389 linked_list_buffer)); 384 linked_list_buffer));
@@ -394,11 +389,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
394 * Pass the linked_list_buffer into a module that calculates 389 * Pass the linked_list_buffer into a module that calculates
395 * the buffer size needed for the byte stream. 390 * the buffer size needed for the byte stream.
396 */ 391 */
397 status = acpi_rs_get_byte_stream_length(linked_list_buffer, 392 status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
398 &byte_stream_size_needed);
399 393
400 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", 394 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n",
401 (u32) byte_stream_size_needed, 395 (u32) aml_size_needed,
402 acpi_format_exception(status))); 396 acpi_format_exception(status)));
403 if (ACPI_FAILURE(status)) { 397 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS(status); 398 return_ACPI_STATUS(status);
@@ -406,8 +400,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
406 400
407 /* Validate/Allocate/Clear caller buffer */ 401 /* Validate/Allocate/Clear caller buffer */
408 402
409 status = 403 status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed);
410 acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed);
411 if (ACPI_FAILURE(status)) { 404 if (ACPI_FAILURE(status)) {
412 return_ACPI_STATUS(status); 405 return_ACPI_STATUS(status);
413 } 406 }
@@ -415,9 +408,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
415 /* Do the conversion */ 408 /* Do the conversion */
416 409
417 status = 410 status =
418 acpi_rs_list_to_byte_stream(linked_list_buffer, 411 acpi_rs_convert_resources_to_aml(linked_list_buffer,
419 byte_stream_size_needed, 412 aml_size_needed,
420 output_buffer->pointer); 413 output_buffer->pointer);
421 if (ACPI_FAILURE(status)) { 414 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status); 415 return_ACPI_STATUS(status);
423 } 416 }
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 9d93ee5f0060..2f8990845b2d 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -49,38 +49,6 @@ ACPI_MODULE_NAME("rsdump")
49 49
50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_rs_dump_irq(union acpi_resource_data *resource);
53
54static void acpi_rs_dump_address16(union acpi_resource_data *resource);
55
56static void acpi_rs_dump_address32(union acpi_resource_data *resource);
57
58static void acpi_rs_dump_address64(union acpi_resource_data *resource);
59
60static void acpi_rs_dump_dma(union acpi_resource_data *resource);
61
62static void acpi_rs_dump_io(union acpi_resource_data *resource);
63
64static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource);
65
66static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource);
67
68static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource);
69
70static void acpi_rs_dump_memory24(union acpi_resource_data *resource);
71
72static void acpi_rs_dump_memory32(union acpi_resource_data *resource);
73
74static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource);
75
76static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource);
77
78static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource);
79
80static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource);
81
82static void acpi_rs_dump_end_tag(union acpi_resource_data *resource);
83
84static void acpi_rs_out_string(char *title, char *value); 52static void acpi_rs_out_string(char *title, char *value);
85 53
86static void acpi_rs_out_integer8(char *title, u8 value); 54static void acpi_rs_out_integer8(char *title, u8 value);
@@ -104,30 +72,6 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
104 72
105static void acpi_rs_dump_address_common(union acpi_resource_data *resource); 73static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
106 74
107/* Dispatch table for resource dump functions */
108
109typedef
110void (*ACPI_DUMP_RESOURCE) (union acpi_resource_data * data);
111
112static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = {
113 acpi_rs_dump_irq, /* ACPI_RSTYPE_IRQ */
114 acpi_rs_dump_dma, /* ACPI_RSTYPE_DMA */
115 acpi_rs_dump_start_depend_fns, /* ACPI_RSTYPE_START_DPF */
116 acpi_rs_dump_end_depend_fns, /* ACPI_RSTYPE_END_DPF */
117 acpi_rs_dump_io, /* ACPI_RSTYPE_IO */
118 acpi_rs_dump_fixed_io, /* ACPI_RSTYPE_FIXED_IO */
119 acpi_rs_dump_vendor_specific, /* ACPI_RSTYPE_VENDOR */
120 acpi_rs_dump_end_tag, /* ACPI_RSTYPE_END_TAG */
121 acpi_rs_dump_memory24, /* ACPI_RSTYPE_MEM24 */
122 acpi_rs_dump_memory32, /* ACPI_RSTYPE_MEM32 */
123 acpi_rs_dump_fixed_memory32, /* ACPI_RSTYPE_FIXED_MEM32 */
124 acpi_rs_dump_address16, /* ACPI_RSTYPE_ADDRESS16 */
125 acpi_rs_dump_address32, /* ACPI_RSTYPE_ADDRESS32 */
126 acpi_rs_dump_address64, /* ACPI_RSTYPE_ADDRESS64 */
127 acpi_rs_dump_extended_irq, /* ACPI_RSTYPE_EXT_IRQ */
128 acpi_rs_dump_generic_reg /* ACPI_RSTYPE_GENERIC_REG */
129};
130
131/******************************************************************************* 75/*******************************************************************************
132 * 76 *
133 * FUNCTION: acpi_rs_out* 77 * FUNCTION: acpi_rs_out*
@@ -144,32 +88,32 @@ static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = {
144 88
145static void acpi_rs_out_string(char *title, char *value) 89static void acpi_rs_out_string(char *title, char *value)
146{ 90{
147 acpi_os_printf("%30s : %s\n", title, value); 91 acpi_os_printf("%27s : %s\n", title, value);
148} 92}
149 93
150static void acpi_rs_out_integer8(char *title, u8 value) 94static void acpi_rs_out_integer8(char *title, u8 value)
151{ 95{
152 acpi_os_printf("%30s : %2.2X\n", title, value); 96 acpi_os_printf("%27s : %2.2X\n", title, value);
153} 97}
154 98
155static void acpi_rs_out_integer16(char *title, u16 value) 99static void acpi_rs_out_integer16(char *title, u16 value)
156{ 100{
157 acpi_os_printf("%30s : %4.4X\n", title, value); 101 acpi_os_printf("%27s : %4.4X\n", title, value);
158} 102}
159 103
160static void acpi_rs_out_integer32(char *title, u32 value) 104static void acpi_rs_out_integer32(char *title, u32 value)
161{ 105{
162 acpi_os_printf("%30s : %8.8X\n", title, value); 106 acpi_os_printf("%27s : %8.8X\n", title, value);
163} 107}
164 108
165static void acpi_rs_out_integer64(char *title, u64 value) 109static void acpi_rs_out_integer64(char *title, u64 value)
166{ 110{
167 acpi_os_printf("%30s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); 111 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
168} 112}
169 113
170static void acpi_rs_out_title(char *title) 114static void acpi_rs_out_title(char *title)
171{ 115{
172 acpi_os_printf("%30s : ", title); 116 acpi_os_printf("%27s : ", title);
173} 117}
174 118
175/******************************************************************************* 119/*******************************************************************************
@@ -190,7 +134,7 @@ static void acpi_rs_dump_byte_list(u32 length, u8 * data)
190 u32 i; 134 u32 i;
191 135
192 for (i = 0; i < length; i++) { 136 for (i = 0; i < length; i++) {
193 acpi_os_printf("%28s%2.2X : %2.2X\n", "Byte", i, data[i]); 137 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
194 } 138 }
195} 139}
196 140
@@ -199,7 +143,7 @@ static void acpi_rs_dump_dword_list(u32 length, u32 * data)
199 u32 i; 143 u32 i;
200 144
201 for (i = 0; i < length; i++) { 145 for (i = 0; i < length; i++) {
202 acpi_os_printf("%28s%2.2X : %8.8X\n", "Dword", i, data[i]); 146 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
203 } 147 }
204} 148}
205 149
@@ -213,6 +157,14 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data)
213 acpi_os_printf("\n"); 157 acpi_os_printf("\n");
214} 158}
215 159
160static void acpi_rs_dump_memory_attribute(u32 read_write_attribute)
161{
162
163 acpi_rs_out_string("Read/Write Attribute",
164 ACPI_READ_WRITE_MEMORY == read_write_attribute ?
165 "Read/Write" : "Read-Only");
166}
167
216/******************************************************************************* 168/*******************************************************************************
217 * 169 *
218 * FUNCTION: acpi_rs_dump_resource_source 170 * FUNCTION: acpi_rs_dump_resource_source
@@ -229,6 +181,7 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data)
229static void 181static void
230acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) 182acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
231{ 183{
184 ACPI_FUNCTION_ENTRY();
232 185
233 if (resource_source->index == 0xFF) { 186 if (resource_source->index == 0xFF) {
234 return; 187 return;
@@ -290,11 +243,8 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
290 break; 243 break;
291 } 244 }
292 245
293 acpi_rs_out_string("Read/Write Attribute", 246 acpi_rs_dump_memory_attribute(resource->address.attribute.
294 ACPI_READ_WRITE_MEMORY == 247 memory.read_write_attribute);
295 resource->address.attribute.memory.
296 read_write_attribute ? "Read/Write" :
297 "Read Only");
298 break; 248 break;
299 249
300 case ACPI_IO_RANGE: 250 case ACPI_IO_RANGE:
@@ -392,7 +342,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
392 342
393 /* Validate Type before dispatch */ 343 /* Validate Type before dispatch */
394 344
395 if (resource_list->type > ACPI_RSTYPE_MAX) { 345 if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) {
396 acpi_os_printf 346 acpi_os_printf
397 ("Invalid descriptor type (%X) in resource list\n", 347 ("Invalid descriptor type (%X) in resource list\n",
398 resource_list->type); 348 resource_list->type);
@@ -406,7 +356,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
406 356
407 /* Exit on end tag */ 357 /* Exit on end tag */
408 358
409 if (resource_list->type == ACPI_RSTYPE_END_TAG) { 359 if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) {
410 return; 360 return;
411 } 361 }
412 362
@@ -431,7 +381,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
431 * 381 *
432 ******************************************************************************/ 382 ******************************************************************************/
433 383
434static void acpi_rs_dump_irq(union acpi_resource_data *resource) 384void acpi_rs_dump_irq(union acpi_resource_data *resource)
435{ 385{
436 ACPI_FUNCTION_ENTRY(); 386 ACPI_FUNCTION_ENTRY();
437 387
@@ -439,22 +389,21 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource)
439 389
440 acpi_rs_out_string("Triggering", 390 acpi_rs_out_string("Triggering",
441 ACPI_LEVEL_SENSITIVE == 391 ACPI_LEVEL_SENSITIVE ==
442 resource->irq.edge_level ? "Level" : "Edge"); 392 resource->irq.triggering ? "Level" : "Edge");
443 393
444 acpi_rs_out_string("Active", 394 acpi_rs_out_string("Active",
445 ACPI_ACTIVE_LOW == 395 ACPI_ACTIVE_LOW ==
446 resource->irq.active_high_low ? "Low" : "High"); 396 resource->irq.polarity ? "Low" : "High");
447 397
448 acpi_rs_out_string("Sharing", 398 acpi_rs_out_string("Sharing",
449 ACPI_SHARED == 399 ACPI_SHARED ==
450 resource->irq. 400 resource->irq.sharable ? "Shared" : "Exclusive");
451 shared_exclusive ? "Shared" : "Exclusive");
452 401
453 acpi_rs_out_integer8("Interrupt Count", 402 acpi_rs_out_integer8("Interrupt Count",
454 (u8) resource->irq.number_of_interrupts); 403 (u8) resource->irq.interrupt_count);
455 404
456 acpi_rs_out_title("Interrupt List"); 405 acpi_rs_out_title("Interrupt List");
457 acpi_rs_dump_short_byte_list(resource->irq.number_of_interrupts, 406 acpi_rs_dump_short_byte_list(resource->irq.interrupt_count,
458 resource->irq.interrupts); 407 resource->irq.interrupts);
459} 408}
460 409
@@ -470,7 +419,7 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource)
470 * 419 *
471 ******************************************************************************/ 420 ******************************************************************************/
472 421
473static void acpi_rs_dump_dma(union acpi_resource_data *resource) 422void acpi_rs_dump_dma(union acpi_resource_data *resource)
474{ 423{
475 ACPI_FUNCTION_ENTRY(); 424 ACPI_FUNCTION_ENTRY();
476 425
@@ -523,16 +472,16 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource)
523 } 472 }
524 473
525 acpi_rs_out_integer8("DMA Channel Count", 474 acpi_rs_out_integer8("DMA Channel Count",
526 (u8) resource->dma.number_of_channels); 475 (u8) resource->dma.channel_count);
527 476
528 acpi_rs_out_title("Channel List"); 477 acpi_rs_out_title("Channel List");
529 acpi_rs_dump_short_byte_list(resource->dma.number_of_channels, 478 acpi_rs_dump_short_byte_list(resource->dma.channel_count,
530 resource->dma.channels); 479 resource->dma.channels);
531} 480}
532 481
533/******************************************************************************* 482/*******************************************************************************
534 * 483 *
535 * FUNCTION: acpi_rs_dump_start_depend_fns 484 * FUNCTION: acpi_rs_dump_start_dpf
536 * 485 *
537 * PARAMETERS: Resource - Pointer to an internal resource descriptor 486 * PARAMETERS: Resource - Pointer to an internal resource descriptor
538 * 487 *
@@ -542,7 +491,7 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource)
542 * 491 *
543 ******************************************************************************/ 492 ******************************************************************************/
544 493
545static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) 494void acpi_rs_dump_start_dpf(union acpi_resource_data *resource)
546{ 495{
547 ACPI_FUNCTION_ENTRY(); 496 ACPI_FUNCTION_ENTRY();
548 497
@@ -600,7 +549,7 @@ static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource)
600 * 549 *
601 ******************************************************************************/ 550 ******************************************************************************/
602 551
603static void acpi_rs_dump_io(union acpi_resource_data *resource) 552void acpi_rs_dump_io(union acpi_resource_data *resource)
604{ 553{
605 ACPI_FUNCTION_ENTRY(); 554 ACPI_FUNCTION_ENTRY();
606 555
@@ -610,15 +559,13 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource)
610 ACPI_DECODE_16 == 559 ACPI_DECODE_16 ==
611 resource->io.io_decode ? "16-bit" : "10-bit"); 560 resource->io.io_decode ? "16-bit" : "10-bit");
612 561
613 acpi_rs_out_integer32("Range Minimum Base", 562 acpi_rs_out_integer32("Address Minimum", resource->io.minimum);
614 resource->io.min_base_address);
615 563
616 acpi_rs_out_integer32("Range Maximum Base", 564 acpi_rs_out_integer32("Address Maximum", resource->io.maximum);
617 resource->io.max_base_address);
618 565
619 acpi_rs_out_integer32("Alignment", resource->io.alignment); 566 acpi_rs_out_integer32("Alignment", resource->io.alignment);
620 567
621 acpi_rs_out_integer32("Range Length", resource->io.range_length); 568 acpi_rs_out_integer32("Address Length", resource->io.address_length);
622} 569}
623 570
624/******************************************************************************* 571/*******************************************************************************
@@ -633,21 +580,21 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource)
633 * 580 *
634 ******************************************************************************/ 581 ******************************************************************************/
635 582
636static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) 583void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
637{ 584{
638 ACPI_FUNCTION_ENTRY(); 585 ACPI_FUNCTION_ENTRY();
639 586
640 acpi_os_printf("Fixed I/O Resource\n"); 587 acpi_os_printf("Fixed I/O Resource\n");
641 588
642 acpi_rs_out_integer32("Range Base Address", 589 acpi_rs_out_integer32("Address", resource->fixed_io.address);
643 resource->fixed_io.base_address);
644 590
645 acpi_rs_out_integer32("Range Length", resource->fixed_io.range_length); 591 acpi_rs_out_integer32("Address Length",
592 resource->fixed_io.address_length);
646} 593}
647 594
648/******************************************************************************* 595/*******************************************************************************
649 * 596 *
650 * FUNCTION: acpi_rs_dump_vendor_specific 597 * FUNCTION: acpi_rs_dump_vendor
651 * 598 *
652 * PARAMETERS: Resource - Pointer to an internal resource descriptor 599 * PARAMETERS: Resource - Pointer to an internal resource descriptor
653 * 600 *
@@ -657,16 +604,16 @@ static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
657 * 604 *
658 ******************************************************************************/ 605 ******************************************************************************/
659 606
660static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) 607void acpi_rs_dump_vendor(union acpi_resource_data *resource)
661{ 608{
662 ACPI_FUNCTION_ENTRY(); 609 ACPI_FUNCTION_ENTRY();
663 610
664 acpi_os_printf("Vendor Specific Resource\n"); 611 acpi_os_printf("Vendor Specific Resource\n");
665 612
666 acpi_rs_out_integer16("Length", (u16) resource->vendor_specific.length); 613 acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length);
667 614
668 acpi_rs_dump_byte_list(resource->vendor_specific.length, 615 acpi_rs_dump_byte_list(resource->vendor.byte_length,
669 resource->vendor_specific.reserved); 616 resource->vendor.byte_data);
670} 617}
671 618
672/******************************************************************************* 619/*******************************************************************************
@@ -681,27 +628,24 @@ static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource)
681 * 628 *
682 ******************************************************************************/ 629 ******************************************************************************/
683 630
684static void acpi_rs_dump_memory24(union acpi_resource_data *resource) 631void acpi_rs_dump_memory24(union acpi_resource_data *resource)
685{ 632{
686 ACPI_FUNCTION_ENTRY(); 633 ACPI_FUNCTION_ENTRY();
687 634
688 acpi_os_printf("24-Bit Memory Range Resource\n"); 635 acpi_os_printf("24-Bit Memory Range Resource\n");
689 636
690 acpi_rs_out_string("Attribute", 637 acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute);
691 ACPI_READ_WRITE_MEMORY ==
692 resource->memory24.read_write_attribute ?
693 "Read/Write" : "Read Only");
694 638
695 acpi_rs_out_integer16("Range Minimum Base", 639 acpi_rs_out_integer16("Address Minimum",
696 (u16) resource->memory24.min_base_address); 640 (u16) resource->memory24.minimum);
697 641
698 acpi_rs_out_integer16("Range Maximum Base", 642 acpi_rs_out_integer16("Address Maximum",
699 (u16) resource->memory24.max_base_address); 643 (u16) resource->memory24.maximum);
700 644
701 acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); 645 acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment);
702 646
703 acpi_rs_out_integer16("Range Length", 647 acpi_rs_out_integer16("Address Length",
704 (u16) resource->memory24.range_length); 648 (u16) resource->memory24.address_length);
705} 649}
706 650
707/******************************************************************************* 651/*******************************************************************************
@@ -716,26 +660,22 @@ static void acpi_rs_dump_memory24(union acpi_resource_data *resource)
716 * 660 *
717 ******************************************************************************/ 661 ******************************************************************************/
718 662
719static void acpi_rs_dump_memory32(union acpi_resource_data *resource) 663void acpi_rs_dump_memory32(union acpi_resource_data *resource)
720{ 664{
721 ACPI_FUNCTION_ENTRY(); 665 ACPI_FUNCTION_ENTRY();
722 666
723 acpi_os_printf("32-Bit Memory Range Resource\n"); 667 acpi_os_printf("32-Bit Memory Range Resource\n");
724 668
725 acpi_rs_out_string("Attribute", 669 acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute);
726 ACPI_READ_WRITE_MEMORY ==
727 resource->memory32.read_write_attribute ?
728 "Read/Write" : "Read Only");
729 670
730 acpi_rs_out_integer32("Range Minimum Base", 671 acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum);
731 resource->memory32.min_base_address);
732 672
733 acpi_rs_out_integer32("Range Maximum Base", 673 acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum);
734 resource->memory32.max_base_address);
735 674
736 acpi_rs_out_integer32("Alignment", resource->memory32.alignment); 675 acpi_rs_out_integer32("Alignment", resource->memory32.alignment);
737 676
738 acpi_rs_out_integer32("Range Length", resource->memory32.range_length); 677 acpi_rs_out_integer32("Address Length",
678 resource->memory32.address_length);
739} 679}
740 680
741/******************************************************************************* 681/*******************************************************************************
@@ -750,22 +690,19 @@ static void acpi_rs_dump_memory32(union acpi_resource_data *resource)
750 * 690 *
751 ******************************************************************************/ 691 ******************************************************************************/
752 692
753static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) 693void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
754{ 694{
755 ACPI_FUNCTION_ENTRY(); 695 ACPI_FUNCTION_ENTRY();
756 696
757 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); 697 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
758 698
759 acpi_rs_out_string("Attribute", 699 acpi_rs_dump_memory_attribute(resource->fixed_memory32.
760 ACPI_READ_WRITE_MEMORY == 700 read_write_attribute);
761 resource->fixed_memory32.read_write_attribute ?
762 "Read/Write" : "Read Only");
763 701
764 acpi_rs_out_integer32("Range Base Address", 702 acpi_rs_out_integer32("Address", resource->fixed_memory32.address);
765 resource->fixed_memory32.range_base_address);
766 703
767 acpi_rs_out_integer32("Range Length", 704 acpi_rs_out_integer32("Address Length",
768 resource->fixed_memory32.range_length); 705 resource->fixed_memory32.address_length);
769} 706}
770 707
771/******************************************************************************* 708/*******************************************************************************
@@ -780,26 +717,25 @@ static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
780 * 717 *
781 ******************************************************************************/ 718 ******************************************************************************/
782 719
783static void acpi_rs_dump_address16(union acpi_resource_data *resource) 720void acpi_rs_dump_address16(union acpi_resource_data *resource)
784{ 721{
785 ACPI_FUNCTION_ENTRY(); 722 ACPI_FUNCTION_ENTRY();
786 723
787 acpi_os_printf("16-Bit Address Space Resource\n"); 724 acpi_os_printf("16-Bit WORD Address Space Resource\n");
788 725
789 acpi_rs_dump_address_common(resource); 726 acpi_rs_dump_address_common(resource);
790 727
791 acpi_rs_out_integer16("Granularity", 728 acpi_rs_out_integer16("Granularity",
792 (u16) resource->address16.granularity); 729 (u16) resource->address16.granularity);
793 730
794 acpi_rs_out_integer16("Address Range Min", 731 acpi_rs_out_integer16("Address Minimum",
795 (u16) resource->address16.min_address_range); 732 (u16) resource->address16.minimum);
796 733
797 acpi_rs_out_integer16("Address Range Max", 734 acpi_rs_out_integer16("Address Maximum",
798 (u16) resource->address16.max_address_range); 735 (u16) resource->address16.maximum);
799 736
800 acpi_rs_out_integer16("Address Translation Offset", 737 acpi_rs_out_integer16("Translation Offset",
801 (u16) resource->address16. 738 (u16) resource->address16.translation_offset);
802 address_translation_offset);
803 739
804 acpi_rs_out_integer16("Address Length", 740 acpi_rs_out_integer16("Address Length",
805 (u16) resource->address16.address_length); 741 (u16) resource->address16.address_length);
@@ -819,24 +755,22 @@ static void acpi_rs_dump_address16(union acpi_resource_data *resource)
819 * 755 *
820 ******************************************************************************/ 756 ******************************************************************************/
821 757
822static void acpi_rs_dump_address32(union acpi_resource_data *resource) 758void acpi_rs_dump_address32(union acpi_resource_data *resource)
823{ 759{
824 ACPI_FUNCTION_ENTRY(); 760 ACPI_FUNCTION_ENTRY();
825 761
826 acpi_os_printf("32-Bit Address Space Resource\n"); 762 acpi_os_printf("32-Bit DWORD Address Space Resource\n");
827 763
828 acpi_rs_dump_address_common(resource); 764 acpi_rs_dump_address_common(resource);
829 765
830 acpi_rs_out_integer32("Granularity", resource->address32.granularity); 766 acpi_rs_out_integer32("Granularity", resource->address32.granularity);
831 767
832 acpi_rs_out_integer32("Address Range Min", 768 acpi_rs_out_integer32("Address Minimum", resource->address32.minimum);
833 resource->address32.min_address_range);
834 769
835 acpi_rs_out_integer32("Address Range Max", 770 acpi_rs_out_integer32("Address Maximum", resource->address32.maximum);
836 resource->address32.max_address_range);
837 771
838 acpi_rs_out_integer32("Address Translation Offset", 772 acpi_rs_out_integer32("Translation Offset",
839 resource->address32.address_translation_offset); 773 resource->address32.translation_offset);
840 774
841 acpi_rs_out_integer32("Address Length", 775 acpi_rs_out_integer32("Address Length",
842 resource->address32.address_length); 776 resource->address32.address_length);
@@ -856,37 +790,32 @@ static void acpi_rs_dump_address32(union acpi_resource_data *resource)
856 * 790 *
857 ******************************************************************************/ 791 ******************************************************************************/
858 792
859static void acpi_rs_dump_address64(union acpi_resource_data *resource) 793void acpi_rs_dump_address64(union acpi_resource_data *resource)
860{ 794{
861 ACPI_FUNCTION_ENTRY(); 795 ACPI_FUNCTION_ENTRY();
862 796
863 acpi_os_printf("64-Bit Address Space Resource\n"); 797 acpi_os_printf("64-Bit QWORD Address Space Resource\n");
864 798
865 acpi_rs_dump_address_common(resource); 799 acpi_rs_dump_address_common(resource);
866 800
867 acpi_rs_out_integer64("Granularity", resource->address64.granularity); 801 acpi_rs_out_integer64("Granularity", resource->address64.granularity);
868 802
869 acpi_rs_out_integer64("Address Range Min", 803 acpi_rs_out_integer64("Address Minimum", resource->address64.minimum);
870 resource->address64.min_address_range);
871 804
872 acpi_rs_out_integer64("Address Range Max", 805 acpi_rs_out_integer64("Address Maximum", resource->address64.maximum);
873 resource->address64.max_address_range);
874 806
875 acpi_rs_out_integer64("Address Translation Offset", 807 acpi_rs_out_integer64("Translation Offset",
876 resource->address64.address_translation_offset); 808 resource->address64.translation_offset);
877 809
878 acpi_rs_out_integer64("Address Length", 810 acpi_rs_out_integer64("Address Length",
879 resource->address64.address_length); 811 resource->address64.address_length);
880 812
881 acpi_rs_out_integer64("Type Specific Attributes",
882 resource->address64.type_specific_attributes);
883
884 acpi_rs_dump_resource_source(&resource->address64.resource_source); 813 acpi_rs_dump_resource_source(&resource->address64.resource_source);
885} 814}
886 815
887/******************************************************************************* 816/*******************************************************************************
888 * 817 *
889 * FUNCTION: acpi_rs_dump_extended_irq 818 * FUNCTION: acpi_rs_dump_ext_address64
890 * 819 *
891 * PARAMETERS: Resource - Pointer to an internal resource descriptor 820 * PARAMETERS: Resource - Pointer to an internal resource descriptor
892 * 821 *
@@ -896,7 +825,46 @@ static void acpi_rs_dump_address64(union acpi_resource_data *resource)
896 * 825 *
897 ******************************************************************************/ 826 ******************************************************************************/
898 827
899static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) 828void acpi_rs_dump_ext_address64(union acpi_resource_data *resource)
829{
830 ACPI_FUNCTION_ENTRY();
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}
854
855/*******************************************************************************
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)
900{ 868{
901 ACPI_FUNCTION_ENTRY(); 869 ACPI_FUNCTION_ENTRY();
902 870
@@ -910,24 +878,22 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource)
910 acpi_rs_out_string("Triggering", 878 acpi_rs_out_string("Triggering",
911 ACPI_LEVEL_SENSITIVE == 879 ACPI_LEVEL_SENSITIVE ==
912 resource->extended_irq. 880 resource->extended_irq.
913 edge_level ? "Level" : "Edge"); 881 triggering ? "Level" : "Edge");
914 882
915 acpi_rs_out_string("Active", 883 acpi_rs_out_string("Active",
916 ACPI_ACTIVE_LOW == 884 ACPI_ACTIVE_LOW == resource->extended_irq.polarity ?
917 resource->extended_irq. 885 "Low" : "High");
918 active_high_low ? "Low" : "High");
919 886
920 acpi_rs_out_string("Sharing", 887 acpi_rs_out_string("Sharing",
921 ACPI_SHARED == 888 ACPI_SHARED == resource->extended_irq.sharable ?
922 resource->extended_irq. 889 "Shared" : "Exclusive");
923 shared_exclusive ? "Shared" : "Exclusive");
924 890
925 acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); 891 acpi_rs_dump_resource_source(&resource->extended_irq.resource_source);
926 892
927 acpi_rs_out_integer8("Interrupts", 893 acpi_rs_out_integer8("Interrupts",
928 (u8) resource->extended_irq.number_of_interrupts); 894 (u8) resource->extended_irq.interrupt_count);
929 895
930 acpi_rs_dump_dword_list(resource->extended_irq.number_of_interrupts, 896 acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count,
931 resource->extended_irq.interrupts); 897 resource->extended_irq.interrupts);
932} 898}
933 899
@@ -943,9 +909,8 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource)
943 * 909 *
944 ******************************************************************************/ 910 ******************************************************************************/
945 911
946static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) 912void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
947{ 913{
948
949 ACPI_FUNCTION_ENTRY(); 914 ACPI_FUNCTION_ENTRY();
950 915
951 acpi_os_printf("Generic Register Resource\n"); 916 acpi_os_printf("Generic Register Resource\n");
@@ -957,15 +922,15 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
957 acpi_rs_out_integer8("Bit Offset", 922 acpi_rs_out_integer8("Bit Offset",
958 (u8) resource->generic_reg.bit_offset); 923 (u8) resource->generic_reg.bit_offset);
959 924
960 acpi_rs_out_integer8("Address Size", 925 acpi_rs_out_integer8("Access Size",
961 (u8) resource->generic_reg.address_size); 926 (u8) resource->generic_reg.access_size);
962 927
963 acpi_rs_out_integer64("Address", resource->generic_reg.address); 928 acpi_rs_out_integer64("Address", resource->generic_reg.address);
964} 929}
965 930
966/******************************************************************************* 931/*******************************************************************************
967 * 932 *
968 * FUNCTION: acpi_rs_dump_end_depend_fns 933 * FUNCTION: acpi_rs_dump_end_dpf
969 * 934 *
970 * PARAMETERS: Resource - Pointer to an internal resource descriptor 935 * PARAMETERS: Resource - Pointer to an internal resource descriptor
971 * 936 *
@@ -975,7 +940,7 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
975 * 940 *
976 ******************************************************************************/ 941 ******************************************************************************/
977 942
978static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) 943void acpi_rs_dump_end_dpf(union acpi_resource_data *resource)
979{ 944{
980 ACPI_FUNCTION_ENTRY(); 945 ACPI_FUNCTION_ENTRY();
981 946
@@ -994,7 +959,7 @@ static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource)
994 * 959 *
995 ******************************************************************************/ 960 ******************************************************************************/
996 961
997static void acpi_rs_dump_end_tag(union acpi_resource_data *resource) 962void acpi_rs_dump_end_tag(union acpi_resource_data *resource)
998{ 963{
999 ACPI_FUNCTION_ENTRY(); 964 ACPI_FUNCTION_ENTRY();
1000 965
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
index 49a5f81c727b..b31cb33ec565 100644
--- a/drivers/acpi/resources/rsinfo.c
+++ b/drivers/acpi/resources/rsinfo.c
@@ -207,7 +207,7 @@ struct acpi_resource_info acpi_gbl_lg_resource_info[] = {
207 {0, ACPI_RLARGE(struct aml_resource_memory24), 207 {0, ACPI_RLARGE(struct aml_resource_memory24),
208 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, 208 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)},
209 {0, ACPI_RLARGE(struct aml_resource_generic_register), 209 {0, ACPI_RLARGE(struct aml_resource_generic_register),
210 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)}, 210 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)},
211 {0, 0, 0}, 211 {0, 0, 0},
212 {1, ACPI_RLARGE(struct aml_resource_vendor_large), 212 {1, ACPI_RLARGE(struct aml_resource_vendor_large),
213 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, 213 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index 6574e2ae2e52..0dab8cdfa800 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -49,426 +49,269 @@ ACPI_MODULE_NAME("rsio")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_io_resource 52 * FUNCTION: acpi_rs_get_io
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * stream 55 * aml_resource_length - Length of the resource from the AML header
56 * bytes_consumed - Pointer to where the number of bytes 56 * Resource - Where the internal resource is returned
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 57 *
63 * RETURN: Status 58 * RETURN: Status
64 * 59 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 61 * internal resource descriptor, simplifying bitflags and handling
67 * number of bytes consumed from the byte stream. 62 * alignment and endian issues if necessary.
68 * 63 *
69 ******************************************************************************/ 64 ******************************************************************************/
70acpi_status 65acpi_status
71acpi_rs_io_resource(u8 * byte_stream_buffer, 66acpi_rs_get_io(union aml_resource *aml,
72 acpi_size * bytes_consumed, 67 u16 aml_resource_length, struct acpi_resource *resource)
73 u8 ** output_buffer, acpi_size * structure_size)
74{ 68{
75 u8 *buffer = byte_stream_buffer; 69 ACPI_FUNCTION_TRACE("rs_get_io");
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
80 70
81 ACPI_FUNCTION_TRACE("rs_io_resource"); 71 /* Get the Decode flag */
82 72
83 /* The number of bytes consumed are Constant */ 73 resource->data.io.io_decode = aml->io.information & 0x01;
84 74
85 *bytes_consumed = 8; 75 /*
76 * Get the following contiguous fields from the AML descriptor:
77 * Minimum Base Address
78 * Maximum Base Address
79 * Address Alignment
80 * Length
81 */
82 ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum);
83 ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum);
84 resource->data.io.alignment = aml->io.alignment;
85 resource->data.io.address_length = aml->io.address_length;
86 86
87 output_struct->type = ACPI_RSTYPE_IO; 87 /* Complete the resource header */
88 88
89 /* Check Decode */ 89 resource->type = ACPI_RESOURCE_TYPE_IO;
90 90 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
91 buffer += 1;
92 temp8 = *buffer;
93
94 output_struct->data.io.io_decode = temp8 & 0x01;
95
96 /* Check min_base Address */
97
98 buffer += 1;
99 ACPI_MOVE_16_TO_16(&temp16, buffer);
100
101 output_struct->data.io.min_base_address = temp16;
102
103 /* Check max_base Address */
104
105 buffer += 2;
106 ACPI_MOVE_16_TO_16(&temp16, buffer);
107
108 output_struct->data.io.max_base_address = temp16;
109
110 /* Check Base alignment */
111
112 buffer += 2;
113 temp8 = *buffer;
114
115 output_struct->data.io.alignment = temp8;
116
117 /* Check range_length */
118
119 buffer += 1;
120 temp8 = *buffer;
121
122 output_struct->data.io.range_length = temp8;
123
124 /* Set the Length parameter */
125
126 output_struct->length = (u32) struct_size;
127
128 /* Return the final size of the structure */
129
130 *structure_size = struct_size;
131 return_ACPI_STATUS(AE_OK); 91 return_ACPI_STATUS(AE_OK);
132} 92}
133 93
134/******************************************************************************* 94/*******************************************************************************
135 * 95 *
136 * FUNCTION: acpi_rs_fixed_io_resource 96 * FUNCTION: acpi_rs_set_io
137 * 97 *
138 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 98 * PARAMETERS: Resource - Pointer to the resource descriptor
139 * stream 99 * Aml - Where the AML descriptor is returned
140 * bytes_consumed - Pointer to where the number of bytes
141 * consumed the byte_stream_buffer is
142 * returned
143 * output_buffer - Pointer to the return data buffer
144 * structure_size - Pointer to where the number of bytes
145 * in the return data struct is returned
146 * 100 *
147 * RETURN: Status 101 * RETURN: Status
148 * 102 *
149 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 103 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
150 * structure pointed to by the output_buffer. Return the 104 * external AML resource descriptor.
151 * number of bytes consumed from the byte stream.
152 * 105 *
153 ******************************************************************************/ 106 ******************************************************************************/
154 107
155acpi_status 108acpi_status
156acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 109acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml)
157 acpi_size * bytes_consumed,
158 u8 ** output_buffer, acpi_size * structure_size)
159{ 110{
160 u8 *buffer = byte_stream_buffer; 111 ACPI_FUNCTION_TRACE("rs_set_io");
161 struct acpi_resource *output_struct = (void *)*output_buffer;
162 u16 temp16 = 0;
163 u8 temp8 = 0;
164 acpi_size struct_size =
165 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
166
167 ACPI_FUNCTION_TRACE("rs_fixed_io_resource");
168 112
169 /* The number of bytes consumed are Constant */ 113 /* I/O Information Byte */
170 114
171 *bytes_consumed = 4; 115 aml->io.information = (u8) (resource->data.io.io_decode & 0x01);
172 116
173 output_struct->type = ACPI_RSTYPE_FIXED_IO; 117 /*
118 * Set the following contiguous fields in the AML descriptor:
119 * Minimum Base Address
120 * Maximum Base Address
121 * Address Alignment
122 * Length
123 */
124 ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum);
125 ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum);
126 aml->io.alignment = (u8) resource->data.io.alignment;
127 aml->io.address_length = (u8) resource->data.io.address_length;
174 128
175 /* Check Range Base Address */ 129 /* Complete the AML descriptor header */
176 130
177 buffer += 1; 131 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO,
178 ACPI_MOVE_16_TO_16(&temp16, buffer); 132 sizeof(struct aml_resource_io), aml);
179
180 output_struct->data.fixed_io.base_address = temp16;
181
182 /* Check range_length */
183
184 buffer += 2;
185 temp8 = *buffer;
186
187 output_struct->data.fixed_io.range_length = temp8;
188
189 /* Set the Length parameter */
190
191 output_struct->length = (u32) struct_size;
192
193 /* Return the final size of the structure */
194
195 *structure_size = struct_size;
196 return_ACPI_STATUS(AE_OK); 133 return_ACPI_STATUS(AE_OK);
197} 134}
198 135
199/******************************************************************************* 136/*******************************************************************************
200 * 137 *
201 * FUNCTION: acpi_rs_io_stream 138 * FUNCTION: acpi_rs_get_fixed_io
202 * 139 *
203 * PARAMETERS: Resource - Pointer to the resource linked list 140 * PARAMETERS: Aml - Pointer to the AML resource descriptor
204 * output_buffer - Pointer to the user's return buffer 141 * aml_resource_length - Length of the resource from the AML header
205 * bytes_consumed - Pointer to where the number of bytes 142 * Resource - Where the internal resource is returned
206 * used in the output_buffer is returned
207 * 143 *
208 * RETURN: Status 144 * RETURN: Status
209 * 145 *
210 * DESCRIPTION: Take the linked list resource structure and fills in the 146 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
211 * the appropriate bytes in a byte stream 147 * internal resource descriptor, simplifying bitflags and handling
148 * alignment and endian issues if necessary.
212 * 149 *
213 ******************************************************************************/ 150 ******************************************************************************/
214 151
215acpi_status 152acpi_status
216acpi_rs_io_stream(struct acpi_resource *resource, 153acpi_rs_get_fixed_io(union aml_resource *aml,
217 u8 ** output_buffer, acpi_size * bytes_consumed) 154 u16 aml_resource_length, struct acpi_resource *resource)
218{ 155{
219 u8 *buffer = *output_buffer; 156 ACPI_FUNCTION_TRACE("rs_get_fixed_io");
220 u16 temp16 = 0;
221 u8 temp8 = 0;
222
223 ACPI_FUNCTION_TRACE("rs_io_stream");
224
225 /* The Descriptor Type field is static */
226
227 *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07;
228 buffer += 1;
229
230 /* Io Information Byte */
231
232 temp8 = (u8) (resource->data.io.io_decode & 0x01);
233
234 *buffer = temp8;
235 buffer += 1;
236
237 /* Set the Range minimum base address */
238
239 temp16 = (u16) resource->data.io.min_base_address;
240
241 ACPI_MOVE_16_TO_16(buffer, &temp16);
242 buffer += 2;
243
244 /* Set the Range maximum base address */
245 157
246 temp16 = (u16) resource->data.io.max_base_address; 158 /*
159 * Get the following contiguous fields from the AML descriptor:
160 * Base Address
161 * Length
162 */
163 ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address,
164 &aml->fixed_io.address);
165 resource->data.fixed_io.address_length = aml->fixed_io.address_length;
247 166
248 ACPI_MOVE_16_TO_16(buffer, &temp16); 167 /* Complete the resource header */
249 buffer += 2;
250 168
251 /* Set the base alignment */ 169 resource->type = ACPI_RESOURCE_TYPE_FIXED_IO;
252 170 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
253 temp8 = (u8) resource->data.io.alignment;
254
255 *buffer = temp8;
256 buffer += 1;
257
258 /* Set the range length */
259
260 temp8 = (u8) resource->data.io.range_length;
261
262 *buffer = temp8;
263 buffer += 1;
264
265 /* Return the number of bytes consumed in this operation */
266
267 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
268 return_ACPI_STATUS(AE_OK); 171 return_ACPI_STATUS(AE_OK);
269} 172}
270 173
271/******************************************************************************* 174/*******************************************************************************
272 * 175 *
273 * FUNCTION: acpi_rs_fixed_io_stream 176 * FUNCTION: acpi_rs_set_fixed_io
274 * 177 *
275 * PARAMETERS: Resource - Pointer to the resource linked list 178 * PARAMETERS: Resource - Pointer to the resource descriptor
276 * output_buffer - Pointer to the user's return buffer 179 * Aml - Where the AML descriptor is returned
277 * bytes_consumed - Pointer to where the number of bytes
278 * used in the output_buffer is returned
279 * 180 *
280 * RETURN: Status 181 * RETURN: Status
281 * 182 *
282 * DESCRIPTION: Take the linked list resource structure and fills in the 183 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
283 * the appropriate bytes in a byte stream 184 * external AML resource descriptor.
284 * 185 *
285 ******************************************************************************/ 186 ******************************************************************************/
286 187
287acpi_status 188acpi_status
288acpi_rs_fixed_io_stream(struct acpi_resource *resource, 189acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml)
289 u8 ** output_buffer, acpi_size * bytes_consumed)
290{ 190{
291 u8 *buffer = *output_buffer; 191 ACPI_FUNCTION_TRACE("rs_set_fixed_io");
292 u16 temp16 = 0; 192
293 u8 temp8 = 0; 193 /*
294 194 * Set the following contiguous fields in the AML descriptor:
295 ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); 195 * Base Address
296 196 * Length
297 /* The Descriptor Type field is static */ 197 */
298 198 ACPI_MOVE_32_TO_16(&aml->fixed_io.address,
299 *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03; 199 &resource->data.fixed_io.address);
300 buffer += 1; 200 aml->fixed_io.address_length =
301 201 (u8) resource->data.fixed_io.address_length;
302 /* Set the Range base address */ 202
303 203 /* Complete the AML descriptor header */
304 temp16 = (u16) resource->data.fixed_io.base_address; 204
305 205 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO,
306 ACPI_MOVE_16_TO_16(buffer, &temp16); 206 sizeof(struct aml_resource_fixed_io), aml);
307 buffer += 2;
308
309 /* Set the range length */
310
311 temp8 = (u8) resource->data.fixed_io.range_length;
312
313 *buffer = temp8;
314 buffer += 1;
315
316 /* Return the number of bytes consumed in this operation */
317
318 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
319 return_ACPI_STATUS(AE_OK); 207 return_ACPI_STATUS(AE_OK);
320} 208}
321 209
322/******************************************************************************* 210/*******************************************************************************
323 * 211 *
324 * FUNCTION: acpi_rs_dma_resource 212 * FUNCTION: acpi_rs_get_dma
325 * 213 *
326 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 214 * PARAMETERS: Aml - Pointer to the AML resource descriptor
327 * stream 215 * aml_resource_length - Length of the resource from the AML header
328 * bytes_consumed - Pointer to where the number of bytes 216 * Resource - Where the internal resource is returned
329 * consumed the byte_stream_buffer is
330 * returned
331 * output_buffer - Pointer to the return data buffer
332 * structure_size - Pointer to where the number of bytes
333 * in the return data struct is returned
334 * 217 *
335 * RETURN: Status 218 * RETURN: Status
336 * 219 *
337 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 220 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
338 * structure pointed to by the output_buffer. Return the 221 * internal resource descriptor, simplifying bitflags and handling
339 * number of bytes consumed from the byte stream. 222 * alignment and endian issues if necessary.
340 * 223 *
341 ******************************************************************************/ 224 ******************************************************************************/
342 225
343acpi_status 226acpi_status
344acpi_rs_dma_resource(u8 * byte_stream_buffer, 227acpi_rs_get_dma(union aml_resource *aml,
345 acpi_size * bytes_consumed, 228 u16 aml_resource_length, struct acpi_resource *resource)
346 u8 ** output_buffer, acpi_size * structure_size)
347{ 229{
348 u8 *buffer = byte_stream_buffer; 230 u32 channel_count = 0;
349 struct acpi_resource *output_struct = (void *)*output_buffer; 231 u32 i;
350 u8 temp8 = 0; 232 u8 temp8;
351 u8 index;
352 u8 i;
353 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
354 233
355 ACPI_FUNCTION_TRACE("rs_dma_resource"); 234 ACPI_FUNCTION_TRACE("rs_get_dma");
356
357 /* The number of bytes consumed are Constant */
358
359 *bytes_consumed = 3;
360 output_struct->type = ACPI_RSTYPE_DMA;
361
362 /* Point to the 8-bits of Byte 1 */
363
364 buffer += 1;
365 temp8 = *buffer;
366 235
367 /* Decode the DMA channel bits */ 236 /* Decode the DMA channel bits */
368 237
369 for (i = 0, index = 0; index < 8; index++) { 238 for (i = 0; i < 8; i++) {
370 if ((temp8 >> index) & 0x01) { 239 if ((aml->dma.dma_channel_mask >> i) & 0x01) {
371 output_struct->data.dma.channels[i] = index; 240 resource->data.dma.channels[channel_count] = i;
372 i++; 241 channel_count++;
373 } 242 }
374 } 243 }
375 244
376 /* Zero DMA channels is valid */ 245 resource->length = 0;
377 246 resource->data.dma.channel_count = channel_count;
378 output_struct->data.dma.number_of_channels = i;
379 if (i > 0) {
380 /* Calculate the structure size based upon the number of interrupts */
381 247
382 struct_size += ((acpi_size) i - 1) * 4; 248 /*
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;
383 } 254 }
384 255
385 /* Point to Byte 2 */ 256 /* Get the flags: transfer preference, bus mastering, channel speed */
386 257
387 buffer += 1; 258 temp8 = aml->dma.flags;
388 temp8 = *buffer; 259 resource->data.dma.transfer = temp8 & 0x03;
260 resource->data.dma.bus_master = (temp8 >> 2) & 0x01;
261 resource->data.dma.type = (temp8 >> 5) & 0x03;
389 262
390 /* Check for transfer preference (Bits[1:0]) */ 263 if (resource->data.dma.transfer == 0x03) {
391
392 output_struct->data.dma.transfer = temp8 & 0x03;
393
394 if (0x03 == output_struct->data.dma.transfer) {
395 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 264 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
396 "Invalid DMA.Transfer preference (3)\n")); 265 "Invalid DMA.Transfer preference (3)\n"));
397 return_ACPI_STATUS(AE_BAD_DATA); 266 return_ACPI_STATUS(AE_BAD_DATA);
398 } 267 }
399 268
400 /* Get bus master preference (Bit[2]) */ 269 /* Complete the resource header */
401
402 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
403
404 /* Get channel speed support (Bits[6:5]) */
405 270
406 output_struct->data.dma.type = (temp8 >> 5) & 0x03; 271 resource->type = ACPI_RESOURCE_TYPE_DMA;
407 272 resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
408 /* Set the Length parameter */
409
410 output_struct->length = (u32) struct_size;
411
412 /* Return the final size of the structure */
413
414 *structure_size = struct_size;
415 return_ACPI_STATUS(AE_OK); 273 return_ACPI_STATUS(AE_OK);
416} 274}
417 275
418/******************************************************************************* 276/*******************************************************************************
419 * 277 *
420 * FUNCTION: acpi_rs_dma_stream 278 * FUNCTION: acpi_rs_set_dma
421 * 279 *
422 * PARAMETERS: Resource - Pointer to the resource linked list 280 * PARAMETERS: Resource - Pointer to the resource descriptor
423 * output_buffer - Pointer to the user's return buffer 281 * Aml - Where the AML descriptor is returned
424 * bytes_consumed - Pointer to where the number of bytes
425 * used in the output_buffer is returned
426 * 282 *
427 * RETURN: Status 283 * RETURN: Status
428 * 284 *
429 * DESCRIPTION: Take the linked list resource structure and fills in the 285 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
430 * the appropriate bytes in a byte stream 286 * external AML resource descriptor.
431 * 287 *
432 ******************************************************************************/ 288 ******************************************************************************/
433 289
434acpi_status 290acpi_status
435acpi_rs_dma_stream(struct acpi_resource *resource, 291acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml)
436 u8 ** output_buffer, acpi_size * bytes_consumed)
437{ 292{
438 u8 *buffer = *output_buffer; 293 u8 i;
439 u16 temp16 = 0;
440 u8 temp8 = 0;
441 u8 index;
442
443 ACPI_FUNCTION_TRACE("rs_dma_stream");
444
445 /* The Descriptor Type field is static */
446 294
447 *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02; 295 ACPI_FUNCTION_TRACE("rs_set_dma");
448 buffer += 1;
449 temp8 = 0;
450 296
451 /* Loop through all of the Channels and set the mask bits */ 297 /* Convert channel list to 8-bit DMA channel bitmask */
452 298
453 for (index = 0; index < resource->data.dma.number_of_channels; index++) { 299 aml->dma.dma_channel_mask = 0;
454 temp16 = (u16) resource->data.dma.channels[index]; 300 for (i = 0; i < resource->data.dma.channel_count; i++) {
455 temp8 |= 0x1 << temp16; 301 aml->dma.dma_channel_mask |=
302 (1 << resource->data.dma.channels[i]);
456 } 303 }
457 304
458 *buffer = temp8; 305 /* Set the DMA Flag bits */
459 buffer += 1;
460
461 /* Set the DMA Info */
462
463 temp8 = (u8) ((resource->data.dma.type & 0x03) << 5);
464 temp8 |= ((resource->data.dma.bus_master & 0x01) << 2);
465 temp8 |= (resource->data.dma.transfer & 0x03);
466 306
467 *buffer = temp8; 307 aml->dma.flags = (u8)
468 buffer += 1; 308 (((resource->data.dma.type & 0x03) << 5) |
309 ((resource->data.dma.bus_master & 0x01) << 2) |
310 (resource->data.dma.transfer & 0x03));
469 311
470 /* Return the number of bytes consumed in this operation */ 312 /* Complete the AML descriptor header */
471 313
472 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 314 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA,
315 sizeof(struct aml_resource_dma), aml);
473 return_ACPI_STATUS(AE_OK); 316 return_ACPI_STATUS(AE_OK);
474} 317}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 75df962115cc..4e854ba70811 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -49,93 +49,67 @@ ACPI_MODULE_NAME("rsirq")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_irq_resource 52 * FUNCTION: acpi_rs_get_irq
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * stream 55 * aml_resource_length - Length of the resource from the AML header
56 * bytes_consumed - Pointer to where the number of bytes 56 * Resource - Where the internal resource is returned
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 57 *
63 * RETURN: Status 58 * RETURN: Status
64 * 59 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 61 * internal resource descriptor, simplifying bitflags and handling
67 * number of bytes consumed from the byte stream. 62 * alignment and endian issues if necessary.
68 * 63 *
69 ******************************************************************************/ 64 ******************************************************************************/
70acpi_status 65acpi_status
71acpi_rs_irq_resource(u8 * byte_stream_buffer, 66acpi_rs_get_irq(union aml_resource *aml,
72 acpi_size * bytes_consumed, 67 u16 aml_resource_length, struct acpi_resource *resource)
73 u8 ** output_buffer, acpi_size * structure_size)
74{ 68{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0; 69 u16 temp16 = 0;
78 u8 temp8 = 0; 70 u32 interrupt_count = 0;
79 u8 index; 71 u32 i;
80 u8 i; 72 u32 resource_length;
81 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
82
83 ACPI_FUNCTION_TRACE("rs_irq_resource");
84
85 /*
86 * The number of bytes consumed are contained in the descriptor
87 * (Bits:0-1)
88 */
89 temp8 = *buffer;
90 *bytes_consumed = (temp8 & 0x03) + 1;
91 output_struct->type = ACPI_RSTYPE_IRQ;
92 73
93 /* Point to the 16-bits of Bytes 1 and 2 */ 74 ACPI_FUNCTION_TRACE("rs_get_irq");
94 75
95 buffer += 1; 76 /* Get the IRQ mask (bytes 1:2) */
96 ACPI_MOVE_16_TO_16(&temp16, buffer);
97 77
98 output_struct->data.irq.number_of_interrupts = 0; 78 ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask);
99 79
100 /* Decode the IRQ bits */ 80 /* Decode the IRQ bits (up to 16 possible) */
101 81
102 for (i = 0, index = 0; index < 16; index++) { 82 for (i = 0; i < 16; i++) {
103 if ((temp16 >> index) & 0x01) { 83 if ((temp16 >> i) & 0x01) {
104 output_struct->data.irq.interrupts[i] = index; 84 resource->data.irq.interrupts[interrupt_count] = i;
105 i++; 85 interrupt_count++;
106 } 86 }
107 } 87 }
108 88
109 /* Zero interrupts is valid */ 89 /* Zero interrupts is valid */
110 90
111 output_struct->data.irq.number_of_interrupts = i; 91 resource_length = 0;
112 if (i > 0) { 92 resource->data.irq.interrupt_count = interrupt_count;
93 if (interrupt_count > 0) {
113 /* Calculate the structure size based upon the number of interrupts */ 94 /* Calculate the structure size based upon the number of interrupts */
114 95
115 struct_size += ((acpi_size) i - 1) * 4; 96 resource_length = (u32) (interrupt_count - 1) * 4;
116 } 97 }
117 98
118 /* Point to Byte 3 if it is used */ 99 /* Get Flags (Byte 3) if it is used */
119
120 if (4 == *bytes_consumed) {
121 buffer += 2;
122 temp8 = *buffer;
123 100
101 if (aml_resource_length == 3) {
124 /* Check for HE, LL interrupts */ 102 /* Check for HE, LL interrupts */
125 103
126 switch (temp8 & 0x09) { 104 switch (aml->irq.flags & 0x09) {
127 case 0x01: /* HE */ 105 case 0x01: /* HE */
128 output_struct->data.irq.edge_level = 106 resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
129 ACPI_EDGE_SENSITIVE; 107 resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
130 output_struct->data.irq.active_high_low =
131 ACPI_ACTIVE_HIGH;
132 break; 108 break;
133 109
134 case 0x08: /* LL */ 110 case 0x08: /* LL */
135 output_struct->data.irq.edge_level = 111 resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE;
136 ACPI_LEVEL_SENSITIVE; 112 resource->data.irq.polarity = ACPI_ACTIVE_LOW;
137 output_struct->data.irq.active_high_low =
138 ACPI_ACTIVE_LOW;
139 break; 113 break;
140 114
141 default: 115 default:
@@ -146,170 +120,131 @@ acpi_rs_irq_resource(u8 * byte_stream_buffer,
146 */ 120 */
147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
148 "Invalid interrupt polarity/trigger in resource list, %X\n", 122 "Invalid interrupt polarity/trigger in resource list, %X\n",
149 temp8)); 123 aml->irq.flags));
150 return_ACPI_STATUS(AE_BAD_DATA); 124 return_ACPI_STATUS(AE_BAD_DATA);
151 } 125 }
152 126
153 /* Check for sharable */ 127 /* Get Sharing flag */
154 128
155 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 129 resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01;
156 } else { 130 } else {
157 /* 131 /*
158 * Assume Edge Sensitive, Active High, Non-Sharable 132 * Default configuration: assume Edge Sensitive, Active High,
159 * per ACPI Specification 133 * Non-Sharable as per the ACPI Specification
160 */ 134 */
161 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 135 resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
162 output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; 136 resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
163 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 137 resource->data.irq.sharable = ACPI_EXCLUSIVE;
164 } 138 }
165 139
166 /* Set the Length parameter */ 140 /* Complete the resource header */
167 141
168 output_struct->length = (u32) struct_size; 142 resource->type = ACPI_RESOURCE_TYPE_IRQ;
169 143 resource->length =
170 /* Return the final size of the structure */ 144 resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
171
172 *structure_size = struct_size;
173 return_ACPI_STATUS(AE_OK); 145 return_ACPI_STATUS(AE_OK);
174} 146}
175 147
176/******************************************************************************* 148/*******************************************************************************
177 * 149 *
178 * FUNCTION: acpi_rs_irq_stream 150 * FUNCTION: acpi_rs_set_irq
179 * 151 *
180 * PARAMETERS: Resource - Pointer to the resource linked list 152 * PARAMETERS: Resource - Pointer to the resource descriptor
181 * output_buffer - Pointer to the user's return buffer 153 * Aml - Where the AML descriptor is returned
182 * bytes_consumed - Pointer to where the number of bytes
183 * used in the output_buffer is returned
184 * 154 *
185 * RETURN: Status 155 * RETURN: Status
186 * 156 *
187 * DESCRIPTION: Take the linked list resource structure and fills in the 157 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
188 * the appropriate bytes in a byte stream 158 * external AML resource descriptor.
189 * 159 *
190 ******************************************************************************/ 160 ******************************************************************************/
191 161
192acpi_status 162acpi_status
193acpi_rs_irq_stream(struct acpi_resource *resource, 163acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml)
194 u8 ** output_buffer, acpi_size * bytes_consumed)
195{ 164{
196 u8 *buffer = *output_buffer; 165 acpi_size descriptor_length;
197 u16 temp16 = 0; 166 u16 irq_mask;
198 u8 temp8 = 0; 167 u8 i;
199 u8 index; 168
200 u8 IRqinfo_byte_needed; 169 ACPI_FUNCTION_TRACE("rs_set_irq");
201 170
202 ACPI_FUNCTION_TRACE("rs_irq_stream"); 171 /* Convert interrupt list to 16-bit IRQ bitmask */
172
173 irq_mask = 0;
174 for (i = 0; i < resource->data.irq.interrupt_count; i++) {
175 irq_mask |= (1 << resource->data.irq.interrupts[i]);
176 }
177
178 /* Set the interrupt mask */
179
180 ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask);
203 181
204 /* 182 /*
205 * The descriptor field is set based upon whether a third byte is 183 * The descriptor field is set based upon whether a third byte is
206 * needed to contain the IRQ Information. 184 * needed to contain the IRQ Information.
207 */ 185 */
208 if (ACPI_EDGE_SENSITIVE == resource->data.irq.edge_level && 186 if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) &&
209 ACPI_ACTIVE_HIGH == resource->data.irq.active_high_low && 187 (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) &&
210 ACPI_EXCLUSIVE == resource->data.irq.shared_exclusive) { 188 (resource->data.irq.sharable == ACPI_EXCLUSIVE)) {
211 *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x02; 189 /* irq_no_flags() descriptor can be used */
212 IRqinfo_byte_needed = FALSE;
213 } else {
214 *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x03;
215 IRqinfo_byte_needed = TRUE;
216 }
217
218 buffer += 1;
219 temp16 = 0;
220
221 /* Loop through all of the interrupts and set the mask bits */
222 190
223 for (index = 0; 191 descriptor_length = sizeof(struct aml_resource_irq_noflags);
224 index < resource->data.irq.number_of_interrupts; index++) { 192 } else {
225 temp8 = (u8) resource->data.irq.interrupts[index]; 193 /* Irq() descriptor must be used */
226 temp16 |= 0x1 << temp8;
227 }
228 194
229 ACPI_MOVE_16_TO_16(buffer, &temp16); 195 descriptor_length = sizeof(struct aml_resource_irq);
230 buffer += 2;
231 196
232 /* Set the IRQ Info byte if needed. */ 197 /* Set the IRQ Info byte */
233 198
234 if (IRqinfo_byte_needed) { 199 aml->irq.flags = (u8)
235 temp8 = 0; 200 ((resource->data.irq.sharable & 0x01) << 4);
236 temp8 = (u8) ((resource->data.irq.shared_exclusive &
237 0x01) << 4);
238 201
239 if (ACPI_LEVEL_SENSITIVE == resource->data.irq.edge_level && 202 if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering &&
240 ACPI_ACTIVE_LOW == resource->data.irq.active_high_low) { 203 ACPI_ACTIVE_LOW == resource->data.irq.polarity) {
241 temp8 |= 0x08; 204 aml->irq.flags |= 0x08;
242 } else { 205 } else {
243 temp8 |= 0x01; 206 aml->irq.flags |= 0x01;
244 } 207 }
245
246 *buffer = temp8;
247 buffer += 1;
248 } 208 }
249 209
250 /* Return the number of bytes consumed in this operation */ 210 /* Complete the AML descriptor header */
251 211
252 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 212 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length,
213 aml);
253 return_ACPI_STATUS(AE_OK); 214 return_ACPI_STATUS(AE_OK);
254} 215}
255 216
256/******************************************************************************* 217/*******************************************************************************
257 * 218 *
258 * FUNCTION: acpi_rs_extended_irq_resource 219 * FUNCTION: acpi_rs_get_ext_irq
259 * 220 *
260 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 221 * PARAMETERS: Aml - Pointer to the AML resource descriptor
261 * stream 222 * aml_resource_length - Length of the resource from the AML header
262 * bytes_consumed - Pointer to where the number of bytes 223 * Resource - Where the internal resource is returned
263 * consumed the byte_stream_buffer is
264 * returned
265 * output_buffer - Pointer to the return data buffer
266 * structure_size - Pointer to where the number of bytes
267 * in the return data struct is returned
268 * 224 *
269 * RETURN: Status 225 * RETURN: Status
270 * 226 *
271 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 227 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
272 * structure pointed to by the output_buffer. Return the 228 * internal resource descriptor, simplifying bitflags and handling
273 * number of bytes consumed from the byte stream. 229 * alignment and endian issues if necessary.
274 * 230 *
275 ******************************************************************************/ 231 ******************************************************************************/
276 232
277acpi_status 233acpi_status
278acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, 234acpi_rs_get_ext_irq(union aml_resource *aml,
279 acpi_size * bytes_consumed, 235 u16 aml_resource_length, struct acpi_resource *resource)
280 u8 ** output_buffer, acpi_size * structure_size)
281{ 236{
282 u8 *buffer = byte_stream_buffer; 237 char *out_resource_string;
283 struct acpi_resource *output_struct = (void *)*output_buffer; 238 u8 temp8;
284 u16 temp16 = 0;
285 u8 temp8 = 0;
286 u8 *temp_ptr;
287 u8 index;
288 acpi_size struct_size =
289 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
290
291 ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
292 239
293 /* Get the Descriptor Length field */ 240 ACPI_FUNCTION_TRACE("rs_get_ext_irq");
294 241
295 buffer += 1; 242 /* Get the flag bits */
296 ACPI_MOVE_16_TO_16(&temp16, buffer);
297 243
298 /* Validate minimum descriptor length */ 244 temp8 = aml->extended_irq.flags;
299 245 resource->data.extended_irq.producer_consumer = temp8 & 0x01;
300 if (temp16 < 6) { 246 resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01;
301 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 247 resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01;
302 }
303
304 *bytes_consumed = temp16 + 3;
305 output_struct->type = ACPI_RSTYPE_EXT_IRQ;
306
307 /* Point to the Byte3 */
308
309 buffer += 2;
310 temp8 = *buffer;
311
312 output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
313 248
314 /* 249 /*
315 * Check for Interrupt Mode 250 * Check for Interrupt Mode
@@ -319,165 +254,80 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
319 * 254 *
320 * - Edge/Level are defined opposite in the table vs the headers 255 * - Edge/Level are defined opposite in the table vs the headers
321 */ 256 */
322 output_struct->data.extended_irq.edge_level = 257 resource->data.extended_irq.triggering =
323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 258 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
324 259
325 /* Check Interrupt Polarity */ 260 /* Get the IRQ Table length (Byte4) */
326
327 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
328
329 /* Check for sharable */
330
331 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
332
333 /* Point to Byte4 (IRQ Table length) */
334
335 buffer += 1;
336 temp8 = *buffer;
337
338 /* Must have at least one IRQ */
339 261
262 temp8 = aml->extended_irq.table_length;
263 resource->data.extended_irq.interrupt_count = temp8;
340 if (temp8 < 1) { 264 if (temp8 < 1) {
265 /* Must have at least one IRQ */
266
341 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 267 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
342 } 268 }
343 269
344 output_struct->data.extended_irq.number_of_interrupts = temp8;
345
346 /* 270 /*
347 * Add any additional structure size to properly calculate 271 * Add any additional structure size to properly calculate
348 * the next pointer at the end of this function 272 * the next pointer at the end of this function
349 */ 273 */
350 struct_size += (temp8 - 1) * 4; 274 resource->length = (temp8 - 1) * 4;
275 out_resource_string = ACPI_CAST_PTR(char,
276 (&resource->data.extended_irq.
277 interrupts[0] + temp8));
351 278
352 /* Point to Byte5 (First IRQ Number) */ 279 /* Get every IRQ in the table, each is 32 bits */
353 280
354 buffer += 1; 281 acpi_rs_move_data(resource->data.extended_irq.interrupts,
282 aml->extended_irq.interrupt_number,
283 (u16) temp8, ACPI_MOVE_TYPE_32_TO_32);
355 284
356 /* Cycle through every IRQ in the table */ 285 /* Get the optional resource_source (index and string) */
357 286
358 for (index = 0; index < temp8; index++) { 287 resource->length +=
359 ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq. 288 acpi_rs_get_resource_source(aml_resource_length,
360 interrupts[index], buffer); 289 (acpi_size) resource->length +
290 sizeof(struct
291 aml_resource_extended_irq),
292 &resource->data.extended_irq.
293 resource_source, aml,
294 out_resource_string);
361 295
362 /* Point to the next IRQ */ 296 /* Complete the resource header */
363 297
364 buffer += 4; 298 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
365 } 299 resource->length +=
366 300 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq);
367 /*
368 * This will leave us pointing to the Resource Source Index
369 * If it is present, then save it off and calculate the
370 * pointer to where the null terminated string goes:
371 * Each Interrupt takes 32-bits + the 5 bytes of the
372 * stream that are default.
373 *
374 * Note: Some resource descriptors will have an additional null, so
375 * we add 1 to the length.
376 */
377 if (*bytes_consumed >
378 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
379 4) + (5 + 1)) {
380 /* Dereference the Index */
381
382 temp8 = *buffer;
383 output_struct->data.extended_irq.resource_source.index =
384 (u32) temp8;
385
386 /* Point to the String */
387
388 buffer += 1;
389
390 /* Point the String pointer to the end of this structure. */
391
392 output_struct->data.extended_irq.resource_source.string_ptr =
393 (char *)((char *)output_struct + struct_size);
394
395 temp_ptr = (u8 *)
396 output_struct->data.extended_irq.resource_source.string_ptr;
397
398 /* Copy the string into the buffer */
399
400 index = 0;
401 while (*buffer) {
402 *temp_ptr = *buffer;
403
404 temp_ptr += 1;
405 buffer += 1;
406 index += 1;
407 }
408
409 /* Add the terminating null */
410
411 *temp_ptr = 0;
412 output_struct->data.extended_irq.resource_source.string_length =
413 index + 1;
414
415 /*
416 * In order for the struct_size to fall on a 32-bit boundary,
417 * calculate the length of the string and expand the
418 * struct_size to the next 32-bit boundary.
419 */
420 temp8 = (u8) (index + 1);
421 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
422 } else {
423 output_struct->data.extended_irq.resource_source.index = 0;
424 output_struct->data.extended_irq.resource_source.string_length =
425 0;
426 output_struct->data.extended_irq.resource_source.string_ptr =
427 NULL;
428 }
429
430 /* Set the Length parameter */
431
432 output_struct->length = (u32) struct_size;
433
434 /* Return the final size of the structure */
435
436 *structure_size = struct_size;
437 return_ACPI_STATUS(AE_OK); 301 return_ACPI_STATUS(AE_OK);
438} 302}
439 303
440/******************************************************************************* 304/*******************************************************************************
441 * 305 *
442 * FUNCTION: acpi_rs_extended_irq_stream 306 * FUNCTION: acpi_rs_set_ext_irq
443 * 307 *
444 * PARAMETERS: Resource - Pointer to the resource linked list 308 * PARAMETERS: Resource - Pointer to the resource descriptor
445 * output_buffer - Pointer to the user's return buffer 309 * Aml - Where the AML descriptor is returned
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 * 310 *
449 * RETURN: Status 311 * RETURN: Status
450 * 312 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the 313 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
452 * the appropriate bytes in a byte stream 314 * external AML resource descriptor.
453 * 315 *
454 ******************************************************************************/ 316 ******************************************************************************/
455 317
456acpi_status 318acpi_status
457acpi_rs_extended_irq_stream(struct acpi_resource *resource, 319acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml)
458 u8 ** output_buffer, acpi_size * bytes_consumed)
459{ 320{
460 u8 *buffer = *output_buffer; 321 acpi_size descriptor_length;
461 u16 *length_field;
462 u8 temp8 = 0;
463 u8 index;
464
465 ACPI_FUNCTION_TRACE("rs_extended_irq_stream");
466
467 /* Set the Descriptor Type field */
468
469 *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT;
470 buffer += 1;
471 322
472 /* Save a pointer to the Length field - to be filled in later */ 323 ACPI_FUNCTION_TRACE("rs_set_ext_irq");
473
474 length_field = ACPI_CAST_PTR(u16, buffer);
475 buffer += 2;
476 324
477 /* Set the Interrupt vector flags */ 325 /* Set the Interrupt vector flags */
478 326
479 temp8 = (u8) (resource->data.extended_irq.producer_consumer & 0x01); 327 aml->extended_irq.flags = (u8)
480 temp8 |= ((resource->data.extended_irq.shared_exclusive & 0x01) << 3); 328 ((resource->data.extended_irq.producer_consumer & 0x01) |
329 ((resource->data.extended_irq.sharable & 0x01) << 3) |
330 ((resource->data.extended_irq.polarity & 0x1) << 2));
481 331
482 /* 332 /*
483 * Set the Interrupt Mode 333 * Set the Interrupt Mode
@@ -488,64 +338,36 @@ acpi_rs_extended_irq_stream(struct acpi_resource *resource,
488 * 338 *
489 * - Edge/Level are defined opposite in the table vs the headers 339 * - Edge/Level are defined opposite in the table vs the headers
490 */ 340 */
491 if (ACPI_EDGE_SENSITIVE == resource->data.extended_irq.edge_level) { 341 if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) {
492 temp8 |= 0x2; 342 aml->extended_irq.flags |= 0x02;
493 } 343 }
494 344
495 /* Set the Interrupt Polarity */
496
497 temp8 |= ((resource->data.extended_irq.active_high_low & 0x1) << 2);
498
499 *buffer = temp8;
500 buffer += 1;
501
502 /* Set the Interrupt table length */ 345 /* Set the Interrupt table length */
503 346
504 temp8 = (u8) resource->data.extended_irq.number_of_interrupts; 347 aml->extended_irq.table_length = (u8)
505 348 resource->data.extended_irq.interrupt_count;
506 *buffer = temp8;
507 buffer += 1;
508 349
509 for (index = 0; 350 descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) +
510 index < resource->data.extended_irq.number_of_interrupts; 351 ((acpi_size) resource->data.extended_irq.interrupt_count *
511 index++) { 352 sizeof(u32));
512 ACPI_MOVE_32_TO_32(buffer,
513 &resource->data.extended_irq.
514 interrupts[index]);
515 buffer += 4;
516 }
517
518 /* Resource Source Index and Resource Source are optional */
519 353
520 if (0 != resource->data.extended_irq.resource_source.string_length) { 354 /* Set each interrupt value */
521 *buffer =
522 (u8) resource->data.extended_irq.resource_source.index;
523 buffer += 1;
524 355
525 /* Copy the string */ 356 acpi_rs_move_data(aml->extended_irq.interrupt_number,
357 resource->data.extended_irq.interrupts,
358 (u16) resource->data.extended_irq.interrupt_count,
359 ACPI_MOVE_TYPE_32_TO_32);
526 360
527 ACPI_STRCPY((char *)buffer, 361 /* Resource Source Index and Resource Source are optional */
528 resource->data.extended_irq.resource_source.
529 string_ptr);
530
531 /*
532 * Buffer needs to be set to the length of the string + one for the
533 * terminating null
534 */
535 buffer +=
536 (acpi_size) (ACPI_STRLEN
537 (resource->data.extended_irq.resource_source.
538 string_ptr) + 1);
539 }
540 362
541 /* Return the number of bytes consumed in this operation */ 363 descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length,
364 &resource->data.
365 extended_irq.
366 resource_source);
542 367
543 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 368 /* Complete the AML descriptor header */
544 369
545 /* 370 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ,
546 * Set the length field to the number of bytes consumed 371 descriptor_length, aml);
547 * minus the header size (3 bytes)
548 */
549 *length_field = (u16) (*bytes_consumed - 3);
550 return_ACPI_STATUS(AE_OK); 372 return_ACPI_STATUS(AE_OK);
551} 373}
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 87e75349dd0a..f72d42e0927b 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -47,106 +47,70 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rslist") 48ACPI_MODULE_NAME("rslist")
49 49
50/* Dispatch table for convert-to-stream functions */
51typedef
52acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource,
53 u8 ** output_buffer,
54 acpi_size * bytes_consumed);
55
56static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = {
57 acpi_rs_irq_stream, /* ACPI_RSTYPE_IRQ */
58 acpi_rs_dma_stream, /* ACPI_RSTYPE_DMA */
59 acpi_rs_start_depend_fns_stream, /* ACPI_RSTYPE_START_DPF */
60 acpi_rs_end_depend_fns_stream, /* ACPI_RSTYPE_END_DPF */
61 acpi_rs_io_stream, /* ACPI_RSTYPE_IO */
62 acpi_rs_fixed_io_stream, /* ACPI_RSTYPE_FIXED_IO */
63 acpi_rs_vendor_stream, /* ACPI_RSTYPE_VENDOR */
64 acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */
65 acpi_rs_memory24_stream, /* ACPI_RSTYPE_MEM24 */
66 acpi_rs_memory32_range_stream, /* ACPI_RSTYPE_MEM32 */
67 acpi_rs_fixed_memory32_stream, /* ACPI_RSTYPE_FIXED_MEM32 */
68 acpi_rs_address16_stream, /* ACPI_RSTYPE_ADDRESS16 */
69 acpi_rs_address32_stream, /* ACPI_RSTYPE_ADDRESS32 */
70 acpi_rs_address64_stream, /* ACPI_RSTYPE_ADDRESS64 */
71 acpi_rs_extended_irq_stream, /* ACPI_RSTYPE_EXT_IRQ */
72 acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */
73};
74
75/* Dispatch tables for convert-to-resource functions */
76
77typedef
78acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer,
79 acpi_size * bytes_consumed,
80 u8 ** output_buffer,
81 acpi_size * structure_size);
82
83static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = {
84 NULL, /* 0x00, Reserved */
85 NULL, /* 0x01, Reserved */
86 NULL, /* 0x02, Reserved */
87 NULL, /* 0x03, Reserved */
88 acpi_rs_irq_resource, /* ACPI_RDESC_TYPE_IRQ_FORMAT */
89 acpi_rs_dma_resource, /* ACPI_RDESC_TYPE_DMA_FORMAT */
90 acpi_rs_start_depend_fns_resource, /* ACPI_RDESC_TYPE_START_DEPENDENT */
91 acpi_rs_end_depend_fns_resource, /* ACPI_RDESC_TYPE_END_DEPENDENT */
92 acpi_rs_io_resource, /* ACPI_RDESC_TYPE_IO_PORT */
93 acpi_rs_fixed_io_resource, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */
94 NULL, /* 0x0A, Reserved */
95 NULL, /* 0x0B, Reserved */
96 NULL, /* 0x0C, Reserved */
97 NULL, /* 0x0D, Reserved */
98 acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_SMALL_VENDOR */
99 acpi_rs_end_tag_resource /* ACPI_RDESC_TYPE_END_TAG */
100};
101
102static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = {
103 NULL, /* 0x00, Reserved */
104 acpi_rs_memory24_resource, /* ACPI_RDESC_TYPE_MEMORY_24 */
105 acpi_rs_generic_register_resource, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */
106 NULL, /* 0x03, Reserved */
107 acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_LARGE_VENDOR */
108 acpi_rs_memory32_range_resource, /* ACPI_RDESC_TYPE_MEMORY_32 */
109 acpi_rs_fixed_memory32_resource, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */
110 acpi_rs_address32_resource, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */
111 acpi_rs_address16_resource, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */
112 acpi_rs_extended_irq_resource, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */
113 acpi_rs_address64_resource, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */
114 acpi_rs_address64_resource /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */
115};
116
117/* Local prototypes */ 50/* Local prototypes */
51static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type);
118 52
119static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); 53static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml);
120 54
121/******************************************************************************* 55/*******************************************************************************
122 * 56 *
123 * FUNCTION: acpi_rs_get_resource_type 57 * FUNCTION: acpi_rs_validate_resource_length
124 * 58 *
125 * PARAMETERS: resource_type - Byte 0 of a resource descriptor 59 * PARAMETERS: Aml - Pointer to the AML resource descriptor
126 * 60 *
127 * RETURN: The Resource Type with no extraneous bits (except the large/ 61 * RETURN: Status - AE_OK if the resource length appears valid
128 * small bit -- left alone)
129 * 62 *
130 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 63 * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must
131 * a resource descriptor. 64 * have the exact length; variable-length descriptors must be
65 * at least as long as the minimum. Certain Small descriptors
66 * can vary in size by at most one byte.
132 * 67 *
133 ******************************************************************************/ 68 ******************************************************************************/
134 69
135u8 acpi_rs_get_resource_type(u8 resource_type) 70static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml)
136{ 71{
72 struct acpi_resource_info *resource_info;
73 u16 minimum_aml_resource_length;
74 u16 resource_length;
75
137 ACPI_FUNCTION_ENTRY(); 76 ACPI_FUNCTION_ENTRY();
138 77
139 /* Determine if this is a small or large resource */ 78 /* Get the size and type info about this resource descriptor */
140 79
141 if (resource_type & ACPI_RDESC_TYPE_LARGE) { 80 resource_info =
142 /* Large Resource Type -- bits 6:0 contain the name */ 81 acpi_rs_get_resource_info(aml->small_header.descriptor_type);
82 if (!resource_info) {
83 return (AE_AML_INVALID_RESOURCE_TYPE);
84 }
85
86 resource_length = acpi_rs_get_resource_length(aml);
87 minimum_aml_resource_length =
88 resource_info->minimum_aml_resource_length;
89
90 /* Validate based upon the type of resource, fixed length or variable */
91
92 if (resource_info->length_type == ACPI_FIXED_LENGTH) {
93 /* Fixed length resource, length must match exactly */
143 94
144 return (resource_type); 95 if (resource_length != minimum_aml_resource_length) {
96 return (AE_AML_BAD_RESOURCE_LENGTH);
97 }
98 } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) {
99 /* Variable length resource, must be at least the minimum */
100
101 if (resource_length < minimum_aml_resource_length) {
102 return (AE_AML_BAD_RESOURCE_LENGTH);
103 }
145 } else { 104 } else {
146 /* Small Resource Type -- bits 6:3 contain the name */ 105 /* Small variable length resource, allowed to be (Min) or (Min-1) */
147 106
148 return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK)); 107 if ((resource_length > minimum_aml_resource_length) ||
108 (resource_length < (minimum_aml_resource_length - 1))) {
109 return (AE_AML_BAD_RESOURCE_LENGTH);
110 }
149 } 111 }
112
113 return (AE_OK);
150} 114}
151 115
152/******************************************************************************* 116/*******************************************************************************
@@ -162,38 +126,38 @@ u8 acpi_rs_get_resource_type(u8 resource_type)
162 * 126 *
163 ******************************************************************************/ 127 ******************************************************************************/
164 128
165static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) 129static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
166{ 130{
167 ACPI_FUNCTION_ENTRY(); 131 ACPI_FUNCTION_ENTRY();
168 132
169 /* Determine if this is a small or large resource */ 133 /* Determine if this is a small or large resource */
170 134
171 if (resource_type & ACPI_RDESC_TYPE_LARGE) { 135 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
172 /* Large Resource Type -- bits 6:0 contain the name */ 136 /* Large Resource Type -- bits 6:0 contain the name */
173 137
174 if (resource_type > ACPI_RDESC_LARGE_MAX) { 138 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
175 return (NULL); 139 return (NULL);
176 } 140 }
177 141
178 return (acpi_gbl_lg_resource_dispatch[(resource_type & 142 return (acpi_gbl_lg_get_resource_dispatch[(resource_type &
179 ACPI_RDESC_LARGE_MASK)]); 143 ACPI_RESOURCE_NAME_LARGE_MASK)]);
180 } else { 144 } else {
181 /* Small Resource Type -- bits 6:3 contain the name */ 145 /* Small Resource Type -- bits 6:3 contain the name */
182 146
183 return (acpi_gbl_sm_resource_dispatch[((resource_type & 147 return (acpi_gbl_sm_get_resource_dispatch[((resource_type &
184 ACPI_RDESC_SMALL_MASK) 148 ACPI_RESOURCE_NAME_SMALL_MASK)
185 >> 3)]); 149 >> 3)]);
186 } 150 }
187} 151}
188 152
189/******************************************************************************* 153/*******************************************************************************
190 * 154 *
191 * FUNCTION: acpi_rs_byte_stream_to_list 155 * FUNCTION: acpi_rs_convert_aml_to_resources
192 * 156 *
193 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 157 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
194 * byte_stream_buffer_length - Length of byte_stream_buffer 158 * aml_buffer_length - Length of aml_buffer
195 * output_buffer - Pointer to the buffer that will 159 * output_buffer - Pointer to the buffer that will
196 * contain the output structures 160 * contain the output structures
197 * 161 *
198 * RETURN: Status 162 * RETURN: Status
199 * 163 *
@@ -203,37 +167,60 @@ static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
203 ******************************************************************************/ 167 ******************************************************************************/
204 168
205acpi_status 169acpi_status
206acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 170acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
207 u32 byte_stream_buffer_length, u8 * output_buffer) 171 u32 aml_buffer_length, u8 * output_buffer)
208{ 172{
209 u8 *buffer = output_buffer; 173 u8 *buffer = output_buffer;
210 acpi_status status; 174 acpi_status status;
211 acpi_size bytes_parsed = 0; 175 acpi_size bytes_parsed = 0;
212 acpi_size bytes_consumed = 0;
213 acpi_size structure_size = 0;
214 struct acpi_resource *resource; 176 struct acpi_resource *resource;
215 ACPI_RESOURCE_HANDLER handler; 177 u16 resource_length;
178 u32 descriptor_length;
179 ACPI_GET_RESOURCE_HANDLER handler;
216 180
217 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); 181 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
218 182
219 /* Loop until end-of-buffer or an end_tag is found */ 183 /* Loop until end-of-buffer or an end_tag is found */
220 184
221 while (bytes_parsed < byte_stream_buffer_length) { 185 while (bytes_parsed < aml_buffer_length) {
222 /* Get the handler associated with this Descriptor Type */ 186 /* Get the handler associated with this Descriptor Type */
223 187
224 handler = acpi_rs_get_resource_handler(*byte_stream_buffer); 188 handler = acpi_rs_get_resource_handler(*aml_buffer);
225 if (handler) { 189 if (!handler) {
226 /* Convert a byte stream resource to local resource struct */ 190 /* No handler indicates invalid resource type */
227 191
228 status = handler(byte_stream_buffer, &bytes_consumed, 192 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
229 &buffer, &structure_size); 193 }
230 } else {
231 /* Invalid resource type */
232 194
233 status = AE_AML_INVALID_RESOURCE_TYPE; 195 resource_length =
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
205 /*
206 * Perform limited validation of the resource length, based upon
207 * what we know about the resource type
208 */
209 status =
210 acpi_rs_validate_resource_length(ACPI_CAST_PTR
211 (union aml_resource,
212 aml_buffer));
213 if (ACPI_FAILURE(status)) {
214 return_ACPI_STATUS(status);
234 } 215 }
235 216
217 /* Convert a byte stream resource to local resource struct */
218
219 status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer),
220 resource_length,
221 ACPI_CAST_PTR(struct acpi_resource, buffer));
236 if (ACPI_FAILURE(status)) { 222 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)));
237 return_ACPI_STATUS(status); 224 return_ACPI_STATUS(status);
238 } 225 }
239 226
@@ -245,19 +232,19 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
245 232
246 /* Normal exit on completion of an end_tag resource descriptor */ 233 /* Normal exit on completion of an end_tag resource descriptor */
247 234
248 if (acpi_rs_get_resource_type(*byte_stream_buffer) == 235 if (acpi_rs_get_resource_type(*aml_buffer) ==
249 ACPI_RDESC_TYPE_END_TAG) { 236 ACPI_RESOURCE_NAME_END_TAG) {
250 return_ACPI_STATUS(AE_OK); 237 return_ACPI_STATUS(AE_OK);
251 } 238 }
252 239
253 /* Update counter and point to the next input resource */ 240 /* Update counter and point to the next input resource */
254 241
255 bytes_parsed += bytes_consumed; 242 bytes_parsed += descriptor_length;
256 byte_stream_buffer += bytes_consumed; 243 aml_buffer += descriptor_length;
257 244
258 /* Point to the next structure in the output buffer */ 245 /* Point to the next structure in the output buffer */
259 246
260 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); 247 buffer += resource->length;
261 } 248 }
262 249
263 /* Completed buffer, but did not find an end_tag resource descriptor */ 250 /* Completed buffer, but did not find an end_tag resource descriptor */
@@ -267,17 +254,15 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
267 254
268/******************************************************************************* 255/*******************************************************************************
269 * 256 *
270 * FUNCTION: acpi_rs_list_to_byte_stream 257 * FUNCTION: acpi_rs_convert_resources_to_aml
271 * 258 *
272 * PARAMETERS: Resource - Pointer to the resource linked list 259 * PARAMETERS: Resource - Pointer to the resource linked list
273 * byte_steam_size_needed - Calculated size of the byte stream 260 * aml_size_needed - Calculated size of the byte stream
274 * needed from calling 261 * needed from calling acpi_rs_get_aml_length()
275 * acpi_rs_get_byte_stream_length() 262 * The size of the output_buffer is
276 * The size of the output_buffer is 263 * guaranteed to be >= aml_size_needed
277 * guaranteed to be >= 264 * output_buffer - Pointer to the buffer that will
278 * byte_stream_size_needed 265 * contain the byte stream
279 * output_buffer - Pointer to the buffer that will
280 * contain the byte stream
281 * 266 *
282 * RETURN: Status 267 * RETURN: Status
283 * 268 *
@@ -287,52 +272,69 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
287 ******************************************************************************/ 272 ******************************************************************************/
288 273
289acpi_status 274acpi_status
290acpi_rs_list_to_byte_stream(struct acpi_resource *resource, 275acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
291 acpi_size byte_stream_size_needed, 276 acpi_size aml_size_needed, u8 * output_buffer)
292 u8 * output_buffer)
293{ 277{
294 u8 *buffer = output_buffer; 278 u8 *aml_buffer = output_buffer;
295 acpi_size bytes_consumed = 0;
296 acpi_status status; 279 acpi_status status;
297 280
298 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); 281 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
299 282
300 /* Convert each resource descriptor in the list */ 283 /* Convert each resource descriptor in the list */
301 284
302 while (1) { 285 while (1) {
303 /* Validate Type before dispatch */ 286 /* Validate Resource Descriptor Type before dispatch */
304 287
305 if (resource->type > ACPI_RSTYPE_MAX) { 288 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
306 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
307 "Invalid descriptor type (%X) in resource list\n", 290 "Invalid descriptor type (%X) in resource list\n",
308 resource->type)); 291 resource->type));
309 return_ACPI_STATUS(AE_BAD_DATA); 292 return_ACPI_STATUS(AE_BAD_DATA);
310 } 293 }
311 294
312 /* Perform the conversion, per resource type */ 295 /* Perform the conversion per resource type */
296
297 status =
298 acpi_gbl_set_resource_dispatch[resource->type] (resource,
299 ACPI_CAST_PTR
300 (union
301 aml_resource,
302 aml_buffer));
303 if (ACPI_FAILURE(status)) {
304 ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status)));
305 return_ACPI_STATUS(status);
306 }
307
308 /* Perform final sanity check on the new AML resource descriptor */
313 309
314 status = acpi_gbl_stream_dispatch[resource->type] (resource, 310 status =
315 &buffer, 311 acpi_rs_validate_resource_length(ACPI_CAST_PTR
316 &bytes_consumed); 312 (union aml_resource,
313 aml_buffer));
317 if (ACPI_FAILURE(status)) { 314 if (ACPI_FAILURE(status)) {
318 return_ACPI_STATUS(status); 315 return_ACPI_STATUS(status);
319 } 316 }
320 317
321 /* Check for end-of-list */ 318 /* Check for end-of-list, normal exit */
322 319
323 if (resource->type == ACPI_RSTYPE_END_TAG) { 320 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
324 /* An End Tag indicates the end of the Resource Template */ 321 /* An End Tag indicates the end of the input Resource Template */
325 322
326 return_ACPI_STATUS(AE_OK); 323 return_ACPI_STATUS(AE_OK);
327 } 324 }
328 325
329 /* Set the Buffer to point to the next (output) resource descriptor */ 326 /* Extract the total length of the new descriptor */
327 /* Set the aml_buffer to point to the next (output) resource descriptor */
330 328
331 buffer += bytes_consumed; 329 aml_buffer +=
330 acpi_rs_get_descriptor_length(ACPI_CAST_PTR
331 (union aml_resource,
332 aml_buffer));
332 333
333 /* Point to the next input resource object */ 334 /* Point to the next input resource descriptor */
334 335
335 resource = ACPI_PTR_ADD(struct acpi_resource, 336 resource =
336 resource, resource->length); 337 ACPI_PTR_ADD(struct acpi_resource, resource,
338 resource->length);
337 } 339 }
338} 340}
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index 418f1afb10a3..47e979e7ba35 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -49,446 +49,260 @@ ACPI_MODULE_NAME("rsmemory")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_memory24_resource 52 * FUNCTION: acpi_rs_get_memory24
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * stream 55 * aml_resource_length - Length of the resource from the AML header
56 * bytes_consumed - Pointer to where the number of bytes 56 * Resource - Where the internal resource is returned
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 57 *
63 * RETURN: Status 58 * RETURN: Status
64 * 59 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 61 * internal resource descriptor, simplifying bitflags and handling
67 * number of bytes consumed from the byte stream. 62 * alignment and endian issues if necessary.
68 * 63 *
69 ******************************************************************************/ 64 ******************************************************************************/
70acpi_status 65acpi_status
71acpi_rs_memory24_resource(u8 * byte_stream_buffer, 66acpi_rs_get_memory24(union aml_resource * aml,
72 acpi_size * bytes_consumed, 67 u16 aml_resource_length, struct acpi_resource * resource)
73 u8 ** output_buffer, acpi_size * structure_size)
74{ 68{
75 u8 *buffer = byte_stream_buffer; 69 ACPI_FUNCTION_TRACE("rs_get_memory24");
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size =
80 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
81 70
82 ACPI_FUNCTION_TRACE("rs_memory24_resource"); 71 /* Get the Read/Write bit */
83 72
84 /* Point past the Descriptor to get the number of bytes consumed */ 73 resource->data.memory24.read_write_attribute =
74 (aml->memory24.information & 0x01);
85 75
86 buffer += 1; 76 /*
87 ACPI_MOVE_16_TO_16(&temp16, buffer); 77 * Get the following contiguous fields from the AML descriptor:
88 78 * Minimum Base Address
89 buffer += 2; 79 * Maximum Base Address
90 *bytes_consumed = (acpi_size) temp16 + 3; 80 * Address Base Alignment
91 output_struct->type = ACPI_RSTYPE_MEM24; 81 * Range Length
92 82 */
93 /* Check Byte 3 the Read/Write bit */ 83 acpi_rs_move_data(&resource->data.memory24.minimum,
94 84 &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32);
95 temp8 = *buffer;
96 buffer += 1;
97 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
98
99 /* Get min_base_address (Bytes 4-5) */
100
101 ACPI_MOVE_16_TO_16(&temp16, buffer);
102 buffer += 2;
103 output_struct->data.memory24.min_base_address = temp16;
104
105 /* Get max_base_address (Bytes 6-7) */
106
107 ACPI_MOVE_16_TO_16(&temp16, buffer);
108 buffer += 2;
109 output_struct->data.memory24.max_base_address = temp16;
110
111 /* Get Alignment (Bytes 8-9) */
112
113 ACPI_MOVE_16_TO_16(&temp16, buffer);
114 buffer += 2;
115 output_struct->data.memory24.alignment = temp16;
116
117 /* Get range_length (Bytes 10-11) */
118
119 ACPI_MOVE_16_TO_16(&temp16, buffer);
120 output_struct->data.memory24.range_length = temp16;
121
122 /* Set the Length parameter */
123
124 output_struct->length = (u32) struct_size;
125 85
126 /* Return the final size of the structure */ 86 /* Complete the resource header */
127 87
128 *structure_size = struct_size; 88 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
89 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24);
129 return_ACPI_STATUS(AE_OK); 90 return_ACPI_STATUS(AE_OK);
130} 91}
131 92
132/******************************************************************************* 93/*******************************************************************************
133 * 94 *
134 * FUNCTION: acpi_rs_memory24_stream 95 * FUNCTION: acpi_rs_set_memory24
135 * 96 *
136 * PARAMETERS: Resource - Pointer to the resource linked list 97 * PARAMETERS: Resource - Pointer to the resource descriptor
137 * output_buffer - Pointer to the user's return buffer 98 * Aml - Where the AML descriptor is returned
138 * bytes_consumed - Pointer to where the number of bytes
139 * used in the output_buffer is returned
140 * 99 *
141 * RETURN: Status 100 * RETURN: Status
142 * 101 *
143 * DESCRIPTION: Take the linked list resource structure and fills in the 102 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
144 * the appropriate bytes in a byte stream 103 * external AML resource descriptor.
145 * 104 *
146 ******************************************************************************/ 105 ******************************************************************************/
147 106
148acpi_status 107acpi_status
149acpi_rs_memory24_stream(struct acpi_resource *resource, 108acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml)
150 u8 ** output_buffer, acpi_size * bytes_consumed)
151{ 109{
152 u8 *buffer = *output_buffer; 110 ACPI_FUNCTION_TRACE("rs_set_memory24");
153 u16 temp16 = 0;
154 u8 temp8 = 0;
155
156 ACPI_FUNCTION_TRACE("rs_memory24_stream");
157
158 /* The Descriptor Type field is static */
159
160 *buffer = ACPI_RDESC_TYPE_MEMORY_24;
161 buffer += 1;
162
163 /* The length field is static */
164
165 temp16 = 0x09;
166 ACPI_MOVE_16_TO_16(buffer, &temp16);
167 buffer += 2;
168 111
169 /* Set the Information Byte */ 112 /* Set the Information Byte */
170 113
171 temp8 = (u8) (resource->data.memory24.read_write_attribute & 0x01); 114 aml->memory24.information = (u8)
172 *buffer = temp8; 115 (resource->data.memory24.read_write_attribute & 0x01);
173 buffer += 1;
174
175 /* Set the Range minimum base address */
176 116
177 ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.min_base_address); 117 /*
178 buffer += 2; 118 * Set the following contiguous fields in the AML descriptor:
179 119 * Minimum Base Address
180 /* Set the Range maximum base address */ 120 * Maximum Base Address
181 121 * Address Base Alignment
182 ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.max_base_address); 122 * Range Length
183 buffer += 2; 123 */
184 124 acpi_rs_move_data(&aml->memory24.minimum,
185 /* Set the base alignment */ 125 &resource->data.memory24.minimum, 4,
186 126 ACPI_MOVE_TYPE_32_TO_16);
187 ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.alignment);
188 buffer += 2;
189
190 /* Set the range length */
191
192 ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.range_length);
193 buffer += 2;
194 127
195 /* Return the number of bytes consumed in this operation */ 128 /* Complete the AML descriptor header */
196 129
197 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 130 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24,
131 sizeof(struct aml_resource_memory24), aml);
198 return_ACPI_STATUS(AE_OK); 132 return_ACPI_STATUS(AE_OK);
199} 133}
200 134
201/******************************************************************************* 135/*******************************************************************************
202 * 136 *
203 * FUNCTION: acpi_rs_memory32_range_resource 137 * FUNCTION: acpi_rs_get_memory32
204 * 138 *
205 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 139 * PARAMETERS: Aml - Pointer to the AML resource descriptor
206 * stream 140 * aml_resource_length - Length of the resource from the AML header
207 * bytes_consumed - Pointer to where the number of bytes 141 * Resource - Where the internal resource is returned
208 * consumed the byte_stream_buffer is
209 * returned
210 * output_buffer - Pointer to the return data buffer
211 * structure_size - Pointer to where the number of bytes
212 * in the return data struct is returned
213 * 142 *
214 * RETURN: Status 143 * RETURN: Status
215 * 144 *
216 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 145 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
217 * structure pointed to by the output_buffer. Return the 146 * internal resource descriptor, simplifying bitflags and handling
218 * number of bytes consumed from the byte stream. 147 * alignment and endian issues if necessary.
219 * 148 *
220 ******************************************************************************/ 149 ******************************************************************************/
221 150
222acpi_status 151acpi_status
223acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 152acpi_rs_get_memory32(union aml_resource *aml,
224 acpi_size * bytes_consumed, 153 u16 aml_resource_length, struct acpi_resource *resource)
225 u8 ** output_buffer, acpi_size * structure_size)
226{ 154{
227 u8 *buffer = byte_stream_buffer; 155 ACPI_FUNCTION_TRACE("rs_get_memory32");
228 struct acpi_resource *output_struct = (void *)*output_buffer;
229 u16 temp16 = 0;
230 u8 temp8 = 0;
231 acpi_size struct_size =
232 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
233
234 ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
235 156
236 /* Point past the Descriptor to get the number of bytes consumed */ 157 /* Get the Read/Write bit */
237 158
238 buffer += 1; 159 resource->data.memory32.read_write_attribute =
239 ACPI_MOVE_16_TO_16(&temp16, buffer); 160 (aml->memory32.information & 0x01);
240
241 buffer += 2;
242 *bytes_consumed = (acpi_size) temp16 + 3;
243 output_struct->type = ACPI_RSTYPE_MEM32;
244 161
245 /* 162 /*
246 * Point to the place in the output buffer where the data portion will 163 * Get the following contiguous fields from the AML descriptor:
247 * begin. 164 * Minimum Base Address
248 * 1. Set the RESOURCE_DATA * Data to point to its own address, then 165 * Maximum Base Address
249 * 2. Set the pointer to the next address. 166 * Address Base Alignment
250 * 167 * Range Length
251 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
252 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
253 */ 168 */
169 acpi_rs_move_data(&resource->data.memory32.minimum,
170 &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32);
254 171
255 /* Check Byte 3 the Read/Write bit */ 172 /* Complete the resource header */
256
257 temp8 = *buffer;
258 buffer += 1;
259
260 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
261
262 /* Get min_base_address (Bytes 4-7) */
263
264 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
265 buffer);
266 buffer += 4;
267
268 /* Get max_base_address (Bytes 8-11) */
269
270 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
271 buffer);
272 buffer += 4;
273
274 /* Get Alignment (Bytes 12-15) */
275
276 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
277 buffer += 4;
278
279 /* Get range_length (Bytes 16-19) */
280
281 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
282
283 /* Set the Length parameter */
284 173
285 output_struct->length = (u32) struct_size; 174 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
286 175 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32);
287 /* Return the final size of the structure */
288
289 *structure_size = struct_size;
290 return_ACPI_STATUS(AE_OK); 176 return_ACPI_STATUS(AE_OK);
291} 177}
292 178
293/******************************************************************************* 179/*******************************************************************************
294 * 180 *
295 * FUNCTION: acpi_rs_fixed_memory32_resource 181 * FUNCTION: acpi_rs_set_memory32
296 * 182 *
297 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 183 * PARAMETERS: Resource - Pointer to the resource descriptor
298 * stream 184 * Aml - Where the AML descriptor is returned
299 * bytes_consumed - Pointer to where the number of bytes
300 * consumed the byte_stream_buffer is
301 * returned
302 * output_buffer - Pointer to the return data buffer
303 * structure_size - Pointer to where the number of bytes
304 * in the return data struct is returned
305 * 185 *
306 * RETURN: Status 186 * RETURN: Status
307 * 187 *
308 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 188 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
309 * structure pointed to by the output_buffer. Return the 189 * external AML resource descriptor.
310 * number of bytes consumed from the byte stream.
311 * 190 *
312 ******************************************************************************/ 191 ******************************************************************************/
313 192
314acpi_status 193acpi_status
315acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 194acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml)
316 acpi_size * bytes_consumed,
317 u8 ** output_buffer, acpi_size * structure_size)
318{ 195{
319 u8 *buffer = byte_stream_buffer; 196 ACPI_FUNCTION_TRACE("rs_set_memory32");
320 struct acpi_resource *output_struct = (void *)*output_buffer;
321 u16 temp16 = 0;
322 u8 temp8 = 0;
323 acpi_size struct_size =
324 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
325
326 ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
327
328 /* Point past the Descriptor to get the number of bytes consumed */
329
330 buffer += 1;
331 ACPI_MOVE_16_TO_16(&temp16, buffer);
332
333 buffer += 2;
334 *bytes_consumed = (acpi_size) temp16 + 3;
335 output_struct->type = ACPI_RSTYPE_FIXED_MEM32;
336
337 /* Check Byte 3 the Read/Write bit */
338
339 temp8 = *buffer;
340 buffer += 1;
341 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
342
343 /* Get range_base_address (Bytes 4-7) */
344
345 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
346 range_base_address, buffer);
347 buffer += 4;
348
349 /* Get range_length (Bytes 8-11) */
350 197
351 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length, 198 /* Set the Information Byte */
352 buffer);
353 199
354 /* Set the Length parameter */ 200 aml->memory32.information = (u8)
201 (resource->data.memory32.read_write_attribute & 0x01);
355 202
356 output_struct->length = (u32) struct_size; 203 /*
204 * Set the following contiguous fields in the AML descriptor:
205 * Minimum Base Address
206 * Maximum Base Address
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);
357 213
358 /* Return the final size of the structure */ 214 /* Complete the AML descriptor header */
359 215
360 *structure_size = struct_size; 216 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32,
217 sizeof(struct aml_resource_memory32), aml);
361 return_ACPI_STATUS(AE_OK); 218 return_ACPI_STATUS(AE_OK);
362} 219}
363 220
364/******************************************************************************* 221/*******************************************************************************
365 * 222 *
366 * FUNCTION: acpi_rs_memory32_range_stream 223 * FUNCTION: acpi_rs_get_fixed_memory32
367 * 224 *
368 * PARAMETERS: Resource - Pointer to the resource linked list 225 * PARAMETERS: Aml - Pointer to the AML resource descriptor
369 * output_buffer - Pointer to the user's return buffer 226 * aml_resource_length - Length of the resource from the AML header
370 * bytes_consumed - Pointer to where the number of bytes 227 * Resource - Where the internal resource is returned
371 * used in the output_buffer is returned
372 * 228 *
373 * RETURN: Status 229 * RETURN: Status
374 * 230 *
375 * DESCRIPTION: Take the linked list resource structure and fills in the 231 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
376 * the appropriate bytes in a byte stream 232 * internal resource descriptor, simplifying bitflags and handling
233 * alignment and endian issues if necessary.
377 * 234 *
378 ******************************************************************************/ 235 ******************************************************************************/
379 236
380acpi_status 237acpi_status
381acpi_rs_memory32_range_stream(struct acpi_resource *resource, 238acpi_rs_get_fixed_memory32(union aml_resource *aml,
382 u8 ** output_buffer, acpi_size * bytes_consumed) 239 u16 aml_resource_length,
240 struct acpi_resource *resource)
383{ 241{
384 u8 *buffer = *output_buffer; 242 ACPI_FUNCTION_TRACE("rs_get_fixed_memory32");
385 u16 temp16 = 0;
386 u8 temp8 = 0;
387
388 ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
389
390 /* The Descriptor Type field is static */
391 243
392 *buffer = ACPI_RDESC_TYPE_MEMORY_32; 244 /* Get the Read/Write bit */
393 buffer += 1;
394
395 /* The length field is static */
396
397 temp16 = 0x11;
398
399 ACPI_MOVE_16_TO_16(buffer, &temp16);
400 buffer += 2;
401
402 /* Set the Information Byte */
403 245
404 temp8 = (u8) (resource->data.memory32.read_write_attribute & 0x01); 246 resource->data.fixed_memory32.read_write_attribute =
405 *buffer = temp8; 247 (aml->fixed_memory32.information & 0x01);
406 buffer += 1;
407 248
408 /* Set the Range minimum base address */ 249 /*
409 250 * Get the following contiguous fields from the AML descriptor:
410 ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.min_base_address); 251 * Base Address
411 buffer += 4; 252 * Range Length
412 253 */
413 /* Set the Range maximum base address */ 254 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address,
414 255 &aml->fixed_memory32.address);
415 ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.max_base_address); 256 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length,
416 buffer += 4; 257 &aml->fixed_memory32.address_length);
417
418 /* Set the base alignment */
419
420 ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.alignment);
421 buffer += 4;
422
423 /* Set the range length */
424
425 ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.range_length);
426 buffer += 4;
427 258
428 /* Return the number of bytes consumed in this operation */ 259 /* Complete the resource header */
429 260
430 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 261 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
262 resource->length =
263 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32);
431 return_ACPI_STATUS(AE_OK); 264 return_ACPI_STATUS(AE_OK);
432} 265}
433 266
434/******************************************************************************* 267/*******************************************************************************
435 * 268 *
436 * FUNCTION: acpi_rs_fixed_memory32_stream 269 * FUNCTION: acpi_rs_set_fixed_memory32
437 * 270 *
438 * PARAMETERS: Resource - Pointer to the resource linked list 271 * PARAMETERS: Resource - Pointer to the resource descriptor
439 * output_buffer - Pointer to the user's return buffer 272 * Aml - Where the AML descriptor is returned
440 * bytes_consumed - Pointer to where the number of bytes
441 * used in the output_buffer is returned
442 * 273 *
443 * RETURN: Status 274 * RETURN: Status
444 * 275 *
445 * DESCRIPTION: Take the linked list resource structure and fills in the 276 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
446 * the appropriate bytes in a byte stream 277 * external AML resource descriptor.
447 * 278 *
448 ******************************************************************************/ 279 ******************************************************************************/
449 280
450acpi_status 281acpi_status
451acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, 282acpi_rs_set_fixed_memory32(struct acpi_resource *resource,
452 u8 ** output_buffer, acpi_size * bytes_consumed) 283 union aml_resource *aml)
453{ 284{
454 u8 *buffer = *output_buffer; 285 ACPI_FUNCTION_TRACE("rs_set_fixed_memory32");
455 u16 temp16 = 0;
456 u8 temp8 = 0;
457
458 ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
459
460 /* The Descriptor Type field is static */
461
462 *buffer = ACPI_RDESC_TYPE_FIXED_MEMORY_32;
463 buffer += 1;
464
465 /* The length field is static */
466
467 temp16 = 0x09;
468
469 ACPI_MOVE_16_TO_16(buffer, &temp16);
470 buffer += 2;
471 286
472 /* Set the Information Byte */ 287 /* Set the Information Byte */
473 288
474 temp8 = 289 aml->fixed_memory32.information = (u8)
475 (u8) (resource->data.fixed_memory32.read_write_attribute & 0x01); 290 (resource->data.fixed_memory32.read_write_attribute & 0x01);
476 *buffer = temp8;
477 buffer += 1;
478 291
479 /* Set the Range base address */ 292 /*
480 293 * Set the following contiguous fields in the AML descriptor:
481 ACPI_MOVE_32_TO_32(buffer, 294 * Base Address
482 &resource->data.fixed_memory32.range_base_address); 295 * Range Length
483 buffer += 4; 296 */
484 297 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address,
485 /* Set the range length */ 298 &resource->data.fixed_memory32.address);
486 299 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length,
487 ACPI_MOVE_32_TO_32(buffer, &resource->data.fixed_memory32.range_length); 300 &resource->data.fixed_memory32.address_length);
488 buffer += 4;
489 301
490 /* Return the number of bytes consumed in this operation */ 302 /* Complete the AML descriptor header */
491 303
492 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 304 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32,
305 sizeof(struct aml_resource_fixed_memory32),
306 aml);
493 return_ACPI_STATUS(AE_OK); 307 return_ACPI_STATUS(AE_OK);
494} 308}
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index fa7f5a85b61d..337a0f01cb23 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -49,641 +49,432 @@ ACPI_MODULE_NAME("rsmisc")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_generic_register_resource 52 * FUNCTION: acpi_rs_get_generic_reg
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * stream 55 * aml_resource_length - Length of the resource from the AML header
56 * bytes_consumed - Pointer to where the number of bytes 56 * Resource - Where the internal resource is returned
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 57 *
63 * RETURN: Status 58 * RETURN: Status
64 * 59 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 60 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 61 * internal resource descriptor, simplifying bitflags and handling
67 * number of bytes consumed from the byte stream. 62 * alignment and endian issues if necessary.
68 * 63 *
69 ******************************************************************************/ 64 ******************************************************************************/
70acpi_status 65acpi_status
71acpi_rs_generic_register_resource(u8 * byte_stream_buffer, 66acpi_rs_get_generic_reg(union aml_resource *aml,
72 acpi_size * bytes_consumed, 67 u16 aml_resource_length, struct acpi_resource *resource)
73 u8 ** output_buffer,
74 acpi_size * structure_size)
75{ 68{
76 u8 *buffer = byte_stream_buffer; 69 ACPI_FUNCTION_TRACE("rs_get_generic_reg");
77 struct acpi_resource *output_struct = (void *)*output_buffer;
78 u16 temp16;
79 u8 temp8;
80 acpi_size struct_size =
81 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg);
82 70
83 ACPI_FUNCTION_TRACE("rs_generic_register_resource"); 71 /*
84 72 * Get the following fields from the AML descriptor:
85 /* Byte 0 is the Descriptor Type */ 73 * Address Space ID
86 74 * Register Bit Width
87 buffer += 1; 75 * Register Bit Offset
88 76 * Access Size
89 /* Get the Descriptor Length field (Bytes 1-2) */ 77 * Register Address
90 78 */
91 ACPI_MOVE_16_TO_16(&temp16, buffer); 79 resource->data.generic_reg.space_id = aml->generic_reg.address_space_id;
92 buffer += 2; 80 resource->data.generic_reg.bit_width = aml->generic_reg.bit_width;
93 81 resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset;
94 /* Validate the descriptor length */ 82 resource->data.generic_reg.access_size = aml->generic_reg.access_size;
95 83 ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address,
96 if (temp16 != 12) { 84 &aml->generic_reg.address);
97 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 85
98 } 86 /* Complete the resource header */
99 87
100 /* The number of bytes consumed is fixed (12 + 3) */ 88 resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER;
101 89 resource->length =
102 *bytes_consumed = 15; 90 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register);
103
104 /* Fill out the structure */
105
106 output_struct->type = ACPI_RSTYPE_GENERIC_REG;
107
108 /* Get space_id (Byte 3) */
109
110 temp8 = *buffer;
111 output_struct->data.generic_reg.space_id = temp8;
112 buffer += 1;
113
114 /* Get register_bit_width (Byte 4) */
115
116 temp8 = *buffer;
117 output_struct->data.generic_reg.bit_width = temp8;
118 buffer += 1;
119
120 /* Get register_bit_offset (Byte 5) */
121
122 temp8 = *buffer;
123 output_struct->data.generic_reg.bit_offset = temp8;
124 buffer += 1;
125
126 /* Get address_size (Byte 6) */
127
128 temp8 = *buffer;
129 output_struct->data.generic_reg.address_size = temp8;
130 buffer += 1;
131
132 /* Get register_address (Bytes 7-14) */
133
134 ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer);
135
136 /* Set the Length parameter */
137
138 output_struct->length = (u32) struct_size;
139
140 /* Return the final size of the structure */
141
142 *structure_size = struct_size;
143 return_ACPI_STATUS(AE_OK); 91 return_ACPI_STATUS(AE_OK);
144} 92}
145 93
146/******************************************************************************* 94/*******************************************************************************
147 * 95 *
148 * FUNCTION: acpi_rs_generic_register_stream 96 * FUNCTION: acpi_rs_set_generic_reg
149 * 97 *
150 * PARAMETERS: Resource - Pointer to the resource linked list 98 * PARAMETERS: Resource - Pointer to the resource descriptor
151 * output_buffer - Pointer to the user's return buffer 99 * Aml - Where the AML descriptor is returned
152 * bytes_consumed - Pointer to where the number of bytes
153 * used in the output_buffer is returned
154 * 100 *
155 * RETURN: Status 101 * RETURN: Status
156 * 102 *
157 * DESCRIPTION: Take the linked list resource structure and fills in the 103 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
158 * the appropriate bytes in a byte stream 104 * external AML resource descriptor.
159 * 105 *
160 ******************************************************************************/ 106 ******************************************************************************/
161 107
162acpi_status 108acpi_status
163acpi_rs_generic_register_stream(struct acpi_resource *resource, 109acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml)
164 u8 ** output_buffer, acpi_size * bytes_consumed)
165{ 110{
166 u8 *buffer = *output_buffer; 111 ACPI_FUNCTION_TRACE("rs_set_generic_reg");
167 u16 temp16;
168
169 ACPI_FUNCTION_TRACE("rs_generic_register_stream");
170
171 /* Set the Descriptor Type (Byte 0) */
172
173 *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER;
174 buffer += 1;
175
176 /* Set the Descriptor Length (Bytes 1-2) */
177
178 temp16 = 12;
179 ACPI_MOVE_16_TO_16(buffer, &temp16);
180 buffer += 2;
181
182 /* Set space_id (Byte 3) */
183
184 *buffer = (u8) resource->data.generic_reg.space_id;
185 buffer += 1;
186
187 /* Set register_bit_width (Byte 4) */
188
189 *buffer = (u8) resource->data.generic_reg.bit_width;
190 buffer += 1;
191
192 /* Set register_bit_offset (Byte 5) */
193
194 *buffer = (u8) resource->data.generic_reg.bit_offset;
195 buffer += 1;
196
197 /* Set address_size (Byte 6) */
198
199 *buffer = (u8) resource->data.generic_reg.address_size;
200 buffer += 1;
201
202 /* Set register_address (Bytes 7-14) */
203 112
204 ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address); 113 /*
205 buffer += 8; 114 * Set the following fields in the AML descriptor:
206 115 * Address Space ID
207 /* Return the number of bytes consumed in this operation */ 116 * Register Bit Width
208 117 * Register Bit Offset
209 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 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);
210 return_ACPI_STATUS(AE_OK); 136 return_ACPI_STATUS(AE_OK);
211} 137}
212 138
213/******************************************************************************* 139/*******************************************************************************
214 * 140 *
215 * FUNCTION: acpi_rs_end_tag_resource 141 * FUNCTION: acpi_rs_get_vendor
216 * 142 *
217 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 143 * PARAMETERS: Aml - Pointer to the AML resource descriptor
218 * stream 144 * aml_resource_length - Length of the resource from the AML header
219 * bytes_consumed - Pointer to where the number of bytes 145 * Resource - Where the internal resource is returned
220 * consumed the byte_stream_buffer is
221 * returned
222 * output_buffer - Pointer to the return data buffer
223 * structure_size - Pointer to where the number of bytes
224 * in the return data struct is returned
225 * 146 *
226 * RETURN: Status 147 * RETURN: Status
227 * 148 *
228 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 149 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
229 * structure pointed to by the output_buffer. Return the 150 * internal resource descriptor, simplifying bitflags and handling
230 * number of bytes consumed from the byte stream. 151 * alignment and endian issues if necessary.
231 * 152 *
232 ******************************************************************************/ 153 ******************************************************************************/
233 154
234acpi_status 155acpi_status
235acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 156acpi_rs_get_vendor(union aml_resource *aml,
236 acpi_size * bytes_consumed, 157 u16 aml_resource_length, struct acpi_resource *resource)
237 u8 ** output_buffer, acpi_size * structure_size)
238{ 158{
239 struct acpi_resource *output_struct = (void *)*output_buffer; 159 u8 *aml_byte_data;
240 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
241
242 ACPI_FUNCTION_TRACE("rs_end_tag_resource");
243 160
244 /* The number of bytes consumed is static */ 161 ACPI_FUNCTION_TRACE("rs_get_vendor");
245 162
246 *bytes_consumed = 2; 163 /* Determine if this is a large or small vendor specific item */
247 164
248 /* Fill out the structure */ 165 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
166 /* Large item, Point to the first vendor byte */
249 167
250 output_struct->type = ACPI_RSTYPE_END_TAG; 168 aml_byte_data =
169 ((u8 *) aml) + sizeof(struct aml_resource_large_header);
170 } else {
171 /* Small item, Point to the first vendor byte */
251 172
252 /* Set the Length parameter */ 173 aml_byte_data =
174 ((u8 *) aml) + sizeof(struct aml_resource_small_header);
175 }
253 176
254 output_struct->length = 0; 177 /* Copy the vendor-specific bytes */
255 178
256 /* Return the final size of the structure */ 179 ACPI_MEMCPY(resource->data.vendor.byte_data,
180 aml_byte_data, aml_resource_length);
181 resource->data.vendor.byte_length = aml_resource_length;
257 182
258 *structure_size = struct_size; 183 /*
184 * In order for the struct_size to fall on a 32-bit boundary,
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);
259 return_ACPI_STATUS(AE_OK); 191 return_ACPI_STATUS(AE_OK);
260} 192}
261 193
262/******************************************************************************* 194/*******************************************************************************
263 * 195 *
264 * FUNCTION: acpi_rs_end_tag_stream 196 * FUNCTION: acpi_rs_set_vendor
265 * 197 *
266 * PARAMETERS: Resource - Pointer to the resource linked list 198 * PARAMETERS: Resource - Pointer to the resource descriptor
267 * output_buffer - Pointer to the user's return buffer 199 * Aml - Where the AML descriptor is returned
268 * bytes_consumed - Pointer to where the number of bytes
269 * used in the output_buffer is returned
270 * 200 *
271 * RETURN: Status 201 * RETURN: Status
272 * 202 *
273 * DESCRIPTION: Take the linked list resource structure and fills in the 203 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
274 * the appropriate bytes in a byte stream 204 * external AML resource descriptor.
275 * 205 *
276 ******************************************************************************/ 206 ******************************************************************************/
277 207
278acpi_status 208acpi_status
279acpi_rs_end_tag_stream(struct acpi_resource *resource, 209acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml)
280 u8 ** output_buffer, acpi_size * bytes_consumed)
281{ 210{
282 u8 *buffer = *output_buffer; 211 u32 resource_length;
283 u8 temp8 = 0; 212 u8 *source;
213 u8 *destination;
284 214
285 ACPI_FUNCTION_TRACE("rs_end_tag_stream"); 215 ACPI_FUNCTION_TRACE("rs_set_vendor");
286 216
287 /* The Descriptor Type field is static */ 217 resource_length = resource->data.vendor.byte_length;
218 source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data);
288 219
289 *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01; 220 /* Length determines if this is a large or small resource */
290 buffer += 1;
291 221
292 /* 222 if (resource_length > 7) {
293 * Set the Checksum - zero means that the resource data is treated as if 223 /* Large item, get pointer to the data part of the descriptor */
294 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) 224
295 */ 225 destination =
296 temp8 = 0; 226 ((u8 *) aml) + sizeof(struct aml_resource_large_header);
227
228 /* Complete the AML descriptor header */
229
230 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE,
231 (u32) (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 */
297 237
298 *buffer = temp8; 238 destination =
299 buffer += 1; 239 ((u8 *) aml) + sizeof(struct aml_resource_small_header);
300 240
301 /* Return the number of bytes consumed in this operation */ 241 /* Complete the AML descriptor header */
302 242
303 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 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 }
249
250 /* Copy the vendor-specific bytes */
251
252 ACPI_MEMCPY(destination, source, resource_length);
304 return_ACPI_STATUS(AE_OK); 253 return_ACPI_STATUS(AE_OK);
305} 254}
306 255
307/******************************************************************************* 256/*******************************************************************************
308 * 257 *
309 * FUNCTION: acpi_rs_vendor_resource 258 * FUNCTION: acpi_rs_get_start_dpf
310 * 259 *
311 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 260 * PARAMETERS: Aml - Pointer to the AML resource descriptor
312 * stream 261 * aml_resource_length - Length of the resource from the AML header
313 * bytes_consumed - Pointer to where the number of bytes 262 * Resource - Where the internal resource is returned
314 * consumed the byte_stream_buffer is
315 * returned
316 * output_buffer - Pointer to the return data buffer
317 * structure_size - Pointer to where the number of bytes
318 * in the return data struct is returned
319 * 263 *
320 * RETURN: Status 264 * RETURN: Status
321 * 265 *
322 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 266 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
323 * structure pointed to by the output_buffer. Return the 267 * internal resource descriptor, simplifying bitflags and handling
324 * number of bytes consumed from the byte stream. 268 * alignment and endian issues if necessary.
325 * 269 *
326 ******************************************************************************/ 270 ******************************************************************************/
327 271
328acpi_status 272acpi_status
329acpi_rs_vendor_resource(u8 * byte_stream_buffer, 273acpi_rs_get_start_dpf(union aml_resource *aml,
330 acpi_size * bytes_consumed, 274 u16 aml_resource_length, struct acpi_resource *resource)
331 u8 ** output_buffer, acpi_size * structure_size)
332{ 275{
333 u8 *buffer = byte_stream_buffer; 276 ACPI_FUNCTION_TRACE("rs_get_start_dpf");
334 struct acpi_resource *output_struct = (void *)*output_buffer;
335 u16 temp16 = 0;
336 u8 temp8 = 0;
337 u8 index;
338 acpi_size struct_size =
339 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
340
341 ACPI_FUNCTION_TRACE("rs_vendor_resource");
342
343 /* Dereference the Descriptor to find if this is a large or small item. */
344 277
345 temp8 = *buffer; 278 /* Get the flags byte if present */
346 279
347 if (temp8 & ACPI_RDESC_TYPE_LARGE) { 280 if (aml_resource_length == 1) {
348 /* Large Item, point to the length field */ 281 /* Get the Compatibility priority */
349 282
350 buffer += 1; 283 resource->data.start_dpf.compatibility_priority =
284 (aml->start_dpf.flags & 0x03);
351 285
352 /* Dereference */ 286 if (resource->data.start_dpf.compatibility_priority >= 3) {
353 287 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
354 ACPI_MOVE_16_TO_16(&temp16, buffer); 288 }
355
356 /* Calculate bytes consumed */
357 289
358 *bytes_consumed = (acpi_size) temp16 + 3; 290 /* Get the Performance/Robustness preference */
359 291
360 /* Point to the first vendor byte */ 292 resource->data.start_dpf.performance_robustness =
293 ((aml->start_dpf.flags >> 2) & 0x03);
361 294
362 buffer += 2; 295 if (resource->data.start_dpf.performance_robustness >= 3) {
296 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
297 }
363 } else { 298 } else {
364 /* Small Item, dereference the size */ 299 /* start_dependent_no_pri(), no flags byte, set defaults */
365
366 temp16 = (u8) (*buffer & 0x07);
367
368 /* Calculate bytes consumed */
369 300
370 *bytes_consumed = (acpi_size) temp16 + 1; 301 resource->data.start_dpf.compatibility_priority =
371 302 ACPI_ACCEPTABLE_CONFIGURATION;
372 /* Point to the first vendor byte */
373 303
374 buffer += 1; 304 resource->data.start_dpf.performance_robustness =
305 ACPI_ACCEPTABLE_CONFIGURATION;
375 } 306 }
376 307
377 output_struct->type = ACPI_RSTYPE_VENDOR; 308 /* Complete the resource header */
378 output_struct->data.vendor_specific.length = temp16;
379
380 for (index = 0; index < temp16; index++) {
381 output_struct->data.vendor_specific.reserved[index] = *buffer;
382 buffer += 1;
383 }
384 309
385 /* 310 resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT;
386 * In order for the struct_size to fall on a 32-bit boundary, 311 resource->length =
387 * calculate the length of the vendor string and expand the 312 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent);
388 * struct_size to the next 32-bit boundary.
389 */
390 struct_size += ACPI_ROUND_UP_to_32_bITS(temp16);
391
392 /* Set the Length parameter */
393
394 output_struct->length = (u32) struct_size;
395
396 /* Return the final size of the structure */
397
398 *structure_size = struct_size;
399 return_ACPI_STATUS(AE_OK); 313 return_ACPI_STATUS(AE_OK);
400} 314}
401 315
402/******************************************************************************* 316/*******************************************************************************
403 * 317 *
404 * FUNCTION: acpi_rs_vendor_stream 318 * FUNCTION: acpi_rs_set_start_dpf
405 * 319 *
406 * PARAMETERS: Resource - Pointer to the resource linked list 320 * PARAMETERS: Resource - Pointer to the resource descriptor
407 * output_buffer - Pointer to the user's return buffer 321 * Aml - Where the AML descriptor is returned
408 * bytes_consumed - Pointer to where the number of bytes
409 * used in the output_buffer is returned
410 * 322 *
411 * RETURN: Status 323 * RETURN: Status
412 * 324 *
413 * DESCRIPTION: Take the linked list resource structure and fills in the 325 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
414 * the appropriate bytes in a byte stream 326 * external AML resource descriptor.
415 * 327 *
416 ******************************************************************************/ 328 ******************************************************************************/
417 329
418acpi_status 330acpi_status
419acpi_rs_vendor_stream(struct acpi_resource *resource, 331acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml)
420 u8 ** output_buffer, acpi_size * bytes_consumed)
421{ 332{
422 u8 *buffer = *output_buffer; 333 ACPI_FUNCTION_TRACE("rs_set_start_dpf");
423 u16 temp16 = 0;
424 u8 temp8 = 0;
425 u8 index;
426
427 ACPI_FUNCTION_TRACE("rs_vendor_stream");
428
429 /* Dereference the length to find if this is a large or small item. */
430
431 if (resource->data.vendor_specific.length > 7) {
432 /* Large Item, Set the descriptor field and length bytes */
433 334
434 *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR; 335 /*
435 buffer += 1; 336 * The descriptor type field is set based upon whether a byte is needed
436 337 * to contain Priority data.
437 temp16 = (u16) resource->data.vendor_specific.length; 338 */
438 339 if (ACPI_ACCEPTABLE_CONFIGURATION ==
439 ACPI_MOVE_16_TO_16(buffer, &temp16); 340 resource->data.start_dpf.compatibility_priority &&
440 buffer += 2; 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);
441 } else { 347 } else {
442 /* Small Item, Set the descriptor field */ 348 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
443 349 sizeof(struct
444 temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR; 350 aml_resource_start_dependent),
445 temp8 |= (u8) resource->data.vendor_specific.length; 351 aml);
446 352
447 *buffer = temp8; 353 /* Set the Flags byte */
448 buffer += 1; 354
449 } 355 aml->start_dpf.flags = (u8)
450 356 (((resource->data.start_dpf.
451 /* Loop through all of the Vendor Specific fields */ 357 performance_robustness & 0x03) << 2) | (resource->data.
452 358 start_dpf.
453 for (index = 0; index < resource->data.vendor_specific.length; index++) { 359 compatibility_priority
454 temp8 = resource->data.vendor_specific.reserved[index]; 360 & 0x03));
455
456 *buffer = temp8;
457 buffer += 1;
458 } 361 }
459
460 /* Return the number of bytes consumed in this operation */
461
462 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
463 return_ACPI_STATUS(AE_OK); 362 return_ACPI_STATUS(AE_OK);
464} 363}
465 364
466/******************************************************************************* 365/*******************************************************************************
467 * 366 *
468 * FUNCTION: acpi_rs_start_depend_fns_resource 367 * FUNCTION: acpi_rs_get_end_dpf
469 * 368 *
470 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 369 * PARAMETERS: Aml - Pointer to the AML resource descriptor
471 * stream 370 * aml_resource_length - Length of the resource from the AML header
472 * bytes_consumed - Pointer to where the number of bytes 371 * Resource - Where the internal resource is returned
473 * consumed the byte_stream_buffer is
474 * returned
475 * output_buffer - Pointer to the return data buffer
476 * structure_size - Pointer to where the number of bytes
477 * in the return data struct is returned
478 * 372 *
479 * RETURN: Status 373 * RETURN: Status
480 * 374 *
481 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 375 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
482 * structure pointed to by the output_buffer. Return the 376 * internal resource descriptor, simplifying bitflags and handling
483 * number of bytes consumed from the byte stream. 377 * alignment and endian issues if necessary.
484 * 378 *
485 ******************************************************************************/ 379 ******************************************************************************/
486 380
487acpi_status 381acpi_status
488acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 382acpi_rs_get_end_dpf(union aml_resource *aml,
489 acpi_size * bytes_consumed, 383 u16 aml_resource_length, struct acpi_resource *resource)
490 u8 ** output_buffer,
491 acpi_size * structure_size)
492{ 384{
493 u8 *buffer = byte_stream_buffer; 385 ACPI_FUNCTION_TRACE("rs_get_end_dpf");
494 struct acpi_resource *output_struct = (void *)*output_buffer;
495 u8 temp8 = 0;
496 acpi_size struct_size =
497 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf);
498
499 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
500
501 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
502
503 temp8 = *buffer;
504
505 *bytes_consumed = (temp8 & 0x01) + 1;
506
507 output_struct->type = ACPI_RSTYPE_START_DPF;
508
509 /* Point to Byte 1 if it is used */
510
511 if (2 == *bytes_consumed) {
512 buffer += 1;
513 temp8 = *buffer;
514
515 /* Check Compatibility priority */
516
517 output_struct->data.start_dpf.compatibility_priority =
518 temp8 & 0x03;
519
520 if (3 == output_struct->data.start_dpf.compatibility_priority) {
521 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
522 }
523 386
524 /* Check Performance/Robustness preference */ 387 /* Complete the resource header */
525 388
526 output_struct->data.start_dpf.performance_robustness = 389 resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT;
527 (temp8 >> 2) & 0x03; 390 resource->length = (u32) ACPI_RESOURCE_LENGTH;
528
529 if (3 == output_struct->data.start_dpf.performance_robustness) {
530 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
531 }
532 } else {
533 output_struct->data.start_dpf.compatibility_priority =
534 ACPI_ACCEPTABLE_CONFIGURATION;
535
536 output_struct->data.start_dpf.performance_robustness =
537 ACPI_ACCEPTABLE_CONFIGURATION;
538 }
539
540 /* Set the Length parameter */
541
542 output_struct->length = (u32) struct_size;
543
544 /* Return the final size of the structure */
545
546 *structure_size = struct_size;
547 return_ACPI_STATUS(AE_OK); 391 return_ACPI_STATUS(AE_OK);
548} 392}
549 393
550/******************************************************************************* 394/*******************************************************************************
551 * 395 *
552 * FUNCTION: acpi_rs_end_depend_fns_resource 396 * FUNCTION: acpi_rs_set_end_dpf
553 * 397 *
554 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 398 * PARAMETERS: Resource - Pointer to the resource descriptor
555 * stream 399 * Aml - Where the AML descriptor is returned
556 * bytes_consumed - Pointer to where the number of bytes
557 * consumed the byte_stream_buffer is
558 * returned
559 * output_buffer - Pointer to the return data buffer
560 * structure_size - Pointer to where the number of bytes
561 * in the return data struct is returned
562 * 400 *
563 * RETURN: Status 401 * RETURN: Status
564 * 402 *
565 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 403 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
566 * structure pointed to by the output_buffer. Return the 404 * external AML resource descriptor.
567 * number of bytes consumed from the byte stream.
568 * 405 *
569 ******************************************************************************/ 406 ******************************************************************************/
570 407
571acpi_status 408acpi_status
572acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, 409acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml)
573 acpi_size * bytes_consumed,
574 u8 ** output_buffer, acpi_size * structure_size)
575{ 410{
576 struct acpi_resource *output_struct = (void *)*output_buffer; 411 ACPI_FUNCTION_TRACE("rs_set_end_dpf");
577 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
578
579 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
580
581 /* The number of bytes consumed is static */
582
583 *bytes_consumed = 1;
584 412
585 /* Fill out the structure */ 413 /* Complete the AML descriptor header */
586 414
587 output_struct->type = ACPI_RSTYPE_END_DPF; 415 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT,
588 416 sizeof(struct aml_resource_end_dependent),
589 /* Set the Length parameter */ 417 aml);
590
591 output_struct->length = (u32) struct_size;
592
593 /* Return the final size of the structure */
594
595 *structure_size = struct_size;
596 return_ACPI_STATUS(AE_OK); 418 return_ACPI_STATUS(AE_OK);
597} 419}
598 420
599/******************************************************************************* 421/*******************************************************************************
600 * 422 *
601 * FUNCTION: acpi_rs_start_depend_fns_stream 423 * FUNCTION: acpi_rs_get_end_tag
602 * 424 *
603 * PARAMETERS: Resource - Pointer to the resource linked list 425 * PARAMETERS: Aml - Pointer to the AML resource descriptor
604 * output_buffer - Pointer to the user's return buffer 426 * aml_resource_length - Length of the resource from the AML header
605 * bytes_consumed - u32 pointer that is filled with 427 * Resource - Where the internal resource is returned
606 * the number of bytes of the
607 * output_buffer used
608 * 428 *
609 * RETURN: Status 429 * RETURN: Status
610 * 430 *
611 * DESCRIPTION: Take the linked list resource structure and fills in the 431 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
612 * the appropriate bytes in a byte stream 432 * internal resource descriptor, simplifying bitflags and handling
433 * alignment and endian issues if necessary.
613 * 434 *
614 ******************************************************************************/ 435 ******************************************************************************/
615 436
616acpi_status 437acpi_status
617acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, 438acpi_rs_get_end_tag(union aml_resource *aml,
618 u8 ** output_buffer, acpi_size * bytes_consumed) 439 u16 aml_resource_length, struct acpi_resource *resource)
619{ 440{
620 u8 *buffer = *output_buffer; 441 ACPI_FUNCTION_TRACE("rs_get_end_tag");
621 u8 temp8 = 0;
622
623 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
624 442
625 /* 443 /* Complete the resource header */
626 * The descriptor type field is set based upon whether a byte is needed
627 * to contain Priority data.
628 */
629 if (ACPI_ACCEPTABLE_CONFIGURATION ==
630 resource->data.start_dpf.compatibility_priority &&
631 ACPI_ACCEPTABLE_CONFIGURATION ==
632 resource->data.start_dpf.performance_robustness) {
633 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT;
634 } else {
635 *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01;
636 buffer += 1;
637
638 /* Set the Priority Byte Definition */
639 444
640 temp8 = 0; 445 resource->type = ACPI_RESOURCE_TYPE_END_TAG;
641 temp8 = (u8) ((resource->data.start_dpf.performance_robustness & 446 resource->length = ACPI_RESOURCE_LENGTH;
642 0x03) << 2);
643 temp8 |= (resource->data.start_dpf.compatibility_priority &
644 0x03);
645 *buffer = temp8;
646 }
647
648 buffer += 1;
649
650 /* Return the number of bytes consumed in this operation */
651
652 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
653 return_ACPI_STATUS(AE_OK); 447 return_ACPI_STATUS(AE_OK);
654} 448}
655 449
656/******************************************************************************* 450/*******************************************************************************
657 * 451 *
658 * FUNCTION: acpi_rs_end_depend_fns_stream 452 * FUNCTION: acpi_rs_set_end_tag
659 * 453 *
660 * PARAMETERS: Resource - Pointer to the resource linked list 454 * PARAMETERS: Resource - Pointer to the resource descriptor
661 * output_buffer - Pointer to the user's return buffer 455 * Aml - Where the AML descriptor is returned
662 * bytes_consumed - Pointer to where the number of bytes
663 * used in the output_buffer is returned
664 * 456 *
665 * RETURN: Status 457 * RETURN: Status
666 * 458 *
667 * DESCRIPTION: Take the linked list resource structure and fills in the 459 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
668 * the appropriate bytes in a byte stream 460 * external AML resource descriptor.
669 * 461 *
670 ******************************************************************************/ 462 ******************************************************************************/
671 463
672acpi_status 464acpi_status
673acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, 465acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml)
674 u8 ** output_buffer, acpi_size * bytes_consumed)
675{ 466{
676 u8 *buffer = *output_buffer; 467 ACPI_FUNCTION_TRACE("rs_set_end_tag");
677
678 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
679 468
680 /* The Descriptor Type field is static */ 469 /*
681 470 * Set the Checksum - zero means that the resource data is treated as if
682 *buffer = ACPI_RDESC_TYPE_END_DEPENDENT; 471 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
683 buffer += 1; 472 */
473 aml->end_tag.checksum = 0;
684 474
685 /* Return the number of bytes consumed in this operation */ 475 /* Complete the AML descriptor header */
686 476
687 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 477 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG,
478 sizeof(struct aml_resource_end_tag), aml);
688 return_ACPI_STATUS(AE_OK); 479 return_ACPI_STATUS(AE_OK);
689} 480}
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 4446778eaf79..9d503de1a349 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -50,6 +50,438 @@ ACPI_MODULE_NAME("rsutils")
50 50
51/******************************************************************************* 51/*******************************************************************************
52 * 52 *
53 * FUNCTION: acpi_rs_move_data
54 *
55 * PARAMETERS: Destination - Pointer to the destination descriptor
56 * Source - Pointer to the source descriptor
57 * item_count - How many items to move
58 * move_type - Byte width
59 *
60 * RETURN: None
61 *
62 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
63 * alignment issues and endian issues if necessary, as configured
64 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
65 *
66 ******************************************************************************/
67void
68acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
69{
70 acpi_native_uint i;
71
72 /* One move per item */
73
74 for (i = 0; i < item_count; i++) {
75 switch (move_type) {
76 case ACPI_MOVE_TYPE_16_TO_32:
77 ACPI_MOVE_16_TO_32(&((u32 *) destination)[i],
78 &((u16 *) source)[i]);
79 break;
80
81 case ACPI_MOVE_TYPE_32_TO_16:
82 ACPI_MOVE_32_TO_16(&((u16 *) destination)[i],
83 &((u32 *) source)[i]);
84 break;
85
86 case ACPI_MOVE_TYPE_32_TO_32:
87 ACPI_MOVE_32_TO_32(&((u32 *) destination)[i],
88 &((u32 *) source)[i]);
89 break;
90
91 case ACPI_MOVE_TYPE_64_TO_64:
92 ACPI_MOVE_64_TO_64(&((u64 *) destination)[i],
93 &((u64 *) source)[i]);
94 break;
95
96 default:
97 return;
98 }
99 }
100}
101
102/*******************************************************************************
103 *
104 * FUNCTION: acpi_rs_get_resource_info
105 *
106 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
107 *
108 * RETURN: Pointer to the resource conversion handler
109 *
110 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
111 * a resource descriptor.
112 *
113 ******************************************************************************/
114
115struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type)
116{
117 struct acpi_resource_info *size_info;
118
119 ACPI_FUNCTION_ENTRY();
120
121 /* Determine if this is a small or large resource */
122
123 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
124 /* Large Resource Type -- bits 6:0 contain the name */
125
126 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
127 return (NULL);
128 }
129
130 size_info = &acpi_gbl_lg_resource_info[(resource_type &
131 ACPI_RESOURCE_NAME_LARGE_MASK)];
132 } else {
133 /* Small Resource Type -- bits 6:3 contain the name */
134
135 size_info = &acpi_gbl_sm_resource_info[((resource_type &
136 ACPI_RESOURCE_NAME_SMALL_MASK)
137 >> 3)];
138 }
139
140 /* Zero entry indicates an invalid resource type */
141
142 if (!size_info->minimum_internal_struct_length) {
143 return (NULL);
144 }
145
146 return (size_info);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_rs_get_resource_length
152 *
153 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
154 *
155 * RETURN: Byte Length
156 *
157 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
158 * definition, this does not include the size of the descriptor
159 * header or the length field itself.
160 *
161 ******************************************************************************/
162
163u16 acpi_rs_get_resource_length(union aml_resource * aml)
164{
165 u16 resource_length;
166
167 ACPI_FUNCTION_ENTRY();
168
169 /* Determine if this is a small or large resource */
170
171 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
172 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
173
174 ACPI_MOVE_16_TO_16(&resource_length,
175 &aml->large_header.resource_length);
176
177 } else {
178 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
179
180 resource_length = (u16) (aml->small_header.descriptor_type &
181 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
182 }
183
184 return (resource_length);
185}
186
187/*******************************************************************************
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
212 ACPI_MOVE_16_TO_32(&descriptor_length,
213 &aml->large_header.resource_length);
214 descriptor_length += sizeof(struct aml_resource_large_header);
215
216 } else {
217 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
218
219 descriptor_length = (u32) (aml->small_header.descriptor_type &
220 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
221 descriptor_length += sizeof(struct aml_resource_small_header);
222 }
223
224 return (descriptor_length);
225}
226
227/*******************************************************************************
228 *
229 * FUNCTION: acpi_rs_set_resource_header
230 *
231 * PARAMETERS: descriptor_type - Byte to be inserted as the type
232 * total_length - Length of the AML descriptor, including
233 * the header and length fields.
234 * Aml - Pointer to the raw AML descriptor
235 *
236 * RETURN: None
237 *
238 * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
239 * resource descriptor, both Large and Small descriptors are
240 * supported automatically
241 *
242 ******************************************************************************/
243
244void
245acpi_rs_set_resource_header(u8 descriptor_type,
246 acpi_size total_length, union aml_resource *aml)
247{
248 u16 resource_length;
249
250 ACPI_FUNCTION_ENTRY();
251
252 /* Set the descriptor type */
253
254 aml->small_header.descriptor_type = descriptor_type;
255
256 /* Determine if this is a small or large resource */
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 /* Determine if this is a small or large resource */
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}
312
313/*******************************************************************************
314 *
315 * FUNCTION: acpi_rs_strcpy
316 *
317 * PARAMETERS: Destination - Pointer to the destination string
318 * Source - Pointer to the source string
319 *
320 * RETURN: String length, including NULL terminator
321 *
322 * DESCRIPTION: Local string copy that returns the string length, saving a
323 * strcpy followed by a strlen.
324 *
325 ******************************************************************************/
326
327static u16 acpi_rs_strcpy(char *destination, char *source)
328{
329 u16 i;
330
331 ACPI_FUNCTION_ENTRY();
332
333 for (i = 0; source[i]; i++) {
334 destination[i] = source[i];
335 }
336
337 destination[i] = 0;
338
339 /* Return string length including the NULL terminator */
340
341 return ((u16) (i + 1));
342}
343
344/*******************************************************************************
345 *
346 * FUNCTION: acpi_rs_get_resource_source
347 *
348 * PARAMETERS: resource_length - Length field of the descriptor
349 * minimum_length - Minimum length of the descriptor (minus
350 * any optional fields)
351 * resource_source - Where the resource_source is returned
352 * Aml - Pointer to the raw AML descriptor
353 * string_ptr - (optional) where to store the actual
354 * resource_source string
355 *
356 * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit
357 *
358 * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
359 * to an internal resource descriptor
360 *
361 ******************************************************************************/
362
363u16
364acpi_rs_get_resource_source(u16 resource_length,
365 acpi_size minimum_length,
366 struct acpi_resource_source * resource_source,
367 union aml_resource * aml, char *string_ptr)
368{
369 acpi_size total_length;
370 u8 *aml_resource_source;
371
372 ACPI_FUNCTION_ENTRY();
373
374 total_length =
375 resource_length + sizeof(struct aml_resource_large_header);
376 aml_resource_source = ((u8 *) aml) + minimum_length;
377
378 /*
379 * resource_source is present if the length of the descriptor is longer than
380 * the minimum length.
381 *
382 * Note: Some resource descriptors will have an additional null, so
383 * we add 1 to the minimum length.
384 */
385 if (total_length > (minimum_length + 1)) {
386 /* Get the resource_source_index */
387
388 resource_source->index = aml_resource_source[0];
389
390 resource_source->string_ptr = string_ptr;
391 if (!string_ptr) {
392 /*
393 * String destination pointer is not specified; Set the String
394 * pointer to the end of the current resource_source structure.
395 */
396 resource_source->string_ptr = (char *)
397 ((u8 *) resource_source) +
398 sizeof(struct acpi_resource_source);
399 }
400
401 /* Copy the resource_source string to the destination */
402
403 resource_source->string_length =
404 acpi_rs_strcpy(resource_source->string_ptr,
405 (char *)&aml_resource_source[1]);
406
407 /*
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 {
416 /* resource_source is not present */
417
418 resource_source->index = 0;
419 resource_source->string_length = 0;
420 resource_source->string_ptr = NULL;
421 return (0);
422 }
423}
424
425/*******************************************************************************
426 *
427 * FUNCTION: acpi_rs_set_resource_source
428 *
429 * PARAMETERS: Aml - Pointer to the raw AML descriptor
430 * minimum_length - Minimum length of the descriptor (minus
431 * any optional fields)
432 * resource_source - Internal resource_source
433
434 *
435 * RETURN: Total length of the AML descriptor
436 *
437 * DESCRIPTION: Convert an optoinal resource_source from internal format to a
438 * raw AML resource descriptor
439 *
440 ******************************************************************************/
441
442acpi_size
443acpi_rs_set_resource_source(union aml_resource * aml,
444 acpi_size minimum_length,
445 struct acpi_resource_source * resource_source)
446{
447 u8 *aml_resource_source;
448 acpi_size descriptor_length;
449
450 ACPI_FUNCTION_ENTRY();
451
452 descriptor_length = minimum_length;
453
454 /* Non-zero string length indicates presence of a resource_source */
455
456 if (resource_source->string_length) {
457 /* Point to the end of the AML descriptor */
458
459 aml_resource_source = ((u8 *) aml) + minimum_length;
460
461 /* Copy the resource_source_index */
462
463 aml_resource_source[0] = (u8) resource_source->index;
464
465 /* Copy the resource_source string */
466
467 ACPI_STRCPY((char *)&aml_resource_source[1],
468 resource_source->string_ptr);
469
470 /*
471 * Add the length of the string (+ 1 for null terminator) to the
472 * final descriptor length
473 */
474 descriptor_length +=
475 ((acpi_size) resource_source->string_length + 1);
476 }
477
478 /* Return the new total length of the AML descriptor */
479
480 return (descriptor_length);
481}
482
483/*******************************************************************************
484 *
53 * FUNCTION: acpi_rs_get_prt_method_data 485 * FUNCTION: acpi_rs_get_prt_method_data
54 * 486 *
55 * PARAMETERS: Handle - a handle to the containing object 487 * PARAMETERS: Handle - a handle to the containing object
@@ -65,8 +497,9 @@ ACPI_MODULE_NAME("rsutils")
65 * and the contents of the callers buffer is undefined. 497 * and the contents of the callers buffer is undefined.
66 * 498 *
67 ******************************************************************************/ 499 ******************************************************************************/
500
68acpi_status 501acpi_status
69acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 502acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
70{ 503{
71 union acpi_operand_object *obj_desc; 504 union acpi_operand_object *obj_desc;
72 acpi_status status; 505 acpi_status status;
@@ -284,7 +717,7 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer)
284 * Convert the linked list into a byte stream 717 * Convert the linked list into a byte stream
285 */ 718 */
286 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 719 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
287 status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); 720 status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
288 if (ACPI_FAILURE(status)) { 721 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status); 722 return_ACPI_STATUS(status);
290 } 723 }
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index 1a87c4c7bd97..9d179beb17ae 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -59,9 +59,9 @@ ACPI_MODULE_NAME("rsxface")
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, attribute); \
61 ACPI_COPY_FIELD(out, in, granularity); \ 61 ACPI_COPY_FIELD(out, in, granularity); \
62 ACPI_COPY_FIELD(out, in, min_address_range); \ 62 ACPI_COPY_FIELD(out, in, minimum); \
63 ACPI_COPY_FIELD(out, in, max_address_range); \ 63 ACPI_COPY_FIELD(out, in, maximum); \
64 ACPI_COPY_FIELD(out, in, address_translation_offset); \ 64 ACPI_COPY_FIELD(out, in, translation_offset); \
65 ACPI_COPY_FIELD(out, in, address_length); \ 65 ACPI_COPY_FIELD(out, in, address_length); \
66 ACPI_COPY_FIELD(out, in, resource_source); 66 ACPI_COPY_FIELD(out, in, resource_source);
67/******************************************************************************* 67/*******************************************************************************
@@ -269,7 +269,7 @@ acpi_walk_resources(acpi_handle device_handle,
269 /* Walk the resource list */ 269 /* Walk the resource list */
270 270
271 for (;;) { 271 for (;;) {
272 if (!resource || resource->type == ACPI_RSTYPE_END_TAG) { 272 if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
273 break; 273 break;
274 } 274 }
275 275
@@ -382,19 +382,19 @@ acpi_resource_to_address64(struct acpi_resource *resource,
382 struct acpi_resource_address32 *address32; 382 struct acpi_resource_address32 *address32;
383 383
384 switch (resource->type) { 384 switch (resource->type) {
385 case ACPI_RSTYPE_ADDRESS16: 385 case ACPI_RESOURCE_TYPE_ADDRESS16:
386 386
387 address16 = (struct acpi_resource_address16 *)&resource->data; 387 address16 = (struct acpi_resource_address16 *)&resource->data;
388 ACPI_COPY_ADDRESS(out, address16); 388 ACPI_COPY_ADDRESS(out, address16);
389 break; 389 break;
390 390
391 case ACPI_RSTYPE_ADDRESS32: 391 case ACPI_RESOURCE_TYPE_ADDRESS32:
392 392
393 address32 = (struct acpi_resource_address32 *)&resource->data; 393 address32 = (struct acpi_resource_address32 *)&resource->data;
394 ACPI_COPY_ADDRESS(out, address32); 394 ACPI_COPY_ADDRESS(out, address32);
395 break; 395 break;
396 396
397 case ACPI_RSTYPE_ADDRESS64: 397 case ACPI_RESOURCE_TYPE_ADDRESS64:
398 398
399 /* Simple copy for 64 bit source */ 399 /* Simple copy for 64 bit source */
400 400
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index ad0252c2f7db..3cee0cee4cc2 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -251,7 +251,7 @@ acpi_status acpi_tb_get_table_rsdt(void)
251 } 251 }
252 252
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
257 257
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 3b8a7e063e8a..b01a4b2ae7da 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -251,7 +251,7 @@ acpi_get_firmware_table(acpi_string signature,
251 251
252 acpi_tb_get_rsdt_address(&address); 252 acpi_tb_get_rsdt_address(&address);
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
257 257
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 068450b36475..dc7f24b3a1c0 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -304,7 +304,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
304 304
305 if (!size) { 305 if (!size) {
306 _ACPI_REPORT_ERROR(module, line, component, 306 _ACPI_REPORT_ERROR(module, line, component,
307 ("ut_allocate: Attempt to allocate zero bytes\n")); 307 ("ut_allocate: Attempt to allocate zero bytes, allocating 1 byte\n"));
308 size = 1; 308 size = 1;
309 } 309 }
310 310
@@ -347,8 +347,8 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
347 347
348 if (!size) { 348 if (!size) {
349 _ACPI_REPORT_ERROR(module, line, component, 349 _ACPI_REPORT_ERROR(module, line, component,
350 ("ut_callocate: Attempt to allocate zero bytes\n")); 350 ("ut_callocate: Attempt to allocate zero bytes, allocating 1 byte\n"));
351 return_PTR(NULL); 351 size = 1;
352 } 352 }
353 353
354 allocation = acpi_os_allocate(size); 354 allocation = acpi_os_allocate(size);
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 399e64b51886..7f72839841ca 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -825,6 +825,9 @@ void acpi_ut_init_globals(void)
825 acpi_gbl_ps_find_count = 0; 825 acpi_gbl_ps_find_count = 0;
826 acpi_gbl_acpi_hardware_present = TRUE; 826 acpi_gbl_acpi_hardware_present = TRUE;
827 acpi_gbl_owner_id_mask = 0; 827 acpi_gbl_owner_id_mask = 0;
828 acpi_gbl_trace_method_name = 0;
829 acpi_gbl_trace_dbg_level = 0;
830 acpi_gbl_trace_dbg_layer = 0;
828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 831 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 832 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
830 833
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index aa1dcd851f89..b57afa7421e8 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -811,15 +811,15 @@ u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
811 811
812 while (buffer < end_buffer) { 812 while (buffer < end_buffer) {
813 buffer_byte = *buffer; 813 buffer_byte = *buffer;
814 if (buffer_byte & ACPI_RDESC_TYPE_LARGE) { 814 if (buffer_byte & ACPI_RESOURCE_NAME_LARGE) {
815 /* Large Descriptor - Length is next 2 bytes */ 815 /* Large Descriptor - Length is next 2 bytes */
816 816
817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); 817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3);
818 } else { 818 } else {
819 /* Small Descriptor. End Tag will be found here */ 819 /* Small Descriptor. End Tag will be found here */
820 820
821 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == 821 if ((buffer_byte & ACPI_RESOURCE_NAME_SMALL_MASK) ==
822 ACPI_RDESC_TYPE_END_TAG) { 822 ACPI_RESOURCE_NAME_END_TAG) {
823 /* Found the end tag descriptor, all done. */ 823 /* Found the end tag descriptor, all done. */
824 824
825 return (buffer); 825 return (buffer);
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 5172d4e1236c..66a2fee06eb9 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -927,9 +927,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
927 if (ACPI_SUCCESS(status)) { 927 if (ACPI_SUCCESS(status)) {
928 unsigned long size; 928 unsigned long size;
929 929
930 size = addr.max_address_range - addr.min_address_range + 1; 930 size = addr.maximum - addr.minimum + 1;
931 hdp->hd_phys_address = addr.min_address_range; 931 hdp->hd_phys_address = addr.minimum;
932 hdp->hd_address = ioremap(addr.min_address_range, size); 932 hdp->hd_address = ioremap(addr.minimum, size);
933 933
934 if (hpet_is_known(hdp)) { 934 if (hpet_is_known(hdp)) {
935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 935 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
@@ -937,15 +937,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
937 iounmap(hdp->hd_address); 937 iounmap(hdp->hd_address);
938 return -EBUSY; 938 return -EBUSY;
939 } 939 }
940 } else if (res->type == ACPI_RSTYPE_FIXED_MEM32) { 940 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
941 struct acpi_resource_fixed_mem32 *fixmem32; 941 struct acpi_resource_fixed_memory32 *fixmem32;
942 942
943 fixmem32 = &res->data.fixed_memory32; 943 fixmem32 = &res->data.fixed_memory32;
944 if (!fixmem32) 944 if (!fixmem32)
945 return -EINVAL; 945 return -EINVAL;
946 946
947 hdp->hd_phys_address = fixmem32->range_base_address; 947 hdp->hd_phys_address = fixmem32->address;
948 hdp->hd_address = ioremap(fixmem32->range_base_address, 948 hdp->hd_address = ioremap(fixmem32->address,
949 HPET_RANGE_SIZE); 949 HPET_RANGE_SIZE);
950 950
951 if (hpet_is_known(hdp)) { 951 if (hpet_is_known(hdp)) {
@@ -954,20 +954,20 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
954 iounmap(hdp->hd_address); 954 iounmap(hdp->hd_address);
955 return -EBUSY; 955 return -EBUSY;
956 } 956 }
957 } else if (res->type == ACPI_RSTYPE_EXT_IRQ) { 957 } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
958 struct acpi_resource_ext_irq *irqp; 958 struct acpi_resource_extended_irq *irqp;
959 int i; 959 int i;
960 960
961 irqp = &res->data.extended_irq; 961 irqp = &res->data.extended_irq;
962 962
963 if (irqp->number_of_interrupts > 0) { 963 if (irqp->interrupt_count > 0) {
964 hdp->hd_nirqs = irqp->number_of_interrupts; 964 hdp->hd_nirqs = irqp->interrupt_count;
965 965
966 for (i = 0; i < hdp->hd_nirqs; i++) { 966 for (i = 0; i < hdp->hd_nirqs; i++) {
967 int rc = 967 int rc =
968 acpi_register_gsi(irqp->interrupts[i], 968 acpi_register_gsi(irqp->interrupts[i],
969 irqp->edge_level, 969 irqp->triggering,
970 irqp->active_high_low); 970 irqp->polarity);
971 if (rc < 0) 971 if (rc < 0)
972 return AE_ERROR; 972 return AE_ERROR;
973 hdp->hd_irq[i] = rc; 973 hdp->hd_irq[i] = rc;
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 15ec05f69ddd..f4adebde6155 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr> 4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com> 5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any 9 * Free Software Foundation; either version 2, or (at your option) any
@@ -32,17 +32,17 @@
32/* 32/*
33 * Allocated Resources 33 * Allocated Resources
34 */ 34 */
35static int irq_flags(int edge_level, int active_high_low) 35static int irq_flags(int triggering, int polarity)
36{ 36{
37 int flag; 37 int flag;
38 if (edge_level == ACPI_LEVEL_SENSITIVE) { 38 if (triggering == ACPI_LEVEL_SENSITIVE) {
39 if(active_high_low == ACPI_ACTIVE_LOW) 39 if(polarity == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 }
44 else { 44 else {
45 if(active_high_low == ACPI_ACTIVE_LOW) 45 if(polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 46 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 47 else
48 flag = IORESOURCE_IRQ_HIGHEDGE; 48 flag = IORESOURCE_IRQ_HIGHEDGE;
@@ -50,31 +50,31 @@ static int irq_flags(int edge_level, int active_high_low)
50 return flag; 50 return flag;
51} 51}
52 52
53static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) 53static void decode_irq_flags(int flag, int *triggering, int *polarity)
54{ 54{
55 switch (flag) { 55 switch (flag) {
56 case IORESOURCE_IRQ_LOWLEVEL: 56 case IORESOURCE_IRQ_LOWLEVEL:
57 *edge_level = ACPI_LEVEL_SENSITIVE; 57 *triggering = ACPI_LEVEL_SENSITIVE;
58 *active_high_low = ACPI_ACTIVE_LOW; 58 *polarity = ACPI_ACTIVE_LOW;
59 break; 59 break;
60 case IORESOURCE_IRQ_HIGHLEVEL: 60 case IORESOURCE_IRQ_HIGHLEVEL:
61 *edge_level = ACPI_LEVEL_SENSITIVE; 61 *triggering = ACPI_LEVEL_SENSITIVE;
62 *active_high_low = ACPI_ACTIVE_HIGH; 62 *polarity = ACPI_ACTIVE_HIGH;
63 break; 63 break;
64 case IORESOURCE_IRQ_LOWEDGE: 64 case IORESOURCE_IRQ_LOWEDGE:
65 *edge_level = ACPI_EDGE_SENSITIVE; 65 *triggering = ACPI_EDGE_SENSITIVE;
66 *active_high_low = ACPI_ACTIVE_LOW; 66 *polarity = ACPI_ACTIVE_LOW;
67 break; 67 break;
68 case IORESOURCE_IRQ_HIGHEDGE: 68 case IORESOURCE_IRQ_HIGHEDGE:
69 *edge_level = ACPI_EDGE_SENSITIVE; 69 *triggering = ACPI_EDGE_SENSITIVE;
70 *active_high_low = ACPI_ACTIVE_HIGH; 70 *polarity = ACPI_ACTIVE_HIGH;
71 break; 71 break;
72 } 72 }
73} 73}
74 74
75static void 75static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, 76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
77 int edge_level, int active_high_low) 77 int triggering, int polarity)
78{ 78{
79 int i = 0; 79 int i = 0;
80 int irq; 80 int irq;
@@ -89,7 +89,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
89 return; 89 return;
90 90
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 irq = acpi_register_gsi(gsi, edge_level, active_high_low); 92 irq = acpi_register_gsi(gsi, triggering, polarity);
93 if (irq < 0) { 93 if (irq < 0) {
94 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 94 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
95 return; 95 return;
@@ -164,73 +164,73 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
164 int i; 164 int i;
165 165
166 switch (res->type) { 166 switch (res->type) {
167 case ACPI_RSTYPE_IRQ: 167 case ACPI_RESOURCE_TYPE_IRQ:
168 /* 168 /*
169 * Per spec, only one interrupt per descriptor is allowed in 169 * Per spec, only one interrupt per descriptor is allowed in
170 * _CRS, but some firmware violates this, so parse them all. 170 * _CRS, but some firmware violates this, so parse them all.
171 */ 171 */
172 for (i = 0; i < res->data.irq.number_of_interrupts; i++) { 172 for (i = 0; i < res->data.irq.interrupt_count; i++) {
173 pnpacpi_parse_allocated_irqresource(res_table, 173 pnpacpi_parse_allocated_irqresource(res_table,
174 res->data.irq.interrupts[i], 174 res->data.irq.interrupts[i],
175 res->data.irq.edge_level, 175 res->data.irq.triggering,
176 res->data.irq.active_high_low); 176 res->data.irq.polarity);
177 } 177 }
178 break; 178 break;
179 179
180 case ACPI_RSTYPE_EXT_IRQ: 180 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
181 for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { 181 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
182 pnpacpi_parse_allocated_irqresource(res_table, 182 pnpacpi_parse_allocated_irqresource(res_table,
183 res->data.extended_irq.interrupts[i], 183 res->data.extended_irq.interrupts[i],
184 res->data.extended_irq.edge_level, 184 res->data.extended_irq.triggering,
185 res->data.extended_irq.active_high_low); 185 res->data.extended_irq.polarity);
186 } 186 }
187 break; 187 break;
188 case ACPI_RSTYPE_DMA: 188 case ACPI_RESOURCE_TYPE_DMA:
189 if (res->data.dma.number_of_channels > 0) 189 if (res->data.dma.channel_count > 0)
190 pnpacpi_parse_allocated_dmaresource(res_table, 190 pnpacpi_parse_allocated_dmaresource(res_table,
191 res->data.dma.channels[0]); 191 res->data.dma.channels[0]);
192 break; 192 break;
193 case ACPI_RSTYPE_IO: 193 case ACPI_RESOURCE_TYPE_IO:
194 pnpacpi_parse_allocated_ioresource(res_table, 194 pnpacpi_parse_allocated_ioresource(res_table,
195 res->data.io.min_base_address, 195 res->data.io.minimum,
196 res->data.io.range_length); 196 res->data.io.address_length);
197 break; 197 break;
198 case ACPI_RSTYPE_FIXED_IO: 198 case ACPI_RESOURCE_TYPE_FIXED_IO:
199 pnpacpi_parse_allocated_ioresource(res_table, 199 pnpacpi_parse_allocated_ioresource(res_table,
200 res->data.fixed_io.base_address, 200 res->data.fixed_io.address,
201 res->data.fixed_io.range_length); 201 res->data.fixed_io.address_length);
202 break; 202 break;
203 case ACPI_RSTYPE_MEM24: 203 case ACPI_RESOURCE_TYPE_MEMORY24:
204 pnpacpi_parse_allocated_memresource(res_table, 204 pnpacpi_parse_allocated_memresource(res_table,
205 res->data.memory24.min_base_address, 205 res->data.memory24.minimum,
206 res->data.memory24.range_length); 206 res->data.memory24.address_length);
207 break; 207 break;
208 case ACPI_RSTYPE_MEM32: 208 case ACPI_RESOURCE_TYPE_MEMORY32:
209 pnpacpi_parse_allocated_memresource(res_table, 209 pnpacpi_parse_allocated_memresource(res_table,
210 res->data.memory32.min_base_address, 210 res->data.memory32.minimum,
211 res->data.memory32.range_length); 211 res->data.memory32.address_length);
212 break; 212 break;
213 case ACPI_RSTYPE_FIXED_MEM32: 213 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
214 pnpacpi_parse_allocated_memresource(res_table, 214 pnpacpi_parse_allocated_memresource(res_table,
215 res->data.fixed_memory32.range_base_address, 215 res->data.fixed_memory32.address,
216 res->data.fixed_memory32.range_length); 216 res->data.fixed_memory32.address_length);
217 break; 217 break;
218 case ACPI_RSTYPE_ADDRESS16: 218 case ACPI_RESOURCE_TYPE_ADDRESS16:
219 pnpacpi_parse_allocated_memresource(res_table, 219 pnpacpi_parse_allocated_memresource(res_table,
220 res->data.address16.min_address_range, 220 res->data.address16.minimum,
221 res->data.address16.address_length); 221 res->data.address16.address_length);
222 break; 222 break;
223 case ACPI_RSTYPE_ADDRESS32: 223 case ACPI_RESOURCE_TYPE_ADDRESS32:
224 pnpacpi_parse_allocated_memresource(res_table, 224 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address32.min_address_range, 225 res->data.address32.minimum,
226 res->data.address32.address_length); 226 res->data.address32.address_length);
227 break; 227 break;
228 case ACPI_RSTYPE_ADDRESS64: 228 case ACPI_RESOURCE_TYPE_ADDRESS64:
229 pnpacpi_parse_allocated_memresource(res_table, 229 pnpacpi_parse_allocated_memresource(res_table,
230 res->data.address64.min_address_range, 230 res->data.address64.minimum,
231 res->data.address64.address_length); 231 res->data.address64.address_length);
232 break; 232 break;
233 case ACPI_RSTYPE_VENDOR: 233 case ACPI_RESOURCE_TYPE_VENDOR:
234 break; 234 break;
235 default: 235 default:
236 pnp_warn("PnPACPI: unknown resource type %d", res->type); 236 pnp_warn("PnPACPI: unknown resource type %d", res->type);
@@ -253,13 +253,13 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
253 int i; 253 int i;
254 struct pnp_dma * dma; 254 struct pnp_dma * dma;
255 255
256 if (p->number_of_channels == 0) 256 if (p->channel_count == 0)
257 return; 257 return;
258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
259 if (!dma) 259 if (!dma)
260 return; 260 return;
261 261
262 for(i = 0; i < p->number_of_channels; i++) 262 for(i = 0; i < p->channel_count; i++)
263 dma->map |= 1 << p->channels[i]; 263 dma->map |= 1 << p->channels[i];
264 dma->flags = 0; 264 dma->flags = 0;
265 if (p->bus_master) 265 if (p->bus_master)
@@ -309,37 +309,37 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
309 int i; 309 int i;
310 struct pnp_irq * irq; 310 struct pnp_irq * irq;
311 311
312 if (p->number_of_interrupts == 0) 312 if (p->interrupt_count == 0)
313 return; 313 return;
314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
315 if (!irq) 315 if (!irq)
316 return; 316 return;
317 317
318 for(i = 0; i < p->number_of_interrupts; i++) 318 for(i = 0; i < p->interrupt_count; i++)
319 if (p->interrupts[i]) 319 if (p->interrupts[i])
320 __set_bit(p->interrupts[i], irq->map); 320 __set_bit(p->interrupts[i], irq->map);
321 irq->flags = irq_flags(p->edge_level, p->active_high_low); 321 irq->flags = irq_flags(p->triggering, p->polarity);
322 322
323 pnp_register_irq_resource(option, irq); 323 pnp_register_irq_resource(option, irq);
324 return; 324 return;
325} 325}
326 326
327static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 327static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
328 struct acpi_resource_ext_irq *p) 328 struct acpi_resource_extended_irq *p)
329{ 329{
330 int i; 330 int i;
331 struct pnp_irq * irq; 331 struct pnp_irq * irq;
332 332
333 if (p->number_of_interrupts == 0) 333 if (p->interrupt_count == 0)
334 return; 334 return;
335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
336 if (!irq) 336 if (!irq)
337 return; 337 return;
338 338
339 for(i = 0; i < p->number_of_interrupts; i++) 339 for(i = 0; i < p->interrupt_count; i++)
340 if (p->interrupts[i]) 340 if (p->interrupts[i])
341 __set_bit(p->interrupts[i], irq->map); 341 __set_bit(p->interrupts[i], irq->map);
342 irq->flags = irq_flags(p->edge_level, p->active_high_low); 342 irq->flags = irq_flags(p->triggering, p->polarity);
343 343
344 pnp_register_irq_resource(option, irq); 344 pnp_register_irq_resource(option, irq);
345 return; 345 return;
@@ -351,16 +351,16 @@ pnpacpi_parse_port_option(struct pnp_option *option,
351{ 351{
352 struct pnp_port * port; 352 struct pnp_port * port;
353 353
354 if (io->range_length == 0) 354 if (io->address_length == 0)
355 return; 355 return;
356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
357 if (!port) 357 if (!port)
358 return; 358 return;
359 port->min = io->min_base_address; 359 port->min = io->minimum;
360 port->max = io->max_base_address; 360 port->max = io->maximum;
361 port->align = io->alignment; 361 port->align = io->alignment;
362 port->size = io->range_length; 362 port->size = io->address_length;
363 port->flags = ACPI_DECODE_16 == io->io_decode ? 363 port->flags = ACPI_DECODE_16 == io->io_decode ?
364 PNP_PORT_FLAG_16BITADDR : 0; 364 PNP_PORT_FLAG_16BITADDR : 0;
365 pnp_register_port_resource(option,port); 365 pnp_register_port_resource(option,port);
366 return; 366 return;
@@ -372,13 +372,13 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
372{ 372{
373 struct pnp_port * port; 373 struct pnp_port * port;
374 374
375 if (io->range_length == 0) 375 if (io->address_length == 0)
376 return; 376 return;
377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
378 if (!port) 378 if (!port)
379 return; 379 return;
380 port->min = port->max = io->base_address; 380 port->min = port->max = io->address;
381 port->size = io->range_length; 381 port->size = io->address_length;
382 port->align = 0; 382 port->align = 0;
383 port->flags = PNP_PORT_FLAG_FIXED; 383 port->flags = PNP_PORT_FLAG_FIXED;
384 pnp_register_port_resource(option,port); 384 pnp_register_port_resource(option,port);
@@ -387,19 +387,19 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
387 387
388static void 388static void
389pnpacpi_parse_mem24_option(struct pnp_option *option, 389pnpacpi_parse_mem24_option(struct pnp_option *option,
390 struct acpi_resource_mem24 *p) 390 struct acpi_resource_memory24 *p)
391{ 391{
392 struct pnp_mem * mem; 392 struct pnp_mem * mem;
393 393
394 if (p->range_length == 0) 394 if (p->address_length == 0)
395 return; 395 return;
396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
397 if (!mem) 397 if (!mem)
398 return; 398 return;
399 mem->min = p->min_base_address; 399 mem->min = p->minimum;
400 mem->max = p->max_base_address; 400 mem->max = p->maximum;
401 mem->align = p->alignment; 401 mem->align = p->alignment;
402 mem->size = p->range_length; 402 mem->size = p->address_length;
403 403
404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
405 IORESOURCE_MEM_WRITEABLE : 0; 405 IORESOURCE_MEM_WRITEABLE : 0;
@@ -410,19 +410,19 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
410 410
411static void 411static void
412pnpacpi_parse_mem32_option(struct pnp_option *option, 412pnpacpi_parse_mem32_option(struct pnp_option *option,
413 struct acpi_resource_mem32 *p) 413 struct acpi_resource_memory32 *p)
414{ 414{
415 struct pnp_mem * mem; 415 struct pnp_mem * mem;
416 416
417 if (p->range_length == 0) 417 if (p->address_length == 0)
418 return; 418 return;
419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
420 if (!mem) 420 if (!mem)
421 return; 421 return;
422 mem->min = p->min_base_address; 422 mem->min = p->minimum;
423 mem->max = p->max_base_address; 423 mem->max = p->maximum;
424 mem->align = p->alignment; 424 mem->align = p->alignment;
425 mem->size = p->range_length; 425 mem->size = p->address_length;
426 426
427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
428 IORESOURCE_MEM_WRITEABLE : 0; 428 IORESOURCE_MEM_WRITEABLE : 0;
@@ -433,17 +433,17 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
433 433
434static void 434static void
435pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 435pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
436 struct acpi_resource_fixed_mem32 *p) 436 struct acpi_resource_fixed_memory32 *p)
437{ 437{
438 struct pnp_mem * mem; 438 struct pnp_mem * mem;
439 439
440 if (p->range_length == 0) 440 if (p->address_length == 0)
441 return; 441 return;
442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
443 if (!mem) 443 if (!mem)
444 return; 444 return;
445 mem->min = mem->max = p->range_base_address; 445 mem->min = mem->max = p->address;
446 mem->size = p->range_length; 446 mem->size = p->address_length;
447 mem->align = 0; 447 mem->align = 0;
448 448
449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
@@ -459,7 +459,7 @@ struct acpipnp_parse_option_s {
459 struct pnp_dev *dev; 459 struct pnp_dev *dev;
460}; 460};
461 461
462static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 462static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
463 void *data) 463 void *data)
464{ 464{
465 int priority = 0; 465 int priority = 0;
@@ -468,34 +468,34 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
468 struct pnp_option *option = parse_data->option; 468 struct pnp_option *option = parse_data->option;
469 469
470 switch (res->type) { 470 switch (res->type) {
471 case ACPI_RSTYPE_IRQ: 471 case ACPI_RESOURCE_TYPE_IRQ:
472 pnpacpi_parse_irq_option(option, &res->data.irq); 472 pnpacpi_parse_irq_option(option, &res->data.irq);
473 break; 473 break;
474 case ACPI_RSTYPE_EXT_IRQ: 474 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
475 pnpacpi_parse_ext_irq_option(option, 475 pnpacpi_parse_ext_irq_option(option,
476 &res->data.extended_irq); 476 &res->data.extended_irq);
477 break; 477 break;
478 case ACPI_RSTYPE_DMA: 478 case ACPI_RESOURCE_TYPE_DMA:
479 pnpacpi_parse_dma_option(option, &res->data.dma); 479 pnpacpi_parse_dma_option(option, &res->data.dma);
480 break; 480 break;
481 case ACPI_RSTYPE_IO: 481 case ACPI_RESOURCE_TYPE_IO:
482 pnpacpi_parse_port_option(option, &res->data.io); 482 pnpacpi_parse_port_option(option, &res->data.io);
483 break; 483 break;
484 case ACPI_RSTYPE_FIXED_IO: 484 case ACPI_RESOURCE_TYPE_FIXED_IO:
485 pnpacpi_parse_fixed_port_option(option, 485 pnpacpi_parse_fixed_port_option(option,
486 &res->data.fixed_io); 486 &res->data.fixed_io);
487 break; 487 break;
488 case ACPI_RSTYPE_MEM24: 488 case ACPI_RESOURCE_TYPE_MEMORY24:
489 pnpacpi_parse_mem24_option(option, &res->data.memory24); 489 pnpacpi_parse_mem24_option(option, &res->data.memory24);
490 break; 490 break;
491 case ACPI_RSTYPE_MEM32: 491 case ACPI_RESOURCE_TYPE_MEMORY32:
492 pnpacpi_parse_mem32_option(option, &res->data.memory32); 492 pnpacpi_parse_mem32_option(option, &res->data.memory32);
493 break; 493 break;
494 case ACPI_RSTYPE_FIXED_MEM32: 494 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
495 pnpacpi_parse_fixed_mem32_option(option, 495 pnpacpi_parse_fixed_mem32_option(option,
496 &res->data.fixed_memory32); 496 &res->data.fixed_memory32);
497 break; 497 break;
498 case ACPI_RSTYPE_START_DPF: 498 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
499 switch (res->data.start_dpf.compatibility_priority) { 499 switch (res->data.start_dpf.compatibility_priority) {
500 case ACPI_GOOD_CONFIGURATION: 500 case ACPI_GOOD_CONFIGURATION:
501 priority = PNP_RES_PRIORITY_PREFERRED; 501 priority = PNP_RES_PRIORITY_PREFERRED;
@@ -518,7 +518,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
518 return AE_ERROR; 518 return AE_ERROR;
519 parse_data->option = option; 519 parse_data->option = option;
520 break; 520 break;
521 case ACPI_RSTYPE_END_DPF: 521 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
522 /*only one EndDependentFn is allowed*/ 522 /*only one EndDependentFn is allowed*/
523 if (!parse_data->option_independent) { 523 if (!parse_data->option_independent) {
524 pnp_warn("PnPACPI: more than one EndDependentFn"); 524 pnp_warn("PnPACPI: more than one EndDependentFn");
@@ -535,7 +535,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
535 return AE_OK; 535 return AE_OK;
536} 536}
537 537
538acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 538acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
539 struct pnp_dev *dev) 539 struct pnp_dev *dev)
540{ 540{
541 acpi_status status; 541 acpi_status status;
@@ -546,7 +546,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
546 return AE_ERROR; 546 return AE_ERROR;
547 parse_data.option_independent = parse_data.option; 547 parse_data.option_independent = parse_data.option;
548 parse_data.dev = dev; 548 parse_data.dev = dev;
549 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 549 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
550 pnpacpi_option_resource, &parse_data); 550 pnpacpi_option_resource, &parse_data);
551 551
552 return status; 552 return status;
@@ -560,18 +560,18 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
560{ 560{
561 int *res_cnt = (int *)data; 561 int *res_cnt = (int *)data;
562 switch (res->type) { 562 switch (res->type) {
563 case ACPI_RSTYPE_IRQ: 563 case ACPI_RESOURCE_TYPE_IRQ:
564 case ACPI_RSTYPE_EXT_IRQ: 564 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
565 case ACPI_RSTYPE_DMA: 565 case ACPI_RESOURCE_TYPE_DMA:
566 case ACPI_RSTYPE_IO: 566 case ACPI_RESOURCE_TYPE_IO:
567 case ACPI_RSTYPE_FIXED_IO: 567 case ACPI_RESOURCE_TYPE_FIXED_IO:
568 case ACPI_RSTYPE_MEM24: 568 case ACPI_RESOURCE_TYPE_MEMORY24:
569 case ACPI_RSTYPE_MEM32: 569 case ACPI_RESOURCE_TYPE_MEMORY32:
570 case ACPI_RSTYPE_FIXED_MEM32: 570 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
571#if 0 571#if 0
572 case ACPI_RSTYPE_ADDRESS16: 572 case ACPI_RESOURCE_TYPE_ADDRESS16:
573 case ACPI_RSTYPE_ADDRESS32: 573 case ACPI_RESOURCE_TYPE_ADDRESS32:
574 case ACPI_RSTYPE_ADDRESS64: 574 case ACPI_RESOURCE_TYPE_ADDRESS64:
575#endif 575#endif
576 (*res_cnt) ++; 576 (*res_cnt) ++;
577 default: 577 default:
@@ -585,18 +585,18 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
585{ 585{
586 struct acpi_resource **resource = (struct acpi_resource **)data; 586 struct acpi_resource **resource = (struct acpi_resource **)data;
587 switch (res->type) { 587 switch (res->type) {
588 case ACPI_RSTYPE_IRQ: 588 case ACPI_RESOURCE_TYPE_IRQ:
589 case ACPI_RSTYPE_EXT_IRQ: 589 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
590 case ACPI_RSTYPE_DMA: 590 case ACPI_RESOURCE_TYPE_DMA:
591 case ACPI_RSTYPE_IO: 591 case ACPI_RESOURCE_TYPE_IO:
592 case ACPI_RSTYPE_FIXED_IO: 592 case ACPI_RESOURCE_TYPE_FIXED_IO:
593 case ACPI_RSTYPE_MEM24: 593 case ACPI_RESOURCE_TYPE_MEMORY24:
594 case ACPI_RSTYPE_MEM32: 594 case ACPI_RESOURCE_TYPE_MEMORY32:
595 case ACPI_RSTYPE_FIXED_MEM32: 595 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
596#if 0 596#if 0
597 case ACPI_RSTYPE_ADDRESS16: 597 case ACPI_RESOURCE_TYPE_ADDRESS16:
598 case ACPI_RSTYPE_ADDRESS32: 598 case ACPI_RESOURCE_TYPE_ADDRESS32:
599 case ACPI_RSTYPE_ADDRESS64: 599 case ACPI_RESOURCE_TYPE_ADDRESS64:
600#endif 600#endif
601 (*resource)->type = res->type; 601 (*resource)->type = res->type;
602 (*resource)++; 602 (*resource)++;
@@ -607,14 +607,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
607 return AE_OK; 607 return AE_OK;
608} 608}
609 609
610int pnpacpi_build_resource_template(acpi_handle handle, 610int pnpacpi_build_resource_template(acpi_handle handle,
611 struct acpi_buffer *buffer) 611 struct acpi_buffer *buffer)
612{ 612{
613 struct acpi_resource *resource; 613 struct acpi_resource *resource;
614 int res_cnt = 0; 614 int res_cnt = 0;
615 acpi_status status; 615 acpi_status status;
616 616
617 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 617 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
618 pnpacpi_count_resources, &res_cnt); 618 pnpacpi_count_resources, &res_cnt);
619 if (ACPI_FAILURE(status)) { 619 if (ACPI_FAILURE(status)) {
620 pnp_err("Evaluate _CRS failed"); 620 pnp_err("Evaluate _CRS failed");
@@ -628,7 +628,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
628 return -ENOMEM; 628 return -ENOMEM;
629 pnp_dbg("Res cnt %d", res_cnt); 629 pnp_dbg("Res cnt %d", res_cnt);
630 resource = (struct acpi_resource *)buffer->pointer; 630 resource = (struct acpi_resource *)buffer->pointer;
631 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 631 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
632 pnpacpi_type_resources, &resource); 632 pnpacpi_type_resources, &resource);
633 if (ACPI_FAILURE(status)) { 633 if (ACPI_FAILURE(status)) {
634 kfree(buffer->pointer); 634 kfree(buffer->pointer);
@@ -636,54 +636,54 @@ int pnpacpi_build_resource_template(acpi_handle handle,
636 return -EINVAL; 636 return -EINVAL;
637 } 637 }
638 /* resource will pointer the end resource now */ 638 /* resource will pointer the end resource now */
639 resource->type = ACPI_RSTYPE_END_TAG; 639 resource->type = ACPI_RESOURCE_TYPE_END_TAG;
640 640
641 return 0; 641 return 0;
642} 642}
643 643
644static void pnpacpi_encode_irq(struct acpi_resource *resource, 644static void pnpacpi_encode_irq(struct acpi_resource *resource,
645 struct resource *p) 645 struct resource *p)
646{ 646{
647 int edge_level, active_high_low; 647 int triggering, polarity;
648 648
649 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 649 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
650 &active_high_low); 650 &polarity);
651 resource->type = ACPI_RSTYPE_IRQ; 651 resource->type = ACPI_RESOURCE_TYPE_IRQ;
652 resource->length = sizeof(struct acpi_resource); 652 resource->length = sizeof(struct acpi_resource);
653 resource->data.irq.edge_level = edge_level; 653 resource->data.irq.triggering = triggering;
654 resource->data.irq.active_high_low = active_high_low; 654 resource->data.irq.polarity = polarity;
655 if (edge_level == ACPI_EDGE_SENSITIVE) 655 if (triggering == ACPI_EDGE_SENSITIVE)
656 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 656 resource->data.irq.sharable = ACPI_EXCLUSIVE;
657 else 657 else
658 resource->data.irq.shared_exclusive = ACPI_SHARED; 658 resource->data.irq.sharable = ACPI_SHARED;
659 resource->data.irq.number_of_interrupts = 1; 659 resource->data.irq.interrupt_count = 1;
660 resource->data.irq.interrupts[0] = p->start; 660 resource->data.irq.interrupts[0] = p->start;
661} 661}
662 662
663static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 663static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
664 struct resource *p) 664 struct resource *p)
665{ 665{
666 int edge_level, active_high_low; 666 int triggering, polarity;
667 667
668 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 668 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
669 &active_high_low); 669 &polarity);
670 resource->type = ACPI_RSTYPE_EXT_IRQ; 670 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
671 resource->length = sizeof(struct acpi_resource); 671 resource->length = sizeof(struct acpi_resource);
672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
673 resource->data.extended_irq.edge_level = edge_level; 673 resource->data.extended_irq.triggering = triggering;
674 resource->data.extended_irq.active_high_low = active_high_low; 674 resource->data.extended_irq.polarity = polarity;
675 if (edge_level == ACPI_EDGE_SENSITIVE) 675 if (triggering == ACPI_EDGE_SENSITIVE)
676 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 676 resource->data.irq.sharable = ACPI_EXCLUSIVE;
677 else 677 else
678 resource->data.irq.shared_exclusive = ACPI_SHARED; 678 resource->data.irq.sharable = ACPI_SHARED;
679 resource->data.extended_irq.number_of_interrupts = 1; 679 resource->data.extended_irq.interrupt_count = 1;
680 resource->data.extended_irq.interrupts[0] = p->start; 680 resource->data.extended_irq.interrupts[0] = p->start;
681} 681}
682 682
683static void pnpacpi_encode_dma(struct acpi_resource *resource, 683static void pnpacpi_encode_dma(struct acpi_resource *resource,
684 struct resource *p) 684 struct resource *p)
685{ 685{
686 resource->type = ACPI_RSTYPE_DMA; 686 resource->type = ACPI_RESOURCE_TYPE_DMA;
687 resource->length = sizeof(struct acpi_resource); 687 resource->length = sizeof(struct acpi_resource);
688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
689 if (p->flags & IORESOURCE_DMA_COMPATIBLE) 689 if (p->flags & IORESOURCE_DMA_COMPATIBLE)
@@ -701,75 +701,75 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
701 else if (p->flags & IORESOURCE_DMA_16BIT) 701 else if (p->flags & IORESOURCE_DMA_16BIT)
702 resource->data.dma.transfer = ACPI_TRANSFER_16; 702 resource->data.dma.transfer = ACPI_TRANSFER_16;
703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER;
704 resource->data.dma.number_of_channels = 1; 704 resource->data.dma.channel_count = 1;
705 resource->data.dma.channels[0] = p->start; 705 resource->data.dma.channels[0] = p->start;
706} 706}
707 707
708static void pnpacpi_encode_io(struct acpi_resource *resource, 708static void pnpacpi_encode_io(struct acpi_resource *resource,
709 struct resource *p) 709 struct resource *p)
710{ 710{
711 resource->type = ACPI_RSTYPE_IO; 711 resource->type = ACPI_RESOURCE_TYPE_IO;
712 resource->length = sizeof(struct acpi_resource); 712 resource->length = sizeof(struct acpi_resource);
713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)?
715 ACPI_DECODE_16 : ACPI_DECODE_10; 715 ACPI_DECODE_16 : ACPI_DECODE_10;
716 resource->data.io.min_base_address = p->start; 716 resource->data.io.minimum = p->start;
717 resource->data.io.max_base_address = p->end; 717 resource->data.io.maximum = p->end;
718 resource->data.io.alignment = 0; /* Correct? */ 718 resource->data.io.alignment = 0; /* Correct? */
719 resource->data.io.range_length = p->end - p->start + 1; 719 resource->data.io.address_length = p->end - p->start + 1;
720} 720}
721 721
722static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 722static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
723 struct resource *p) 723 struct resource *p)
724{ 724{
725 resource->type = ACPI_RSTYPE_FIXED_IO; 725 resource->type = ACPI_RESOURCE_TYPE_FIXED_IO;
726 resource->length = sizeof(struct acpi_resource); 726 resource->length = sizeof(struct acpi_resource);
727 resource->data.fixed_io.base_address = p->start; 727 resource->data.fixed_io.address = p->start;
728 resource->data.fixed_io.range_length = p->end - p->start + 1; 728 resource->data.fixed_io.address_length = p->end - p->start + 1;
729} 729}
730 730
731static void pnpacpi_encode_mem24(struct acpi_resource *resource, 731static void pnpacpi_encode_mem24(struct acpi_resource *resource,
732 struct resource *p) 732 struct resource *p)
733{ 733{
734 resource->type = ACPI_RSTYPE_MEM24; 734 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
735 resource->length = sizeof(struct acpi_resource); 735 resource->length = sizeof(struct acpi_resource);
736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
737 resource->data.memory24.read_write_attribute = 737 resource->data.memory24.read_write_attribute =
738 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 738 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
740 resource->data.memory24.min_base_address = p->start; 740 resource->data.memory24.minimum = p->start;
741 resource->data.memory24.max_base_address = p->end; 741 resource->data.memory24.maximum = p->end;
742 resource->data.memory24.alignment = 0; 742 resource->data.memory24.alignment = 0;
743 resource->data.memory24.range_length = p->end - p->start + 1; 743 resource->data.memory24.address_length = p->end - p->start + 1;
744} 744}
745 745
746static void pnpacpi_encode_mem32(struct acpi_resource *resource, 746static void pnpacpi_encode_mem32(struct acpi_resource *resource,
747 struct resource *p) 747 struct resource *p)
748{ 748{
749 resource->type = ACPI_RSTYPE_MEM32; 749 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
750 resource->length = sizeof(struct acpi_resource); 750 resource->length = sizeof(struct acpi_resource);
751 resource->data.memory32.read_write_attribute = 751 resource->data.memory32.read_write_attribute =
752 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 752 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
754 resource->data.memory32.min_base_address = p->start; 754 resource->data.memory32.minimum = p->start;
755 resource->data.memory32.max_base_address = p->end; 755 resource->data.memory32.maximum = p->end;
756 resource->data.memory32.alignment = 0; 756 resource->data.memory32.alignment = 0;
757 resource->data.memory32.range_length = p->end - p->start + 1; 757 resource->data.memory32.address_length = p->end - p->start + 1;
758} 758}
759 759
760static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 760static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
761 struct resource *p) 761 struct resource *p)
762{ 762{
763 resource->type = ACPI_RSTYPE_FIXED_MEM32; 763 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
764 resource->length = sizeof(struct acpi_resource); 764 resource->length = sizeof(struct acpi_resource);
765 resource->data.fixed_memory32.read_write_attribute = 765 resource->data.fixed_memory32.read_write_attribute =
766 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 766 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
768 resource->data.fixed_memory32.range_base_address = p->start; 768 resource->data.fixed_memory32.address = p->start;
769 resource->data.fixed_memory32.range_length = p->end - p->start + 1; 769 resource->data.fixed_memory32.address_length = p->end - p->start + 1;
770} 770}
771 771
772int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 772int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
773 struct acpi_buffer *buffer) 773 struct acpi_buffer *buffer)
774{ 774{
775 int i = 0; 775 int i = 0;
@@ -781,50 +781,50 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
781 pnp_dbg("res cnt %d", res_cnt); 781 pnp_dbg("res cnt %d", res_cnt);
782 while (i < res_cnt) { 782 while (i < res_cnt) {
783 switch(resource->type) { 783 switch(resource->type) {
784 case ACPI_RSTYPE_IRQ: 784 case ACPI_RESOURCE_TYPE_IRQ:
785 pnp_dbg("Encode irq"); 785 pnp_dbg("Encode irq");
786 pnpacpi_encode_irq(resource, 786 pnpacpi_encode_irq(resource,
787 &res_table->irq_resource[irq]); 787 &res_table->irq_resource[irq]);
788 irq++; 788 irq++;
789 break; 789 break;
790 790
791 case ACPI_RSTYPE_EXT_IRQ: 791 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
792 pnp_dbg("Encode ext irq"); 792 pnp_dbg("Encode ext irq");
793 pnpacpi_encode_ext_irq(resource, 793 pnpacpi_encode_ext_irq(resource,
794 &res_table->irq_resource[irq]); 794 &res_table->irq_resource[irq]);
795 irq++; 795 irq++;
796 break; 796 break;
797 case ACPI_RSTYPE_DMA: 797 case ACPI_RESOURCE_TYPE_DMA:
798 pnp_dbg("Encode dma"); 798 pnp_dbg("Encode dma");
799 pnpacpi_encode_dma(resource, 799 pnpacpi_encode_dma(resource,
800 &res_table->dma_resource[dma]); 800 &res_table->dma_resource[dma]);
801 dma ++; 801 dma ++;
802 break; 802 break;
803 case ACPI_RSTYPE_IO: 803 case ACPI_RESOURCE_TYPE_IO:
804 pnp_dbg("Encode io"); 804 pnp_dbg("Encode io");
805 pnpacpi_encode_io(resource, 805 pnpacpi_encode_io(resource,
806 &res_table->port_resource[port]); 806 &res_table->port_resource[port]);
807 port ++; 807 port ++;
808 break; 808 break;
809 case ACPI_RSTYPE_FIXED_IO: 809 case ACPI_RESOURCE_TYPE_FIXED_IO:
810 pnp_dbg("Encode fixed io"); 810 pnp_dbg("Encode fixed io");
811 pnpacpi_encode_fixed_io(resource, 811 pnpacpi_encode_fixed_io(resource,
812 &res_table->port_resource[port]); 812 &res_table->port_resource[port]);
813 port ++; 813 port ++;
814 break; 814 break;
815 case ACPI_RSTYPE_MEM24: 815 case ACPI_RESOURCE_TYPE_MEMORY24:
816 pnp_dbg("Encode mem24"); 816 pnp_dbg("Encode mem24");
817 pnpacpi_encode_mem24(resource, 817 pnpacpi_encode_mem24(resource,
818 &res_table->mem_resource[mem]); 818 &res_table->mem_resource[mem]);
819 mem ++; 819 mem ++;
820 break; 820 break;
821 case ACPI_RSTYPE_MEM32: 821 case ACPI_RESOURCE_TYPE_MEMORY32:
822 pnp_dbg("Encode mem32"); 822 pnp_dbg("Encode mem32");
823 pnpacpi_encode_mem32(resource, 823 pnpacpi_encode_mem32(resource,
824 &res_table->mem_resource[mem]); 824 &res_table->mem_resource[mem]);
825 mem ++; 825 mem ++;
826 break; 826 break;
827 case ACPI_RSTYPE_FIXED_MEM32: 827 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
828 pnp_dbg("Encode fixed mem32"); 828 pnp_dbg("Encode fixed mem32");
829 pnpacpi_encode_fixed_mem32(resource, 829 pnpacpi_encode_fixed_mem32(resource,
830 &res_table->mem_resource[mem]); 830 &res_table->mem_resource[mem]);
diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
index 36681ba7b033..809f89ab965c 100644
--- a/drivers/serial/8250_acpi.c
+++ b/drivers/serial/8250_acpi.c
@@ -27,7 +27,7 @@ struct serial_private {
27static acpi_status acpi_serial_mmio(struct uart_port *port, 27static acpi_status acpi_serial_mmio(struct uart_port *port,
28 struct acpi_resource_address64 *addr) 28 struct acpi_resource_address64 *addr)
29{ 29{
30 port->mapbase = addr->min_address_range; 30 port->mapbase = addr->minimum;
31 port->iotype = UPIO_MEM; 31 port->iotype = UPIO_MEM;
32 port->flags |= UPF_IOREMAP; 32 port->flags |= UPF_IOREMAP;
33 return AE_OK; 33 return AE_OK;
@@ -36,8 +36,8 @@ static acpi_status acpi_serial_mmio(struct uart_port *port,
36static acpi_status acpi_serial_port(struct uart_port *port, 36static acpi_status acpi_serial_port(struct uart_port *port,
37 struct acpi_resource_io *io) 37 struct acpi_resource_io *io)
38{ 38{
39 if (io->range_length) { 39 if (io->address_length) {
40 port->iobase = io->min_base_address; 40 port->iobase = io->minimum;
41 port->iotype = UPIO_PORT; 41 port->iotype = UPIO_PORT;
42 } else 42 } else
43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); 43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__);
@@ -45,13 +45,13 @@ static acpi_status acpi_serial_port(struct uart_port *port,
45} 45}
46 46
47static acpi_status acpi_serial_ext_irq(struct uart_port *port, 47static acpi_status acpi_serial_ext_irq(struct uart_port *port,
48 struct acpi_resource_ext_irq *ext_irq) 48 struct acpi_resource_extended_irq *ext_irq)
49{ 49{
50 int rc; 50 int rc;
51 51
52 if (ext_irq->number_of_interrupts > 0) { 52 if (ext_irq->interrupt_count > 0) {
53 rc = acpi_register_gsi(ext_irq->interrupts[0], 53 rc = acpi_register_gsi(ext_irq->interrupts[0],
54 ext_irq->edge_level, ext_irq->active_high_low); 54 ext_irq->triggering, ext_irq->polarity);
55 if (rc < 0) 55 if (rc < 0)
56 return AE_ERROR; 56 return AE_ERROR;
57 port->irq = rc; 57 port->irq = rc;
@@ -64,9 +64,9 @@ static acpi_status acpi_serial_irq(struct uart_port *port,
64{ 64{
65 int rc; 65 int rc;
66 66
67 if (irq->number_of_interrupts > 0) { 67 if (irq->interrupt_count > 0) {
68 rc = acpi_register_gsi(irq->interrupts[0], 68 rc = acpi_register_gsi(irq->interrupts[0],
69 irq->edge_level, irq->active_high_low); 69 irq->triggering, irq->polarity);
70 if (rc < 0) 70 if (rc < 0)
71 return AE_ERROR; 71 return AE_ERROR;
72 port->irq = rc; 72 port->irq = rc;
@@ -83,11 +83,11 @@ static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
83 status = acpi_resource_to_address64(res, &addr); 83 status = acpi_resource_to_address64(res, &addr);
84 if (ACPI_SUCCESS(status)) 84 if (ACPI_SUCCESS(status))
85 return acpi_serial_mmio(port, &addr); 85 return acpi_serial_mmio(port, &addr);
86 else if (res->type == ACPI_RSTYPE_IO) 86 else if (res->type == ACPI_RESOURCE_TYPE_IO)
87 return acpi_serial_port(port, &res->data.io); 87 return acpi_serial_port(port, &res->data.io);
88 else if (res->type == ACPI_RSTYPE_EXT_IRQ) 88 else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
89 return acpi_serial_ext_irq(port, &res->data.extended_irq); 89 return acpi_serial_ext_irq(port, &res->data.extended_irq);
90 else if (res->type == ACPI_RSTYPE_IRQ) 90 else if (res->type == ACPI_RESOURCE_TYPE_IRQ)
91 return acpi_serial_irq(port, &res->data.irq); 91 return acpi_serial_irq(port, &res->data.irq);
92 return AE_OK; 92 return AE_OK;
93} 93}