From 2f6a28f1e36601dd01e46029baf6528cc5458612 Mon Sep 17 00:00:00 2001 From: fincs Date: Fri, 1 Jul 2016 18:27:39 +0200 Subject: [PATCH] Add ResetType enum (and fixed many wrong ResetType usages) --- libctru/include/3ds/svc.h | 13 ++++++++++--- libctru/source/gfx.c | 2 +- libctru/source/ndsp/ndsp.c | 4 ++-- libctru/source/services/gspgpu.c | 2 +- libctru/source/services/uds.c | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libctru/include/3ds/svc.h b/libctru/include/3ds/svc.h index b953f55..6dfb6fa 100644 --- a/libctru/include/3ds/svc.h +++ b/libctru/include/3ds/svc.h @@ -90,6 +90,13 @@ typedef enum { ///@name Multithreading ///@{ +/// Reset types (for use with events and timers) +typedef enum { + RESET_ONESHOT = 0, ///< When the primitive is signaled, it will wake up exactly one thread and will clear itself automatically. + RESET_STICKY = 1, ///< When the primitive is signaled, it will wake up all threads and it won't clear itself automatically. + RESET_PULSE = 2, ///< Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just once. +} ResetType; + /// Types of thread info. typedef enum { THREADINFO_TYPE_UNKNOWN ///< Unknown. @@ -741,9 +748,9 @@ Result svcReleaseSemaphore(s32* count, Handle semaphore, s32 release_count); /** * @brief Creates an event handle. * @param[out] event Pointer to output the created event handle to. - * @param reset_type Type of reset the event uses. + * @param reset_type Type of reset the event uses (RESET_ONESHOT/RESET_STICKY). */ -Result svcCreateEvent(Handle* event, u8 reset_type); +Result svcCreateEvent(Handle* event, ResetType reset_type); /** * @brief Signals an event. @@ -846,7 +853,7 @@ Result svcUnbindInterrupt(u32 interruptId, Handle event); * @param[out] timer Pointer to output the handle of the created timer to. * @param reset_type Type of reset to perform on the timer. */ -Result svcCreateTimer(Handle* timer, u8 reset_type); +Result svcCreateTimer(Handle* timer, ResetType reset_type); /** * @brief Sets a timer. diff --git a/libctru/source/gfx.c b/libctru/source/gfx.c index f16ce27..2ce4455 100644 --- a/libctru/source/gfx.c +++ b/libctru/source/gfx.c @@ -129,7 +129,7 @@ void gfxInit(GSPGPU_FramebufferFormats topFormat, GSPGPU_FramebufferFormats bott GSPGPU_AcquireRight(0x0); //setup our gsp shared mem section - svcCreateEvent(&gspEvent, 0x0); + svcCreateEvent(&gspEvent, RESET_ONESHOT); GSPGPU_RegisterInterruptRelayQueue(gspEvent, 0x1, &gspSharedMemHandle, &gfxThreadID); svcMapMemoryBlock(gspSharedMemHandle, (u32)gfxSharedMemory, 0x3, 0x10000000); diff --git a/libctru/source/ndsp/ndsp.c b/libctru/source/ndsp/ndsp.c index 867eeb5..70c914c 100644 --- a/libctru/source/ndsp/ndsp.c +++ b/libctru/source/ndsp/ndsp.c @@ -211,7 +211,7 @@ static Result ndspInitialize(bool resume) rc = ndspLoadComponent(); if (R_FAILED(rc)) return rc; - rc = svcCreateEvent(&irqEvent, 1); + rc = svcCreateEvent(&irqEvent, RESET_STICKY); if (R_FAILED(rc)) goto _fail1; rc = DSP_RegisterInterruptEvents(irqEvent, 2, 2); @@ -479,7 +479,7 @@ Result ndspInit(void) rc = ndspInitialize(false); if (R_FAILED(rc)) goto _fail1; - rc = svcCreateEvent(&sleepEvent, 0); + rc = svcCreateEvent(&sleepEvent, RESET_STICKY); if (R_FAILED(rc)) goto _fail2; ndspThread = threadCreate(ndspThreadMain, 0x0, NDSP_THREAD_STACK_SIZE, 0x18, -2, true); diff --git a/libctru/source/services/gspgpu.c b/libctru/source/services/gspgpu.c index a4b3c0d..46278dc 100644 --- a/libctru/source/services/gspgpu.c +++ b/libctru/source/services/gspgpu.c @@ -57,7 +57,7 @@ Result gspInitEventHandler(Handle _gspEvent, vu8* _gspSharedMem, u8 gspThreadId) int i; for (i = 0; i < GSPGPU_EVENT_MAX; i ++) { - Result rc = svcCreateEvent(&gspEvents[i], 0); + Result rc = svcCreateEvent(&gspEvents[i], RESET_STICKY); if (rc != 0) { // Destroy already created events due to failure diff --git a/libctru/source/services/uds.c b/libctru/source/services/uds.c index cf25708..5a12366 100644 --- a/libctru/source/services/uds.c +++ b/libctru/source/services/uds.c @@ -481,7 +481,7 @@ Result udsScanBeacons(void *buf, size_t maxsize, udsNetworkScanInfo **networks, if(maxsize < sizeof(nwmBeaconDataReplyHeader))return -2; - ret = svcCreateEvent(&event, 0); + ret = svcCreateEvent(&event, RESET_ONESHOT); if(R_FAILED(ret))return ret; if(!connected)ret = udsipc_RecvBeaconBroadcastData(outbuf, maxsize, &scaninput, wlancommID, id8, event);