Repository navigation
aml: Fix Divide argument order, and report error in division by zero - #375
Merged
Merged
Conversation
DefOpDivide is Divide (Dividend, Divisor, Remainder, Result): the third operand is the remainder's target and the fourth the quotient's. They were swapped, so `Divide (17, 5, Local0, Local1)` or `X = A / B` stored the remainder where the quotient was expected. Divide has its own function now, as it has two targets: do_binary_maths is back to (left, right, target). Dividing by zero (Divide or Mod) is a new AmlError::DivideByZero (ACPICA's AE_AML_DIVIDE_BY_ZERO) instead of a panic.
Contributor
|
Good find @ogoffart and thank you for the fix! Looks good to me with no particular comments. I appreciate the tests, thanks again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Divideswaps its two targetsI ran into this while using
acpito read a laptop's battery state: we run the firmware's own AML (_BST/_BIXon the battery devices). The result were nonsense.Tracing it down, the firmware's methods do things like
Local0 = Local1 / Local2, and we were getting the remainder back instead of the quotient.DefOpDivide is Divide (Dividend, Divisor, Remainder, Result): the third operand is the remainder's target and the fourth the quotient's. They were swapped, so
Divide (17, 5, Local0, Local1)orX = A / Bstored the remainder where the quotient was expected.Divide has its own function now, as it has two targets: do_binary_maths is back to (left, right, target). Dividing by zero (Divide or Mod) is a new AmlError::DivideByZero (ACPICA's AE_AML_DIVIDE_BY_ZERO) instead of a panic.