aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer
diff options
context:
space:
mode:
authorRobert Moore <robert.moore@intel.com>2005-06-24 00:00:00 -0400
committerLen Brown <len.brown@intel.com>2005-07-13 23:45:36 -0400
commit73459f73e5d1602c59ebec114fc45185521353c1 (patch)
tree56c2183e345784d2be09c2f5d2530cf36221c55e /drivers/acpi/executer
parent88ac00f5a841dcfc5c682000f4a6add0add8caac (diff)
ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>
ACPICA 20050617: Moved the object cache operations into the OS interface layer (OSL) to allow the host OS to handle these operations if desired (for example, the Linux OSL will invoke the slab allocator). This support is optional; the compile time define ACPI_USE_LOCAL_CACHE may be used to utilize the original cache code in the ACPI CA core. The new OSL interfaces are shown below. See utalloc.c for an example implementation, and acpiosxf.h for the exact interface definitions. Thanks to Alexey Starikovskiy. acpi_os_create_cache acpi_os_delete_cache acpi_os_purge_cache acpi_os_acquire_object acpi_os_release_object Modified the interfaces to acpi_os_acquire_lock and acpi_os_release_lock to return and restore a flags parameter. This fits better with many OS lock models. Note: the current execution state (interrupt handler or not) is no longer passed to these interfaces. If necessary, the OSL must determine this state by itself, a simple and fast operation. Thanks to Alexey Starikovskiy. Fixed a problem in the ACPI table handling where a valid XSDT was assumed present if the revision of the RSDP was 2 or greater. According to the ACPI specification, the XSDT is optional in all cases, and the table manager therefore now checks for both an RSDP >=2 and a valid XSDT pointer. Otherwise, the RSDT pointer is used. Some ACPI 2.0 compliant BIOSs contain only the RSDT. Fixed an interpreter problem with the Mid() operator in the case of an input string where the resulting output string is of zero length. It now correctly returns a valid, null terminated string object instead of a string object with a null pointer. Fixed a problem with the control method argument handling to allow a store to an Arg object that already contains an object of type Device. The Device object is now correctly overwritten. Previously, an error was returned. ACPICA 20050624: Modified the new OSL cache interfaces to use ACPI_CACHE_T as the type for the host-defined cache object. This allows the OSL implementation to define and type this object in any manner desired, simplifying the OSL implementation. For example, ACPI_CACHE_T is defined as kmem_cache_t for Linux, and should be defined in the OS-specific header file for other operating systems as required. Changed the interface to AcpiOsAcquireObject to directly return the requested object as the function return (instead of ACPI_STATUS.) This change was made for performance reasons, since this is the purpose of the interface in the first place. acpi_os_acquire_object is now similar to the acpi_os_allocate interface. Thanks to Alexey Starikovskiy. Modified the initialization sequence in acpi_initialize_subsystem to call the OSL interface acpi_osl_initialize first, before any local initialization. This change was required because the global initialization now calls OSL interfaces. Restructured the code base to split some files because of size and/or because the code logically belonged in a separate file. New files are listed below. utilities/utcache.c /* Local cache interfaces */ utilities/utmutex.c /* Local mutex support */ utilities/utstate.c /* State object support */ parser/psloop.c /* Main AML parse loop */ Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/executer')
-rw-r--r--drivers/acpi/executer/exconvrt.c2
-rw-r--r--drivers/acpi/executer/exdump.c174
-rw-r--r--drivers/acpi/executer/exmisc.c2
-rw-r--r--drivers/acpi/executer/exoparg1.c3
-rw-r--r--drivers/acpi/executer/exoparg3.c63
-rw-r--r--drivers/acpi/executer/exstore.c2
-rw-r--r--drivers/acpi/executer/exutils.c2
7 files changed, 204 insertions, 44 deletions
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 97856c48bd74..21331625e66e 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii (
367 367
368 /* hex_length: 2 ascii hex chars per data byte */ 368 /* hex_length: 2 ascii hex chars per data byte */
369 369
370 hex_length = ACPI_MUL_2 (data_width); 370 hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width);
371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { 371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
372 /* Get one hex digit, most significant digits first */ 372 /* Get one hex digit, most significant digits first */
373 373
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index ae6cad85e015..7007abb6051e 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -80,6 +80,16 @@ acpi_ex_out_address (
80 acpi_physical_address value); 80 acpi_physical_address value);
81#endif /* ACPI_FUTURE_USAGE */ 81#endif /* ACPI_FUTURE_USAGE */
82 82
83static void
84acpi_ex_dump_reference (
85 union acpi_operand_object *obj_desc);
86
87static void
88acpi_ex_dump_package (
89 union acpi_operand_object *obj_desc,
90 u32 level,
91 u32 index);
92
83 93
84/******************************************************************************* 94/*******************************************************************************
85 * 95 *
@@ -508,7 +518,7 @@ acpi_ex_out_integer (
508 char *title, 518 char *title,
509 u32 value) 519 u32 value)
510{ 520{
511 acpi_os_printf ("%20s : %X\n", title, value); 521 acpi_os_printf ("%20s : %.2X\n", title, value);
512} 522}
513 523
514static void 524static void
@@ -565,9 +575,144 @@ acpi_ex_dump_node (
565 575
566/******************************************************************************* 576/*******************************************************************************
567 * 577 *
578 * FUNCTION: acpi_ex_dump_reference
579 *
580 * PARAMETERS: Object - Descriptor to dump
581 *
582 * DESCRIPTION: Dumps a reference object
583 *
584 ******************************************************************************/
585
586static void
587acpi_ex_dump_reference (
588 union acpi_operand_object *obj_desc)
589{
590 struct acpi_buffer ret_buf;
591 acpi_status status;
592
593
594 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
595 acpi_os_printf ("Named Object %p ", obj_desc->reference.node);
596 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
597 status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf);
598 if (ACPI_FAILURE (status)) {
599 acpi_os_printf ("Could not convert name to pathname\n");
600 }
601 else {
602 acpi_os_printf ("%s\n", ret_buf.pointer);
603 ACPI_MEM_FREE (ret_buf.pointer);
604 }
605 }
606 else if (obj_desc->reference.object) {
607 acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
608 }
609}
610
611
612/*******************************************************************************
613 *
614 * FUNCTION: acpi_ex_dump_package
615 *
616 * PARAMETERS: Object - Descriptor to dump
617 * Level - Indentation Level
618 * Index - Package index for this object
619 *
620 * DESCRIPTION: Dumps the elements of the package
621 *
622 ******************************************************************************/
623
624static void
625acpi_ex_dump_package (
626 union acpi_operand_object *obj_desc,
627 u32 level,
628 u32 index)
629{
630 u32 i;
631
632
633 /* Indentation and index output */
634
635 if (level > 0) {
636 for (i = 0; i < level; i++) {
637 acpi_os_printf (" ");
638 }
639
640 acpi_os_printf ("[%.2d] ", index);
641 }
642
643 acpi_os_printf ("%p ", obj_desc);
644
645 /* Null package elements are allowed */
646
647 if (!obj_desc) {
648 acpi_os_printf ("[Null Object]\n");
649 return;
650 }
651
652 /* Packages may only contain a few object types */
653
654 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
655 case ACPI_TYPE_INTEGER:
656
657 acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
658 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
659 break;
660
661
662 case ACPI_TYPE_STRING:
663
664 acpi_os_printf ("[String] Value: ");
665 for (i = 0; i < obj_desc->string.length; i++) {
666 acpi_os_printf ("%c", obj_desc->string.pointer[i]);
667 }
668 acpi_os_printf ("\n");
669 break;
670
671
672 case ACPI_TYPE_BUFFER:
673
674 acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length);
675 if (obj_desc->buffer.length) {
676 acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer,
677 obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
678 }
679 else {
680 acpi_os_printf ("\n");
681 }
682 break;
683
684
685 case ACPI_TYPE_PACKAGE:
686
687 acpi_os_printf ("[Package] Contains %d Elements: \n",
688 obj_desc->package.count);
689
690 for (i = 0; i < obj_desc->package.count; i++) {
691 acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i);
692 }
693 break;
694
695
696 case ACPI_TYPE_LOCAL_REFERENCE:
697
698 acpi_os_printf ("[Object Reference] ");
699 acpi_ex_dump_reference (obj_desc);
700 break;
701
702
703 default:
704
705 acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
706 break;
707 }
708}
709
710
711/*******************************************************************************
712 *
568 * FUNCTION: acpi_ex_dump_object_descriptor 713 * FUNCTION: acpi_ex_dump_object_descriptor
569 * 714 *
570 * PARAMETERS: *Object - Descriptor to dump 715 * PARAMETERS: Object - Descriptor to dump
571 * Flags - Force display if TRUE 716 * Flags - Force display if TRUE
572 * 717 *
573 * DESCRIPTION: Dumps the members of the object descriptor given. 718 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -579,9 +724,6 @@ acpi_ex_dump_object_descriptor (
579 union acpi_operand_object *obj_desc, 724 union acpi_operand_object *obj_desc,
580 u32 flags) 725 u32 flags)
581{ 726{
582 u32 i;
583
584
585 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); 727 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
586 728
587 729
@@ -648,22 +790,13 @@ acpi_ex_dump_object_descriptor (
648 case ACPI_TYPE_PACKAGE: 790 case ACPI_TYPE_PACKAGE:
649 791
650 acpi_ex_out_integer ("Flags", obj_desc->package.flags); 792 acpi_ex_out_integer ("Flags", obj_desc->package.flags);
651 acpi_ex_out_integer ("Count", obj_desc->package.count); 793 acpi_ex_out_integer ("Elements", obj_desc->package.count);
652 acpi_ex_out_pointer ("Elements", obj_desc->package.elements); 794 acpi_ex_out_pointer ("Element List", obj_desc->package.elements);
653 795
654 /* Dump the package contents */ 796 /* Dump the package contents */
655 797
656 if (obj_desc->package.count > 0) { 798 acpi_os_printf ("\nPackage Contents:\n");
657 acpi_os_printf ("\nPackage Contents:\n"); 799 acpi_ex_dump_package (obj_desc, 0, 0);
658 for (i = 0; i < obj_desc->package.count; i++) {
659 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
660 if (obj_desc->package.elements[i]) {
661 acpi_os_printf (" %s",
662 acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
663 }
664 acpi_os_printf ("\n");
665 }
666 }
667 break; 800 break;
668 801
669 802
@@ -790,10 +923,7 @@ acpi_ex_dump_object_descriptor (
790 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 923 acpi_ex_out_pointer ("Node", obj_desc->reference.node);
791 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 924 acpi_ex_out_pointer ("Where", obj_desc->reference.where);
792 925
793 if (obj_desc->reference.object) { 926 acpi_ex_dump_reference (obj_desc);
794 acpi_os_printf ("\nReferenced Object:\n");
795 acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
796 }
797 break; 927 break;
798 928
799 929
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 022f281345b8..237ef28c8132 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -302,7 +302,7 @@ acpi_ex_do_concatenate (
302 /* Result of two Integers is a Buffer */ 302 /* Result of two Integers is a Buffer */
303 /* Need enough buffer space for two integers */ 303 /* Need enough buffer space for two integers */
304 304
305 return_desc = acpi_ut_create_buffer_object ( 305 return_desc = acpi_ut_create_buffer_object ((acpi_size)
306 ACPI_MUL_2 (acpi_gbl_integer_byte_width)); 306 ACPI_MUL_2 (acpi_gbl_integer_byte_width));
307 if (!return_desc) { 307 if (!return_desc) {
308 status = AE_NO_MEMORY; 308 status = AE_NO_MEMORY;
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index ffc61ddeb659..131f49acb1df 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R (
113 status = AE_NO_MEMORY; 113 status = AE_NO_MEMORY;
114 goto cleanup; 114 goto cleanup;
115 } 115 }
116 116#if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer (); 117 return_desc->integer.value = acpi_os_get_timer ();
118#endif
118 break; 119 break;
119 120
120 default: /* Unknown opcode */ 121 default: /* Unknown opcode */
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 23b068adbf58..197890f443b5 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R (
160{ 160{
161 union acpi_operand_object **operand = &walk_state->operands[0]; 161 union acpi_operand_object **operand = &walk_state->operands[0];
162 union acpi_operand_object *return_desc = NULL; 162 union acpi_operand_object *return_desc = NULL;
163 char *buffer; 163 char *buffer = NULL;
164 acpi_status status = AE_OK; 164 acpi_status status = AE_OK;
165 acpi_integer index; 165 acpi_integer index;
166 acpi_size length; 166 acpi_size length;
@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R (
193 * If the index is beyond the length of the String/Buffer, or if the 193 * If the index is beyond the length of the String/Buffer, or if the
194 * requested length is zero, return a zero-length String/Buffer 194 * requested length is zero, return a zero-length String/Buffer
195 */ 195 */
196 if ((index < operand[0]->string.length) && 196 if (index >= operand[0]->string.length) {
197 (length > 0)) { 197 length = 0;
198 /* Truncate request if larger than the actual String/Buffer */ 198 }
199 199
200 if ((index + length) > 200 /* Truncate request if larger than the actual String/Buffer */
201 operand[0]->string.length) { 201
202 length = (acpi_size) operand[0]->string.length - 202 else if ((index + length) > operand[0]->string.length) {
203 (acpi_size) index; 203 length = (acpi_size) operand[0]->string.length -
204 } 204 (acpi_size) index;
205 }
205 206
206 /* Allocate a new buffer for the String/Buffer */ 207 /* Strings always have a sub-pointer, not so for buffers */
208
209 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
210 case ACPI_TYPE_STRING:
211
212 /* Always allocate a new buffer for the String */
207 213
208 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 214 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
209 if (!buffer) { 215 if (!buffer) {
210 status = AE_NO_MEMORY; 216 status = AE_NO_MEMORY;
211 goto cleanup; 217 goto cleanup;
212 } 218 }
219 break;
220
221 case ACPI_TYPE_BUFFER:
222
223 /* If the requested length is zero, don't allocate a buffer */
224
225 if (length > 0) {
226 /* Allocate a new buffer for the Buffer */
227
228 buffer = ACPI_MEM_CALLOCATE (length);
229 if (!buffer) {
230 status = AE_NO_MEMORY;
231 goto cleanup;
232 }
233 }
234 break;
213 235
236 default: /* Should not happen */
237
238 status = AE_AML_OPERAND_TYPE;
239 goto cleanup;
240 }
241
242 if (length > 0) {
214 /* Copy the portion requested */ 243 /* Copy the portion requested */
215 244
216 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, 245 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
217 length); 246 length);
247 }
218 248
219 /* Set the length of the new String/Buffer */ 249 /* Set the length of the new String/Buffer */
220 250
221 return_desc->string.pointer = buffer; 251 return_desc->string.pointer = buffer;
222 return_desc->string.length = (u32) length; 252 return_desc->string.length = (u32) length;
223 }
224 253
225 /* Mark buffer initialized */ 254 /* Mark buffer initialized */
226 255
@@ -244,13 +273,13 @@ cleanup:
244 273
245 /* Delete return object on error */ 274 /* Delete return object on error */
246 275
247 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE (status) || walk_state->result_obj) {
248 acpi_ut_remove_reference (return_desc); 277 acpi_ut_remove_reference (return_desc);
249 } 278 }
250 279
251 /* Set the return object and exit */ 280 /* Set the return object and exit */
252 281
253 if (!walk_state->result_obj) { 282 else {
254 walk_state->result_obj = return_desc; 283 walk_state->result_obj = return_desc;
255 } 284 }
256 return_ACPI_STATUS (status); 285 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 763ffeea8503..59dbfeaa54c0 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -147,7 +147,7 @@ acpi_ex_do_debug_object (
147 147
148 case ACPI_TYPE_BUFFER: 148 case ACPI_TYPE_BUFFER:
149 149
150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", 150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
151 (u32) source_desc->buffer.length)); 151 (u32) source_desc->buffer.length));
152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer, 152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); 153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 5c7ec0c04177..d00b0dcba96a 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string (
369 * 369 *
370 * RETURN: None, string 370 * RETURN: None, string
371 * 371 *
372 * DESCRIPTOIN: Convert a number to string representation. Assumes string 372 * DESCRIPTION: Convert a number to string representation. Assumes string
373 * buffer is large enough to hold the string. 373 * buffer is large enough to hold the string.
374 * 374 *
375 ******************************************************************************/ 375 ******************************************************************************/