1/* 2 * Some or all of this work - Copyright (c) 2006 - 2021, 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 * Tests originated from bdemo/0262 31 */ 32 33Name(z162, 162) 34 35/* 36 * Bug 262 (Fiodor Suietov): 37 * 38 * SUMMARY: Unexpected AE_STACK_OVERFLOW for a method call expression with nested calls 39 */ 40Method(ms00,, Serialized) 41{ 42 Name(ts, "ms00") 43 44 Name(iad1, 0x1) 45 Name(iad2, 0x10) 46 Name(iad3, 0x100) 47 Name(iad4, 0x1000) 48 Name(iad5, 0x10000) 49 Name(iad6, 0x100000) 50 Name(iad7, 0x1000000) 51 52 Method(mad1, 1) {Return(Arg0)} 53 Method(mad7, 7) {Return(Add(Add(Add(Add(Add(Add(Arg0, Arg1), Arg2), Arg3), Arg4), Arg5), Arg6))} 54 55 Method(m000) 56 { 57 Store(mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 58 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 59 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 60 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 61 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 62 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 63 mad7(mad1(iad1), mad1(iad2), mad1(iad3), mad1(iad4), mad1(iad5), mad1(iad6), 64 mad1(iad7)))))))), Local0) 65 66 Store (Local0, Debug) 67 68 if (LNotEqual(Local0, 0x1777777)) { 69 err(ts, z162, __LINE__, 0, 0, Local0, 0x1777777) 70 } 71 } 72 73 CH03(ts, z162, 0x001, __LINE__, 0) 74 m000() 75 CH03(ts, z162, 0x002, __LINE__, 0) 76} 77 78/* 79 * This is how MS actually works 80 */ 81Method(ms01, 1, Serialized) 82{ 83 Name(ts, "ms01") 84 Name(i000, 0) 85 Name(b000, Buffer(9) {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}) 86 CreateField(b000, 0, 8, bf00) 87 88 Name(tp00, 0) 89 90 Method(m000, 1) 91 { 92 Store(ObjectType(arg0), Local0) 93 if (LNotEqual(Local0, tp00)) { 94 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 95 } 96 } 97 98 // This is how it should be: 99 Store(c009, tp00) 100 101 // This is how MS actually works: 102 Store(c00b, tp00) 103 104 105 Store(ObjectType(bf00), Local0) 106 if (LNotEqual(Local0, c016)) { 107 err(ts, z162, __LINE__, 0, 0, Local0, c016) 108 } 109 110 m000(bf00) 111 112 Store(bf00, i000) 113 Store(ObjectType(i000), Local0) 114 if (LNotEqual(Local0, c009)) { 115 err(ts, z162, __LINE__, 0, 0, Local0, c009) 116 } 117 118 Store(bf00, Local1) 119 Store(ObjectType(Local1), Local0) 120 if (LNotEqual(Local0, tp00)) { 121 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 122 } 123 124 Store(bf00, arg0) 125 Store(ObjectType(arg0), Local0) 126 if (LNotEqual(Local0, tp00)) { 127 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 128 } 129} 130 131/* 132 * This is how MS actually works 133 */ 134Method(ms02, 1, Serialized) 135{ 136 Name(ts, "ms02") 137 Name(i000, 0) 138 OperationRegion(r000, SystemMemory, 0x100, 0x100) 139 Field(r000, ByteAcc, NoLock, Preserve) { f000, 8 } 140 141 Name(tp00, 0) 142 143 Method(m000, 1) 144 { 145 Store(ObjectType(arg0), Local0) 146 if (LNotEqual(Local0, tp00)) { 147 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 148 } 149 } 150 151 Store(c009, tp00) 152 153 Store(ObjectType(f000), Local0) 154 if (LNotEqual(Local0, c00d)) { 155 err(ts, z162, __LINE__, 0, 0, Local0, c00d) 156 } 157 158 m000(f000) 159 160 Store(f000, i000) 161 Store(ObjectType(i000), Local0) 162 if (LNotEqual(Local0, c009)) { 163 err(ts, z162, __LINE__, 0, 0, Local0, c009) 164 } 165 166 Store(f000, Local1) 167 Store(ObjectType(Local1), Local0) 168 if (LNotEqual(Local0, tp00)) { 169 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 170 } 171 172 Store(f000, arg0) 173 Store(ObjectType(arg0), Local0) 174 if (LNotEqual(Local0, tp00)) { 175 err(ts, z162, __LINE__, 0, 0, Local0, tp00) 176 } 177} 178 179/* 180 * Bug 275: 181 * 182 * SUMMARY: Pop result from bottom principle doesn't work 183 */ 184Method(ms03,, Serialized) 185{ 186 Name(i000, 0x11000000) 187 Name(i001, 0x00220000) 188 Name(p000, Package () {0xabcd0000, 0xabcd0001, 0xabcd0002}) 189 190 Method(m000) 191 { 192 Return (p000) 193 } 194 195 Method(m001, 1) 196 { 197 Return (0xabcd0003) 198 } 199 200 Method(m002, 2) 201 { 202 Index(arg0, 1, Local0) 203 Store(DerefOf(Local0), Local1) 204 205 if (LNotEqual(Local1, 0xabcd0001)) { 206 err("ms03", z162, __LINE__, 0, 0, Local0, c00d) 207 } 208 } 209 210 // Works correctly: 211 m002(p000, 0xabcd0004) 212 m002(m000(), 0xabcd0004) 213 m002(p000, m001(Add(i000, i001))) 214 215 // Works incorrectly (bug 275): 216 m002(m000(), m001(Add(i000, i001))) 217} 218 219Method(msff) 220{ 221 SRMT("ms00") 222 if (y262) { 223 ms00() 224 } else { 225 BLCK() 226 } 227 228 SRMT("ms01") 229 ms01(0) 230 SRMT("ms02") 231 ms02(0) 232 SRMT("ms03") 233 if (y275) { 234 ms03() 235 } else { 236 BLCK() 237 } 238} 239