1/****************************************************************************** 2 * 3 * Module Name: exconvrt - Object conversion routines
|
4 * $Revision: 32 $
|
4 * $Revision: 37 $ |
5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118#define __EXCONVRT_C__ 119 120#include "acpi.h"
|
121#include "acparser.h"
122#include "acnamesp.h"
|
121#include "acinterp.h"
|
124#include "acevents.h"
|
122#include "amlcode.h"
|
126#include "acdispat.h"
|
123 124 125#define _COMPONENT ACPI_EXECUTER 126 ACPI_MODULE_NAME ("exconvrt") 127 128 129/******************************************************************************* 130 * 131 * FUNCTION: AcpiExConvertToInteger 132 * 133 * PARAMETERS: *ObjDesc - Object to be converted. Must be an 134 * Integer, Buffer, or String 135 * WalkState - Current method state 136 * 137 * RETURN: Status 138 * 139 * DESCRIPTION: Convert an ACPI Object to an integer. 140 * 141 ******************************************************************************/ 142 143ACPI_STATUS 144AcpiExConvertToInteger ( 145 ACPI_OPERAND_OBJECT *ObjDesc, 146 ACPI_OPERAND_OBJECT **ResultDesc, 147 ACPI_WALK_STATE *WalkState) 148{ 149 UINT32 i; 150 ACPI_OPERAND_OBJECT *RetDesc; 151 UINT32 Count;
|
156 char *Pointer;
|
152 UINT8 *Pointer; |
153 ACPI_INTEGER Result;
|
158 UINT32 IntegerSize = sizeof (ACPI_INTEGER);
|
154 ACPI_STATUS Status; |
155 156 157 ACPI_FUNCTION_TRACE_PTR ("ExConvertToInteger", ObjDesc); 158 159
|
164 switch (ObjDesc->Common.Type)
|
160 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) |
161 { 162 case ACPI_TYPE_INTEGER: 163 *ResultDesc = ObjDesc; 164 return_ACPI_STATUS (AE_OK); 165 166 case ACPI_TYPE_STRING:
|
171 Pointer = ObjDesc->String.Pointer;
|
167 Pointer = (UINT8 *) ObjDesc->String.Pointer; |
168 Count = ObjDesc->String.Length; 169 break; 170 171 case ACPI_TYPE_BUFFER:
|
176 Pointer = (char *) ObjDesc->Buffer.Pointer;
|
172 Pointer = ObjDesc->Buffer.Pointer; |
173 Count = ObjDesc->Buffer.Length; 174 break; 175 176 default: 177 return_ACPI_STATUS (AE_TYPE); 178 } 179 180 /*
|
185 * Create a new integer
186 */
187 RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
188 if (!RetDesc)
189 {
190 return_ACPI_STATUS (AE_NO_MEMORY);
191 }
192
193 /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
194
195 if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
196 {
197 /*
198 * We are running a method that exists in a 32-bit ACPI table.
199 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
200 */
201 IntegerSize = sizeof (UINT32);
202 }
203
204 /*
|
181 * Convert the buffer/string to an integer. Note that both buffers and 182 * strings are treated as raw data - we don't convert ascii to hex for 183 * strings. 184 * 185 * There are two terminating conditions for the loop: 186 * 1) The size of an integer has been reached, or 187 * 2) The end of the buffer or string has been reached 188 */ 189 Result = 0; 190 191 /* Transfer no more than an integer's worth of data */ 192
|
217 if (Count > IntegerSize)
|
193 if (Count > AcpiGbl_IntegerByteWidth) |
194 {
|
219 Count = IntegerSize;
|
195 Count = AcpiGbl_IntegerByteWidth; |
196 } 197 198 /* 199 * String conversion is different than Buffer conversion 200 */
|
225 switch (ObjDesc->Common.Type)
|
201 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) |
202 { 203 case ACPI_TYPE_STRING: 204
|
229 /* TBD: Need to use 64-bit ACPI_STRTOUL */
230
|
205 /* 206 * Convert string to an integer 207 * String must be hexadecimal as per the ACPI specification 208 */
|
235 Result = ACPI_STRTOUL (Pointer, NULL, 16);
|
209 Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result); 210 if (ACPI_FAILURE (Status)) 211 { 212 return_ACPI_STATUS (Status); 213 } |
214 break; 215 216 217 case ACPI_TYPE_BUFFER: 218 219 /* 220 * Buffer conversion - we simply grab enough raw data from the 221 * buffer to fill an integer 222 */ 223 for (i = 0; i < Count; i++) 224 { 225 /* 226 * Get next byte and shift it into the Result. 227 * Little endian is used, meaning that the first byte of the buffer 228 * is the LSB of the integer 229 */ 230 Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); 231 } 232 break;
|
233 234 235 default: 236 /* No other types can get here */ 237 break; |
238 } 239
|
240 /* 241 * Create a new integer 242 */ 243 RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 244 if (!RetDesc) 245 { 246 return_ACPI_STATUS (AE_NO_MEMORY); 247 } 248 |
249 /* Save the Result, delete original descriptor, store new descriptor */ 250 251 RetDesc->Integer.Value = Result; 252 253 if (*ResultDesc == ObjDesc) 254 { 255 if (WalkState->Opcode != AML_STORE_OP) 256 { 257 AcpiUtRemoveReference (ObjDesc); 258 } 259 } 260 261 *ResultDesc = RetDesc; 262 return_ACPI_STATUS (AE_OK); 263} 264 265 266/******************************************************************************* 267 * 268 * FUNCTION: AcpiExConvertToBuffer 269 * 270 * PARAMETERS: *ObjDesc - Object to be converted. Must be an 271 * Integer, Buffer, or String 272 * WalkState - Current method state 273 * 274 * RETURN: Status 275 * 276 * DESCRIPTION: Convert an ACPI Object to an Buffer 277 * 278 ******************************************************************************/ 279 280ACPI_STATUS 281AcpiExConvertToBuffer ( 282 ACPI_OPERAND_OBJECT *ObjDesc, 283 ACPI_OPERAND_OBJECT **ResultDesc, 284 ACPI_WALK_STATE *WalkState) 285{ 286 ACPI_OPERAND_OBJECT *RetDesc; 287 UINT32 i;
|
296 UINT32 IntegerSize = sizeof (ACPI_INTEGER);
|
288 UINT8 *NewBuf; 289 290 291 ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc); 292 293
|
303 switch (ObjDesc->Common.Type)
|
294 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) |
295 { 296 case ACPI_TYPE_INTEGER: 297 298 /*
|
308 * Create a new Buffer
|
299 * Create a new Buffer object |
300 */ 301 RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 302 if (!RetDesc) 303 { 304 return_ACPI_STATUS (AE_NO_MEMORY); 305 } 306
|
316 /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
317
318 if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
319 {
320 /*
321 * We are running a method that exists in a 32-bit ACPI table.
322 * Use only 32 bits of the Integer for conversion.
323 */
324 IntegerSize = sizeof (UINT32);
325 }
326
|
307 /* Need enough space for one integer */ 308
|
329 RetDesc->Buffer.Length = IntegerSize;
330 NewBuf = ACPI_MEM_CALLOCATE (IntegerSize);
|
309 NewBuf = ACPI_MEM_CALLOCATE (AcpiGbl_IntegerByteWidth); |
310 if (!NewBuf) 311 { 312 ACPI_REPORT_ERROR 313 (("ExConvertToBuffer: Buffer allocation failure\n")); 314 AcpiUtRemoveReference (RetDesc); 315 return_ACPI_STATUS (AE_NO_MEMORY); 316 } 317 318 /* Copy the integer to the buffer */ 319
|
341 for (i = 0; i < IntegerSize; i++)
|
320 for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) |
321 { 322 NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8)); 323 }
|
324 325 /* Complete buffer object initialization */ 326 327 RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; |
328 RetDesc->Buffer.Pointer = NewBuf;
|
329 RetDesc->Buffer.Length = AcpiGbl_IntegerByteWidth; |
330 331 /* Return the new buffer descriptor */ 332 333 *ResultDesc = RetDesc; 334 break; 335 336 337 case ACPI_TYPE_STRING: 338 *ResultDesc = ObjDesc; 339 break; 340 341 342 case ACPI_TYPE_BUFFER: 343 *ResultDesc = ObjDesc; 344 break; 345 346 347 default: 348 return_ACPI_STATUS (AE_TYPE); 349 } 350 351 /* Mark buffer initialized */ 352 353 (*ResultDesc)->Common.Flags |= AOPOBJ_DATA_VALID; 354 return_ACPI_STATUS (AE_OK); 355} 356 357 358/******************************************************************************* 359 * 360 * FUNCTION: AcpiExConvertAscii 361 * 362 * PARAMETERS: Integer 363 * 364 * RETURN: Actual string length 365 * 366 * DESCRIPTION: Convert an ACPI Integer to a hex string 367 * 368 ******************************************************************************/ 369 370UINT32 371AcpiExConvertToAscii ( 372 ACPI_INTEGER Integer, 373 UINT32 Base, 374 UINT8 *String) 375{ 376 UINT32 i; 377 UINT32 j; 378 UINT32 k = 0;
|
395 UINT8 HexDigit;
|
379 char HexDigit; |
380 ACPI_INTEGER Digit; 381 UINT32 Remainder; 382 UINT32 Length = sizeof (ACPI_INTEGER); 383 BOOLEAN LeadingZero = TRUE; 384 385 386 ACPI_FUNCTION_ENTRY (); 387 388 389 switch (Base) 390 { 391 case 10: 392 393 Remainder = 0; 394 for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--) 395 { 396 /* Divide by nth factor of 10 */ 397 398 Digit = Integer; 399 for (j = 1; j < i; j++) 400 {
|
417 AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder);
|
401 (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder); |
402 } 403 404 /* Create the decimal digit */ 405 406 if (Digit != 0) 407 { 408 LeadingZero = FALSE; 409 } 410 411 if (!LeadingZero) 412 { 413 String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); 414 k++; 415 } 416 } 417 break; 418 419 case 16: 420 421 /* Copy the integer to the buffer */ 422 423 for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--) 424 { 425 426 HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4)); 427 if (HexDigit != ACPI_ASCII_ZERO) 428 { 429 LeadingZero = FALSE; 430 } 431 432 if (!LeadingZero) 433 {
|
450 String[k] = HexDigit;
|
434 String[k] = (UINT8) HexDigit; |
435 k++; 436 } 437 } 438 break; 439 440 default: 441 break; 442 } 443 444 /* 445 * Since leading zeros are supressed, we must check for the case where 446 * the integer equals 0. 447 * 448 * Finally, null terminate the string and return the length 449 */ 450 if (!k) 451 { 452 String [0] = ACPI_ASCII_ZERO; 453 k = 1; 454 } 455 String [k] = 0; 456 457 return (k); 458} 459 460 461/******************************************************************************* 462 * 463 * FUNCTION: AcpiExConvertToString 464 * 465 * PARAMETERS: *ObjDesc - Object to be converted. Must be an 466 * Integer, Buffer, or String 467 * WalkState - Current method state 468 * 469 * RETURN: Status 470 * 471 * DESCRIPTION: Convert an ACPI Object to a string 472 * 473 ******************************************************************************/ 474 475ACPI_STATUS 476AcpiExConvertToString ( 477 ACPI_OPERAND_OBJECT *ObjDesc, 478 ACPI_OPERAND_OBJECT **ResultDesc, 479 UINT32 Base, 480 UINT32 MaxLength, 481 ACPI_WALK_STATE *WalkState) 482{ 483 ACPI_OPERAND_OBJECT *RetDesc; 484 UINT32 i; 485 UINT32 Index; 486 UINT32 StringLength;
|
503 UINT32 IntegerSize = sizeof (ACPI_INTEGER);
|
487 UINT8 *NewBuf; 488 UINT8 *Pointer; 489 490 491 ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); 492 493
|
511 switch (ObjDesc->Common.Type)
|
494 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) |
495 { 496 case ACPI_TYPE_INTEGER: 497
|
515 /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
516
517 if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
518 {
519 /*
520 * We are running a method that exists in a 32-bit ACPI table.
521 * Use only 32 bits of the Integer
522 */
523 IntegerSize = sizeof (UINT32);
524 }
525
526 StringLength = IntegerSize * 2;
|
498 StringLength = AcpiGbl_IntegerByteWidth * 2; |
499 if (Base == 10) 500 { 501 StringLength = ACPI_MAX_DECIMAL_DIGITS; 502 } 503 504 /* 505 * Create a new String 506 */ 507 RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); 508 if (!RetDesc) 509 { 510 return_ACPI_STATUS (AE_NO_MEMORY); 511 } 512 513 /* Need enough space for one ASCII integer plus null terminator */ 514
|
543 NewBuf = ACPI_MEM_CALLOCATE (StringLength + 1);
|
515 NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); |
516 if (!NewBuf) 517 { 518 ACPI_REPORT_ERROR 519 (("ExConvertToString: Buffer allocation failure\n")); 520 AcpiUtRemoveReference (RetDesc); 521 return_ACPI_STATUS (AE_NO_MEMORY); 522 } 523
|
552
|
524 /* Convert */ 525 526 i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf); 527 528 /* Null terminate at the correct place */ 529 530 if (MaxLength < i) 531 { 532 NewBuf[MaxLength] = 0; 533 RetDesc->String.Length = MaxLength; 534 } 535 else 536 { 537 NewBuf [i] = 0; 538 RetDesc->String.Length = i; 539 } 540 541 RetDesc->Buffer.Pointer = NewBuf; 542 543 /* Return the new buffer descriptor */ 544 545 if (*ResultDesc == ObjDesc) 546 { 547 if (WalkState->Opcode != AML_STORE_OP) 548 { 549 AcpiUtRemoveReference (ObjDesc); 550 } 551 } 552 553 *ResultDesc = RetDesc; 554 break; 555 556 557 case ACPI_TYPE_BUFFER: 558 559 StringLength = ObjDesc->Buffer.Length * 3; 560 if (Base == 10) 561 { 562 StringLength = ObjDesc->Buffer.Length * 4; 563 } 564 565 if (MaxLength > ACPI_MAX_STRING_CONVERSION) 566 { 567 if (StringLength > ACPI_MAX_STRING_CONVERSION) 568 { 569 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 570 } 571 } 572 573 /* 574 * Create a new string object 575 */ 576 RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); 577 if (!RetDesc) 578 { 579 return_ACPI_STATUS (AE_NO_MEMORY); 580 } 581 582 /* String length is the lesser of the Max or the actual length */ 583 584 if (MaxLength < StringLength) 585 { 586 StringLength = MaxLength; 587 } 588
|
618 NewBuf = ACPI_MEM_CALLOCATE (StringLength + 1);
|
589 NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); |
590 if (!NewBuf) 591 { 592 ACPI_REPORT_ERROR 593 (("ExConvertToString: Buffer allocation failure\n")); 594 AcpiUtRemoveReference (RetDesc); 595 return_ACPI_STATUS (AE_NO_MEMORY); 596 } 597 598 /* 599 * Convert each byte of the buffer to two ASCII characters plus a space. 600 */ 601 Pointer = ObjDesc->Buffer.Pointer; 602 Index = 0; 603 for (i = 0, Index = 0; i < ObjDesc->Buffer.Length; i++) 604 {
|
634 Index = AcpiExConvertToAscii (Pointer[i], Base, &NewBuf[Index]);
|
605 Index = AcpiExConvertToAscii ((ACPI_INTEGER) Pointer[i], Base, &NewBuf[Index]); |
606 607 NewBuf[Index] = ' '; 608 Index++; 609 } 610 611 /* Null terminate */ 612 613 NewBuf [Index-1] = 0; 614 RetDesc->Buffer.Pointer = NewBuf; 615 RetDesc->String.Length = ACPI_STRLEN ((char *) NewBuf); 616
|
646
|
617 /* Return the new buffer descriptor */ 618 619 if (*ResultDesc == ObjDesc) 620 { 621 if (WalkState->Opcode != AML_STORE_OP) 622 { 623 AcpiUtRemoveReference (ObjDesc); 624 } 625 } 626 627 *ResultDesc = RetDesc; 628 break; 629 630 631 case ACPI_TYPE_STRING: 632 633 if (MaxLength >= ObjDesc->String.Length) 634 { 635 *ResultDesc = ObjDesc; 636 } 637 638 else 639 { 640 /* Must copy the string first and then truncate it */ 641 642 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 643 } 644 break; 645 646 647 default: 648 return_ACPI_STATUS (AE_TYPE); 649 } 650 651 return_ACPI_STATUS (AE_OK); 652} 653 654 655/******************************************************************************* 656 * 657 * FUNCTION: AcpiExConvertToTargetType 658 * 659 * PARAMETERS: DestinationType - Current type of the destination 660 * SourceDesc - Source object to be converted. 661 * WalkState - Current method state 662 * 663 * RETURN: Status 664 * 665 * DESCRIPTION: Implements "implicit conversion" rules for storing an object. 666 * 667 ******************************************************************************/ 668 669ACPI_STATUS 670AcpiExConvertToTargetType ( 671 ACPI_OBJECT_TYPE DestinationType, 672 ACPI_OPERAND_OBJECT *SourceDesc, 673 ACPI_OPERAND_OBJECT **ResultDesc, 674 ACPI_WALK_STATE *WalkState) 675{ 676 ACPI_STATUS Status = AE_OK; 677 678 679 ACPI_FUNCTION_TRACE ("ExConvertToTargetType"); 680 681 682 /* Default behavior */ 683 684 *ResultDesc = SourceDesc; 685 686 /* 687 * If required by the target, 688 * perform implicit conversion on the source before we store it. 689 */ 690 switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) 691 { 692 case ARGI_SIMPLE_TARGET: 693 case ARGI_FIXED_TARGET: 694 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ 695 696 switch (DestinationType) 697 { 698 case INTERNAL_TYPE_REGION_FIELD: 699 /* 700 * Named field can always handle conversions 701 */ 702 break; 703 704 default: 705 /* No conversion allowed for these types */ 706
|
737 if (DestinationType != SourceDesc->Common.Type)
|
707 if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc)) |
708 { 709 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 710 "Target does not allow conversion of type %s to %s\n",
|
741 AcpiUtGetTypeName ((SourceDesc)->Common.Type),
|
711 AcpiUtGetObjectTypeName (SourceDesc), |
712 AcpiUtGetTypeName (DestinationType))); 713 Status = AE_TYPE; 714 } 715 } 716 break; 717 718 719 case ARGI_TARGETREF: 720 721 switch (DestinationType) 722 { 723 case ACPI_TYPE_INTEGER: 724 case ACPI_TYPE_BUFFER_FIELD: 725 case INTERNAL_TYPE_BANK_FIELD: 726 case INTERNAL_TYPE_INDEX_FIELD: 727 /* 728 * These types require an Integer operand. We can convert 729 * a Buffer or a String to an Integer if necessary. 730 */ 731 Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState); 732 break; 733 734 735 case ACPI_TYPE_STRING: 736 737 /* 738 * The operand must be a String. We can convert an 739 * Integer or Buffer if necessary 740 */ 741 Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState); 742 break; 743 744 745 case ACPI_TYPE_BUFFER: 746 747 /* 748 * The operand must be a Buffer. We can convert an 749 * Integer or String if necessary 750 */ 751 Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState); 752 break;
|
753 754 755 default: 756 Status = AE_AML_INTERNAL; 757 break; |
758 } 759 break; 760 761 762 case ARGI_REFERENCE: 763 /* 764 * CreateXxxxField cases - we are storing the field object into the name 765 */ 766 break; 767 768 769 default: 770 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 771 "Unknown Target type ID 0x%X Op %s DestType %s\n", 772 GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), 773 WalkState->OpInfo->Name, AcpiUtGetTypeName (DestinationType))); 774 775 Status = AE_AML_INTERNAL; 776 } 777
|
803
|
778 /* 779 * Source-to-Target conversion semantics: 780 * 781 * If conversion to the target type cannot be performed, then simply 782 * overwrite the target with the new object and type. 783 */ 784 if (Status == AE_TYPE) 785 { 786 Status = AE_OK; 787 } 788 789 return_ACPI_STATUS (Status); 790} 791 792
|