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: dbexec - debugger control method execution |
3 | * Module Name: dbexec - debugger control method execution |
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 | 116 | ||
117 | #include "acpi.h" |
117 | #include "acpi.h" |
118 | #include "accommon.h" |
118 | #include "accommon.h" |
119 | #include "acdebug.h" |
119 | #include "acdebug.h" |
120 | #include "acnamesp.h" |
120 | #include "acnamesp.h" |
121 | 121 | ||
122 | #ifdef ACPI_DEBUGGER |
122 | #ifdef ACPI_DEBUGGER |
123 | 123 | ||
124 | #define _COMPONENT ACPI_CA_DEBUGGER |
124 | #define _COMPONENT ACPI_CA_DEBUGGER |
125 | ACPI_MODULE_NAME ("dbexec") |
125 | ACPI_MODULE_NAME ("dbexec") |
126 | 126 | ||
127 | 127 | ||
128 | static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; |
128 | static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; |
- | 129 | #define DB_DEFAULT_PKG_ELEMENTS 33 |
|
129 | 130 | ||
130 | /* Local prototypes */ |
131 | /* Local prototypes */ |
131 | 132 | ||
132 | static ACPI_STATUS |
133 | static ACPI_STATUS |
133 | AcpiDbExecuteMethod ( |
134 | AcpiDbExecuteMethod ( |
134 | ACPI_DB_METHOD_INFO *Info, |
135 | ACPI_DB_METHOD_INFO *Info, |
135 | ACPI_BUFFER *ReturnObj); |
136 | ACPI_BUFFER *ReturnObj); |
136 | 137 | ||
137 | static void |
138 | static void |
138 | AcpiDbExecuteSetup ( |
139 | AcpiDbExecuteSetup ( |
139 | ACPI_DB_METHOD_INFO *Info); |
140 | ACPI_DB_METHOD_INFO *Info); |
140 | 141 | ||
141 | static UINT32 |
142 | static UINT32 |
142 | AcpiDbGetOutstandingAllocations ( |
143 | AcpiDbGetOutstandingAllocations ( |
143 | void); |
144 | void); |
144 | 145 | ||
145 | static void ACPI_SYSTEM_XFACE |
146 | static void ACPI_SYSTEM_XFACE |
146 | AcpiDbMethodThread ( |
147 | AcpiDbMethodThread ( |
147 | void *Context); |
148 | void *Context); |
148 | 149 | ||
149 | static ACPI_STATUS |
150 | static ACPI_STATUS |
150 | AcpiDbExecutionWalk ( |
151 | AcpiDbExecutionWalk ( |
151 | ACPI_HANDLE ObjHandle, |
152 | ACPI_HANDLE ObjHandle, |
152 | UINT32 NestingLevel, |
153 | UINT32 NestingLevel, |
153 | void *Context, |
154 | void *Context, |
154 | void **ReturnValue); |
155 | void **ReturnValue); |
- | 156 | ||
- | 157 | static ACPI_STATUS |
|
- | 158 | AcpiDbHexCharToValue ( |
|
- | 159 | int HexChar, |
|
- | 160 | UINT8 *ReturnValue); |
|
- | 161 | ||
- | 162 | static ACPI_STATUS |
|
- | 163 | AcpiDbConvertToPackage ( |
|
- | 164 | char *String, |
|
- | 165 | ACPI_OBJECT *Object); |
|
- | 166 | ||
- | 167 | static ACPI_STATUS |
|
- | 168 | AcpiDbConvertToObject ( |
|
- | 169 | ACPI_OBJECT_TYPE Type, |
|
- | 170 | char *String, |
|
- | 171 | ACPI_OBJECT *Object); |
|
- | 172 | ||
- | 173 | static void |
|
- | 174 | AcpiDbDeleteObjects ( |
|
- | 175 | UINT32 Count, |
|
- | 176 | ACPI_OBJECT *Objects); |
|
- | 177 | ||
- | 178 | ||
- | 179 | /******************************************************************************* |
|
- | 180 | * |
|
- | 181 | * FUNCTION: AcpiDbHexCharToValue |
|
- | 182 | * |
|
- | 183 | * PARAMETERS: HexChar - Ascii Hex digit, 0-9|a-f|A-F |
|
- | 184 | * ReturnValue - Where the converted value is returned |
|
- | 185 | * |
|
- | 186 | * RETURN: Status |
|
- | 187 | * |
|
- | 188 | * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16). |
|
- | 189 | * |
|
- | 190 | ******************************************************************************/ |
|
- | 191 | ||
- | 192 | static ACPI_STATUS |
|
- | 193 | AcpiDbHexCharToValue ( |
|
- | 194 | int HexChar, |
|
- | 195 | UINT8 *ReturnValue) |
|
- | 196 | { |
|
- | 197 | UINT8 Value; |
|
- | 198 | ||
- | 199 | ||
- | 200 | /* Digit must be ascii [0-9a-fA-F] */ |
|
- | 201 | ||
- | 202 | if (!ACPI_IS_XDIGIT (HexChar)) |
|
- | 203 | { |
|
- | 204 | return (AE_BAD_HEX_CONSTANT); |
|
- | 205 | } |
|
- | 206 | ||
- | 207 | if (HexChar <= 0x39) |
|
- | 208 | { |
|
- | 209 | Value = (UINT8) (HexChar - 0x30); |
|
- | 210 | } |
|
- | 211 | else |
|
- | 212 | { |
|
- | 213 | Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37); |
|
- | 214 | } |
|
- | 215 | ||
- | 216 | *ReturnValue = Value; |
|
- | 217 | return (AE_OK); |
|
- | 218 | } |
|
- | 219 | ||
- | 220 | ||
- | 221 | /******************************************************************************* |
|
- | 222 | * |
|
- | 223 | * FUNCTION: AcpiDbHexByteToBinary |
|
- | 224 | * |
|
- | 225 | * PARAMETERS: HexByte - Double hex digit (0x00 - 0xFF) in format: |
|
- | 226 | * HiByte then LoByte. |
|
- | 227 | * ReturnValue - Where the converted value is returned |
|
- | 228 | * |
|
- | 229 | * RETURN: Status |
|
- | 230 | * |
|
- | 231 | * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255). |
|
- | 232 | * |
|
- | 233 | ******************************************************************************/ |
|
- | 234 | ||
- | 235 | static ACPI_STATUS |
|
- | 236 | AcpiDbHexByteToBinary ( |
|
- | 237 | char *HexByte, |
|
- | 238 | UINT8 *ReturnValue) |
|
- | 239 | { |
|
- | 240 | UINT8 Local0; |
|
- | 241 | UINT8 Local1; |
|
- | 242 | ACPI_STATUS Status; |
|
- | 243 | ||
- | 244 | ||
- | 245 | /* High byte */ |
|
- | 246 | ||
- | 247 | Status = AcpiDbHexCharToValue (HexByte[0], &Local0); |
|
- | 248 | if (ACPI_FAILURE (Status)) |
|
- | 249 | { |
|
- | 250 | return (Status); |
|
- | 251 | } |
|
- | 252 | ||
- | 253 | /* Low byte */ |
|
- | 254 | ||
- | 255 | Status = AcpiDbHexCharToValue (HexByte[1], &Local1); |
|
- | 256 | if (ACPI_FAILURE (Status)) |
|
- | 257 | { |
|
- | 258 | return (Status); |
|
- | 259 | } |
|
- | 260 | ||
- | 261 | *ReturnValue = (UINT8) ((Local0 << 4) | Local1); |
|
- | 262 | return (AE_OK); |
|
- | 263 | } |
|
- | 264 | ||
- | 265 | ||
- | 266 | /******************************************************************************* |
|
- | 267 | * |
|
- | 268 | * FUNCTION: AcpiDbConvertToBuffer |
|
- | 269 | * |
|
- | 270 | * PARAMETERS: String - Input string to be converted |
|
- | 271 | * Object - Where the buffer object is returned |
|
- | 272 | * |
|
- | 273 | * RETURN: Status |
|
- | 274 | * |
|
- | 275 | * DESCRIPTION: Convert a string to a buffer object. String is treated a list |
|
- | 276 | * of buffer elements, each separated by a space or comma. |
|
- | 277 | * |
|
- | 278 | ******************************************************************************/ |
|
- | 279 | ||
- | 280 | static ACPI_STATUS |
|
- | 281 | AcpiDbConvertToBuffer ( |
|
- | 282 | char *String, |
|
- | 283 | ACPI_OBJECT *Object) |
|
- | 284 | { |
|
- | 285 | UINT32 i; |
|
- | 286 | UINT32 j; |
|
- | 287 | UINT32 Length; |
|
- | 288 | UINT8 *Buffer; |
|
- | 289 | ACPI_STATUS Status; |
|
- | 290 | ||
- | 291 | ||
- | 292 | /* Generate the final buffer length */ |
|
- | 293 | ||
- | 294 | for (i = 0, Length = 0; String[i];) |
|
- | 295 | { |
|
- | 296 | i+=2; |
|
- | 297 | Length++; |
|
- | 298 | ||
- | 299 | while (String[i] && |
|
- | 300 | ((String[i] == ',') || (String[i] == ' '))) |
|
- | 301 | { |
|
- | 302 | i++; |
|
- | 303 | } |
|
- | 304 | } |
|
- | 305 | ||
- | 306 | Buffer = ACPI_ALLOCATE (Length); |
|
- | 307 | if (!Buffer) |
|
- | 308 | { |
|
- | 309 | return (AE_NO_MEMORY); |
|
- | 310 | } |
|
- | 311 | ||
- | 312 | /* Convert the command line bytes to the buffer */ |
|
- | 313 | ||
- | 314 | for (i = 0, j = 0; String[i];) |
|
- | 315 | { |
|
- | 316 | Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]); |
|
- | 317 | if (ACPI_FAILURE (Status)) |
|
- | 318 | { |
|
- | 319 | ACPI_FREE (Buffer); |
|
- | 320 | return (Status); |
|
- | 321 | } |
|
- | 322 | ||
- | 323 | j++; |
|
- | 324 | i+=2; |
|
- | 325 | while (String[i] && |
|
- | 326 | ((String[i] == ',') || (String[i] == ' '))) |
|
- | 327 | { |
|
- | 328 | i++; |
|
- | 329 | } |
|
- | 330 | } |
|
- | 331 | ||
- | 332 | Object->Type = ACPI_TYPE_BUFFER; |
|
- | 333 | Object->Buffer.Pointer = Buffer; |
|
- | 334 | Object->Buffer.Length = Length; |
|
- | 335 | return (AE_OK); |
|
- | 336 | } |
|
- | 337 | ||
- | 338 | ||
- | 339 | /******************************************************************************* |
|
- | 340 | * |
|
- | 341 | * FUNCTION: AcpiDbConvertToPackage |
|
- | 342 | * |
|
- | 343 | * PARAMETERS: String - Input string to be converted |
|
- | 344 | * Object - Where the package object is returned |
|
- | 345 | * |
|
- | 346 | * RETURN: Status |
|
- | 347 | * |
|
- | 348 | * DESCRIPTION: Convert a string to a package object. Handles nested packages |
|
- | 349 | * via recursion with AcpiDbConvertToObject. |
|
- | 350 | * |
|
- | 351 | ******************************************************************************/ |
|
- | 352 | ||
- | 353 | static ACPI_STATUS |
|
- | 354 | AcpiDbConvertToPackage ( |
|
- | 355 | char *String, |
|
- | 356 | ACPI_OBJECT *Object) |
|
- | 357 | { |
|
- | 358 | char *This; |
|
- | 359 | char *Next; |
|
- | 360 | UINT32 i; |
|
- | 361 | ACPI_OBJECT_TYPE Type; |
|
- | 362 | ACPI_OBJECT *Elements; |
|
- | 363 | ACPI_STATUS Status; |
|
- | 364 | ||
- | 365 | ||
- | 366 | Elements = ACPI_ALLOCATE_ZEROED ( |
|
- | 367 | DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT)); |
|
- | 368 | ||
- | 369 | This = String; |
|
- | 370 | for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) |
|
- | 371 | { |
|
- | 372 | This = AcpiDbGetNextToken (This, &Next, &Type); |
|
- | 373 | if (!This) |
|
- | 374 | { |
|
- | 375 | break; |
|
- | 376 | } |
|
- | 377 | ||
- | 378 | /* Recursive call to convert each package element */ |
|
- | 379 | ||
- | 380 | Status = AcpiDbConvertToObject (Type, This, &Elements[i]); |
|
- | 381 | if (ACPI_FAILURE (Status)) |
|
- | 382 | { |
|
- | 383 | AcpiDbDeleteObjects (i + 1, Elements); |
|
- | 384 | ACPI_FREE (Elements); |
|
- | 385 | return (Status); |
|
- | 386 | } |
|
- | 387 | ||
- | 388 | This = Next; |
|
- | 389 | } |
|
- | 390 | ||
- | 391 | Object->Type = ACPI_TYPE_PACKAGE; |
|
- | 392 | Object->Package.Count = i; |
|
- | 393 | Object->Package.Elements = Elements; |
|
- | 394 | return (AE_OK); |
|
- | 395 | } |
|
- | 396 | ||
- | 397 | ||
- | 398 | /******************************************************************************* |
|
- | 399 | * |
|
- | 400 | * FUNCTION: AcpiDbConvertToObject |
|
- | 401 | * |
|
- | 402 | * PARAMETERS: Type - Object type as determined by parser |
|
- | 403 | * String - Input string to be converted |
|
- | 404 | * Object - Where the new object is returned |
|
- | 405 | * |
|
- | 406 | * RETURN: Status |
|
- | 407 | * |
|
- | 408 | * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing: |
|
- | 409 | * 1) String objects were surrounded by quotes. |
|
- | 410 | * 2) Buffer objects were surrounded by parentheses. |
|
- | 411 | * 3) Package objects were surrounded by brackets "[]". |
|
- | 412 | * 4) All standalone tokens are treated as integers. |
|
- | 413 | * |
|
- | 414 | ******************************************************************************/ |
|
- | 415 | ||
- | 416 | static ACPI_STATUS |
|
- | 417 | AcpiDbConvertToObject ( |
|
- | 418 | ACPI_OBJECT_TYPE Type, |
|
- | 419 | char *String, |
|
- | 420 | ACPI_OBJECT *Object) |
|
- | 421 | { |
|
- | 422 | ACPI_STATUS Status = AE_OK; |
|
- | 423 | ||
- | 424 | ||
- | 425 | switch (Type) |
|
- | 426 | { |
|
- | 427 | case ACPI_TYPE_STRING: |
|
- | 428 | Object->Type = ACPI_TYPE_STRING; |
|
- | 429 | Object->String.Pointer = String; |
|
- | 430 | Object->String.Length = (UINT32) ACPI_STRLEN (String); |
|
- | 431 | break; |
|
- | 432 | ||
- | 433 | case ACPI_TYPE_BUFFER: |
|
- | 434 | Status = AcpiDbConvertToBuffer (String, Object); |
|
- | 435 | break; |
|
- | 436 | ||
- | 437 | case ACPI_TYPE_PACKAGE: |
|
- | 438 | Status = AcpiDbConvertToPackage (String, Object); |
|
- | 439 | break; |
|
- | 440 | ||
- | 441 | default: |
|
- | 442 | Object->Type = ACPI_TYPE_INTEGER; |
|
- | 443 | Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); |
|
- | 444 | break; |
|
- | 445 | } |
|
- | 446 | ||
- | 447 | return (Status); |
|
- | 448 | } |
|
- | 449 | ||
- | 450 | ||
- | 451 | /******************************************************************************* |
|
- | 452 | * |
|
- | 453 | * FUNCTION: AcpiDbDeleteObjects |
|
- | 454 | * |
|
- | 455 | * PARAMETERS: Count - Count of objects in the list |
|
- | 456 | * Objects - Array of ACPI_OBJECTs to be deleted |
|
- | 457 | * |
|
- | 458 | * RETURN: None |
|
- | 459 | * |
|
- | 460 | * DESCRIPTION: Delete a list of ACPI_OBJECTS. Handles packages and nested |
|
- | 461 | * packages via recursion. |
|
- | 462 | * |
|
- | 463 | ******************************************************************************/ |
|
- | 464 | ||
- | 465 | static void |
|
- | 466 | AcpiDbDeleteObjects ( |
|
- | 467 | UINT32 Count, |
|
- | 468 | ACPI_OBJECT *Objects) |
|
- | 469 | { |
|
- | 470 | UINT32 i; |
|
- | 471 | ||
- | 472 | ||
- | 473 | for (i = 0; i < Count; i++) |
|
- | 474 | { |
|
- | 475 | switch (Objects[i].Type) |
|
- | 476 | { |
|
- | 477 | case ACPI_TYPE_BUFFER: |
|
- | 478 | ACPI_FREE (Objects[i].Buffer.Pointer); |
|
- | 479 | break; |
|
- | 480 | ||
- | 481 | case ACPI_TYPE_PACKAGE: |
|
- | 482 | ||
- | 483 | /* Recursive call to delete package elements */ |
|
- | 484 | ||
- | 485 | AcpiDbDeleteObjects (Objects[i].Package.Count, |
|
- | 486 | Objects[i].Package.Elements); |
|
- | 487 | ||
- | 488 | /* Free the elements array */ |
|
- | 489 | ||
- | 490 | ACPI_FREE (Objects[i].Package.Elements); |
|
- | 491 | break; |
|
- | 492 | ||
- | 493 | default: |
|
- | 494 | break; |
|
- | 495 | } |
|
- | 496 | } |
|
- | 497 | } |
|
155 | 498 | ||
156 | 499 | ||
157 | /******************************************************************************* |
500 | /******************************************************************************* |
158 | * |
501 | * |
159 | * FUNCTION: AcpiDbExecuteMethod |
502 | * FUNCTION: AcpiDbExecuteMethod |
160 | * |
503 | * |
161 | * PARAMETERS: Info - Valid info segment |
504 | * PARAMETERS: Info - Valid info segment |
162 | * ReturnObj - Where to put return object |
505 | * ReturnObj - Where to put return object |
163 | * |
506 | * |
164 | * RETURN: Status |
507 | * RETURN: Status |
165 | * |
508 | * |
166 | * DESCRIPTION: Execute a control method. |
509 | * DESCRIPTION: Execute a control method. |
167 | * |
510 | * |
168 | ******************************************************************************/ |
511 | ******************************************************************************/ |
169 | 512 | ||
170 | static ACPI_STATUS |
513 | static ACPI_STATUS |
171 | AcpiDbExecuteMethod ( |
514 | AcpiDbExecuteMethod ( |
172 | ACPI_DB_METHOD_INFO *Info, |
515 | ACPI_DB_METHOD_INFO *Info, |
173 | ACPI_BUFFER *ReturnObj) |
516 | ACPI_BUFFER *ReturnObj) |
174 | { |
517 | { |
175 | ACPI_STATUS Status; |
518 | ACPI_STATUS Status; |
176 | ACPI_OBJECT_LIST ParamObjects; |
519 | ACPI_OBJECT_LIST ParamObjects; |
177 | ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; |
520 | ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; |
178 | ACPI_HANDLE Handle; |
521 | ACPI_HANDLE Handle; |
179 | UINT32 i; |
- | |
180 | ACPI_DEVICE_INFO *ObjInfo; |
522 | ACPI_DEVICE_INFO *ObjInfo; |
- | 523 | UINT32 i; |
|
- | 524 | ||
- | 525 | ||
- | 526 | ACPI_FUNCTION_TRACE (DbExecuteMethod); |
|
181 | 527 | ||
182 | 528 | ||
183 | if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) |
529 | if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) |
184 | { |
530 | { |
185 | AcpiOsPrintf ("Warning: debug output is not enabled!\n"); |
531 | AcpiOsPrintf ("Warning: debug output is not enabled!\n"); |
186 | } |
532 | } |
187 | 533 | ||
188 | /* Get the NS node, determines existence also */ |
534 | /* Get the NS node, determines existence also */ |
189 | 535 | ||
190 | Status = AcpiGetHandle (NULL, Info->Pathname, &Handle); |
536 | Status = AcpiGetHandle (NULL, Info->Pathname, &Handle); |
191 | if (ACPI_FAILURE (Status)) |
537 | if (ACPI_FAILURE (Status)) |
192 | { |
538 | { |
193 | return (Status); |
539 | return_ACPI_STATUS (Status); |
194 | } |
540 | } |
195 | 541 | ||
196 | /* Get the object info for number of method parameters */ |
542 | /* Get the object info for number of method parameters */ |
197 | 543 | ||
198 | Status = AcpiGetObjectInfo (Handle, &ObjInfo); |
544 | Status = AcpiGetObjectInfo (Handle, &ObjInfo); |
199 | if (ACPI_FAILURE (Status)) |
545 | if (ACPI_FAILURE (Status)) |
200 | { |
546 | { |
201 | return (Status); |
547 | return_ACPI_STATUS (Status); |
202 | } |
548 | } |
203 | 549 | ||
204 | ParamObjects.Pointer = NULL; |
550 | ParamObjects.Pointer = NULL; |
205 | ParamObjects.Count = 0; |
551 | ParamObjects.Count = 0; |
206 | 552 | ||
207 | if (ObjInfo->Type == ACPI_TYPE_METHOD) |
553 | if (ObjInfo->Type == ACPI_TYPE_METHOD) |
208 | { |
554 | { |
209 | /* Are there arguments to the method? */ |
555 | /* Are there arguments to the method? */ |
- | 556 | ||
210 | 557 | i = 0; |
|
211 | if (Info->Args && Info->Args[0]) |
558 | if (Info->Args && Info->Args[0]) |
- | 559 | { |
|
- | 560 | /* Get arguments passed on the command line */ |
|
- | 561 | ||
212 | { |
562 | for (; Info->Args[i] && |
- | 563 | (i < ACPI_METHOD_NUM_ARGS) && |
|
- | 564 | (i < ObjInfo->ParamCount); |
|
- | 565 | i++) |
|
- | 566 | { |
|
- | 567 | /* Convert input string (token) to an actual ACPI_OBJECT */ |
|
- | 568 | ||
- | 569 | Status = AcpiDbConvertToObject (Info->Types[i], |
|
- | 570 | Info->Args[i], &Params[i]); |
|
213 | for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++) |
571 | if (ACPI_FAILURE (Status)) |
214 | { |
572 | { |
215 | Params[i].Type = ACPI_TYPE_INTEGER; |
573 | ACPI_EXCEPTION ((AE_INFO, Status, |
- | 574 | "While parsing method arguments")); |
|
216 | Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); |
575 | goto Cleanup; |
217 | } |
- | |
218 | - | ||
219 | ParamObjects.Pointer = Params; |
- | |
220 | ParamObjects.Count = i; |
576 | } |
221 | } |
577 | } |
- | 578 | } |
|
- | 579 | ||
- | 580 | /* Create additional "default" parameters as needed */ |
|
- | 581 | ||
222 | else |
582 | if (i < ObjInfo->ParamCount) |
- | 583 | { |
|
223 | { |
584 | AcpiOsPrintf ("Adding %u arguments containing default values\n", |
224 | /* Setup default parameters */ |
585 | ObjInfo->ParamCount - i); |
225 | 586 | ||
226 | for (i = 0; i < ObjInfo->ParamCount; i++) |
587 | for (; i < ObjInfo->ParamCount; i++) |
227 | { |
588 | { |
228 | switch (i) |
589 | switch (i) |
229 | { |
590 | { |
230 | case 0: |
591 | case 0: |
231 | 592 | ||
232 | Params[0].Type = ACPI_TYPE_INTEGER; |
593 | Params[0].Type = ACPI_TYPE_INTEGER; |
233 | Params[0].Integer.Value = 0x01020304; |
594 | Params[0].Integer.Value = 0x01020304; |
234 | break; |
595 | break; |
235 | 596 | ||
236 | case 1: |
597 | case 1: |
237 | 598 | ||
238 | Params[1].Type = ACPI_TYPE_STRING; |
599 | Params[1].Type = ACPI_TYPE_STRING; |
239 | Params[1].String.Length = 12; |
600 | Params[1].String.Length = 12; |
240 | Params[1].String.Pointer = "AML Debugger"; |
601 | Params[1].String.Pointer = "AML Debugger"; |
241 | break; |
602 | break; |
242 | 603 | ||
243 | default: |
604 | default: |
244 | 605 | ||
245 | Params[i].Type = ACPI_TYPE_INTEGER; |
606 | Params[i].Type = ACPI_TYPE_INTEGER; |
246 | Params[i].Integer.Value = i * (UINT64) 0x1000; |
607 | Params[i].Integer.Value = i * (UINT64) 0x1000; |
247 | break; |
608 | break; |
248 | } |
609 | } |
249 | } |
610 | } |
- | 611 | } |
|
250 | - | ||
251 | ParamObjects.Pointer = Params; |
612 | |
252 | ParamObjects.Count = ObjInfo->ParamCount; |
613 | ParamObjects.Count = ObjInfo->ParamCount; |
253 | } |
614 | ParamObjects.Pointer = Params; |
254 | } |
- | |
255 | - | ||
256 | ACPI_FREE (ObjInfo); |
615 | } |
257 | 616 | ||
258 | /* Prepare for a return object of arbitrary size */ |
617 | /* Prepare for a return object of arbitrary size */ |
259 | 618 | ||
260 | ReturnObj->Pointer = AcpiGbl_DbBuffer; |
619 | ReturnObj->Pointer = AcpiGbl_DbBuffer; |
261 | ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; |
620 | ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; |
262 | 621 | ||
263 | /* Do the actual method execution */ |
622 | /* Do the actual method execution */ |
264 | 623 | ||
265 | AcpiGbl_MethodExecuting = TRUE; |
624 | AcpiGbl_MethodExecuting = TRUE; |
266 | Status = AcpiEvaluateObject (NULL, |
625 | Status = AcpiEvaluateObject (NULL, |
267 | Info->Pathname, &ParamObjects, ReturnObj); |
626 | Info->Pathname, &ParamObjects, ReturnObj); |
268 | 627 | ||
269 | AcpiGbl_CmSingleStep = FALSE; |
628 | AcpiGbl_CmSingleStep = FALSE; |
270 | AcpiGbl_MethodExecuting = FALSE; |
629 | AcpiGbl_MethodExecuting = FALSE; |
- | 630 | ||
- | 631 | if (ACPI_FAILURE (Status)) |
|
- | 632 | { |
|
- | 633 | ACPI_EXCEPTION ((AE_INFO, Status, |
|
- | 634 | "while executing %s from debugger", Info->Pathname)); |
|
- | 635 | ||
- | 636 | if (Status == AE_BUFFER_OVERFLOW) |
|
- | 637 | { |
|
- | 638 | ACPI_ERROR ((AE_INFO, |
|
- | 639 | "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", |
|
- | 640 | ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length)); |
|
- | 641 | } |
|
- | 642 | } |
|
- | 643 | ||
- | 644 | Cleanup: |
|
- | 645 | AcpiDbDeleteObjects (ObjInfo->ParamCount, Params); |
|
- | 646 | ACPI_FREE (ObjInfo); |
|
271 | 647 | ||
272 | return (Status); |
648 | return_ACPI_STATUS (Status); |
273 | } |
649 | } |
274 | 650 | ||
275 | 651 | ||
276 | /******************************************************************************* |
652 | /******************************************************************************* |
277 | * |
653 | * |
278 | * FUNCTION: AcpiDbExecuteSetup |
654 | * FUNCTION: AcpiDbExecuteSetup |
279 | * |
655 | * |
280 | * PARAMETERS: Info - Valid method info |
656 | * PARAMETERS: Info - Valid method info |
281 | * |
657 | * |
282 | * RETURN: None |
658 | * RETURN: None |
283 | * |
659 | * |
284 | * DESCRIPTION: Setup info segment prior to method execution |
660 | * DESCRIPTION: Setup info segment prior to method execution |
285 | * |
661 | * |
286 | ******************************************************************************/ |
662 | ******************************************************************************/ |
287 | 663 | ||
288 | static void |
664 | static void |
289 | AcpiDbExecuteSetup ( |
665 | AcpiDbExecuteSetup ( |
290 | ACPI_DB_METHOD_INFO *Info) |
666 | ACPI_DB_METHOD_INFO *Info) |
291 | { |
667 | { |
292 | 668 | ||
293 | /* Catenate the current scope to the supplied name */ |
669 | /* Catenate the current scope to the supplied name */ |
294 | 670 | ||
295 | Info->Pathname[0] = 0; |
671 | Info->Pathname[0] = 0; |
296 | if ((Info->Name[0] != '\\') && |
672 | if ((Info->Name[0] != '\\') && |
297 | (Info->Name[0] != '/')) |
673 | (Info->Name[0] != '/')) |
298 | { |
674 | { |
299 | ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); |
675 | ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); |
300 | } |
676 | } |
301 | 677 | ||
302 | ACPI_STRCAT (Info->Pathname, Info->Name); |
678 | ACPI_STRCAT (Info->Pathname, Info->Name); |
303 | AcpiDbPrepNamestring (Info->Pathname); |
679 | AcpiDbPrepNamestring (Info->Pathname); |
304 | 680 | ||
305 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
681 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
306 | AcpiOsPrintf ("Executing %s\n", Info->Pathname); |
682 | AcpiOsPrintf ("Executing %s\n", Info->Pathname); |
307 | 683 | ||
308 | if (Info->Flags & EX_SINGLE_STEP) |
684 | if (Info->Flags & EX_SINGLE_STEP) |
309 | { |
685 | { |
310 | AcpiGbl_CmSingleStep = TRUE; |
686 | AcpiGbl_CmSingleStep = TRUE; |
311 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
687 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
312 | } |
688 | } |
313 | 689 | ||
314 | else |
690 | else |
315 | { |
691 | { |
316 | /* No single step, allow redirection to a file */ |
692 | /* No single step, allow redirection to a file */ |
317 | 693 | ||
318 | AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
694 | AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
319 | } |
695 | } |
320 | } |
696 | } |
321 | 697 | ||
322 | 698 | ||
323 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
699 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
324 | UINT32 |
700 | UINT32 |
325 | AcpiDbGetCacheInfo ( |
701 | AcpiDbGetCacheInfo ( |
326 | ACPI_MEMORY_LIST *Cache) |
702 | ACPI_MEMORY_LIST *Cache) |
327 | { |
703 | { |
328 | 704 | ||
329 | return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth); |
705 | return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth); |
330 | } |
706 | } |
331 | #endif |
707 | #endif |
332 | 708 | ||
333 | /******************************************************************************* |
709 | /******************************************************************************* |
334 | * |
710 | * |
335 | * FUNCTION: AcpiDbGetOutstandingAllocations |
711 | * FUNCTION: AcpiDbGetOutstandingAllocations |
336 | * |
712 | * |
337 | * PARAMETERS: None |
713 | * PARAMETERS: None |
338 | * |
714 | * |
339 | * RETURN: Current global allocation count minus cache entries |
715 | * RETURN: Current global allocation count minus cache entries |
340 | * |
716 | * |
341 | * DESCRIPTION: Determine the current number of "outstanding" allocations -- |
717 | * DESCRIPTION: Determine the current number of "outstanding" allocations -- |
342 | * those allocations that have not been freed and also are not |
718 | * those allocations that have not been freed and also are not |
343 | * in one of the various object caches. |
719 | * in one of the various object caches. |
344 | * |
720 | * |
345 | ******************************************************************************/ |
721 | ******************************************************************************/ |
346 | 722 | ||
347 | static UINT32 |
723 | static UINT32 |
348 | AcpiDbGetOutstandingAllocations ( |
724 | AcpiDbGetOutstandingAllocations ( |
349 | void) |
725 | void) |
350 | { |
726 | { |
351 | UINT32 Outstanding = 0; |
727 | UINT32 Outstanding = 0; |
352 | 728 | ||
353 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
729 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
354 | 730 | ||
355 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache); |
731 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache); |
356 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache); |
732 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache); |
357 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache); |
733 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache); |
358 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache); |
734 | Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache); |
359 | #endif |
735 | #endif |
360 | 736 | ||
361 | return (Outstanding); |
737 | return (Outstanding); |
362 | } |
738 | } |
363 | 739 | ||
364 | 740 | ||
365 | /******************************************************************************* |
741 | /******************************************************************************* |
366 | * |
742 | * |
367 | * FUNCTION: AcpiDbExecutionWalk |
743 | * FUNCTION: AcpiDbExecutionWalk |
368 | * |
744 | * |
369 | * PARAMETERS: WALK_CALLBACK |
745 | * PARAMETERS: WALK_CALLBACK |
370 | * |
746 | * |
371 | * RETURN: Status |
747 | * RETURN: Status |
372 | * |
748 | * |
373 | * DESCRIPTION: Execute a control method. Name is relative to the current |
749 | * DESCRIPTION: Execute a control method. Name is relative to the current |
374 | * scope. |
750 | * scope. |
375 | * |
751 | * |
376 | ******************************************************************************/ |
752 | ******************************************************************************/ |
377 | 753 | ||
378 | static ACPI_STATUS |
754 | static ACPI_STATUS |
379 | AcpiDbExecutionWalk ( |
755 | AcpiDbExecutionWalk ( |
380 | ACPI_HANDLE ObjHandle, |
756 | ACPI_HANDLE ObjHandle, |
381 | UINT32 NestingLevel, |
757 | UINT32 NestingLevel, |
382 | void *Context, |
758 | void *Context, |
383 | void **ReturnValue) |
759 | void **ReturnValue) |
384 | { |
760 | { |
385 | ACPI_OPERAND_OBJECT *ObjDesc; |
761 | ACPI_OPERAND_OBJECT *ObjDesc; |
386 | ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
762 | ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
387 | ACPI_BUFFER ReturnObj; |
763 | ACPI_BUFFER ReturnObj; |
388 | ACPI_STATUS Status; |
764 | ACPI_STATUS Status; |
389 | 765 | ||
390 | 766 | ||
391 | ObjDesc = AcpiNsGetAttachedObject (Node); |
767 | ObjDesc = AcpiNsGetAttachedObject (Node); |
392 | if (ObjDesc->Method.ParamCount) |
768 | if (ObjDesc->Method.ParamCount) |
393 | { |
769 | { |
394 | return (AE_OK); |
770 | return (AE_OK); |
395 | } |
771 | } |
396 | 772 | ||
397 | ReturnObj.Pointer = NULL; |
773 | ReturnObj.Pointer = NULL; |
398 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
774 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
399 | 775 | ||
400 | AcpiNsPrintNodePathname (Node, "Execute"); |
776 | AcpiNsPrintNodePathname (Node, "Execute"); |
401 | 777 | ||
402 | /* Do the actual method execution */ |
778 | /* Do the actual method execution */ |
403 | 779 | ||
404 | AcpiOsPrintf ("\n"); |
780 | AcpiOsPrintf ("\n"); |
405 | AcpiGbl_MethodExecuting = TRUE; |
781 | AcpiGbl_MethodExecuting = TRUE; |
406 | 782 | ||
407 | Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); |
783 | Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); |
408 | 784 | ||
409 | AcpiOsPrintf ("[%4.4s] returned %s\n", AcpiUtGetNodeName (Node), |
785 | AcpiOsPrintf ("[%4.4s] returned %s\n", AcpiUtGetNodeName (Node), |
410 | AcpiFormatException (Status)); |
786 | AcpiFormatException (Status)); |
411 | AcpiGbl_MethodExecuting = FALSE; |
787 | AcpiGbl_MethodExecuting = FALSE; |
412 | 788 | ||
413 | return (AE_OK); |
789 | return (AE_OK); |
414 | } |
790 | } |
415 | 791 | ||
416 | 792 | ||
417 | /******************************************************************************* |
793 | /******************************************************************************* |
418 | * |
794 | * |
419 | * FUNCTION: AcpiDbExecute |
795 | * FUNCTION: AcpiDbExecute |
420 | * |
796 | * |
421 | * PARAMETERS: Name - Name of method to execute |
797 | * PARAMETERS: Name - Name of method to execute |
422 | * Args - Parameters to the method |
798 | * Args - Parameters to the method |
423 | * Flags - single step/no single step |
799 | * Flags - single step/no single step |
424 | * |
800 | * |
425 | * RETURN: None |
801 | * RETURN: None |
426 | * |
802 | * |
427 | * DESCRIPTION: Execute a control method. Name is relative to the current |
803 | * DESCRIPTION: Execute a control method. Name is relative to the current |
428 | * scope. |
804 | * scope. |
429 | * |
805 | * |
430 | ******************************************************************************/ |
806 | ******************************************************************************/ |
431 | 807 | ||
432 | void |
808 | void |
433 | AcpiDbExecute ( |
809 | AcpiDbExecute ( |
434 | char *Name, |
810 | char *Name, |
435 | char **Args, |
811 | char **Args, |
- | 812 | ACPI_OBJECT_TYPE *Types, |
|
436 | UINT32 Flags) |
813 | UINT32 Flags) |
437 | { |
814 | { |
438 | ACPI_STATUS Status; |
815 | ACPI_STATUS Status; |
439 | ACPI_BUFFER ReturnObj; |
816 | ACPI_BUFFER ReturnObj; |
440 | char *NameString; |
817 | char *NameString; |
441 | 818 | ||
442 | 819 | ||
443 | #ifdef ACPI_DEBUG_OUTPUT |
820 | #ifdef ACPI_DEBUG_OUTPUT |
444 | UINT32 PreviousAllocations; |
821 | UINT32 PreviousAllocations; |
445 | UINT32 Allocations; |
822 | UINT32 Allocations; |
446 | 823 | ||
447 | 824 | ||
448 | /* Memory allocation tracking */ |
825 | /* Memory allocation tracking */ |
449 | 826 | ||
450 | PreviousAllocations = AcpiDbGetOutstandingAllocations (); |
827 | PreviousAllocations = AcpiDbGetOutstandingAllocations (); |
451 | #endif |
828 | #endif |
452 | 829 | ||
453 | if (*Name == '*') |
830 | if (*Name == '*') |
454 | { |
831 | { |
455 | (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, |
832 | (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, |
456 | ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); |
833 | ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); |
457 | return; |
834 | return; |
458 | } |
835 | } |
459 | else |
836 | else |
460 | { |
837 | { |
461 | NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); |
838 | NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); |
462 | if (!NameString) |
839 | if (!NameString) |
463 | { |
840 | { |
464 | return; |
841 | return; |
465 | } |
842 | } |
466 | 843 | ||
467 | ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
844 | ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
468 | 845 | ||
469 | ACPI_STRCPY (NameString, Name); |
846 | ACPI_STRCPY (NameString, Name); |
470 | AcpiUtStrupr (NameString); |
847 | AcpiUtStrupr (NameString); |
471 | AcpiGbl_DbMethodInfo.Name = NameString; |
848 | AcpiGbl_DbMethodInfo.Name = NameString; |
472 | AcpiGbl_DbMethodInfo.Args = Args; |
849 | AcpiGbl_DbMethodInfo.Args = Args; |
- | 850 | AcpiGbl_DbMethodInfo.Types = Types; |
|
473 | AcpiGbl_DbMethodInfo.Flags = Flags; |
851 | AcpiGbl_DbMethodInfo.Flags = Flags; |
474 | 852 | ||
475 | ReturnObj.Pointer = NULL; |
853 | ReturnObj.Pointer = NULL; |
476 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
854 | ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
477 | 855 | ||
478 | AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
856 | AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
479 | Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); |
857 | Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); |
480 | ACPI_FREE (NameString); |
858 | ACPI_FREE (NameString); |
481 | } |
859 | } |
482 | 860 | ||
483 | /* |
861 | /* |
484 | * Allow any handlers in separate threads to complete. |
862 | * Allow any handlers in separate threads to complete. |
485 | * (Such as Notify handlers invoked from AML executed above). |
863 | * (Such as Notify handlers invoked from AML executed above). |
486 | */ |
864 | */ |
487 | AcpiOsSleep ((UINT64) 10); |
865 | AcpiOsSleep ((UINT64) 10); |
488 | 866 | ||
489 | 867 | ||
490 | #ifdef ACPI_DEBUG_OUTPUT |
868 | #ifdef ACPI_DEBUG_OUTPUT |
491 | 869 | ||
492 | /* Memory allocation tracking */ |
870 | /* Memory allocation tracking */ |
493 | 871 | ||
494 | Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations; |
872 | Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations; |
495 | 873 | ||
496 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
874 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
497 | 875 | ||
498 | if (Allocations > 0) |
876 | if (Allocations > 0) |
499 | { |
877 | { |
500 | AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", |
878 | AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", |
501 | Allocations); |
879 | Allocations); |
502 | } |
880 | } |
503 | #endif |
881 | #endif |
504 | 882 | ||
505 | if (ACPI_FAILURE (Status)) |
883 | if (ACPI_FAILURE (Status)) |
506 | { |
884 | { |
507 | AcpiOsPrintf ("Execution of %s failed with status %s\n", |
885 | AcpiOsPrintf ("Execution of %s failed with status %s\n", |
508 | AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); |
886 | AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); |
509 | } |
887 | } |
510 | else |
888 | else |
511 | { |
889 | { |
512 | /* Display a return object, if any */ |
890 | /* Display a return object, if any */ |
513 | 891 | ||
514 | if (ReturnObj.Length) |
892 | if (ReturnObj.Length) |
515 | { |
893 | { |
516 | AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
894 | AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
517 | AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, |
895 | AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, |
518 | (UINT32) ReturnObj.Length); |
896 | (UINT32) ReturnObj.Length); |
519 | AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
897 | AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
520 | } |
898 | } |
521 | else |
899 | else |
522 | { |
900 | { |
523 | AcpiOsPrintf ("No return object from execution of %s\n", |
901 | AcpiOsPrintf ("No return object from execution of %s\n", |
524 | AcpiGbl_DbMethodInfo.Pathname); |
902 | AcpiGbl_DbMethodInfo.Pathname); |
525 | } |
903 | } |
526 | } |
904 | } |
527 | 905 | ||
528 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
906 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
529 | } |
907 | } |
530 | 908 | ||
531 | 909 | ||
532 | /******************************************************************************* |
910 | /******************************************************************************* |
533 | * |
911 | * |
534 | * FUNCTION: AcpiDbMethodThread |
912 | * FUNCTION: AcpiDbMethodThread |
535 | * |
913 | * |
536 | * PARAMETERS: Context - Execution info segment |
914 | * PARAMETERS: Context - Execution info segment |
537 | * |
915 | * |
538 | * RETURN: None |
916 | * RETURN: None |
539 | * |
917 | * |
540 | * DESCRIPTION: Debugger execute thread. Waits for a command line, then |
918 | * DESCRIPTION: Debugger execute thread. Waits for a command line, then |
541 | * simply dispatches it. |
919 | * simply dispatches it. |
542 | * |
920 | * |
543 | ******************************************************************************/ |
921 | ******************************************************************************/ |
544 | 922 | ||
545 | static void ACPI_SYSTEM_XFACE |
923 | static void ACPI_SYSTEM_XFACE |
546 | AcpiDbMethodThread ( |
924 | AcpiDbMethodThread ( |
547 | void *Context) |
925 | void *Context) |
548 | { |
926 | { |
549 | ACPI_STATUS Status; |
927 | ACPI_STATUS Status; |
550 | ACPI_DB_METHOD_INFO *Info = Context; |
928 | ACPI_DB_METHOD_INFO *Info = Context; |
551 | ACPI_DB_METHOD_INFO LocalInfo; |
929 | ACPI_DB_METHOD_INFO LocalInfo; |
552 | UINT32 i; |
930 | UINT32 i; |
553 | UINT8 Allow; |
931 | UINT8 Allow; |
554 | ACPI_BUFFER ReturnObj; |
932 | ACPI_BUFFER ReturnObj; |
555 | 933 | ||
556 | 934 | ||
557 | /* |
935 | /* |
558 | * AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments. |
936 | * AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments. |
559 | * Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads |
937 | * Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads |
560 | * concurrently. |
938 | * concurrently. |
561 | * |
939 | * |
562 | * Note: The arguments we are passing are used by the ASL test suite |
940 | * Note: The arguments we are passing are used by the ASL test suite |
563 | * (aslts). Do not change them without updating the tests. |
941 | * (aslts). Do not change them without updating the tests. |
564 | */ |
942 | */ |
565 | (void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER); |
943 | (void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER); |
566 | 944 | ||
567 | if (Info->InitArgs) |
945 | if (Info->InitArgs) |
568 | { |
946 | { |
569 | AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); |
947 | AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); |
570 | AcpiDbUInt32ToHexString (ACPI_TO_INTEGER (AcpiOsGetThreadId ()), |
948 | AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); |
571 | Info->IdOfThreadStr); |
- | |
572 | } |
949 | } |
573 | 950 | ||
574 | if (Info->Threads && (Info->NumCreated < Info->NumThreads)) |
951 | if (Info->Threads && (Info->NumCreated < Info->NumThreads)) |
575 | { |
952 | { |
576 | Info->Threads[Info->NumCreated++] = |
953 | Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId(); |
577 | ACPI_TO_INTEGER (AcpiOsGetThreadId()); |
- | |
578 | } |
954 | } |
579 | 955 | ||
580 | LocalInfo = *Info; |
956 | LocalInfo = *Info; |
581 | LocalInfo.Args = LocalInfo.Arguments; |
957 | LocalInfo.Args = LocalInfo.Arguments; |
582 | LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr; |
958 | LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr; |
583 | LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr; |
959 | LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr; |
584 | LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr; |
960 | LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr; |
585 | LocalInfo.Arguments[3] = NULL; |
961 | LocalInfo.Arguments[3] = NULL; |
- | 962 | ||
- | 963 | LocalInfo.Types = LocalInfo.ArgTypes; |
|
586 | 964 | ||
587 | (void) AcpiOsSignalSemaphore (Info->InfoGate, 1); |
965 | (void) AcpiOsSignalSemaphore (Info->InfoGate, 1); |
588 | 966 | ||
589 | for (i = 0; i < Info->NumLoops; i++) |
967 | for (i = 0; i < Info->NumLoops; i++) |
590 | { |
968 | { |
591 | Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj); |
969 | Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj); |
592 | if (ACPI_FAILURE (Status)) |
970 | if (ACPI_FAILURE (Status)) |
593 | { |
971 | { |
594 | AcpiOsPrintf ("%s During execution of %s at iteration %X\n", |
972 | AcpiOsPrintf ("%s During execution of %s at iteration %X\n", |
595 | AcpiFormatException (Status), Info->Pathname, i); |
973 | AcpiFormatException (Status), Info->Pathname, i); |
596 | if (Status == AE_ABORT_METHOD) |
974 | if (Status == AE_ABORT_METHOD) |
597 | { |
975 | { |
598 | break; |
976 | break; |
599 | } |
977 | } |
600 | } |
978 | } |
601 | 979 | ||
602 | #if 0 |
980 | #if 0 |
603 | if ((i % 100) == 0) |
981 | if ((i % 100) == 0) |
604 | { |
982 | { |
605 | AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); |
983 | AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); |
606 | } |
984 | } |
607 | 985 | ||
608 | if (ReturnObj.Length) |
986 | if (ReturnObj.Length) |
609 | { |
987 | { |
610 | AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
988 | AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
611 | Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); |
989 | Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); |
612 | AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
990 | AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
613 | } |
991 | } |
614 | #endif |
992 | #endif |
615 | } |
993 | } |
616 | 994 | ||
617 | /* Signal our completion */ |
995 | /* Signal our completion */ |
618 | 996 | ||
619 | Allow = 0; |
997 | Allow = 0; |
620 | (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); |
998 | (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); |
621 | Info->NumCompleted++; |
999 | Info->NumCompleted++; |
622 | 1000 | ||
623 | if (Info->NumCompleted == Info->NumThreads) |
1001 | if (Info->NumCompleted == Info->NumThreads) |
624 | { |
1002 | { |
625 | /* Do signal for main thread once only */ |
1003 | /* Do signal for main thread once only */ |
626 | Allow = 1; |
1004 | Allow = 1; |
627 | } |
1005 | } |
628 | 1006 | ||
629 | (void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1); |
1007 | (void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1); |
630 | 1008 | ||
631 | if (Allow) |
1009 | if (Allow) |
632 | { |
1010 | { |
633 | Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); |
1011 | Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); |
634 | if (ACPI_FAILURE (Status)) |
1012 | if (ACPI_FAILURE (Status)) |
635 | { |
1013 | { |
636 | AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", |
1014 | AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", |
637 | AcpiFormatException (Status)); |
1015 | AcpiFormatException (Status)); |
638 | } |
1016 | } |
639 | } |
1017 | } |
640 | } |
1018 | } |
641 | 1019 | ||
642 | 1020 | ||
643 | /******************************************************************************* |
1021 | /******************************************************************************* |
644 | * |
1022 | * |
645 | * FUNCTION: AcpiDbCreateExecutionThreads |
1023 | * FUNCTION: AcpiDbCreateExecutionThreads |
646 | * |
1024 | * |
647 | * PARAMETERS: NumThreadsArg - Number of threads to create |
1025 | * PARAMETERS: NumThreadsArg - Number of threads to create |
648 | * NumLoopsArg - Loop count for the thread(s) |
1026 | * NumLoopsArg - Loop count for the thread(s) |
649 | * MethodNameArg - Control method to execute |
1027 | * MethodNameArg - Control method to execute |
650 | * |
1028 | * |
651 | * RETURN: None |
1029 | * RETURN: None |
652 | * |
1030 | * |
653 | * DESCRIPTION: Create threads to execute method(s) |
1031 | * DESCRIPTION: Create threads to execute method(s) |
654 | * |
1032 | * |
655 | ******************************************************************************/ |
1033 | ******************************************************************************/ |
656 | 1034 | ||
657 | void |
1035 | void |
658 | AcpiDbCreateExecutionThreads ( |
1036 | AcpiDbCreateExecutionThreads ( |
659 | char *NumThreadsArg, |
1037 | char *NumThreadsArg, |
660 | char *NumLoopsArg, |
1038 | char *NumLoopsArg, |
661 | char *MethodNameArg) |
1039 | char *MethodNameArg) |
662 | { |
1040 | { |
663 | ACPI_STATUS Status; |
1041 | ACPI_STATUS Status; |
664 | UINT32 NumThreads; |
1042 | UINT32 NumThreads; |
665 | UINT32 NumLoops; |
1043 | UINT32 NumLoops; |
666 | UINT32 i; |
1044 | UINT32 i; |
667 | UINT32 Size; |
1045 | UINT32 Size; |
668 | ACPI_MUTEX MainThreadGate; |
1046 | ACPI_MUTEX MainThreadGate; |
669 | ACPI_MUTEX ThreadCompleteGate; |
1047 | ACPI_MUTEX ThreadCompleteGate; |
670 | ACPI_MUTEX InfoGate; |
1048 | ACPI_MUTEX InfoGate; |
671 | 1049 | ||
672 | 1050 | ||
673 | /* Get the arguments */ |
1051 | /* Get the arguments */ |
674 | 1052 | ||
675 | NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); |
1053 | NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); |
676 | NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); |
1054 | NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); |
677 | 1055 | ||
678 | if (!NumThreads || !NumLoops) |
1056 | if (!NumThreads || !NumLoops) |
679 | { |
1057 | { |
680 | AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", |
1058 | AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", |
681 | NumThreads, NumLoops); |
1059 | NumThreads, NumLoops); |
682 | return; |
1060 | return; |
683 | } |
1061 | } |
684 | 1062 | ||
685 | /* |
1063 | /* |
686 | * Create the semaphore for synchronization of |
1064 | * Create the semaphore for synchronization of |
687 | * the created threads with the main thread. |
1065 | * the created threads with the main thread. |
688 | */ |
1066 | */ |
689 | Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); |
1067 | Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); |
690 | if (ACPI_FAILURE (Status)) |
1068 | if (ACPI_FAILURE (Status)) |
691 | { |
1069 | { |
692 | AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", |
1070 | AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", |
693 | AcpiFormatException (Status)); |
1071 | AcpiFormatException (Status)); |
694 | return; |
1072 | return; |
695 | } |
1073 | } |
696 | 1074 | ||
697 | /* |
1075 | /* |
698 | * Create the semaphore for synchronization |
1076 | * Create the semaphore for synchronization |
699 | * between the created threads. |
1077 | * between the created threads. |
700 | */ |
1078 | */ |
701 | Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); |
1079 | Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); |
702 | if (ACPI_FAILURE (Status)) |
1080 | if (ACPI_FAILURE (Status)) |
703 | { |
1081 | { |
704 | AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", |
1082 | AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", |
705 | AcpiFormatException (Status)); |
1083 | AcpiFormatException (Status)); |
706 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
1084 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
707 | return; |
1085 | return; |
708 | } |
1086 | } |
709 | 1087 | ||
710 | Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); |
1088 | Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); |
711 | if (ACPI_FAILURE (Status)) |
1089 | if (ACPI_FAILURE (Status)) |
712 | { |
1090 | { |
713 | AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", |
1091 | AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", |
714 | AcpiFormatException (Status)); |
1092 | AcpiFormatException (Status)); |
715 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
1093 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
716 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
1094 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
717 | return; |
1095 | return; |
718 | } |
1096 | } |
719 | 1097 | ||
720 | ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
1098 | ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
721 | 1099 | ||
722 | /* Array to store IDs of threads */ |
1100 | /* Array to store IDs of threads */ |
723 | 1101 | ||
724 | AcpiGbl_DbMethodInfo.NumThreads = NumThreads; |
1102 | AcpiGbl_DbMethodInfo.NumThreads = NumThreads; |
725 | Size = 4 * AcpiGbl_DbMethodInfo.NumThreads; |
1103 | Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads; |
726 | AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size); |
1104 | AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size); |
727 | if (AcpiGbl_DbMethodInfo.Threads == NULL) |
1105 | if (AcpiGbl_DbMethodInfo.Threads == NULL) |
728 | { |
1106 | { |
729 | AcpiOsPrintf ("No memory for thread IDs array\n"); |
1107 | AcpiOsPrintf ("No memory for thread IDs array\n"); |
730 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
1108 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
731 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
1109 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
732 | (void) AcpiOsDeleteSemaphore (InfoGate); |
1110 | (void) AcpiOsDeleteSemaphore (InfoGate); |
733 | return; |
1111 | return; |
734 | } |
1112 | } |
735 | ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); |
1113 | ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); |
736 | 1114 | ||
737 | /* Setup the context to be passed to each thread */ |
1115 | /* Setup the context to be passed to each thread */ |
738 | 1116 | ||
739 | AcpiGbl_DbMethodInfo.Name = MethodNameArg; |
1117 | AcpiGbl_DbMethodInfo.Name = MethodNameArg; |
740 | AcpiGbl_DbMethodInfo.Flags = 0; |
1118 | AcpiGbl_DbMethodInfo.Flags = 0; |
741 | AcpiGbl_DbMethodInfo.NumLoops = NumLoops; |
1119 | AcpiGbl_DbMethodInfo.NumLoops = NumLoops; |
742 | AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate; |
1120 | AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate; |
743 | AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate; |
1121 | AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate; |
744 | AcpiGbl_DbMethodInfo.InfoGate = InfoGate; |
1122 | AcpiGbl_DbMethodInfo.InfoGate = InfoGate; |
745 | 1123 | ||
746 | /* Init arguments to be passed to method */ |
1124 | /* Init arguments to be passed to method */ |
747 | 1125 | ||
748 | AcpiGbl_DbMethodInfo.InitArgs = 1; |
1126 | AcpiGbl_DbMethodInfo.InitArgs = 1; |
749 | AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments; |
1127 | AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments; |
750 | AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr; |
1128 | AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr; |
751 | AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr; |
1129 | AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr; |
752 | AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr; |
1130 | AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr; |
753 | AcpiGbl_DbMethodInfo.Arguments[3] = NULL; |
1131 | AcpiGbl_DbMethodInfo.Arguments[3] = NULL; |
- | 1132 | ||
- | 1133 | AcpiGbl_DbMethodInfo.Types = AcpiGbl_DbMethodInfo.ArgTypes; |
|
- | 1134 | AcpiGbl_DbMethodInfo.ArgTypes[0] = ACPI_TYPE_INTEGER; |
|
- | 1135 | AcpiGbl_DbMethodInfo.ArgTypes[1] = ACPI_TYPE_INTEGER; |
|
- | 1136 | AcpiGbl_DbMethodInfo.ArgTypes[2] = ACPI_TYPE_INTEGER; |
|
- | 1137 | ||
754 | AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); |
1138 | AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); |
755 | 1139 | ||
756 | AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
1140 | AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
757 | 1141 | ||
758 | /* Create the threads */ |
1142 | /* Create the threads */ |
759 | 1143 | ||
760 | AcpiOsPrintf ("Creating %X threads to execute %X times each\n", |
1144 | AcpiOsPrintf ("Creating %X threads to execute %X times each\n", |
761 | NumThreads, NumLoops); |
1145 | NumThreads, NumLoops); |
762 | 1146 | ||
763 | for (i = 0; i < (NumThreads); i++) |
1147 | for (i = 0; i < (NumThreads); i++) |
764 | { |
1148 | { |
765 | Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, |
1149 | Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, |
766 | &AcpiGbl_DbMethodInfo); |
1150 | &AcpiGbl_DbMethodInfo); |
767 | if (ACPI_FAILURE (Status)) |
1151 | if (ACPI_FAILURE (Status)) |
768 | { |
1152 | { |
769 | break; |
1153 | break; |
770 | } |
1154 | } |
771 | } |
1155 | } |
772 | 1156 | ||
773 | /* Wait for all threads to complete */ |
1157 | /* Wait for all threads to complete */ |
774 | 1158 | ||
775 | (void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER); |
1159 | (void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER); |
776 | 1160 | ||
777 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
1161 | AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
778 | AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); |
1162 | AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); |
779 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
1163 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
780 | 1164 | ||
781 | /* Cleanup and exit */ |
1165 | /* Cleanup and exit */ |
782 | 1166 | ||
783 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
1167 | (void) AcpiOsDeleteSemaphore (MainThreadGate); |
784 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
1168 | (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
785 | (void) AcpiOsDeleteSemaphore (InfoGate); |
1169 | (void) AcpiOsDeleteSemaphore (InfoGate); |
786 | 1170 | ||
787 | AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); |
1171 | AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); |
788 | AcpiGbl_DbMethodInfo.Threads = NULL; |
1172 | AcpiGbl_DbMethodInfo.Threads = NULL; |
789 | } |
1173 | } |
790 | 1174 | ||
791 | #endif /* ACPI_DEBUGGER */>>>>> |
1175 | #endif /* ACPI_DEBUGGER */>>>>>>>>>><>=> |