1 /******************************************************************************
2 *
3 * Module Name: pstree - Parser op tree manipulation/traversal/search
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
68 * PARAMETERS: Op - Get an argument for this op
69 * Argn - Nth argument to get
70 *
71 * RETURN: The argument (as an Op object). NULL if argument does not exist
72 *
73 * DESCRIPTION: Get the specified op's argument.
74 *
75 ******************************************************************************/
76
77 ACPI_PARSE_OBJECT *
78 AcpiPsGetArg (
79 ACPI_PARSE_OBJECT *Op,
80 UINT32 Argn)
81 {
82 ACPI_PARSE_OBJECT *Arg = NULL;
83 const ACPI_OPCODE_INFO *OpInfo;
84
85
86 ACPI_FUNCTION_ENTRY ();
87
88
89 /* Get the info structure for this opcode */
90
91 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
92 if (OpInfo->Class == AML_CLASS_UNKNOWN)
93 {
94 /* Invalid opcode or ASCII character */
95
96 return (NULL);
97 }
98
99 /* Check if this opcode requires argument sub-objects */
100
101 if (!(OpInfo->Flags & AML_HAS_ARGS))
102 {
103 /* Has no linked argument objects */
104
105 return (NULL);
106 }
107
108 /* Get the requested argument object */
300 AcpiPsGetChild (
301 ACPI_PARSE_OBJECT *Op)
302 {
303 ACPI_PARSE_OBJECT *Child = NULL;
304
305
306 ACPI_FUNCTION_ENTRY ();
307
308
309 switch (Op->Common.AmlOpcode)
310 {
311 case AML_SCOPE_OP:
312 case AML_ELSE_OP:
313 case AML_DEVICE_OP:
314 case AML_THERMAL_ZONE_OP:
315 case AML_INT_METHODCALL_OP:
316
317 Child = AcpiPsGetArg (Op, 0);
318 break;
319
320
321 case AML_BUFFER_OP:
322 case AML_PACKAGE_OP:
323 case AML_METHOD_OP:
324 case AML_IF_OP:
325 case AML_WHILE_OP:
326 case AML_FIELD_OP:
327
328 Child = AcpiPsGetArg (Op, 1);
329 break;
330
331
332 case AML_POWER_RES_OP:
333 case AML_INDEX_FIELD_OP:
334
335 Child = AcpiPsGetArg (Op, 2);
336 break;
337
338
339 case AML_PROCESSOR_OP:
340 case AML_BANK_FIELD_OP:
341
342 Child = AcpiPsGetArg (Op, 3);
343 break;
344
345
346 default:
347 /* All others have no children */
348 break;
349 }
350
351 return (Child);
352 }
353 #endif
354
355
|
1 /******************************************************************************
2 *
3 * Module Name: pstree - Parser op tree manipulation/traversal/search
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
68 * PARAMETERS: Op - Get an argument for this op
69 * Argn - Nth argument to get
70 *
71 * RETURN: The argument (as an Op object). NULL if argument does not exist
72 *
73 * DESCRIPTION: Get the specified op's argument.
74 *
75 ******************************************************************************/
76
77 ACPI_PARSE_OBJECT *
78 AcpiPsGetArg (
79 ACPI_PARSE_OBJECT *Op,
80 UINT32 Argn)
81 {
82 ACPI_PARSE_OBJECT *Arg = NULL;
83 const ACPI_OPCODE_INFO *OpInfo;
84
85
86 ACPI_FUNCTION_ENTRY ();
87
88 /*
89 if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
90 {
91 return (Op->Common.Value.Arg);
92 }
93 */
94 /* Get the info structure for this opcode */
95
96 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
97 if (OpInfo->Class == AML_CLASS_UNKNOWN)
98 {
99 /* Invalid opcode or ASCII character */
100
101 return (NULL);
102 }
103
104 /* Check if this opcode requires argument sub-objects */
105
106 if (!(OpInfo->Flags & AML_HAS_ARGS))
107 {
108 /* Has no linked argument objects */
109
110 return (NULL);
111 }
112
113 /* Get the requested argument object */
305 AcpiPsGetChild (
306 ACPI_PARSE_OBJECT *Op)
307 {
308 ACPI_PARSE_OBJECT *Child = NULL;
309
310
311 ACPI_FUNCTION_ENTRY ();
312
313
314 switch (Op->Common.AmlOpcode)
315 {
316 case AML_SCOPE_OP:
317 case AML_ELSE_OP:
318 case AML_DEVICE_OP:
319 case AML_THERMAL_ZONE_OP:
320 case AML_INT_METHODCALL_OP:
321
322 Child = AcpiPsGetArg (Op, 0);
323 break;
324
325 case AML_BUFFER_OP:
326 case AML_PACKAGE_OP:
327 case AML_METHOD_OP:
328 case AML_IF_OP:
329 case AML_WHILE_OP:
330 case AML_FIELD_OP:
331
332 Child = AcpiPsGetArg (Op, 1);
333 break;
334
335 case AML_POWER_RES_OP:
336 case AML_INDEX_FIELD_OP:
337
338 Child = AcpiPsGetArg (Op, 2);
339 break;
340
341 case AML_PROCESSOR_OP:
342 case AML_BANK_FIELD_OP:
343
344 Child = AcpiPsGetArg (Op, 3);
345 break;
346
347 default:
348
349 /* All others have no children */
350
351 break;
352 }
353
354 return (Child);
355 }
356 #endif
|