diff --git a/include/coreinit/baseheap.h b/include/coreinit/baseheap.h index 3c62b2a..fd83ee8 100644 --- a/include/coreinit/baseheap.h +++ b/include/coreinit/baseheap.h @@ -11,15 +11,14 @@ extern "C" { #endif -typedef uint32_t MEMBaseHeapType; typedef void *MEMHeapHandle; -enum MEMBaseHeapType +typedef enum MEMBaseHeapType { MEM_BASE_HEAP_MEM1 = 0, MEM_BASE_HEAP_MEM2 = 1, MEM_BASE_HEAP_FG = 8, -}; +} MEMBaseHeapType; MEMBaseHeapType MEMGetArena(MEMHeapHandle handle); diff --git a/include/coreinit/event.h b/include/coreinit/event.h index 9600195..0395271 100644 --- a/include/coreinit/event.h +++ b/include/coreinit/event.h @@ -18,16 +18,15 @@ extern "C" { #endif typedef struct OSEvent OSEvent; -typedef uint32_t OSEventMode; -enum OSEventMode +typedef enum OSEventMode { //! A manual event will only reset when OSResetEvent is called. OS_EVENT_MODE_MANUAL = 0, //! An auto event will reset everytime a thread is woken. OS_EVENT_MODE_AUTO = 1, -}; +} OSEventMode; #define OS_EVENT_TAG 0x65566E54u diff --git a/include/coreinit/exception.h b/include/coreinit/exception.h index e000bce..d0ec70a 100644 --- a/include/coreinit/exception.h +++ b/include/coreinit/exception.h @@ -14,7 +14,7 @@ extern "C" { typedef uint32_t OSExceptionType; typedef BOOL (*OSExceptionCallbackFn)(OSContext *context); -enum OSExceptionType +typedef enum OSExceptionType { OS_EXCEPTION_TYPE_SYSTEM_RESET = 0, OS_EXCEPTION_TYPE_MACHINE_CHECK = 1, @@ -31,7 +31,7 @@ enum OSExceptionType OS_EXCEPTION_TYPE_BREAKPOINT = 12, OS_EXCEPTION_TYPE_SYSTEM_INTERRUPT = 13, OS_EXCEPTION_TYPE_ICI = 14, -}; +} OSExceptionType; OSExceptionCallbackFn OSSetExceptionCallback(OSExceptionType exceptionType, diff --git a/include/coreinit/expandedheap.h b/include/coreinit/expandedheap.h index 0c3b8d6..b6293eb 100644 --- a/include/coreinit/expandedheap.h +++ b/include/coreinit/expandedheap.h @@ -11,27 +11,24 @@ extern "C" { #endif -typedef struct MEMExpandedHeap MEMExpandedHeap; - -typedef uint32_t MEMExpHeapMode; -typedef uint32_t MEMExpHeapDirection; +typedef struct MEMExpandedHeap MEMExpandedHeap;; struct MEMExpandedHeap { }; UNKNOWN_SIZE(MEMExpandedHeap); -enum MEMExpHeapMode +typedef enum MEMExpHeapMode { MEM_EXP_HEAP_MODE_FIRST_FREE = 0, MEM_EXP_HEAP_MODE_NEAREST_SIZE = 1, -}; +} MEMExpHeapMode; -enum MEMExpHeapDirection +typedef enum MEMExpHeapDirection { MEM_EXP_HEAP_DIR_FROM_TOP = 0, MEM_EXP_HEAP_DIR_FROM_BOTTOM = 1, -}; +} MEMExpHeapDirection; MEMExpandedHeap * MEMCreateExpHeap(MEMExpandedHeap *heap, uint32_t size); diff --git a/include/coreinit/frameheap.h b/include/coreinit/frameheap.h index eeaaa64..6e8ce04 100644 --- a/include/coreinit/frameheap.h +++ b/include/coreinit/frameheap.h @@ -11,13 +11,11 @@ extern "C" { #endif -typedef uint32_t MEMFrameHeapFreeMode; - -enum MEMFrameHeapFreeMode +typedef enum MEMFrameHeapFreeMode { MEM_FRAME_HEAP_FREE_FROM_BOTTOM = 1 << 0, MEM_FRAME_HEAP_FREE_FROM_TOP = 1 << 1, -}; +} MEMFrameHeapFreeMode; MEMFrameHeap * MEMCreateFrmHeap(MEMFrameHeap *heap, diff --git a/include/coreinit/messagequeue.h b/include/coreinit/messagequeue.h index 713e4e1..c81fe4f 100644 --- a/include/coreinit/messagequeue.h +++ b/include/coreinit/messagequeue.h @@ -11,13 +11,11 @@ extern "C" { #endif -typedef uint32_t OSMessageFlags; - -enum OSMessageFlags +typedef enum OSMessageFlags { OS_MESSAGE_QUEUE_BLOCKING = 1 << 0, OS_MESSAGE_QUEUE_HIGH_PRIORITY = 1 << 1, -}; +} OSMessageFlags; struct OSMessage { diff --git a/include/coreinit/taskqueue.h b/include/coreinit/taskqueue.h index 2bef9d5..4a15b23 100644 --- a/include/coreinit/taskqueue.h +++ b/include/coreinit/taskqueue.h @@ -17,17 +17,15 @@ typedef struct MPTaskInfo MPTaskInfo; typedef struct MPTaskQueue MPTaskQueue; typedef struct MPTaskQueueInfo MPTaskQueueInfo; -typedef uint32_t MPTaskState; - typedef uint32_t (*MPTaskFunc)(uint32_t, uint32_t); -enum MPTaskState +typedef enum MPTaskState { MP_TASK_STATE_INITIALISED = 1 << 0, MP_TASK_STATE_READY = 1 << 1, MP_TASK_STATE_RUNNING = 1 << 2, MP_TASK_STATE_FINISHED = 1 << 3, -}; +} MPTaskState; struct MPTaskInfo { diff --git a/include/coreinit/thread.h b/include/coreinit/thread.h index 492e9be..7e6779b 100644 --- a/include/coreinit/thread.h +++ b/include/coreinit/thread.h @@ -34,15 +34,20 @@ typedef struct OSMutex OSMutex; typedef struct OSMutexQueue OSMutexQueue; typedef struct OSThread OSThread; +//! A value from enum OS_THREAD_STATE. typedef uint8_t OSThreadState; + +//! A value from enum OS_THREAD_REQUEST. typedef uint32_t OSThreadRequest; + +//! A bitfield of enum OS_THREAD_ATTRIB. typedef uint8_t OSThreadAttributes; typedef int (*OSThreadEntryPointFn)(int argc, const char **argv); typedef void (*OSThreadCleanupCallbackFn)(OSThread *thread, void *stack); typedef void (*OSThreadDeallocatorFn)(OSThread *thread, void *stack); -enum OSThreadState +enum OS_THREAD_STATE { OS_THREAD_STATE_NONE = 0, @@ -59,14 +64,14 @@ enum OSThreadState OS_THREAD_STATE_MORIBUND = 1 << 3, }; -enum OSThreadRequest +enum OS_THREAD_REQUEST { OS_THREAD_REQUEST_NONE = 0, OS_THREAD_REQUEST_SUSPEND = 1, OS_THREAD_REQUEST_CANCEL = 2, }; -enum OSThreadAttributes +enum OS_THREAD_ATTRIB { //! Allow the thread to run on CPU0. OS_THREAD_ATTRIB_AFFINITY_CPU0 = 1 << 0, @@ -167,13 +172,21 @@ CHECK_OFFSET(OSFastMutexQueue, 0x04, tail); CHECK_SIZE(OSFastMutexQueue, 0x08); #define OS_THREAD_TAG 0x74487244u - +#pragma pack(push, 1) struct OSThread { OSContext context; + + //! Should always be set to the value OS_THREAD_TAG. uint32_t tag; + + //! Bitfield of OS_THREAD_STATE OSThreadState state; + + //! Bitfield of OS_THREAD_ATTRIB OSThreadAttributes attr; + + //! Unique thread ID uint16_t id; //! Suspend count (increased by OSSuspendThread). @@ -252,8 +265,10 @@ struct OSThread //! Queue of threads waiting for a thread to be suspended. OSThreadQueue suspendQueue; + UNKNOWN(0x69c - 0x5f4); }; +#pragma pack(pop) CHECK_OFFSET(OSThread, 0x320, tag); CHECK_OFFSET(OSThread, 0x324, state); CHECK_OFFSET(OSThread, 0x325, attr); diff --git a/include/gx2/state.h b/include/gx2/state.h index 0f6d4b2..8aefb99 100644 --- a/include/gx2/state.h +++ b/include/gx2/state.h @@ -11,16 +11,14 @@ extern "C" { #endif -typedef uint32_t GX2InitAttributes; - -enum GX2InitAttributes +typedef enum GX2InitAttributes { GX2_INIT_END = 0, GX2_INIT_CMD_BUF_BASE = 1, GX2_INIT_CMD_BUF_POOL_SIZE = 2, GX2_INIT_ARGC = 7, GX2_INIT_ARGV = 8, -}; +} GX2InitAttributes; void GX2Init(uint32_t *attributes);