]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add ResetType enum (and fixed many wrong ResetType usages)
authorfincs <fincs.alt1@gmail.com>
Fri, 1 Jul 2016 16:27:39 +0000 (18:27 +0200)
committerfincs <fincs.alt1@gmail.com>
Fri, 1 Jul 2016 16:27:39 +0000 (18:27 +0200)
libctru/include/3ds/svc.h
libctru/source/gfx.c
libctru/source/ndsp/ndsp.c
libctru/source/services/gspgpu.c
libctru/source/services/uds.c

index b953f5545826d9a46710a797e666252486bbb13f..6dfb6fad3d711091b7a22bd164805ca880badbbc 100644 (file)
@@ -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.
index f16ce27d20a2f4d7900e5a3d116a5b8ce057e316..2ce4455d42f150b6f074f20f9f303a310824f2dd 100644 (file)
@@ -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);
 
index 867eeb5aed348d2e71e686412d4c86e4f2ea8e1a..70c914c7c47f3519869920343ce257290e411441 100644 (file)
@@ -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);
index a4b3c0dac83345ba9434a915cf476fd6c660ec57..46278dc3883da9e5628f9f13683180efbd1c04d3 100644 (file)
@@ -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
index cf25708ad478d062c761220c51cc1d75066ffaf0..5a1236606ea7dd274a9c5b27b2cb501f510699f8 100644 (file)
@@ -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);