Sync ACPICA with Intel's version 20151124.
[dragonfly.git] / sys / contrib / dev / acpica / source / components / executer / exmisc.c
1 /******************************************************************************
2  *
3  * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2015, Intel Corp.
9  * All rights reserved.
10  *
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.
25  *
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.
29  *
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.
42  */
43
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acinterp.h"
47 #include "amlcode.h"
48 #include "amlresrc.h"
49
50
51 #define _COMPONENT          ACPI_EXECUTER
52         ACPI_MODULE_NAME    ("exmisc")
53
54
55 /*******************************************************************************
56  *
57  * FUNCTION:    AcpiExGetObjectReference
58  *
59  * PARAMETERS:  ObjDesc             - Create a reference to this object
60  *              ReturnDesc          - Where to store the reference
61  *              WalkState           - Current state
62  *
63  * RETURN:      Status
64  *
65  * DESCRIPTION: Obtain and return a "reference" to the target object
66  *              Common code for the RefOfOp and the CondRefOfOp.
67  *
68  ******************************************************************************/
69
70 ACPI_STATUS
71 AcpiExGetObjectReference (
72     ACPI_OPERAND_OBJECT     *ObjDesc,
73     ACPI_OPERAND_OBJECT     **ReturnDesc,
74     ACPI_WALK_STATE         *WalkState)
75 {
76     ACPI_OPERAND_OBJECT     *ReferenceObj;
77     ACPI_OPERAND_OBJECT     *ReferencedObj;
78
79
80     ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
81
82
83     *ReturnDesc = NULL;
84
85     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
86     {
87     case ACPI_DESC_TYPE_OPERAND:
88
89         if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
90         {
91             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
92         }
93
94         /*
95          * Must be a reference to a Local or Arg
96          */
97         switch (ObjDesc->Reference.Class)
98         {
99         case ACPI_REFCLASS_LOCAL:
100         case ACPI_REFCLASS_ARG:
101         case ACPI_REFCLASS_DEBUG:
102
103             /* The referenced object is the pseudo-node for the local/arg */
104
105             ReferencedObj = ObjDesc->Reference.Object;
106             break;
107
108         default:
109
110             ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
111                 ObjDesc->Reference.Class));
112             return_ACPI_STATUS (AE_AML_INTERNAL);
113         }
114         break;
115
116     case ACPI_DESC_TYPE_NAMED:
117         /*
118          * A named reference that has already been resolved to a Node
119          */
120         ReferencedObj = ObjDesc;
121         break;
122
123     default:
124
125         ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
126             ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
127         return_ACPI_STATUS (AE_TYPE);
128     }
129
130
131     /* Create a new reference object */
132
133     ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
134     if (!ReferenceObj)
135     {
136         return_ACPI_STATUS (AE_NO_MEMORY);
137     }
138
139     ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
140     ReferenceObj->Reference.Object = ReferencedObj;
141     *ReturnDesc = ReferenceObj;
142
143     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
144         "Object %p Type [%s], returning Reference %p\n",
145         ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
146
147     return_ACPI_STATUS (AE_OK);
148 }
149
150
151 /*******************************************************************************
152  *
153  * FUNCTION:    AcpiExConcatTemplate
154  *
155  * PARAMETERS:  Operand0            - First source object
156  *              Operand1            - Second source object
157  *              ActualReturnDesc    - Where to place the return object
158  *              WalkState           - Current walk state
159  *
160  * RETURN:      Status
161  *
162  * DESCRIPTION: Concatenate two resource templates
163  *
164  ******************************************************************************/
165
166 ACPI_STATUS
167 AcpiExConcatTemplate (
168     ACPI_OPERAND_OBJECT     *Operand0,
169     ACPI_OPERAND_OBJECT     *Operand1,
170     ACPI_OPERAND_OBJECT     **ActualReturnDesc,
171     ACPI_WALK_STATE         *WalkState)
172 {
173     ACPI_STATUS             Status;
174     ACPI_OPERAND_OBJECT     *ReturnDesc;
175     UINT8                   *NewBuf;
176     UINT8                   *EndTag;
177     ACPI_SIZE               Length0;
178     ACPI_SIZE               Length1;
179     ACPI_SIZE               NewLength;
180
181
182     ACPI_FUNCTION_TRACE (ExConcatTemplate);
183
184
185     /*
186      * Find the EndTag descriptor in each resource template.
187      * Note1: returned pointers point TO the EndTag, not past it.
188      * Note2: zero-length buffers are allowed; treated like one EndTag
189      */
190
191     /* Get the length of the first resource template */
192
193     Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
194     if (ACPI_FAILURE (Status))
195     {
196         return_ACPI_STATUS (Status);
197     }
198
199     Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
200
201     /* Get the length of the second resource template */
202
203     Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
204     if (ACPI_FAILURE (Status))
205     {
206         return_ACPI_STATUS (Status);
207     }
208
209     Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
210
211     /* Combine both lengths, minimum size will be 2 for EndTag */
212
213     NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
214
215     /* Create a new buffer object for the result (with one EndTag) */
216
217     ReturnDesc = AcpiUtCreateBufferObject (NewLength);
218     if (!ReturnDesc)
219     {
220         return_ACPI_STATUS (AE_NO_MEMORY);
221     }
222
223     /*
224      * Copy the templates to the new buffer, 0 first, then 1 follows. One
225      * EndTag descriptor is copied from Operand1.
226      */
227     NewBuf = ReturnDesc->Buffer.Pointer;
228     memcpy (NewBuf, Operand0->Buffer.Pointer, Length0);
229     memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
230
231     /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
232
233     NewBuf[NewLength - 1] = 0;
234     NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
235
236     /* Return the completed resource template */
237
238     *ActualReturnDesc = ReturnDesc;
239     return_ACPI_STATUS (AE_OK);
240 }
241
242
243 /*******************************************************************************
244  *
245  * FUNCTION:    AcpiExDoConcatenate
246  *
247  * PARAMETERS:  Operand0            - First source object
248  *              Operand1            - Second source object
249  *              ActualReturnDesc    - Where to place the return object
250  *              WalkState           - Current walk state
251  *
252  * RETURN:      Status
253  *
254  * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
255  *
256  ******************************************************************************/
257
258 ACPI_STATUS
259 AcpiExDoConcatenate (
260     ACPI_OPERAND_OBJECT     *Operand0,
261     ACPI_OPERAND_OBJECT     *Operand1,
262     ACPI_OPERAND_OBJECT     **ActualReturnDesc,
263     ACPI_WALK_STATE         *WalkState)
264 {
265     ACPI_OPERAND_OBJECT     *LocalOperand1 = Operand1;
266     ACPI_OPERAND_OBJECT     *ReturnDesc;
267     char                    *NewBuf;
268     ACPI_STATUS             Status;
269
270
271     ACPI_FUNCTION_TRACE (ExDoConcatenate);
272
273
274     /*
275      * Convert the second operand if necessary. The first operand
276      * determines the type of the second operand, (See the Data Types
277      * section of the ACPI specification.)  Both object types are
278      * guaranteed to be either Integer/String/Buffer by the operand
279      * resolution mechanism.
280      */
281     switch (Operand0->Common.Type)
282     {
283     case ACPI_TYPE_INTEGER:
284
285         Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
286         break;
287
288     case ACPI_TYPE_STRING:
289
290         Status = AcpiExConvertToString (
291             Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
292         break;
293
294     case ACPI_TYPE_BUFFER:
295
296         Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
297         break;
298
299     default:
300
301         ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
302             Operand0->Common.Type));
303         Status = AE_AML_INTERNAL;
304     }
305
306     if (ACPI_FAILURE (Status))
307     {
308         goto Cleanup;
309     }
310
311     /*
312      * Both operands are now known to be the same object type
313      * (Both are Integer, String, or Buffer), and we can now perform the
314      * concatenation.
315      */
316
317     /*
318      * There are three cases to handle:
319      *
320      * 1) Two Integers concatenated to produce a new Buffer
321      * 2) Two Strings concatenated to produce a new String
322      * 3) Two Buffers concatenated to produce a new Buffer
323      */
324     switch (Operand0->Common.Type)
325     {
326     case ACPI_TYPE_INTEGER:
327
328         /* Result of two Integers is a Buffer */
329         /* Need enough buffer space for two integers */
330
331         ReturnDesc = AcpiUtCreateBufferObject (
332             (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
333         if (!ReturnDesc)
334         {
335             Status = AE_NO_MEMORY;
336             goto Cleanup;
337         }
338
339         NewBuf = (char *) ReturnDesc->Buffer.Pointer;
340
341         /* Copy the first integer, LSB first */
342
343         memcpy (NewBuf, &Operand0->Integer.Value,
344             AcpiGbl_IntegerByteWidth);
345
346         /* Copy the second integer (LSB first) after the first */
347
348         memcpy (NewBuf + AcpiGbl_IntegerByteWidth,
349             &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth);
350         break;
351
352     case ACPI_TYPE_STRING:
353
354         /* Result of two Strings is a String */
355
356         ReturnDesc = AcpiUtCreateStringObject (
357             ((ACPI_SIZE) Operand0->String.Length +
358             LocalOperand1->String.Length));
359         if (!ReturnDesc)
360         {
361             Status = AE_NO_MEMORY;
362             goto Cleanup;
363         }
364
365         NewBuf = ReturnDesc->String.Pointer;
366
367         /* Concatenate the strings */
368
369         strcpy (NewBuf, Operand0->String.Pointer);
370         strcpy (NewBuf + Operand0->String.Length,
371             LocalOperand1->String.Pointer);
372         break;
373
374     case ACPI_TYPE_BUFFER:
375
376         /* Result of two Buffers is a Buffer */
377
378         ReturnDesc = AcpiUtCreateBufferObject (
379             ((ACPI_SIZE) Operand0->Buffer.Length +
380             LocalOperand1->Buffer.Length));
381         if (!ReturnDesc)
382         {
383             Status = AE_NO_MEMORY;
384             goto Cleanup;
385         }
386
387         NewBuf = (char *) ReturnDesc->Buffer.Pointer;
388
389         /* Concatenate the buffers */
390
391         memcpy (NewBuf, Operand0->Buffer.Pointer,
392             Operand0->Buffer.Length);
393         memcpy (NewBuf + Operand0->Buffer.Length,
394             LocalOperand1->Buffer.Pointer,
395             LocalOperand1->Buffer.Length);
396         break;
397
398     default:
399
400         /* Invalid object type, should not happen here */
401
402         ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
403             Operand0->Common.Type));
404         Status =AE_AML_INTERNAL;
405         goto Cleanup;
406     }
407
408     *ActualReturnDesc = ReturnDesc;
409
410 Cleanup:
411     if (LocalOperand1 != Operand1)
412     {
413         AcpiUtRemoveReference (LocalOperand1);
414     }
415     return_ACPI_STATUS (Status);
416 }
417
418
419 /*******************************************************************************
420  *
421  * FUNCTION:    AcpiExDoMathOp
422  *
423  * PARAMETERS:  Opcode              - AML opcode
424  *              Integer0            - Integer operand #0
425  *              Integer1            - Integer operand #1
426  *
427  * RETURN:      Integer result of the operation
428  *
429  * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
430  *              math functions here is to prevent a lot of pointer dereferencing
431  *              to obtain the operands.
432  *
433  ******************************************************************************/
434
435 UINT64
436 AcpiExDoMathOp (
437     UINT16                  Opcode,
438     UINT64                  Integer0,
439     UINT64                  Integer1)
440 {
441
442     ACPI_FUNCTION_ENTRY ();
443
444
445     switch (Opcode)
446     {
447     case AML_ADD_OP:                /* Add (Integer0, Integer1, Result) */
448
449         return (Integer0 + Integer1);
450
451     case AML_BIT_AND_OP:            /* And (Integer0, Integer1, Result) */
452
453         return (Integer0 & Integer1);
454
455     case AML_BIT_NAND_OP:           /* NAnd (Integer0, Integer1, Result) */
456
457         return (~(Integer0 & Integer1));
458
459     case AML_BIT_OR_OP:             /* Or (Integer0, Integer1, Result) */
460
461         return (Integer0 | Integer1);
462
463     case AML_BIT_NOR_OP:            /* NOr (Integer0, Integer1, Result) */
464
465         return (~(Integer0 | Integer1));
466
467     case AML_BIT_XOR_OP:            /* XOr (Integer0, Integer1, Result) */
468
469         return (Integer0 ^ Integer1);
470
471     case AML_MULTIPLY_OP:           /* Multiply (Integer0, Integer1, Result) */
472
473         return (Integer0 * Integer1);
474
475     case AML_SHIFT_LEFT_OP:         /* ShiftLeft (Operand, ShiftCount, Result)*/
476
477         /*
478          * We need to check if the shiftcount is larger than the integer bit
479          * width since the behavior of this is not well-defined in the C language.
480          */
481         if (Integer1 >= AcpiGbl_IntegerBitWidth)
482         {
483             return (0);
484         }
485         return (Integer0 << Integer1);
486
487     case AML_SHIFT_RIGHT_OP:        /* ShiftRight (Operand, ShiftCount, Result) */
488
489         /*
490          * We need to check if the shiftcount is larger than the integer bit
491          * width since the behavior of this is not well-defined in the C language.
492          */
493         if (Integer1 >= AcpiGbl_IntegerBitWidth)
494         {
495             return (0);
496         }
497         return (Integer0 >> Integer1);
498
499     case AML_SUBTRACT_OP:           /* Subtract (Integer0, Integer1, Result) */
500
501         return (Integer0 - Integer1);
502
503     default:
504
505         return (0);
506     }
507 }
508
509
510 /*******************************************************************************
511  *
512  * FUNCTION:    AcpiExDoLogicalNumericOp
513  *
514  * PARAMETERS:  Opcode              - AML opcode
515  *              Integer0            - Integer operand #0
516  *              Integer1            - Integer operand #1
517  *              LogicalResult       - TRUE/FALSE result of the operation
518  *
519  * RETURN:      Status
520  *
521  * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
522  *              operators (LAnd and LOr), both operands must be integers.
523  *
524  *              Note: cleanest machine code seems to be produced by the code
525  *              below, rather than using statements of the form:
526  *                  Result = (Integer0 && Integer1);
527  *
528  ******************************************************************************/
529
530 ACPI_STATUS
531 AcpiExDoLogicalNumericOp (
532     UINT16                  Opcode,
533     UINT64                  Integer0,
534     UINT64                  Integer1,
535     BOOLEAN                 *LogicalResult)
536 {
537     ACPI_STATUS             Status = AE_OK;
538     BOOLEAN                 LocalResult = FALSE;
539
540
541     ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
542
543
544     switch (Opcode)
545     {
546     case AML_LAND_OP:               /* LAnd (Integer0, Integer1) */
547
548         if (Integer0 && Integer1)
549         {
550             LocalResult = TRUE;
551         }
552         break;
553
554     case AML_LOR_OP:                /* LOr (Integer0, Integer1) */
555
556         if (Integer0 || Integer1)
557         {
558             LocalResult = TRUE;
559         }
560         break;
561
562     default:
563
564         Status = AE_AML_INTERNAL;
565         break;
566     }
567
568     /* Return the logical result and status */
569
570     *LogicalResult = LocalResult;
571     return_ACPI_STATUS (Status);
572 }
573
574
575 /*******************************************************************************
576  *
577  * FUNCTION:    AcpiExDoLogicalOp
578  *
579  * PARAMETERS:  Opcode              - AML opcode
580  *              Operand0            - operand #0
581  *              Operand1            - operand #1
582  *              LogicalResult       - TRUE/FALSE result of the operation
583  *
584  * RETURN:      Status
585  *
586  * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
587  *              functions here is to prevent a lot of pointer dereferencing
588  *              to obtain the operands and to simplify the generation of the
589  *              logical value. For the Numeric operators (LAnd and LOr), both
590  *              operands must be integers. For the other logical operators,
591  *              operands can be any combination of Integer/String/Buffer. The
592  *              first operand determines the type to which the second operand
593  *              will be converted.
594  *
595  *              Note: cleanest machine code seems to be produced by the code
596  *              below, rather than using statements of the form:
597  *                  Result = (Operand0 == Operand1);
598  *
599  ******************************************************************************/
600
601 ACPI_STATUS
602 AcpiExDoLogicalOp (
603     UINT16                  Opcode,
604     ACPI_OPERAND_OBJECT     *Operand0,
605     ACPI_OPERAND_OBJECT     *Operand1,
606     BOOLEAN                 *LogicalResult)
607 {
608     ACPI_OPERAND_OBJECT     *LocalOperand1 = Operand1;
609     UINT64                  Integer0;
610     UINT64                  Integer1;
611     UINT32                  Length0;
612     UINT32                  Length1;
613     ACPI_STATUS             Status = AE_OK;
614     BOOLEAN                 LocalResult = FALSE;
615     int                     Compare;
616
617
618     ACPI_FUNCTION_TRACE (ExDoLogicalOp);
619
620
621     /*
622      * Convert the second operand if necessary. The first operand
623      * determines the type of the second operand, (See the Data Types
624      * section of the ACPI 3.0+ specification.)  Both object types are
625      * guaranteed to be either Integer/String/Buffer by the operand
626      * resolution mechanism.
627      */
628     switch (Operand0->Common.Type)
629     {
630     case ACPI_TYPE_INTEGER:
631
632         Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
633         break;
634
635     case ACPI_TYPE_STRING:
636
637         Status = AcpiExConvertToString (
638             Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
639         break;
640
641     case ACPI_TYPE_BUFFER:
642
643         Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
644         break;
645
646     default:
647
648         Status = AE_AML_INTERNAL;
649         break;
650     }
651
652     if (ACPI_FAILURE (Status))
653     {
654         goto Cleanup;
655     }
656
657     /*
658      * Two cases: 1) Both Integers, 2) Both Strings or Buffers
659      */
660     if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
661     {
662         /*
663          * 1) Both operands are of type integer
664          *    Note: LocalOperand1 may have changed above
665          */
666         Integer0 = Operand0->Integer.Value;
667         Integer1 = LocalOperand1->Integer.Value;
668
669         switch (Opcode)
670         {
671         case AML_LEQUAL_OP:             /* LEqual (Operand0, Operand1) */
672
673             if (Integer0 == Integer1)
674             {
675                 LocalResult = TRUE;
676             }
677             break;
678
679         case AML_LGREATER_OP:           /* LGreater (Operand0, Operand1) */
680
681             if (Integer0 > Integer1)
682             {
683                 LocalResult = TRUE;
684             }
685             break;
686
687         case AML_LLESS_OP:              /* LLess (Operand0, Operand1) */
688
689             if (Integer0 < Integer1)
690             {
691                 LocalResult = TRUE;
692             }
693             break;
694
695         default:
696
697             Status = AE_AML_INTERNAL;
698             break;
699         }
700     }
701     else
702     {
703         /*
704          * 2) Both operands are Strings or both are Buffers
705          *    Note: Code below takes advantage of common Buffer/String
706          *          object fields. LocalOperand1 may have changed above. Use
707          *          memcmp to handle nulls in buffers.
708          */
709         Length0 = Operand0->Buffer.Length;
710         Length1 = LocalOperand1->Buffer.Length;
711
712         /* Lexicographic compare: compare the data bytes */
713
714         Compare = memcmp (Operand0->Buffer.Pointer,
715             LocalOperand1->Buffer.Pointer,
716             (Length0 > Length1) ? Length1 : Length0);
717
718         switch (Opcode)
719         {
720         case AML_LEQUAL_OP:             /* LEqual (Operand0, Operand1) */
721
722             /* Length and all bytes must be equal */
723
724             if ((Length0 == Length1) &&
725                 (Compare == 0))
726             {
727                 /* Length and all bytes match ==> TRUE */
728
729                 LocalResult = TRUE;
730             }
731             break;
732
733         case AML_LGREATER_OP:           /* LGreater (Operand0, Operand1) */
734
735             if (Compare > 0)
736             {
737                 LocalResult = TRUE;
738                 goto Cleanup;   /* TRUE */
739             }
740             if (Compare < 0)
741             {
742                 goto Cleanup;   /* FALSE */
743             }
744
745             /* Bytes match (to shortest length), compare lengths */
746
747             if (Length0 > Length1)
748             {
749                 LocalResult = TRUE;
750             }
751             break;
752
753         case AML_LLESS_OP:              /* LLess (Operand0, Operand1) */
754
755             if (Compare > 0)
756             {
757                 goto Cleanup;   /* FALSE */
758             }
759             if (Compare < 0)
760             {
761                 LocalResult = TRUE;
762                 goto Cleanup;   /* TRUE */
763             }
764
765             /* Bytes match (to shortest length), compare lengths */
766
767             if (Length0 < Length1)
768             {
769                 LocalResult = TRUE;
770             }
771             break;
772
773         default:
774
775             Status = AE_AML_INTERNAL;
776             break;
777         }
778     }
779
780 Cleanup:
781
782     /* New object was created if implicit conversion performed - delete */
783
784     if (LocalOperand1 != Operand1)
785     {
786         AcpiUtRemoveReference (LocalOperand1);
787     }
788
789     /* Return the logical result and status */
790
791     *LogicalResult = LocalResult;
792     return_ACPI_STATUS (Status);
793 }