diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exdyadic.c')
-rw-r--r-- | sys/contrib/dev/acpica/exdyadic.c | 193 |
1 files changed, 63 insertions, 130 deletions
diff --git a/sys/contrib/dev/acpica/exdyadic.c b/sys/contrib/dev/acpica/exdyadic.c index 546438328c8e..ef434a298388 100644 --- a/sys/contrib/dev/acpica/exdyadic.c +++ b/sys/contrib/dev/acpica/exdyadic.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exdyadic - ACPI AML execution for dyadic (2-operand) operators - * $Revision: 88 $ + * $Revision: 91 $ * *****************************************************************************/ @@ -314,8 +314,7 @@ Cleanup: * * FUNCTION: AcpiExDyadic1 * - * PARAMETERS: Opcode - The opcode to be executed - * WalkState - Current walk state + * PARAMETERS: WalkState - Current walk state * * RETURN: Status * @@ -328,7 +327,6 @@ Cleanup: ACPI_STATUS AcpiExDyadic1 ( - UINT16 Opcode, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; @@ -342,19 +340,17 @@ AcpiExDyadic1 ( /* Examine the opcode */ - switch (Opcode) + switch (WalkState->Opcode) { - /* DefNotify := NotifyOp (0)NotifyObject (1)NotifyValue */ - - case AML_NOTIFY_OP: + case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ - /* The ObjDesc is actually an Node */ + /* The first operand is a namespace node */ Node = (ACPI_NAMESPACE_NODE *) Operand[0]; Operand[0] = NULL; - /* Object must be a device or thermal zone */ + /* The node must refer to a device or thermal zone */ if (Node && Operand[1]) { @@ -376,7 +372,7 @@ AcpiExDyadic1 ( default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type %X\n", - Operand[0]->Common.Type)); + Node->Type)); Status = AE_AML_OPERAND_TYPE; break; @@ -386,12 +382,11 @@ AcpiExDyadic1 ( default: - REPORT_ERROR (("AcpiExDyadic1: Unknown dyadic opcode %X\n", Opcode)); + REPORT_ERROR (("AcpiExDyadic1: Unknown dyadic opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; } - /* Always delete both operands */ AcpiUtRemoveReference (Operand[1]); @@ -406,9 +401,7 @@ AcpiExDyadic1 ( * * FUNCTION: AcpiExDyadic2R * - * PARAMETERS: Opcode - The opcode to be executed - * WalkState - Current walk state - * ReturnDesc - Where to store the return object + * PARAMETERS: WalkState - Current walk state * * RETURN: Status * @@ -421,9 +414,7 @@ AcpiExDyadic1 ( ACPI_STATUS AcpiExDyadic2R ( - UINT16 Opcode, - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) + ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *RetDesc = NULL; @@ -431,12 +422,12 @@ AcpiExDyadic2R ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE_U32 ("ExDyadic2R", Opcode); + FUNCTION_TRACE_U32 ("ExDyadic2R", WalkState->Opcode); /* Create an internal return object if necessary */ - switch (Opcode) + switch (WalkState->Opcode) { case AML_ADD_OP: case AML_BIT_AND_OP: @@ -465,71 +456,56 @@ AcpiExDyadic2R ( /* * Execute the opcode */ - switch (Opcode) + switch (WalkState->Opcode) { - /* DefAdd := AddOp Operand1 Operand2 Result */ - - case AML_ADD_OP: + case AML_ADD_OP: /* Add (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value + Operand[1]->Integer.Value; break; - /* DefAnd := AndOp Operand1 Operand2 Result */ - - case AML_BIT_AND_OP: + case AML_BIT_AND_OP: /* And (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value & Operand[1]->Integer.Value; break; - /* DefNAnd := NAndOp Operand1 Operand2 Result */ - - case AML_BIT_NAND_OP: + case AML_BIT_NAND_OP: /* NAnd (Operand1, Operand2, Result) */ RetDesc->Integer.Value = ~(Operand[0]->Integer.Value & Operand[1]->Integer.Value); break; - /* DefOr := OrOp Operand1 Operand2 Result */ - - case AML_BIT_OR_OP: + case AML_BIT_OR_OP: /* Or (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value | Operand[1]->Integer.Value; break; - /* DefNOr := NOrOp Operand1 Operand2 Result */ - - case AML_BIT_NOR_OP: + case AML_BIT_NOR_OP: /* NOr (Operand1, Operand2, Result) */ RetDesc->Integer.Value = ~(Operand[0]->Integer.Value | Operand[1]->Integer.Value); break; - /* DefXOr := XOrOp Operand1 Operand2 Result */ - - case AML_BIT_XOR_OP: + case AML_BIT_XOR_OP: /* XOr (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value ^ Operand[1]->Integer.Value; break; - /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */ - - case AML_DIVIDE_OP: + case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, RemainderResult QuotientRsult) */ if (!Operand[1]->Integer.Value) { - REPORT_ERROR - (("DivideOp: Divide by zero\n")); + REPORT_ERROR (("DivideOp: Divide by zero\n")); Status = AE_AML_DIVIDE_BY_ZERO; goto Cleanup; @@ -542,77 +518,63 @@ AcpiExDyadic2R ( goto Cleanup; } - /* Remainder (modulo) */ - - RetDesc->Integer.Value = ACPI_MODULO (Operand[0]->Integer.Value, - Operand[1]->Integer.Value); - - /* Result (what we used to call the quotient) */ + /* + * RetDesc2 will contain the quotient, + * RetDesc will contain the remainder + */ + Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, + &RetDesc2->Integer.Value, &RetDesc->Integer.Value); - RetDesc2->Integer.Value = ACPI_DIVIDE (Operand[0]->Integer.Value, - Operand[1]->Integer.Value); break; - /* DefMod := ModOp Dividend Divisor Remainder */ - - case AML_MOD_OP: /* ACPI 2.0 */ + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ if (!Operand[1]->Integer.Value) { - REPORT_ERROR - (("ModOp: Divide by zero\n")); + REPORT_ERROR (("ModOp: Divide by zero\n")); Status = AE_AML_DIVIDE_BY_ZERO; goto Cleanup; } - /* Remainder (modulo) */ + /* RetDesc will contain the remainder */ - RetDesc->Integer.Value = ACPI_MODULO (Operand[0]->Integer.Value, - Operand[1]->Integer.Value); - break; + Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, + NULL, &RetDesc->Integer.Value); + break; - /* DefMultiply := MultiplyOp Operand1 Operand2 Result */ - case AML_MULTIPLY_OP: + case AML_MULTIPLY_OP: /* Multiply (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value * Operand[1]->Integer.Value; break; - /* DefShiftLeft := ShiftLeftOp Operand ShiftCount Result */ - - case AML_SHIFT_LEFT_OP: + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value << Operand[1]->Integer.Value; break; - /* DefShiftRight := ShiftRightOp Operand ShiftCount Result */ - - case AML_SHIFT_RIGHT_OP: + case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value >> Operand[1]->Integer.Value; break; - /* DefSubtract := SubtractOp Operand1 Operand2 Result */ - - case AML_SUBTRACT_OP: + case AML_SUBTRACT_OP: /* Subtract (Operand1, Operand2, Result) */ RetDesc->Integer.Value = Operand[0]->Integer.Value - Operand[1]->Integer.Value; break; - /* DefConcat := ConcatOp Data1 Data2 Result */ - - case AML_CONCAT_OP: + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ /* * Convert the second operand if necessary. The first operand @@ -644,7 +606,6 @@ AcpiExDyadic2R ( goto Cleanup; } - /* * Both operands are now known to be the same object type * (Both are Integer, String, or Buffer), and we can now perform the @@ -658,18 +619,14 @@ AcpiExDyadic2R ( break; - /* DefToString := Buffer, Length, Result */ - - case AML_TO_STRING_OP: /* ACPI 2.0 */ + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ Status = AcpiExConvertToString (Operand[0], &RetDesc, 16, (UINT32) Operand[1]->Integer.Value, WalkState); break; - /* DefConcatRes := Buffer, Buffer, Result */ - - case AML_CONCAT_RES_OP: /* ACPI 2.0 */ + case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ Status = AE_NOT_IMPLEMENTED; goto Cleanup; @@ -679,7 +636,7 @@ AcpiExDyadic2R ( default: REPORT_ERROR (("AcpiExDyadic2R: Unknown dyadic opcode %X\n", - Opcode)); + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -696,7 +653,7 @@ AcpiExDyadic2R ( goto Cleanup; } - if (AML_DIVIDE_OP == Opcode) + if (AML_DIVIDE_OP == WalkState->Opcode) { Status = AcpiExStore (RetDesc2, Operand[3], WalkState); @@ -705,12 +662,12 @@ AcpiExDyadic2R ( * the object we created earlier */ AcpiUtRemoveReference (RetDesc); - *ReturnDesc = RetDesc2; + WalkState->ResultObj = RetDesc2; } else { - *ReturnDesc = RetDesc; + WalkState->ResultObj = RetDesc; } @@ -750,9 +707,7 @@ Cleanup: * * FUNCTION: AcpiExDyadic2S * - * PARAMETERS: Opcode - The opcode to be executed - * WalkState - Current walk state - * ReturnDesc - Where to store the return object + * PARAMETERS: WalkState - Current walk state * * RETURN: Status * @@ -764,9 +719,7 @@ Cleanup: ACPI_STATUS AcpiExDyadic2S ( - UINT16 Opcode, - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) + ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *RetDesc = NULL; @@ -793,20 +746,16 @@ AcpiExDyadic2S ( /* Examine the opcode */ - switch (Opcode) + switch (WalkState->Opcode) { - /* DefAcquire := AcquireOp MutexObject Timeout */ - - case AML_ACQUIRE_OP: + case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); break; - /* DefWait := WaitOp AcpiEventObject Timeout */ - - case AML_WAIT_OP: + case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); break; @@ -814,7 +763,7 @@ AcpiExDyadic2S ( default: - REPORT_ERROR (("AcpiExDyadic2S: Unknown dyadic synchronization opcode %X\n", Opcode)); + REPORT_ERROR (("AcpiExDyadic2S: Unknown dyadic synchronization opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -850,7 +799,7 @@ Cleanup: /* Set the return object and exit */ - *ReturnDesc = RetDesc; + WalkState->ResultObj = RetDesc; return_ACPI_STATUS (Status); } @@ -859,9 +808,7 @@ Cleanup: * * FUNCTION: AcpiExDyadic2 * - * PARAMETERS: Opcode - The opcode to be executed - * WalkState - Current walk state - * ReturnDesc - Where to store the return object + * PARAMETERS: WalkState - Current walk state * * RETURN: Status * @@ -875,9 +822,7 @@ Cleanup: ACPI_STATUS AcpiExDyadic2 ( - UINT16 Opcode, - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) + ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *RetDesc = NULL; @@ -898,60 +843,48 @@ AcpiExDyadic2 ( } /* - * Execute the Opcode + * Execute the WalkState->Opcode */ Lboolean = FALSE; - switch (Opcode) + switch (WalkState->Opcode) { - /* DefLAnd := LAndOp Operand1 Operand2 */ - - case AML_LAND_OP: + case AML_LAND_OP: /* LAnd (Operand1, Operand2) */ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value && Operand[1]->Integer.Value); break; - /* DefLEqual := LEqualOp Operand1 Operand2 */ - - case AML_LEQUAL_OP: + case AML_LEQUAL_OP: /* LEqual (Operand1, Operand2) */ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value == Operand[1]->Integer.Value); break; - /* DefLGreater := LGreaterOp Operand1 Operand2 */ - - case AML_LGREATER_OP: + case AML_LGREATER_OP: /* LGreater (Operand1, Operand2) */ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value > Operand[1]->Integer.Value); break; - /* DefLLess := LLessOp Operand1 Operand2 */ - - case AML_LLESS_OP: + case AML_LLESS_OP: /* LLess (Operand1, Operand2) */ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value < Operand[1]->Integer.Value); break; - /* DefLOr := LOrOp Operand1 Operand2 */ - - case AML_LOR_OP: + case AML_LOR_OP: /* LOr (Operand1, Operand2) */ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value || Operand[1]->Integer.Value); break; - /* DefCopy := Source, Destination */ - - case AML_COPY_OP: /* ACPI 2.0 */ + case AML_COPY_OP: /* Copy (Source, Target) (ACPI 2.0) */ Status = AE_NOT_IMPLEMENTED; goto Cleanup; @@ -960,7 +893,7 @@ AcpiExDyadic2 ( default: - REPORT_ERROR (("AcpiExDyadic2: Unknown dyadic opcode %X\n", Opcode)); + REPORT_ERROR (("AcpiExDyadic2: Unknown dyadic opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; break; @@ -999,7 +932,7 @@ Cleanup: /* Set the return object and exit */ - *ReturnDesc = RetDesc; + WalkState->ResultObj = RetDesc; return_ACPI_STATUS (Status); } |