MCPcopy Create free account
hub / github.com/devkitPro/libctru / ndspWaitForIrq

Function ndspWaitForIrq

libctru/source/ndsp/ndsp.c:31–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29static Thread ndspThread;
30
31static inline bool ndspWaitForIrq(u64 timeout_ns)
32{
33 LightLock_Lock(&ndspMutex);
34
35 // BUG: Official sw has a race condition here when entering sleep mode. DSP state might
36 // have already been torn down, and thus this ends up waiting on an invalid (0) handle.
37 // There's code that tries to panic if an error happens, however said error handler fails
38 // to actually panic because it checks that the result code level is specifically 'Fatal'.
39 // Note that the "invalid handle" result code has a 'Permanent' level...
40 // We will instead handle invalid handles properly and immediately return.
41 bool waitOk = false;
42 if (irqEvent)
43 {
44 Result rc = svcWaitSynchronization(irqEvent, timeout_ns);
45 if (R_FAILED(rc))
46 svcBreak(USERBREAK_PANIC); // Shouldn't happen.
47
48 waitOk = R_DESCRIPTION(rc) != RD_TIMEOUT;
49 }
50
51 if (waitOk)
52 svcClearEvent(irqEvent);
53
54 LightLock_Unlock(&ndspMutex);
55 return waitOk;
56}
57
58static inline void ndspSetCounter(int a, int counter)
59{

Callers 2

ndspInitializeFunction · 0.85
ndspSyncFunction · 0.85

Calls 2

LightLock_LockFunction · 0.85
LightLock_UnlockFunction · 0.85

Tested by

no test coverage detected