| 357 | #define ROUND(n, a) (((u32)(n) + (a)-1) & ~((a)-1)) |
| 358 | |
| 359 | static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputBytes, |
| 360 | SICallback callback) |
| 361 | { |
| 362 | BOOL enabled; |
| 363 | u32 rLen; |
| 364 | u32 i; |
| 365 | u32 sr; |
| 366 | SIComm_u comcsr; |
| 367 | |
| 368 | enabled = OSDisableInterrupts(); |
| 369 | if (Si.chan != -1) |
| 370 | { |
| 371 | OSRestoreInterrupts(enabled); |
| 372 | return FALSE; |
| 373 | } |
| 374 | |
| 375 | sr = __SIRegs[14]; |
| 376 | sr &= (0xf000000) >> (8 * chan); |
| 377 | __SIRegs[14] = sr; |
| 378 | |
| 379 | Si.chan = chan; |
| 380 | Si.callback = callback; |
| 381 | Si.inputBytes = inputBytes; |
| 382 | Si.input = input; |
| 383 | |
| 384 | rLen = ROUND(outputBytes, 4) / 4; |
| 385 | for (i = 0; i < rLen; i++) |
| 386 | { |
| 387 | __SIRegs[32 + i] = ((u32*)output)[i]; |
| 388 | } |
| 389 | |
| 390 | comcsr.val = __SIRegs[13]; |
| 391 | comcsr.f.tcint = 1; |
| 392 | comcsr.f.tcintmsk = callback ? 1 : 0; |
| 393 | comcsr.f.outlngth = (outputBytes == SI_MAX_COMCSR_OUTLNGTH) ? 0 : outputBytes; |
| 394 | comcsr.f.inlngth = (inputBytes == SI_MAX_COMCSR_INLNGTH) ? 0 : inputBytes; |
| 395 | comcsr.f.channel = chan; |
| 396 | comcsr.f.tstart = 1; |
| 397 | __SIRegs[13] = comcsr.val; |
| 398 | |
| 399 | OSRestoreInterrupts(enabled); |
| 400 | |
| 401 | return TRUE; |
| 402 | } |
| 403 | |
| 404 | u32 SIGetStatus(s32 chan) |
| 405 | { |
no test coverage detected