xref: /openbmc/linux/drivers/acpi/acpica/exmisc.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
195857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
295b482a8SLen Brown /******************************************************************************
395b482a8SLen Brown  *
495b482a8SLen Brown  * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
595b482a8SLen Brown  *
6*612c2932SBob Moore  * Copyright (C) 2000 - 2023, Intel Corp.
795b482a8SLen Brown  *
895857638SErik Schmauss  *****************************************************************************/
995b482a8SLen Brown 
1095b482a8SLen Brown #include <acpi/acpi.h>
11e2f7a777SLen Brown #include "accommon.h"
12e2f7a777SLen Brown #include "acinterp.h"
13e2f7a777SLen Brown #include "amlcode.h"
1495b482a8SLen Brown 
1595b482a8SLen Brown #define _COMPONENT          ACPI_EXECUTER
1695b482a8SLen Brown ACPI_MODULE_NAME("exmisc")
1795b482a8SLen Brown 
1895b482a8SLen Brown /*******************************************************************************
1995b482a8SLen Brown  *
2095b482a8SLen Brown  * FUNCTION:    acpi_ex_get_object_reference
2195b482a8SLen Brown  *
2295b482a8SLen Brown  * PARAMETERS:  obj_desc            - Create a reference to this object
2395b482a8SLen Brown  *              return_desc         - Where to store the reference
2495b482a8SLen Brown  *              walk_state          - Current state
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * RETURN:      Status
2795b482a8SLen Brown  *
2895b482a8SLen Brown  * DESCRIPTION: Obtain and return a "reference" to the target object
2995b482a8SLen Brown  *              Common code for the ref_of_op and the cond_ref_of_op.
3095b482a8SLen Brown  *
3195b482a8SLen Brown  ******************************************************************************/
3295b482a8SLen Brown acpi_status
acpi_ex_get_object_reference(union acpi_operand_object * obj_desc,union acpi_operand_object ** return_desc,struct acpi_walk_state * walk_state)3395b482a8SLen Brown acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
3495b482a8SLen Brown 			     union acpi_operand_object **return_desc,
3595b482a8SLen Brown 			     struct acpi_walk_state *walk_state)
3695b482a8SLen Brown {
3795b482a8SLen Brown 	union acpi_operand_object *reference_obj;
3895b482a8SLen Brown 	union acpi_operand_object *referenced_obj;
3995b482a8SLen Brown 
4095b482a8SLen Brown 	ACPI_FUNCTION_TRACE_PTR(ex_get_object_reference, obj_desc);
4195b482a8SLen Brown 
4295b482a8SLen Brown 	*return_desc = NULL;
4395b482a8SLen Brown 
4495b482a8SLen Brown 	switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
4595b482a8SLen Brown 	case ACPI_DESC_TYPE_OPERAND:
4695b482a8SLen Brown 
473371c19cSBob Moore 		if (obj_desc->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
4895b482a8SLen Brown 			return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
4995b482a8SLen Brown 		}
5095b482a8SLen Brown 
5195b482a8SLen Brown 		/*
5295b482a8SLen Brown 		 * Must be a reference to a Local or Arg
5395b482a8SLen Brown 		 */
5495b482a8SLen Brown 		switch (obj_desc->reference.class) {
5595b482a8SLen Brown 		case ACPI_REFCLASS_LOCAL:
5695b482a8SLen Brown 		case ACPI_REFCLASS_ARG:
5795b482a8SLen Brown 		case ACPI_REFCLASS_DEBUG:
5895b482a8SLen Brown 
5995b482a8SLen Brown 			/* The referenced object is the pseudo-node for the local/arg */
6095b482a8SLen Brown 
6195b482a8SLen Brown 			referenced_obj = obj_desc->reference.object;
6295b482a8SLen Brown 			break;
6395b482a8SLen Brown 
6495b482a8SLen Brown 		default:
6595b482a8SLen Brown 
66395ec731SBob Moore 			ACPI_ERROR((AE_INFO, "Invalid Reference Class 0x%2.2X",
6795b482a8SLen Brown 				    obj_desc->reference.class));
68395ec731SBob Moore 			return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
6995b482a8SLen Brown 		}
7095b482a8SLen Brown 		break;
7195b482a8SLen Brown 
7295b482a8SLen Brown 	case ACPI_DESC_TYPE_NAMED:
7395b482a8SLen Brown 		/*
7495b482a8SLen Brown 		 * A named reference that has already been resolved to a Node
7595b482a8SLen Brown 		 */
7695b482a8SLen Brown 		referenced_obj = obj_desc;
7795b482a8SLen Brown 		break;
7895b482a8SLen Brown 
7995b482a8SLen Brown 	default:
8095b482a8SLen Brown 
81f6a22b0bSBob Moore 		ACPI_ERROR((AE_INFO, "Invalid descriptor type 0x%X",
8295b482a8SLen Brown 			    ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
8395b482a8SLen Brown 		return_ACPI_STATUS(AE_TYPE);
8495b482a8SLen Brown 	}
8595b482a8SLen Brown 
8695b482a8SLen Brown 	/* Create a new reference object */
8795b482a8SLen Brown 
8895b482a8SLen Brown 	reference_obj =
8995b482a8SLen Brown 	    acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
9095b482a8SLen Brown 	if (!reference_obj) {
9195b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
9295b482a8SLen Brown 	}
9395b482a8SLen Brown 
9495b482a8SLen Brown 	reference_obj->reference.class = ACPI_REFCLASS_REFOF;
9595b482a8SLen Brown 	reference_obj->reference.object = referenced_obj;
9695b482a8SLen Brown 	*return_desc = reference_obj;
9795b482a8SLen Brown 
9895b482a8SLen Brown 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
9995b482a8SLen Brown 			  "Object %p Type [%s], returning Reference %p\n",
10095b482a8SLen Brown 			  obj_desc, acpi_ut_get_object_type_name(obj_desc),
10195b482a8SLen Brown 			  *return_desc));
10295b482a8SLen Brown 
10395b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
10495b482a8SLen Brown }
10595b482a8SLen Brown 
10695b482a8SLen Brown /*******************************************************************************
10795b482a8SLen Brown  *
10895b482a8SLen Brown  * FUNCTION:    acpi_ex_do_math_op
10995b482a8SLen Brown  *
110ba494beeSBob Moore  * PARAMETERS:  opcode              - AML opcode
111ba494beeSBob Moore  *              integer0            - Integer operand #0
112ba494beeSBob Moore  *              integer1            - Integer operand #1
11395b482a8SLen Brown  *
11495b482a8SLen Brown  * RETURN:      Integer result of the operation
11595b482a8SLen Brown  *
11695b482a8SLen Brown  * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
11795b482a8SLen Brown  *              math functions here is to prevent a lot of pointer dereferencing
11895b482a8SLen Brown  *              to obtain the operands.
11995b482a8SLen Brown  *
12095b482a8SLen Brown  ******************************************************************************/
12195b482a8SLen Brown 
acpi_ex_do_math_op(u16 opcode,u64 integer0,u64 integer1)1225df7e6cbSBob Moore u64 acpi_ex_do_math_op(u16 opcode, u64 integer0, u64 integer1)
12395b482a8SLen Brown {
12495b482a8SLen Brown 
12595b482a8SLen Brown 	ACPI_FUNCTION_ENTRY();
12695b482a8SLen Brown 
12795b482a8SLen Brown 	switch (opcode) {
12895b482a8SLen Brown 	case AML_ADD_OP:	/* Add (Integer0, Integer1, Result) */
12995b482a8SLen Brown 
13095b482a8SLen Brown 		return (integer0 + integer1);
13195b482a8SLen Brown 
13295b482a8SLen Brown 	case AML_BIT_AND_OP:	/* And (Integer0, Integer1, Result) */
13395b482a8SLen Brown 
13495b482a8SLen Brown 		return (integer0 & integer1);
13595b482a8SLen Brown 
13695b482a8SLen Brown 	case AML_BIT_NAND_OP:	/* NAnd (Integer0, Integer1, Result) */
13795b482a8SLen Brown 
13895b482a8SLen Brown 		return (~(integer0 & integer1));
13995b482a8SLen Brown 
14095b482a8SLen Brown 	case AML_BIT_OR_OP:	/* Or (Integer0, Integer1, Result) */
14195b482a8SLen Brown 
14295b482a8SLen Brown 		return (integer0 | integer1);
14395b482a8SLen Brown 
14495b482a8SLen Brown 	case AML_BIT_NOR_OP:	/* NOr (Integer0, Integer1, Result) */
14595b482a8SLen Brown 
14695b482a8SLen Brown 		return (~(integer0 | integer1));
14795b482a8SLen Brown 
14895b482a8SLen Brown 	case AML_BIT_XOR_OP:	/* XOr (Integer0, Integer1, Result) */
14995b482a8SLen Brown 
15095b482a8SLen Brown 		return (integer0 ^ integer1);
15195b482a8SLen Brown 
15295b482a8SLen Brown 	case AML_MULTIPLY_OP:	/* Multiply (Integer0, Integer1, Result) */
15395b482a8SLen Brown 
15495b482a8SLen Brown 		return (integer0 * integer1);
15595b482a8SLen Brown 
15695b482a8SLen Brown 	case AML_SHIFT_LEFT_OP:	/* shift_left (Operand, shift_count, Result) */
15795b482a8SLen Brown 
15895b482a8SLen Brown 		/*
15995b482a8SLen Brown 		 * We need to check if the shiftcount is larger than the integer bit
16095b482a8SLen Brown 		 * width since the behavior of this is not well-defined in the C language.
16195b482a8SLen Brown 		 */
16295b482a8SLen Brown 		if (integer1 >= acpi_gbl_integer_bit_width) {
16395b482a8SLen Brown 			return (0);
16495b482a8SLen Brown 		}
16595b482a8SLen Brown 		return (integer0 << integer1);
16695b482a8SLen Brown 
16795b482a8SLen Brown 	case AML_SHIFT_RIGHT_OP:	/* shift_right (Operand, shift_count, Result) */
16895b482a8SLen Brown 
16995b482a8SLen Brown 		/*
17095b482a8SLen Brown 		 * We need to check if the shiftcount is larger than the integer bit
17195b482a8SLen Brown 		 * width since the behavior of this is not well-defined in the C language.
17295b482a8SLen Brown 		 */
17395b482a8SLen Brown 		if (integer1 >= acpi_gbl_integer_bit_width) {
17495b482a8SLen Brown 			return (0);
17595b482a8SLen Brown 		}
17695b482a8SLen Brown 		return (integer0 >> integer1);
17795b482a8SLen Brown 
17895b482a8SLen Brown 	case AML_SUBTRACT_OP:	/* Subtract (Integer0, Integer1, Result) */
17995b482a8SLen Brown 
18095b482a8SLen Brown 		return (integer0 - integer1);
18195b482a8SLen Brown 
18295b482a8SLen Brown 	default:
18395b482a8SLen Brown 
18495b482a8SLen Brown 		return (0);
18595b482a8SLen Brown 	}
18695b482a8SLen Brown }
18795b482a8SLen Brown 
18895b482a8SLen Brown /*******************************************************************************
18995b482a8SLen Brown  *
19095b482a8SLen Brown  * FUNCTION:    acpi_ex_do_logical_numeric_op
19195b482a8SLen Brown  *
192ba494beeSBob Moore  * PARAMETERS:  opcode              - AML opcode
193ba494beeSBob Moore  *              integer0            - Integer operand #0
194ba494beeSBob Moore  *              integer1            - Integer operand #1
19595b482a8SLen Brown  *              logical_result      - TRUE/FALSE result of the operation
19695b482a8SLen Brown  *
19795b482a8SLen Brown  * RETURN:      Status
19895b482a8SLen Brown  *
19995b482a8SLen Brown  * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
20095b482a8SLen Brown  *              operators (LAnd and LOr), both operands must be integers.
20195b482a8SLen Brown  *
20295b482a8SLen Brown  *              Note: cleanest machine code seems to be produced by the code
20395b482a8SLen Brown  *              below, rather than using statements of the form:
20495b482a8SLen Brown  *                  Result = (Integer0 && Integer1);
20595b482a8SLen Brown  *
20695b482a8SLen Brown  ******************************************************************************/
20795b482a8SLen Brown 
20895b482a8SLen Brown acpi_status
acpi_ex_do_logical_numeric_op(u16 opcode,u64 integer0,u64 integer1,u8 * logical_result)20995b482a8SLen Brown acpi_ex_do_logical_numeric_op(u16 opcode,
2105df7e6cbSBob Moore 			      u64 integer0, u64 integer1, u8 *logical_result)
21195b482a8SLen Brown {
21295b482a8SLen Brown 	acpi_status status = AE_OK;
21395b482a8SLen Brown 	u8 local_result = FALSE;
21495b482a8SLen Brown 
21595b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ex_do_logical_numeric_op);
21695b482a8SLen Brown 
21795b482a8SLen Brown 	switch (opcode) {
2189ff5a21aSBob Moore 	case AML_LOGICAL_AND_OP:	/* LAnd (Integer0, Integer1) */
21995b482a8SLen Brown 
22095b482a8SLen Brown 		if (integer0 && integer1) {
22195b482a8SLen Brown 			local_result = TRUE;
22295b482a8SLen Brown 		}
22395b482a8SLen Brown 		break;
22495b482a8SLen Brown 
2259ff5a21aSBob Moore 	case AML_LOGICAL_OR_OP:	/* LOr (Integer0, Integer1) */
22695b482a8SLen Brown 
22795b482a8SLen Brown 		if (integer0 || integer1) {
22895b482a8SLen Brown 			local_result = TRUE;
22995b482a8SLen Brown 		}
23095b482a8SLen Brown 		break;
23195b482a8SLen Brown 
23295b482a8SLen Brown 	default:
2331d1ea1b7SChao Guan 
234376a588cSBob Moore 		ACPI_ERROR((AE_INFO,
235376a588cSBob Moore 			    "Invalid numeric logical opcode: %X", opcode));
23695b482a8SLen Brown 		status = AE_AML_INTERNAL;
23795b482a8SLen Brown 		break;
23895b482a8SLen Brown 	}
23995b482a8SLen Brown 
24095b482a8SLen Brown 	/* Return the logical result and status */
24195b482a8SLen Brown 
24295b482a8SLen Brown 	*logical_result = local_result;
24395b482a8SLen Brown 	return_ACPI_STATUS(status);
24495b482a8SLen Brown }
24595b482a8SLen Brown 
24695b482a8SLen Brown /*******************************************************************************
24795b482a8SLen Brown  *
24895b482a8SLen Brown  * FUNCTION:    acpi_ex_do_logical_op
24995b482a8SLen Brown  *
250ba494beeSBob Moore  * PARAMETERS:  opcode              - AML opcode
251ba494beeSBob Moore  *              operand0            - operand #0
252ba494beeSBob Moore  *              operand1            - operand #1
25395b482a8SLen Brown  *              logical_result      - TRUE/FALSE result of the operation
25495b482a8SLen Brown  *
25595b482a8SLen Brown  * RETURN:      Status
25695b482a8SLen Brown  *
25795b482a8SLen Brown  * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
25895b482a8SLen Brown  *              functions here is to prevent a lot of pointer dereferencing
25995b482a8SLen Brown  *              to obtain the operands and to simplify the generation of the
26095b482a8SLen Brown  *              logical value. For the Numeric operators (LAnd and LOr), both
26195b482a8SLen Brown  *              operands must be integers. For the other logical operators,
26295b482a8SLen Brown  *              operands can be any combination of Integer/String/Buffer. The
26395b482a8SLen Brown  *              first operand determines the type to which the second operand
26495b482a8SLen Brown  *              will be converted.
26595b482a8SLen Brown  *
26695b482a8SLen Brown  *              Note: cleanest machine code seems to be produced by the code
26795b482a8SLen Brown  *              below, rather than using statements of the form:
26895b482a8SLen Brown  *                  Result = (Operand0 == Operand1);
26995b482a8SLen Brown  *
27095b482a8SLen Brown  ******************************************************************************/
27195b482a8SLen Brown 
27295b482a8SLen Brown acpi_status
acpi_ex_do_logical_op(u16 opcode,union acpi_operand_object * operand0,union acpi_operand_object * operand1,u8 * logical_result)27395b482a8SLen Brown acpi_ex_do_logical_op(u16 opcode,
27495b482a8SLen Brown 		      union acpi_operand_object *operand0,
27595b482a8SLen Brown 		      union acpi_operand_object *operand1, u8 * logical_result)
27695b482a8SLen Brown {
27795b482a8SLen Brown 	union acpi_operand_object *local_operand1 = operand1;
2785df7e6cbSBob Moore 	u64 integer0;
2795df7e6cbSBob Moore 	u64 integer1;
28095b482a8SLen Brown 	u32 length0;
28195b482a8SLen Brown 	u32 length1;
28295b482a8SLen Brown 	acpi_status status = AE_OK;
28395b482a8SLen Brown 	u8 local_result = FALSE;
28495b482a8SLen Brown 	int compare;
28595b482a8SLen Brown 
28695b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ex_do_logical_op);
28795b482a8SLen Brown 
28895b482a8SLen Brown 	/*
28995b482a8SLen Brown 	 * Convert the second operand if necessary. The first operand
29095b482a8SLen Brown 	 * determines the type of the second operand, (See the Data Types
29195b482a8SLen Brown 	 * section of the ACPI 3.0+ specification.)  Both object types are
29295b482a8SLen Brown 	 * guaranteed to be either Integer/String/Buffer by the operand
29395b482a8SLen Brown 	 * resolution mechanism.
29495b482a8SLen Brown 	 */
2953371c19cSBob Moore 	switch (operand0->common.type) {
29695b482a8SLen Brown 	case ACPI_TYPE_INTEGER:
2971d1ea1b7SChao Guan 
2985ebd2eaaSBob Moore 		status = acpi_ex_convert_to_integer(operand1, &local_operand1,
299fe97d287SBob Moore 						    ACPI_IMPLICIT_CONVERSION);
30095b482a8SLen Brown 		break;
30195b482a8SLen Brown 
30295b482a8SLen Brown 	case ACPI_TYPE_STRING:
3031d1ea1b7SChao Guan 
3041fad8738SBob Moore 		status =
3051fad8738SBob Moore 		    acpi_ex_convert_to_string(operand1, &local_operand1,
30695b482a8SLen Brown 					      ACPI_IMPLICIT_CONVERT_HEX);
30795b482a8SLen Brown 		break;
30895b482a8SLen Brown 
30995b482a8SLen Brown 	case ACPI_TYPE_BUFFER:
3101d1ea1b7SChao Guan 
31195b482a8SLen Brown 		status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
31295b482a8SLen Brown 		break;
31395b482a8SLen Brown 
31495b482a8SLen Brown 	default:
3151d1ea1b7SChao Guan 
316376a588cSBob Moore 		ACPI_ERROR((AE_INFO,
317376a588cSBob Moore 			    "Invalid object type for logical operator: %X",
318376a588cSBob Moore 			    operand0->common.type));
31995b482a8SLen Brown 		status = AE_AML_INTERNAL;
32095b482a8SLen Brown 		break;
32195b482a8SLen Brown 	}
32295b482a8SLen Brown 
32395b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
32495b482a8SLen Brown 		goto cleanup;
32595b482a8SLen Brown 	}
32695b482a8SLen Brown 
32795b482a8SLen Brown 	/*
32895b482a8SLen Brown 	 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
32995b482a8SLen Brown 	 */
3303371c19cSBob Moore 	if (operand0->common.type == ACPI_TYPE_INTEGER) {
33195b482a8SLen Brown 		/*
33295b482a8SLen Brown 		 * 1) Both operands are of type integer
33395b482a8SLen Brown 		 *    Note: local_operand1 may have changed above
33495b482a8SLen Brown 		 */
33595b482a8SLen Brown 		integer0 = operand0->integer.value;
33695b482a8SLen Brown 		integer1 = local_operand1->integer.value;
33795b482a8SLen Brown 
33895b482a8SLen Brown 		switch (opcode) {
3399ff5a21aSBob Moore 		case AML_LOGICAL_EQUAL_OP:	/* LEqual (Operand0, Operand1) */
34095b482a8SLen Brown 
34195b482a8SLen Brown 			if (integer0 == integer1) {
34295b482a8SLen Brown 				local_result = TRUE;
34395b482a8SLen Brown 			}
34495b482a8SLen Brown 			break;
34595b482a8SLen Brown 
3469ff5a21aSBob Moore 		case AML_LOGICAL_GREATER_OP:	/* LGreater (Operand0, Operand1) */
34795b482a8SLen Brown 
34895b482a8SLen Brown 			if (integer0 > integer1) {
34995b482a8SLen Brown 				local_result = TRUE;
35095b482a8SLen Brown 			}
35195b482a8SLen Brown 			break;
35295b482a8SLen Brown 
3539ff5a21aSBob Moore 		case AML_LOGICAL_LESS_OP:	/* LLess (Operand0, Operand1) */
35495b482a8SLen Brown 
35595b482a8SLen Brown 			if (integer0 < integer1) {
35695b482a8SLen Brown 				local_result = TRUE;
35795b482a8SLen Brown 			}
35895b482a8SLen Brown 			break;
35995b482a8SLen Brown 
36095b482a8SLen Brown 		default:
3611d1ea1b7SChao Guan 
362376a588cSBob Moore 			ACPI_ERROR((AE_INFO,
363376a588cSBob Moore 				    "Invalid comparison opcode: %X", opcode));
36495b482a8SLen Brown 			status = AE_AML_INTERNAL;
36595b482a8SLen Brown 			break;
36695b482a8SLen Brown 		}
36795b482a8SLen Brown 	} else {
36895b482a8SLen Brown 		/*
36995b482a8SLen Brown 		 * 2) Both operands are Strings or both are Buffers
37095b482a8SLen Brown 		 *    Note: Code below takes advantage of common Buffer/String
37195b482a8SLen Brown 		 *          object fields. local_operand1 may have changed above. Use
37295b482a8SLen Brown 		 *          memcmp to handle nulls in buffers.
37395b482a8SLen Brown 		 */
37495b482a8SLen Brown 		length0 = operand0->buffer.length;
37595b482a8SLen Brown 		length1 = local_operand1->buffer.length;
37695b482a8SLen Brown 
37795b482a8SLen Brown 		/* Lexicographic compare: compare the data bytes */
37895b482a8SLen Brown 
3794fa4616eSBob Moore 		compare = memcmp(operand0->buffer.pointer,
38095b482a8SLen Brown 				 local_operand1->buffer.pointer,
38195b482a8SLen Brown 				 (length0 > length1) ? length1 : length0);
38295b482a8SLen Brown 
38395b482a8SLen Brown 		switch (opcode) {
3849ff5a21aSBob Moore 		case AML_LOGICAL_EQUAL_OP:	/* LEqual (Operand0, Operand1) */
38595b482a8SLen Brown 
38695b482a8SLen Brown 			/* Length and all bytes must be equal */
38795b482a8SLen Brown 
38895b482a8SLen Brown 			if ((length0 == length1) && (compare == 0)) {
38995b482a8SLen Brown 
39095b482a8SLen Brown 				/* Length and all bytes match ==> TRUE */
39195b482a8SLen Brown 
39295b482a8SLen Brown 				local_result = TRUE;
39395b482a8SLen Brown 			}
39495b482a8SLen Brown 			break;
39595b482a8SLen Brown 
3969ff5a21aSBob Moore 		case AML_LOGICAL_GREATER_OP:	/* LGreater (Operand0, Operand1) */
39795b482a8SLen Brown 
39895b482a8SLen Brown 			if (compare > 0) {
39995b482a8SLen Brown 				local_result = TRUE;
40095b482a8SLen Brown 				goto cleanup;	/* TRUE */
40195b482a8SLen Brown 			}
40295b482a8SLen Brown 			if (compare < 0) {
40395b482a8SLen Brown 				goto cleanup;	/* FALSE */
40495b482a8SLen Brown 			}
40595b482a8SLen Brown 
40695b482a8SLen Brown 			/* Bytes match (to shortest length), compare lengths */
40795b482a8SLen Brown 
40895b482a8SLen Brown 			if (length0 > length1) {
40995b482a8SLen Brown 				local_result = TRUE;
41095b482a8SLen Brown 			}
41195b482a8SLen Brown 			break;
41295b482a8SLen Brown 
4139ff5a21aSBob Moore 		case AML_LOGICAL_LESS_OP:	/* LLess (Operand0, Operand1) */
41495b482a8SLen Brown 
41595b482a8SLen Brown 			if (compare > 0) {
41695b482a8SLen Brown 				goto cleanup;	/* FALSE */
41795b482a8SLen Brown 			}
41895b482a8SLen Brown 			if (compare < 0) {
41995b482a8SLen Brown 				local_result = TRUE;
42095b482a8SLen Brown 				goto cleanup;	/* TRUE */
42195b482a8SLen Brown 			}
42295b482a8SLen Brown 
42395b482a8SLen Brown 			/* Bytes match (to shortest length), compare lengths */
42495b482a8SLen Brown 
42595b482a8SLen Brown 			if (length0 < length1) {
42695b482a8SLen Brown 				local_result = TRUE;
42795b482a8SLen Brown 			}
42895b482a8SLen Brown 			break;
42995b482a8SLen Brown 
43095b482a8SLen Brown 		default:
4311d1ea1b7SChao Guan 
432376a588cSBob Moore 			ACPI_ERROR((AE_INFO,
433376a588cSBob Moore 				    "Invalid comparison opcode: %X", opcode));
43495b482a8SLen Brown 			status = AE_AML_INTERNAL;
43595b482a8SLen Brown 			break;
43695b482a8SLen Brown 		}
43795b482a8SLen Brown 	}
43895b482a8SLen Brown 
43995b482a8SLen Brown cleanup:
44095b482a8SLen Brown 
44195b482a8SLen Brown 	/* New object was created if implicit conversion performed - delete */
44295b482a8SLen Brown 
44395b482a8SLen Brown 	if (local_operand1 != operand1) {
44495b482a8SLen Brown 		acpi_ut_remove_reference(local_operand1);
44595b482a8SLen Brown 	}
44695b482a8SLen Brown 
44795b482a8SLen Brown 	/* Return the logical result and status */
44895b482a8SLen Brown 
44995b482a8SLen Brown 	*logical_result = local_result;
45095b482a8SLen Brown 	return_ACPI_STATUS(status);
45195b482a8SLen Brown }
452