1/* 2 * Copyright (C) 2008 Advanced Micro Devices, Inc. 3 * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com> 4 * 5 * Modified from coreboot src/arch/x86/acpi/globutil.asl 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ 9 10Method(MIN, 2) 11{ 12 If (LLess(Arg0, Arg1)) { 13 Return (Arg0) 14 } Else { 15 Return (Arg1) 16 } 17} 18 19Method(SLEN, 1) 20{ 21 Store(Arg0, Local0) 22 Return (Sizeof(Local0)) 23} 24 25Method(S2BF, 1, Serialized) 26{ 27 Add(SLEN(Arg0), One, Local0) 28 Name(BUFF, Buffer(Local0) {}) 29 Store(Arg0, BUFF) 30 Return (BUFF) 31} 32 33/* 34 * SCMP - Strong string compare 35 * 36 * Checks both length and content 37 */ 38Method(SCMP, 2) 39{ 40 Store(S2BF(Arg0), Local0) 41 Store(S2BF(Arg1), Local1) 42 Store(Zero, Local4) 43 Store(SLEN(Arg0), Local5) 44 Store(SLEN(Arg1), Local6) 45 Store(MIN(Local5, Local6), Local7) 46 47 While (LLess(Local4, Local7)) { 48 Store(Derefof(Index(Local0, Local4)), Local2) 49 Store(Derefof(Index(Local1, Local4)), Local3) 50 If (LGreater(Local2, Local3)) { 51 Return (One) 52 } Else { 53 If (LLess(Local2, Local3)) { 54 Return (Ones) 55 } 56 } 57 Increment(Local4) 58 } 59 60 If (LLess(Local4, Local5)) { 61 Return (One) 62 } Else { 63 If (LLess(Local4, Local6)) { 64 Return (Ones) 65 } Else { 66 Return (Zero) 67 } 68 } 69} 70 71/* 72 * WCMP - Weak string compare 73 * 74 * Checks to find Arg1 at beginning of Arg0. 75 * Fails if length(Arg0) < length(Arg1). 76 * Returns 0 on fail, 1 on pass. 77 */ 78Method(WCMP, 2) 79{ 80 Store(S2BF(Arg0), Local0) 81 Store(S2BF(Arg1), Local1) 82 If (LLess(SLEN(Arg0), SLEN(Arg1))) { 83 Return (Zero) 84 } 85 Store(Zero, Local2) 86 Store(SLEN(Arg1), Local3) 87 88 While (LLess(Local2, Local3)) { 89 If (LNotEqual(Derefof(Index(Local0, Local2)), 90 Derefof(Index(Local1, Local2)))) { 91 Return (Zero) 92 } 93 Increment(Local2) 94 } 95 96 Return (One) 97} 98 99/* 100 * I2BM - Returns Bit Map 101 * 102 * Arg0 = IRQ Number (0-15) 103 */ 104Method(I2BM, 1) 105{ 106 Store(0, Local0) 107 If (LNotEqual(Arg0, 0)) { 108 Store(1, Local1) 109 ShiftLeft(Local1, Arg0, Local0) 110 } 111 112 Return (Local0) 113} 114