vendorcode/google/chromeos: Use explicit zero check in ACPI code

The ASL 2.0 syntax for "!X" resolves to "LNot(X)" which will evaluate
the object as an integer and turn into a boolean.  This may not do the
right thing if the object is actually a string and it can lead to
unexpected behavior.

Instead be specific about the object type and check for zero or an
empty string depending on what is being returned.

This fixes an issue where some VPD keys were causing the search to
stop and miss subsequent entries.

Change-Id: I1688842964f9c2f81ca31073da9c2d71a8c81767
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32694
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Duncan Laurie 2019-05-08 15:09:29 -06:00 committed by Duncan Laurie
parent 24047fefda
commit 643daed6b5
2 changed files with 7 additions and 6 deletions

View File

@ -42,6 +42,7 @@ Scope (\_SB)
/* Get "dock_passthru" value from RW_VPD */
Local0 = \VPD.VPDF ("RW", "dock_passthru")
Local1 = Zero
Switch (ToString (Local0))
{
Case ("ethernet_mac0") {
@ -55,7 +56,7 @@ Scope (\_SB)
Local1 = \VPD.VPDF ("RO", "dock_mac")
}
}
If (!Local1) {
If (Local1 == Zero) {
Return (Zero)
}
Printf ("MAC address returned from VPD: %o", Local1)

View File

@ -139,7 +139,7 @@ Device (VPD)
Local1 <<= 7
Local1 |= Local2 & 0x7f
}
If (!Local1) {
If (Local1 == Zero) {
Return (Zero)
}
@ -162,7 +162,7 @@ Device (VPD)
*/
Method (VPDS, 0, Serialized)
{
Name (VPKV, Package () { Zero, Zero })
Name (VPKV, Package () { "", "" })
/* Read the VPD type and ensure it is a string */
If (^VPRB () != ^VPES) {
@ -193,14 +193,14 @@ Device (VPD)
/* End address of VPD region */
^VEND = ^VPTR + DerefOf (Local0[1])
If (!^VPTR || !^VEND) {
If (^VPTR == Zero || ^VEND == Zero) {
Printf ("Unable to find VPD region")
Return (Zero)
}
/* Verify VPD info header and save size */
Local0 = VVPD (^VPTR)
If (!Local0) {
If (Local0 == Zero) {
Printf ("VPD region %o did not verify", Arg0)
Return (Zero)
}
@ -213,7 +213,7 @@ Device (VPD)
While (Local1 != ToString (Arg1)) {
Local2 = VPDS ()
Local1 = DerefOf (Local2[0])
If (!Local1) {
If (Local1 == "") {
Printf ("VPD KEY %o not found", Arg1)
Return (Zero)
}