ReactOS 0.4.15-dev-7131-ge4d03f4
exconvrt.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "amlcode.h"
Include dependency graph for exconvrt.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

static UINT32 AcpiExConvertToAscii (UINT64 Integer, UINT16 Base, UINT8 *String, UINT8 MaxLength)
 
ACPI_STATUS AcpiExConvertToInteger (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 ImplicitConversion)
 
ACPI_STATUS AcpiExConvertToBuffer (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
 
ACPI_STATUS AcpiExConvertToString (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Type)
 
ACPI_STATUS AcpiExConvertToTargetType (ACPI_OBJECT_TYPE DestinationType, ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 50 of file exconvrt.c.

Function Documentation

◆ AcpiExConvertToAscii()

static UINT32 AcpiExConvertToAscii ( UINT64  Integer,
UINT16  Base,
UINT8 String,
UINT8  MaxLength 
)
static

Definition at line 315 of file exconvrt.c.

320{
321 UINT64 Digit;
322 UINT32 i;
323 UINT32 j;
324 UINT32 k = 0;
325 UINT32 HexLength;
326 UINT32 DecimalLength;
328 BOOLEAN SupressZeros;
329
330
332
333
334 switch (Base)
335 {
336 case 10:
337
338 /* Setup max length for the decimal number */
339
340 switch (DataWidth)
341 {
342 case 1:
343
344 DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
345 break;
346
347 case 4:
348
349 DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
350 break;
351
352 case 8:
353 default:
354
355 DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
356 break;
357 }
358
359 SupressZeros = TRUE; /* No leading zeros */
360 Remainder = 0;
361
362 for (i = DecimalLength; i > 0; i--)
363 {
364 /* Divide by nth factor of 10 */
365
366 Digit = Integer;
367 for (j = 0; j < i; j++)
368 {
369 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
370 }
371
372 /* Handle leading zeros */
373
374 if (Remainder != 0)
375 {
376 SupressZeros = FALSE;
377 }
378
379 if (!SupressZeros)
380 {
382 k++;
383 }
384 }
385 break;
386
387 case 16:
388
389 /* HexLength: 2 ascii hex chars per data byte */
390
391 HexLength = (DataWidth * 2);
392 for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
393 {
394 /* Get one hex digit, most significant digits first */
395
396 String[k] = (UINT8)
397 AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
398 k++;
399 }
400 break;
401
402 default:
403 return (0);
404 }
405
406 /*
407 * Since leading zeros are suppressed, we must check for the case where
408 * the integer equals 0
409 *
410 * Finally, null terminate the string and return the length
411 */
412 if (!k)
413 {
415 k = 1;
416 }
417
418 String [k] = 0;
419 return ((UINT32) k);
420}
unsigned char BOOLEAN
unsigned long long UINT64
unsigned char UINT8
unsigned int UINT32
#define ACPI_ASCII_ZERO
Definition: aclocal.h:1356
#define ACPI_MUL_4(a)
Definition: acmacros.h:211
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_MAX8_DECIMAL_DIGITS
Definition: actypes.h:495
#define ACPI_MAX32_DECIMAL_DIGITS
Definition: actypes.h:493
#define ACPI_MAX64_DECIMAL_DIGITS
Definition: actypes.h:492
char AcpiUtHexToAsciiChar(UINT64 Integer, UINT32 Position)
Definition: uthex.c:74
ACPI_STATUS AcpiUtShortDivide(UINT64 InDividend, UINT32 Divisor, UINT64 *OutQuotient, UINT32 *OutRemainder)
Definition: utmath.c:337
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3045

Referenced by AcpiExConvertToString().

◆ AcpiExConvertToBuffer()

ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc 
)

Definition at line 224 of file exconvrt.c.

227{
228 ACPI_OPERAND_OBJECT *ReturnDesc;
229 UINT8 *NewBuf;
230
231
232 ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
233
234
235 switch (ObjDesc->Common.Type)
236 {
237 case ACPI_TYPE_BUFFER:
238
239 /* No conversion necessary */
240
241 *ResultDesc = ObjDesc;
243
244
246 /*
247 * Create a new Buffer object.
248 * Need enough space for one integer
249 */
250 ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
251 if (!ReturnDesc)
252 {
254 }
255
256 /* Copy the integer to the buffer, LSB first */
257
258 NewBuf = ReturnDesc->Buffer.Pointer;
259 memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
260 break;
261
262 case ACPI_TYPE_STRING:
263 /*
264 * Create a new Buffer object
265 * Size will be the string length
266 *
267 * NOTE: Add one to the string length to include the null terminator.
268 * The ACPI spec is unclear on this subject, but there is existing
269 * ASL/AML code that depends on the null being transferred to the new
270 * buffer.
271 */
272 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
273 ObjDesc->String.Length + 1);
274 if (!ReturnDesc)
275 {
277 }
278
279 /* Copy the string to the buffer */
280
281 NewBuf = ReturnDesc->Buffer.Pointer;
282 strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
283 ObjDesc->String.Length);
284 break;
285
286 default:
287
289 }
290
291 /* Mark buffer initialized */
292
293 ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
294 *ResultDesc = ReturnDesc;
296}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_TYPE
Definition: acexcep.h:116
#define AE_OK
Definition: acexcep.h:97
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject(ACPI_SIZE BufferSize)
Definition: utobject.c:258
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_STRING String
Definition: acobject.h:521
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522

Referenced by AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), AcpiExResolveOperands(), and AcpiNsConvertToBuffer().

◆ AcpiExConvertToInteger()

ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
UINT32  ImplicitConversion 
)

Definition at line 79 of file exconvrt.c.

83{
84 ACPI_OPERAND_OBJECT *ReturnDesc;
85 UINT8 *Pointer;
87 UINT32 i;
89
90
91 ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
92
93
94 switch (ObjDesc->Common.Type)
95 {
97
98 /* No conversion necessary */
99
100 *ResultDesc = ObjDesc;
102
103 case ACPI_TYPE_BUFFER:
104 case ACPI_TYPE_STRING:
105
106 /* Note: Takes advantage of common buffer/string fields */
107
108 Pointer = ObjDesc->Buffer.Pointer;
109 Count = ObjDesc->Buffer.Length;
110 break;
111
112 default:
113
115 }
116
117 /*
118 * Convert the buffer/string to an integer. Note that both buffers and
119 * strings are treated as raw data - we don't convert ascii to hex for
120 * strings.
121 *
122 * There are two terminating conditions for the loop:
123 * 1) The size of an integer has been reached, or
124 * 2) The end of the buffer or string has been reached
125 */
126 Result = 0;
127
128 /* String conversion is different than Buffer conversion */
129
130 switch (ObjDesc->Common.Type)
131 {
132 case ACPI_TYPE_STRING:
133 /*
134 * Convert string to an integer - for most cases, the string must be
135 * hexadecimal as per the ACPI specification. The only exception (as
136 * of ACPI 3.0) is that the ToInteger() operator allows both decimal
137 * and hexadecimal strings (hex prefixed with "0x").
138 *
139 * Explicit conversion is used only by ToInteger.
140 * All other string-to-integer conversions are implicit conversions.
141 */
142 if (ImplicitConversion)
143 {
144 Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
145 }
146 else
147 {
148 Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
149 }
150 break;
151
152 case ACPI_TYPE_BUFFER:
153
154 /* Check for zero-length buffer */
155
156 if (!Count)
157 {
159 }
160
161 /* Transfer no more than an integer's worth of data */
162
163 if (Count > AcpiGbl_IntegerByteWidth)
164 {
165 Count = AcpiGbl_IntegerByteWidth;
166 }
167
168 /*
169 * Convert buffer to an integer - we simply grab enough raw data
170 * from the buffer to fill an integer
171 */
172 for (i = 0; i < Count; i++)
173 {
174 /*
175 * Get next byte and shift it into the Result.
176 * Little endian is used, meaning that the first byte of the buffer
177 * is the LSB of the integer
178 */
179 Result |= (((UINT64) Pointer[i]) << (i * 8));
180 }
181 break;
182
183 default:
184
185 /* No other types can get here */
186
187 break;
188 }
189
190 /* Create a new integer */
191
192 ReturnDesc = AcpiUtCreateIntegerObject (Result);
193 if (!ReturnDesc)
194 {
196 }
197
198 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
200
201 /* Save the Result */
202
203 (void) AcpiExTruncateFor32bitTable (ReturnDesc);
204 *ResultDesc = ReturnDesc;
206}
#define AE_AML_BUFFER_LIMIT
Definition: acexcep.h:189
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
UINT64 AcpiUtExplicitStrtoul64(char *String)
Definition: utstrtoul64.c:347
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
UINT64 AcpiUtImplicitStrtoul64(char *String)
Definition: utstrtoul64.c:259
BOOLEAN AcpiExTruncateFor32bitTable(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exutils.c:177
int Count
Definition: noreturn.cpp:7
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by AcpiDsGetPredicateValue(), AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), and AcpiExResolveOperands().

