ec/google/chromeec/acpi: Fix long battery string reporting for Windows
`ToString(byte x)` is undefined behavior per the ACPI spec, which causes Windows to discard the battery device status entirely. Fix this and improve performance of the BRSX method by using an array to store the characters read, calling ToString() only once at the end. TEST=build/boot Win11 and Linux on google/rex, verify battery status reported properly under both OSes. Change-Id: I4e5aea3b2763a3c4433abe95c3a41d218fcd06c1 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/89602 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com> Reviewed-by: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
parent
bc475414c7
commit
7afd731849
1 changed files with 10 additions and 4 deletions
|
|
@ -152,13 +152,19 @@ Method(BRSX, 1, Serialized)
|
|||
// Read to end of string, or up to a reasonable maximum length. Reads of
|
||||
// BSRF consume bytes from the FIFO, so take care to read it only once
|
||||
// per byte of data.
|
||||
Local0 = ""
|
||||
Local1 = BSRF
|
||||
While (Local1 != 0 && SizeOf (Local0) < 32)
|
||||
Local0 = Buffer (33){}
|
||||
For (Local2 = 0, Local2 < SizeOf(Local0) - 1, Local2++)
|
||||
{
|
||||
Local0 = Concatenate (Local0, ToString (Local1))
|
||||
Local1 = BSRF
|
||||
If (Local1 == 0)
|
||||
{
|
||||
Break
|
||||
}
|
||||
Local0[Local2] = Local1
|
||||
}
|
||||
|
||||
Local0[Local2] = 0
|
||||
Local0 = ToString(Local0)
|
||||
}
|
||||
|
||||
// Store the result in the cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue