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 * Synchronization (events) 31 */ 32 33/* 34!!!!!!!!!!!!!!!!!!!!!!!!!!!! 35SEE: shouls be a few updated 36!!!!!!!!!!!!!!!!!!!!!!!!!!!! 37*/ 38 39// The test for ASL-Events to be run on a single invocation only 40// 41// Note: additional checkings should be implemented to measure 42// the actual idle time provided by Wait operator according 43// to the time measuring provided by the Timer operator. 44 45// Pass TimeoutValues for Wait globally (all locals busy) 46Name(TOT0, 0) 47Name(TOT1, 0) 48Name(TOT2, 0) 49Name(TOT3, 0) 50 51// All events 52Event(EVT0) 53Event(EVT1) 54Event(EVT2) 55Event(EVT3) 56 57// Wait, expected Zero 58Method(m050, 5) 59{ 60 if (0) {Store("m050: Wait, expected Zero", Debug)} 61 62 if (arg1){CH00(arg0, 0x00, 0, Wait(EVT0, TOT0))} 63 if (arg2){CH00(arg0, 0x00, 1, Wait(EVT1, TOT1))} 64 if (arg3){CH00(arg0, 0x00, 2, Wait(EVT2, TOT2))} 65 if (arg4){CH00(arg0, 0x00, 3, Wait(EVT3, TOT3))} 66} 67 68// Wait, expected Non-Zero 69Method(m051, 5) 70{ 71 if (0) {Store("m051: Wait, expected Non-Zero", Debug)} 72 73 if (arg1){CH01(arg0, 0x01, 0, Wait(EVT0, TOT0))} 74 if (arg2){CH01(arg0, 0x01, 1, Wait(EVT1, TOT1))} 75 if (arg3){CH01(arg0, 0x01, 2, Wait(EVT2, TOT2))} 76 if (arg4){CH01(arg0, 0x01, 3, Wait(EVT3, TOT3))} 77} 78 79// Signal 80Method(m052, 5) 81{ 82 if (0) {Store("m052: Signal", Debug)} 83 84 if (arg1){Signal(EVT0)} 85 if (arg2){Signal(EVT1)} 86 if (arg3){Signal(EVT2)} 87 if (arg4){Signal(EVT3)} 88} 89 90// Reset 91Method(m053, 5) 92{ 93 if (0) {Store("m053: Reset", Debug)} 94 95 if (arg1){Reset(EVT0)} 96 if (arg2){Reset(EVT1)} 97 if (arg3){Reset(EVT2)} 98 if (arg4){Reset(EVT3)} 99} 100 101/* 102 * Package:={N lines} 103 * Line:= consists of 6 elements: 104 * 0: operation: 105 * 0 - Wait, expected Zero (acquired) 106 * 1 - Wait, expected Non-Zero (failed to acquire) 107 * 2 - Signal 108 * 3 - Reset 109 * 1: bit-mask of events operation to be applied to which 110 * bit 0x08 - 0th event 111 * bit 0x04 - 1th event 112 * bit 0x02 - 2th event 113 * bit 0x01 - 3th event 114 * 2-5: TimeoutValues for Wait operations (left->right too) 115 */ 116 Name(p011, Package() { 117 118 // 1. Wait without signals results in non-zero (failed to acquire) 119 // 2. Applied to all 4 event-Objects 120 121 1, 0x0f, 0x0000, 0x0001, 0x002, 0x00ff, 122 1, 0x0f, 0x0001, 0x0002, 0x003, 0x0004, 123 1, 0x0f, 0x0011, 0x0022, 0x033, 0x0000, 124 125 // 1. Send Ni signals to i-th Object. 126 // 2. All Ni events of i-th Object are successfully one 127 // by one acquired by Ni Waits applied to that Object. 128 // 3. But, attempt to acquire one more failed. 129 // 4. Applied to all 4 event-Objects. 130 131 2, 0x0f, 0, 0, 0, 0, 132 2, 0x0f, 0, 0, 0, 0, 133 2, 0x0f, 0, 0, 0, 0, 134 2, 0x0f, 0, 0, 0, 0, 135 0, 0x0f, 0xffff, 0xffff, 0xffff, 0xffff, 136 0, 0x0f, 0x8000, 0x4000, 0x2000, 0x1000, 137 0, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 138 0, 0x0f, 0xffff, 0xffff, 0xffff, 0xffff, 139 1, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 140 141 2, 0x0f, 0, 0, 0, 0, 142 2, 0x07, 0, 0, 0, 0, 143 2, 0x03, 0, 0, 0, 0, 144 2, 0x01, 0, 0, 0, 0, 145 0, 0x01, 0xffff, 0xffff, 0xffff, 0xffff, 146 0, 0x03, 0xffff, 0xffff, 0xffff, 0xffff, 147 0, 0x07, 0xffff, 0xffff, 0xffff, 0xffff, 148 0, 0x0f, 0xffff, 0xffff, 0xffff, 0xffff, 149 1, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 150 151 // 1. Send Ni_s signals to i-th Object. 152 // 2. Reset i-th object, one time. 153 // 3. Wait of i-th Object results in non-zero (failed to acquire) 154 // 4. Applied to all 4 event-Objects. 155 156 2, 0x0f, 0, 0, 0, 0, 157 2, 0x0f, 0, 0, 0, 0, 158 2, 0x0f, 0, 0, 0, 0, 159 2, 0x0f, 0, 0, 0, 0, 160 3, 0x0f, 0, 0, 0, 0, 161 1, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 162 1, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 163 164 2, 0x0f, 0, 0, 0, 0, 165 2, 0x0f, 0, 0, 0, 0, 166 2, 0x0f, 0, 0, 0, 0, 167 2, 0x0f, 0, 0, 0, 0, 168 3, 0x0a, 0, 0, 0, 0, 169 1, 0x0a, 0x0001, 0x0002, 0x0003, 0x0004, 170 0, 0x05, 0x0001, 0x0002, 0x0003, 0x0004, 171 0, 0x05, 0x0001, 0x0002, 0x0003, 0x0004, 172 0, 0x05, 0x0001, 0x0002, 0x0003, 0x0004, 173 0, 0x05, 0x0001, 0x0002, 0x0003, 0x0004, 174 1, 0x0f, 0x0001, 0x0002, 0x0003, 0x0004, 175 176 // For to track the current state only: 177 // Wait() allows TimeoutValue greater then 178 // 0xffff though cuts it to 16 bits. 179 180 1, 0x0f, 0x10000, 0x10000, 0x10000, 0x10000, 181 } 182) 183 184/* 185 * Run operations one by one in accordance with the table passed by arg2. 186 * arg1 - number of operations. 187 */ 188Method(m060, 4) 189{ 190 Store(0, Local7) 191 While(arg1) { 192 Multiply(Local7, 6, Local6) 193 Store(DeRefOf(Index(arg2, Local6)), Local5) 194 195 Increment(Local6) 196 Store(DeRefOf(Index(arg2, Local6)), Local1) 197 198 // TimeoutValues for Wait 199 200 Increment(Local6) 201 Store(DeRefOf(Index(arg2, Local6)), TOT0) 202 Increment(Local6) 203 Store(DeRefOf(Index(arg2, Local6)), TOT1) 204 Increment(Local6) 205 Store(DeRefOf(Index(arg2, Local6)), TOT2) 206 Increment(Local6) 207 Store(DeRefOf(Index(arg2, Local6)), TOT3) 208 209 // Local1 - run 0th event 210 Store(0, Local2) // run 1th event 211 Store(0, Local3) // run 2th event 212 Store(0, Local4) // run 3th event 213 214 if (And(Local1, 0x04)) { 215 Store(1, Local2) 216 } 217 if (And(Local1, 0x02)) { 218 Store(1, Local3) 219 } 220 if (And(Local1, 0x01)) { 221 Store(1, Local4) 222 } 223 if (And(Local1, 0x08)) { 224 Store(1, Local1) 225 } else { 226 Store(0, Local1) 227 } 228 229 if (LEqual(Local5, 0)) { 230 m050(arg0, Local1, Local2, Local3, Local4) 231 } else { 232 if (LEqual(Local5, 1)) { 233 m051(arg0, Local1, Local2, Local3, Local4) 234 } else { 235 if (LEqual(Local5, 2)) { 236 m052(arg0, Local1, Local2, Local3, Local4) 237 } else { 238 if (LEqual(Local5, 3)) { 239 m053(arg0, Local1, Local2, Local3, Local4) 240 } 241 } 242 } 243 } 244 245 Increment(Local7) 246 Decrement(arg1) 247 } 248} 249 250Method(WAI0,, Serialized) 251{ 252 Name(ts, "WAI0") 253 254 Store("TEST: WAI0, Wait for Events", Debug) 255 256 m060(ts, 40, p011, "p011") 257} 258 259// Run-method 260Method(EVN0) 261{ 262 Store("TEST: EVN0, Events", Debug) 263 264 WAI0() 265} 266 267 268