1/* 2 * Some or all of this work - Copyright (c) 2006 - 2016, Intel Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * Neither the name of Intel Corporation nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * Resource Descriptor macros 31 */ 32 33Name(z029, 29) 34Name(lpN0, 0) 35Name(lpC0, 0) 36 37Method(m330, 5) // ts, len, msg, op, res 38{ 39 40 Store(arg1, lpN0) 41 Store(0, lpC0) 42 43 While(lpN0) { 44 45 // Operand 46 47 Store(DeRefOf(Index(arg3, lpC0)), Local0) 48 49 // Expected result 50 51 Store(DeRefOf(Index(arg4, lpC0)), Local1) 52 53 if (LNotEqual(Local0, Local1)) { 54 err(arg0, z029, 0, 0, 0, lpC0, arg2) 55 } 56 57 Decrement(lpN0) 58 Increment(lpC0) 59 } 60 return (0) 61} 62 63Method(m331, 7) // ts, grerr, val0, ver0, val1, ver1, msg 64{ 65 if (LNotEqual(arg2, arg3)) { 66 err(arg0, z029, arg1, arg6, arg6, arg2, arg3) 67 } 68 if (LNotEqual(arg4, arg5)) { 69 err(arg0, z029, arg1, arg6, arg6, arg4, arg5) 70 } 71} 72 73Method(m332, 6, Serialized) // ts, len, msg, op1, op2, res 74{ 75 Name(lpN0, 0) 76 Name(lpC0, 0) 77 78 Store(arg1, lpN0) 79 Store(0, lpC0) 80 81 While(lpN0) { 82 83 // Operand 1 84 85 Store(DeRefOf(Index(arg3, lpC0)), Local0) 86 87 // Operand 2 88 89 Store(DeRefOf(Index(arg4, lpC0)), Local1) 90 91 // Expected result 92 93 Store(DeRefOf(Index(arg5, lpC0)), Local2) 94 95 Store(ConcatenateResTemplate(Local0, Local1), Local3) 96 97 98 if (LNotEqual(Local3, Local2)) { 99 Store(Local3, Debug) 100 Store(Local2, Debug) 101 err(arg0, z029, 3, 0, 0, lpC0, arg2) 102 } 103 104 Decrement(lpN0) 105 Increment(lpC0) 106 } 107 return (0) 108} 109 110// components/utilities/utmisc.c AcpiUtGenerateChecksum() analog 111Method(m335, 2, Serialized) // buf, len 112{ 113 Name(lpN0, 0) 114 Name(lpC0, 0) 115 116 Store(0, Local0) // sum 117 118 Store(arg1, lpN0) 119 Store(0, lpC0) 120 121 While(lpN0) { 122 Store(DeRefOf(Index(arg0, lpC0)), Local1) 123 Add(Local0, Local1, Local0) 124 Mod(Local0, 0x100, Local0) 125 Decrement(lpN0) 126 Increment(lpC0) 127 } 128 129 Subtract(0, Local0, Local0) 130 Mod(Local0, 0x100, Local0) 131 132 Store("checksum", Debug) 133 Store(Local0, Debug) 134 135 return (Local0) 136} 137 138// Updates the last byte of each buffer in package with checksum 139Method(m334, 2, Serialized) // pkg, len 140{ 141 Name(lpN0, 0) 142 Name(lpC0, 0) 143 144 Store(arg1, lpN0) 145 Store(0, lpC0) 146 147 While(lpN0) { 148 149 Store(DeRefOf(Index(arg0, lpC0)), Local1) 150 Store(SizeOf(Local1), Local2) 151 152 if (Local2) { 153 Decrement(Local2) 154 Store(m335(Local1, Local2), Local3) 155 Store(Local3, Index(Local1, Local2)) 156 Store(Local1, Index(arg0, lpC0)) 157 } 158 159 Decrement(lpN0) 160 Increment(lpC0) 161 } 162 163 return (0) 164} 165