Home | History | Annotate | Line # | Download | only in executer
exmisc.c revision 1.1.1.11
      1       1.1    jruoho /******************************************************************************
      2       1.1    jruoho  *
      3       1.1    jruoho  * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
      4       1.1    jruoho  *
      5       1.1    jruoho  *****************************************************************************/
      6       1.1    jruoho 
      7   1.1.1.2    jruoho /*
      8  1.1.1.10  christos  * Copyright (C) 2000 - 2017, Intel Corp.
      9       1.1    jruoho  * All rights reserved.
     10       1.1    jruoho  *
     11   1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12   1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13   1.1.1.2    jruoho  * are met:
     14   1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15   1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16   1.1.1.2    jruoho  *    without modification.
     17   1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18   1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19   1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20   1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21   1.1.1.2    jruoho  *    binary redistribution.
     22   1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23   1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24   1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25   1.1.1.2    jruoho  *
     26   1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27   1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28   1.1.1.2    jruoho  * Software Foundation.
     29   1.1.1.2    jruoho  *
     30   1.1.1.2    jruoho  * NO WARRANTY
     31   1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32   1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33   1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34   1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35   1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36   1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37   1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38   1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39   1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40   1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41   1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42   1.1.1.2    jruoho  */
     43       1.1    jruoho 
     44       1.1    jruoho #include "acpi.h"
     45       1.1    jruoho #include "accommon.h"
     46       1.1    jruoho #include "acinterp.h"
     47       1.1    jruoho #include "amlcode.h"
     48       1.1    jruoho 
     49       1.1    jruoho 
     50       1.1    jruoho #define _COMPONENT          ACPI_EXECUTER
     51       1.1    jruoho         ACPI_MODULE_NAME    ("exmisc")
     52       1.1    jruoho 
     53       1.1    jruoho 
     54       1.1    jruoho /*******************************************************************************
     55       1.1    jruoho  *
     56       1.1    jruoho  * FUNCTION:    AcpiExGetObjectReference
     57       1.1    jruoho  *
     58       1.1    jruoho  * PARAMETERS:  ObjDesc             - Create a reference to this object
     59       1.1    jruoho  *              ReturnDesc          - Where to store the reference
     60       1.1    jruoho  *              WalkState           - Current state
     61       1.1    jruoho  *
     62       1.1    jruoho  * RETURN:      Status
     63       1.1    jruoho  *
     64       1.1    jruoho  * DESCRIPTION: Obtain and return a "reference" to the target object
     65       1.1    jruoho  *              Common code for the RefOfOp and the CondRefOfOp.
     66       1.1    jruoho  *
     67       1.1    jruoho  ******************************************************************************/
     68       1.1    jruoho 
     69       1.1    jruoho ACPI_STATUS
     70       1.1    jruoho AcpiExGetObjectReference (
     71       1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc,
     72       1.1    jruoho     ACPI_OPERAND_OBJECT     **ReturnDesc,
     73       1.1    jruoho     ACPI_WALK_STATE         *WalkState)
     74       1.1    jruoho {
     75       1.1    jruoho     ACPI_OPERAND_OBJECT     *ReferenceObj;
     76       1.1    jruoho     ACPI_OPERAND_OBJECT     *ReferencedObj;
     77       1.1    jruoho 
     78       1.1    jruoho 
     79       1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
     80       1.1    jruoho 
     81       1.1    jruoho 
     82       1.1    jruoho     *ReturnDesc = NULL;
     83       1.1    jruoho 
     84       1.1    jruoho     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
     85       1.1    jruoho     {
     86       1.1    jruoho     case ACPI_DESC_TYPE_OPERAND:
     87       1.1    jruoho 
     88       1.1    jruoho         if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
     89       1.1    jruoho         {
     90       1.1    jruoho             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
     91       1.1    jruoho         }
     92       1.1    jruoho 
     93       1.1    jruoho         /*
     94       1.1    jruoho          * Must be a reference to a Local or Arg
     95       1.1    jruoho          */
     96       1.1    jruoho         switch (ObjDesc->Reference.Class)
     97       1.1    jruoho         {
     98       1.1    jruoho         case ACPI_REFCLASS_LOCAL:
     99       1.1    jruoho         case ACPI_REFCLASS_ARG:
    100       1.1    jruoho         case ACPI_REFCLASS_DEBUG:
    101       1.1    jruoho 
    102       1.1    jruoho             /* The referenced object is the pseudo-node for the local/arg */
    103       1.1    jruoho 
    104       1.1    jruoho             ReferencedObj = ObjDesc->Reference.Object;
    105       1.1    jruoho             break;
    106       1.1    jruoho 
    107       1.1    jruoho         default:
    108       1.1    jruoho 
    109   1.1.1.7  christos             ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X",
    110       1.1    jruoho                 ObjDesc->Reference.Class));
    111   1.1.1.7  christos             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
    112       1.1    jruoho         }
    113       1.1    jruoho         break;
    114       1.1    jruoho 
    115       1.1    jruoho     case ACPI_DESC_TYPE_NAMED:
    116       1.1    jruoho         /*
    117       1.1    jruoho          * A named reference that has already been resolved to a Node
    118       1.1    jruoho          */
    119       1.1    jruoho         ReferencedObj = ObjDesc;
    120       1.1    jruoho         break;
    121       1.1    jruoho 
    122       1.1    jruoho     default:
    123       1.1    jruoho 
    124       1.1    jruoho         ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
    125       1.1    jruoho             ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
    126       1.1    jruoho         return_ACPI_STATUS (AE_TYPE);
    127       1.1    jruoho     }
    128       1.1    jruoho 
    129       1.1    jruoho 
    130       1.1    jruoho     /* Create a new reference object */
    131       1.1    jruoho 
    132       1.1    jruoho     ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
    133       1.1    jruoho     if (!ReferenceObj)
    134       1.1    jruoho     {
    135       1.1    jruoho         return_ACPI_STATUS (AE_NO_MEMORY);
    136       1.1    jruoho     }
    137       1.1    jruoho 
    138       1.1    jruoho     ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
    139       1.1    jruoho     ReferenceObj->Reference.Object = ReferencedObj;
    140       1.1    jruoho     *ReturnDesc = ReferenceObj;
    141       1.1    jruoho 
    142       1.1    jruoho     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    143       1.1    jruoho         "Object %p Type [%s], returning Reference %p\n",
    144       1.1    jruoho         ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
    145       1.1    jruoho 
    146       1.1    jruoho     return_ACPI_STATUS (AE_OK);
    147       1.1    jruoho }
    148       1.1    jruoho 
    149       1.1    jruoho 
    150       1.1    jruoho /*******************************************************************************
    151       1.1    jruoho  *
    152       1.1    jruoho  * FUNCTION:    AcpiExDoMathOp
    153       1.1    jruoho  *
    154       1.1    jruoho  * PARAMETERS:  Opcode              - AML opcode
    155       1.1    jruoho  *              Integer0            - Integer operand #0
    156       1.1    jruoho  *              Integer1            - Integer operand #1
    157       1.1    jruoho  *
    158       1.1    jruoho  * RETURN:      Integer result of the operation
    159       1.1    jruoho  *
    160       1.1    jruoho  * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
    161       1.1    jruoho  *              math functions here is to prevent a lot of pointer dereferencing
    162       1.1    jruoho  *              to obtain the operands.
    163       1.1    jruoho  *
    164       1.1    jruoho  ******************************************************************************/
    165       1.1    jruoho 
    166       1.1    jruoho UINT64
    167       1.1    jruoho AcpiExDoMathOp (
    168       1.1    jruoho     UINT16                  Opcode,
    169       1.1    jruoho     UINT64                  Integer0,
    170       1.1    jruoho     UINT64                  Integer1)
    171       1.1    jruoho {
    172       1.1    jruoho 
    173       1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    174       1.1    jruoho 
    175       1.1    jruoho 
    176       1.1    jruoho     switch (Opcode)
    177       1.1    jruoho     {
    178       1.1    jruoho     case AML_ADD_OP:                /* Add (Integer0, Integer1, Result) */
    179       1.1    jruoho 
    180       1.1    jruoho         return (Integer0 + Integer1);
    181       1.1    jruoho 
    182       1.1    jruoho     case AML_BIT_AND_OP:            /* And (Integer0, Integer1, Result) */
    183       1.1    jruoho 
    184       1.1    jruoho         return (Integer0 & Integer1);
    185       1.1    jruoho 
    186       1.1    jruoho     case AML_BIT_NAND_OP:           /* NAnd (Integer0, Integer1, Result) */
    187       1.1    jruoho 
    188       1.1    jruoho         return (~(Integer0 & Integer1));
    189       1.1    jruoho 
    190       1.1    jruoho     case AML_BIT_OR_OP:             /* Or (Integer0, Integer1, Result) */
    191       1.1    jruoho 
    192       1.1    jruoho         return (Integer0 | Integer1);
    193       1.1    jruoho 
    194       1.1    jruoho     case AML_BIT_NOR_OP:            /* NOr (Integer0, Integer1, Result) */
    195       1.1    jruoho 
    196       1.1    jruoho         return (~(Integer0 | Integer1));
    197       1.1    jruoho 
    198       1.1    jruoho     case AML_BIT_XOR_OP:            /* XOr (Integer0, Integer1, Result) */
    199       1.1    jruoho 
    200       1.1    jruoho         return (Integer0 ^ Integer1);
    201       1.1    jruoho 
    202       1.1    jruoho     case AML_MULTIPLY_OP:           /* Multiply (Integer0, Integer1, Result) */
    203       1.1    jruoho 
    204       1.1    jruoho         return (Integer0 * Integer1);
    205       1.1    jruoho 
    206       1.1    jruoho     case AML_SHIFT_LEFT_OP:         /* ShiftLeft (Operand, ShiftCount, Result)*/
    207       1.1    jruoho 
    208       1.1    jruoho         /*
    209       1.1    jruoho          * We need to check if the shiftcount is larger than the integer bit
    210       1.1    jruoho          * width since the behavior of this is not well-defined in the C language.
    211       1.1    jruoho          */
    212       1.1    jruoho         if (Integer1 >= AcpiGbl_IntegerBitWidth)
    213       1.1    jruoho         {
    214       1.1    jruoho             return (0);
    215       1.1    jruoho         }
    216       1.1    jruoho         return (Integer0 << Integer1);
    217       1.1    jruoho 
    218       1.1    jruoho     case AML_SHIFT_RIGHT_OP:        /* ShiftRight (Operand, ShiftCount, Result) */
    219       1.1    jruoho 
    220       1.1    jruoho         /*
    221       1.1    jruoho          * We need to check if the shiftcount is larger than the integer bit
    222       1.1    jruoho          * width since the behavior of this is not well-defined in the C language.
    223       1.1    jruoho          */
    224       1.1    jruoho         if (Integer1 >= AcpiGbl_IntegerBitWidth)
    225       1.1    jruoho         {
    226       1.1    jruoho             return (0);
    227       1.1    jruoho         }
    228       1.1    jruoho         return (Integer0 >> Integer1);
    229       1.1    jruoho 
    230       1.1    jruoho     case AML_SUBTRACT_OP:           /* Subtract (Integer0, Integer1, Result) */
    231       1.1    jruoho 
    232       1.1    jruoho         return (Integer0 - Integer1);
    233       1.1    jruoho 
    234       1.1    jruoho     default:
    235       1.1    jruoho 
    236       1.1    jruoho         return (0);
    237       1.1    jruoho     }
    238       1.1    jruoho }
    239       1.1    jruoho 
    240       1.1    jruoho 
    241       1.1    jruoho /*******************************************************************************
    242       1.1    jruoho  *
    243       1.1    jruoho  * FUNCTION:    AcpiExDoLogicalNumericOp
    244       1.1    jruoho  *
    245       1.1    jruoho  * PARAMETERS:  Opcode              - AML opcode
    246       1.1    jruoho  *              Integer0            - Integer operand #0
    247       1.1    jruoho  *              Integer1            - Integer operand #1
    248       1.1    jruoho  *              LogicalResult       - TRUE/FALSE result of the operation
    249       1.1    jruoho  *
    250       1.1    jruoho  * RETURN:      Status
    251       1.1    jruoho  *
    252       1.1    jruoho  * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
    253       1.1    jruoho  *              operators (LAnd and LOr), both operands must be integers.
    254       1.1    jruoho  *
    255       1.1    jruoho  *              Note: cleanest machine code seems to be produced by the code
    256       1.1    jruoho  *              below, rather than using statements of the form:
    257       1.1    jruoho  *                  Result = (Integer0 && Integer1);
    258       1.1    jruoho  *
    259       1.1    jruoho  ******************************************************************************/
    260       1.1    jruoho 
    261       1.1    jruoho ACPI_STATUS
    262       1.1    jruoho AcpiExDoLogicalNumericOp (
    263       1.1    jruoho     UINT16                  Opcode,
    264       1.1    jruoho     UINT64                  Integer0,
    265       1.1    jruoho     UINT64                  Integer1,
    266       1.1    jruoho     BOOLEAN                 *LogicalResult)
    267       1.1    jruoho {
    268       1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    269       1.1    jruoho     BOOLEAN                 LocalResult = FALSE;
    270       1.1    jruoho 
    271       1.1    jruoho 
    272       1.1    jruoho     ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
    273       1.1    jruoho 
    274       1.1    jruoho 
    275       1.1    jruoho     switch (Opcode)
    276       1.1    jruoho     {
    277  1.1.1.11  christos     case AML_LOGICAL_AND_OP:        /* LAnd (Integer0, Integer1) */
    278       1.1    jruoho 
    279       1.1    jruoho         if (Integer0 && Integer1)
    280       1.1    jruoho         {
    281       1.1    jruoho             LocalResult = TRUE;
    282       1.1    jruoho         }
    283       1.1    jruoho         break;
    284       1.1    jruoho 
    285  1.1.1.11  christos     case AML_LOGICAL_OR_OP:         /* LOr (Integer0, Integer1) */
    286       1.1    jruoho 
    287       1.1    jruoho         if (Integer0 || Integer1)
    288       1.1    jruoho         {
    289       1.1    jruoho             LocalResult = TRUE;
    290       1.1    jruoho         }
    291       1.1    jruoho         break;
    292       1.1    jruoho 
    293       1.1    jruoho     default:
    294   1.1.1.3  christos 
    295       1.1    jruoho         Status = AE_AML_INTERNAL;
    296       1.1    jruoho         break;
    297       1.1    jruoho     }
    298       1.1    jruoho 
    299       1.1    jruoho     /* Return the logical result and status */
    300       1.1    jruoho 
    301       1.1    jruoho     *LogicalResult = LocalResult;
    302       1.1    jruoho     return_ACPI_STATUS (Status);
    303       1.1    jruoho }
    304       1.1    jruoho 
    305       1.1    jruoho 
    306       1.1    jruoho /*******************************************************************************
    307       1.1    jruoho  *
    308       1.1    jruoho  * FUNCTION:    AcpiExDoLogicalOp
    309       1.1    jruoho  *
    310       1.1    jruoho  * PARAMETERS:  Opcode              - AML opcode
    311       1.1    jruoho  *              Operand0            - operand #0
    312       1.1    jruoho  *              Operand1            - operand #1
    313       1.1    jruoho  *              LogicalResult       - TRUE/FALSE result of the operation
    314       1.1    jruoho  *
    315       1.1    jruoho  * RETURN:      Status
    316       1.1    jruoho  *
    317       1.1    jruoho  * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
    318       1.1    jruoho  *              functions here is to prevent a lot of pointer dereferencing
    319       1.1    jruoho  *              to obtain the operands and to simplify the generation of the
    320       1.1    jruoho  *              logical value. For the Numeric operators (LAnd and LOr), both
    321       1.1    jruoho  *              operands must be integers. For the other logical operators,
    322       1.1    jruoho  *              operands can be any combination of Integer/String/Buffer. The
    323       1.1    jruoho  *              first operand determines the type to which the second operand
    324       1.1    jruoho  *              will be converted.
    325       1.1    jruoho  *
    326       1.1    jruoho  *              Note: cleanest machine code seems to be produced by the code
    327       1.1    jruoho  *              below, rather than using statements of the form:
    328       1.1    jruoho  *                  Result = (Operand0 == Operand1);
    329       1.1    jruoho  *
    330       1.1    jruoho  ******************************************************************************/
    331       1.1    jruoho 
    332       1.1    jruoho ACPI_STATUS
    333       1.1    jruoho AcpiExDoLogicalOp (
    334       1.1    jruoho     UINT16                  Opcode,
    335       1.1    jruoho     ACPI_OPERAND_OBJECT     *Operand0,
    336       1.1    jruoho     ACPI_OPERAND_OBJECT     *Operand1,
    337       1.1    jruoho     BOOLEAN                 *LogicalResult)
    338       1.1    jruoho {
    339       1.1    jruoho     ACPI_OPERAND_OBJECT     *LocalOperand1 = Operand1;
    340       1.1    jruoho     UINT64                  Integer0;
    341       1.1    jruoho     UINT64                  Integer1;
    342       1.1    jruoho     UINT32                  Length0;
    343       1.1    jruoho     UINT32                  Length1;
    344       1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    345       1.1    jruoho     BOOLEAN                 LocalResult = FALSE;
    346       1.1    jruoho     int                     Compare;
    347       1.1    jruoho 
    348       1.1    jruoho 
    349       1.1    jruoho     ACPI_FUNCTION_TRACE (ExDoLogicalOp);
    350       1.1    jruoho 
    351       1.1    jruoho 
    352       1.1    jruoho     /*
    353   1.1.1.3  christos      * Convert the second operand if necessary. The first operand
    354       1.1    jruoho      * determines the type of the second operand, (See the Data Types
    355       1.1    jruoho      * section of the ACPI 3.0+ specification.)  Both object types are
    356       1.1    jruoho      * guaranteed to be either Integer/String/Buffer by the operand
    357       1.1    jruoho      * resolution mechanism.
    358       1.1    jruoho      */
    359       1.1    jruoho     switch (Operand0->Common.Type)
    360       1.1    jruoho     {
    361       1.1    jruoho     case ACPI_TYPE_INTEGER:
    362   1.1.1.3  christos 
    363   1.1.1.9  christos         Status = AcpiExConvertToInteger (Operand1, &LocalOperand1,
    364   1.1.1.9  christos             ACPI_STRTOUL_BASE16);
    365       1.1    jruoho         break;
    366       1.1    jruoho 
    367       1.1    jruoho     case ACPI_TYPE_STRING:
    368   1.1.1.3  christos 
    369   1.1.1.7  christos         Status = AcpiExConvertToString (
    370   1.1.1.7  christos             Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
    371       1.1    jruoho         break;
    372       1.1    jruoho 
    373       1.1    jruoho     case ACPI_TYPE_BUFFER:
    374   1.1.1.3  christos 
    375       1.1    jruoho         Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
    376       1.1    jruoho         break;
    377       1.1    jruoho 
    378       1.1    jruoho     default:
    379   1.1.1.3  christos 
    380       1.1    jruoho         Status = AE_AML_INTERNAL;
    381       1.1    jruoho         break;
    382       1.1    jruoho     }
    383       1.1    jruoho 
    384       1.1    jruoho     if (ACPI_FAILURE (Status))
    385       1.1    jruoho     {
    386       1.1    jruoho         goto Cleanup;
    387       1.1    jruoho     }
    388       1.1    jruoho 
    389       1.1    jruoho     /*
    390       1.1    jruoho      * Two cases: 1) Both Integers, 2) Both Strings or Buffers
    391       1.1    jruoho      */
    392       1.1    jruoho     if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
    393       1.1    jruoho     {
    394       1.1    jruoho         /*
    395       1.1    jruoho          * 1) Both operands are of type integer
    396       1.1    jruoho          *    Note: LocalOperand1 may have changed above
    397       1.1    jruoho          */
    398       1.1    jruoho         Integer0 = Operand0->Integer.Value;
    399       1.1    jruoho         Integer1 = LocalOperand1->Integer.Value;
    400       1.1    jruoho 
    401       1.1    jruoho         switch (Opcode)
    402       1.1    jruoho         {
    403  1.1.1.11  christos         case AML_LOGICAL_EQUAL_OP:          /* LEqual (Operand0, Operand1) */
    404       1.1    jruoho 
    405       1.1    jruoho             if (Integer0 == Integer1)
    406       1.1    jruoho             {
    407       1.1    jruoho                 LocalResult = TRUE;
    408       1.1    jruoho             }
    409       1.1    jruoho             break;
    410       1.1    jruoho 
    411  1.1.1.11  christos         case AML_LOGICAL_GREATER_OP:        /* LGreater (Operand0, Operand1) */
    412       1.1    jruoho 
    413       1.1    jruoho             if (Integer0 > Integer1)
    414       1.1    jruoho             {
    415       1.1    jruoho                 LocalResult = TRUE;
    416       1.1    jruoho             }
    417       1.1    jruoho             break;
    418       1.1    jruoho 
    419  1.1.1.11  christos         case AML_LOGICAL_LESS_OP:           /* LLess (Operand0, Operand1) */
    420       1.1    jruoho 
    421       1.1    jruoho             if (Integer0 < Integer1)
    422       1.1    jruoho             {
    423       1.1    jruoho                 LocalResult = TRUE;
    424       1.1    jruoho             }
    425       1.1    jruoho             break;
    426       1.1    jruoho 
    427       1.1    jruoho         default:
    428   1.1.1.3  christos 
    429       1.1    jruoho             Status = AE_AML_INTERNAL;
    430       1.1    jruoho             break;
    431       1.1    jruoho         }
    432       1.1    jruoho     }
    433       1.1    jruoho     else
    434       1.1    jruoho     {
    435       1.1    jruoho         /*
    436       1.1    jruoho          * 2) Both operands are Strings or both are Buffers
    437       1.1    jruoho          *    Note: Code below takes advantage of common Buffer/String
    438       1.1    jruoho          *          object fields. LocalOperand1 may have changed above. Use
    439       1.1    jruoho          *          memcmp to handle nulls in buffers.
    440       1.1    jruoho          */
    441       1.1    jruoho         Length0 = Operand0->Buffer.Length;
    442       1.1    jruoho         Length1 = LocalOperand1->Buffer.Length;
    443       1.1    jruoho 
    444       1.1    jruoho         /* Lexicographic compare: compare the data bytes */
    445       1.1    jruoho 
    446   1.1.1.6  christos         Compare = memcmp (Operand0->Buffer.Pointer,
    447   1.1.1.7  christos             LocalOperand1->Buffer.Pointer,
    448   1.1.1.7  christos             (Length0 > Length1) ? Length1 : Length0);
    449       1.1    jruoho 
    450       1.1    jruoho         switch (Opcode)
    451       1.1    jruoho         {
    452  1.1.1.11  christos         case AML_LOGICAL_EQUAL_OP:      /* LEqual (Operand0, Operand1) */
    453       1.1    jruoho 
    454       1.1    jruoho             /* Length and all bytes must be equal */
    455       1.1    jruoho 
    456       1.1    jruoho             if ((Length0 == Length1) &&
    457       1.1    jruoho                 (Compare == 0))
    458       1.1    jruoho             {
    459       1.1    jruoho                 /* Length and all bytes match ==> TRUE */
    460       1.1    jruoho 
    461       1.1    jruoho                 LocalResult = TRUE;
    462       1.1    jruoho             }
    463       1.1    jruoho             break;
    464       1.1    jruoho 
    465  1.1.1.11  christos         case AML_LOGICAL_GREATER_OP:    /* LGreater (Operand0, Operand1) */
    466       1.1    jruoho 
    467       1.1    jruoho             if (Compare > 0)
    468       1.1    jruoho             {
    469       1.1    jruoho                 LocalResult = TRUE;
    470       1.1    jruoho                 goto Cleanup;   /* TRUE */
    471       1.1    jruoho             }
    472       1.1    jruoho             if (Compare < 0)
    473       1.1    jruoho             {
    474       1.1    jruoho                 goto Cleanup;   /* FALSE */
    475       1.1    jruoho             }
    476       1.1    jruoho 
    477       1.1    jruoho             /* Bytes match (to shortest length), compare lengths */
    478       1.1    jruoho 
    479       1.1    jruoho             if (Length0 > Length1)
    480       1.1    jruoho             {
    481       1.1    jruoho                 LocalResult = TRUE;
    482       1.1    jruoho             }
    483       1.1    jruoho             break;
    484       1.1    jruoho 
    485  1.1.1.11  christos         case AML_LOGICAL_LESS_OP:       /* LLess (Operand0, Operand1) */
    486       1.1    jruoho 
    487       1.1    jruoho             if (Compare > 0)
    488       1.1    jruoho             {
    489       1.1    jruoho                 goto Cleanup;   /* FALSE */
    490       1.1    jruoho             }
    491       1.1    jruoho             if (Compare < 0)
    492       1.1    jruoho             {
    493       1.1    jruoho                 LocalResult = TRUE;
    494       1.1    jruoho                 goto Cleanup;   /* TRUE */
    495       1.1    jruoho             }
    496       1.1    jruoho 
    497       1.1    jruoho             /* Bytes match (to shortest length), compare lengths */
    498       1.1    jruoho 
    499       1.1    jruoho             if (Length0 < Length1)
    500       1.1    jruoho             {
    501       1.1    jruoho                 LocalResult = TRUE;
    502       1.1    jruoho             }
    503       1.1    jruoho             break;
    504       1.1    jruoho 
    505       1.1    jruoho         default:
    506   1.1.1.3  christos 
    507       1.1    jruoho             Status = AE_AML_INTERNAL;
    508       1.1    jruoho             break;
    509       1.1    jruoho         }
    510       1.1    jruoho     }
    511       1.1    jruoho 
    512       1.1    jruoho Cleanup:
    513       1.1    jruoho 
    514       1.1    jruoho     /* New object was created if implicit conversion performed - delete */
    515       1.1    jruoho 
    516       1.1    jruoho     if (LocalOperand1 != Operand1)
    517       1.1    jruoho     {
    518       1.1    jruoho         AcpiUtRemoveReference (LocalOperand1);
    519       1.1    jruoho     }
    520       1.1    jruoho 
    521       1.1    jruoho     /* Return the logical result and status */
    522       1.1    jruoho 
    523       1.1    jruoho     *LogicalResult = LocalResult;
    524       1.1    jruoho     return_ACPI_STATUS (Status);
    525       1.1    jruoho }
    526