Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
1 | /****************************************************************************** |
1 | /****************************************************************************** |
2 | * |
2 | * |
3 | * Module Name: aehandlers - Various handlers for acpiexec |
3 | * Module Name: aehandlers - Various handlers for acpiexec |
4 | * |
4 | * |
5 | *****************************************************************************/ |
5 | *****************************************************************************/ |
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
17 | * rights. You may have additional license terms from the party that provided |
17 | * rights. You may have additional license terms from the party that provided |
18 | * you this software, covering your right to use that party's intellectual |
18 | * you this software, covering your right to use that party's intellectual |
19 | * property rights. |
19 | * property rights. |
20 | * |
20 | * |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
22 | * copy of the source code appearing in this file ("Covered Code") an |
22 | * copy of the source code appearing in this file ("Covered Code") an |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
25 | * make derivatives, distribute, use and display any portion of the Covered |
25 | * make derivatives, distribute, use and display any portion of the Covered |
26 | * Code in any form, with the right to sublicense such rights; and |
26 | * Code in any form, with the right to sublicense such rights; and |
27 | * |
27 | * |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
29 | * license (with the right to sublicense), under only those claims of Intel |
29 | * license (with the right to sublicense), under only those claims of Intel |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
32 | * solely to the minimum extent necessary to exercise the above copyright |
32 | * solely to the minimum extent necessary to exercise the above copyright |
33 | * license, and in no event shall the patent license extend to any additions |
33 | * license, and in no event shall the patent license extend to any additions |
34 | * to or modifications of the Original Intel Code. No other license or right |
34 | * to or modifications of the Original Intel Code. No other license or right |
35 | * is granted directly or by implication, estoppel or otherwise; |
35 | * is granted directly or by implication, estoppel or otherwise; |
36 | * |
36 | * |
37 | * The above copyright and patent license is granted only if the following |
37 | * The above copyright and patent license is granted only if the following |
38 | * conditions are met: |
38 | * conditions are met: |
39 | * |
39 | * |
40 | * 3. Conditions |
40 | * 3. Conditions |
41 | * |
41 | * |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
43 | * Redistribution of source code of any substantial portion of the Covered |
43 | * Redistribution of source code of any substantial portion of the Covered |
44 | * Code or modification with rights to further distribute source must include |
44 | * Code or modification with rights to further distribute source must include |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
48 | * contain a file documenting the changes Licensee made to create that Covered |
48 | * contain a file documenting the changes Licensee made to create that Covered |
49 | * Code and the date of any change. Licensee must include in that file the |
49 | * Code and the date of any change. Licensee must include in that file the |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
51 | * must include a prominent statement that the modification is derived, |
51 | * must include a prominent statement that the modification is derived, |
52 | * directly or indirectly, from Original Intel Code. |
52 | * directly or indirectly, from Original Intel Code. |
53 | * |
53 | * |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
55 | * Redistribution of source code of any substantial portion of the Covered |
55 | * Redistribution of source code of any substantial portion of the Covered |
56 | * Code or modification without rights to further distribute source must |
56 | * Code or modification without rights to further distribute source must |
57 | * include the following Disclaimer and Export Compliance provision in the |
57 | * include the following Disclaimer and Export Compliance provision in the |
58 | * documentation and/or other materials provided with distribution. In |
58 | * documentation and/or other materials provided with distribution. In |
59 | * addition, Licensee may not authorize further sublicense of source of any |
59 | * addition, Licensee may not authorize further sublicense of source of any |
60 | * portion of the Covered Code, and must include terms to the effect that the |
60 | * portion of the Covered Code, and must include terms to the effect that the |
61 | * license from Licensee to its licensee is limited to the intellectual |
61 | * license from Licensee to its licensee is limited to the intellectual |
62 | * property embodied in the software Licensee provides to its licensee, and |
62 | * property embodied in the software Licensee provides to its licensee, and |
63 | * not to intellectual property embodied in modifications its licensee may |
63 | * not to intellectual property embodied in modifications its licensee may |
64 | * make. |
64 | * make. |
65 | * |
65 | * |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
67 | * substantial portion of the Covered Code or modification must reproduce the |
67 | * substantial portion of the Covered Code or modification must reproduce the |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
69 | * provision in the documentation and/or other materials provided with the |
69 | * provision in the documentation and/or other materials provided with the |
70 | * distribution. |
70 | * distribution. |
71 | * |
71 | * |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
73 | * Intel Code. |
73 | * Intel Code. |
74 | * |
74 | * |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
77 | * other dealings in products derived from or relating to the Covered Code |
77 | * other dealings in products derived from or relating to the Covered Code |
78 | * without prior written authorization from Intel. |
78 | * without prior written authorization from Intel. |
79 | * |
79 | * |
80 | * 4. Disclaimer and Export Compliance |
80 | * 4. Disclaimer and Export Compliance |
81 | * |
81 | * |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
88 | * PARTICULAR PURPOSE. |
88 | * PARTICULAR PURPOSE. |
89 | * |
89 | * |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
97 | * LIMITED REMEDY. |
97 | * LIMITED REMEDY. |
98 | * |
98 | * |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
100 | * software or system incorporating such software without first obtaining any |
100 | * software or system incorporating such software without first obtaining any |
101 | * required license or other approval from the U. S. Department of Commerce or |
101 | * required license or other approval from the U. S. Department of Commerce or |
102 | * any other agency or department of the United States Government. In the |
102 | * any other agency or department of the United States Government. In the |
103 | * event Licensee exports any such software from the United States or |
103 | * event Licensee exports any such software from the United States or |
104 | * re-exports any such software from a foreign destination, Licensee shall |
104 | * re-exports any such software from a foreign destination, Licensee shall |
105 | * ensure that the distribution and export/re-export of the software is in |
105 | * ensure that the distribution and export/re-export of the software is in |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
109 | * software, or service, directly or indirectly, to any country for which the |
109 | * software, or service, directly or indirectly, to any country for which the |
110 | * United States government or any agency thereof requires an export license, |
110 | * United States government or any agency thereof requires an export license, |
111 | * other governmental approval, or letter of assurance, without first obtaining |
111 | * other governmental approval, or letter of assurance, without first obtaining |
112 | * such license, approval or letter. |
112 | * such license, approval or letter. |
113 | * |
113 | * |
114 | *****************************************************************************/ |
114 | *****************************************************************************/ |
115 | 115 | ||
116 | #include "aecommon.h" |
116 | #include "aecommon.h" |
117 | 117 | ||
118 | #define _COMPONENT ACPI_TOOLS |
118 | #define _COMPONENT ACPI_TOOLS |
119 | ACPI_MODULE_NAME ("aehandlers") |
119 | ACPI_MODULE_NAME ("aehandlers") |
120 | 120 | ||
121 | /* Local prototypes */ |
121 | /* Local prototypes */ |
122 | 122 | ||
123 | void |
123 | static void |
124 | AeNotifyHandler ( |
124 | AeNotifyHandler ( |
125 | ACPI_HANDLE Device, |
125 | ACPI_HANDLE Device, |
126 | UINT32 Value, |
126 | UINT32 Value, |
127 | void *Context); |
127 | void *Context); |
128 | 128 | ||
129 | void |
129 | static void |
130 | AeDeviceNotifyHandler ( |
130 | AeDeviceNotifyHandler ( |
131 | ACPI_HANDLE Device, |
131 | ACPI_HANDLE Device, |
132 | UINT32 Value, |
132 | UINT32 Value, |
133 | void *Context); |
133 | void *Context); |
134 | 134 | ||
135 | ACPI_STATUS |
135 | static ACPI_STATUS |
136 | AeExceptionHandler ( |
136 | AeExceptionHandler ( |
137 | ACPI_STATUS AmlStatus, |
137 | ACPI_STATUS AmlStatus, |
138 | ACPI_NAME Name, |
138 | ACPI_NAME Name, |
139 | UINT16 Opcode, |
139 | UINT16 Opcode, |
140 | UINT32 AmlOffset, |
140 | UINT32 AmlOffset, |
141 | void *Context); |
141 | void *Context); |
142 | 142 | ||
143 | ACPI_STATUS |
143 | static ACPI_STATUS |
144 | AeTableHandler ( |
144 | AeTableHandler ( |
145 | UINT32 Event, |
145 | UINT32 Event, |
146 | void *Table, |
146 | void *Table, |
147 | void *Context); |
147 | void *Context); |
148 | 148 | ||
149 | ACPI_STATUS |
149 | static ACPI_STATUS |
150 | AeRegionInit ( |
150 | AeRegionInit ( |
151 | ACPI_HANDLE RegionHandle, |
151 | ACPI_HANDLE RegionHandle, |
152 | UINT32 Function, |
152 | UINT32 Function, |
153 | void *HandlerContext, |
153 | void *HandlerContext, |
154 | void **RegionContext); |
154 | void **RegionContext); |
155 | 155 | ||
156 | void |
156 | static void |
157 | AeAttachedDataHandler ( |
157 | AeAttachedDataHandler ( |
158 | ACPI_HANDLE Object, |
158 | ACPI_HANDLE Object, |
159 | void *Data); |
159 | void *Data); |
- | 160 | ||
- | 161 | static UINT32 |
|
- | 162 | AeInterfaceHandler ( |
|
- | 163 | ACPI_STRING InterfaceName, |
|
- | 164 | UINT32 Supported); |
|
- | 165 | ||
- | 166 | static UINT32 |
|
- | 167 | AeEventHandler ( |
|
- | 168 | void *Context); |
|
160 | 169 | ||
161 | UINT32 SigintCount = 0; |
170 | static UINT32 SigintCount = 0; |
- | 171 | static AE_DEBUG_REGIONS AeRegions; |
|
- | 172 | ||
- | 173 | ||
- | 174 | /* |
|
- | 175 | * We will override some of the default region handlers, especially the |
|
- | 176 | * SystemMemory handler, which must be implemented locally. Do not override |
|
- | 177 | * the PCI_Config handler since we would like to exercise the default handler |
|
- | 178 | * code. These handlers are installed "early" - before any _REG methods |
|
- | 179 | * are executed - since they are special in the sense that tha ACPI spec |
|
- | 180 | * declares that they must "always be available". Cannot override the |
|
- | 181 | * DataTable region handler either -- needed for test execution. |
|
- | 182 | */ |
|
- | 183 | static ACPI_ADR_SPACE_TYPE DefaultSpaceIdList[] = { |
|
- | 184 | ACPI_ADR_SPACE_SYSTEM_MEMORY, |
|
- | 185 | ACPI_ADR_SPACE_SYSTEM_IO |
|
- | 186 | }; |
|
- | 187 | ||
- | 188 | /* |
|
- | 189 | * We will install handlers for some of the various address space IDs |
|
- | 190 | * Test one user-defined address space (used by aslts.) |
|
- | 191 | */ |
|
- | 192 | #define ACPI_ADR_SPACE_USER_DEFINED 0x80 |
|
- | 193 | ||
- | 194 | static ACPI_ADR_SPACE_TYPE SpaceIdList[] = { |
|
- | 195 | ACPI_ADR_SPACE_EC, |
|
- | 196 | ACPI_ADR_SPACE_SMBUS, |
|
- | 197 | ACPI_ADR_SPACE_PCI_BAR_TARGET, |
|
- | 198 | ACPI_ADR_SPACE_IPMI, |
|
- | 199 | ACPI_ADR_SPACE_FIXED_HARDWARE, |
|
- | 200 | ACPI_ADR_SPACE_USER_DEFINED |
|
162 | AE_DEBUG_REGIONS AeRegions; |
201 | }; |
163 | 202 | ||
164 | 203 | ||
165 | /****************************************************************************** |
204 | /****************************************************************************** |
166 | * |
205 | * |
167 | * FUNCTION: AeCtrlCHandler |
206 | * FUNCTION: AeCtrlCHandler |
168 | * |
207 | * |
169 | * PARAMETERS: Sig |
208 | * PARAMETERS: Sig |
170 | * |
209 | * |
171 | * RETURN: none |
210 | * RETURN: none |
172 | * |
211 | * |
173 | * DESCRIPTION: Control-C handler. Abort running control method if any. |
212 | * DESCRIPTION: Control-C handler. Abort running control method if any. |
174 | * |
213 | * |
175 | *****************************************************************************/ |
214 | *****************************************************************************/ |
176 | 215 | ||
177 | void __cdecl |
216 | void ACPI_SYSTEM_XFACE |
178 | AeCtrlCHandler ( |
217 | AeCtrlCHandler ( |
179 | int Sig) |
218 | int Sig) |
180 | { |
219 | { |
181 | 220 | ||
182 | signal (SIGINT, SIG_IGN); |
221 | signal (SIGINT, SIG_IGN); |
183 | SigintCount++; |
222 | SigintCount++; |
184 | 223 | ||
185 | AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount); |
224 | AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount); |
186 | 225 | ||
187 | if (AcpiGbl_MethodExecuting) |
226 | if (AcpiGbl_MethodExecuting) |
188 | { |
227 | { |
189 | AcpiGbl_AbortMethod = TRUE; |
228 | AcpiGbl_AbortMethod = TRUE; |
190 | signal (SIGINT, AeCtrlCHandler); |
229 | signal (SIGINT, AeCtrlCHandler); |
191 | 230 | ||
192 | if (SigintCount < 10) |
231 | if (SigintCount < 10) |
193 | { |
232 | { |
194 | return; |
233 | return; |
195 | } |
234 | } |
196 | } |
235 | } |
197 | 236 | ||
198 | exit (0); |
237 | exit (0); |
199 | } |
238 | } |
200 | 239 | ||
201 | 240 | ||
202 | /****************************************************************************** |
241 | /****************************************************************************** |
203 | * |
242 | * |
204 | * FUNCTION: AeNotifyHandler |
243 | * FUNCTION: AeNotifyHandler |
205 | * |
244 | * |
206 | * PARAMETERS: Standard notify handler parameters |
245 | * PARAMETERS: Standard notify handler parameters |
207 | * |
246 | * |
208 | * RETURN: Status |
247 | * RETURN: Status |
209 | * |
248 | * |
210 | * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL |
249 | * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL |
211 | * test suite(s) to communicate errors and other information to |
250 | * test suite(s) to communicate errors and other information to |
212 | * this utility via the Notify() operator. |
251 | * this utility via the Notify() operator. |
213 | * |
252 | * |
214 | *****************************************************************************/ |
253 | *****************************************************************************/ |
215 | 254 | ||
216 | void |
255 | static void |
217 | AeNotifyHandler ( |
256 | AeNotifyHandler ( |
218 | ACPI_HANDLE Device, |
257 | ACPI_HANDLE Device, |
219 | UINT32 Value, |
258 | UINT32 Value, |
220 | void *Context) |
259 | void *Context) |
221 | { |
260 | { |
222 | 261 | ||
223 | switch (Value) |
262 | switch (Value) |
224 | { |
263 | { |
225 | #if 0 |
264 | #if 0 |
226 | case 0: |
265 | case 0: |
227 | printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value); |
266 | printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value); |
228 | if (AcpiGbl_DebugFile) |
267 | if (AcpiGbl_DebugFile) |
229 | { |
268 | { |
230 | AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n"); |
269 | AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n"); |
231 | } |
270 | } |
232 | break; |
271 | break; |
233 | 272 | ||
234 | 273 | ||
235 | case 1: |
274 | case 1: |
236 | printf ("[AcpiExec] Method Error: Incorrect numeric result\n"); |
275 | printf ("[AcpiExec] Method Error: Incorrect numeric result\n"); |
237 | if (AcpiGbl_DebugFile) |
276 | if (AcpiGbl_DebugFile) |
238 | { |
277 | { |
239 | AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n"); |
278 | AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n"); |
240 | } |
279 | } |
241 | break; |
280 | break; |
242 | 281 | ||
243 | 282 | ||
244 | case 2: |
283 | case 2: |
245 | printf ("[AcpiExec] Method Error: An operand was overwritten\n"); |
284 | printf ("[AcpiExec] Method Error: An operand was overwritten\n"); |
246 | if (AcpiGbl_DebugFile) |
285 | if (AcpiGbl_DebugFile) |
247 | { |
286 | { |
248 | AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n"); |
287 | AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n"); |
249 | } |
288 | } |
250 | break; |
289 | break; |
251 | 290 | ||
252 | #endif |
291 | #endif |
253 | 292 | ||
254 | default: |
293 | default: |
255 | printf ("[AcpiExec] Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", |
294 | printf ("[AcpiExec] Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", |
256 | AcpiUtGetNodeName (Device), Device, Value, |
295 | AcpiUtGetNodeName (Device), Device, Value, |
257 | AcpiUtGetNotifyName (Value)); |
296 | AcpiUtGetNotifyName (Value)); |
258 | if (AcpiGbl_DebugFile) |
297 | if (AcpiGbl_DebugFile) |
259 | { |
298 | { |
260 | AcpiOsPrintf ("[AcpiExec] Received a system notify, Value 0x%2.2X\n", Value); |
299 | AcpiOsPrintf ("[AcpiExec] Received a system notify, Value 0x%2.2X\n", Value); |
261 | } |
300 | } |
262 | 301 | ||
263 | (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); |
302 | (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); |
264 | break; |
303 | break; |
265 | } |
304 | } |
266 | - | ||
267 | } |
305 | } |
268 | 306 | ||
269 | 307 | ||
270 | /****************************************************************************** |
308 | /****************************************************************************** |
271 | * |
309 | * |
272 | * FUNCTION: AeDeviceNotifyHandler |
310 | * FUNCTION: AeDeviceNotifyHandler |
273 | * |
311 | * |
274 | * PARAMETERS: Standard notify handler parameters |
312 | * PARAMETERS: Standard notify handler parameters |
275 | * |
313 | * |
276 | * RETURN: Status |
314 | * RETURN: Status |
277 | * |
315 | * |
278 | * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL |
316 | * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL |
279 | * test suite(s) to communicate errors and other information to |
317 | * test suite(s) to communicate errors and other information to |
280 | * this utility via the Notify() operator. |
318 | * this utility via the Notify() operator. |
281 | * |
319 | * |
282 | *****************************************************************************/ |
320 | *****************************************************************************/ |
283 | 321 | ||
284 | void |
322 | static void |
285 | AeDeviceNotifyHandler ( |
323 | AeDeviceNotifyHandler ( |
286 | ACPI_HANDLE Device, |
324 | ACPI_HANDLE Device, |
287 | UINT32 Value, |
325 | UINT32 Value, |
288 | void *Context) |
326 | void *Context) |
289 | { |
327 | { |
290 | 328 | ||
291 | printf ("[AcpiExec] Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", |
329 | printf ("[AcpiExec] Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", |
292 | AcpiUtGetNodeName (Device), Device, Value, |
330 | AcpiUtGetNodeName (Device), Device, Value, |
293 | AcpiUtGetNotifyName (Value)); |
331 | AcpiUtGetNotifyName (Value)); |
294 | if (AcpiGbl_DebugFile) |
332 | if (AcpiGbl_DebugFile) |
295 | { |
333 | { |
296 | AcpiOsPrintf ("[AcpiExec] Received a device notify, Value 0x%2.2X\n", Value); |
334 | AcpiOsPrintf ("[AcpiExec] Received a device notify, Value 0x%2.2X\n", Value); |
297 | } |
335 | } |
298 | 336 | ||
299 | (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); |
337 | (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); |
300 | } |
338 | } |
301 | 339 | ||
302 | 340 | ||
303 | /****************************************************************************** |
341 | /****************************************************************************** |
304 | * |
342 | * |
305 | * FUNCTION: AeExceptionHandler |
343 | * FUNCTION: AeExceptionHandler |
306 | * |
344 | * |
307 | * PARAMETERS: Standard exception handler parameters |
345 | * PARAMETERS: Standard exception handler parameters |
308 | * |
346 | * |
309 | * RETURN: Status |
347 | * RETURN: Status |
310 | * |
348 | * |
311 | * DESCRIPTION: System exception handler for AcpiExec utility. |
349 | * DESCRIPTION: System exception handler for AcpiExec utility. |
312 | * |
350 | * |
313 | *****************************************************************************/ |
351 | *****************************************************************************/ |
314 | 352 | ||
315 | ACPI_STATUS |
353 | static ACPI_STATUS |
316 | AeExceptionHandler ( |
354 | AeExceptionHandler ( |
317 | ACPI_STATUS AmlStatus, |
355 | ACPI_STATUS AmlStatus, |
318 | ACPI_NAME Name, |
356 | ACPI_NAME Name, |
319 | UINT16 Opcode, |
357 | UINT16 Opcode, |
320 | UINT32 AmlOffset, |
358 | UINT32 AmlOffset, |
321 | void *Context) |
359 | void *Context) |
322 | { |
360 | { |
323 | ACPI_STATUS NewAmlStatus = AmlStatus; |
361 | ACPI_STATUS NewAmlStatus = AmlStatus; |
324 | ACPI_STATUS Status; |
362 | ACPI_STATUS Status; |
325 | ACPI_BUFFER ReturnObj; |
363 | ACPI_BUFFER ReturnObj; |
326 | ACPI_OBJECT_LIST ArgList; |
364 | ACPI_OBJECT_LIST ArgList; |
327 | ACPI_OBJECT Arg[3]; |
365 | ACPI_OBJECT Arg[3]; |
328 | const char *Exception; |
366 | const char *Exception; |
329 | 367 | ||
330 | 368 | ||
331 | Exception = AcpiFormatException (AmlStatus); |
369 | Exception = AcpiFormatException (AmlStatus); |
332 | AcpiOsPrintf ("[AcpiExec] Exception %s during execution ", Exception); |
370 | AcpiOsPrintf ("[AcpiExec] Exception %s during execution ", Exception); |
333 | if (Name) |
371 | if (Name) |
334 | { |
372 | { |
335 | AcpiOsPrintf ("of method [%4.4s]", (char *) &Name); |
373 | AcpiOsPrintf ("of method [%4.4s]", (char *) &Name); |
336 | } |
374 | } |
337 | else |
375 | else |
338 | { |
376 | { |
339 | AcpiOsPrintf ("at module level (table load)"); |
377 | AcpiOsPrintf ("at module level (table load)"); |
340 | } |
378 | } |
341 | AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset); |
379 | AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset); |
342 | 380 | ||
343 | /* |
381 | /* |
344 | * Invoke the _ERR method if present |
382 | * Invoke the _ERR method if present |
345 | * |
383 | * |
346 | * Setup parameter object |
384 | * Setup parameter object |
347 | */ |
385 | */ |
348 | ArgList.Count = 3; |
386 | ArgList.Count = 3; |
349 | ArgList.Pointer = Arg; |
387 | ArgList.Pointer = Arg; |
350 | 388 | ||
351 | Arg[0].Type = ACPI_TYPE_INTEGER; |
389 | Arg[0].Type = ACPI_TYPE_INTEGER; |
352 | Arg[0].Integer.Value = AmlStatus; |
390 | Arg[0].Integer.Value = AmlStatus; |
353 | 391 | ||
354 | Arg[1].Type = ACPI_TYPE_STRING; |
392 | Arg[1].Type = ACPI_TYPE_STRING; |
355 | Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception); |
393 | Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception); |
356 | Arg[1].String.Length = ACPI_STRLEN (Exception); |
394 | Arg[1].String.Length = ACPI_STRLEN (Exception); |
357 | 395 | ||
358 | Arg[2].Type = ACPI_TYPE_INTEGER; |
396 | Arg[2].Type = ACPI_TYPE_INTEGER; |
359 | Arg[2].Integer.Value = ACPI_TO_INTEGER (AcpiOsGetThreadId()); |
397 | Arg[2].Integer.Value = AcpiOsGetThreadId(); |
360 | 398 | ||
361 | /* Setup return buffer */ |
399 | /* Setup return buffer */ |
362 | 400 | ||
363 | ReturnObj.Pointer = NULL; |
401 | ReturnObj.Pointer = NULL; |
364 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
402 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
365 | 403 | ||
366 | Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj); |
404 | Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj); |
367 | if (ACPI_SUCCESS (Status)) |
405 | if (ACPI_SUCCESS (Status)) |
368 | { |
406 | { |
369 | if (ReturnObj.Pointer) |
407 | if (ReturnObj.Pointer) |
370 | { |
408 | { |
371 | /* Override original status */ |
409 | /* Override original status */ |
372 | 410 | ||
373 | NewAmlStatus = (ACPI_STATUS) |
411 | NewAmlStatus = (ACPI_STATUS) |
374 | ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; |
412 | ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; |
375 | 413 | ||
376 | AcpiOsFree (ReturnObj.Pointer); |
414 | AcpiOsFree (ReturnObj.Pointer); |
377 | } |
415 | } |
378 | } |
416 | } |
379 | else if (Status != AE_NOT_FOUND) |
417 | else if (Status != AE_NOT_FOUND) |
380 | { |
418 | { |
381 | AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n", |
419 | AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n", |
382 | AcpiFormatException (Status)); |
420 | AcpiFormatException (Status)); |
383 | } |
421 | } |
384 | 422 | ||
385 | /* Global override */ |
423 | /* Global override */ |
386 | 424 | ||
387 | if (AcpiGbl_IgnoreErrors) |
425 | if (AcpiGbl_IgnoreErrors) |
388 | { |
426 | { |
389 | NewAmlStatus = AE_OK; |
427 | NewAmlStatus = AE_OK; |
390 | } |
428 | } |
391 | 429 | ||
392 | if (NewAmlStatus != AmlStatus) |
430 | if (NewAmlStatus != AmlStatus) |
393 | { |
431 | { |
394 | AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n", |
432 | AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n", |
395 | AcpiFormatException (NewAmlStatus)); |
433 | AcpiFormatException (NewAmlStatus)); |
396 | } |
434 | } |
397 | 435 | ||
398 | return (NewAmlStatus); |
436 | return (NewAmlStatus); |
399 | } |
437 | } |
400 | 438 | ||
401 | 439 | ||
402 | /****************************************************************************** |
440 | /****************************************************************************** |
403 | * |
441 | * |
404 | * FUNCTION: AeTableHandler |
442 | * FUNCTION: AeTableHandler |
405 | * |
443 | * |
406 | * PARAMETERS: Table handler |
444 | * PARAMETERS: Table handler |
407 | * |
445 | * |
408 | * RETURN: Status |
446 | * RETURN: Status |
409 | * |
447 | * |
410 | * DESCRIPTION: System table handler for AcpiExec utility. |
448 | * DESCRIPTION: System table handler for AcpiExec utility. |
411 | * |
449 | * |
412 | *****************************************************************************/ |
450 | *****************************************************************************/ |
413 | 451 | ||
414 | char *TableEvents[] = |
452 | static char *TableEvents[] = |
415 | { |
453 | { |
416 | "LOAD", |
454 | "LOAD", |
417 | "UNLOAD", |
455 | "UNLOAD", |
418 | "UNKNOWN" |
456 | "UNKNOWN" |
419 | }; |
457 | }; |
420 | 458 | ||
421 | ACPI_STATUS |
459 | static ACPI_STATUS |
422 | AeTableHandler ( |
460 | AeTableHandler ( |
423 | UINT32 Event, |
461 | UINT32 Event, |
424 | void *Table, |
462 | void *Table, |
425 | void *Context) |
463 | void *Context) |
426 | { |
464 | { |
- | 465 | ACPI_STATUS Status; |
|
- | 466 | ||
427 | 467 | ||
428 | if (Event > ACPI_NUM_TABLE_EVENTS) |
468 | if (Event > ACPI_NUM_TABLE_EVENTS) |
429 | { |
469 | { |
430 | Event = ACPI_NUM_TABLE_EVENTS; |
470 | Event = ACPI_NUM_TABLE_EVENTS; |
431 | } |
471 | } |
432 | 472 | ||
- | 473 | /* Enable any GPEs associated with newly-loaded GPE methods */ |
|
- | 474 | ||
- | 475 | Status = AcpiUpdateAllGpes (); |
|
433 | /* TBD: could dump entire table header, need a header dump routine */ |
476 | AE_CHECK_OK (AcpiUpdateAllGpes, Status); |
434 | 477 | ||
435 | printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", |
478 | printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", |
436 | TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); |
479 | TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); |
437 | return (AE_OK); |
480 | return (AE_OK); |
438 | } |
481 | } |
439 | 482 | ||
440 | 483 | ||
441 | /****************************************************************************** |
484 | /****************************************************************************** |
442 | * |
485 | * |
443 | * FUNCTION: AeGpeHandler |
486 | * FUNCTION: AeGpeHandler |
444 | * |
487 | * |
445 | * DESCRIPTION: GPE handler for acpiexec |
488 | * DESCRIPTION: Common GPE handler for acpiexec |
446 | * |
489 | * |
447 | *****************************************************************************/ |
490 | *****************************************************************************/ |
448 | 491 | ||
449 | UINT32 |
492 | UINT32 |
450 | AeGpeHandler ( |
493 | AeGpeHandler ( |
- | 494 | ACPI_HANDLE GpeDevice, |
|
- | 495 | UINT32 GpeNumber, |
|
451 | void *Context) |
496 | void *Context) |
452 | { |
497 | { |
- | 498 | ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice; |
|
- | 499 | ||
- | 500 | ||
453 | AcpiOsPrintf ("Received a GPE at handler\n"); |
501 | AcpiOsPrintf ("[AcpiExec] GPE Handler received GPE%02X (GPE block %4.4s)\n", |
- | 502 | GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT"); |
|
- | 503 | ||
- | 504 | return (ACPI_REENABLE_GPE); |
|
- | 505 | } |
|
- | 506 | ||
- | 507 | ||
- | 508 | /****************************************************************************** |
|
- | 509 | * |
|
- | 510 | * FUNCTION: AeGlobalEventHandler |
|
- | 511 | * |
|
- | 512 | * DESCRIPTION: Global GPE/Fixed event handler |
|
- | 513 | * |
|
- | 514 | *****************************************************************************/ |
|
- | 515 | ||
- | 516 | void |
|
- | 517 | AeGlobalEventHandler ( |
|
- | 518 | UINT32 Type, |
|
- | 519 | ACPI_HANDLE Device, |
|
- | 520 | UINT32 EventNumber, |
|
- | 521 | void *Context) |
|
- | 522 | { |
|
- | 523 | char *TypeName; |
|
- | 524 | ||
- | 525 | ||
- | 526 | switch (Type) |
|
- | 527 | { |
|
- | 528 | case ACPI_EVENT_TYPE_GPE: |
|
- | 529 | TypeName = "GPE"; |
|
- | 530 | break; |
|
- | 531 | ||
- | 532 | case ACPI_EVENT_TYPE_FIXED: |
|
- | 533 | TypeName = "FixedEvent"; |
|
- | 534 | break; |
|
- | 535 | ||
- | 536 | default: |
|
- | 537 | TypeName = "UNKNOWN"; |
|
454 | return (0); |
538 | break; |
- | 539 | } |
|
- | 540 | ||
- | 541 | AcpiOsPrintf ("[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", |
|
- | 542 | TypeName, EventNumber, Device); |
|
455 | } |
543 | } |
456 | 544 | ||
457 | 545 | ||
458 | /****************************************************************************** |
546 | /****************************************************************************** |
459 | * |
547 | * |
460 | * FUNCTION: AeAttachedDataHandler |
548 | * FUNCTION: AeAttachedDataHandler |
461 | * |
549 | * |
462 | * DESCRIPTION: Handler for deletion of nodes with attached data (attached via |
550 | * DESCRIPTION: Handler for deletion of nodes with attached data (attached via |
463 | * AcpiAttachData) |
551 | * AcpiAttachData) |
464 | * |
552 | * |
465 | *****************************************************************************/ |
553 | *****************************************************************************/ |
466 | 554 | ||
467 | void |
555 | static void |
468 | AeAttachedDataHandler ( |
556 | AeAttachedDataHandler ( |
469 | ACPI_HANDLE Object, |
557 | ACPI_HANDLE Object, |
470 | void *Data) |
558 | void *Data) |
471 | { |
559 | { |
472 | ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); |
560 | ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); |
473 | 561 | ||
474 | 562 | ||
475 | AcpiOsPrintf ("Received an attached data deletion on %4.4s\n", |
563 | AcpiOsPrintf ("Received an attached data deletion on %4.4s\n", |
476 | Node->Name.Ascii); |
564 | Node->Name.Ascii); |
477 | } |
565 | } |
478 | 566 | ||
479 | 567 | ||
480 | /****************************************************************************** |
568 | /****************************************************************************** |
481 | * |
569 | * |
- | 570 | * FUNCTION: AeInterfaceHandler |
|
- | 571 | * |
|
- | 572 | * DESCRIPTION: Handler for _OSI invocations |
|
- | 573 | * |
|
- | 574 | *****************************************************************************/ |
|
- | 575 | ||
- | 576 | static UINT32 |
|
- | 577 | AeInterfaceHandler ( |
|
- | 578 | ACPI_STRING InterfaceName, |
|
- | 579 | UINT32 Supported) |
|
- | 580 | { |
|
- | 581 | ACPI_FUNCTION_NAME (AeInterfaceHandler); |
|
- | 582 | ||
- | 583 | ||
- | 584 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, |
|
- | 585 | "Received _OSI (\"%s\"), is %ssupported\n", |
|
- | 586 | InterfaceName, Supported == 0 ? "not " : "")); |
|
- | 587 | ||
- | 588 | return (Supported); |
|
- | 589 | } |
|
- | 590 | ||
- | 591 | ||
- | 592 | /****************************************************************************** |
|
- | 593 | * |
|
- | 594 | * FUNCTION: AeEventHandler |
|
- | 595 | * |
|
- | 596 | * DESCRIPTION: Handler for Fixed Events |
|
- | 597 | * |
|
- | 598 | *****************************************************************************/ |
|
- | 599 | ||
- | 600 | static UINT32 |
|
- | 601 | AeEventHandler ( |
|
- | 602 | void *Context) |
|
- | 603 | { |
|
- | 604 | return (0); |
|
- | 605 | } |
|
- | 606 | ||
- | 607 | ||
- | 608 | /****************************************************************************** |
|
- | 609 | * |
|
482 | * FUNCTION: AeRegionInit |
610 | * FUNCTION: AeRegionInit |
483 | * |
611 | * |
484 | * PARAMETERS: None |
612 | * PARAMETERS: None |
485 | * |
613 | * |
486 | * RETURN: Status |
614 | * RETURN: Status |
487 | * |
615 | * |
488 | * DESCRIPTION: Opregion init function. |
616 | * DESCRIPTION: Opregion init function. |
489 | * |
617 | * |
490 | *****************************************************************************/ |
618 | *****************************************************************************/ |
491 | 619 | ||
492 | ACPI_STATUS |
620 | static ACPI_STATUS |
493 | AeRegionInit ( |
621 | AeRegionInit ( |
494 | ACPI_HANDLE RegionHandle, |
622 | ACPI_HANDLE RegionHandle, |
495 | UINT32 Function, |
623 | UINT32 Function, |
496 | void *HandlerContext, |
624 | void *HandlerContext, |
497 | void **RegionContext) |
625 | void **RegionContext) |
498 | { |
626 | { |
499 | /* |
627 | /* |
500 | * Real simple, set the RegionContext to the RegionHandle |
628 | * Real simple, set the RegionContext to the RegionHandle |
501 | */ |
629 | */ |
502 | *RegionContext = RegionHandle; |
630 | *RegionContext = RegionHandle; |
503 | 631 | ||
504 | return AE_OK; |
632 | return (AE_OK); |
505 | } |
633 | } |
506 | 634 | ||
507 | 635 | ||
508 | /****************************************************************************** |
636 | /****************************************************************************** |
509 | * |
637 | * |
510 | * FUNCTION: AeInstallHandlers |
638 | * FUNCTION: AeInstallLateHandlers |
511 | * |
639 | * |
512 | * PARAMETERS: None |
640 | * PARAMETERS: None |
513 | * |
641 | * |
514 | * RETURN: Status |
642 | * RETURN: Status |
515 | * |
643 | * |
516 | * DESCRIPTION: Install handlers for the AcpiExec utility. |
644 | * DESCRIPTION: Install handlers for the AcpiExec utility. |
517 | * |
645 | * |
518 | *****************************************************************************/ |
646 | *****************************************************************************/ |
- | 647 | ||
- | 648 | ACPI_STATUS |
|
- | 649 | AeInstallLateHandlers ( |
|
- | 650 | void) |
|
- | 651 | { |
|
- | 652 | ACPI_STATUS Status; |
|
- | 653 | UINT32 i; |
|
- | 654 | ||
- | 655 | ||
- | 656 | /* Install some fixed event handlers */ |
|
- | 657 | ||
- | 658 | Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AeEventHandler, NULL); |
|
- | 659 | AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); |
|
- | 660 | ||
- | 661 | Status = AcpiInstallFixedEventHandler (ACPI_EVENT_RTC, AeEventHandler, NULL); |
|
- | 662 | AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); |
|
- | 663 | ||
- | 664 | /* |
|
- | 665 | * Install handlers for some of the "device driver" address spaces |
|
- | 666 | * such as EC, SMBus, etc. |
|
- | 667 | */ |
|
- | 668 | for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++) |
|
- | 669 | { |
|
- | 670 | /* Install handler at the root object */ |
|
- | 671 | ||
519 | 672 | Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, |
|
520 | ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 5, 6, 7, 0x80}; |
673 | SpaceIdList[i], AeRegionHandler, AeRegionInit, NULL); |
- | 674 | if (ACPI_FAILURE (Status)) |
|
- | 675 | { |
|
- | 676 | ACPI_EXCEPTION ((AE_INFO, Status, |
|
- | 677 | "Could not install an OpRegion handler for %s space(%u)", |
|
- | 678 | AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i])); |
|
- | 679 | return (Status); |
|
- | 680 | } |
|
- | 681 | } |
|
- | 682 | ||
- | 683 | return (AE_OK); |
|
- | 684 | } |
|
- | 685 | ||
- | 686 | ||
- | 687 | /****************************************************************************** |
|
- | 688 | * |
|
- | 689 | * FUNCTION: AeInstallEarlyHandlers |
|
- | 690 | * |
|
- | 691 | * PARAMETERS: None |
|
- | 692 | * |
|
- | 693 | * RETURN: Status |
|
- | 694 | * |
|
- | 695 | * DESCRIPTION: Install handlers for the AcpiExec utility. |
|
- | 696 | * |
|
- | 697 | * Notes: Don't install handler for PCI_Config, we want to use the |
|
- | 698 | * default handler to exercise that code. |
|
- | 699 | * |
|
521 | #define AEXEC_NUM_REGIONS 9 |
700 | *****************************************************************************/ |
522 | 701 | ||
- | 702 | ACPI_STATUS |
|
523 | ACPI_STATUS |
703 | AeInstallEarlyHandlers ( |
524 | AeInstallHandlers (void) |
704 | void) |
525 | { |
705 | { |
526 | ACPI_STATUS Status; |
706 | ACPI_STATUS Status; |
527 | UINT32 i; |
707 | UINT32 i; |
528 | ACPI_HANDLE Handle; |
708 | ACPI_HANDLE Handle; |
529 | 709 | ||
530 | 710 | ||
531 | ACPI_FUNCTION_ENTRY (); |
711 | ACPI_FUNCTION_ENTRY (); |
532 | 712 | ||
- | 713 | ||
- | 714 | Status = AcpiInstallInterfaceHandler (AeInterfaceHandler); |
|
- | 715 | if (ACPI_FAILURE (Status)) |
|
- | 716 | { |
|
- | 717 | printf ("Could not install interface handler, %s\n", |
|
- | 718 | AcpiFormatException (Status)); |
|
- | 719 | } |
|
533 | 720 | ||
534 | Status = AcpiInstallTableHandler (AeTableHandler, NULL); |
721 | Status = AcpiInstallTableHandler (AeTableHandler, NULL); |
535 | if (ACPI_FAILURE (Status)) |
722 | if (ACPI_FAILURE (Status)) |
536 | { |
723 | { |
537 | printf ("Could not install table handler, %s\n", |
724 | printf ("Could not install table handler, %s\n", |
538 | AcpiFormatException (Status)); |
725 | AcpiFormatException (Status)); |
539 | } |
726 | } |
540 | 727 | ||
541 | Status = AcpiInstallExceptionHandler (AeExceptionHandler); |
728 | Status = AcpiInstallExceptionHandler (AeExceptionHandler); |
542 | if (ACPI_FAILURE (Status)) |
729 | if (ACPI_FAILURE (Status)) |
543 | { |
730 | { |
544 | printf ("Could not install exception handler, %s\n", |
731 | printf ("Could not install exception handler, %s\n", |
545 | AcpiFormatException (Status)); |
732 | AcpiFormatException (Status)); |
546 | } |
733 | } |
547 | 734 | ||
548 | /* Install global notify handler */ |
735 | /* Install global notify handler */ |
549 | 736 | ||
550 | Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, |
737 | Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, |
551 | AeNotifyHandler, NULL); |
738 | AeNotifyHandler, NULL); |
552 | if (ACPI_FAILURE (Status)) |
739 | if (ACPI_FAILURE (Status)) |
553 | { |
740 | { |
554 | printf ("Could not install a global notify handler, %s\n", |
741 | printf ("Could not install a global notify handler, %s\n", |
555 | AcpiFormatException (Status)); |
742 | AcpiFormatException (Status)); |
556 | } |
743 | } |
557 | 744 | ||
558 | Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, |
745 | Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, |
559 | AeDeviceNotifyHandler, NULL); |
746 | AeDeviceNotifyHandler, NULL); |
560 | if (ACPI_FAILURE (Status)) |
747 | if (ACPI_FAILURE (Status)) |
561 | { |
748 | { |
562 | printf ("Could not install a global notify handler, %s\n", |
749 | printf ("Could not install a global notify handler, %s\n", |
563 | AcpiFormatException (Status)); |
750 | AcpiFormatException (Status)); |
564 | } |
751 | } |
565 | 752 | ||
566 | Status = AcpiGetHandle (NULL, "\\_SB", &Handle); |
753 | Status = AcpiGetHandle (NULL, "\\_SB", &Handle); |
567 | if (ACPI_SUCCESS (Status)) |
754 | if (ACPI_SUCCESS (Status)) |
568 | { |
755 | { |
569 | Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, |
756 | Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, |
570 | AeNotifyHandler, NULL); |
757 | AeNotifyHandler, NULL); |
571 | if (ACPI_FAILURE (Status)) |
758 | if (ACPI_FAILURE (Status)) |
572 | { |
759 | { |
573 | printf ("Could not install a notify handler, %s\n", |
760 | printf ("Could not install a notify handler, %s\n", |
574 | AcpiFormatException (Status)); |
761 | AcpiFormatException (Status)); |
575 | } |
762 | } |
576 | 763 | ||
577 | Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, |
764 | Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, |
578 | AeNotifyHandler); |
765 | AeNotifyHandler); |
579 | if (ACPI_FAILURE (Status)) |
766 | if (ACPI_FAILURE (Status)) |
580 | { |
767 | { |
581 | printf ("Could not remove a notify handler, %s\n", |
768 | printf ("Could not remove a notify handler, %s\n", |
582 | AcpiFormatException (Status)); |
769 | AcpiFormatException (Status)); |
583 | } |
770 | } |
584 | 771 | ||
585 | Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
772 | Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
586 | AeNotifyHandler, NULL); |
773 | AeNotifyHandler, NULL); |
- | 774 | AE_CHECK_OK (AcpiInstallNotifyHandler, Status); |
|
- | 775 | ||
587 | Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
776 | Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
588 | AeNotifyHandler); |
777 | AeNotifyHandler); |
- | 778 | AE_CHECK_OK (AcpiRemoveNotifyHandler, Status); |
|
- | 779 | ||
589 | Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
780 | Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, |
590 | AeNotifyHandler, NULL); |
781 | AeNotifyHandler, NULL); |
591 | if (ACPI_FAILURE (Status)) |
782 | if (ACPI_FAILURE (Status)) |
592 | { |
783 | { |
593 | printf ("Could not install a notify handler, %s\n", |
784 | printf ("Could not install a notify handler, %s\n", |
594 | AcpiFormatException (Status)); |
785 | AcpiFormatException (Status)); |
595 | } |
786 | } |
596 | 787 | ||
597 | Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); |
788 | Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); |
- | 789 | AE_CHECK_OK (AcpiAttachData, Status); |
|
- | 790 | ||
598 | Status = AcpiDetachData (Handle, AeAttachedDataHandler); |
791 | Status = AcpiDetachData (Handle, AeAttachedDataHandler); |
- | 792 | AE_CHECK_OK (AcpiDetachData, Status); |
|
- | 793 | ||
599 | Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); |
794 | Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); |
- | 795 | AE_CHECK_OK (AcpiAttachData, Status); |
|
600 | } |
796 | } |
601 | else |
797 | else |
602 | { |
798 | { |
603 | printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); |
799 | printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); |
604 | } |
800 | } |
605 | - | ||
- | 801 | ||
- | 802 | ||
- | 803 | /* |
|
- | 804 | * Install handlers that will override the default handlers for some of |
|
606 | /* Set a handler for all supported operation regions */ |
805 | * the space IDs. |
607 | 806 | */ |
|
608 | for (i = 0; i < AEXEC_NUM_REGIONS; i++) |
- | |
609 | { |
807 | for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++) |
610 | Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode, |
- | |
611 | SpaceId[i], AeRegionHandler); |
- | |
612 | - | ||
613 | /* Install handler at the root object. |
808 | { |
614 | * TBD: all default handlers should be installed here! |
809 | /* Install handler at the root object */ |
- | 810 | ||
615 | */ |
811 | Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, |
616 | Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, |
812 | DefaultSpaceIdList[i], AeRegionHandler, |
617 | SpaceId[i], AeRegionHandler, AeRegionInit, NULL); |
813 | AeRegionInit, NULL); |
618 | if (ACPI_FAILURE (Status)) |
814 | if (ACPI_FAILURE (Status)) |
619 | { |
815 | { |
620 | ACPI_EXCEPTION ((AE_INFO, Status, |
816 | ACPI_EXCEPTION ((AE_INFO, Status, |
621 | "Could not install an OpRegion handler for %s space(%u)", |
817 | "Could not install a default OpRegion handler for %s space(%u)", |
622 | AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i])); |
818 | AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]), |
- | 819 | DefaultSpaceIdList[i])); |
|
623 | return (Status); |
820 | return (Status); |
624 | } |
821 | } |
625 | } |
822 | } |
626 | 823 | ||
627 | /* |
824 | /* |
628 | * Initialize the global Region Handler space |
825 | * Initialize the global Region Handler space |
629 | * MCW 3/23/00 |
826 | * MCW 3/23/00 |
630 | */ |
827 | */ |
631 | AeRegions.NumberOfRegions = 0; |
828 | AeRegions.NumberOfRegions = 0; |
632 | AeRegions.RegionList = NULL; |
829 | AeRegions.RegionList = NULL; |
633 | - | ||
634 | return Status; |
830 | return (Status); |
635 | } |
831 | } |
636 | 832 | ||
637 | 833 | ||
638 | /****************************************************************************** |
834 | /****************************************************************************** |
639 | * |
835 | * |
640 | * FUNCTION: AeRegionHandler |
836 | * FUNCTION: AeRegionHandler |
641 | * |
837 | * |
642 | * PARAMETERS: Standard region handler parameters |
838 | * PARAMETERS: Standard region handler parameters |
643 | * |
839 | * |
644 | * RETURN: Status |
840 | * RETURN: Status |
645 | * |
841 | * |
646 | * DESCRIPTION: Test handler - Handles some dummy regions via memory that can |
842 | * DESCRIPTION: Test handler - Handles some dummy regions via memory that can |
647 | * be manipulated in Ring 3. Simulates actual reads and writes. |
843 | * be manipulated in Ring 3. Simulates actual reads and writes. |
648 | * |
844 | * |
649 | *****************************************************************************/ |
845 | *****************************************************************************/ |
650 | 846 | ||
651 | ACPI_STATUS |
847 | ACPI_STATUS |
652 | AeRegionHandler ( |
848 | AeRegionHandler ( |
653 | UINT32 Function, |
849 | UINT32 Function, |
654 | ACPI_PHYSICAL_ADDRESS Address, |
850 | ACPI_PHYSICAL_ADDRESS Address, |
655 | UINT32 BitWidth, |
851 | UINT32 BitWidth, |
656 | UINT64 *Value, |
852 | UINT64 *Value, |
657 | void *HandlerContext, |
853 | void *HandlerContext, |
658 | void *RegionContext) |
854 | void *RegionContext) |
659 | { |
855 | { |
660 | 856 | ||
661 | ACPI_OPERAND_OBJECT *RegionObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, RegionContext); |
857 | ACPI_OPERAND_OBJECT *RegionObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, RegionContext); |
662 | UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Value); |
858 | UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Value); |
663 | ACPI_PHYSICAL_ADDRESS BaseAddress; |
859 | ACPI_PHYSICAL_ADDRESS BaseAddress; |
664 | ACPI_SIZE Length; |
860 | ACPI_SIZE Length; |
665 | BOOLEAN BufferExists; |
861 | BOOLEAN BufferExists; |
666 | AE_REGION *RegionElement; |
862 | AE_REGION *RegionElement; |
667 | void *BufferValue; |
863 | void *BufferValue; |
668 | ACPI_STATUS Status; |
864 | ACPI_STATUS Status; |
669 | UINT32 ByteWidth; |
865 | UINT32 ByteWidth; |
670 | UINT32 i; |
866 | UINT32 i; |
671 | UINT8 SpaceId; |
867 | UINT8 SpaceId; |
672 | 868 | ||
673 | 869 | ||
674 | ACPI_FUNCTION_NAME (AeRegionHandler); |
870 | ACPI_FUNCTION_NAME (AeRegionHandler); |
675 | 871 | ||
676 | /* |
872 | /* |
677 | * If the object is not a region, simply return |
873 | * If the object is not a region, simply return |
678 | */ |
874 | */ |
679 | if (RegionObject->Region.Type != ACPI_TYPE_REGION) |
875 | if (RegionObject->Region.Type != ACPI_TYPE_REGION) |
680 | { |
876 | { |
681 | return AE_OK; |
877 | return (AE_OK); |
682 | } |
878 | } |
683 | 879 | ||
684 | /* |
880 | /* |
685 | * Region support can be disabled with the -r option. |
881 | * Region support can be disabled with the -r option. |
686 | * We use this to support dynamically loaded tables where we pass a valid |
882 | * We use this to support dynamically loaded tables where we pass a valid |
687 | * address to the AML. |
883 | * address to the AML. |
688 | */ |
884 | */ |
689 | if (AcpiGbl_DbOpt_NoRegionSupport) |
885 | if (AcpiGbl_DbOpt_NoRegionSupport) |
690 | { |
886 | { |
691 | BufferValue = ACPI_TO_POINTER (Address); |
887 | BufferValue = ACPI_TO_POINTER (Address); |
692 | ByteWidth = (BitWidth / 8); |
888 | ByteWidth = (BitWidth / 8); |
693 | 889 | ||
694 | if (BitWidth % 8) |
890 | if (BitWidth % 8) |
695 | { |
891 | { |
696 | ByteWidth += 1; |
892 | ByteWidth += 1; |
697 | } |
893 | } |
698 | goto DoFunction; |
894 | goto DoFunction; |
699 | } |
895 | } |
700 | 896 | ||
701 | /* |
897 | /* |
702 | * Find the region's address space and length before searching |
898 | * Find the region's address space and length before searching |
703 | * the linked list. |
899 | * the linked list. |
704 | */ |
900 | */ |
705 | BaseAddress = RegionObject->Region.Address; |
901 | BaseAddress = RegionObject->Region.Address; |
706 | Length = (ACPI_SIZE) RegionObject->Region.Length; |
902 | Length = (ACPI_SIZE) RegionObject->Region.Length; |
707 | SpaceId = RegionObject->Region.SpaceId; |
903 | SpaceId = RegionObject->Region.SpaceId; |
708 | 904 | ||
709 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n", |
905 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n", |
710 | AcpiUtGetRegionName (RegionObject->Region.SpaceId), |
906 | AcpiUtGetRegionName (RegionObject->Region.SpaceId), |
711 | (UINT32) Address)); |
907 | (UINT32) Address)); |
712 | 908 | ||
713 | switch (SpaceId) |
909 | switch (SpaceId) |
714 | { |
910 | { |
715 | case ACPI_ADR_SPACE_SYSTEM_IO: |
911 | case ACPI_ADR_SPACE_SYSTEM_IO: |
716 | /* |
912 | /* |
717 | * For I/O space, exercise the port validation |
913 | * For I/O space, exercise the port validation |
718 | */ |
914 | */ |
719 | switch (Function & ACPI_IO_MASK) |
915 | switch (Function & ACPI_IO_MASK) |
720 | { |
916 | { |
721 | case ACPI_READ: |
917 | case ACPI_READ: |
722 | Status = AcpiHwReadPort (Address, (UINT32 *) Value, BitWidth); |
918 | Status = AcpiHwReadPort (Address, (UINT32 *) Value, BitWidth); |
- | 919 | AE_CHECK_OK (AcpiHwReadPort, Status); |
|
723 | break; |
920 | break; |
724 | 921 | ||
725 | case ACPI_WRITE: |
922 | case ACPI_WRITE: |
726 | Status = AcpiHwWritePort (Address, (UINT32) *Value, BitWidth); |
923 | Status = AcpiHwWritePort (Address, (UINT32) *Value, BitWidth); |
- | 924 | AE_CHECK_OK (AcpiHwWritePort, Status); |
|
727 | break; |
925 | break; |
728 | 926 | ||
729 | default: |
927 | default: |
730 | Status = AE_BAD_PARAMETER; |
928 | Status = AE_BAD_PARAMETER; |
731 | break; |
929 | break; |
732 | } |
930 | } |
733 | 931 | ||
734 | if (ACPI_FAILURE (Status)) |
932 | if (ACPI_FAILURE (Status)) |
735 | { |
933 | { |
736 | return (Status); |
934 | return (Status); |
737 | } |
935 | } |
738 | 936 | ||
739 | /* Now go ahead and simulate the hardware */ |
937 | /* Now go ahead and simulate the hardware */ |
740 | break; |
938 | break; |
741 | 939 | ||
742 | 940 | ||
743 | case ACPI_ADR_SPACE_SMBUS: |
941 | case ACPI_ADR_SPACE_SMBUS: |
744 | 942 | ||
745 | Length = 0; |
943 | Length = 0; |
746 | 944 | ||
747 | switch (Function & ACPI_IO_MASK) |
945 | switch (Function & ACPI_IO_MASK) |
748 | { |
946 | { |
749 | case ACPI_READ: |
947 | case ACPI_READ: |
750 | switch (Function >> 16) |
948 | switch (Function >> 16) |
751 | { |
949 | { |
752 | case AML_FIELD_ATTRIB_SMB_QUICK: |
950 | case AML_FIELD_ATTRIB_SMB_QUICK: |
753 | case AML_FIELD_ATTRIB_SMB_SEND_RCV: |
951 | case AML_FIELD_ATTRIB_SMB_SEND_RCV: |
754 | case AML_FIELD_ATTRIB_SMB_BYTE: |
952 | case AML_FIELD_ATTRIB_SMB_BYTE: |
755 | Length = 1; |
953 | Length = 1; |
756 | break; |
954 | break; |
757 | 955 | ||
758 | case AML_FIELD_ATTRIB_SMB_WORD: |
956 | case AML_FIELD_ATTRIB_SMB_WORD: |
759 | case AML_FIELD_ATTRIB_SMB_WORD_CALL: |
957 | case AML_FIELD_ATTRIB_SMB_WORD_CALL: |
760 | Length = 2; |
958 | Length = 2; |
761 | break; |
959 | break; |
762 | 960 | ||
763 | case AML_FIELD_ATTRIB_SMB_BLOCK: |
961 | case AML_FIELD_ATTRIB_SMB_BLOCK: |
764 | case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: |
962 | case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: |
765 | Length = 32; |
963 | Length = 32; |
766 | break; |
964 | break; |
767 | 965 | ||
768 | default: |
966 | default: |
769 | break; |
967 | break; |
770 | } |
968 | } |
771 | break; |
969 | break; |
772 | 970 | ||
773 | case ACPI_WRITE: |
971 | case ACPI_WRITE: |
774 | switch (Function >> 16) |
972 | switch (Function >> 16) |
775 | { |
973 | { |
776 | case AML_FIELD_ATTRIB_SMB_QUICK: |
974 | case AML_FIELD_ATTRIB_SMB_QUICK: |
777 | case AML_FIELD_ATTRIB_SMB_SEND_RCV: |
975 | case AML_FIELD_ATTRIB_SMB_SEND_RCV: |
778 | case AML_FIELD_ATTRIB_SMB_BYTE: |
976 | case AML_FIELD_ATTRIB_SMB_BYTE: |
779 | case AML_FIELD_ATTRIB_SMB_WORD: |
977 | case AML_FIELD_ATTRIB_SMB_WORD: |
780 | case AML_FIELD_ATTRIB_SMB_BLOCK: |
978 | case AML_FIELD_ATTRIB_SMB_BLOCK: |
781 | Length = 0; |
979 | Length = 0; |
782 | break; |
980 | break; |
783 | 981 | ||
784 | case AML_FIELD_ATTRIB_SMB_WORD_CALL: |
982 | case AML_FIELD_ATTRIB_SMB_WORD_CALL: |
785 | Length = 2; |
983 | Length = 2; |
786 | break; |
984 | break; |
787 | 985 | ||
788 | case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: |
986 | case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: |
789 | Length = 32; |
987 | Length = 32; |
790 | break; |
988 | break; |
791 | 989 | ||
792 | default: |
990 | default: |
793 | break; |
991 | break; |
794 | } |
992 | } |
795 | break; |
993 | break; |
796 | 994 | ||
797 | default: |
995 | default: |
798 | break; |
996 | break; |
799 | } |
997 | } |
800 | 998 | ||
801 | for (i = 0; i < Length; i++) |
999 | for (i = 0; i < Length; i++) |
802 | { |
1000 | { |
803 | Buffer[i+2] = (UINT8) (0xA0 + i); |
1001 | Buffer[i+2] = (UINT8) (0xA0 + i); |
804 | } |
1002 | } |
805 | 1003 | ||
806 | Buffer[0] = 0x7A; |
1004 | Buffer[0] = 0x7A; |
807 | Buffer[1] = (UINT8) Length; |
1005 | Buffer[1] = (UINT8) Length; |
808 | return (AE_OK); |
1006 | return (AE_OK); |
809 | 1007 | ||
810 | 1008 | ||
811 | case ACPI_ADR_SPACE_IPMI: /* ACPI 4.0 */ |
1009 | case ACPI_ADR_SPACE_IPMI: /* ACPI 4.0 */ |
812 | 1010 | ||
813 | AcpiOsPrintf ("AcpiExec: Received IPMI request: " |
1011 | AcpiOsPrintf ("AcpiExec: Received IPMI request: " |
814 | "Address %X BaseAddress %X Length %X Width %X BufferLength %u\n", |
1012 | "Address %X BaseAddress %X Length %X Width %X BufferLength %u\n", |
815 | (UINT32) Address, (UINT32) BaseAddress, |
1013 | (UINT32) Address, (UINT32) BaseAddress, |
816 | Length, BitWidth, Buffer[1]); |
1014 | Length, BitWidth, Buffer[1]); |
817 | 1015 | ||
818 | /* |
1016 | /* |
819 | * Regardless of a READ or WRITE, this handler is passed a 66-byte |
1017 | * Regardless of a READ or WRITE, this handler is passed a 66-byte |
820 | * buffer in which to return the IPMI status/length/data. |
1018 | * buffer in which to return the IPMI status/length/data. |
821 | * |
1019 | * |
822 | * Return some example data to show use of the bidirectional buffer |
1020 | * Return some example data to show use of the bidirectional buffer |
823 | */ |
1021 | */ |
824 | Buffer[0] = 0; /* Status byte */ |
1022 | Buffer[0] = 0; /* Status byte */ |
825 | Buffer[1] = 64; /* Return buffer data length */ |
1023 | Buffer[1] = 64; /* Return buffer data length */ |
826 | Buffer[2] = 0; /* Completion code */ |
1024 | Buffer[2] = 0; /* Completion code */ |
827 | Buffer[3] = 0x34; /* Power measurement */ |
1025 | Buffer[3] = 0x34; /* Power measurement */ |
828 | Buffer[4] = 0x12; /* Power measurement */ |
1026 | Buffer[4] = 0x12; /* Power measurement */ |
829 | Buffer[65] = 0xEE; /* last buffer byte */ |
1027 | Buffer[65] = 0xEE; /* last buffer byte */ |
830 | return (AE_OK); |
1028 | return (AE_OK); |
831 | 1029 | ||
832 | default: |
1030 | default: |
833 | break; |
1031 | break; |
834 | } |
1032 | } |
835 | 1033 | ||
836 | /* |
1034 | /* |
837 | * Search through the linked list for this region's buffer |
1035 | * Search through the linked list for this region's buffer |
838 | */ |
1036 | */ |
839 | BufferExists = FALSE; |
1037 | BufferExists = FALSE; |
840 | RegionElement = AeRegions.RegionList; |
1038 | RegionElement = AeRegions.RegionList; |
841 | 1039 | ||
842 | if (AeRegions.NumberOfRegions) |
1040 | if (AeRegions.NumberOfRegions) |
843 | { |
1041 | { |
844 | while (!BufferExists && RegionElement) |
1042 | while (!BufferExists && RegionElement) |
845 | { |
1043 | { |
846 | if (RegionElement->Address == BaseAddress && |
1044 | if (RegionElement->Address == BaseAddress && |
847 | RegionElement->Length == Length && |
1045 | RegionElement->Length == Length && |
848 | RegionElement->SpaceId == SpaceId) |
1046 | RegionElement->SpaceId == SpaceId) |
849 | { |
1047 | { |
850 | BufferExists = TRUE; |
1048 | BufferExists = TRUE; |
851 | } |
1049 | } |
852 | else |
1050 | else |
853 | { |
1051 | { |
854 | RegionElement = RegionElement->NextRegion; |
1052 | RegionElement = RegionElement->NextRegion; |
855 | } |
1053 | } |
856 | } |
1054 | } |
857 | } |
1055 | } |
858 | 1056 | ||
859 | /* |
1057 | /* |
860 | * If the Region buffer does not exist, create it now |
1058 | * If the Region buffer does not exist, create it now |
861 | */ |
1059 | */ |
862 | if (!BufferExists) |
1060 | if (!BufferExists) |
863 | { |
1061 | { |
864 | /* |
1062 | /* |
865 | * Do the memory allocations first |
1063 | * Do the memory allocations first |
866 | */ |
1064 | */ |
867 | RegionElement = AcpiOsAllocate (sizeof (AE_REGION)); |
1065 | RegionElement = AcpiOsAllocate (sizeof (AE_REGION)); |
868 | if (!RegionElement) |
1066 | if (!RegionElement) |
869 | { |
1067 | { |
870 | return AE_NO_MEMORY; |
1068 | return (AE_NO_MEMORY); |
871 | } |
1069 | } |
872 | 1070 | ||
873 | RegionElement->Buffer = AcpiOsAllocate (Length); |
1071 | RegionElement->Buffer = AcpiOsAllocate (Length); |
874 | if (!RegionElement->Buffer) |
1072 | if (!RegionElement->Buffer) |
875 | { |
1073 | { |
876 | AcpiOsFree (RegionElement); |
1074 | AcpiOsFree (RegionElement); |
877 | return AE_NO_MEMORY; |
1075 | return (AE_NO_MEMORY); |
878 | } |
1076 | } |
879 | 1077 | ||
880 | /* Initialize the region with the default fill value */ |
1078 | /* Initialize the region with the default fill value */ |
881 | 1079 | ||
882 | ACPI_MEMSET (RegionElement->Buffer, AcpiGbl_RegionFillValue, Length); |
1080 | ACPI_MEMSET (RegionElement->Buffer, AcpiGbl_RegionFillValue, Length); |
883 | 1081 | ||
884 | RegionElement->Address = BaseAddress; |
1082 | RegionElement->Address = BaseAddress; |
885 | RegionElement->Length = Length; |
1083 | RegionElement->Length = Length; |
886 | RegionElement->SpaceId = SpaceId; |
1084 | RegionElement->SpaceId = SpaceId; |
887 | RegionElement->NextRegion = NULL; |
1085 | RegionElement->NextRegion = NULL; |
888 | 1086 | ||
889 | /* |
1087 | /* |
890 | * Increment the number of regions and put this one |
1088 | * Increment the number of regions and put this one |
891 | * at the head of the list as it will probably get accessed |
1089 | * at the head of the list as it will probably get accessed |
892 | * more often anyway. |
1090 | * more often anyway. |
893 | */ |
1091 | */ |
894 | AeRegions.NumberOfRegions += 1; |
1092 | AeRegions.NumberOfRegions += 1; |
895 | 1093 | ||
896 | if (AeRegions.RegionList) |
1094 | if (AeRegions.RegionList) |
897 | { |
1095 | { |
898 | RegionElement->NextRegion = AeRegions.RegionList; |
1096 | RegionElement->NextRegion = AeRegions.RegionList; |
899 | } |
1097 | } |
900 | 1098 | ||
901 | AeRegions.RegionList = RegionElement; |
1099 | AeRegions.RegionList = RegionElement; |
902 | } |
1100 | } |
903 | 1101 | ||
904 | /* |
1102 | /* |
905 | * Calculate the size of the memory copy |
1103 | * Calculate the size of the memory copy |
906 | */ |
1104 | */ |
907 | ByteWidth = (BitWidth / 8); |
1105 | ByteWidth = (BitWidth / 8); |
908 | 1106 | ||
909 | if (BitWidth % 8) |
1107 | if (BitWidth % 8) |
910 | { |
1108 | { |
911 | ByteWidth += 1; |
1109 | ByteWidth += 1; |
912 | } |
1110 | } |
913 | 1111 | ||
914 | /* |
1112 | /* |
915 | * The buffer exists and is pointed to by RegionElement. |
1113 | * The buffer exists and is pointed to by RegionElement. |
916 | * We now need to verify the request is valid and perform the operation. |
1114 | * We now need to verify the request is valid and perform the operation. |
917 | * |
1115 | * |
918 | * NOTE: RegionElement->Length is in bytes, therefore it we compare against |
1116 | * NOTE: RegionElement->Length is in bytes, therefore it we compare against |
919 | * ByteWidth (see above) |
1117 | * ByteWidth (see above) |
920 | */ |
1118 | */ |
921 | if (((UINT64) Address + ByteWidth) > |
1119 | if (((UINT64) Address + ByteWidth) > |
922 | ((UINT64)(RegionElement->Address) + RegionElement->Length)) |
1120 | ((UINT64)(RegionElement->Address) + RegionElement->Length)) |
923 | { |
1121 | { |
924 | ACPI_WARNING ((AE_INFO, |
1122 | ACPI_WARNING ((AE_INFO, |
925 | "Request on [%4.4s] is beyond region limit Req-0x%X+0x%X, Base=0x%X, Len-0x%X", |
1123 | "Request on [%4.4s] is beyond region limit Req-0x%X+0x%X, Base=0x%X, Len-0x%X", |
926 | (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address, |
1124 | (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address, |
927 | ByteWidth, (UINT32)(RegionElement->Address), |
1125 | ByteWidth, (UINT32)(RegionElement->Address), |
928 | RegionElement->Length)); |
1126 | RegionElement->Length)); |
929 | 1127 | ||
930 | return AE_AML_REGION_LIMIT; |
1128 | return (AE_AML_REGION_LIMIT); |
931 | } |
1129 | } |
932 | 1130 | ||
933 | /* |
1131 | /* |
934 | * Get BufferValue to point to the "address" in the buffer |
1132 | * Get BufferValue to point to the "address" in the buffer |
935 | */ |
1133 | */ |
936 | BufferValue = ((UINT8 *) RegionElement->Buffer + |
1134 | BufferValue = ((UINT8 *) RegionElement->Buffer + |
937 | ((UINT64) Address - (UINT64) RegionElement->Address)); |
1135 | ((UINT64) Address - (UINT64) RegionElement->Address)); |
938 | 1136 | ||
939 | DoFunction: |
1137 | DoFunction: |
940 | 1138 | ||
941 | /* |
1139 | /* |
942 | * Perform a read or write to the buffer space |
1140 | * Perform a read or write to the buffer space |
943 | */ |
1141 | */ |
944 | switch (Function) |
1142 | switch (Function) |
945 | { |
1143 | { |
946 | case ACPI_READ: |
1144 | case ACPI_READ: |
947 | /* |
1145 | /* |
948 | * Set the pointer Value to whatever is in the buffer |
1146 | * Set the pointer Value to whatever is in the buffer |
949 | */ |
1147 | */ |
950 | ACPI_MEMCPY (Value, BufferValue, ByteWidth); |
1148 | ACPI_MEMCPY (Value, BufferValue, ByteWidth); |
951 | break; |
1149 | break; |
952 | 1150 | ||
953 | case ACPI_WRITE: |
1151 | case ACPI_WRITE: |
954 | /* |
1152 | /* |
955 | * Write the contents of Value to the buffer |
1153 | * Write the contents of Value to the buffer |
956 | */ |
1154 | */ |
957 | ACPI_MEMCPY (BufferValue, Value, ByteWidth); |
1155 | ACPI_MEMCPY (BufferValue, Value, ByteWidth); |
958 | break; |
1156 | break; |
959 | 1157 | ||
960 | default: |
1158 | default: |
961 | return AE_BAD_PARAMETER; |
1159 | return (AE_BAD_PARAMETER); |
962 | } |
1160 | } |
- | 1161 | ||
963 | return AE_OK; |
1162 | return (AE_OK); |
964 | }>>> |
1163 | }>>>> |