◆ AcpiExConvertToString()

ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
UINT32  Type 
)

Definition at line 440 of file exconvrt.c.

444{
445 ACPI_OPERAND_OBJECT *ReturnDesc;
446 UINT8 *NewBuf;
447 UINT32 i;
448 UINT32 StringLength = 0;
449 UINT16 Base = 16;
450 UINT8 Separator = ',';
451
452
453 ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
454
455
456 switch (ObjDesc->Common.Type)
457 {
458 case ACPI_TYPE_STRING:
459
460 /* No conversion necessary */
461
462 *ResultDesc = ObjDesc;
464
466
467 switch (Type)
468 {
470 /*
471 * From ToDecimalString, integer source.
472 *
473 * Make room for the maximum decimal number size
474 */
475 StringLength = ACPI_MAX_DECIMAL_DIGITS;
476 Base = 10;
477 break;
478
479 default:
480
481 /* Two hex string characters for each integer byte */
482
483 StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
484 break;
485 }
486
487 /*
488 * Create a new String
489 * Need enough space for one ASCII integer (plus null terminator)
490 */
491 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
492 if (!ReturnDesc)
493 {
495 }
496
497 NewBuf = ReturnDesc->Buffer.Pointer;
498
499 /* Convert integer to string */
500
501 StringLength = AcpiExConvertToAscii (
502 ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth);
503
504 /* Null terminate at the correct place */
505
506 ReturnDesc->String.Length = StringLength;
507 NewBuf [StringLength] = 0;
508 break;
509
510 case ACPI_TYPE_BUFFER:
511
512 /* Setup string length, base, and separator */
513
514 switch (Type)
515 {
516 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
517 /*
518 * Explicit conversion from the ToDecimalString ASL operator.
519 *
520 * From ACPI: "If the input is a buffer, it is converted to a
521 * a string of decimal values separated by commas."
522 */
523 Base = 10;
524
525 /*
526 * Calculate the final string length. Individual string values
527 * are variable length (include separator for each)
528 */
529 for (i = 0; i < ObjDesc->Buffer.Length; i++)
530 {
531 if (ObjDesc->Buffer.Pointer[i] >= 100)
532 {
533 StringLength += 4;
534 }
535 else if (ObjDesc->Buffer.Pointer[i] >= 10)
536 {
537 StringLength += 3;
538 }
539 else
540 {
541 StringLength += 2;
542 }
543 }
544 break;
545
547 /*
548 * Implicit buffer-to-string conversion
549 *
550 * From the ACPI spec:
551 * "The entire contents of the buffer are converted to a string of
552 * two-character hexadecimal numbers, each separated by a space."
553 *
554 * Each hex number is prefixed with 0x (11/2018)
555 */
556 Separator = ' ';
557 StringLength = (ObjDesc->Buffer.Length * 5);
558 break;
559
561 /*
562 * Explicit conversion from the ToHexString ASL operator.
563 *
564 * From ACPI: "If Data is a buffer, it is converted to a string of
565 * hexadecimal values separated by commas."
566 *
567 * Each hex number is prefixed with 0x (11/2018)
568 */
569 Separator = ',';
570 StringLength = (ObjDesc->Buffer.Length * 5);
571 break;
572
573 default:
575 }
576
577 /*
578 * Create a new string object and string buffer
579 * (-1 because of extra separator included in StringLength from above)
580 * Allow creation of zero-length strings from zero-length buffers.
581 */
582 if (StringLength)
583 {
584 StringLength--;
585 }
586
587 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
588 if (!ReturnDesc)
589 {
591 }
592
593 NewBuf = ReturnDesc->Buffer.Pointer;
594
595 /*
596 * Convert buffer bytes to hex or decimal values
597 * (separated by commas or spaces)
598 */
599 for (i = 0; i < ObjDesc->Buffer.Length; i++)
600 {
601 if (Base == 16)
602 {
603 /* Emit 0x prefix for explicit/implicit hex conversion */
604
605 *NewBuf++ = '0';
606 *NewBuf++ = 'x';
607 }
608
609 NewBuf += AcpiExConvertToAscii (
610 (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1);
611
612 /* Each digit is separated by either a comma or space */
613
614 *NewBuf++ = Separator;
615 }
616
617 /*
618 * Null terminate the string
619 * (overwrites final comma/space from above)
620 */
621 if (ObjDesc->Buffer.Length)
622 {
623 NewBuf--;
624 }
625 *NewBuf = 0;
626 break;
627
628 default:
629
631 }
632
633 *ResultDesc = ReturnDesc;
635}
unsigned short UINT16
Type
Definition: Type.h:7
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_EXPLICIT_CONVERT_DECIMAL
Definition: acinterp.h:127
#define ACPI_EXPLICIT_CONVERT_HEX
Definition: acinterp.h:125
#define ACPI_IMPLICIT_CONVERT_HEX
Definition: acinterp.h:126
#define ACPI_MUL_2(a)
Definition: acmacros.h:207
#define ACPI_MAX_DECIMAL_DIGITS
Definition: actypes.h:491
ACPI_OPERAND_OBJECT * AcpiUtCreateStringObject(ACPI_SIZE StringSize)
Definition: utobject.c:320
static UINT32 AcpiExConvertToAscii(UINT64 Integer, UINT16 Base, UINT8 *String, UINT8 MaxLength)
Definition: exconvrt.c:315

Referenced by AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), AcpiExResolveOperands(), and AcpiNsConvertToString().

