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 * Synchronization (events) 30 */ 31 /* 32 !!!!!!!!!!!!!!!!!!!!!!!!!!!! 33 SEE: should be a few updated 34 !!!!!!!!!!!!!!!!!!!!!!!!!!!! 35 */ 36 /* The test for ASL-Events to be run on a single invocation only */ 37 /* */ 38 /* Note: additional checkings should be implemented to measure */ 39 /* the actual idle time provided by Wait operator according */ 40 /* to the time measuring provided by the Timer operator. */ 41 /* Pass TimeoutValues for Wait globally (all locals busy) */ 42 Name (TOT0, 0x00) 43 Name (TOT1, 0x00) 44 Name (TOT2, 0x00) 45 Name (TOT3, 0x00) 46 /* All events */ 47 48 Event (EVT0) 49 Event (EVT1) 50 Event (EVT2) 51 Event (EVT3) 52 /* Wait, expected Zero */ 53 54 Method (M050, 5, NotSerialized) 55 { 56 If (0x00) 57 { 58 Debug = "m050: Wait, expected Zero" 59 } 60 61 If (Arg1) 62 { 63 CH00 (Arg0, 0x00, 0x00, Wait (EVT0, TOT0)) 64 } 65 66 If (Arg2) 67 { 68 CH00 (Arg0, 0x00, 0x01, Wait (EVT1, TOT1)) 69 } 70 71 If (Arg3) 72 { 73 CH00 (Arg0, 0x00, 0x02, Wait (EVT2, TOT2)) 74 } 75 76 If (Arg4) 77 { 78 CH00 (Arg0, 0x00, 0x03, Wait (EVT3, TOT3)) 79 } 80 } 81 82 /* Wait, expected Non-Zero */ 83 84 Method (M051, 5, NotSerialized) 85 { 86 If (0x00) 87 { 88 Debug = "m051: Wait, expected Non-Zero" 89 } 90 91 If (Arg1) 92 { 93 CH01 (Arg0, 0x01, 0x00, Wait (EVT0, TOT0)) 94 } 95 96 If (Arg2) 97 { 98 CH01 (Arg0, 0x01, 0x01, Wait (EVT1, TOT1)) 99 } 100 101 If (Arg3) 102 { 103 CH01 (Arg0, 0x01, 0x02, Wait (EVT2, TOT2)) 104 } 105 106 If (Arg4) 107 { 108 CH01 (Arg0, 0x01, 0x03, Wait (EVT3, TOT3)) 109 } 110 } 111 112 /* Signal */ 113 114 Method (M052, 5, NotSerialized) 115 { 116 If (0x00) 117 { 118 Debug = "m052: Signal" 119 } 120 121 If (Arg1) 122 { 123 Signal (EVT0) 124 } 125 126 If (Arg2) 127 { 128 Signal (EVT1) 129 } 130 131 If (Arg3) 132 { 133 Signal (EVT2) 134 } 135 136 If (Arg4) 137 { 138 Signal (EVT3) 139 } 140 } 141 142 /* Reset */ 143 144 Method (M053, 5, NotSerialized) 145 { 146 If (0x00) 147 { 148 Debug = "m053: Reset" 149 } 150 151 If (Arg1) 152 { 153 Reset (EVT0) 154 } 155 156 If (Arg2) 157 { 158 Reset (EVT1) 159 } 160 161 If (Arg3) 162 { 163 Reset (EVT2) 164 } 165 166 If (Arg4) 167 { 168 Reset (EVT3) 169 } 170 } 171 172 /* 173 * Package:={N lines} 174 * Line:= consists of 6 elements: 175 * 0: operation: 176 * 0 - Wait, expected Zero (acquired) 177 * 1 - Wait, expected Non-Zero (failed to acquire) 178 * 2 - Signal 179 * 3 - Reset 180 * 1: bit-mask of events operation to be applied to which 181 * bit 0x08 - 0th event 182 * bit 0x04 - 1th event 183 * bit 0x02 - 2th event 184 * bit 0x01 - 3th event 185 * 2-5: TimeoutValues for Wait operations (left->right too) 186 */ 187 Name (P011, Package (0xF0) 188 { 189 /* 1. Wait without signals results in non-zero (failed to acquire) */ 190 /* 2. Applied to all 4 event-Objects */ 191 0x01, 192 0x0F, 193 0x00, 194 0x01, 195 0x02, 196 0xFF, 197 0x01, 198 0x0F, 199 0x01, 200 0x02, 201 0x03, 202 0x04, 203 0x01, 204 0x0F, 205 0x11, 206 0x22, 207 0x33, 208 0x00, 209 /* 1. Send Ni signals to i-th Object. */ 210 /* 2. All Ni events of i-th Object are successfully one */ 211 /* by one acquired by Ni Waits applied to that Object. */ 212 /* 3. But, attempt to acquire one more failed. */ 213 /* 4. Applied to all 4 event-Objects. */ 214 0x02, 215 0x0F, 216 0x00, 217 0x00, 218 0x00, 219 0x00, 220 0x02, 221 0x0F, 222 0x00, 223 0x00, 224 0x00, 225 0x00, 226 0x02, 227 0x0F, 228 0x00, 229 0x00, 230 0x00, 231 0x00, 232 0x02, 233 0x0F, 234 0x00, 235 0x00, 236 0x00, 237 0x00, 238 0x00, 239 0x0F, 240 0xFFFF, 241 0xFFFF, 242 0xFFFF, 243 0xFFFF, 244 0x00, 245 0x0F, 246 0x8000, 247 0x4000, 248 0x2000, 249 0x1000, 250 0x00, 251 0x0F, 252 0x01, 253 0x02, 254 0x03, 255 0x04, 256 0x00, 257 0x0F, 258 0xFFFF, 259 0xFFFF, 260 0xFFFF, 261 0xFFFF, 262 0x01, 263 0x0F, 264 0x01, 265 0x02, 266 0x03, 267 0x04, 268 0x02, 269 0x0F, 270 0x00, 271 0x00, 272 0x00, 273 0x00, 274 0x02, 275 0x07, 276 0x00, 277 0x00, 278 0x00, 279 0x00, 280 0x02, 281 0x03, 282 0x00, 283 0x00, 284 0x00, 285 0x00, 286 0x02, 287 0x01, 288 0x00, 289 0x00, 290 0x00, 291 0x00, 292 0x00, 293 0x01, 294 0xFFFF, 295 0xFFFF, 296 0xFFFF, 297 0xFFFF, 298 0x00, 299 0x03, 300 0xFFFF, 301 0xFFFF, 302 0xFFFF, 303 0xFFFF, 304 0x00, 305 0x07, 306 0xFFFF, 307 0xFFFF, 308 0xFFFF, 309 0xFFFF, 310 0x00, 311 0x0F, 312 0xFFFF, 313 0xFFFF, 314 0xFFFF, 315 0xFFFF, 316 0x01, 317 0x0F, 318 0x01, 319 0x02, 320 0x03, 321 0x04, 322 /* 1. Send Ni_s signals to i-th Object. */ 323 /* 2. Reset i-th object, one time. */ 324 /* 3. Wait of i-th Object results in non-zero (failed to acquire) */ 325 /* 4. Applied to all 4 event-Objects. */ 326 0x02, 327 0x0F, 328 0x00, 329 0x00, 330 0x00, 331 0x00, 332 0x02, 333 0x0F, 334 0x00, 335 0x00, 336 0x00, 337 0x00, 338 0x02, 339 0x0F, 340 0x00, 341 0x00, 342 0x00, 343 0x00, 344 0x02, 345 0x0F, 346 0x00, 347 0x00, 348 0x00, 349 0x00, 350 0x03, 351 0x0F, 352 0x00, 353 0x00, 354 0x00, 355 0x00, 356 0x01, 357 0x0F, 358 0x01, 359 0x02, 360 0x03, 361 0x04, 362 0x01, 363 0x0F, 364 0x01, 365 0x02, 366 0x03, 367 0x04, 368 0x02, 369 0x0F, 370 0x00, 371 0x00, 372 0x00, 373 0x00, 374 0x02, 375 0x0F, 376 0x00, 377 0x00, 378 0x00, 379 0x00, 380 0x02, 381 0x0F, 382 0x00, 383 0x00, 384 0x00, 385 0x00, 386 0x02, 387 0x0F, 388 0x00, 389 0x00, 390 0x00, 391 0x00, 392 0x03, 393 0x0A, 394 0x00, 395 0x00, 396 0x00, 397 0x00, 398 0x01, 399 0x0A, 400 0x01, 401 0x02, 402 0x03, 403 0x04, 404 0x00, 405 0x05, 406 0x01, 407 0x02, 408 0x03, 409 0x04, 410 0x00, 411 0x05, 412 0x01, 413 0x02, 414 0x03, 415 0x04, 416 0x00, 417 0x05, 418 0x01, 419 0x02, 420 0x03, 421 0x04, 422 0x00, 423 0x05, 424 0x01, 425 0x02, 426 0x03, 427 0x04, 428 0x01, 429 0x0F, 430 0x01, 431 0x02, 432 0x03, 433 0x04, 434 /* For to track the current state only: */ 435 /* Wait() allows TimeoutValue greater then */ 436 /* 0xffff though cuts it to 16 bits. */ 437 0x01, 438 0x0F, 439 0x00010000, 440 0x00010000, 441 0x00010000, 442 0x00010000 443 }) 444 /* 445 * Run operations one by one in accordance with the table passed by arg2. 446 * arg1 - number of operations. 447 */ 448 Method (M060, 4, NotSerialized) 449 { 450 Local7 = 0x00 451 While (Arg1) 452 { 453 Local6 = (Local7 * 0x06) 454 Local5 = DerefOf (Arg2 [Local6]) 455 Local6++ 456 Local1 = DerefOf (Arg2 [Local6]) 457 /* TimeoutValues for Wait */ 458 459 Local6++ 460 TOT0 = DerefOf (Arg2 [Local6]) 461 Local6++ 462 TOT1 = DerefOf (Arg2 [Local6]) 463 Local6++ 464 TOT2 = DerefOf (Arg2 [Local6]) 465 Local6++ 466 TOT3 = DerefOf (Arg2 [Local6]) 467 /* Local1 - run 0th event */ 468 469 Local2 = 0x00 /* run 1th event */ 470 Local3 = 0x00 /* run 2th event */ 471 Local4 = 0x00 /* run 3th event */ 472 If ((Local1 & 0x04)) 473 { 474 Local2 = 0x01 475 } 476 477 If ((Local1 & 0x02)) 478 { 479 Local3 = 0x01 480 } 481 482 If ((Local1 & 0x01)) 483 { 484 Local4 = 0x01 485 } 486 487 If ((Local1 & 0x08)) 488 { 489 Local1 = 0x01 490 } 491 Else 492 { 493 Local1 = 0x00 494 } 495 496 If ((Local5 == 0x00)) 497 { 498 M050 (Arg0, Local1, Local2, Local3, Local4) 499 } 500 ElseIf ((Local5 == 0x01)) 501 { 502 M051 (Arg0, Local1, Local2, Local3, Local4) 503 } 504 ElseIf ((Local5 == 0x02)) 505 { 506 M052 (Arg0, Local1, Local2, Local3, Local4) 507 } 508 ElseIf ((Local5 == 0x03)) 509 { 510 M053 (Arg0, Local1, Local2, Local3, Local4) 511 } 512 513 Local7++ 514 Arg1-- 515 } 516 } 517 518 Method (WAI0, 0, Serialized) 519 { 520 Debug = "TEST: WAI0, Wait for Events" 521 M060 (__METHOD__, 0x28, P011, "p011") 522 } 523 524 /* Run-method */ 525 526 Method (EVN0, 0, NotSerialized) 527 { 528 Debug = "TEST: EVN0, Events" 529 WAI0 () 530 } 531