ReactOS  0.4.14-dev-342-gdc047f9
exoparg3.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "acparser.h"
#include "amlcode.h"
Include dependency graph for exoparg3.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

ACPI_STATUS AcpiExOpcode_3A_0T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_3A_1T_1R (ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 51 of file exoparg3.c.

Function Documentation

◆ AcpiExOpcode_3A_0T_0R()

ACPI_STATUS AcpiExOpcode_3A_0T_0R ( ACPI_WALK_STATE WalkState)

Naming convention for AML interpreter execution routines.

The routines that begin execution of AML opcodes are named with a common convention based upon the number of arguments, the number of target operands, and whether or not a value is returned:

 AcpiExOpcode_xA_yT_zR

Where:

xA - ARGUMENTS: The number of arguments (input operands) that are required for this opcode type (1 through 6 args). yT - TARGETS: The number of targets (output operands) that are required for this opcode type (0, 1, or 2 targets). zR - RETURN VALUE: Indicates whether this opcode type returns a value as the function return (0 or 1).

The AcpiExOpcode* functions are called via the Dispatcher component with fully resolved operands. !

Definition at line 91 of file exoparg3.c.

93 {
94  ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
97 
98 
99  ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
100  AcpiPsGetOpcodeName (WalkState->Opcode));
101 
102 
103  switch (WalkState->Opcode)
104  {
105  case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */
106 
108  "FatalOp: Type %X Code %X Arg %X "
109  "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
110  (UINT32) Operand[0]->Integer.Value,
111  (UINT32) Operand[1]->Integer.Value,
112  (UINT32) Operand[2]->Integer.Value));
113 
115  if (Fatal)
116  {
117  Fatal->Type = (UINT32) Operand[0]->Integer.Value;
118  Fatal->Code = (UINT32) Operand[1]->Integer.Value;
119  Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
120  }
121 
122  /* Always signal the OS! */
123 
125 
126  /* Might return while OS is shutting down, just continue */
127 
128  ACPI_FREE (Fatal);
129  goto Cleanup;
130 
131  case AML_EXTERNAL_OP:
132  /*
133  * If the interpreter sees this opcode, just ignore it. The External
134  * op is intended for use by disassemblers in order to properly
135  * disassemble control method invocations. The opcode or group of
136  * opcodes should be surrounded by an "if (0)" clause to ensure that
137  * AML interpreters never see the opcode. Thus, something is
138  * wrong if an external opcode ever gets here.
139  */
140  ACPI_ERROR ((AE_INFO, "Executed External Op"));
141  Status = AE_OK;
142  goto Cleanup;
143 
144  default:
145 
146  ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
147  WalkState->Opcode));
148 
150  goto Cleanup;
151  }
152 
153 
154 Cleanup:
155 
157 }
#define ACPI_FREE(a)
Definition: actypes.h:386
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
ACPI_STATUS AcpiOsSignal(UINT32 Function, void *Info)
Definition: osl.c:904
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
void Fatal(const char *filename, unsigned nLine, const char *pcLine, const char *pc, size_t errorlen, const char *format,...)
Definition: spec2def.c:811
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:517
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AML_FATAL_OP
Definition: amlcode.h:178
#define ACPI_FUNCTION_TRACE_STR(a, b)
Definition: acoutput.h:483
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
UINT16 Opcode
Definition: acstruct.h:78
#define AE_OK
Definition: acexcep.h:97
#define ACPI_SIGNAL_FATAL
Definition: acpiosxf.h:73

◆ AcpiExOpcode_3A_1T_1R()

ACPI_STATUS AcpiExOpcode_3A_1T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 173 of file exoparg3.c.

175 {
176  ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
177  ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
178  char *Buffer = NULL;
180  UINT64 Index;
181  ACPI_SIZE Length;
182 
183 
184  ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
185  AcpiPsGetOpcodeName (WalkState->Opcode));
186 
187 
188  switch (WalkState->Opcode)
189  {
190  case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
191  /*
192  * Create the return object. The Source operand is guaranteed to be
193  * either a String or a Buffer, so just use its type.
194  */
195  ReturnDesc = AcpiUtCreateInternalObject (
196  (Operand[0])->Common.Type);
197  if (!ReturnDesc)
198  {
200  goto Cleanup;
201  }
202 
203  /* Get the Integer values from the objects */
204 
205  Index = Operand[1]->Integer.Value;
206  Length = (ACPI_SIZE) Operand[2]->Integer.Value;
207 
208  /*
209  * If the index is beyond the length of the String/Buffer, or if the
210  * requested length is zero, return a zero-length String/Buffer
211  */
212  if (Index >= Operand[0]->String.Length)
213  {
214  Length = 0;
215  }
216 
217  /* Truncate request if larger than the actual String/Buffer */
218 
219  else if ((Index + Length) > Operand[0]->String.Length)
220  {
221  Length =
222  (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index;
223  }
224 
225  /* Strings always have a sub-pointer, not so for buffers */
226 
227  switch ((Operand[0])->Common.Type)
228  {
229  case ACPI_TYPE_STRING:
230 
231  /* Always allocate a new buffer for the String */
232 
233  Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
234  if (!Buffer)
235  {
237  goto Cleanup;
238  }
239  break;
240 
241  case ACPI_TYPE_BUFFER:
242 
243  /* If the requested length is zero, don't allocate a buffer */
244 
245  if (Length > 0)
246  {
247  /* Allocate a new buffer for the Buffer */
248 
250  if (!Buffer)
251  {
253  goto Cleanup;
254  }
255  }
256  break;
257 
258  default: /* Should not happen */
259 
261  goto Cleanup;
262  }
263 
264  if (Buffer)
265  {
266  /* We have a buffer, copy the portion requested */
267 
268  memcpy (Buffer,
269  Operand[0]->String.Pointer + Index, Length);
270  }
271 
272  /* Set the length of the new String/Buffer */
273 
274  ReturnDesc->String.Pointer = Buffer;
275  ReturnDesc->String.Length = (UINT32) Length;
276 
277  /* Mark buffer initialized */
278 
279  ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
280  break;
281 
282  default:
283 
284  ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
285  WalkState->Opcode));
286 
288  goto Cleanup;
289  }
290 
291  /* Store the result in the target */
292 
293  Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
294 
295 Cleanup:
296 
297  /* Delete return object on error */
298 
299  if (ACPI_FAILURE (Status) || WalkState->ResultObj)
300  {
301  AcpiUtRemoveReference (ReturnDesc);
302  WalkState->ResultObj = NULL;
303  }
304  else
305  {
306  /* Set the return object and exit */
307 
308  WalkState->ResultObj = ReturnDesc;
309  }
310 
312 }
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
ACPI_STATUS AcpiExStore(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState)
Definition: exstore.c:91
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AML_MID_OP
Definition: amlcode.h:132
#define ACPI_TYPE_BUFFER
Definition: actypes.h:681
static WCHAR String[]
Definition: stringtable.c:55
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
Definition: bufpool.h:45
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:519
union acpi_operand_object * ResultObj
Definition: acstruct.h:121
if(!(yy_init))
Definition: macro.lex.yy.c:714
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:517
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR Cleanup[]
Definition: register.c:80
ACPI_OBJECT_STRING String
Definition: acobject.h:518
Status
Definition: gdiplustypes.h:24
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE_STR(a, b)
Definition: acoutput.h:483
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
UINT16 Opcode
Definition: acstruct.h:78
#define ACPI_TYPE_STRING
Definition: actypes.h:680
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
unsigned long long UINT64
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define AE_OK
Definition: acexcep.h:97