◆ AcpiExConvertToTargetType()

ACPI_STATUS AcpiExConvertToTargetType ( ACPI_OBJECT_TYPE  DestinationType,
ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 654 of file exconvrt.c.

659{
661
662
663 ACPI_FUNCTION_TRACE (ExConvertToTargetType);
664
665
666 /* Default behavior */
667
668 *ResultDesc = SourceDesc;
669
670 /*
671 * If required by the target,
672 * perform implicit conversion on the source before we store it.
673 */
674 switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
675 {
678 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
679
680 switch (DestinationType)
681 {
683 /*
684 * Named field can always handle conversions
685 */
686 break;
687
688 default:
689
690 /* No conversion allowed for these types */
691
692 if (DestinationType != SourceDesc->Common.Type)
693 {
695 "Explicit operator, will store (%s) over existing type (%s)\n",
696 AcpiUtGetObjectTypeName (SourceDesc),
697 AcpiUtGetTypeName (DestinationType)));
698 Status = AE_TYPE;
699 }
700 }
701 break;
702
703 case ARGI_TARGETREF:
705
706 switch (DestinationType)
707 {
712 /*
713 * These types require an Integer operand. We can convert
714 * a Buffer or a String to an Integer if necessary.
715 */
716 Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
718 break;
719
720 case ACPI_TYPE_STRING:
721 /*
722 * The operand must be a String. We can convert an
723 * Integer or Buffer if necessary
724 */
725 Status = AcpiExConvertToString (SourceDesc, ResultDesc,
727 break;
728
729 case ACPI_TYPE_BUFFER:
730 /*
731 * The operand must be a Buffer. We can convert an
732 * Integer or String if necessary
733 */
734 Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
735 break;
736
737 default:
738
740 "Bad destination type during conversion: 0x%X",
741 DestinationType));
743 break;
744 }
745 break;
746
747 case ARGI_REFERENCE:
748 /*
749 * CreateXxxxField cases - we are storing the field object into the name
750 */
751 break;
752
753 default:
754
756 "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
758 WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
760 }
761
762 /*
763 * Source-to-Target conversion semantics:
764 *
765 * If conversion to the target type cannot be performed, then simply
766 * overwrite the target with the new object and type.
767 */
768 if (Status == AE_TYPE)
769 {
770 Status = AE_OK;
771 }
772
774}
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define GET_CURRENT_ARG_TYPE(List)
Definition: acmacros.h:450
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:701
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:717
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:716
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_LOCAL_INDEX_FIELD
Definition: actypes.h:718
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264
#define ACPI_IMPLICIT_CONVERSION
Definition: acutils.h:145
#define ARGI_REFERENCE
Definition: amlcode.h:279
#define ARGI_INTEGER_REF
Definition: amlcode.h:276
#define ARGI_FIXED_TARGET
Definition: amlcode.h:281
#define ARGI_TARGETREF
Definition: amlcode.h:280
#define ARGI_STORE_TARGET
Definition: amlcode.h:283
#define ARGI_SIMPLE_TARGET
Definition: amlcode.h:282
ACPI_STATUS AcpiExConvertToBuffer(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
Definition: exconvrt.c:224
ACPI_STATUS AcpiExConvertToInteger(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 ImplicitConversion)
Definition: exconvrt.c:79
ACPI_STATUS AcpiExConvertToString(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Type)
Definition: exconvrt.c:440
Status
Definition: gdiplustypes.h:25
UINT32 RuntimeArgs
Definition: aclocal.h:872
UINT16 Opcode
Definition: acstruct.h:78
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119

Referenced by AcpiExStoreObjectToObject().