Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (42 commits)
ACPI: minor printk format change in acpi_pad
ACPI: make acpi_pad /sys output more readable
ACPICA: Update version to 20110316
ACPICA: Header support for SLIC table
ACPI: Make sure the FADT is at least rev 2 before using the reset register
ACPI: Bug compatibility for Windows on the ACPI reboot vector
ACPICA: Fix access width for reset vector
ACPI battery: fribble sysfs files from a resume notifier
ACPI button: remove unused procfs I/F
ACPI, APEI, Add PCIe AER error information printing support
PCIe, AER, use pre-generated prefix in error information printing
ACPI, APEI, Add ERST record ID cache
ACPI: Use syscore_ops instead of sysdev class and sysdev
ACPI: Remove the unused EC sysdev class
ACPI: use __cpuinit for the acpi_processor_set_pdc() call tree
ACPI: use __init where possible in processor driver
Thermal_Framework-Fix_crash_during_hwmon_unregister
ACPICA: Update version to 20110211.
ACPICA: Add mechanism to defer _REG methods for some installed handlers
ACPICA: Add support for FunctionalFixedHW in acpi_ut_get_region_name
...

+2918 -2372
+25
Documentation/acpi/apei/output_format.txt
··· 92 92 class_code: <integer>] 93 93 [serial number: <integer>, <integer>] 94 94 [bridge: secondary_status: <integer>, control: <integer>] 95 + [aer_status: <integer>, aer_mask: <integer> 96 + <aer status string> 97 + [aer_uncor_severity: <integer>] 98 + aer_layer=<aer layer string>, aer_agent=<aer agent string> 99 + aer_tlp_header: <integer> <integer> <integer> <integer>] 95 100 96 101 <pcie port type string>* := PCIe end point | legacy PCI end point | \ 97 102 unknown | unknown | root port | upstream switch port | \ 98 103 downstream switch port | PCIe to PCI/PCI-X bridge | \ 99 104 PCI/PCI-X to PCIe bridge | root complex integrated endpoint device | \ 100 105 root complex event collector 106 + 107 + if section severity is fatal or recoverable 108 + <aer status string># := 109 + unknown | unknown | unknown | unknown | Data Link Protocol | \ 110 + unknown | unknown | unknown | unknown | unknown | unknown | unknown | \ 111 + Poisoned TLP | Flow Control Protocol | Completion Timeout | \ 112 + Completer Abort | Unexpected Completion | Receiver Overflow | \ 113 + Malformed TLP | ECRC | Unsupported Request 114 + else 115 + <aer status string># := 116 + Receiver Error | unknown | unknown | unknown | unknown | unknown | \ 117 + Bad TLP | Bad DLLP | RELAY_NUM Rollover | unknown | unknown | unknown | \ 118 + Replay Timer Timeout | Advisory Non-Fatal 119 + fi 120 + 121 + <aer layer string> := 122 + Physical Layer | Data Link Layer | Transaction Layer 123 + 124 + <aer agent string> := 125 + Receiver ID | Requester ID | Completer ID | Transmitter ID 101 126 102 127 Where, [] designate corresponding content is optional 103 128
-8
Documentation/feature-removal-schedule.txt
··· 270 270 271 271 --------------------------- 272 272 273 - What: /proc/acpi/button 274 - When: August 2007 275 - Why: /proc/acpi/button has been replaced by events to the input layer 276 - since 2.6.20. 277 - Who: Len Brown <len.brown@intel.com> 278 - 279 - --------------------------- 280 - 281 273 What: /proc/acpi/event 282 274 When: February 2008 283 275 Why: /proc/acpi/event has been replaced by events via the input layer
+3 -3
arch/ia64/include/asm/acpi.h
··· 128 128 int acpi_request_vector (u32 int_type); 129 129 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 130 130 131 - /* routines for saving/restoring kernel state */ 132 - extern int acpi_save_state_mem(void); 133 - extern void acpi_restore_state_mem(void); 131 + /* Low-level suspend routine. */ 132 + extern int acpi_suspend_lowlevel(void); 133 + 134 134 extern unsigned long acpi_wakeup_address; 135 135 136 136 /*
+9 -14
arch/ia64/kernel/acpi.c
··· 803 803 * ACPI based hotplug CPU support 804 804 */ 805 805 #ifdef CONFIG_ACPI_HOTPLUG_CPU 806 - static 806 + static __cpuinit 807 807 int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 808 808 { 809 809 #ifdef CONFIG_ACPI_NUMA ··· 878 878 set_cpu_possible(i, true); 879 879 } 880 880 881 - int acpi_map_lsapic(acpi_handle handle, int *pcpu) 881 + static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu) 882 882 { 883 883 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 884 884 union acpi_object *obj; ··· 929 929 return (0); 930 930 } 931 931 932 + /* wrapper to silence section mismatch warning */ 933 + int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu) 934 + { 935 + return _acpi_map_lsapic(handle, pcpu); 936 + } 932 937 EXPORT_SYMBOL(acpi_map_lsapic); 933 938 934 939 int acpi_unmap_lsapic(int cpu) ··· 1039 1034 EXPORT_SYMBOL(acpi_unregister_ioapic); 1040 1035 1041 1036 /* 1042 - * acpi_save_state_mem() - save kernel state 1037 + * acpi_suspend_lowlevel() - save kernel state and suspend. 1043 1038 * 1044 1039 * TBD when when IA64 starts to support suspend... 1045 1040 */ 1046 - int acpi_save_state_mem(void) { return 0; } 1047 - 1048 - /* 1049 - * acpi_restore_state() 1050 - */ 1051 - void acpi_restore_state_mem(void) {} 1052 - 1053 - /* 1054 - * do_suspend_lowlevel() 1055 - */ 1056 - void do_suspend_lowlevel(void) {} 1041 + int acpi_suspend_lowlevel(void) { return 0; }
+2 -3
arch/x86/include/asm/acpi.h
··· 114 114 acpi_noirq_set(); 115 115 } 116 116 117 - /* routines for saving/restoring kernel state */ 118 - extern int acpi_save_state_mem(void); 119 - extern void acpi_restore_state_mem(void); 117 + /* Low-level suspend routine. */ 118 + extern int acpi_suspend_lowlevel(void); 120 119 121 120 extern const unsigned char acpi_wakeup_code[]; 122 121 #define acpi_wakeup_address (__pa(TRAMPOLINE_SYM(acpi_wakeup_code)))
+3 -9
arch/x86/kernel/acpi/sleep.c
··· 25 25 #endif 26 26 27 27 /** 28 - * acpi_save_state_mem - save kernel state 28 + * acpi_suspend_lowlevel - save kernel state 29 29 * 30 30 * Create an identity mapped page table and copy the wakeup routine to 31 31 * low memory. 32 32 */ 33 - int acpi_save_state_mem(void) 33 + int acpi_suspend_lowlevel(void) 34 34 { 35 35 struct wakeup_header *header; 36 36 /* address in low memory of the wakeup routine. */ ··· 96 96 saved_magic = 0x123456789abcdef0L; 97 97 #endif /* CONFIG_64BIT */ 98 98 99 + do_suspend_lowlevel(); 99 100 return 0; 100 - } 101 - 102 - /* 103 - * acpi_restore_state - undo effects of acpi_save_state_mem 104 - */ 105 - void acpi_restore_state_mem(void) 106 - { 107 101 } 108 102 109 103 static int __init acpi_sleep_setup(char *str)
+2
arch/x86/kernel/acpi/sleep.h
··· 11 11 12 12 extern unsigned long acpi_copy_wakeup_routine(unsigned long); 13 13 extern void wakeup_long64(void); 14 + 15 + extern void do_suspend_lowlevel(void);
+25 -15
arch/x86/kernel/cpu/mcheck/mce-apei.c
··· 106 106 ssize_t apei_read_mce(struct mce *m, u64 *record_id) 107 107 { 108 108 struct cper_mce_record rcd; 109 - ssize_t len; 109 + int rc, pos; 110 110 111 - len = erst_read_next(&rcd.hdr, sizeof(rcd)); 112 - if (len <= 0) 113 - return len; 114 - /* Can not skip other records in storage via ERST unless clear them */ 115 - else if (len != sizeof(rcd) || 116 - uuid_le_cmp(rcd.hdr.creator_id, CPER_CREATOR_MCE)) { 117 - if (printk_ratelimit()) 118 - pr_warning( 119 - "MCE-APEI: Can not skip the unknown record in ERST"); 120 - return -EIO; 121 - } 122 - 111 + rc = erst_get_record_id_begin(&pos); 112 + if (rc) 113 + return rc; 114 + retry: 115 + rc = erst_get_record_id_next(&pos, record_id); 116 + if (rc) 117 + goto out; 118 + /* no more record */ 119 + if (*record_id == APEI_ERST_INVALID_RECORD_ID) 120 + goto out; 121 + rc = erst_read(*record_id, &rcd.hdr, sizeof(rcd)); 122 + /* someone else has cleared the record, try next one */ 123 + if (rc == -ENOENT) 124 + goto retry; 125 + else if (rc < 0) 126 + goto out; 127 + /* try to skip other type records in storage */ 128 + else if (rc != sizeof(rcd) || 129 + uuid_le_cmp(rcd.hdr.creator_id, CPER_CREATOR_MCE)) 130 + goto retry; 123 131 memcpy(m, &rcd.mce, sizeof(*m)); 124 - *record_id = rcd.hdr.record_id; 132 + rc = sizeof(*m); 133 + out: 134 + erst_get_record_id_end(); 125 135 126 - return sizeof(*m); 136 + return rc; 127 137 } 128 138 129 139 /* Check whether there is record in ERST */
+8 -5
drivers/acpi/acpi_pad.c
··· 298 298 static ssize_t acpi_pad_rrtime_show(struct device *dev, 299 299 struct device_attribute *attr, char *buf) 300 300 { 301 - return scnprintf(buf, PAGE_SIZE, "%d", round_robin_time); 301 + return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time); 302 302 } 303 303 static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR, 304 304 acpi_pad_rrtime_show, ··· 321 321 static ssize_t acpi_pad_idlepct_show(struct device *dev, 322 322 struct device_attribute *attr, char *buf) 323 323 { 324 - return scnprintf(buf, PAGE_SIZE, "%d", idle_pct); 324 + return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct); 325 325 } 326 326 static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR, 327 327 acpi_pad_idlepct_show, ··· 342 342 static ssize_t acpi_pad_idlecpus_show(struct device *dev, 343 343 struct device_attribute *attr, char *buf) 344 344 { 345 - return cpumask_scnprintf(buf, PAGE_SIZE, 346 - to_cpumask(pad_busy_cpus_bits)); 345 + int n = 0; 346 + n = cpumask_scnprintf(buf, PAGE_SIZE-2, to_cpumask(pad_busy_cpus_bits)); 347 + buf[n++] = '\n'; 348 + buf[n] = '\0'; 349 + return n; 347 350 } 348 351 static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR, 349 352 acpi_pad_idlecpus_show, ··· 456 453 dev_name(&device->dev), event, 0); 457 454 break; 458 455 default: 459 - printk(KERN_WARNING"Unsupported event [0x%x]\n", event); 456 + printk(KERN_WARNING "Unsupported event [0x%x]\n", event); 460 457 break; 461 458 } 462 459 }
+2 -2
drivers/acpi/acpica/Makefile
··· 10 10 11 11 acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \ 12 12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \ 13 - dsinit.o 13 + dsinit.o dsargs.o dscontrol.o dswload2.o 14 14 15 15 acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ 16 16 evmisc.o evrgnini.o evxface.o evxfregn.o \ ··· 45 45 acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 46 46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 47 47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \ 48 - utosi.o utxferror.o 48 + utosi.o utxferror.o utdecode.o
+22 -16
drivers/acpi/acpica/acdispat.h
··· 48 48 #define NAMEOF_ARG_NTE "__A0" 49 49 50 50 /* 51 - * dsopcode - support for late evaluation 51 + * dsargs - execution of dynamic arguments for static objects 52 52 */ 53 53 acpi_status 54 54 acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc); ··· 62 62 63 63 acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc); 64 64 65 + /* 66 + * dscontrol - support for execution control opcodes 67 + */ 68 + acpi_status 69 + acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, 70 + union acpi_parse_object *op); 71 + 72 + acpi_status 73 + acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state, 74 + union acpi_parse_object *op); 75 + 76 + /* 77 + * dsopcode - support for late operand evaluation 78 + */ 65 79 acpi_status 66 80 acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, 67 81 union acpi_parse_object *op); ··· 98 84 union acpi_parse_object *op); 99 85 100 86 acpi_status acpi_ds_initialize_region(acpi_handle obj_handle); 101 - 102 - /* 103 - * dsctrl - Parser/Interpreter interface, control stack routines 104 - */ 105 - acpi_status 106 - acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, 107 - union acpi_parse_object *op); 108 - 109 - acpi_status 110 - acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state, 111 - union acpi_parse_object *op); 112 87 113 88 /* 114 89 * dsexec - Parser/Interpreter interface, method execution callbacks ··· 139 136 struct acpi_walk_state *walk_state); 140 137 141 138 /* 142 - * dsload - Parser/Interpreter interface, namespace load callbacks 139 + * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks 143 140 */ 141 + acpi_status 142 + acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number); 143 + 144 144 acpi_status 145 145 acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state, 146 146 union acpi_parse_object **out_op); 147 147 148 148 acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state); 149 149 150 + /* 151 + * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks 152 + */ 150 153 acpi_status 151 154 acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, 152 155 union acpi_parse_object **out_op); 153 156 154 157 acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state); 155 - 156 - acpi_status 157 - acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number); 158 158 159 159 /* 160 160 * dsmthdat - method data (locals/args)
+4
drivers/acpi/acpica/acglobal.h
··· 273 273 ACPI_EXTERN u8 acpi_gbl_last_owner_id_index; 274 274 ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset; 275 275 276 + /* Initialization sequencing */ 277 + 278 + ACPI_EXTERN u8 acpi_gbl_reg_methods_executed; 279 + 276 280 /* Misc */ 277 281 278 282 ACPI_EXTERN u32 acpi_gbl_original_mode;
-19
drivers/acpi/acpica/aclocal.h
··· 89 89 #define ACPI_MAX_MUTEX 7 90 90 #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 91 91 92 - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 93 - #ifdef DEFINE_ACPI_GLOBALS 94 - 95 - /* Debug names for the mutexes above */ 96 - 97 - static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { 98 - "ACPI_MTX_Interpreter", 99 - "ACPI_MTX_Namespace", 100 - "ACPI_MTX_Tables", 101 - "ACPI_MTX_Events", 102 - "ACPI_MTX_Caches", 103 - "ACPI_MTX_Memory", 104 - "ACPI_MTX_CommandComplete", 105 - "ACPI_MTX_CommandReady" 106 - }; 107 - 108 - #endif 109 - #endif 110 - 111 92 /* Lock structure for reader/writer interfaces */ 112 93 113 94 struct acpi_rw_lock {
+391
drivers/acpi/acpica/dsargs.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: dsargs - Support for execution of dynamic arguments for static 4 + * objects (regions, fields, buffer fields, etc.) 5 + * 6 + *****************************************************************************/ 7 + 8 + /* 9 + * Copyright (C) 2000 - 2011, Intel Corp. 10 + * All rights reserved. 11 + * 12 + * Redistribution and use in source and binary forms, with or without 13 + * modification, are permitted provided that the following conditions 14 + * are met: 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions, and the following disclaimer, 17 + * without modification. 18 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 + * substantially similar to the "NO WARRANTY" disclaimer below 20 + * ("Disclaimer") and any redistribution must be conditioned upon 21 + * including a substantially similar Disclaimer requirement for further 22 + * binary redistribution. 23 + * 3. Neither the names of the above-listed copyright holders nor the names 24 + * of any contributors may be used to endorse or promote products derived 25 + * from this software without specific prior written permission. 26 + * 27 + * Alternatively, this software may be distributed under the terms of the 28 + * GNU General Public License ("GPL") version 2 as published by the Free 29 + * Software Foundation. 30 + * 31 + * NO WARRANTY 32 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 + * POSSIBILITY OF SUCH DAMAGES. 43 + */ 44 + 45 + #include <acpi/acpi.h> 46 + #include "accommon.h" 47 + #include "acparser.h" 48 + #include "amlcode.h" 49 + #include "acdispat.h" 50 + #include "acnamesp.h" 51 + 52 + #define _COMPONENT ACPI_DISPATCHER 53 + ACPI_MODULE_NAME("dsargs") 54 + 55 + /* Local prototypes */ 56 + static acpi_status 57 + acpi_ds_execute_arguments(struct acpi_namespace_node *node, 58 + struct acpi_namespace_node *scope_node, 59 + u32 aml_length, u8 *aml_start); 60 + 61 + /******************************************************************************* 62 + * 63 + * FUNCTION: acpi_ds_execute_arguments 64 + * 65 + * PARAMETERS: Node - Object NS node 66 + * scope_node - Parent NS node 67 + * aml_length - Length of executable AML 68 + * aml_start - Pointer to the AML 69 + * 70 + * RETURN: Status. 71 + * 72 + * DESCRIPTION: Late (deferred) execution of region or field arguments 73 + * 74 + ******************************************************************************/ 75 + 76 + static acpi_status 77 + acpi_ds_execute_arguments(struct acpi_namespace_node *node, 78 + struct acpi_namespace_node *scope_node, 79 + u32 aml_length, u8 *aml_start) 80 + { 81 + acpi_status status; 82 + union acpi_parse_object *op; 83 + struct acpi_walk_state *walk_state; 84 + 85 + ACPI_FUNCTION_TRACE(ds_execute_arguments); 86 + 87 + /* Allocate a new parser op to be the root of the parsed tree */ 88 + 89 + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); 90 + if (!op) { 91 + return_ACPI_STATUS(AE_NO_MEMORY); 92 + } 93 + 94 + /* Save the Node for use in acpi_ps_parse_aml */ 95 + 96 + op->common.node = scope_node; 97 + 98 + /* Create and initialize a new parser state */ 99 + 100 + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); 101 + if (!walk_state) { 102 + status = AE_NO_MEMORY; 103 + goto cleanup; 104 + } 105 + 106 + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, 107 + aml_length, NULL, ACPI_IMODE_LOAD_PASS1); 108 + if (ACPI_FAILURE(status)) { 109 + acpi_ds_delete_walk_state(walk_state); 110 + goto cleanup; 111 + } 112 + 113 + /* Mark this parse as a deferred opcode */ 114 + 115 + walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP; 116 + walk_state->deferred_node = node; 117 + 118 + /* Pass1: Parse the entire declaration */ 119 + 120 + status = acpi_ps_parse_aml(walk_state); 121 + if (ACPI_FAILURE(status)) { 122 + goto cleanup; 123 + } 124 + 125 + /* Get and init the Op created above */ 126 + 127 + op->common.node = node; 128 + acpi_ps_delete_parse_tree(op); 129 + 130 + /* Evaluate the deferred arguments */ 131 + 132 + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); 133 + if (!op) { 134 + return_ACPI_STATUS(AE_NO_MEMORY); 135 + } 136 + 137 + op->common.node = scope_node; 138 + 139 + /* Create and initialize a new parser state */ 140 + 141 + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); 142 + if (!walk_state) { 143 + status = AE_NO_MEMORY; 144 + goto cleanup; 145 + } 146 + 147 + /* Execute the opcode and arguments */ 148 + 149 + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, 150 + aml_length, NULL, ACPI_IMODE_EXECUTE); 151 + if (ACPI_FAILURE(status)) { 152 + acpi_ds_delete_walk_state(walk_state); 153 + goto cleanup; 154 + } 155 + 156 + /* Mark this execution as a deferred opcode */ 157 + 158 + walk_state->deferred_node = node; 159 + status = acpi_ps_parse_aml(walk_state); 160 + 161 + cleanup: 162 + acpi_ps_delete_parse_tree(op); 163 + return_ACPI_STATUS(status); 164 + } 165 + 166 + /******************************************************************************* 167 + * 168 + * FUNCTION: acpi_ds_get_buffer_field_arguments 169 + * 170 + * PARAMETERS: obj_desc - A valid buffer_field object 171 + * 172 + * RETURN: Status. 173 + * 174 + * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late 175 + * evaluation of these field attributes. 176 + * 177 + ******************************************************************************/ 178 + 179 + acpi_status 180 + acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc) 181 + { 182 + union acpi_operand_object *extra_desc; 183 + struct acpi_namespace_node *node; 184 + acpi_status status; 185 + 186 + ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc); 187 + 188 + if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 189 + return_ACPI_STATUS(AE_OK); 190 + } 191 + 192 + /* Get the AML pointer (method object) and buffer_field node */ 193 + 194 + extra_desc = acpi_ns_get_secondary_object(obj_desc); 195 + node = obj_desc->buffer_field.node; 196 + 197 + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_BUFFER_FIELD, 198 + node, NULL)); 199 + 200 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 201 + acpi_ut_get_node_name(node))); 202 + 203 + /* Execute the AML code for the term_arg arguments */ 204 + 205 + status = acpi_ds_execute_arguments(node, node->parent, 206 + extra_desc->extra.aml_length, 207 + extra_desc->extra.aml_start); 208 + return_ACPI_STATUS(status); 209 + } 210 + 211 + /******************************************************************************* 212 + * 213 + * FUNCTION: acpi_ds_get_bank_field_arguments 214 + * 215 + * PARAMETERS: obj_desc - A valid bank_field object 216 + * 217 + * RETURN: Status. 218 + * 219 + * DESCRIPTION: Get bank_field bank_value. This implements the late 220 + * evaluation of these field attributes. 221 + * 222 + ******************************************************************************/ 223 + 224 + acpi_status 225 + acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc) 226 + { 227 + union acpi_operand_object *extra_desc; 228 + struct acpi_namespace_node *node; 229 + acpi_status status; 230 + 231 + ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc); 232 + 233 + if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 234 + return_ACPI_STATUS(AE_OK); 235 + } 236 + 237 + /* Get the AML pointer (method object) and bank_field node */ 238 + 239 + extra_desc = acpi_ns_get_secondary_object(obj_desc); 240 + node = obj_desc->bank_field.node; 241 + 242 + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname 243 + (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL)); 244 + 245 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", 246 + acpi_ut_get_node_name(node))); 247 + 248 + /* Execute the AML code for the term_arg arguments */ 249 + 250 + status = acpi_ds_execute_arguments(node, node->parent, 251 + extra_desc->extra.aml_length, 252 + extra_desc->extra.aml_start); 253 + return_ACPI_STATUS(status); 254 + } 255 + 256 + /******************************************************************************* 257 + * 258 + * FUNCTION: acpi_ds_get_buffer_arguments 259 + * 260 + * PARAMETERS: obj_desc - A valid Buffer object 261 + * 262 + * RETURN: Status. 263 + * 264 + * DESCRIPTION: Get Buffer length and initializer byte list. This implements 265 + * the late evaluation of these attributes. 266 + * 267 + ******************************************************************************/ 268 + 269 + acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) 270 + { 271 + struct acpi_namespace_node *node; 272 + acpi_status status; 273 + 274 + ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc); 275 + 276 + if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 277 + return_ACPI_STATUS(AE_OK); 278 + } 279 + 280 + /* Get the Buffer node */ 281 + 282 + node = obj_desc->buffer.node; 283 + if (!node) { 284 + ACPI_ERROR((AE_INFO, 285 + "No pointer back to namespace node in buffer object %p", 286 + obj_desc)); 287 + return_ACPI_STATUS(AE_AML_INTERNAL); 288 + } 289 + 290 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n")); 291 + 292 + /* Execute the AML code for the term_arg arguments */ 293 + 294 + status = acpi_ds_execute_arguments(node, node, 295 + obj_desc->buffer.aml_length, 296 + obj_desc->buffer.aml_start); 297 + return_ACPI_STATUS(status); 298 + } 299 + 300 + /******************************************************************************* 301 + * 302 + * FUNCTION: acpi_ds_get_package_arguments 303 + * 304 + * PARAMETERS: obj_desc - A valid Package object 305 + * 306 + * RETURN: Status. 307 + * 308 + * DESCRIPTION: Get Package length and initializer byte list. This implements 309 + * the late evaluation of these attributes. 310 + * 311 + ******************************************************************************/ 312 + 313 + acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) 314 + { 315 + struct acpi_namespace_node *node; 316 + acpi_status status; 317 + 318 + ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc); 319 + 320 + if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 321 + return_ACPI_STATUS(AE_OK); 322 + } 323 + 324 + /* Get the Package node */ 325 + 326 + node = obj_desc->package.node; 327 + if (!node) { 328 + ACPI_ERROR((AE_INFO, 329 + "No pointer back to namespace node in package %p", 330 + obj_desc)); 331 + return_ACPI_STATUS(AE_AML_INTERNAL); 332 + } 333 + 334 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n")); 335 + 336 + /* Execute the AML code for the term_arg arguments */ 337 + 338 + status = acpi_ds_execute_arguments(node, node, 339 + obj_desc->package.aml_length, 340 + obj_desc->package.aml_start); 341 + return_ACPI_STATUS(status); 342 + } 343 + 344 + /******************************************************************************* 345 + * 346 + * FUNCTION: acpi_ds_get_region_arguments 347 + * 348 + * PARAMETERS: obj_desc - A valid region object 349 + * 350 + * RETURN: Status. 351 + * 352 + * DESCRIPTION: Get region address and length. This implements the late 353 + * evaluation of these region attributes. 354 + * 355 + ******************************************************************************/ 356 + 357 + acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) 358 + { 359 + struct acpi_namespace_node *node; 360 + acpi_status status; 361 + union acpi_operand_object *extra_desc; 362 + 363 + ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc); 364 + 365 + if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 366 + return_ACPI_STATUS(AE_OK); 367 + } 368 + 369 + extra_desc = acpi_ns_get_secondary_object(obj_desc); 370 + if (!extra_desc) { 371 + return_ACPI_STATUS(AE_NOT_EXIST); 372 + } 373 + 374 + /* Get the Region node */ 375 + 376 + node = obj_desc->region.node; 377 + 378 + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname 379 + (ACPI_TYPE_REGION, node, NULL)); 380 + 381 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", 382 + acpi_ut_get_node_name(node), 383 + extra_desc->extra.aml_start)); 384 + 385 + /* Execute the argument AML */ 386 + 387 + status = acpi_ds_execute_arguments(node, node->parent, 388 + extra_desc->extra.aml_length, 389 + extra_desc->extra.aml_start); 390 + return_ACPI_STATUS(status); 391 + }
+410
drivers/acpi/acpica/dscontrol.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: dscontrol - Support for execution control opcodes - 4 + * if/else/while/return 5 + * 6 + *****************************************************************************/ 7 + 8 + /* 9 + * Copyright (C) 2000 - 2011, Intel Corp. 10 + * All rights reserved. 11 + * 12 + * Redistribution and use in source and binary forms, with or without 13 + * modification, are permitted provided that the following conditions 14 + * are met: 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions, and the following disclaimer, 17 + * without modification. 18 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 + * substantially similar to the "NO WARRANTY" disclaimer below 20 + * ("Disclaimer") and any redistribution must be conditioned upon 21 + * including a substantially similar Disclaimer requirement for further 22 + * binary redistribution. 23 + * 3. Neither the names of the above-listed copyright holders nor the names 24 + * of any contributors may be used to endorse or promote products derived 25 + * from this software without specific prior written permission. 26 + * 27 + * Alternatively, this software may be distributed under the terms of the 28 + * GNU General Public License ("GPL") version 2 as published by the Free 29 + * Software Foundation. 30 + * 31 + * NO WARRANTY 32 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 + * POSSIBILITY OF SUCH DAMAGES. 43 + */ 44 + 45 + #include <acpi/acpi.h> 46 + #include "accommon.h" 47 + #include "amlcode.h" 48 + #include "acdispat.h" 49 + #include "acinterp.h" 50 + 51 + #define _COMPONENT ACPI_DISPATCHER 52 + ACPI_MODULE_NAME("dscontrol") 53 + 54 + /******************************************************************************* 55 + * 56 + * FUNCTION: acpi_ds_exec_begin_control_op 57 + * 58 + * PARAMETERS: walk_list - The list that owns the walk stack 59 + * Op - The control Op 60 + * 61 + * RETURN: Status 62 + * 63 + * DESCRIPTION: Handles all control ops encountered during control method 64 + * execution. 65 + * 66 + ******************************************************************************/ 67 + acpi_status 68 + acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, 69 + union acpi_parse_object *op) 70 + { 71 + acpi_status status = AE_OK; 72 + union acpi_generic_state *control_state; 73 + 74 + ACPI_FUNCTION_NAME(ds_exec_begin_control_op); 75 + 76 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", 77 + op, op->common.aml_opcode, walk_state)); 78 + 79 + switch (op->common.aml_opcode) { 80 + case AML_WHILE_OP: 81 + 82 + /* 83 + * If this is an additional iteration of a while loop, continue. 84 + * There is no need to allocate a new control state. 85 + */ 86 + if (walk_state->control_state) { 87 + if (walk_state->control_state->control. 88 + aml_predicate_start == 89 + (walk_state->parser_state.aml - 1)) { 90 + 91 + /* Reset the state to start-of-loop */ 92 + 93 + walk_state->control_state->common.state = 94 + ACPI_CONTROL_CONDITIONAL_EXECUTING; 95 + break; 96 + } 97 + } 98 + 99 + /*lint -fallthrough */ 100 + 101 + case AML_IF_OP: 102 + 103 + /* 104 + * IF/WHILE: Create a new control state to manage these 105 + * constructs. We need to manage these as a stack, in order 106 + * to handle nesting. 107 + */ 108 + control_state = acpi_ut_create_control_state(); 109 + if (!control_state) { 110 + status = AE_NO_MEMORY; 111 + break; 112 + } 113 + /* 114 + * Save a pointer to the predicate for multiple executions 115 + * of a loop 116 + */ 117 + control_state->control.aml_predicate_start = 118 + walk_state->parser_state.aml - 1; 119 + control_state->control.package_end = 120 + walk_state->parser_state.pkg_end; 121 + control_state->control.opcode = op->common.aml_opcode; 122 + 123 + /* Push the control state on this walk's control stack */ 124 + 125 + acpi_ut_push_generic_state(&walk_state->control_state, 126 + control_state); 127 + break; 128 + 129 + case AML_ELSE_OP: 130 + 131 + /* Predicate is in the state object */ 132 + /* If predicate is true, the IF was executed, ignore ELSE part */ 133 + 134 + if (walk_state->last_predicate) { 135 + status = AE_CTRL_TRUE; 136 + } 137 + 138 + break; 139 + 140 + case AML_RETURN_OP: 141 + 142 + break; 143 + 144 + default: 145 + break; 146 + } 147 + 148 + return (status); 149 + } 150 + 151 + /******************************************************************************* 152 + * 153 + * FUNCTION: acpi_ds_exec_end_control_op 154 + * 155 + * PARAMETERS: walk_list - The list that owns the walk stack 156 + * Op - The control Op 157 + * 158 + * RETURN: Status 159 + * 160 + * DESCRIPTION: Handles all control ops encountered during control method 161 + * execution. 162 + * 163 + ******************************************************************************/ 164 + 165 + acpi_status 166 + acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, 167 + union acpi_parse_object * op) 168 + { 169 + acpi_status status = AE_OK; 170 + union acpi_generic_state *control_state; 171 + 172 + ACPI_FUNCTION_NAME(ds_exec_end_control_op); 173 + 174 + switch (op->common.aml_opcode) { 175 + case AML_IF_OP: 176 + 177 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); 178 + 179 + /* 180 + * Save the result of the predicate in case there is an 181 + * ELSE to come 182 + */ 183 + walk_state->last_predicate = 184 + (u8)walk_state->control_state->common.value; 185 + 186 + /* 187 + * Pop the control state that was created at the start 188 + * of the IF and free it 189 + */ 190 + control_state = 191 + acpi_ut_pop_generic_state(&walk_state->control_state); 192 + acpi_ut_delete_generic_state(control_state); 193 + break; 194 + 195 + case AML_ELSE_OP: 196 + 197 + break; 198 + 199 + case AML_WHILE_OP: 200 + 201 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 202 + 203 + control_state = walk_state->control_state; 204 + if (control_state->common.value) { 205 + 206 + /* Predicate was true, the body of the loop was just executed */ 207 + 208 + /* 209 + * This loop counter mechanism allows the interpreter to escape 210 + * possibly infinite loops. This can occur in poorly written AML 211 + * when the hardware does not respond within a while loop and the 212 + * loop does not implement a timeout. 213 + */ 214 + control_state->control.loop_count++; 215 + if (control_state->control.loop_count > 216 + ACPI_MAX_LOOP_ITERATIONS) { 217 + status = AE_AML_INFINITE_LOOP; 218 + break; 219 + } 220 + 221 + /* 222 + * Go back and evaluate the predicate and maybe execute the loop 223 + * another time 224 + */ 225 + status = AE_CTRL_PENDING; 226 + walk_state->aml_last_while = 227 + control_state->control.aml_predicate_start; 228 + break; 229 + } 230 + 231 + /* Predicate was false, terminate this while loop */ 232 + 233 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 234 + "[WHILE_OP] termination! Op=%p\n", op)); 235 + 236 + /* Pop this control state and free it */ 237 + 238 + control_state = 239 + acpi_ut_pop_generic_state(&walk_state->control_state); 240 + acpi_ut_delete_generic_state(control_state); 241 + break; 242 + 243 + case AML_RETURN_OP: 244 + 245 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 246 + "[RETURN_OP] Op=%p Arg=%p\n", op, 247 + op->common.value.arg)); 248 + 249 + /* 250 + * One optional operand -- the return value 251 + * It can be either an immediate operand or a result that 252 + * has been bubbled up the tree 253 + */ 254 + if (op->common.value.arg) { 255 + 256 + /* Since we have a real Return(), delete any implicit return */ 257 + 258 + acpi_ds_clear_implicit_return(walk_state); 259 + 260 + /* Return statement has an immediate operand */ 261 + 262 + status = 263 + acpi_ds_create_operands(walk_state, 264 + op->common.value.arg); 265 + if (ACPI_FAILURE(status)) { 266 + return (status); 267 + } 268 + 269 + /* 270 + * If value being returned is a Reference (such as 271 + * an arg or local), resolve it now because it may 272 + * cease to exist at the end of the method. 273 + */ 274 + status = 275 + acpi_ex_resolve_to_value(&walk_state->operands[0], 276 + walk_state); 277 + if (ACPI_FAILURE(status)) { 278 + return (status); 279 + } 280 + 281 + /* 282 + * Get the return value and save as the last result 283 + * value. This is the only place where walk_state->return_desc 284 + * is set to anything other than zero! 285 + */ 286 + walk_state->return_desc = walk_state->operands[0]; 287 + } else if (walk_state->result_count) { 288 + 289 + /* Since we have a real Return(), delete any implicit return */ 290 + 291 + acpi_ds_clear_implicit_return(walk_state); 292 + 293 + /* 294 + * The return value has come from a previous calculation. 295 + * 296 + * If value being returned is a Reference (such as 297 + * an arg or local), resolve it now because it may 298 + * cease to exist at the end of the method. 299 + * 300 + * Allow references created by the Index operator to return 301 + * unchanged. 302 + */ 303 + if ((ACPI_GET_DESCRIPTOR_TYPE 304 + (walk_state->results->results.obj_desc[0]) == 305 + ACPI_DESC_TYPE_OPERAND) 306 + && ((walk_state->results->results.obj_desc[0])-> 307 + common.type == ACPI_TYPE_LOCAL_REFERENCE) 308 + && ((walk_state->results->results.obj_desc[0])-> 309 + reference.class != ACPI_REFCLASS_INDEX)) { 310 + status = 311 + acpi_ex_resolve_to_value(&walk_state-> 312 + results->results. 313 + obj_desc[0], 314 + walk_state); 315 + if (ACPI_FAILURE(status)) { 316 + return (status); 317 + } 318 + } 319 + 320 + walk_state->return_desc = 321 + walk_state->results->results.obj_desc[0]; 322 + } else { 323 + /* No return operand */ 324 + 325 + if (walk_state->num_operands) { 326 + acpi_ut_remove_reference(walk_state-> 327 + operands[0]); 328 + } 329 + 330 + walk_state->operands[0] = NULL; 331 + walk_state->num_operands = 0; 332 + walk_state->return_desc = NULL; 333 + } 334 + 335 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 336 + "Completed RETURN_OP State=%p, RetVal=%p\n", 337 + walk_state, walk_state->return_desc)); 338 + 339 + /* End the control method execution right now */ 340 + 341 + status = AE_CTRL_TERMINATE; 342 + break; 343 + 344 + case AML_NOOP_OP: 345 + 346 + /* Just do nothing! */ 347 + break; 348 + 349 + case AML_BREAK_POINT_OP: 350 + 351 + /* 352 + * Set the single-step flag. This will cause the debugger (if present) 353 + * to break to the console within the AML debugger at the start of the 354 + * next AML instruction. 355 + */ 356 + ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE); 357 + ACPI_DEBUGGER_EXEC(acpi_os_printf 358 + ("**break** Executed AML BreakPoint opcode\n")); 359 + 360 + /* Call to the OSL in case OS wants a piece of the action */ 361 + 362 + status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT, 363 + "Executed AML Breakpoint opcode"); 364 + break; 365 + 366 + case AML_BREAK_OP: 367 + case AML_CONTINUE_OP: /* ACPI 2.0 */ 368 + 369 + /* Pop and delete control states until we find a while */ 370 + 371 + while (walk_state->control_state && 372 + (walk_state->control_state->control.opcode != 373 + AML_WHILE_OP)) { 374 + control_state = 375 + acpi_ut_pop_generic_state(&walk_state-> 376 + control_state); 377 + acpi_ut_delete_generic_state(control_state); 378 + } 379 + 380 + /* No while found? */ 381 + 382 + if (!walk_state->control_state) { 383 + return (AE_AML_NO_WHILE); 384 + } 385 + 386 + /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ 387 + 388 + walk_state->aml_last_while = 389 + walk_state->control_state->control.package_end; 390 + 391 + /* Return status depending on opcode */ 392 + 393 + if (op->common.aml_opcode == AML_BREAK_OP) { 394 + status = AE_CTRL_BREAK; 395 + } else { 396 + status = AE_CTRL_CONTINUE; 397 + } 398 + break; 399 + 400 + default: 401 + 402 + ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p", 403 + op->common.aml_opcode, op)); 404 + 405 + status = AE_AML_BAD_OPCODE; 406 + break; 407 + } 408 + 409 + return (status); 410 + }
+4 -721
drivers/acpi/acpica/dsopcode.c
··· 1 1 /****************************************************************************** 2 2 * 3 - * Module Name: dsopcode - Dispatcher Op Region support and handling of 4 - * "control" opcodes 3 + * Module Name: dsopcode - Dispatcher suport for regions and fields 5 4 * 6 5 *****************************************************************************/ 7 6 ··· 56 57 57 58 /* Local prototypes */ 58 59 static acpi_status 59 - acpi_ds_execute_arguments(struct acpi_namespace_node *node, 60 - struct acpi_namespace_node *scope_node, 61 - u32 aml_length, u8 * aml_start); 62 - 63 - static acpi_status 64 60 acpi_ds_init_buffer_field(u16 aml_opcode, 65 61 union acpi_operand_object *obj_desc, 66 62 union acpi_operand_object *buffer_desc, 67 63 union acpi_operand_object *offset_desc, 68 64 union acpi_operand_object *length_desc, 69 65 union acpi_operand_object *result_desc); 70 - 71 - /******************************************************************************* 72 - * 73 - * FUNCTION: acpi_ds_execute_arguments 74 - * 75 - * PARAMETERS: Node - Object NS node 76 - * scope_node - Parent NS node 77 - * aml_length - Length of executable AML 78 - * aml_start - Pointer to the AML 79 - * 80 - * RETURN: Status. 81 - * 82 - * DESCRIPTION: Late (deferred) execution of region or field arguments 83 - * 84 - ******************************************************************************/ 85 - 86 - static acpi_status 87 - acpi_ds_execute_arguments(struct acpi_namespace_node *node, 88 - struct acpi_namespace_node *scope_node, 89 - u32 aml_length, u8 * aml_start) 90 - { 91 - acpi_status status; 92 - union acpi_parse_object *op; 93 - struct acpi_walk_state *walk_state; 94 - 95 - ACPI_FUNCTION_TRACE(ds_execute_arguments); 96 - 97 - /* 98 - * Allocate a new parser op to be the root of the parsed tree 99 - */ 100 - op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); 101 - if (!op) { 102 - return_ACPI_STATUS(AE_NO_MEMORY); 103 - } 104 - 105 - /* Save the Node for use in acpi_ps_parse_aml */ 106 - 107 - op->common.node = scope_node; 108 - 109 - /* Create and initialize a new parser state */ 110 - 111 - walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); 112 - if (!walk_state) { 113 - status = AE_NO_MEMORY; 114 - goto cleanup; 115 - } 116 - 117 - status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, 118 - aml_length, NULL, ACPI_IMODE_LOAD_PASS1); 119 - if (ACPI_FAILURE(status)) { 120 - acpi_ds_delete_walk_state(walk_state); 121 - goto cleanup; 122 - } 123 - 124 - /* Mark this parse as a deferred opcode */ 125 - 126 - walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP; 127 - walk_state->deferred_node = node; 128 - 129 - /* Pass1: Parse the entire declaration */ 130 - 131 - status = acpi_ps_parse_aml(walk_state); 132 - if (ACPI_FAILURE(status)) { 133 - goto cleanup; 134 - } 135 - 136 - /* Get and init the Op created above */ 137 - 138 - op->common.node = node; 139 - acpi_ps_delete_parse_tree(op); 140 - 141 - /* Evaluate the deferred arguments */ 142 - 143 - op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); 144 - if (!op) { 145 - return_ACPI_STATUS(AE_NO_MEMORY); 146 - } 147 - 148 - op->common.node = scope_node; 149 - 150 - /* Create and initialize a new parser state */ 151 - 152 - walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); 153 - if (!walk_state) { 154 - status = AE_NO_MEMORY; 155 - goto cleanup; 156 - } 157 - 158 - /* Execute the opcode and arguments */ 159 - 160 - status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, 161 - aml_length, NULL, ACPI_IMODE_EXECUTE); 162 - if (ACPI_FAILURE(status)) { 163 - acpi_ds_delete_walk_state(walk_state); 164 - goto cleanup; 165 - } 166 - 167 - /* Mark this execution as a deferred opcode */ 168 - 169 - walk_state->deferred_node = node; 170 - status = acpi_ps_parse_aml(walk_state); 171 - 172 - cleanup: 173 - acpi_ps_delete_parse_tree(op); 174 - return_ACPI_STATUS(status); 175 - } 176 - 177 - /******************************************************************************* 178 - * 179 - * FUNCTION: acpi_ds_get_buffer_field_arguments 180 - * 181 - * PARAMETERS: obj_desc - A valid buffer_field object 182 - * 183 - * RETURN: Status. 184 - * 185 - * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late 186 - * evaluation of these field attributes. 187 - * 188 - ******************************************************************************/ 189 - 190 - acpi_status 191 - acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc) 192 - { 193 - union acpi_operand_object *extra_desc; 194 - struct acpi_namespace_node *node; 195 - acpi_status status; 196 - 197 - ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc); 198 - 199 - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 200 - return_ACPI_STATUS(AE_OK); 201 - } 202 - 203 - /* Get the AML pointer (method object) and buffer_field node */ 204 - 205 - extra_desc = acpi_ns_get_secondary_object(obj_desc); 206 - node = obj_desc->buffer_field.node; 207 - 208 - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname 209 - (ACPI_TYPE_BUFFER_FIELD, node, NULL)); 210 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 211 - acpi_ut_get_node_name(node))); 212 - 213 - /* Execute the AML code for the term_arg arguments */ 214 - 215 - status = acpi_ds_execute_arguments(node, node->parent, 216 - extra_desc->extra.aml_length, 217 - extra_desc->extra.aml_start); 218 - return_ACPI_STATUS(status); 219 - } 220 - 221 - /******************************************************************************* 222 - * 223 - * FUNCTION: acpi_ds_get_bank_field_arguments 224 - * 225 - * PARAMETERS: obj_desc - A valid bank_field object 226 - * 227 - * RETURN: Status. 228 - * 229 - * DESCRIPTION: Get bank_field bank_value. This implements the late 230 - * evaluation of these field attributes. 231 - * 232 - ******************************************************************************/ 233 - 234 - acpi_status 235 - acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc) 236 - { 237 - union acpi_operand_object *extra_desc; 238 - struct acpi_namespace_node *node; 239 - acpi_status status; 240 - 241 - ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc); 242 - 243 - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 244 - return_ACPI_STATUS(AE_OK); 245 - } 246 - 247 - /* Get the AML pointer (method object) and bank_field node */ 248 - 249 - extra_desc = acpi_ns_get_secondary_object(obj_desc); 250 - node = obj_desc->bank_field.node; 251 - 252 - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname 253 - (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL)); 254 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", 255 - acpi_ut_get_node_name(node))); 256 - 257 - /* Execute the AML code for the term_arg arguments */ 258 - 259 - status = acpi_ds_execute_arguments(node, node->parent, 260 - extra_desc->extra.aml_length, 261 - extra_desc->extra.aml_start); 262 - return_ACPI_STATUS(status); 263 - } 264 - 265 - /******************************************************************************* 266 - * 267 - * FUNCTION: acpi_ds_get_buffer_arguments 268 - * 269 - * PARAMETERS: obj_desc - A valid Buffer object 270 - * 271 - * RETURN: Status. 272 - * 273 - * DESCRIPTION: Get Buffer length and initializer byte list. This implements 274 - * the late evaluation of these attributes. 275 - * 276 - ******************************************************************************/ 277 - 278 - acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) 279 - { 280 - struct acpi_namespace_node *node; 281 - acpi_status status; 282 - 283 - ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc); 284 - 285 - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 286 - return_ACPI_STATUS(AE_OK); 287 - } 288 - 289 - /* Get the Buffer node */ 290 - 291 - node = obj_desc->buffer.node; 292 - if (!node) { 293 - ACPI_ERROR((AE_INFO, 294 - "No pointer back to namespace node in buffer object %p", 295 - obj_desc)); 296 - return_ACPI_STATUS(AE_AML_INTERNAL); 297 - } 298 - 299 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n")); 300 - 301 - /* Execute the AML code for the term_arg arguments */ 302 - 303 - status = acpi_ds_execute_arguments(node, node, 304 - obj_desc->buffer.aml_length, 305 - obj_desc->buffer.aml_start); 306 - return_ACPI_STATUS(status); 307 - } 308 - 309 - /******************************************************************************* 310 - * 311 - * FUNCTION: acpi_ds_get_package_arguments 312 - * 313 - * PARAMETERS: obj_desc - A valid Package object 314 - * 315 - * RETURN: Status. 316 - * 317 - * DESCRIPTION: Get Package length and initializer byte list. This implements 318 - * the late evaluation of these attributes. 319 - * 320 - ******************************************************************************/ 321 - 322 - acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) 323 - { 324 - struct acpi_namespace_node *node; 325 - acpi_status status; 326 - 327 - ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc); 328 - 329 - if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 330 - return_ACPI_STATUS(AE_OK); 331 - } 332 - 333 - /* Get the Package node */ 334 - 335 - node = obj_desc->package.node; 336 - if (!node) { 337 - ACPI_ERROR((AE_INFO, 338 - "No pointer back to namespace node in package %p", 339 - obj_desc)); 340 - return_ACPI_STATUS(AE_AML_INTERNAL); 341 - } 342 - 343 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n")); 344 - 345 - /* Execute the AML code for the term_arg arguments */ 346 - 347 - status = acpi_ds_execute_arguments(node, node, 348 - obj_desc->package.aml_length, 349 - obj_desc->package.aml_start); 350 - return_ACPI_STATUS(status); 351 - } 352 - 353 - /***************************************************************************** 354 - * 355 - * FUNCTION: acpi_ds_get_region_arguments 356 - * 357 - * PARAMETERS: obj_desc - A valid region object 358 - * 359 - * RETURN: Status. 360 - * 361 - * DESCRIPTION: Get region address and length. This implements the late 362 - * evaluation of these region attributes. 363 - * 364 - ****************************************************************************/ 365 - 366 - acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) 367 - { 368 - struct acpi_namespace_node *node; 369 - acpi_status status; 370 - union acpi_operand_object *extra_desc; 371 - 372 - ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc); 373 - 374 - if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 375 - return_ACPI_STATUS(AE_OK); 376 - } 377 - 378 - extra_desc = acpi_ns_get_secondary_object(obj_desc); 379 - if (!extra_desc) { 380 - return_ACPI_STATUS(AE_NOT_EXIST); 381 - } 382 - 383 - /* Get the Region node */ 384 - 385 - node = obj_desc->region.node; 386 - 387 - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname 388 - (ACPI_TYPE_REGION, node, NULL)); 389 - 390 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", 391 - acpi_ut_get_node_name(node), 392 - extra_desc->extra.aml_start)); 393 - 394 - /* Execute the argument AML */ 395 - 396 - status = acpi_ds_execute_arguments(node, node->parent, 397 - extra_desc->extra.aml_length, 398 - extra_desc->extra.aml_start); 399 - if (ACPI_FAILURE(status)) { 400 - return_ACPI_STATUS(status); 401 - } 402 - 403 - /* Validate the region address/length via the host OS */ 404 - 405 - status = acpi_os_validate_address(obj_desc->region.space_id, 406 - obj_desc->region.address, 407 - (acpi_size) obj_desc->region.length, 408 - acpi_ut_get_node_name(node)); 409 - 410 - if (ACPI_FAILURE(status)) { 411 - /* 412 - * Invalid address/length. We will emit an error message and mark 413 - * the region as invalid, so that it will cause an additional error if 414 - * it is ever used. Then return AE_OK. 415 - */ 416 - ACPI_EXCEPTION((AE_INFO, status, 417 - "During address validation of OpRegion [%4.4s]", 418 - node->name.ascii)); 419 - obj_desc->common.flags |= AOPOBJ_INVALID; 420 - status = AE_OK; 421 - } 422 - 423 - return_ACPI_STATUS(status); 424 - } 425 66 426 67 /******************************************************************************* 427 68 * ··· 465 826 * 466 827 * RETURN: Status 467 828 * 468 - * DESCRIPTION: Get region address and length 469 - * Called from acpi_ds_exec_end_op during data_table_region parse tree walk 829 + * DESCRIPTION: Get region address and length. 830 + * Called from acpi_ds_exec_end_op during data_table_region parse 831 + * tree walk. 470 832 * 471 833 ******************************************************************************/ 472 834 ··· 753 1113 754 1114 acpi_ut_remove_reference(operand_desc); 755 1115 return_ACPI_STATUS(status); 756 - } 757 - 758 - /******************************************************************************* 759 - * 760 - * FUNCTION: acpi_ds_exec_begin_control_op 761 - * 762 - * PARAMETERS: walk_list - The list that owns the walk stack 763 - * Op - The control Op 764 - * 765 - * RETURN: Status 766 - * 767 - * DESCRIPTION: Handles all control ops encountered during control method 768 - * execution. 769 - * 770 - ******************************************************************************/ 771 - 772 - acpi_status 773 - acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, 774 - union acpi_parse_object *op) 775 - { 776 - acpi_status status = AE_OK; 777 - union acpi_generic_state *control_state; 778 - 779 - ACPI_FUNCTION_NAME(ds_exec_begin_control_op); 780 - 781 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, 782 - op->common.aml_opcode, walk_state)); 783 - 784 - switch (op->common.aml_opcode) { 785 - case AML_WHILE_OP: 786 - 787 - /* 788 - * If this is an additional iteration of a while loop, continue. 789 - * There is no need to allocate a new control state. 790 - */ 791 - if (walk_state->control_state) { 792 - if (walk_state->control_state->control.aml_predicate_start 793 - == (walk_state->parser_state.aml - 1)) { 794 - 795 - /* Reset the state to start-of-loop */ 796 - 797 - walk_state->control_state->common.state = 798 - ACPI_CONTROL_CONDITIONAL_EXECUTING; 799 - break; 800 - } 801 - } 802 - 803 - /*lint -fallthrough */ 804 - 805 - case AML_IF_OP: 806 - 807 - /* 808 - * IF/WHILE: Create a new control state to manage these 809 - * constructs. We need to manage these as a stack, in order 810 - * to handle nesting. 811 - */ 812 - control_state = acpi_ut_create_control_state(); 813 - if (!control_state) { 814 - status = AE_NO_MEMORY; 815 - break; 816 - } 817 - /* 818 - * Save a pointer to the predicate for multiple executions 819 - * of a loop 820 - */ 821 - control_state->control.aml_predicate_start = 822 - walk_state->parser_state.aml - 1; 823 - control_state->control.package_end = 824 - walk_state->parser_state.pkg_end; 825 - control_state->control.opcode = op->common.aml_opcode; 826 - 827 - /* Push the control state on this walk's control stack */ 828 - 829 - acpi_ut_push_generic_state(&walk_state->control_state, 830 - control_state); 831 - break; 832 - 833 - case AML_ELSE_OP: 834 - 835 - /* Predicate is in the state object */ 836 - /* If predicate is true, the IF was executed, ignore ELSE part */ 837 - 838 - if (walk_state->last_predicate) { 839 - status = AE_CTRL_TRUE; 840 - } 841 - 842 - break; 843 - 844 - case AML_RETURN_OP: 845 - 846 - break; 847 - 848 - default: 849 - break; 850 - } 851 - 852 - return (status); 853 - } 854 - 855 - /******************************************************************************* 856 - * 857 - * FUNCTION: acpi_ds_exec_end_control_op 858 - * 859 - * PARAMETERS: walk_list - The list that owns the walk stack 860 - * Op - The control Op 861 - * 862 - * RETURN: Status 863 - * 864 - * DESCRIPTION: Handles all control ops encountered during control method 865 - * execution. 866 - * 867 - ******************************************************************************/ 868 - 869 - acpi_status 870 - acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, 871 - union acpi_parse_object * op) 872 - { 873 - acpi_status status = AE_OK; 874 - union acpi_generic_state *control_state; 875 - 876 - ACPI_FUNCTION_NAME(ds_exec_end_control_op); 877 - 878 - switch (op->common.aml_opcode) { 879 - case AML_IF_OP: 880 - 881 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); 882 - 883 - /* 884 - * Save the result of the predicate in case there is an 885 - * ELSE to come 886 - */ 887 - walk_state->last_predicate = 888 - (u8) walk_state->control_state->common.value; 889 - 890 - /* 891 - * Pop the control state that was created at the start 892 - * of the IF and free it 893 - */ 894 - control_state = 895 - acpi_ut_pop_generic_state(&walk_state->control_state); 896 - acpi_ut_delete_generic_state(control_state); 897 - break; 898 - 899 - case AML_ELSE_OP: 900 - 901 - break; 902 - 903 - case AML_WHILE_OP: 904 - 905 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 906 - 907 - control_state = walk_state->control_state; 908 - if (control_state->common.value) { 909 - 910 - /* Predicate was true, the body of the loop was just executed */ 911 - 912 - /* 913 - * This loop counter mechanism allows the interpreter to escape 914 - * possibly infinite loops. This can occur in poorly written AML 915 - * when the hardware does not respond within a while loop and the 916 - * loop does not implement a timeout. 917 - */ 918 - control_state->control.loop_count++; 919 - if (control_state->control.loop_count > 920 - ACPI_MAX_LOOP_ITERATIONS) { 921 - status = AE_AML_INFINITE_LOOP; 922 - break; 923 - } 924 - 925 - /* 926 - * Go back and evaluate the predicate and maybe execute the loop 927 - * another time 928 - */ 929 - status = AE_CTRL_PENDING; 930 - walk_state->aml_last_while = 931 - control_state->control.aml_predicate_start; 932 - break; 933 - } 934 - 935 - /* Predicate was false, terminate this while loop */ 936 - 937 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 938 - "[WHILE_OP] termination! Op=%p\n", op)); 939 - 940 - /* Pop this control state and free it */ 941 - 942 - control_state = 943 - acpi_ut_pop_generic_state(&walk_state->control_state); 944 - acpi_ut_delete_generic_state(control_state); 945 - break; 946 - 947 - case AML_RETURN_OP: 948 - 949 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 950 - "[RETURN_OP] Op=%p Arg=%p\n", op, 951 - op->common.value.arg)); 952 - 953 - /* 954 - * One optional operand -- the return value 955 - * It can be either an immediate operand or a result that 956 - * has been bubbled up the tree 957 - */ 958 - if (op->common.value.arg) { 959 - 960 - /* Since we have a real Return(), delete any implicit return */ 961 - 962 - acpi_ds_clear_implicit_return(walk_state); 963 - 964 - /* Return statement has an immediate operand */ 965 - 966 - status = 967 - acpi_ds_create_operands(walk_state, 968 - op->common.value.arg); 969 - if (ACPI_FAILURE(status)) { 970 - return (status); 971 - } 972 - 973 - /* 974 - * If value being returned is a Reference (such as 975 - * an arg or local), resolve it now because it may 976 - * cease to exist at the end of the method. 977 - */ 978 - status = 979 - acpi_ex_resolve_to_value(&walk_state->operands[0], 980 - walk_state); 981 - if (ACPI_FAILURE(status)) { 982 - return (status); 983 - } 984 - 985 - /* 986 - * Get the return value and save as the last result 987 - * value. This is the only place where walk_state->return_desc 988 - * is set to anything other than zero! 989 - */ 990 - walk_state->return_desc = walk_state->operands[0]; 991 - } else if (walk_state->result_count) { 992 - 993 - /* Since we have a real Return(), delete any implicit return */ 994 - 995 - acpi_ds_clear_implicit_return(walk_state); 996 - 997 - /* 998 - * The return value has come from a previous calculation. 999 - * 1000 - * If value being returned is a Reference (such as 1001 - * an arg or local), resolve it now because it may 1002 - * cease to exist at the end of the method. 1003 - * 1004 - * Allow references created by the Index operator to return unchanged. 1005 - */ 1006 - if ((ACPI_GET_DESCRIPTOR_TYPE 1007 - (walk_state->results->results.obj_desc[0]) == 1008 - ACPI_DESC_TYPE_OPERAND) 1009 - && ((walk_state->results->results.obj_desc[0])-> 1010 - common.type == ACPI_TYPE_LOCAL_REFERENCE) 1011 - && ((walk_state->results->results.obj_desc[0])-> 1012 - reference.class != ACPI_REFCLASS_INDEX)) { 1013 - status = 1014 - acpi_ex_resolve_to_value(&walk_state-> 1015 - results->results. 1016 - obj_desc[0], 1017 - walk_state); 1018 - if (ACPI_FAILURE(status)) { 1019 - return (status); 1020 - } 1021 - } 1022 - 1023 - walk_state->return_desc = 1024 - walk_state->results->results.obj_desc[0]; 1025 - } else { 1026 - /* No return operand */ 1027 - 1028 - if (walk_state->num_operands) { 1029 - acpi_ut_remove_reference(walk_state-> 1030 - operands[0]); 1031 - } 1032 - 1033 - walk_state->operands[0] = NULL; 1034 - walk_state->num_operands = 0; 1035 - walk_state->return_desc = NULL; 1036 - } 1037 - 1038 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 1039 - "Completed RETURN_OP State=%p, RetVal=%p\n", 1040 - walk_state, walk_state->return_desc)); 1041 - 1042 - /* End the control method execution right now */ 1043 - 1044 - status = AE_CTRL_TERMINATE; 1045 - break; 1046 - 1047 - case AML_NOOP_OP: 1048 - 1049 - /* Just do nothing! */ 1050 - break; 1051 - 1052 - case AML_BREAK_POINT_OP: 1053 - 1054 - /* 1055 - * Set the single-step flag. This will cause the debugger (if present) 1056 - * to break to the console within the AML debugger at the start of the 1057 - * next AML instruction. 1058 - */ 1059 - ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE); 1060 - ACPI_DEBUGGER_EXEC(acpi_os_printf 1061 - ("**break** Executed AML BreakPoint opcode\n")); 1062 - 1063 - /* Call to the OSL in case OS wants a piece of the action */ 1064 - 1065 - status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT, 1066 - "Executed AML Breakpoint opcode"); 1067 - break; 1068 - 1069 - case AML_BREAK_OP: 1070 - case AML_CONTINUE_OP: /* ACPI 2.0 */ 1071 - 1072 - /* Pop and delete control states until we find a while */ 1073 - 1074 - while (walk_state->control_state && 1075 - (walk_state->control_state->control.opcode != 1076 - AML_WHILE_OP)) { 1077 - control_state = 1078 - acpi_ut_pop_generic_state(&walk_state-> 1079 - control_state); 1080 - acpi_ut_delete_generic_state(control_state); 1081 - } 1082 - 1083 - /* No while found? */ 1084 - 1085 - if (!walk_state->control_state) { 1086 - return (AE_AML_NO_WHILE); 1087 - } 1088 - 1089 - /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ 1090 - 1091 - walk_state->aml_last_while = 1092 - walk_state->control_state->control.package_end; 1093 - 1094 - /* Return status depending on opcode */ 1095 - 1096 - if (op->common.aml_opcode == AML_BREAK_OP) { 1097 - status = AE_CTRL_BREAK; 1098 - } else { 1099 - status = AE_CTRL_CONTINUE; 1100 - } 1101 - break; 1102 - 1103 - default: 1104 - 1105 - ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p", 1106 - op->common.aml_opcode, op)); 1107 - 1108 - status = AE_AML_BAD_OPCODE; 1109 - break; 1110 - } 1111 - 1112 - return (status); 1113 1116 }
+1 -669
drivers/acpi/acpica/dswload.c
··· 1 1 /****************************************************************************** 2 2 * 3 - * Module Name: dswload - Dispatcher namespace load callbacks 3 + * Module Name: dswload - Dispatcher first pass namespace load callbacks 4 4 * 5 5 *****************************************************************************/ 6 6 ··· 48 48 #include "acdispat.h" 49 49 #include "acinterp.h" 50 50 #include "acnamesp.h" 51 - #include "acevents.h" 52 51 53 52 #ifdef ACPI_ASL_COMPILER 54 53 #include <acpi/acdisasm.h> ··· 534 535 status = acpi_ds_scope_stack_pop(walk_state); 535 536 } 536 537 537 - return_ACPI_STATUS(status); 538 - } 539 - 540 - /******************************************************************************* 541 - * 542 - * FUNCTION: acpi_ds_load2_begin_op 543 - * 544 - * PARAMETERS: walk_state - Current state of the parse tree walk 545 - * out_op - Wher to return op if a new one is created 546 - * 547 - * RETURN: Status 548 - * 549 - * DESCRIPTION: Descending callback used during the loading of ACPI tables. 550 - * 551 - ******************************************************************************/ 552 - 553 - acpi_status 554 - acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, 555 - union acpi_parse_object **out_op) 556 - { 557 - union acpi_parse_object *op; 558 - struct acpi_namespace_node *node; 559 - acpi_status status; 560 - acpi_object_type object_type; 561 - char *buffer_ptr; 562 - u32 flags; 563 - 564 - ACPI_FUNCTION_TRACE(ds_load2_begin_op); 565 - 566 - op = walk_state->op; 567 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 568 - walk_state)); 569 - 570 - if (op) { 571 - if ((walk_state->control_state) && 572 - (walk_state->control_state->common.state == 573 - ACPI_CONTROL_CONDITIONAL_EXECUTING)) { 574 - 575 - /* We are executing a while loop outside of a method */ 576 - 577 - status = acpi_ds_exec_begin_op(walk_state, out_op); 578 - return_ACPI_STATUS(status); 579 - } 580 - 581 - /* We only care about Namespace opcodes here */ 582 - 583 - if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 584 - (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 585 - (!(walk_state->op_info->flags & AML_NAMED))) { 586 - return_ACPI_STATUS(AE_OK); 587 - } 588 - 589 - /* Get the name we are going to enter or lookup in the namespace */ 590 - 591 - if (walk_state->opcode == AML_INT_NAMEPATH_OP) { 592 - 593 - /* For Namepath op, get the path string */ 594 - 595 - buffer_ptr = op->common.value.string; 596 - if (!buffer_ptr) { 597 - 598 - /* No name, just exit */ 599 - 600 - return_ACPI_STATUS(AE_OK); 601 - } 602 - } else { 603 - /* Get name from the op */ 604 - 605 - buffer_ptr = ACPI_CAST_PTR(char, &op->named.name); 606 - } 607 - } else { 608 - /* Get the namestring from the raw AML */ 609 - 610 - buffer_ptr = 611 - acpi_ps_get_next_namestring(&walk_state->parser_state); 612 - } 613 - 614 - /* Map the opcode into an internal object type */ 615 - 616 - object_type = walk_state->op_info->object_type; 617 - 618 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 619 - "State=%p Op=%p Type=%X\n", walk_state, op, 620 - object_type)); 621 - 622 - switch (walk_state->opcode) { 623 - case AML_FIELD_OP: 624 - case AML_BANK_FIELD_OP: 625 - case AML_INDEX_FIELD_OP: 626 - 627 - node = NULL; 628 - status = AE_OK; 629 - break; 630 - 631 - case AML_INT_NAMEPATH_OP: 632 - /* 633 - * The name_path is an object reference to an existing object. 634 - * Don't enter the name into the namespace, but look it up 635 - * for use later. 636 - */ 637 - status = 638 - acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 639 - object_type, ACPI_IMODE_EXECUTE, 640 - ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 641 - break; 642 - 643 - case AML_SCOPE_OP: 644 - 645 - /* Special case for Scope(\) -> refers to the Root node */ 646 - 647 - if (op && (op->named.node == acpi_gbl_root_node)) { 648 - node = op->named.node; 649 - 650 - status = 651 - acpi_ds_scope_stack_push(node, object_type, 652 - walk_state); 653 - if (ACPI_FAILURE(status)) { 654 - return_ACPI_STATUS(status); 655 - } 656 - } else { 657 - /* 658 - * The Path is an object reference to an existing object. 659 - * Don't enter the name into the namespace, but look it up 660 - * for use later. 661 - */ 662 - status = 663 - acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 664 - object_type, ACPI_IMODE_EXECUTE, 665 - ACPI_NS_SEARCH_PARENT, walk_state, 666 - &(node)); 667 - if (ACPI_FAILURE(status)) { 668 - #ifdef ACPI_ASL_COMPILER 669 - if (status == AE_NOT_FOUND) { 670 - status = AE_OK; 671 - } else { 672 - ACPI_ERROR_NAMESPACE(buffer_ptr, 673 - status); 674 - } 675 - #else 676 - ACPI_ERROR_NAMESPACE(buffer_ptr, status); 677 - #endif 678 - return_ACPI_STATUS(status); 679 - } 680 - } 681 - 682 - /* 683 - * We must check to make sure that the target is 684 - * one of the opcodes that actually opens a scope 685 - */ 686 - switch (node->type) { 687 - case ACPI_TYPE_ANY: 688 - case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 689 - case ACPI_TYPE_DEVICE: 690 - case ACPI_TYPE_POWER: 691 - case ACPI_TYPE_PROCESSOR: 692 - case ACPI_TYPE_THERMAL: 693 - 694 - /* These are acceptable types */ 695 - break; 696 - 697 - case ACPI_TYPE_INTEGER: 698 - case ACPI_TYPE_STRING: 699 - case ACPI_TYPE_BUFFER: 700 - 701 - /* 702 - * These types we will allow, but we will change the type. 703 - * This enables some existing code of the form: 704 - * 705 - * Name (DEB, 0) 706 - * Scope (DEB) { ... } 707 - */ 708 - ACPI_WARNING((AE_INFO, 709 - "Type override - [%4.4s] had invalid type (%s) " 710 - "for Scope operator, changed to type ANY\n", 711 - acpi_ut_get_node_name(node), 712 - acpi_ut_get_type_name(node->type))); 713 - 714 - node->type = ACPI_TYPE_ANY; 715 - walk_state->scope_info->common.value = ACPI_TYPE_ANY; 716 - break; 717 - 718 - default: 719 - 720 - /* All other types are an error */ 721 - 722 - ACPI_ERROR((AE_INFO, 723 - "Invalid type (%s) for target of " 724 - "Scope operator [%4.4s] (Cannot override)", 725 - acpi_ut_get_type_name(node->type), 726 - acpi_ut_get_node_name(node))); 727 - 728 - return (AE_AML_OPERAND_TYPE); 729 - } 730 - break; 731 - 732 - default: 733 - 734 - /* All other opcodes */ 735 - 736 - if (op && op->common.node) { 737 - 738 - /* This op/node was previously entered into the namespace */ 739 - 740 - node = op->common.node; 741 - 742 - if (acpi_ns_opens_scope(object_type)) { 743 - status = 744 - acpi_ds_scope_stack_push(node, object_type, 745 - walk_state); 746 - if (ACPI_FAILURE(status)) { 747 - return_ACPI_STATUS(status); 748 - } 749 - } 750 - 751 - return_ACPI_STATUS(AE_OK); 752 - } 753 - 754 - /* 755 - * Enter the named type into the internal namespace. We enter the name 756 - * as we go downward in the parse tree. Any necessary subobjects that 757 - * involve arguments to the opcode must be created as we go back up the 758 - * parse tree later. 759 - * 760 - * Note: Name may already exist if we are executing a deferred opcode. 761 - */ 762 - if (walk_state->deferred_node) { 763 - 764 - /* This name is already in the namespace, get the node */ 765 - 766 - node = walk_state->deferred_node; 767 - status = AE_OK; 768 - break; 769 - } 770 - 771 - flags = ACPI_NS_NO_UPSEARCH; 772 - if (walk_state->pass_number == ACPI_IMODE_EXECUTE) { 773 - 774 - /* Execution mode, node cannot already exist, node is temporary */ 775 - 776 - flags |= ACPI_NS_ERROR_IF_FOUND; 777 - 778 - if (! 779 - (walk_state-> 780 - parse_flags & ACPI_PARSE_MODULE_LEVEL)) { 781 - flags |= ACPI_NS_TEMPORARY; 782 - } 783 - } 784 - 785 - /* Add new entry or lookup existing entry */ 786 - 787 - status = 788 - acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 789 - object_type, ACPI_IMODE_LOAD_PASS2, flags, 790 - walk_state, &node); 791 - 792 - if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) { 793 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 794 - "***New Node [%4.4s] %p is temporary\n", 795 - acpi_ut_get_node_name(node), node)); 796 - } 797 - break; 798 - } 799 - 800 - if (ACPI_FAILURE(status)) { 801 - ACPI_ERROR_NAMESPACE(buffer_ptr, status); 802 - return_ACPI_STATUS(status); 803 - } 804 - 805 - if (!op) { 806 - 807 - /* Create a new op */ 808 - 809 - op = acpi_ps_alloc_op(walk_state->opcode); 810 - if (!op) { 811 - return_ACPI_STATUS(AE_NO_MEMORY); 812 - } 813 - 814 - /* Initialize the new op */ 815 - 816 - if (node) { 817 - op->named.name = node->name.integer; 818 - } 819 - *out_op = op; 820 - } 821 - 822 - /* 823 - * Put the Node in the "op" object that the parser uses, so we 824 - * can get it again quickly when this scope is closed 825 - */ 826 - op->common.node = node; 827 - return_ACPI_STATUS(status); 828 - } 829 - 830 - /******************************************************************************* 831 - * 832 - * FUNCTION: acpi_ds_load2_end_op 833 - * 834 - * PARAMETERS: walk_state - Current state of the parse tree walk 835 - * 836 - * RETURN: Status 837 - * 838 - * DESCRIPTION: Ascending callback used during the loading of the namespace, 839 - * both control methods and everything else. 840 - * 841 - ******************************************************************************/ 842 - 843 - acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) 844 - { 845 - union acpi_parse_object *op; 846 - acpi_status status = AE_OK; 847 - acpi_object_type object_type; 848 - struct acpi_namespace_node *node; 849 - union acpi_parse_object *arg; 850 - struct acpi_namespace_node *new_node; 851 - #ifndef ACPI_NO_METHOD_EXECUTION 852 - u32 i; 853 - u8 region_space; 854 - #endif 855 - 856 - ACPI_FUNCTION_TRACE(ds_load2_end_op); 857 - 858 - op = walk_state->op; 859 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 860 - walk_state->op_info->name, op, walk_state)); 861 - 862 - /* Check if opcode had an associated namespace object */ 863 - 864 - if (!(walk_state->op_info->flags & AML_NSOBJECT)) { 865 - return_ACPI_STATUS(AE_OK); 866 - } 867 - 868 - if (op->common.aml_opcode == AML_SCOPE_OP) { 869 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 870 - "Ending scope Op=%p State=%p\n", op, 871 - walk_state)); 872 - } 873 - 874 - object_type = walk_state->op_info->object_type; 875 - 876 - /* 877 - * Get the Node/name from the earlier lookup 878 - * (It was saved in the *op structure) 879 - */ 880 - node = op->common.node; 881 - 882 - /* 883 - * Put the Node on the object stack (Contains the ACPI Name of 884 - * this object) 885 - */ 886 - walk_state->operands[0] = (void *)node; 887 - walk_state->num_operands = 1; 888 - 889 - /* Pop the scope stack */ 890 - 891 - if (acpi_ns_opens_scope(object_type) && 892 - (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 893 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 894 - "(%s) Popping scope for Op %p\n", 895 - acpi_ut_get_type_name(object_type), op)); 896 - 897 - status = acpi_ds_scope_stack_pop(walk_state); 898 - if (ACPI_FAILURE(status)) { 899 - goto cleanup; 900 - } 901 - } 902 - 903 - /* 904 - * Named operations are as follows: 905 - * 906 - * AML_ALIAS 907 - * AML_BANKFIELD 908 - * AML_CREATEBITFIELD 909 - * AML_CREATEBYTEFIELD 910 - * AML_CREATEDWORDFIELD 911 - * AML_CREATEFIELD 912 - * AML_CREATEQWORDFIELD 913 - * AML_CREATEWORDFIELD 914 - * AML_DATA_REGION 915 - * AML_DEVICE 916 - * AML_EVENT 917 - * AML_FIELD 918 - * AML_INDEXFIELD 919 - * AML_METHOD 920 - * AML_METHODCALL 921 - * AML_MUTEX 922 - * AML_NAME 923 - * AML_NAMEDFIELD 924 - * AML_OPREGION 925 - * AML_POWERRES 926 - * AML_PROCESSOR 927 - * AML_SCOPE 928 - * AML_THERMALZONE 929 - */ 930 - 931 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 932 - "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", 933 - acpi_ps_get_opcode_name(op->common.aml_opcode), 934 - walk_state, op, node)); 935 - 936 - /* Decode the opcode */ 937 - 938 - arg = op->common.value.arg; 939 - 940 - switch (walk_state->op_info->type) { 941 - #ifndef ACPI_NO_METHOD_EXECUTION 942 - 943 - case AML_TYPE_CREATE_FIELD: 944 - /* 945 - * Create the field object, but the field buffer and index must 946 - * be evaluated later during the execution phase 947 - */ 948 - status = acpi_ds_create_buffer_field(op, walk_state); 949 - break; 950 - 951 - case AML_TYPE_NAMED_FIELD: 952 - /* 953 - * If we are executing a method, initialize the field 954 - */ 955 - if (walk_state->method_node) { 956 - status = acpi_ds_init_field_objects(op, walk_state); 957 - } 958 - 959 - switch (op->common.aml_opcode) { 960 - case AML_INDEX_FIELD_OP: 961 - 962 - status = 963 - acpi_ds_create_index_field(op, 964 - (acpi_handle) arg-> 965 - common.node, walk_state); 966 - break; 967 - 968 - case AML_BANK_FIELD_OP: 969 - 970 - status = 971 - acpi_ds_create_bank_field(op, arg->common.node, 972 - walk_state); 973 - break; 974 - 975 - case AML_FIELD_OP: 976 - 977 - status = 978 - acpi_ds_create_field(op, arg->common.node, 979 - walk_state); 980 - break; 981 - 982 - default: 983 - /* All NAMED_FIELD opcodes must be handled above */ 984 - break; 985 - } 986 - break; 987 - 988 - case AML_TYPE_NAMED_SIMPLE: 989 - 990 - status = acpi_ds_create_operands(walk_state, arg); 991 - if (ACPI_FAILURE(status)) { 992 - goto cleanup; 993 - } 994 - 995 - switch (op->common.aml_opcode) { 996 - case AML_PROCESSOR_OP: 997 - 998 - status = acpi_ex_create_processor(walk_state); 999 - break; 1000 - 1001 - case AML_POWER_RES_OP: 1002 - 1003 - status = acpi_ex_create_power_resource(walk_state); 1004 - break; 1005 - 1006 - case AML_MUTEX_OP: 1007 - 1008 - status = acpi_ex_create_mutex(walk_state); 1009 - break; 1010 - 1011 - case AML_EVENT_OP: 1012 - 1013 - status = acpi_ex_create_event(walk_state); 1014 - break; 1015 - 1016 - case AML_ALIAS_OP: 1017 - 1018 - status = acpi_ex_create_alias(walk_state); 1019 - break; 1020 - 1021 - default: 1022 - /* Unknown opcode */ 1023 - 1024 - status = AE_OK; 1025 - goto cleanup; 1026 - } 1027 - 1028 - /* Delete operands */ 1029 - 1030 - for (i = 1; i < walk_state->num_operands; i++) { 1031 - acpi_ut_remove_reference(walk_state->operands[i]); 1032 - walk_state->operands[i] = NULL; 1033 - } 1034 - 1035 - break; 1036 - #endif /* ACPI_NO_METHOD_EXECUTION */ 1037 - 1038 - case AML_TYPE_NAMED_COMPLEX: 1039 - 1040 - switch (op->common.aml_opcode) { 1041 - #ifndef ACPI_NO_METHOD_EXECUTION 1042 - case AML_REGION_OP: 1043 - case AML_DATA_REGION_OP: 1044 - 1045 - if (op->common.aml_opcode == AML_REGION_OP) { 1046 - region_space = (acpi_adr_space_type) 1047 - ((op->common.value.arg)->common.value. 1048 - integer); 1049 - } else { 1050 - region_space = REGION_DATA_TABLE; 1051 - } 1052 - 1053 - /* 1054 - * The op_region is not fully parsed at this time. The only valid 1055 - * argument is the space_id. (We must save the address of the 1056 - * AML of the address and length operands) 1057 - * 1058 - * If we have a valid region, initialize it. The namespace is 1059 - * unlocked at this point. 1060 - * 1061 - * Need to unlock interpreter if it is locked (if we are running 1062 - * a control method), in order to allow _REG methods to be run 1063 - * during acpi_ev_initialize_region. 1064 - */ 1065 - if (walk_state->method_node) { 1066 - /* 1067 - * Executing a method: initialize the region and unlock 1068 - * the interpreter 1069 - */ 1070 - status = 1071 - acpi_ex_create_region(op->named.data, 1072 - op->named.length, 1073 - region_space, 1074 - walk_state); 1075 - if (ACPI_FAILURE(status)) { 1076 - return (status); 1077 - } 1078 - 1079 - acpi_ex_exit_interpreter(); 1080 - } 1081 - 1082 - status = 1083 - acpi_ev_initialize_region 1084 - (acpi_ns_get_attached_object(node), FALSE); 1085 - if (walk_state->method_node) { 1086 - acpi_ex_enter_interpreter(); 1087 - } 1088 - 1089 - if (ACPI_FAILURE(status)) { 1090 - /* 1091 - * If AE_NOT_EXIST is returned, it is not fatal 1092 - * because many regions get created before a handler 1093 - * is installed for said region. 1094 - */ 1095 - if (AE_NOT_EXIST == status) { 1096 - status = AE_OK; 1097 - } 1098 - } 1099 - break; 1100 - 1101 - case AML_NAME_OP: 1102 - 1103 - status = acpi_ds_create_node(walk_state, node, op); 1104 - break; 1105 - 1106 - case AML_METHOD_OP: 1107 - /* 1108 - * method_op pkg_length name_string method_flags term_list 1109 - * 1110 - * Note: We must create the method node/object pair as soon as we 1111 - * see the method declaration. This allows later pass1 parsing 1112 - * of invocations of the method (need to know the number of 1113 - * arguments.) 1114 - */ 1115 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 1116 - "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 1117 - walk_state, op, op->named.node)); 1118 - 1119 - if (!acpi_ns_get_attached_object(op->named.node)) { 1120 - walk_state->operands[0] = 1121 - ACPI_CAST_PTR(void, op->named.node); 1122 - walk_state->num_operands = 1; 1123 - 1124 - status = 1125 - acpi_ds_create_operands(walk_state, 1126 - op->common.value. 1127 - arg); 1128 - if (ACPI_SUCCESS(status)) { 1129 - status = 1130 - acpi_ex_create_method(op->named. 1131 - data, 1132 - op->named. 1133 - length, 1134 - walk_state); 1135 - } 1136 - walk_state->operands[0] = NULL; 1137 - walk_state->num_operands = 0; 1138 - 1139 - if (ACPI_FAILURE(status)) { 1140 - return_ACPI_STATUS(status); 1141 - } 1142 - } 1143 - break; 1144 - 1145 - #endif /* ACPI_NO_METHOD_EXECUTION */ 1146 - 1147 - default: 1148 - /* All NAMED_COMPLEX opcodes must be handled above */ 1149 - break; 1150 - } 1151 - break; 1152 - 1153 - case AML_CLASS_INTERNAL: 1154 - 1155 - /* case AML_INT_NAMEPATH_OP: */ 1156 - break; 1157 - 1158 - case AML_CLASS_METHOD_CALL: 1159 - 1160 - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 1161 - "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", 1162 - walk_state, op, node)); 1163 - 1164 - /* 1165 - * Lookup the method name and save the Node 1166 - */ 1167 - status = 1168 - acpi_ns_lookup(walk_state->scope_info, 1169 - arg->common.value.string, ACPI_TYPE_ANY, 1170 - ACPI_IMODE_LOAD_PASS2, 1171 - ACPI_NS_SEARCH_PARENT | 1172 - ACPI_NS_DONT_OPEN_SCOPE, walk_state, 1173 - &(new_node)); 1174 - if (ACPI_SUCCESS(status)) { 1175 - /* 1176 - * Make sure that what we found is indeed a method 1177 - * We didn't search for a method on purpose, to see if the name 1178 - * would resolve 1179 - */ 1180 - if (new_node->type != ACPI_TYPE_METHOD) { 1181 - status = AE_AML_OPERAND_TYPE; 1182 - } 1183 - 1184 - /* We could put the returned object (Node) on the object stack for 1185 - * later, but for now, we will put it in the "op" object that the 1186 - * parser uses, so we can get it again at the end of this scope 1187 - */ 1188 - op->common.node = new_node; 1189 - } else { 1190 - ACPI_ERROR_NAMESPACE(arg->common.value.string, status); 1191 - } 1192 - break; 1193 - 1194 - default: 1195 - break; 1196 - } 1197 - 1198 - cleanup: 1199 - 1200 - /* Remove the Node pushed at the very beginning */ 1201 - 1202 - walk_state->operands[0] = NULL; 1203 - walk_state->num_operands = 0; 1204 538 return_ACPI_STATUS(status); 1205 539 }
+720
drivers/acpi/acpica/dswload2.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: dswload2 - Dispatcher second pass namespace load callbacks 4 + * 5 + *****************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2011, Intel Corp. 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include "accommon.h" 46 + #include "acparser.h" 47 + #include "amlcode.h" 48 + #include "acdispat.h" 49 + #include "acinterp.h" 50 + #include "acnamesp.h" 51 + #include "acevents.h" 52 + 53 + #define _COMPONENT ACPI_DISPATCHER 54 + ACPI_MODULE_NAME("dswload2") 55 + 56 + /******************************************************************************* 57 + * 58 + * FUNCTION: acpi_ds_load2_begin_op 59 + * 60 + * PARAMETERS: walk_state - Current state of the parse tree walk 61 + * out_op - Wher to return op if a new one is created 62 + * 63 + * RETURN: Status 64 + * 65 + * DESCRIPTION: Descending callback used during the loading of ACPI tables. 66 + * 67 + ******************************************************************************/ 68 + acpi_status 69 + acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, 70 + union acpi_parse_object **out_op) 71 + { 72 + union acpi_parse_object *op; 73 + struct acpi_namespace_node *node; 74 + acpi_status status; 75 + acpi_object_type object_type; 76 + char *buffer_ptr; 77 + u32 flags; 78 + 79 + ACPI_FUNCTION_TRACE(ds_load2_begin_op); 80 + 81 + op = walk_state->op; 82 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 83 + walk_state)); 84 + 85 + if (op) { 86 + if ((walk_state->control_state) && 87 + (walk_state->control_state->common.state == 88 + ACPI_CONTROL_CONDITIONAL_EXECUTING)) { 89 + 90 + /* We are executing a while loop outside of a method */ 91 + 92 + status = acpi_ds_exec_begin_op(walk_state, out_op); 93 + return_ACPI_STATUS(status); 94 + } 95 + 96 + /* We only care about Namespace opcodes here */ 97 + 98 + if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 99 + (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 100 + (!(walk_state->op_info->flags & AML_NAMED))) { 101 + return_ACPI_STATUS(AE_OK); 102 + } 103 + 104 + /* Get the name we are going to enter or lookup in the namespace */ 105 + 106 + if (walk_state->opcode == AML_INT_NAMEPATH_OP) { 107 + 108 + /* For Namepath op, get the path string */ 109 + 110 + buffer_ptr = op->common.value.string; 111 + if (!buffer_ptr) { 112 + 113 + /* No name, just exit */ 114 + 115 + return_ACPI_STATUS(AE_OK); 116 + } 117 + } else { 118 + /* Get name from the op */ 119 + 120 + buffer_ptr = ACPI_CAST_PTR(char, &op->named.name); 121 + } 122 + } else { 123 + /* Get the namestring from the raw AML */ 124 + 125 + buffer_ptr = 126 + acpi_ps_get_next_namestring(&walk_state->parser_state); 127 + } 128 + 129 + /* Map the opcode into an internal object type */ 130 + 131 + object_type = walk_state->op_info->object_type; 132 + 133 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 134 + "State=%p Op=%p Type=%X\n", walk_state, op, 135 + object_type)); 136 + 137 + switch (walk_state->opcode) { 138 + case AML_FIELD_OP: 139 + case AML_BANK_FIELD_OP: 140 + case AML_INDEX_FIELD_OP: 141 + 142 + node = NULL; 143 + status = AE_OK; 144 + break; 145 + 146 + case AML_INT_NAMEPATH_OP: 147 + /* 148 + * The name_path is an object reference to an existing object. 149 + * Don't enter the name into the namespace, but look it up 150 + * for use later. 151 + */ 152 + status = 153 + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 154 + object_type, ACPI_IMODE_EXECUTE, 155 + ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 156 + break; 157 + 158 + case AML_SCOPE_OP: 159 + 160 + /* Special case for Scope(\) -> refers to the Root node */ 161 + 162 + if (op && (op->named.node == acpi_gbl_root_node)) { 163 + node = op->named.node; 164 + 165 + status = 166 + acpi_ds_scope_stack_push(node, object_type, 167 + walk_state); 168 + if (ACPI_FAILURE(status)) { 169 + return_ACPI_STATUS(status); 170 + } 171 + } else { 172 + /* 173 + * The Path is an object reference to an existing object. 174 + * Don't enter the name into the namespace, but look it up 175 + * for use later. 176 + */ 177 + status = 178 + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 179 + object_type, ACPI_IMODE_EXECUTE, 180 + ACPI_NS_SEARCH_PARENT, walk_state, 181 + &(node)); 182 + if (ACPI_FAILURE(status)) { 183 + #ifdef ACPI_ASL_COMPILER 184 + if (status == AE_NOT_FOUND) { 185 + status = AE_OK; 186 + } else { 187 + ACPI_ERROR_NAMESPACE(buffer_ptr, 188 + status); 189 + } 190 + #else 191 + ACPI_ERROR_NAMESPACE(buffer_ptr, status); 192 + #endif 193 + return_ACPI_STATUS(status); 194 + } 195 + } 196 + 197 + /* 198 + * We must check to make sure that the target is 199 + * one of the opcodes that actually opens a scope 200 + */ 201 + switch (node->type) { 202 + case ACPI_TYPE_ANY: 203 + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 204 + case ACPI_TYPE_DEVICE: 205 + case ACPI_TYPE_POWER: 206 + case ACPI_TYPE_PROCESSOR: 207 + case ACPI_TYPE_THERMAL: 208 + 209 + /* These are acceptable types */ 210 + break; 211 + 212 + case ACPI_TYPE_INTEGER: 213 + case ACPI_TYPE_STRING: 214 + case ACPI_TYPE_BUFFER: 215 + 216 + /* 217 + * These types we will allow, but we will change the type. 218 + * This enables some existing code of the form: 219 + * 220 + * Name (DEB, 0) 221 + * Scope (DEB) { ... } 222 + */ 223 + ACPI_WARNING((AE_INFO, 224 + "Type override - [%4.4s] had invalid type (%s) " 225 + "for Scope operator, changed to type ANY\n", 226 + acpi_ut_get_node_name(node), 227 + acpi_ut_get_type_name(node->type))); 228 + 229 + node->type = ACPI_TYPE_ANY; 230 + walk_state->scope_info->common.value = ACPI_TYPE_ANY; 231 + break; 232 + 233 + default: 234 + 235 + /* All other types are an error */ 236 + 237 + ACPI_ERROR((AE_INFO, 238 + "Invalid type (%s) for target of " 239 + "Scope operator [%4.4s] (Cannot override)", 240 + acpi_ut_get_type_name(node->type), 241 + acpi_ut_get_node_name(node))); 242 + 243 + return (AE_AML_OPERAND_TYPE); 244 + } 245 + break; 246 + 247 + default: 248 + 249 + /* All other opcodes */ 250 + 251 + if (op && op->common.node) { 252 + 253 + /* This op/node was previously entered into the namespace */ 254 + 255 + node = op->common.node; 256 + 257 + if (acpi_ns_opens_scope(object_type)) { 258 + status = 259 + acpi_ds_scope_stack_push(node, object_type, 260 + walk_state); 261 + if (ACPI_FAILURE(status)) { 262 + return_ACPI_STATUS(status); 263 + } 264 + } 265 + 266 + return_ACPI_STATUS(AE_OK); 267 + } 268 + 269 + /* 270 + * Enter the named type into the internal namespace. We enter the name 271 + * as we go downward in the parse tree. Any necessary subobjects that 272 + * involve arguments to the opcode must be created as we go back up the 273 + * parse tree later. 274 + * 275 + * Note: Name may already exist if we are executing a deferred opcode. 276 + */ 277 + if (walk_state->deferred_node) { 278 + 279 + /* This name is already in the namespace, get the node */ 280 + 281 + node = walk_state->deferred_node; 282 + status = AE_OK; 283 + break; 284 + } 285 + 286 + flags = ACPI_NS_NO_UPSEARCH; 287 + if (walk_state->pass_number == ACPI_IMODE_EXECUTE) { 288 + 289 + /* Execution mode, node cannot already exist, node is temporary */ 290 + 291 + flags |= ACPI_NS_ERROR_IF_FOUND; 292 + 293 + if (! 294 + (walk_state-> 295 + parse_flags & ACPI_PARSE_MODULE_LEVEL)) { 296 + flags |= ACPI_NS_TEMPORARY; 297 + } 298 + } 299 + 300 + /* Add new entry or lookup existing entry */ 301 + 302 + status = 303 + acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 304 + object_type, ACPI_IMODE_LOAD_PASS2, flags, 305 + walk_state, &node); 306 + 307 + if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) { 308 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 309 + "***New Node [%4.4s] %p is temporary\n", 310 + acpi_ut_get_node_name(node), node)); 311 + } 312 + break; 313 + } 314 + 315 + if (ACPI_FAILURE(status)) { 316 + ACPI_ERROR_NAMESPACE(buffer_ptr, status); 317 + return_ACPI_STATUS(status); 318 + } 319 + 320 + if (!op) { 321 + 322 + /* Create a new op */ 323 + 324 + op = acpi_ps_alloc_op(walk_state->opcode); 325 + if (!op) { 326 + return_ACPI_STATUS(AE_NO_MEMORY); 327 + } 328 + 329 + /* Initialize the new op */ 330 + 331 + if (node) { 332 + op->named.name = node->name.integer; 333 + } 334 + *out_op = op; 335 + } 336 + 337 + /* 338 + * Put the Node in the "op" object that the parser uses, so we 339 + * can get it again quickly when this scope is closed 340 + */ 341 + op->common.node = node; 342 + return_ACPI_STATUS(status); 343 + } 344 + 345 + /******************************************************************************* 346 + * 347 + * FUNCTION: acpi_ds_load2_end_op 348 + * 349 + * PARAMETERS: walk_state - Current state of the parse tree walk 350 + * 351 + * RETURN: Status 352 + * 353 + * DESCRIPTION: Ascending callback used during the loading of the namespace, 354 + * both control methods and everything else. 355 + * 356 + ******************************************************************************/ 357 + 358 + acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) 359 + { 360 + union acpi_parse_object *op; 361 + acpi_status status = AE_OK; 362 + acpi_object_type object_type; 363 + struct acpi_namespace_node *node; 364 + union acpi_parse_object *arg; 365 + struct acpi_namespace_node *new_node; 366 + #ifndef ACPI_NO_METHOD_EXECUTION 367 + u32 i; 368 + u8 region_space; 369 + #endif 370 + 371 + ACPI_FUNCTION_TRACE(ds_load2_end_op); 372 + 373 + op = walk_state->op; 374 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 375 + walk_state->op_info->name, op, walk_state)); 376 + 377 + /* Check if opcode had an associated namespace object */ 378 + 379 + if (!(walk_state->op_info->flags & AML_NSOBJECT)) { 380 + return_ACPI_STATUS(AE_OK); 381 + } 382 + 383 + if (op->common.aml_opcode == AML_SCOPE_OP) { 384 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 385 + "Ending scope Op=%p State=%p\n", op, 386 + walk_state)); 387 + } 388 + 389 + object_type = walk_state->op_info->object_type; 390 + 391 + /* 392 + * Get the Node/name from the earlier lookup 393 + * (It was saved in the *op structure) 394 + */ 395 + node = op->common.node; 396 + 397 + /* 398 + * Put the Node on the object stack (Contains the ACPI Name of 399 + * this object) 400 + */ 401 + walk_state->operands[0] = (void *)node; 402 + walk_state->num_operands = 1; 403 + 404 + /* Pop the scope stack */ 405 + 406 + if (acpi_ns_opens_scope(object_type) && 407 + (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 408 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 409 + "(%s) Popping scope for Op %p\n", 410 + acpi_ut_get_type_name(object_type), op)); 411 + 412 + status = acpi_ds_scope_stack_pop(walk_state); 413 + if (ACPI_FAILURE(status)) { 414 + goto cleanup; 415 + } 416 + } 417 + 418 + /* 419 + * Named operations are as follows: 420 + * 421 + * AML_ALIAS 422 + * AML_BANKFIELD 423 + * AML_CREATEBITFIELD 424 + * AML_CREATEBYTEFIELD 425 + * AML_CREATEDWORDFIELD 426 + * AML_CREATEFIELD 427 + * AML_CREATEQWORDFIELD 428 + * AML_CREATEWORDFIELD 429 + * AML_DATA_REGION 430 + * AML_DEVICE 431 + * AML_EVENT 432 + * AML_FIELD 433 + * AML_INDEXFIELD 434 + * AML_METHOD 435 + * AML_METHODCALL 436 + * AML_MUTEX 437 + * AML_NAME 438 + * AML_NAMEDFIELD 439 + * AML_OPREGION 440 + * AML_POWERRES 441 + * AML_PROCESSOR 442 + * AML_SCOPE 443 + * AML_THERMALZONE 444 + */ 445 + 446 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 447 + "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", 448 + acpi_ps_get_opcode_name(op->common.aml_opcode), 449 + walk_state, op, node)); 450 + 451 + /* Decode the opcode */ 452 + 453 + arg = op->common.value.arg; 454 + 455 + switch (walk_state->op_info->type) { 456 + #ifndef ACPI_NO_METHOD_EXECUTION 457 + 458 + case AML_TYPE_CREATE_FIELD: 459 + /* 460 + * Create the field object, but the field buffer and index must 461 + * be evaluated later during the execution phase 462 + */ 463 + status = acpi_ds_create_buffer_field(op, walk_state); 464 + break; 465 + 466 + case AML_TYPE_NAMED_FIELD: 467 + /* 468 + * If we are executing a method, initialize the field 469 + */ 470 + if (walk_state->method_node) { 471 + status = acpi_ds_init_field_objects(op, walk_state); 472 + } 473 + 474 + switch (op->common.aml_opcode) { 475 + case AML_INDEX_FIELD_OP: 476 + 477 + status = 478 + acpi_ds_create_index_field(op, 479 + (acpi_handle) arg-> 480 + common.node, walk_state); 481 + break; 482 + 483 + case AML_BANK_FIELD_OP: 484 + 485 + status = 486 + acpi_ds_create_bank_field(op, arg->common.node, 487 + walk_state); 488 + break; 489 + 490 + case AML_FIELD_OP: 491 + 492 + status = 493 + acpi_ds_create_field(op, arg->common.node, 494 + walk_state); 495 + break; 496 + 497 + default: 498 + /* All NAMED_FIELD opcodes must be handled above */ 499 + break; 500 + } 501 + break; 502 + 503 + case AML_TYPE_NAMED_SIMPLE: 504 + 505 + status = acpi_ds_create_operands(walk_state, arg); 506 + if (ACPI_FAILURE(status)) { 507 + goto cleanup; 508 + } 509 + 510 + switch (op->common.aml_opcode) { 511 + case AML_PROCESSOR_OP: 512 + 513 + status = acpi_ex_create_processor(walk_state); 514 + break; 515 + 516 + case AML_POWER_RES_OP: 517 + 518 + status = acpi_ex_create_power_resource(walk_state); 519 + break; 520 + 521 + case AML_MUTEX_OP: 522 + 523 + status = acpi_ex_create_mutex(walk_state); 524 + break; 525 + 526 + case AML_EVENT_OP: 527 + 528 + status = acpi_ex_create_event(walk_state); 529 + break; 530 + 531 + case AML_ALIAS_OP: 532 + 533 + status = acpi_ex_create_alias(walk_state); 534 + break; 535 + 536 + default: 537 + /* Unknown opcode */ 538 + 539 + status = AE_OK; 540 + goto cleanup; 541 + } 542 + 543 + /* Delete operands */ 544 + 545 + for (i = 1; i < walk_state->num_operands; i++) { 546 + acpi_ut_remove_reference(walk_state->operands[i]); 547 + walk_state->operands[i] = NULL; 548 + } 549 + 550 + break; 551 + #endif /* ACPI_NO_METHOD_EXECUTION */ 552 + 553 + case AML_TYPE_NAMED_COMPLEX: 554 + 555 + switch (op->common.aml_opcode) { 556 + #ifndef ACPI_NO_METHOD_EXECUTION 557 + case AML_REGION_OP: 558 + case AML_DATA_REGION_OP: 559 + 560 + if (op->common.aml_opcode == AML_REGION_OP) { 561 + region_space = (acpi_adr_space_type) 562 + ((op->common.value.arg)->common.value. 563 + integer); 564 + } else { 565 + region_space = REGION_DATA_TABLE; 566 + } 567 + 568 + /* 569 + * The op_region is not fully parsed at this time. The only valid 570 + * argument is the space_id. (We must save the address of the 571 + * AML of the address and length operands) 572 + * 573 + * If we have a valid region, initialize it. The namespace is 574 + * unlocked at this point. 575 + * 576 + * Need to unlock interpreter if it is locked (if we are running 577 + * a control method), in order to allow _REG methods to be run 578 + * during acpi_ev_initialize_region. 579 + */ 580 + if (walk_state->method_node) { 581 + /* 582 + * Executing a method: initialize the region and unlock 583 + * the interpreter 584 + */ 585 + status = 586 + acpi_ex_create_region(op->named.data, 587 + op->named.length, 588 + region_space, 589 + walk_state); 590 + if (ACPI_FAILURE(status)) { 591 + return (status); 592 + } 593 + 594 + acpi_ex_exit_interpreter(); 595 + } 596 + 597 + status = 598 + acpi_ev_initialize_region 599 + (acpi_ns_get_attached_object(node), FALSE); 600 + if (walk_state->method_node) { 601 + acpi_ex_enter_interpreter(); 602 + } 603 + 604 + if (ACPI_FAILURE(status)) { 605 + /* 606 + * If AE_NOT_EXIST is returned, it is not fatal 607 + * because many regions get created before a handler 608 + * is installed for said region. 609 + */ 610 + if (AE_NOT_EXIST == status) { 611 + status = AE_OK; 612 + } 613 + } 614 + break; 615 + 616 + case AML_NAME_OP: 617 + 618 + status = acpi_ds_create_node(walk_state, node, op); 619 + break; 620 + 621 + case AML_METHOD_OP: 622 + /* 623 + * method_op pkg_length name_string method_flags term_list 624 + * 625 + * Note: We must create the method node/object pair as soon as we 626 + * see the method declaration. This allows later pass1 parsing 627 + * of invocations of the method (need to know the number of 628 + * arguments.) 629 + */ 630 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 631 + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 632 + walk_state, op, op->named.node)); 633 + 634 + if (!acpi_ns_get_attached_object(op->named.node)) { 635 + walk_state->operands[0] = 636 + ACPI_CAST_PTR(void, op->named.node); 637 + walk_state->num_operands = 1; 638 + 639 + status = 640 + acpi_ds_create_operands(walk_state, 641 + op->common.value. 642 + arg); 643 + if (ACPI_SUCCESS(status)) { 644 + status = 645 + acpi_ex_create_method(op->named. 646 + data, 647 + op->named. 648 + length, 649 + walk_state); 650 + } 651 + walk_state->operands[0] = NULL; 652 + walk_state->num_operands = 0; 653 + 654 + if (ACPI_FAILURE(status)) { 655 + return_ACPI_STATUS(status); 656 + } 657 + } 658 + break; 659 + 660 + #endif /* ACPI_NO_METHOD_EXECUTION */ 661 + 662 + default: 663 + /* All NAMED_COMPLEX opcodes must be handled above */ 664 + break; 665 + } 666 + break; 667 + 668 + case AML_CLASS_INTERNAL: 669 + 670 + /* case AML_INT_NAMEPATH_OP: */ 671 + break; 672 + 673 + case AML_CLASS_METHOD_CALL: 674 + 675 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 676 + "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", 677 + walk_state, op, node)); 678 + 679 + /* 680 + * Lookup the method name and save the Node 681 + */ 682 + status = 683 + acpi_ns_lookup(walk_state->scope_info, 684 + arg->common.value.string, ACPI_TYPE_ANY, 685 + ACPI_IMODE_LOAD_PASS2, 686 + ACPI_NS_SEARCH_PARENT | 687 + ACPI_NS_DONT_OPEN_SCOPE, walk_state, 688 + &(new_node)); 689 + if (ACPI_SUCCESS(status)) { 690 + /* 691 + * Make sure that what we found is indeed a method 692 + * We didn't search for a method on purpose, to see if the name 693 + * would resolve 694 + */ 695 + if (new_node->type != ACPI_TYPE_METHOD) { 696 + status = AE_AML_OPERAND_TYPE; 697 + } 698 + 699 + /* We could put the returned object (Node) on the object stack for 700 + * later, but for now, we will put it in the "op" object that the 701 + * parser uses, so we can get it again at the end of this scope 702 + */ 703 + op->common.node = new_node; 704 + } else { 705 + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); 706 + } 707 + break; 708 + 709 + default: 710 + break; 711 + } 712 + 713 + cleanup: 714 + 715 + /* Remove the Node pushed at the very beginning */ 716 + 717 + walk_state->operands[0] = NULL; 718 + walk_state->num_operands = 0; 719 + return_ACPI_STATUS(status); 720 + }
+9
drivers/acpi/acpica/evgpe.c
··· 373 373 374 374 gpe_register_info = &gpe_block->register_info[i]; 375 375 376 + /* 377 + * Optimization: If there are no GPEs enabled within this 378 + * register, we can safely ignore the entire register. 379 + */ 380 + if (!(gpe_register_info->enable_for_run | 381 + gpe_register_info->enable_for_wake)) { 382 + continue; 383 + } 384 + 376 385 /* Read the Status Register */ 377 386 378 387 status =
+2
drivers/acpi/acpica/evregion.c
··· 231 231 } 232 232 } 233 233 234 + acpi_gbl_reg_methods_executed = TRUE; 235 + 234 236 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 235 237 return_ACPI_STATUS(status); 236 238 }
+32 -2
drivers/acpi/acpica/evxfregn.c
··· 110 110 goto unlock_and_exit; 111 111 } 112 112 113 - /* Run all _REG methods for this address space */ 113 + /* 114 + * For the default space_iDs, (the IDs for which there are default region handlers 115 + * installed) Only execute the _REG methods if the global initialization _REG 116 + * methods have already been run (via acpi_initialize_objects). In other words, 117 + * we will defer the execution of the _REG methods for these space_iDs until 118 + * execution of acpi_initialize_objects. This is done because we need the handlers 119 + * for the default spaces (mem/io/pci/table) to be installed before we can run 120 + * any control methods (or _REG methods). There is known BIOS code that depends 121 + * on this. 122 + * 123 + * For all other space_iDs, we can safely execute the _REG methods immediately. 124 + * This means that for IDs like embedded_controller, this function should be called 125 + * only after acpi_enable_subsystem has been called. 126 + */ 127 + switch (space_id) { 128 + case ACPI_ADR_SPACE_SYSTEM_MEMORY: 129 + case ACPI_ADR_SPACE_SYSTEM_IO: 130 + case ACPI_ADR_SPACE_PCI_CONFIG: 131 + case ACPI_ADR_SPACE_DATA_TABLE: 114 132 115 - status = acpi_ev_execute_reg_methods(node, space_id); 133 + if (acpi_gbl_reg_methods_executed) { 134 + 135 + /* Run all _REG methods for this address space */ 136 + 137 + status = acpi_ev_execute_reg_methods(node, space_id); 138 + } 139 + break; 140 + 141 + default: 142 + 143 + status = acpi_ev_execute_reg_methods(node, space_id); 144 + break; 145 + } 116 146 117 147 unlock_and_exit: 118 148 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+2 -2
drivers/acpi/acpica/exfldio.c
··· 280 280 if (ACPI_FAILURE(status)) { 281 281 if (status == AE_NOT_IMPLEMENTED) { 282 282 ACPI_ERROR((AE_INFO, 283 - "Region %s(0x%X) not implemented", 283 + "Region %s (ID=%u) not implemented", 284 284 acpi_ut_get_region_name(rgn_desc->region. 285 285 space_id), 286 286 rgn_desc->region.space_id)); 287 287 } else if (status == AE_NOT_EXIST) { 288 288 ACPI_ERROR((AE_INFO, 289 - "Region %s(0x%X) has no handler", 289 + "Region %s (ID=%u) has no handler", 290 290 acpi_ut_get_region_name(rgn_desc->region. 291 291 space_id), 292 292 rgn_desc->region.space_id));
+5 -5
drivers/acpi/acpica/hwxface.c
··· 80 80 81 81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 82 82 /* 83 - * For I/O space, write directly to the OSL. This bypasses the port 84 - * validation mechanism, which may block a valid write to the reset 85 - * register. 83 + * For I/O space, write directly to the OSL. This 84 + * bypasses the port validation mechanism, which may 85 + * block a valid write to the reset register. Spec 86 + * section 4.7.3.6 requires register width to be 8. 86 87 */ 87 88 status = 88 89 acpi_os_write_port((acpi_io_address) reset_reg->address, 89 - acpi_gbl_FADT.reset_value, 90 - reset_reg->bit_width); 90 + acpi_gbl_FADT.reset_value, 8); 91 91 } else { 92 92 /* Write the reset value to the reset register */ 93 93
+4 -1
drivers/acpi/acpica/tbfadt.c
··· 384 384 * 385 385 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at 386 386 * offset 45, 55, 95, and the word located at offset 109, 110. 387 + * 388 + * Note: The FADT revision value is unreliable. Only the length can be 389 + * trusted. 387 390 */ 388 - if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) { 391 + if (acpi_gbl_FADT.header.length <= ACPI_FADT_V2_SIZE) { 389 392 acpi_gbl_FADT.preferred_profile = 0; 390 393 acpi_gbl_FADT.pstate_control = 0; 391 394 acpi_gbl_FADT.cst_control = 0;
+548
drivers/acpi/acpica/utdecode.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: utdecode - Utility decoding routines (value-to-string) 4 + * 5 + *****************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2011, Intel Corp. 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include "accommon.h" 46 + #include "acnamesp.h" 47 + 48 + #define _COMPONENT ACPI_UTILITIES 49 + ACPI_MODULE_NAME("utdecode") 50 + 51 + /******************************************************************************* 52 + * 53 + * FUNCTION: acpi_format_exception 54 + * 55 + * PARAMETERS: Status - The acpi_status code to be formatted 56 + * 57 + * RETURN: A string containing the exception text. A valid pointer is 58 + * always returned. 59 + * 60 + * DESCRIPTION: This function translates an ACPI exception into an ASCII string 61 + * It is here instead of utxface.c so it is always present. 62 + * 63 + ******************************************************************************/ 64 + const char *acpi_format_exception(acpi_status status) 65 + { 66 + const char *exception = NULL; 67 + 68 + ACPI_FUNCTION_ENTRY(); 69 + 70 + exception = acpi_ut_validate_exception(status); 71 + if (!exception) { 72 + 73 + /* Exception code was not recognized */ 74 + 75 + ACPI_ERROR((AE_INFO, 76 + "Unknown exception code: 0x%8.8X", status)); 77 + 78 + exception = "UNKNOWN_STATUS_CODE"; 79 + } 80 + 81 + return (ACPI_CAST_PTR(const char, exception)); 82 + } 83 + 84 + ACPI_EXPORT_SYMBOL(acpi_format_exception) 85 + 86 + /* 87 + * Properties of the ACPI Object Types, both internal and external. 88 + * The table is indexed by values of acpi_object_type 89 + */ 90 + const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = { 91 + ACPI_NS_NORMAL, /* 00 Any */ 92 + ACPI_NS_NORMAL, /* 01 Number */ 93 + ACPI_NS_NORMAL, /* 02 String */ 94 + ACPI_NS_NORMAL, /* 03 Buffer */ 95 + ACPI_NS_NORMAL, /* 04 Package */ 96 + ACPI_NS_NORMAL, /* 05 field_unit */ 97 + ACPI_NS_NEWSCOPE, /* 06 Device */ 98 + ACPI_NS_NORMAL, /* 07 Event */ 99 + ACPI_NS_NEWSCOPE, /* 08 Method */ 100 + ACPI_NS_NORMAL, /* 09 Mutex */ 101 + ACPI_NS_NORMAL, /* 10 Region */ 102 + ACPI_NS_NEWSCOPE, /* 11 Power */ 103 + ACPI_NS_NEWSCOPE, /* 12 Processor */ 104 + ACPI_NS_NEWSCOPE, /* 13 Thermal */ 105 + ACPI_NS_NORMAL, /* 14 buffer_field */ 106 + ACPI_NS_NORMAL, /* 15 ddb_handle */ 107 + ACPI_NS_NORMAL, /* 16 Debug Object */ 108 + ACPI_NS_NORMAL, /* 17 def_field */ 109 + ACPI_NS_NORMAL, /* 18 bank_field */ 110 + ACPI_NS_NORMAL, /* 19 index_field */ 111 + ACPI_NS_NORMAL, /* 20 Reference */ 112 + ACPI_NS_NORMAL, /* 21 Alias */ 113 + ACPI_NS_NORMAL, /* 22 method_alias */ 114 + ACPI_NS_NORMAL, /* 23 Notify */ 115 + ACPI_NS_NORMAL, /* 24 Address Handler */ 116 + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 117 + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 118 + ACPI_NS_NEWSCOPE, /* 27 Scope */ 119 + ACPI_NS_NORMAL, /* 28 Extra */ 120 + ACPI_NS_NORMAL, /* 29 Data */ 121 + ACPI_NS_NORMAL /* 30 Invalid */ 122 + }; 123 + 124 + /******************************************************************************* 125 + * 126 + * FUNCTION: acpi_ut_hex_to_ascii_char 127 + * 128 + * PARAMETERS: Integer - Contains the hex digit 129 + * Position - bit position of the digit within the 130 + * integer (multiple of 4) 131 + * 132 + * RETURN: The converted Ascii character 133 + * 134 + * DESCRIPTION: Convert a hex digit to an Ascii character 135 + * 136 + ******************************************************************************/ 137 + 138 + /* Hex to ASCII conversion table */ 139 + 140 + static const char acpi_gbl_hex_to_ascii[] = { 141 + '0', '1', '2', '3', '4', '5', '6', '7', 142 + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 143 + }; 144 + 145 + char acpi_ut_hex_to_ascii_char(u64 integer, u32 position) 146 + { 147 + 148 + return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 149 + } 150 + 151 + /******************************************************************************* 152 + * 153 + * FUNCTION: acpi_ut_get_region_name 154 + * 155 + * PARAMETERS: Space ID - ID for the region 156 + * 157 + * RETURN: Decoded region space_id name 158 + * 159 + * DESCRIPTION: Translate a Space ID into a name string (Debug only) 160 + * 161 + ******************************************************************************/ 162 + 163 + /* Region type decoding */ 164 + 165 + const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = { 166 + "SystemMemory", 167 + "SystemIO", 168 + "PCI_Config", 169 + "EmbeddedControl", 170 + "SMBus", 171 + "SystemCMOS", 172 + "PCIBARTarget", 173 + "IPMI", 174 + "DataTable" 175 + }; 176 + 177 + char *acpi_ut_get_region_name(u8 space_id) 178 + { 179 + 180 + if (space_id >= ACPI_USER_REGION_BEGIN) { 181 + return ("UserDefinedRegion"); 182 + } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) { 183 + return ("FunctionalFixedHW"); 184 + } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) { 185 + return ("InvalidSpaceId"); 186 + } 187 + 188 + return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id])); 189 + } 190 + 191 + /******************************************************************************* 192 + * 193 + * FUNCTION: acpi_ut_get_event_name 194 + * 195 + * PARAMETERS: event_id - Fixed event ID 196 + * 197 + * RETURN: Decoded event ID name 198 + * 199 + * DESCRIPTION: Translate a Event ID into a name string (Debug only) 200 + * 201 + ******************************************************************************/ 202 + 203 + /* Event type decoding */ 204 + 205 + static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { 206 + "PM_Timer", 207 + "GlobalLock", 208 + "PowerButton", 209 + "SleepButton", 210 + "RealTimeClock", 211 + }; 212 + 213 + char *acpi_ut_get_event_name(u32 event_id) 214 + { 215 + 216 + if (event_id > ACPI_EVENT_MAX) { 217 + return ("InvalidEventID"); 218 + } 219 + 220 + return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id])); 221 + } 222 + 223 + /******************************************************************************* 224 + * 225 + * FUNCTION: acpi_ut_get_type_name 226 + * 227 + * PARAMETERS: Type - An ACPI object type 228 + * 229 + * RETURN: Decoded ACPI object type name 230 + * 231 + * DESCRIPTION: Translate a Type ID into a name string (Debug only) 232 + * 233 + ******************************************************************************/ 234 + 235 + /* 236 + * Elements of acpi_gbl_ns_type_names below must match 237 + * one-to-one with values of acpi_object_type 238 + * 239 + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 240 + * when stored in a table it really means that we have thus far seen no 241 + * evidence to indicate what type is actually going to be stored for this entry. 242 + */ 243 + static const char acpi_gbl_bad_type[] = "UNDEFINED"; 244 + 245 + /* Printable names of the ACPI object types */ 246 + 247 + static const char *acpi_gbl_ns_type_names[] = { 248 + /* 00 */ "Untyped", 249 + /* 01 */ "Integer", 250 + /* 02 */ "String", 251 + /* 03 */ "Buffer", 252 + /* 04 */ "Package", 253 + /* 05 */ "FieldUnit", 254 + /* 06 */ "Device", 255 + /* 07 */ "Event", 256 + /* 08 */ "Method", 257 + /* 09 */ "Mutex", 258 + /* 10 */ "Region", 259 + /* 11 */ "Power", 260 + /* 12 */ "Processor", 261 + /* 13 */ "Thermal", 262 + /* 14 */ "BufferField", 263 + /* 15 */ "DdbHandle", 264 + /* 16 */ "DebugObject", 265 + /* 17 */ "RegionField", 266 + /* 18 */ "BankField", 267 + /* 19 */ "IndexField", 268 + /* 20 */ "Reference", 269 + /* 21 */ "Alias", 270 + /* 22 */ "MethodAlias", 271 + /* 23 */ "Notify", 272 + /* 24 */ "AddrHandler", 273 + /* 25 */ "ResourceDesc", 274 + /* 26 */ "ResourceFld", 275 + /* 27 */ "Scope", 276 + /* 28 */ "Extra", 277 + /* 29 */ "Data", 278 + /* 30 */ "Invalid" 279 + }; 280 + 281 + char *acpi_ut_get_type_name(acpi_object_type type) 282 + { 283 + 284 + if (type > ACPI_TYPE_INVALID) { 285 + return (ACPI_CAST_PTR(char, acpi_gbl_bad_type)); 286 + } 287 + 288 + return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type])); 289 + } 290 + 291 + char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) 292 + { 293 + 294 + if (!obj_desc) { 295 + return ("[NULL Object Descriptor]"); 296 + } 297 + 298 + return (acpi_ut_get_type_name(obj_desc->common.type)); 299 + } 300 + 301 + /******************************************************************************* 302 + * 303 + * FUNCTION: acpi_ut_get_node_name 304 + * 305 + * PARAMETERS: Object - A namespace node 306 + * 307 + * RETURN: ASCII name of the node 308 + * 309 + * DESCRIPTION: Validate the node and return the node's ACPI name. 310 + * 311 + ******************************************************************************/ 312 + 313 + char *acpi_ut_get_node_name(void *object) 314 + { 315 + struct acpi_namespace_node *node = (struct acpi_namespace_node *)object; 316 + 317 + /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 318 + 319 + if (!object) { 320 + return ("NULL"); 321 + } 322 + 323 + /* Check for Root node */ 324 + 325 + if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) { 326 + return ("\"\\\" "); 327 + } 328 + 329 + /* Descriptor must be a namespace node */ 330 + 331 + if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { 332 + return ("####"); 333 + } 334 + 335 + /* 336 + * Ensure name is valid. The name was validated/repaired when the node 337 + * was created, but make sure it has not been corrupted. 338 + */ 339 + acpi_ut_repair_name(node->name.ascii); 340 + 341 + /* Return the name */ 342 + 343 + return (node->name.ascii); 344 + } 345 + 346 + /******************************************************************************* 347 + * 348 + * FUNCTION: acpi_ut_get_descriptor_name 349 + * 350 + * PARAMETERS: Object - An ACPI object 351 + * 352 + * RETURN: Decoded name of the descriptor type 353 + * 354 + * DESCRIPTION: Validate object and return the descriptor type 355 + * 356 + ******************************************************************************/ 357 + 358 + /* Printable names of object descriptor types */ 359 + 360 + static const char *acpi_gbl_desc_type_names[] = { 361 + /* 00 */ "Not a Descriptor", 362 + /* 01 */ "Cached", 363 + /* 02 */ "State-Generic", 364 + /* 03 */ "State-Update", 365 + /* 04 */ "State-Package", 366 + /* 05 */ "State-Control", 367 + /* 06 */ "State-RootParseScope", 368 + /* 07 */ "State-ParseScope", 369 + /* 08 */ "State-WalkScope", 370 + /* 09 */ "State-Result", 371 + /* 10 */ "State-Notify", 372 + /* 11 */ "State-Thread", 373 + /* 12 */ "Walk", 374 + /* 13 */ "Parser", 375 + /* 14 */ "Operand", 376 + /* 15 */ "Node" 377 + }; 378 + 379 + char *acpi_ut_get_descriptor_name(void *object) 380 + { 381 + 382 + if (!object) { 383 + return ("NULL OBJECT"); 384 + } 385 + 386 + if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { 387 + return ("Not a Descriptor"); 388 + } 389 + 390 + return (ACPI_CAST_PTR(char, 391 + acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE 392 + (object)])); 393 + 394 + } 395 + 396 + /******************************************************************************* 397 + * 398 + * FUNCTION: acpi_ut_get_reference_name 399 + * 400 + * PARAMETERS: Object - An ACPI reference object 401 + * 402 + * RETURN: Decoded name of the type of reference 403 + * 404 + * DESCRIPTION: Decode a reference object sub-type to a string. 405 + * 406 + ******************************************************************************/ 407 + 408 + /* Printable names of reference object sub-types */ 409 + 410 + static const char *acpi_gbl_ref_class_names[] = { 411 + /* 00 */ "Local", 412 + /* 01 */ "Argument", 413 + /* 02 */ "RefOf", 414 + /* 03 */ "Index", 415 + /* 04 */ "DdbHandle", 416 + /* 05 */ "Named Object", 417 + /* 06 */ "Debug" 418 + }; 419 + 420 + const char *acpi_ut_get_reference_name(union acpi_operand_object *object) 421 + { 422 + 423 + if (!object) { 424 + return ("NULL Object"); 425 + } 426 + 427 + if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 428 + return ("Not an Operand object"); 429 + } 430 + 431 + if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) { 432 + return ("Not a Reference object"); 433 + } 434 + 435 + if (object->reference.class > ACPI_REFCLASS_MAX) { 436 + return ("Unknown Reference class"); 437 + } 438 + 439 + return (acpi_gbl_ref_class_names[object->reference.class]); 440 + } 441 + 442 + #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 443 + /* 444 + * Strings and procedures used for debug only 445 + */ 446 + 447 + /******************************************************************************* 448 + * 449 + * FUNCTION: acpi_ut_get_mutex_name 450 + * 451 + * PARAMETERS: mutex_id - The predefined ID for this mutex. 452 + * 453 + * RETURN: Decoded name of the internal mutex 454 + * 455 + * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 456 + * 457 + ******************************************************************************/ 458 + 459 + /* Names for internal mutex objects, used for debug output */ 460 + 461 + static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { 462 + "ACPI_MTX_Interpreter", 463 + "ACPI_MTX_Namespace", 464 + "ACPI_MTX_Tables", 465 + "ACPI_MTX_Events", 466 + "ACPI_MTX_Caches", 467 + "ACPI_MTX_Memory", 468 + "ACPI_MTX_CommandComplete", 469 + "ACPI_MTX_CommandReady" 470 + }; 471 + 472 + char *acpi_ut_get_mutex_name(u32 mutex_id) 473 + { 474 + 475 + if (mutex_id > ACPI_MAX_MUTEX) { 476 + return ("Invalid Mutex ID"); 477 + } 478 + 479 + return (acpi_gbl_mutex_names[mutex_id]); 480 + } 481 + 482 + /******************************************************************************* 483 + * 484 + * FUNCTION: acpi_ut_get_notify_name 485 + * 486 + * PARAMETERS: notify_value - Value from the Notify() request 487 + * 488 + * RETURN: Decoded name for the notify value 489 + * 490 + * DESCRIPTION: Translate a Notify Value to a notify namestring. 491 + * 492 + ******************************************************************************/ 493 + 494 + /* Names for Notify() values, used for debug output */ 495 + 496 + static const char *acpi_gbl_notify_value_names[] = { 497 + "Bus Check", 498 + "Device Check", 499 + "Device Wake", 500 + "Eject Request", 501 + "Device Check Light", 502 + "Frequency Mismatch", 503 + "Bus Mode Mismatch", 504 + "Power Fault", 505 + "Capabilities Check", 506 + "Device PLD Check", 507 + "Reserved", 508 + "System Locality Update" 509 + }; 510 + 511 + const char *acpi_ut_get_notify_name(u32 notify_value) 512 + { 513 + 514 + if (notify_value <= ACPI_NOTIFY_MAX) { 515 + return (acpi_gbl_notify_value_names[notify_value]); 516 + } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 517 + return ("Reserved"); 518 + } else { /* Greater or equal to 0x80 */ 519 + 520 + return ("**Device Specific**"); 521 + } 522 + } 523 + #endif 524 + 525 + /******************************************************************************* 526 + * 527 + * FUNCTION: acpi_ut_valid_object_type 528 + * 529 + * PARAMETERS: Type - Object type to be validated 530 + * 531 + * RETURN: TRUE if valid object type, FALSE otherwise 532 + * 533 + * DESCRIPTION: Validate an object type 534 + * 535 + ******************************************************************************/ 536 + 537 + u8 acpi_ut_valid_object_type(acpi_object_type type) 538 + { 539 + 540 + if (type > ACPI_TYPE_LOCAL_MAX) { 541 + 542 + /* Note: Assumes all TYPEs are contiguous (external/local) */ 543 + 544 + return (FALSE); 545 + } 546 + 547 + return (TRUE); 548 + }
+1 -483
drivers/acpi/acpica/utglobal.c
··· 45 45 46 46 #include <acpi/acpi.h> 47 47 #include "accommon.h" 48 - #include "acnamesp.h" 49 48 50 49 #define _COMPONENT ACPI_UTILITIES 51 50 ACPI_MODULE_NAME("utglobal") ··· 106 107 107 108 /******************************************************************************* 108 109 * 109 - * FUNCTION: acpi_format_exception 110 - * 111 - * PARAMETERS: Status - The acpi_status code to be formatted 112 - * 113 - * RETURN: A string containing the exception text. A valid pointer is 114 - * always returned. 115 - * 116 - * DESCRIPTION: This function translates an ACPI exception into an ASCII string 117 - * It is here instead of utxface.c so it is always present. 118 - * 119 - ******************************************************************************/ 120 - 121 - const char *acpi_format_exception(acpi_status status) 122 - { 123 - const char *exception = NULL; 124 - 125 - ACPI_FUNCTION_ENTRY(); 126 - 127 - exception = acpi_ut_validate_exception(status); 128 - if (!exception) { 129 - 130 - /* Exception code was not recognized */ 131 - 132 - ACPI_ERROR((AE_INFO, 133 - "Unknown exception code: 0x%8.8X", status)); 134 - 135 - exception = "UNKNOWN_STATUS_CODE"; 136 - dump_stack(); 137 - } 138 - 139 - return (ACPI_CAST_PTR(const char, exception)); 140 - } 141 - 142 - ACPI_EXPORT_SYMBOL(acpi_format_exception) 143 - 144 - /******************************************************************************* 145 - * 146 110 * Namespace globals 147 111 * 148 112 ******************************************************************************/ ··· 138 176 139 177 {NULL, ACPI_TYPE_ANY, NULL} 140 178 }; 141 - 142 - /* 143 - * Properties of the ACPI Object Types, both internal and external. 144 - * The table is indexed by values of acpi_object_type 145 - */ 146 - const u8 acpi_gbl_ns_properties[] = { 147 - ACPI_NS_NORMAL, /* 00 Any */ 148 - ACPI_NS_NORMAL, /* 01 Number */ 149 - ACPI_NS_NORMAL, /* 02 String */ 150 - ACPI_NS_NORMAL, /* 03 Buffer */ 151 - ACPI_NS_NORMAL, /* 04 Package */ 152 - ACPI_NS_NORMAL, /* 05 field_unit */ 153 - ACPI_NS_NEWSCOPE, /* 06 Device */ 154 - ACPI_NS_NORMAL, /* 07 Event */ 155 - ACPI_NS_NEWSCOPE, /* 08 Method */ 156 - ACPI_NS_NORMAL, /* 09 Mutex */ 157 - ACPI_NS_NORMAL, /* 10 Region */ 158 - ACPI_NS_NEWSCOPE, /* 11 Power */ 159 - ACPI_NS_NEWSCOPE, /* 12 Processor */ 160 - ACPI_NS_NEWSCOPE, /* 13 Thermal */ 161 - ACPI_NS_NORMAL, /* 14 buffer_field */ 162 - ACPI_NS_NORMAL, /* 15 ddb_handle */ 163 - ACPI_NS_NORMAL, /* 16 Debug Object */ 164 - ACPI_NS_NORMAL, /* 17 def_field */ 165 - ACPI_NS_NORMAL, /* 18 bank_field */ 166 - ACPI_NS_NORMAL, /* 19 index_field */ 167 - ACPI_NS_NORMAL, /* 20 Reference */ 168 - ACPI_NS_NORMAL, /* 21 Alias */ 169 - ACPI_NS_NORMAL, /* 22 method_alias */ 170 - ACPI_NS_NORMAL, /* 23 Notify */ 171 - ACPI_NS_NORMAL, /* 24 Address Handler */ 172 - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 173 - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 174 - ACPI_NS_NEWSCOPE, /* 27 Scope */ 175 - ACPI_NS_NORMAL, /* 28 Extra */ 176 - ACPI_NS_NORMAL, /* 29 Data */ 177 - ACPI_NS_NORMAL /* 30 Invalid */ 178 - }; 179 - 180 - /* Hex to ASCII conversion table */ 181 - 182 - static const char acpi_gbl_hex_to_ascii[] = { 183 - '0', '1', '2', '3', '4', '5', '6', '7', 184 - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 185 - }; 186 - 187 - /******************************************************************************* 188 - * 189 - * FUNCTION: acpi_ut_hex_to_ascii_char 190 - * 191 - * PARAMETERS: Integer - Contains the hex digit 192 - * Position - bit position of the digit within the 193 - * integer (multiple of 4) 194 - * 195 - * RETURN: The converted Ascii character 196 - * 197 - * DESCRIPTION: Convert a hex digit to an Ascii character 198 - * 199 - ******************************************************************************/ 200 - 201 - char acpi_ut_hex_to_ascii_char(u64 integer, u32 position) 202 - { 203 - 204 - return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 205 - } 206 179 207 180 /****************************************************************************** 208 181 * ··· 238 341 239 342 /******************************************************************************* 240 343 * 241 - * FUNCTION: acpi_ut_get_region_name 242 - * 243 - * PARAMETERS: None. 244 - * 245 - * RETURN: Status 246 - * 247 - * DESCRIPTION: Translate a Space ID into a name string (Debug only) 248 - * 249 - ******************************************************************************/ 250 - 251 - /* Region type decoding */ 252 - 253 - const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = { 254 - "SystemMemory", 255 - "SystemIO", 256 - "PCI_Config", 257 - "EmbeddedControl", 258 - "SMBus", 259 - "SystemCMOS", 260 - "PCIBARTarget", 261 - "IPMI", 262 - "DataTable" 263 - }; 264 - 265 - char *acpi_ut_get_region_name(u8 space_id) 266 - { 267 - 268 - if (space_id >= ACPI_USER_REGION_BEGIN) { 269 - return ("UserDefinedRegion"); 270 - } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) { 271 - return ("InvalidSpaceId"); 272 - } 273 - 274 - return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id])); 275 - } 276 - 277 - /******************************************************************************* 278 - * 279 - * FUNCTION: acpi_ut_get_event_name 280 - * 281 - * PARAMETERS: None. 282 - * 283 - * RETURN: Status 284 - * 285 - * DESCRIPTION: Translate a Event ID into a name string (Debug only) 286 - * 287 - ******************************************************************************/ 288 - 289 - /* Event type decoding */ 290 - 291 - static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { 292 - "PM_Timer", 293 - "GlobalLock", 294 - "PowerButton", 295 - "SleepButton", 296 - "RealTimeClock", 297 - }; 298 - 299 - char *acpi_ut_get_event_name(u32 event_id) 300 - { 301 - 302 - if (event_id > ACPI_EVENT_MAX) { 303 - return ("InvalidEventID"); 304 - } 305 - 306 - return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id])); 307 - } 308 - 309 - /******************************************************************************* 310 - * 311 - * FUNCTION: acpi_ut_get_type_name 312 - * 313 - * PARAMETERS: None. 314 - * 315 - * RETURN: Status 316 - * 317 - * DESCRIPTION: Translate a Type ID into a name string (Debug only) 318 - * 319 - ******************************************************************************/ 320 - 321 - /* 322 - * Elements of acpi_gbl_ns_type_names below must match 323 - * one-to-one with values of acpi_object_type 324 - * 325 - * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 326 - * when stored in a table it really means that we have thus far seen no 327 - * evidence to indicate what type is actually going to be stored for this entry. 328 - */ 329 - static const char acpi_gbl_bad_type[] = "UNDEFINED"; 330 - 331 - /* Printable names of the ACPI object types */ 332 - 333 - static const char *acpi_gbl_ns_type_names[] = { 334 - /* 00 */ "Untyped", 335 - /* 01 */ "Integer", 336 - /* 02 */ "String", 337 - /* 03 */ "Buffer", 338 - /* 04 */ "Package", 339 - /* 05 */ "FieldUnit", 340 - /* 06 */ "Device", 341 - /* 07 */ "Event", 342 - /* 08 */ "Method", 343 - /* 09 */ "Mutex", 344 - /* 10 */ "Region", 345 - /* 11 */ "Power", 346 - /* 12 */ "Processor", 347 - /* 13 */ "Thermal", 348 - /* 14 */ "BufferField", 349 - /* 15 */ "DdbHandle", 350 - /* 16 */ "DebugObject", 351 - /* 17 */ "RegionField", 352 - /* 18 */ "BankField", 353 - /* 19 */ "IndexField", 354 - /* 20 */ "Reference", 355 - /* 21 */ "Alias", 356 - /* 22 */ "MethodAlias", 357 - /* 23 */ "Notify", 358 - /* 24 */ "AddrHandler", 359 - /* 25 */ "ResourceDesc", 360 - /* 26 */ "ResourceFld", 361 - /* 27 */ "Scope", 362 - /* 28 */ "Extra", 363 - /* 29 */ "Data", 364 - /* 30 */ "Invalid" 365 - }; 366 - 367 - char *acpi_ut_get_type_name(acpi_object_type type) 368 - { 369 - 370 - if (type > ACPI_TYPE_INVALID) { 371 - return (ACPI_CAST_PTR(char, acpi_gbl_bad_type)); 372 - } 373 - 374 - return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type])); 375 - } 376 - 377 - char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) 378 - { 379 - 380 - if (!obj_desc) { 381 - return ("[NULL Object Descriptor]"); 382 - } 383 - 384 - return (acpi_ut_get_type_name(obj_desc->common.type)); 385 - } 386 - 387 - /******************************************************************************* 388 - * 389 - * FUNCTION: acpi_ut_get_node_name 390 - * 391 - * PARAMETERS: Object - A namespace node 392 - * 393 - * RETURN: Pointer to a string 394 - * 395 - * DESCRIPTION: Validate the node and return the node's ACPI name. 396 - * 397 - ******************************************************************************/ 398 - 399 - char *acpi_ut_get_node_name(void *object) 400 - { 401 - struct acpi_namespace_node *node = (struct acpi_namespace_node *)object; 402 - 403 - /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 404 - 405 - if (!object) { 406 - return ("NULL"); 407 - } 408 - 409 - /* Check for Root node */ 410 - 411 - if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) { 412 - return ("\"\\\" "); 413 - } 414 - 415 - /* Descriptor must be a namespace node */ 416 - 417 - if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { 418 - return ("####"); 419 - } 420 - 421 - /* Name must be a valid ACPI name */ 422 - 423 - if (!acpi_ut_valid_acpi_name(node->name.integer)) { 424 - node->name.integer = acpi_ut_repair_name(node->name.ascii); 425 - } 426 - 427 - /* Return the name */ 428 - 429 - return (node->name.ascii); 430 - } 431 - 432 - /******************************************************************************* 433 - * 434 - * FUNCTION: acpi_ut_get_descriptor_name 435 - * 436 - * PARAMETERS: Object - An ACPI object 437 - * 438 - * RETURN: Pointer to a string 439 - * 440 - * DESCRIPTION: Validate object and return the descriptor type 441 - * 442 - ******************************************************************************/ 443 - 444 - /* Printable names of object descriptor types */ 445 - 446 - static const char *acpi_gbl_desc_type_names[] = { 447 - /* 00 */ "Invalid", 448 - /* 01 */ "Cached", 449 - /* 02 */ "State-Generic", 450 - /* 03 */ "State-Update", 451 - /* 04 */ "State-Package", 452 - /* 05 */ "State-Control", 453 - /* 06 */ "State-RootParseScope", 454 - /* 07 */ "State-ParseScope", 455 - /* 08 */ "State-WalkScope", 456 - /* 09 */ "State-Result", 457 - /* 10 */ "State-Notify", 458 - /* 11 */ "State-Thread", 459 - /* 12 */ "Walk", 460 - /* 13 */ "Parser", 461 - /* 14 */ "Operand", 462 - /* 15 */ "Node" 463 - }; 464 - 465 - char *acpi_ut_get_descriptor_name(void *object) 466 - { 467 - 468 - if (!object) { 469 - return ("NULL OBJECT"); 470 - } 471 - 472 - if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { 473 - return (ACPI_CAST_PTR(char, acpi_gbl_bad_type)); 474 - } 475 - 476 - return (ACPI_CAST_PTR(char, 477 - acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE 478 - (object)])); 479 - 480 - } 481 - 482 - /******************************************************************************* 483 - * 484 - * FUNCTION: acpi_ut_get_reference_name 485 - * 486 - * PARAMETERS: Object - An ACPI reference object 487 - * 488 - * RETURN: Pointer to a string 489 - * 490 - * DESCRIPTION: Decode a reference object sub-type to a string. 491 - * 492 - ******************************************************************************/ 493 - 494 - /* Printable names of reference object sub-types */ 495 - 496 - static const char *acpi_gbl_ref_class_names[] = { 497 - /* 00 */ "Local", 498 - /* 01 */ "Argument", 499 - /* 02 */ "RefOf", 500 - /* 03 */ "Index", 501 - /* 04 */ "DdbHandle", 502 - /* 05 */ "Named Object", 503 - /* 06 */ "Debug" 504 - }; 505 - 506 - const char *acpi_ut_get_reference_name(union acpi_operand_object *object) 507 - { 508 - if (!object) 509 - return "NULL Object"; 510 - 511 - if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) 512 - return "Not an Operand object"; 513 - 514 - if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) 515 - return "Not a Reference object"; 516 - 517 - if (object->reference.class > ACPI_REFCLASS_MAX) 518 - return "Unknown Reference class"; 519 - 520 - return acpi_gbl_ref_class_names[object->reference.class]; 521 - } 522 - 523 - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 524 - /* 525 - * Strings and procedures used for debug only 526 - */ 527 - 528 - /******************************************************************************* 529 - * 530 - * FUNCTION: acpi_ut_get_mutex_name 531 - * 532 - * PARAMETERS: mutex_id - The predefined ID for this mutex. 533 - * 534 - * RETURN: String containing the name of the mutex. Always returns a valid 535 - * pointer. 536 - * 537 - * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 538 - * 539 - ******************************************************************************/ 540 - 541 - char *acpi_ut_get_mutex_name(u32 mutex_id) 542 - { 543 - 544 - if (mutex_id > ACPI_MAX_MUTEX) { 545 - return ("Invalid Mutex ID"); 546 - } 547 - 548 - return (acpi_gbl_mutex_names[mutex_id]); 549 - } 550 - 551 - /******************************************************************************* 552 - * 553 - * FUNCTION: acpi_ut_get_notify_name 554 - * 555 - * PARAMETERS: notify_value - Value from the Notify() request 556 - * 557 - * RETURN: String corresponding to the Notify Value. 558 - * 559 - * DESCRIPTION: Translate a Notify Value to a notify namestring. 560 - * 561 - ******************************************************************************/ 562 - 563 - /* Names for Notify() values, used for debug output */ 564 - 565 - static const char *acpi_gbl_notify_value_names[] = { 566 - "Bus Check", 567 - "Device Check", 568 - "Device Wake", 569 - "Eject Request", 570 - "Device Check Light", 571 - "Frequency Mismatch", 572 - "Bus Mode Mismatch", 573 - "Power Fault", 574 - "Capabilities Check", 575 - "Device PLD Check", 576 - "Reserved", 577 - "System Locality Update" 578 - }; 579 - 580 - const char *acpi_ut_get_notify_name(u32 notify_value) 581 - { 582 - 583 - if (notify_value <= ACPI_NOTIFY_MAX) { 584 - return (acpi_gbl_notify_value_names[notify_value]); 585 - } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 586 - return ("Reserved"); 587 - } else { /* Greater or equal to 0x80 */ 588 - 589 - return ("**Device Specific**"); 590 - } 591 - } 592 - #endif 593 - 594 - /******************************************************************************* 595 - * 596 - * FUNCTION: acpi_ut_valid_object_type 597 - * 598 - * PARAMETERS: Type - Object type to be validated 599 - * 600 - * RETURN: TRUE if valid object type, FALSE otherwise 601 - * 602 - * DESCRIPTION: Validate an object type 603 - * 604 - ******************************************************************************/ 605 - 606 - u8 acpi_ut_valid_object_type(acpi_object_type type) 607 - { 608 - 609 - if (type > ACPI_TYPE_LOCAL_MAX) { 610 - 611 - /* Note: Assumes all TYPEs are contiguous (external/local) */ 612 - 613 - return (FALSE); 614 - } 615 - 616 - return (TRUE); 617 - } 618 - 619 - /******************************************************************************* 620 - * 621 344 * FUNCTION: acpi_ut_init_globals 622 345 * 623 346 * PARAMETERS: None ··· 323 806 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 324 807 acpi_gbl_osi_data = 0; 325 808 acpi_gbl_osi_mutex = NULL; 809 + acpi_gbl_reg_methods_executed = FALSE; 326 810 327 811 /* Hardware oriented */ 328 812
+7
drivers/acpi/apei/Kconfig
··· 22 22 by firmware to produce more valuable hardware error 23 23 information for Linux. 24 24 25 + config ACPI_APEI_PCIEAER 26 + bool "APEI PCIe AER logging/recovering support" 27 + depends on ACPI_APEI && PCIEAER 28 + help 29 + PCIe AER errors may be reported via APEI firmware first mode. 30 + Turn on this option to enable the corresponding support. 31 + 25 32 config ACPI_APEI_EINJ 26 33 tristate "APEI Error INJection (EINJ)" 27 34 depends on ACPI_APEI && DEBUG_FS
+14 -4
drivers/acpi/apei/cper.c
··· 29 29 #include <linux/time.h> 30 30 #include <linux/cper.h> 31 31 #include <linux/acpi.h> 32 + #include <linux/aer.h> 32 33 33 34 /* 34 35 * CPER record ID need to be unique even after reboot, because record ··· 71 70 * If the output length is longer than 80, multiple line will be 72 71 * printed, with @pfx is printed at the beginning of each line. 73 72 */ 74 - static void cper_print_bits(const char *pfx, unsigned int bits, 75 - const char *strs[], unsigned int strs_size) 73 + void cper_print_bits(const char *pfx, unsigned int bits, 74 + const char *strs[], unsigned int strs_size) 76 75 { 77 76 int i, len = 0; 78 77 const char *str; ··· 82 81 if (!(bits & (1U << i))) 83 82 continue; 84 83 str = strs[i]; 84 + if (!str) 85 + continue; 85 86 if (len && len + strlen(str) + 2 > 80) { 86 87 printk("%s\n", buf); 87 88 len = 0; ··· 246 243 "root complex event collector", 247 244 }; 248 245 249 - static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie) 246 + static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, 247 + const struct acpi_hest_generic_data *gdata) 250 248 { 251 249 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) 252 250 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, ··· 280 276 printk( 281 277 "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n", 282 278 pfx, pcie->bridge.secondary_status, pcie->bridge.control); 279 + #ifdef CONFIG_ACPI_APEI_PCIEAER 280 + if (pcie->validation_bits & CPER_PCIE_VALID_AER_INFO) { 281 + struct aer_capability_regs *aer_regs = (void *)pcie->aer_info; 282 + cper_print_aer(pfx, gdata->error_severity, aer_regs); 283 + } 284 + #endif 283 285 } 284 286 285 287 static const char *apei_estatus_section_flag_strs[] = { ··· 332 322 struct cper_sec_pcie *pcie = (void *)(gdata + 1); 333 323 printk("%s""section_type: PCIe error\n", pfx); 334 324 if (gdata->error_data_length >= sizeof(*pcie)) 335 - cper_print_pcie(pfx, pcie); 325 + cper_print_pcie(pfx, pcie, gdata); 336 326 else 337 327 goto err_section_too_small; 338 328 } else
+21 -3
drivers/acpi/apei/erst-dbg.c
··· 43 43 44 44 static int erst_dbg_open(struct inode *inode, struct file *file) 45 45 { 46 + int rc, *pos; 47 + 46 48 if (erst_disable) 47 49 return -ENODEV; 48 50 51 + pos = (int *)&file->private_data; 52 + 53 + rc = erst_get_record_id_begin(pos); 54 + if (rc) 55 + return rc; 56 + 49 57 return nonseekable_open(inode, file); 58 + } 59 + 60 + static int erst_dbg_release(struct inode *inode, struct file *file) 61 + { 62 + erst_get_record_id_end(); 63 + 64 + return 0; 50 65 } 51 66 52 67 static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg) ··· 94 79 static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf, 95 80 size_t usize, loff_t *off) 96 81 { 97 - int rc; 82 + int rc, *pos; 98 83 ssize_t len = 0; 99 84 u64 id; 100 85 101 - if (*off != 0) 86 + if (*off) 102 87 return -EINVAL; 103 88 104 89 if (mutex_lock_interruptible(&erst_dbg_mutex) != 0) 105 90 return -EINTR; 106 91 92 + pos = (int *)&filp->private_data; 93 + 107 94 retry_next: 108 - rc = erst_get_next_record_id(&id); 95 + rc = erst_get_record_id_next(pos, &id); 109 96 if (rc) 110 97 goto out; 111 98 /* no more record */ ··· 198 181 static const struct file_operations erst_dbg_ops = { 199 182 .owner = THIS_MODULE, 200 183 .open = erst_dbg_open, 184 + .release = erst_dbg_release, 201 185 .read = erst_dbg_read, 202 186 .write = erst_dbg_write, 203 187 .unlocked_ioctl = erst_dbg_ioctl,
+191 -44
drivers/acpi/apei/erst.c
··· 430 430 } 431 431 EXPORT_SYMBOL_GPL(erst_get_record_count); 432 432 433 + #define ERST_RECORD_ID_CACHE_SIZE_MIN 16 434 + #define ERST_RECORD_ID_CACHE_SIZE_MAX 1024 435 + 436 + struct erst_record_id_cache { 437 + struct mutex lock; 438 + u64 *entries; 439 + int len; 440 + int size; 441 + int refcount; 442 + }; 443 + 444 + static struct erst_record_id_cache erst_record_id_cache = { 445 + .lock = __MUTEX_INITIALIZER(erst_record_id_cache.lock), 446 + .refcount = 0, 447 + }; 448 + 433 449 static int __erst_get_next_record_id(u64 *record_id) 434 450 { 435 451 struct apei_exec_context ctx; ··· 460 444 return 0; 461 445 } 462 446 447 + int erst_get_record_id_begin(int *pos) 448 + { 449 + int rc; 450 + 451 + if (erst_disable) 452 + return -ENODEV; 453 + 454 + rc = mutex_lock_interruptible(&erst_record_id_cache.lock); 455 + if (rc) 456 + return rc; 457 + erst_record_id_cache.refcount++; 458 + mutex_unlock(&erst_record_id_cache.lock); 459 + 460 + *pos = 0; 461 + 462 + return 0; 463 + } 464 + EXPORT_SYMBOL_GPL(erst_get_record_id_begin); 465 + 466 + /* erst_record_id_cache.lock must be held by caller */ 467 + static int __erst_record_id_cache_add_one(void) 468 + { 469 + u64 id, prev_id, first_id; 470 + int i, rc; 471 + u64 *entries; 472 + unsigned long flags; 473 + 474 + id = prev_id = first_id = APEI_ERST_INVALID_RECORD_ID; 475 + retry: 476 + raw_spin_lock_irqsave(&erst_lock, flags); 477 + rc = __erst_get_next_record_id(&id); 478 + raw_spin_unlock_irqrestore(&erst_lock, flags); 479 + if (rc == -ENOENT) 480 + return 0; 481 + if (rc) 482 + return rc; 483 + if (id == APEI_ERST_INVALID_RECORD_ID) 484 + return 0; 485 + /* can not skip current ID, or loop back to first ID */ 486 + if (id == prev_id || id == first_id) 487 + return 0; 488 + if (first_id == APEI_ERST_INVALID_RECORD_ID) 489 + first_id = id; 490 + prev_id = id; 491 + 492 + entries = erst_record_id_cache.entries; 493 + for (i = 0; i < erst_record_id_cache.len; i++) { 494 + if (entries[i] == id) 495 + break; 496 + } 497 + /* record id already in cache, try next */ 498 + if (i < erst_record_id_cache.len) 499 + goto retry; 500 + if (erst_record_id_cache.len >= erst_record_id_cache.size) { 501 + int new_size, alloc_size; 502 + u64 *new_entries; 503 + 504 + new_size = erst_record_id_cache.size * 2; 505 + new_size = clamp_val(new_size, ERST_RECORD_ID_CACHE_SIZE_MIN, 506 + ERST_RECORD_ID_CACHE_SIZE_MAX); 507 + if (new_size <= erst_record_id_cache.size) { 508 + if (printk_ratelimit()) 509 + pr_warning(FW_WARN ERST_PFX 510 + "too many record ID!\n"); 511 + return 0; 512 + } 513 + alloc_size = new_size * sizeof(entries[0]); 514 + if (alloc_size < PAGE_SIZE) 515 + new_entries = kmalloc(alloc_size, GFP_KERNEL); 516 + else 517 + new_entries = vmalloc(alloc_size); 518 + if (!new_entries) 519 + return -ENOMEM; 520 + memcpy(new_entries, entries, 521 + erst_record_id_cache.len * sizeof(entries[0])); 522 + if (erst_record_id_cache.size < PAGE_SIZE) 523 + kfree(entries); 524 + else 525 + vfree(entries); 526 + erst_record_id_cache.entries = entries = new_entries; 527 + erst_record_id_cache.size = new_size; 528 + } 529 + entries[i] = id; 530 + erst_record_id_cache.len++; 531 + 532 + return 1; 533 + } 534 + 463 535 /* 464 536 * Get the record ID of an existing error record on the persistent 465 537 * storage. If there is no error record on the persistent storage, the 466 538 * returned record_id is APEI_ERST_INVALID_RECORD_ID. 467 539 */ 468 - int erst_get_next_record_id(u64 *record_id) 540 + int erst_get_record_id_next(int *pos, u64 *record_id) 469 541 { 470 - int rc; 471 - unsigned long flags; 542 + int rc = 0; 543 + u64 *entries; 472 544 473 545 if (erst_disable) 474 546 return -ENODEV; 475 547 476 - raw_spin_lock_irqsave(&erst_lock, flags); 477 - rc = __erst_get_next_record_id(record_id); 478 - raw_spin_unlock_irqrestore(&erst_lock, flags); 548 + /* must be enclosed by erst_get_record_id_begin/end */ 549 + BUG_ON(!erst_record_id_cache.refcount); 550 + BUG_ON(*pos < 0 || *pos > erst_record_id_cache.len); 551 + 552 + mutex_lock(&erst_record_id_cache.lock); 553 + entries = erst_record_id_cache.entries; 554 + for (; *pos < erst_record_id_cache.len; (*pos)++) 555 + if (entries[*pos] != APEI_ERST_INVALID_RECORD_ID) 556 + break; 557 + /* found next record id in cache */ 558 + if (*pos < erst_record_id_cache.len) { 559 + *record_id = entries[*pos]; 560 + (*pos)++; 561 + goto out_unlock; 562 + } 563 + 564 + /* Try to add one more record ID to cache */ 565 + rc = __erst_record_id_cache_add_one(); 566 + if (rc < 0) 567 + goto out_unlock; 568 + /* successfully add one new ID */ 569 + if (rc == 1) { 570 + *record_id = erst_record_id_cache.entries[*pos]; 571 + (*pos)++; 572 + rc = 0; 573 + } else { 574 + *pos = -1; 575 + *record_id = APEI_ERST_INVALID_RECORD_ID; 576 + } 577 + out_unlock: 578 + mutex_unlock(&erst_record_id_cache.lock); 479 579 480 580 return rc; 481 581 } 482 - EXPORT_SYMBOL_GPL(erst_get_next_record_id); 582 + EXPORT_SYMBOL_GPL(erst_get_record_id_next); 583 + 584 + /* erst_record_id_cache.lock must be held by caller */ 585 + static void __erst_record_id_cache_compact(void) 586 + { 587 + int i, wpos = 0; 588 + u64 *entries; 589 + 590 + if (erst_record_id_cache.refcount) 591 + return; 592 + 593 + entries = erst_record_id_cache.entries; 594 + for (i = 0; i < erst_record_id_cache.len; i++) { 595 + if (entries[i] == APEI_ERST_INVALID_RECORD_ID) 596 + continue; 597 + if (wpos != i) 598 + memcpy(&entries[wpos], &entries[i], sizeof(entries[i])); 599 + wpos++; 600 + } 601 + erst_record_id_cache.len = wpos; 602 + } 603 + 604 + void erst_get_record_id_end(void) 605 + { 606 + /* 607 + * erst_disable != 0 should be detected by invoker via the 608 + * return value of erst_get_record_id_begin/next, so this 609 + * function should not be called for erst_disable != 0. 610 + */ 611 + BUG_ON(erst_disable); 612 + 613 + mutex_lock(&erst_record_id_cache.lock); 614 + erst_record_id_cache.refcount--; 615 + BUG_ON(erst_record_id_cache.refcount < 0); 616 + __erst_record_id_cache_compact(); 617 + mutex_unlock(&erst_record_id_cache.lock); 618 + } 619 + EXPORT_SYMBOL_GPL(erst_get_record_id_end); 483 620 484 621 static int __erst_write_to_storage(u64 offset) 485 622 { ··· 873 704 } 874 705 EXPORT_SYMBOL_GPL(erst_read); 875 706 876 - /* 877 - * If return value > buflen, the buffer size is not big enough, 878 - * else if return value = 0, there is no more record to read, 879 - * else if return value < 0, something goes wrong, 880 - * else everything is OK, and return value is record length 881 - */ 882 - ssize_t erst_read_next(struct cper_record_header *record, size_t buflen) 883 - { 884 - int rc; 885 - ssize_t len; 886 - unsigned long flags; 887 - u64 record_id; 888 - 889 - if (erst_disable) 890 - return -ENODEV; 891 - 892 - raw_spin_lock_irqsave(&erst_lock, flags); 893 - rc = __erst_get_next_record_id(&record_id); 894 - if (rc) { 895 - raw_spin_unlock_irqrestore(&erst_lock, flags); 896 - return rc; 897 - } 898 - /* no more record */ 899 - if (record_id == APEI_ERST_INVALID_RECORD_ID) { 900 - raw_spin_unlock_irqrestore(&erst_lock, flags); 901 - return 0; 902 - } 903 - 904 - len = __erst_read(record_id, record, buflen); 905 - raw_spin_unlock_irqrestore(&erst_lock, flags); 906 - 907 - return len; 908 - } 909 - EXPORT_SYMBOL_GPL(erst_read_next); 910 - 911 707 int erst_clear(u64 record_id) 912 708 { 913 - int rc; 709 + int rc, i; 914 710 unsigned long flags; 711 + u64 *entries; 915 712 916 713 if (erst_disable) 917 714 return -ENODEV; 918 715 716 + rc = mutex_lock_interruptible(&erst_record_id_cache.lock); 717 + if (rc) 718 + return rc; 919 719 raw_spin_lock_irqsave(&erst_lock, flags); 920 720 if (erst_erange.attr & ERST_RANGE_NVRAM) 921 721 rc = __erst_clear_from_nvram(record_id); 922 722 else 923 723 rc = __erst_clear_from_storage(record_id); 924 724 raw_spin_unlock_irqrestore(&erst_lock, flags); 925 - 725 + if (rc) 726 + goto out; 727 + entries = erst_record_id_cache.entries; 728 + for (i = 0; i < erst_record_id_cache.len; i++) { 729 + if (entries[i] == record_id) 730 + entries[i] = APEI_ERST_INVALID_RECORD_ID; 731 + } 732 + __erst_record_id_cache_compact(); 733 + out: 734 + mutex_unlock(&erst_record_id_cache.lock); 926 735 return rc; 927 736 } 928 737 EXPORT_SYMBOL_GPL(erst_clear);
+22
drivers/acpi/battery.c
··· 33 33 #include <linux/async.h> 34 34 #include <linux/dmi.h> 35 35 #include <linux/slab.h> 36 + #include <linux/suspend.h> 36 37 37 38 #ifdef CONFIG_ACPI_PROCFS_POWER 38 39 #include <linux/proc_fs.h> ··· 103 102 struct mutex lock; 104 103 struct power_supply bat; 105 104 struct acpi_device *device; 105 + struct notifier_block pm_nb; 106 106 unsigned long update_time; 107 107 int rate_now; 108 108 int capacity_now; ··· 942 940 power_supply_changed(&battery->bat); 943 941 } 944 942 943 + static int battery_notify(struct notifier_block *nb, 944 + unsigned long mode, void *_unused) 945 + { 946 + struct acpi_battery *battery = container_of(nb, struct acpi_battery, 947 + pm_nb); 948 + switch (mode) { 949 + case PM_POST_SUSPEND: 950 + sysfs_remove_battery(battery); 951 + sysfs_add_battery(battery); 952 + break; 953 + } 954 + 955 + return 0; 956 + } 957 + 945 958 static int acpi_battery_add(struct acpi_device *device) 946 959 { 947 960 int result = 0; ··· 989 972 #endif 990 973 kfree(battery); 991 974 } 975 + 976 + battery->pm_nb.notifier_call = battery_notify; 977 + register_pm_notifier(&battery->pm_nb); 978 + 992 979 return result; 993 980 } 994 981 ··· 1003 982 if (!device || !acpi_driver_data(device)) 1004 983 return -EINVAL; 1005 984 battery = acpi_driver_data(device); 985 + unregister_pm_notifier(&battery->pm_nb); 1006 986 #ifdef CONFIG_ACPI_PROCFS_POWER 1007 987 acpi_battery_remove_fs(device); 1008 988 #endif
+67 -107
drivers/acpi/button.c
··· 78 78 static int acpi_button_remove(struct acpi_device *device, int type); 79 79 static int acpi_button_resume(struct acpi_device *device); 80 80 static void acpi_button_notify(struct acpi_device *device, u32 event); 81 - static int acpi_button_info_open_fs(struct inode *inode, struct file *file); 82 - static int acpi_button_state_open_fs(struct inode *inode, struct file *file); 83 81 84 82 static struct acpi_driver acpi_button_driver = { 85 83 .name = "button", ··· 96 98 struct input_dev *input; 97 99 char phys[32]; /* for input device */ 98 100 unsigned long pushed; 99 - }; 100 - 101 - static const struct file_operations acpi_button_info_fops = { 102 - .owner = THIS_MODULE, 103 - .open = acpi_button_info_open_fs, 104 - .read = seq_read, 105 - .llseek = seq_lseek, 106 - .release = single_release, 107 - }; 108 - 109 - static const struct file_operations acpi_button_state_fops = { 110 - .owner = THIS_MODULE, 111 - .open = acpi_button_state_open_fs, 112 - .read = seq_read, 113 - .llseek = seq_lseek, 114 - .release = single_release, 101 + bool wakeup_enabled; 115 102 }; 116 103 117 104 static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); ··· 107 124 -------------------------------------------------------------------------- */ 108 125 109 126 static struct proc_dir_entry *acpi_button_dir; 110 - 111 - static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) 112 - { 113 - struct acpi_device *device = seq->private; 114 - 115 - seq_printf(seq, "type: %s\n", 116 - acpi_device_name(device)); 117 - return 0; 118 - } 119 - 120 - static int acpi_button_info_open_fs(struct inode *inode, struct file *file) 121 - { 122 - return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); 123 - } 127 + static struct proc_dir_entry *acpi_lid_dir; 124 128 125 129 static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 126 130 { ··· 127 157 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); 128 158 } 129 159 130 - static struct proc_dir_entry *acpi_power_dir; 131 - static struct proc_dir_entry *acpi_sleep_dir; 132 - static struct proc_dir_entry *acpi_lid_dir; 160 + static const struct file_operations acpi_button_state_fops = { 161 + .owner = THIS_MODULE, 162 + .open = acpi_button_state_open_fs, 163 + .read = seq_read, 164 + .llseek = seq_lseek, 165 + .release = single_release, 166 + }; 133 167 134 168 static int acpi_button_add_fs(struct acpi_device *device) 135 169 { 136 170 struct acpi_button *button = acpi_driver_data(device); 137 171 struct proc_dir_entry *entry = NULL; 172 + int ret = 0; 138 173 139 - switch (button->type) { 140 - case ACPI_BUTTON_TYPE_POWER: 141 - if (!acpi_power_dir) 142 - acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 143 - acpi_button_dir); 144 - entry = acpi_power_dir; 145 - break; 146 - case ACPI_BUTTON_TYPE_SLEEP: 147 - if (!acpi_sleep_dir) 148 - acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, 149 - acpi_button_dir); 150 - entry = acpi_sleep_dir; 151 - break; 152 - case ACPI_BUTTON_TYPE_LID: 153 - if (!acpi_lid_dir) 154 - acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, 155 - acpi_button_dir); 156 - entry = acpi_lid_dir; 157 - break; 174 + /* procfs I/F for ACPI lid device only */ 175 + if (button->type != ACPI_BUTTON_TYPE_LID) 176 + return 0; 177 + 178 + if (acpi_button_dir || acpi_lid_dir) { 179 + printk(KERN_ERR PREFIX "More than one Lid device found!\n"); 180 + return -EEXIST; 158 181 } 159 182 160 - if (!entry) 183 + /* create /proc/acpi/button */ 184 + acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 185 + if (!acpi_button_dir) 161 186 return -ENODEV; 162 187 163 - acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 164 - if (!acpi_device_dir(device)) 165 - return -ENODEV; 188 + /* create /proc/acpi/button/lid */ 189 + acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 190 + if (!acpi_lid_dir) { 191 + ret = -ENODEV; 192 + goto remove_button_dir; 193 + } 166 194 167 - /* 'info' [R] */ 168 - entry = proc_create_data(ACPI_BUTTON_FILE_INFO, 195 + /* create /proc/acpi/button/lid/LID/ */ 196 + acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_lid_dir); 197 + if (!acpi_device_dir(device)) { 198 + ret = -ENODEV; 199 + goto remove_lid_dir; 200 + } 201 + 202 + /* create /proc/acpi/button/lid/LID/state */ 203 + entry = proc_create_data(ACPI_BUTTON_FILE_STATE, 169 204 S_IRUGO, acpi_device_dir(device), 170 - &acpi_button_info_fops, device); 171 - if (!entry) 172 - return -ENODEV; 173 - 174 - /* show lid state [R] */ 175 - if (button->type == ACPI_BUTTON_TYPE_LID) { 176 - entry = proc_create_data(ACPI_BUTTON_FILE_STATE, 177 - S_IRUGO, acpi_device_dir(device), 178 - &acpi_button_state_fops, device); 179 - if (!entry) 180 - return -ENODEV; 205 + &acpi_button_state_fops, device); 206 + if (!entry) { 207 + ret = -ENODEV; 208 + goto remove_dev_dir; 181 209 } 182 210 183 - return 0; 211 + done: 212 + return ret; 213 + 214 + remove_dev_dir: 215 + remove_proc_entry(acpi_device_bid(device), 216 + acpi_lid_dir); 217 + acpi_device_dir(device) = NULL; 218 + remove_lid_dir: 219 + remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 220 + remove_button_dir: 221 + remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 222 + goto done; 184 223 } 185 224 186 225 static int acpi_button_remove_fs(struct acpi_device *device) 187 226 { 188 227 struct acpi_button *button = acpi_driver_data(device); 189 228 190 - if (acpi_device_dir(device)) { 191 - if (button->type == ACPI_BUTTON_TYPE_LID) 192 - remove_proc_entry(ACPI_BUTTON_FILE_STATE, 193 - acpi_device_dir(device)); 194 - remove_proc_entry(ACPI_BUTTON_FILE_INFO, 195 - acpi_device_dir(device)); 229 + if (button->type != ACPI_BUTTON_TYPE_LID) 230 + return 0; 196 231 197 - remove_proc_entry(acpi_device_bid(device), 198 - acpi_device_dir(device)->parent); 199 - acpi_device_dir(device) = NULL; 200 - } 232 + remove_proc_entry(ACPI_BUTTON_FILE_STATE, 233 + acpi_device_dir(device)); 234 + remove_proc_entry(acpi_device_bid(device), 235 + acpi_lid_dir); 236 + acpi_device_dir(device) = NULL; 237 + remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 238 + remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 201 239 202 240 return 0; 203 241 } ··· 408 430 /* Button's GPE is run-wake GPE */ 409 431 acpi_enable_gpe(device->wakeup.gpe_device, 410 432 device->wakeup.gpe_number); 411 - device->wakeup.run_wake_count++; 412 - device_set_wakeup_enable(&device->dev, true); 433 + if (!device_may_wakeup(&device->dev)) { 434 + device_set_wakeup_enable(&device->dev, true); 435 + button->wakeup_enabled = true; 436 + } 413 437 } 414 438 415 439 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device)); ··· 433 453 if (device->wakeup.flags.valid) { 434 454 acpi_disable_gpe(device->wakeup.gpe_device, 435 455 device->wakeup.gpe_number); 436 - device->wakeup.run_wake_count--; 437 - device_set_wakeup_enable(&device->dev, false); 456 + if (button->wakeup_enabled) 457 + device_set_wakeup_enable(&device->dev, false); 438 458 } 439 459 440 460 acpi_button_remove_fs(device); ··· 445 465 446 466 static int __init acpi_button_init(void) 447 467 { 448 - int result; 449 - 450 - acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 451 - if (!acpi_button_dir) 452 - return -ENODEV; 453 - 454 - result = acpi_bus_register_driver(&acpi_button_driver); 455 - if (result < 0) { 456 - remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 457 - return -ENODEV; 458 - } 459 - 460 - return 0; 468 + return acpi_bus_register_driver(&acpi_button_driver); 461 469 } 462 470 463 471 static void __exit acpi_button_exit(void) 464 472 { 465 473 acpi_bus_unregister_driver(&acpi_button_driver); 466 - 467 - if (acpi_power_dir) 468 - remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); 469 - if (acpi_sleep_dir) 470 - remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); 471 - if (acpi_lid_dir) 472 - remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 473 - remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 474 474 } 475 475 476 476 module_init(acpi_button_init);
-4
drivers/acpi/ec_sys.c
··· 24 24 25 25 #define EC_SPACE_SIZE 256 26 26 27 - struct sysdev_class acpi_ec_sysdev_class = { 28 - .name = "ec", 29 - }; 30 - 31 27 static struct dentry *acpi_ec_debugfs_dir; 32 28 33 29 static int acpi_ec_open_io(struct inode *i, struct file *f)
-3
drivers/acpi/internal.h
··· 21 21 #ifndef _ACPI_INTERNAL_H_ 22 22 #define _ACPI_INTERNAL_H_ 23 23 24 - #include <linux/sysdev.h> 25 - 26 24 #define PREFIX "ACPI: " 27 25 28 26 int init_acpi_device_notify(void); ··· 62 64 struct list_head list; 63 65 struct transaction *curr; 64 66 spinlock_t curr_lock; 65 - struct sys_device sysdev; 66 67 }; 67 68 68 69 extern struct acpi_ec *first_ec;
+19 -3
drivers/acpi/nvs.c
··· 26 26 unsigned int size; 27 27 void *kaddr; 28 28 void *data; 29 + bool unmap; 29 30 struct list_head node; 30 31 }; 31 32 ··· 44 43 int suspend_nvs_register(unsigned long start, unsigned long size) 45 44 { 46 45 struct nvs_page *entry, *next; 46 + 47 + pr_info("PM: Registering ACPI NVS region at %lx (%ld bytes)\n", 48 + start, size); 47 49 48 50 while (size > 0) { 49 51 unsigned int nr_bytes; ··· 85 81 free_page((unsigned long)entry->data); 86 82 entry->data = NULL; 87 83 if (entry->kaddr) { 88 - iounmap(entry->kaddr); 84 + if (entry->unmap) { 85 + iounmap(entry->kaddr); 86 + entry->unmap = false; 87 + } else { 88 + acpi_os_unmap_memory(entry->kaddr, 89 + entry->size); 90 + } 89 91 entry->kaddr = NULL; 90 92 } 91 93 } ··· 125 115 126 116 list_for_each_entry(entry, &nvs_list, node) 127 117 if (entry->data) { 128 - entry->kaddr = acpi_os_ioremap(entry->phys_start, 129 - entry->size); 118 + unsigned long phys = entry->phys_start; 119 + unsigned int size = entry->size; 120 + 121 + entry->kaddr = acpi_os_get_iomem(phys, size); 122 + if (!entry->kaddr) { 123 + entry->kaddr = acpi_os_ioremap(phys, size); 124 + entry->unmap = !!entry->kaddr; 125 + } 130 126 if (!entry->kaddr) { 131 127 suspend_nvs_free(); 132 128 return -ENOMEM;
+78 -59
drivers/acpi/osl.c
··· 76 76 extern char line_buf[80]; 77 77 #endif /*ENABLE_DEBUGGER */ 78 78 79 - static unsigned int acpi_irq_irq; 80 79 static acpi_osd_handler acpi_irq_handler; 81 80 static void *acpi_irq_context; 82 81 static struct workqueue_struct *kacpid_wq; ··· 104 105 void __iomem *virt; 105 106 acpi_physical_address phys; 106 107 acpi_size size; 107 - struct kref ref; 108 + unsigned long refcount; 108 109 }; 109 110 110 111 static LIST_HEAD(acpi_ioremaps); 111 - static DEFINE_SPINLOCK(acpi_ioremap_lock); 112 + static DEFINE_MUTEX(acpi_ioremap_lock); 112 113 113 114 static void __init acpi_osi_setup_late(void); 114 115 ··· 284 285 return NULL; 285 286 } 286 287 288 + void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size) 289 + { 290 + struct acpi_ioremap *map; 291 + void __iomem *virt = NULL; 292 + 293 + mutex_lock(&acpi_ioremap_lock); 294 + map = acpi_map_lookup(phys, size); 295 + if (map) { 296 + virt = map->virt + (phys - map->phys); 297 + map->refcount++; 298 + } 299 + mutex_unlock(&acpi_ioremap_lock); 300 + return virt; 301 + } 302 + EXPORT_SYMBOL_GPL(acpi_os_get_iomem); 303 + 287 304 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ 288 305 static struct acpi_ioremap * 289 306 acpi_map_lookup_virt(void __iomem *virt, acpi_size size) ··· 317 302 void __iomem *__init_refok 318 303 acpi_os_map_memory(acpi_physical_address phys, acpi_size size) 319 304 { 320 - struct acpi_ioremap *map, *tmp_map; 321 - unsigned long flags; 305 + struct acpi_ioremap *map; 322 306 void __iomem *virt; 323 307 acpi_physical_address pg_off; 324 308 acpi_size pg_sz; ··· 330 316 if (!acpi_gbl_permanent_mmap) 331 317 return __acpi_map_table((unsigned long)phys, size); 332 318 319 + mutex_lock(&acpi_ioremap_lock); 320 + /* Check if there's a suitable mapping already. */ 321 + map = acpi_map_lookup(phys, size); 322 + if (map) { 323 + map->refcount++; 324 + goto out; 325 + } 326 + 333 327 map = kzalloc(sizeof(*map), GFP_KERNEL); 334 - if (!map) 328 + if (!map) { 329 + mutex_unlock(&acpi_ioremap_lock); 335 330 return NULL; 331 + } 336 332 337 333 pg_off = round_down(phys, PAGE_SIZE); 338 334 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; 339 335 virt = acpi_os_ioremap(pg_off, pg_sz); 340 336 if (!virt) { 337 + mutex_unlock(&acpi_ioremap_lock); 341 338 kfree(map); 342 339 return NULL; 343 340 } ··· 357 332 map->virt = virt; 358 333 map->phys = pg_off; 359 334 map->size = pg_sz; 360 - kref_init(&map->ref); 335 + map->refcount = 1; 361 336 362 - spin_lock_irqsave(&acpi_ioremap_lock, flags); 363 - /* Check if page has already been mapped. */ 364 - tmp_map = acpi_map_lookup(phys, size); 365 - if (tmp_map) { 366 - kref_get(&tmp_map->ref); 367 - spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 368 - iounmap(map->virt); 369 - kfree(map); 370 - return tmp_map->virt + (phys - tmp_map->phys); 371 - } 372 337 list_add_tail_rcu(&map->list, &acpi_ioremaps); 373 - spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 374 338 339 + out: 340 + mutex_unlock(&acpi_ioremap_lock); 375 341 return map->virt + (phys - map->phys); 376 342 } 377 343 EXPORT_SYMBOL_GPL(acpi_os_map_memory); 378 344 379 - static void acpi_kref_del_iomap(struct kref *ref) 345 + static void acpi_os_drop_map_ref(struct acpi_ioremap *map) 380 346 { 381 - struct acpi_ioremap *map; 347 + if (!--map->refcount) 348 + list_del_rcu(&map->list); 349 + } 382 350 383 - map = container_of(ref, struct acpi_ioremap, ref); 384 - list_del_rcu(&map->list); 351 + static void acpi_os_map_cleanup(struct acpi_ioremap *map) 352 + { 353 + if (!map->refcount) { 354 + synchronize_rcu(); 355 + iounmap(map->virt); 356 + kfree(map); 357 + } 385 358 } 386 359 387 360 void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size) 388 361 { 389 362 struct acpi_ioremap *map; 390 - unsigned long flags; 391 - int del; 392 363 393 364 if (!acpi_gbl_permanent_mmap) { 394 365 __acpi_unmap_table(virt, size); 395 366 return; 396 367 } 397 368 398 - spin_lock_irqsave(&acpi_ioremap_lock, flags); 369 + mutex_lock(&acpi_ioremap_lock); 399 370 map = acpi_map_lookup_virt(virt, size); 400 371 if (!map) { 401 - spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 402 - printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); 403 - dump_stack(); 372 + mutex_unlock(&acpi_ioremap_lock); 373 + WARN(true, PREFIX "%s: bad address %p\n", __func__, virt); 404 374 return; 405 375 } 376 + acpi_os_drop_map_ref(map); 377 + mutex_unlock(&acpi_ioremap_lock); 406 378 407 - del = kref_put(&map->ref, acpi_kref_del_iomap); 408 - spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 409 - 410 - if (!del) 411 - return; 412 - 413 - synchronize_rcu(); 414 - iounmap(map->virt); 415 - kfree(map); 379 + acpi_os_map_cleanup(map); 416 380 } 417 381 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); 418 382 ··· 411 397 __acpi_unmap_table(virt, size); 412 398 } 413 399 414 - int acpi_os_map_generic_address(struct acpi_generic_address *addr) 400 + static int acpi_os_map_generic_address(struct acpi_generic_address *addr) 415 401 { 416 402 void __iomem *virt; 417 403 ··· 427 413 428 414 return 0; 429 415 } 430 - EXPORT_SYMBOL_GPL(acpi_os_map_generic_address); 431 416 432 - void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) 417 + static void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) 433 418 { 434 - void __iomem *virt; 435 - unsigned long flags; 436 - acpi_size size = addr->bit_width / 8; 419 + struct acpi_ioremap *map; 437 420 438 421 if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) 439 422 return; ··· 438 427 if (!addr->address || !addr->bit_width) 439 428 return; 440 429 441 - spin_lock_irqsave(&acpi_ioremap_lock, flags); 442 - virt = acpi_map_vaddr_lookup(addr->address, size); 443 - spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 430 + mutex_lock(&acpi_ioremap_lock); 431 + map = acpi_map_lookup(addr->address, addr->bit_width / 8); 432 + if (!map) { 433 + mutex_unlock(&acpi_ioremap_lock); 434 + return; 435 + } 436 + acpi_os_drop_map_ref(map); 437 + mutex_unlock(&acpi_ioremap_lock); 444 438 445 - acpi_os_unmap_memory(virt, size); 439 + acpi_os_map_cleanup(map); 446 440 } 447 - EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address); 448 441 449 442 #ifdef ACPI_FUTURE_USAGE 450 443 acpi_status ··· 531 516 acpi_irq_stats_init(); 532 517 533 518 /* 534 - * Ignore the GSI from the core, and use the value in our copy of the 535 - * FADT. It may not be the same if an interrupt source override exists 536 - * for the SCI. 519 + * ACPI interrupts different from the SCI in our copy of the FADT are 520 + * not supported. 537 521 */ 538 - gsi = acpi_gbl_FADT.sci_interrupt; 522 + if (gsi != acpi_gbl_FADT.sci_interrupt) 523 + return AE_BAD_PARAMETER; 524 + 525 + if (acpi_irq_handler) 526 + return AE_ALREADY_ACQUIRED; 527 + 539 528 if (acpi_gsi_to_irq(gsi, &irq) < 0) { 540 529 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", 541 530 gsi); ··· 550 531 acpi_irq_context = context; 551 532 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { 552 533 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 534 + acpi_irq_handler = NULL; 553 535 return AE_NOT_ACQUIRED; 554 536 } 555 - acpi_irq_irq = irq; 556 537 557 538 return AE_OK; 558 539 } 559 540 560 541 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) 561 542 { 562 - if (irq) { 563 - free_irq(irq, acpi_irq); 564 - acpi_irq_handler = NULL; 565 - acpi_irq_irq = 0; 566 - } 543 + if (irq != acpi_gbl_FADT.sci_interrupt) 544 + return AE_BAD_PARAMETER; 545 + 546 + free_irq(irq, acpi_irq); 547 + acpi_irq_handler = NULL; 567 548 568 549 return AE_OK; 569 550 } ··· 1622 1603 acpi_status acpi_os_terminate(void) 1623 1604 { 1624 1605 if (acpi_irq_handler) { 1625 - acpi_os_remove_interrupt_handler(acpi_irq_irq, 1606 + acpi_os_remove_interrupt_handler(acpi_gbl_FADT.sci_interrupt, 1626 1607 acpi_irq_handler); 1627 1608 } 1628 1609
+8 -22
drivers/acpi/pci_link.c
··· 29 29 * for IRQ management (e.g. start()->_SRS). 30 30 */ 31 31 32 - #include <linux/sysdev.h> 32 + #include <linux/syscore_ops.h> 33 33 #include <linux/kernel.h> 34 34 #include <linux/module.h> 35 35 #include <linux/init.h> ··· 757 757 return 0; 758 758 } 759 759 760 - static int irqrouter_resume(struct sys_device *dev) 760 + static void irqrouter_resume(void) 761 761 { 762 762 struct acpi_pci_link *link; 763 763 764 764 list_for_each_entry(link, &acpi_link_list, list) { 765 765 acpi_pci_link_resume(link); 766 766 } 767 - return 0; 768 767 } 769 768 770 769 static int acpi_pci_link_remove(struct acpi_device *device, int type) ··· 870 871 871 872 __setup("acpi_irq_balance", acpi_irq_balance_set); 872 873 873 - /* FIXME: we will remove this interface after all drivers call pci_disable_device */ 874 - static struct sysdev_class irqrouter_sysdev_class = { 875 - .name = "irqrouter", 874 + static struct syscore_ops irqrouter_syscore_ops = { 876 875 .resume = irqrouter_resume, 877 876 }; 878 877 879 - static struct sys_device device_irqrouter = { 880 - .id = 0, 881 - .cls = &irqrouter_sysdev_class, 882 - }; 883 - 884 - static int __init irqrouter_init_sysfs(void) 878 + static int __init irqrouter_init_ops(void) 885 879 { 886 - int error; 880 + if (!acpi_disabled && !acpi_noirq) 881 + register_syscore_ops(&irqrouter_syscore_ops); 887 882 888 - if (acpi_disabled || acpi_noirq) 889 - return 0; 890 - 891 - error = sysdev_class_register(&irqrouter_sysdev_class); 892 - if (!error) 893 - error = sysdev_register(&device_irqrouter); 894 - 895 - return error; 883 + return 0; 896 884 } 897 885 898 - device_initcall(irqrouter_init_sysfs); 886 + device_initcall(irqrouter_init_ops); 899 887 900 888 static int __init acpi_pci_link_init(void) 901 889 {
+8 -9
drivers/acpi/processor_core.c
··· 19 19 #define _COMPONENT ACPI_PROCESSOR_COMPONENT 20 20 ACPI_MODULE_NAME("processor_core"); 21 21 22 - static int set_no_mwait(const struct dmi_system_id *id) 22 + static int __init set_no_mwait(const struct dmi_system_id *id) 23 23 { 24 24 printk(KERN_NOTICE PREFIX "%s detected - " 25 25 "disabling mwait for CPU C-states\n", id->ident); ··· 27 27 return 0; 28 28 } 29 29 30 - static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { 30 + static struct dmi_system_id __initdata processor_idle_dmi_table[] = { 31 31 { 32 32 set_no_mwait, "Extensa 5220", { 33 33 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), ··· 183 183 EXPORT_SYMBOL_GPL(acpi_get_cpuid); 184 184 #endif 185 185 186 - static bool processor_physically_present(acpi_handle handle) 186 + static bool __init processor_physically_present(acpi_handle handle) 187 187 { 188 188 int cpuid, type; 189 189 u32 acpi_id; ··· 223 223 return true; 224 224 } 225 225 226 - static void acpi_set_pdc_bits(u32 *buf) 226 + static void __cpuinit acpi_set_pdc_bits(u32 *buf) 227 227 { 228 228 buf[0] = ACPI_PDC_REVISION_ID; 229 229 buf[1] = 1; ··· 235 235 arch_acpi_set_pdc_bits(buf); 236 236 } 237 237 238 - static struct acpi_object_list *acpi_processor_alloc_pdc(void) 238 + static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void) 239 239 { 240 240 struct acpi_object_list *obj_list; 241 241 union acpi_object *obj; ··· 278 278 * _PDC is required for a BIOS-OS handshake for most of the newer 279 279 * ACPI processor features. 280 280 */ 281 - static int 281 + static int __cpuinit 282 282 acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 283 283 { 284 284 acpi_status status = AE_OK; ··· 306 306 return status; 307 307 } 308 308 309 - void acpi_processor_set_pdc(acpi_handle handle) 309 + void __cpuinit acpi_processor_set_pdc(acpi_handle handle) 310 310 { 311 311 struct acpi_object_list *obj_list; 312 312 ··· 323 323 kfree(obj_list->pointer); 324 324 kfree(obj_list); 325 325 } 326 - EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); 327 326 328 - static acpi_status 327 + static acpi_status __init 329 328 early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) 330 329 { 331 330 if (processor_physically_present(handle) == false)
+2 -2
drivers/acpi/processor_driver.c
··· 635 635 return 0; 636 636 } 637 637 638 - static void __ref acpi_processor_hotplug_notify(acpi_handle handle, 639 - u32 event, void *data) 638 + static void acpi_processor_hotplug_notify(acpi_handle handle, 639 + u32 event, void *data) 640 640 { 641 641 struct acpi_processor *pr; 642 642 struct acpi_device *device = NULL;
+9 -5
drivers/acpi/reboot.c
··· 15 15 16 16 rr = &acpi_gbl_FADT.reset_register; 17 17 18 - /* Is the reset register supported? */ 19 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || 20 - rr->bit_width != 8 || rr->bit_offset != 0) 18 + /* ACPI reset register was only introduced with v2 of the FADT */ 19 + 20 + if (acpi_gbl_FADT.header.revision < 2) 21 + return; 22 + 23 + /* Is the reset register supported? The spec says we should be 24 + * checking the bit width and bit offset, but Windows ignores 25 + * these fields */ 26 + if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)) 21 27 return; 22 28 23 29 reset_value = acpi_gbl_FADT.reset_value; ··· 51 45 acpi_reset(); 52 46 break; 53 47 } 54 - /* Wait ten seconds */ 55 - acpi_os_stall(10000000); 56 48 }
-1
drivers/acpi/scan.c
··· 797 797 acpi_status status; 798 798 acpi_event_status event_status; 799 799 800 - device->wakeup.run_wake_count = 0; 801 800 device->wakeup.flags.notifier_present = 0; 802 801 803 802 /* Power button, Lid switch always enable wakeup */
+5 -23
drivers/acpi/sleep.c
··· 200 200 #endif /* CONFIG_ACPI_SLEEP */ 201 201 202 202 #ifdef CONFIG_SUSPEND 203 - extern void do_suspend_lowlevel(void); 204 - 205 203 static u32 acpi_suspend_states[] = { 206 204 [PM_SUSPEND_ON] = ACPI_STATE_S0, 207 205 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, ··· 242 244 static int acpi_suspend_enter(suspend_state_t pm_state) 243 245 { 244 246 acpi_status status = AE_OK; 245 - unsigned long flags = 0; 246 247 u32 acpi_state = acpi_target_sleep_state; 248 + int error; 247 249 248 250 ACPI_FLUSH_CPU_CACHE(); 249 251 250 - /* Do arch specific saving of state. */ 251 - if (acpi_state == ACPI_STATE_S3) { 252 - int error = acpi_save_state_mem(); 253 - 254 - if (error) 255 - return error; 256 - } 257 - 258 - local_irq_save(flags); 259 252 switch (acpi_state) { 260 253 case ACPI_STATE_S1: 261 254 barrier(); ··· 254 265 break; 255 266 256 267 case ACPI_STATE_S3: 257 - do_suspend_lowlevel(); 268 + error = acpi_suspend_lowlevel(); 269 + if (error) 270 + return error; 271 + pr_info(PREFIX "Low-level resume complete\n"); 258 272 break; 259 273 } 260 274 ··· 282 290 acpi_disable_all_gpes(); 283 291 /* Allow EC transactions to happen. */ 284 292 acpi_ec_unblock_transactions_early(); 285 - 286 - local_irq_restore(flags); 287 - printk(KERN_DEBUG "Back to C!\n"); 288 - 289 - /* restore processor state */ 290 - if (acpi_state == ACPI_STATE_S3) 291 - acpi_restore_state_mem(); 292 293 293 294 suspend_nvs_restore(); 294 295 ··· 458 473 static int acpi_hibernation_enter(void) 459 474 { 460 475 acpi_status status = AE_OK; 461 - unsigned long flags = 0; 462 476 463 477 ACPI_FLUSH_CPU_CACHE(); 464 478 465 - local_irq_save(flags); 466 479 /* This shouldn't return. If it returns, we have a problem */ 467 480 status = acpi_enter_sleep_state(ACPI_STATE_S4); 468 481 /* Reprogram control registers and execute _BFS */ 469 482 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 470 - local_irq_restore(flags); 471 483 472 484 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 473 485 }
+4 -12
drivers/pci/pci-acpi.c
··· 293 293 } 294 294 295 295 if (enable) { 296 - if (!dev->wakeup.run_wake_count++) { 297 - acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); 298 - acpi_enable_gpe(dev->wakeup.gpe_device, 299 - dev->wakeup.gpe_number); 300 - } 301 - } else if (dev->wakeup.run_wake_count > 0) { 302 - if (!--dev->wakeup.run_wake_count) { 303 - acpi_disable_gpe(dev->wakeup.gpe_device, 304 - dev->wakeup.gpe_number); 305 - acpi_disable_wakeup_device_power(dev); 306 - } 296 + acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); 297 + acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 307 298 } else { 308 - error = -EALREADY; 299 + acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 300 + acpi_disable_wakeup_device_power(dev); 309 301 } 310 302 311 303 return error;
+1 -8
drivers/pci/pcie/aer/aerdrv.h
··· 35 35 PCI_ERR_UNC_UNX_COMP| \ 36 36 PCI_ERR_UNC_MALF_TLP) 37 37 38 - struct header_log_regs { 39 - unsigned int dw0; 40 - unsigned int dw1; 41 - unsigned int dw2; 42 - unsigned int dw3; 43 - }; 44 - 45 38 #define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */ 46 39 struct aer_err_info { 47 40 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; ··· 52 59 53 60 unsigned int status; /* COR/UNCOR Error Status */ 54 61 unsigned int mask; /* COR/UNCOR Error Mask */ 55 - struct header_log_regs tlp; /* TLP Header */ 62 + struct aer_header_log_regs tlp; /* TLP Header */ 56 63 }; 57 64 58 65 struct aer_err_source {
+107 -75
drivers/pci/pcie/aer/aerdrv_errprint.c
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/pm.h> 21 21 #include <linux/suspend.h> 22 + #include <linux/cper.h> 22 23 23 24 #include "aerdrv.h" 24 25 ··· 58 57 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \ 59 58 AER_TRANSACTION_LAYER_ERROR) 60 59 61 - #define AER_PR(info, pdev, fmt, args...) \ 62 - printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \ 63 - KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \ 64 - dev_name(&pdev->dev), ## args) 65 - 66 60 /* 67 61 * AER error strings 68 62 */ 69 - static char *aer_error_severity_string[] = { 63 + static const char *aer_error_severity_string[] = { 70 64 "Uncorrected (Non-Fatal)", 71 65 "Uncorrected (Fatal)", 72 66 "Corrected" 73 67 }; 74 68 75 - static char *aer_error_layer[] = { 69 + static const char *aer_error_layer[] = { 76 70 "Physical Layer", 77 71 "Data Link Layer", 78 72 "Transaction Layer" 79 73 }; 80 - static char *aer_correctable_error_string[] = { 81 - "Receiver Error ", /* Bit Position 0 */ 74 + 75 + static const char *aer_correctable_error_string[] = { 76 + "Receiver Error", /* Bit Position 0 */ 82 77 NULL, 83 78 NULL, 84 79 NULL, 85 80 NULL, 86 81 NULL, 87 - "Bad TLP ", /* Bit Position 6 */ 88 - "Bad DLLP ", /* Bit Position 7 */ 89 - "RELAY_NUM Rollover ", /* Bit Position 8 */ 82 + "Bad TLP", /* Bit Position 6 */ 83 + "Bad DLLP", /* Bit Position 7 */ 84 + "RELAY_NUM Rollover", /* Bit Position 8 */ 90 85 NULL, 91 86 NULL, 92 87 NULL, 93 - "Replay Timer Timeout ", /* Bit Position 12 */ 94 - "Advisory Non-Fatal ", /* Bit Position 13 */ 95 - NULL, 96 - NULL, 97 - NULL, 98 - NULL, 99 - NULL, 100 - NULL, 101 - NULL, 102 - NULL, 103 - NULL, 104 - NULL, 105 - NULL, 106 - NULL, 107 - NULL, 108 - NULL, 109 - NULL, 110 - NULL, 111 - NULL, 112 - NULL, 88 + "Replay Timer Timeout", /* Bit Position 12 */ 89 + "Advisory Non-Fatal", /* Bit Position 13 */ 113 90 }; 114 91 115 - static char *aer_uncorrectable_error_string[] = { 92 + static const char *aer_uncorrectable_error_string[] = { 116 93 NULL, 117 94 NULL, 118 95 NULL, 119 96 NULL, 120 - "Data Link Protocol ", /* Bit Position 4 */ 121 - NULL, 122 - NULL, 123 - NULL, 124 - NULL, 125 - NULL, 126 - NULL, 127 - NULL, 128 - "Poisoned TLP ", /* Bit Position 12 */ 129 - "Flow Control Protocol ", /* Bit Position 13 */ 130 - "Completion Timeout ", /* Bit Position 14 */ 131 - "Completer Abort ", /* Bit Position 15 */ 132 - "Unexpected Completion ", /* Bit Position 16 */ 133 - "Receiver Overflow ", /* Bit Position 17 */ 134 - "Malformed TLP ", /* Bit Position 18 */ 135 - "ECRC ", /* Bit Position 19 */ 136 - "Unsupported Request ", /* Bit Position 20 */ 97 + "Data Link Protocol", /* Bit Position 4 */ 137 98 NULL, 138 99 NULL, 139 100 NULL, ··· 103 140 NULL, 104 141 NULL, 105 142 NULL, 106 - NULL, 107 - NULL, 108 - NULL, 109 - NULL, 143 + "Poisoned TLP", /* Bit Position 12 */ 144 + "Flow Control Protocol", /* Bit Position 13 */ 145 + "Completion Timeout", /* Bit Position 14 */ 146 + "Completer Abort", /* Bit Position 15 */ 147 + "Unexpected Completion", /* Bit Position 16 */ 148 + "Receiver Overflow", /* Bit Position 17 */ 149 + "Malformed TLP", /* Bit Position 18 */ 150 + "ECRC", /* Bit Position 19 */ 151 + "Unsupported Request", /* Bit Position 20 */ 110 152 }; 111 153 112 - static char *aer_agent_string[] = { 154 + static const char *aer_agent_string[] = { 113 155 "Receiver ID", 114 156 "Requester ID", 115 157 "Completer ID", 116 158 "Transmitter ID" 117 159 }; 118 160 119 - static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) 161 + static void __aer_print_error(const char *prefix, 162 + struct aer_err_info *info) 120 163 { 121 164 int i, status; 122 - char *errmsg = NULL; 165 + const char *errmsg = NULL; 123 166 124 167 status = (info->status & ~info->mask); 125 168 ··· 134 165 continue; 135 166 136 167 if (info->severity == AER_CORRECTABLE) 137 - errmsg = aer_correctable_error_string[i]; 168 + errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ? 169 + aer_correctable_error_string[i] : NULL; 138 170 else 139 - errmsg = aer_uncorrectable_error_string[i]; 171 + errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ? 172 + aer_uncorrectable_error_string[i] : NULL; 140 173 141 174 if (errmsg) 142 - AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg, 175 + printk("%s"" [%2d] %-22s%s\n", prefix, i, errmsg, 143 176 info->first_error == i ? " (First)" : ""); 144 177 else 145 - AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i, 178 + printk("%s"" [%2d] Unknown Error Bit%s\n", prefix, i, 146 179 info->first_error == i ? " (First)" : ""); 147 180 } 148 181 } ··· 152 181 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) 153 182 { 154 183 int id = ((dev->bus->number << 8) | dev->devfn); 184 + char prefix[44]; 185 + 186 + snprintf(prefix, sizeof(prefix), "%s%s %s: ", 187 + (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR, 188 + dev_driver_string(&dev->dev), dev_name(&dev->dev)); 155 189 156 190 if (info->status == 0) { 157 - AER_PR(info, dev, 158 - "PCIe Bus Error: severity=%s, type=Unaccessible, " 159 - "id=%04x(Unregistered Agent ID)\n", 191 + printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, " 192 + "id=%04x(Unregistered Agent ID)\n", prefix, 160 193 aer_error_severity_string[info->severity], id); 161 194 } else { 162 195 int layer, agent; ··· 168 193 layer = AER_GET_LAYER_ERROR(info->severity, info->status); 169 194 agent = AER_GET_AGENT(info->severity, info->status); 170 195 171 - AER_PR(info, dev, 172 - "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 173 - aer_error_severity_string[info->severity], 196 + printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 197 + prefix, aer_error_severity_string[info->severity], 174 198 aer_error_layer[layer], id, aer_agent_string[agent]); 175 199 176 - AER_PR(info, dev, 177 - " device [%04x:%04x] error status/mask=%08x/%08x\n", 178 - dev->vendor, dev->device, info->status, info->mask); 200 + printk("%s"" device [%04x:%04x] error status/mask=%08x/%08x\n", 201 + prefix, dev->vendor, dev->device, 202 + info->status, info->mask); 179 203 180 - __aer_print_error(info, dev); 204 + __aer_print_error(prefix, info); 181 205 182 206 if (info->tlp_header_valid) { 183 207 unsigned char *tlp = (unsigned char *) &info->tlp; 184 - AER_PR(info, dev, " TLP Header:" 208 + printk("%s"" TLP Header:" 185 209 " %02x%02x%02x%02x %02x%02x%02x%02x" 186 210 " %02x%02x%02x%02x %02x%02x%02x%02x\n", 187 - *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 211 + prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 188 212 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), 189 213 *(tlp + 11), *(tlp + 10), *(tlp + 9), 190 214 *(tlp + 8), *(tlp + 15), *(tlp + 14), ··· 192 218 } 193 219 194 220 if (info->id && info->error_dev_num > 1 && info->id == id) 195 - AER_PR(info, dev, 196 - " Error of this Agent(%04x) is reported first\n", id); 221 + printk("%s"" Error of this Agent(%04x) is reported first\n", 222 + prefix, id); 197 223 } 198 224 199 225 void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) ··· 202 228 info->multi_error_valid ? "Multiple " : "", 203 229 aer_error_severity_string[info->severity], info->id); 204 230 } 231 + 232 + #ifdef CONFIG_ACPI_APEI_PCIEAER 233 + static int cper_severity_to_aer(int cper_severity) 234 + { 235 + switch (cper_severity) { 236 + case CPER_SEV_RECOVERABLE: 237 + return AER_NONFATAL; 238 + case CPER_SEV_FATAL: 239 + return AER_FATAL; 240 + default: 241 + return AER_CORRECTABLE; 242 + } 243 + } 244 + 245 + void cper_print_aer(const char *prefix, int cper_severity, 246 + struct aer_capability_regs *aer) 247 + { 248 + int aer_severity, layer, agent, status_strs_size, tlp_header_valid = 0; 249 + u32 status, mask; 250 + const char **status_strs; 251 + 252 + aer_severity = cper_severity_to_aer(cper_severity); 253 + if (aer_severity == AER_CORRECTABLE) { 254 + status = aer->cor_status; 255 + mask = aer->cor_mask; 256 + status_strs = aer_correctable_error_string; 257 + status_strs_size = ARRAY_SIZE(aer_correctable_error_string); 258 + } else { 259 + status = aer->uncor_status; 260 + mask = aer->uncor_mask; 261 + status_strs = aer_uncorrectable_error_string; 262 + status_strs_size = ARRAY_SIZE(aer_uncorrectable_error_string); 263 + tlp_header_valid = status & AER_LOG_TLP_MASKS; 264 + } 265 + layer = AER_GET_LAYER_ERROR(aer_severity, status); 266 + agent = AER_GET_AGENT(aer_severity, status); 267 + printk("%s""aer_status: 0x%08x, aer_mask: 0x%08x\n", 268 + prefix, status, mask); 269 + cper_print_bits(prefix, status, status_strs, status_strs_size); 270 + printk("%s""aer_layer=%s, aer_agent=%s\n", prefix, 271 + aer_error_layer[layer], aer_agent_string[agent]); 272 + if (aer_severity != AER_CORRECTABLE) 273 + printk("%s""aer_uncor_severity: 0x%08x\n", 274 + prefix, aer->uncor_severity); 275 + if (tlp_header_valid) { 276 + const unsigned char *tlp; 277 + tlp = (const unsigned char *)&aer->header_log; 278 + printk("%s""aer_tlp_header:" 279 + " %02x%02x%02x%02x %02x%02x%02x%02x" 280 + " %02x%02x%02x%02x %02x%02x%02x%02x\n", 281 + prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 282 + *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), 283 + *(tlp + 11), *(tlp + 10), *(tlp + 9), 284 + *(tlp + 8), *(tlp + 15), *(tlp + 14), 285 + *(tlp + 13), *(tlp + 12)); 286 + } 287 + } 288 + #endif
+2 -1
drivers/thermal/thermal_sys.c
··· 560 560 561 561 tz->hwmon = NULL; 562 562 device_remove_file(hwmon->device, &tz->temp_input.attr); 563 - device_remove_file(hwmon->device, &tz->temp_crit.attr); 563 + if (tz->ops->get_crit_temp) 564 + device_remove_file(hwmon->device, &tz->temp_crit.attr); 564 565 565 566 mutex_lock(&thermal_list_lock); 566 567 list_del(&tz->hwmon_node);
+9 -3
include/acpi/acoutput.h
··· 183 183 184 184 #if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) 185 185 /* 186 - * Module name is included in both debug and non-debug versions primarily for 187 - * error messages. The __FILE__ macro is not very useful for this, because it 188 - * often includes the entire pathname to the module 186 + * The module name is used primarily for error and debug messages. 187 + * The __FILE__ macro is not very useful for this, because it 188 + * usually includes the entire pathname to the module making the 189 + * debug output difficult to read. 189 190 */ 190 191 #define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name; 191 192 #else 193 + /* 194 + * For the no-debug and no-error-msg cases, we must at least define 195 + * a null module name. 196 + */ 192 197 #define ACPI_MODULE_NAME(name) 198 + #define _acpi_module_name "" 193 199 #endif 194 200 195 201 /*
-1
include/acpi/acpi_bus.h
··· 250 250 struct acpi_handle_list resources; 251 251 struct acpi_device_wakeup_flags flags; 252 252 int prepare_count; 253 - int run_wake_count; 254 253 }; 255 254 256 255 /* Device */
+1 -1
include/acpi/acpixf.h
··· 47 47 48 48 /* Current ACPICA subsystem version in YYYYMMDD format */ 49 49 50 - #define ACPI_CA_VERSION 0x20110112 50 + #define ACPI_CA_VERSION 0x20110316 51 51 52 52 #include "actypes.h" 53 53 #include "actbl.h"
+16
include/acpi/actbl.h
··· 343 343 #include <acpi/actbl1.h> 344 344 #include <acpi/actbl2.h> 345 345 346 + /* 347 + * Sizes of the various flavors of FADT. We need to look closely 348 + * at the FADT length because the version number essentially tells 349 + * us nothing because of many BIOS bugs where the version does not 350 + * match the expected length. In other words, the length of the 351 + * FADT is the bottom line as to what the version really is. 352 + * 353 + * For reference, the values below are as follows: 354 + * FADT V1 size: 0x74 355 + * FADT V2 size: 0x84 356 + * FADT V3+ size: 0xF4 357 + */ 358 + #define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4) 359 + #define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3) 360 + #define ACPI_FADT_V3_SIZE (u32) (sizeof (struct acpi_table_fadt)) 361 + 346 362 #endif /* __ACTBL_H__ */
+63 -1
include/acpi/actbl2.h
··· 1 1 /****************************************************************************** 2 2 * 3 - * Name: actbl2.h - ACPI Specification Revision 2.0 Tables 3 + * Name: actbl2.h - ACPI Table Definitions (tables not in ACPI spec) 4 4 * 5 5 *****************************************************************************/ 6 6 ··· 712 712 u8 pci_bus; 713 713 u8 pci_device; 714 714 u8 pci_function; 715 + }; 716 + 717 + /******************************************************************************* 718 + * 719 + * SLIC - Software Licensing Description Table 720 + * Version 1 721 + * 722 + * Conforms to "OEM Activation 2.0 for Windows Vista Operating Systems", 723 + * Copyright 2006 724 + * 725 + ******************************************************************************/ 726 + 727 + /* Basic SLIC table is only the common ACPI header */ 728 + 729 + struct acpi_table_slic { 730 + struct acpi_table_header header; /* Common ACPI table header */ 731 + }; 732 + 733 + /* Common SLIC subtable header */ 734 + 735 + struct acpi_slic_header { 736 + u32 type; 737 + u32 length; 738 + }; 739 + 740 + /* Values for Type field above */ 741 + 742 + enum acpi_slic_type { 743 + ACPI_SLIC_TYPE_PUBLIC_KEY = 0, 744 + ACPI_SLIC_TYPE_WINDOWS_MARKER = 1, 745 + ACPI_SLIC_TYPE_RESERVED = 2 /* 2 and greater are reserved */ 746 + }; 747 + 748 + /* 749 + * SLIC Sub-tables, correspond to Type in struct acpi_slic_header 750 + */ 751 + 752 + /* 0: Public Key Structure */ 753 + 754 + struct acpi_slic_key { 755 + struct acpi_slic_header header; 756 + u8 key_type; 757 + u8 version; 758 + u16 reserved; 759 + u32 algorithm; 760 + char magic[4]; 761 + u32 bit_length; 762 + u32 exponent; 763 + u8 modulus[128]; 764 + }; 765 + 766 + /* 1: Windows Marker Structure */ 767 + 768 + struct acpi_slic_marker { 769 + struct acpi_slic_header header; 770 + u32 version; 771 + char oem_id[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ 772 + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ 773 + char windows_flag[8]; 774 + u32 slic_version; 775 + u8 reserved[16]; 776 + u8 signature[128]; 715 777 }; 716 778 717 779 /*******************************************************************************
+3 -2
include/acpi/apei.h
··· 30 30 31 31 int erst_write(const struct cper_record_header *record); 32 32 ssize_t erst_get_record_count(void); 33 - int erst_get_next_record_id(u64 *record_id); 33 + int erst_get_record_id_begin(int *pos); 34 + int erst_get_record_id_next(int *pos, u64 *record_id); 35 + void erst_get_record_id_end(void); 34 36 ssize_t erst_read(u64 record_id, struct cper_record_header *record, 35 37 size_t buflen); 36 - ssize_t erst_read_next(struct cper_record_header *record, size_t buflen); 37 38 int erst_clear(u64 record_id); 38 39 39 40 #endif
+1 -2
include/linux/acpi_io.h
··· 10 10 return ioremap_cache(phys, size); 11 11 } 12 12 13 - int acpi_os_map_generic_address(struct acpi_generic_address *addr); 14 - void acpi_os_unmap_generic_address(struct acpi_generic_address *addr); 13 + void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size); 15 14 16 15 #endif
+24
include/linux/aer.h
··· 7 7 #ifndef _AER_H_ 8 8 #define _AER_H_ 9 9 10 + struct aer_header_log_regs { 11 + unsigned int dw0; 12 + unsigned int dw1; 13 + unsigned int dw2; 14 + unsigned int dw3; 15 + }; 16 + 17 + struct aer_capability_regs { 18 + u32 header; 19 + u32 uncor_status; 20 + u32 uncor_mask; 21 + u32 uncor_severity; 22 + u32 cor_status; 23 + u32 cor_mask; 24 + u32 cap_control; 25 + struct aer_header_log_regs header_log; 26 + u32 root_command; 27 + u32 root_status; 28 + u16 cor_err_source; 29 + u16 uncor_err_source; 30 + }; 31 + 10 32 #if defined(CONFIG_PCIEAER) 11 33 /* pci-e port driver needs this function to enable aer */ 12 34 extern int pci_enable_pcie_error_reporting(struct pci_dev *dev); ··· 49 27 } 50 28 #endif 51 29 30 + extern void cper_print_aer(const char *prefix, int cper_severity, 31 + struct aer_capability_regs *aer); 52 32 #endif //_AER_H_ 53 33
+2
include/linux/cper.h
··· 388 388 #pragma pack() 389 389 390 390 u64 cper_next_record_id(void); 391 + void cper_print_bits(const char *prefix, unsigned int bits, 392 + const char *strs[], unsigned int strs_size); 391 393 392 394 #endif