Indentation fix, cleanup.
[AROS.git] / arch / all-pc / acpica / source / components / disassembler / dmutils.c
blob8c10eec8c93e3596d622a32fdc61e48c346d6031
1 /*******************************************************************************
3 * Module Name: dmutils - AML disassembler utilities
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
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.
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.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include "acpi.h"
46 #include "accommon.h"
47 #include "amlcode.h"
48 #include "acdisasm.h"
50 #ifdef ACPI_ASL_COMPILER
51 #include <acnamesp.h>
52 #endif
54 #ifdef ACPI_DISASSEMBLER
56 #define _COMPONENT ACPI_CA_DEBUGGER
57 ACPI_MODULE_NAME ("dmutils")
60 /* Data used in keeping track of fields */
61 #if 0
62 const char *AcpiGbl_FENames[] =
64 "skip",
65 "?access?"
66 }; /* FE = Field Element */
67 #endif
69 /* Operators for Match() */
71 const char *AcpiGbl_MatchOps[] =
73 "MTR",
74 "MEQ",
75 "MLE",
76 "MLT",
77 "MGE",
78 "MGT"
81 /* Access type decoding */
83 const char *AcpiGbl_AccessTypes[] =
85 "AnyAcc",
86 "ByteAcc",
87 "WordAcc",
88 "DWordAcc",
89 "QWordAcc",
90 "BufferAcc",
91 "InvalidAccType",
92 "InvalidAccType"
95 /* Lock rule decoding */
97 const char *AcpiGbl_LockRule[] =
99 "NoLock",
100 "Lock"
103 /* Update rule decoding */
105 const char *AcpiGbl_UpdateRules[] =
107 "Preserve",
108 "WriteAsOnes",
109 "WriteAsZeros",
110 "InvalidUpdateRule"
113 /* Strings used to decode resource descriptors */
115 const char *AcpiGbl_WordDecode[] =
117 "Memory",
118 "IO",
119 "BusNumber",
120 "UnknownResourceType"
123 const char *AcpiGbl_IrqDecode[] =
125 "IRQNoFlags",
126 "IRQ"
130 /*******************************************************************************
132 * FUNCTION: AcpiDmDecodeAttribute
134 * PARAMETERS: Attribute - Attribute field of AccessAs keyword
136 * RETURN: None
138 * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus and
139 * GenericSerialBus stuff.)
141 ******************************************************************************/
143 void
144 AcpiDmDecodeAttribute (
145 UINT8 Attribute)
148 switch (Attribute)
150 case AML_FIELD_ATTRIB_QUICK:
152 AcpiOsPrintf ("AttribQuick");
153 break;
155 case AML_FIELD_ATTRIB_SEND_RCV:
157 AcpiOsPrintf ("AttribSendReceive");
158 break;
160 case AML_FIELD_ATTRIB_BYTE:
162 AcpiOsPrintf ("AttribByte");
163 break;
165 case AML_FIELD_ATTRIB_WORD:
167 AcpiOsPrintf ("AttribWord");
168 break;
170 case AML_FIELD_ATTRIB_BLOCK:
172 AcpiOsPrintf ("AttribBlock");
173 break;
175 case AML_FIELD_ATTRIB_MULTIBYTE:
177 AcpiOsPrintf ("AttribBytes");
178 break;
180 case AML_FIELD_ATTRIB_WORD_CALL:
182 AcpiOsPrintf ("AttribProcessCall");
183 break;
185 case AML_FIELD_ATTRIB_BLOCK_CALL:
187 AcpiOsPrintf ("AttribBlockProcessCall");
188 break;
190 case AML_FIELD_ATTRIB_RAW_BYTES:
192 AcpiOsPrintf ("AttribRawBytes");
193 break;
195 case AML_FIELD_ATTRIB_RAW_PROCESS:
197 AcpiOsPrintf ("AttribRawProcessBytes");
198 break;
200 default:
202 /* A ByteConst is allowed by the grammar */
204 AcpiOsPrintf ("0x%2.2X", Attribute);
205 break;
210 /*******************************************************************************
212 * FUNCTION: AcpiDmIndent
214 * PARAMETERS: Level - Current source code indentation level
216 * RETURN: None
218 * DESCRIPTION: Indent 4 spaces per indentation level.
220 ******************************************************************************/
222 void
223 AcpiDmIndent (
224 UINT32 Level)
227 if (!Level)
229 return;
232 AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " ");
236 /*******************************************************************************
238 * FUNCTION: AcpiDmCommaIfListMember
240 * PARAMETERS: Op - Current operator/operand
242 * RETURN: TRUE if a comma was inserted
244 * DESCRIPTION: Insert a comma if this Op is a member of an argument list.
246 ******************************************************************************/
248 BOOLEAN
249 AcpiDmCommaIfListMember (
250 ACPI_PARSE_OBJECT *Op)
253 if (!Op->Common.Next)
255 return (FALSE);
258 if (AcpiDmListType (Op->Common.Parent) & BLOCK_COMMA_LIST)
260 /* Check for a NULL target operand */
262 if ((Op->Common.Next->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
263 (!Op->Common.Next->Common.Value.String))
266 * To handle the Divide() case where there are two optional
267 * targets, look ahead one more op. If null, this null target
268 * is the one and only target -- no comma needed. Otherwise,
269 * we need a comma to prepare for the next target.
271 if (!Op->Common.Next->Common.Next)
273 return (FALSE);
277 if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
278 (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)))
280 return (FALSE);
283 AcpiOsPrintf (", ");
284 return (TRUE);
287 else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
288 (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))
290 AcpiOsPrintf (", ");
291 return (TRUE);
294 return (FALSE);
298 /*******************************************************************************
300 * FUNCTION: AcpiDmCommaIfFieldMember
302 * PARAMETERS: Op - Current operator/operand
304 * RETURN: None
306 * DESCRIPTION: Insert a comma if this Op is a member of a Field argument list.
308 ******************************************************************************/
310 void
311 AcpiDmCommaIfFieldMember (
312 ACPI_PARSE_OBJECT *Op)
315 if (Op->Common.Next)
317 AcpiOsPrintf (", ");
321 #endif