From 297a0d70683507b1402e951a52aea505d1d29ac6 Mon Sep 17 00:00:00 2001 From: James Benton Date: Thu, 7 Jan 2016 13:32:55 +0000 Subject: [PATCH] Add messagequeue functions --- include/coreinit/messagequeue.h | 82 +++++++++++++++++++++++++++++++++ rpl/libcoreinit/exports.h | 9 ++++ 2 files changed, 91 insertions(+) create mode 100644 include/coreinit/messagequeue.h diff --git a/include/coreinit/messagequeue.h b/include/coreinit/messagequeue.h new file mode 100644 index 0000000..127b952 --- /dev/null +++ b/include/coreinit/messagequeue.h @@ -0,0 +1,82 @@ +#pragma once +#include + +WUT_LIB_HEADER_START + +typedef uint32_t OSMessageFlags; + +enum OSMessageFlags +{ + OS_MESSAGE_QUEUE_BLOCKING = 1 << 0, + OS_MESSAGE_QUEUE_HIGH_PRIORITY = 1 << 1, +}; + +struct OSMessage +{ + void *message; + uint32_t args[3]; +}; +CHECK_OFFSET(OSMessage, 0x00, message); +CHECK_OFFSET(OSMessage, 0x04, args); +CHECK_SIZE(OSMessage, 0x10); + +#define OS_MESSAGE_QUEUE_TAG 0x6D536751u + +struct OSMessageQueue +{ + uint32_t tag; + const char *name; + UNKNOWN(4); + OSThreadQueue sendQueue; + OSThreadQueue recvQueue; + OSMessage *messages; + uint32_t size; + uint32_t first; + uint32_t used; +}; +CHECK_OFFSET(OSMessageQueue, 0x00, tag); +CHECK_OFFSET(OSMessageQueue, 0x04, name); +CHECK_OFFSET(OSMessageQueue, 0x0c, sendQueue); +CHECK_OFFSET(OSMessageQueue, 0x1c, recvQueue); +CHECK_OFFSET(OSMessageQueue, 0x2c, messages); +CHECK_OFFSET(OSMessageQueue, 0x30, size); +CHECK_OFFSET(OSMessageQueue, 0x34, first); +CHECK_OFFSET(OSMessageQueue, 0x38, used); +CHECK_SIZE(OSMessageQueue, 0x3c); + +#pragma pack(pop) + +void +OSInitMessageQueue(OSMessageQueue *queue, + OSMessage *messages, + int32_t size); + +void +OSInitMessageQueueEx(OSMessageQueue *queue, + OSMessage *messages, + int32_t size, + const char *name); + +BOOL +OSSendMessage(OSMessageQueue *queue, + OSMessage *message, + OSMessageFlags flags); + +BOOL +OSJamMessage(OSMessageQueue *queue, + OSMessage *message, + OSMessageFlags flags); + +BOOL +OSReceiveMessage(OSMessageQueue *queue, + OSMessage *message, + OSMessageFlags flags); + +BOOL +OSPeekMessage(OSMessageQueue *queue, + OSMessage *message); + +OSMessageQueue * +OSGetSystemMessageQueue(); + +WUT_LIB_HEADER_END diff --git a/rpl/libcoreinit/exports.h b/rpl/libcoreinit/exports.h index fa59040..d559866 100644 --- a/rpl/libcoreinit/exports.h +++ b/rpl/libcoreinit/exports.h @@ -137,6 +137,15 @@ EXPORT(MEMGetNextListObject); EXPORT(MEMGetPrevListObject); EXPORT(MEMGetNthListObject); +// coreinit/messagequeue.h +EXPORT(OSInitMessageQueue); +EXPORT(OSInitMessageQueueEx); +EXPORT(OSSendMessage); +EXPORT(OSJamMessage); +EXPORT(OSReceiveMessage); +EXPORT(OSPeekMessage); +EXPORT(OSGetSystemMessageQueue); + // coreinit/mutex.h EXPORT(OSInitMutex); EXPORT(OSInitMutexEx);