From c83ff22780dd545e60988a64dfe599e763af4845 Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 2 Jun 2017 11:40:41 +0100 Subject: [PATCH] coreinit: Move OSContext to context.h --- include/coreinit/context.h | 72 ++++++++++++++++++++++++++++++++++++ include/coreinit/exception.h | 1 + include/coreinit/thread.h | 60 +----------------------------- 3 files changed, 74 insertions(+), 59 deletions(-) create mode 100644 include/coreinit/context.h diff --git a/include/coreinit/context.h b/include/coreinit/context.h new file mode 100644 index 0000000..9548ada --- /dev/null +++ b/include/coreinit/context.h @@ -0,0 +1,72 @@ +#pragma once +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OSContext OSContext; + +#define OS_CONTEXT_TAG 0x4F53436F6E747874ull + +struct OSContext +{ + //! Should always be set to the value OS_CONTEXT_TAG. + uint64_t tag; + + uint32_t gpr[32]; + uint32_t cr; + uint32_t lr; + uint32_t ctr; + uint32_t xer; + uint32_t srr0; + uint32_t srr1; + UNKNOWN(0x14); + uint32_t fpscr; + double fpr[32]; + uint16_t spinLockCount; + uint16_t state; + uint32_t gqr[8]; + UNKNOWN(4); + double psf[32]; + uint64_t coretime[3]; + uint64_t starttime; + uint32_t error; + UNKNOWN(4); + uint32_t pmc1; + uint32_t pmc2; + uint32_t pmc3; + uint32_t pmc4; + uint32_t mmcr0; + uint32_t mmcr1; +}; +CHECK_OFFSET(OSContext, 0x00, tag); +CHECK_OFFSET(OSContext, 0x08, gpr); +CHECK_OFFSET(OSContext, 0x88, cr); +CHECK_OFFSET(OSContext, 0x8c, lr); +CHECK_OFFSET(OSContext, 0x90, ctr); +CHECK_OFFSET(OSContext, 0x94, xer); +CHECK_OFFSET(OSContext, 0x98, srr0); +CHECK_OFFSET(OSContext, 0x9c, srr1); +CHECK_OFFSET(OSContext, 0xb4, fpscr); +CHECK_OFFSET(OSContext, 0xb8, fpr); +CHECK_OFFSET(OSContext, 0x1b8, spinLockCount); +CHECK_OFFSET(OSContext, 0x1ba, state); +CHECK_OFFSET(OSContext, 0x1bc, gqr); +CHECK_OFFSET(OSContext, 0x1e0, psf); +CHECK_OFFSET(OSContext, 0x2e0, coretime); +CHECK_OFFSET(OSContext, 0x2f8, starttime); +CHECK_OFFSET(OSContext, 0x300, error); +CHECK_OFFSET(OSContext, 0x308, pmc1); +CHECK_OFFSET(OSContext, 0x30c, pmc2); +CHECK_OFFSET(OSContext, 0x310, pmc3); +CHECK_OFFSET(OSContext, 0x314, pmc4); +CHECK_OFFSET(OSContext, 0x318, mmcr0); +CHECK_OFFSET(OSContext, 0x31c, mmcr1); +CHECK_SIZE(OSContext, 0x320); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/include/coreinit/exception.h b/include/coreinit/exception.h index ec59607..02658f9 100644 --- a/include/coreinit/exception.h +++ b/include/coreinit/exception.h @@ -1,5 +1,6 @@ #pragma once #include +#include "context.h" /** * \defgroup coreinit_exception Exception Handling diff --git a/include/coreinit/thread.h b/include/coreinit/thread.h index 7e6779b..bff2581 100644 --- a/include/coreinit/thread.h +++ b/include/coreinit/thread.h @@ -1,5 +1,6 @@ #pragma once #include +#include "context.h" #include "time.h" #include "threadqueue.h" @@ -27,7 +28,6 @@ extern "C" { #endif -typedef struct OSContext OSContext; typedef struct OSFastMutex OSFastMutex; typedef struct OSFastMutexQueue OSFastMutexQueue; typedef struct OSMutex OSMutex; @@ -92,64 +92,6 @@ enum OS_THREAD_ATTRIB OS_THREAD_ATTRIB_STACK_USAGE = 1 << 5 }; -#define OS_CONTEXT_TAG 0x4F53436F6E747874ull - -struct OSContext -{ - //! Should always be set to the value OS_CONTEXT_TAG. - uint64_t tag; - - uint32_t gpr[32]; - uint32_t cr; - uint32_t lr; - uint32_t ctr; - uint32_t xer; - uint32_t srr0; - uint32_t srr1; - UNKNOWN(0x14); - uint32_t fpscr; - double fpr[32]; - uint16_t spinLockCount; - uint16_t state; - uint32_t gqr[8]; - UNKNOWN(4); - double psf[32]; - uint64_t coretime[3]; - uint64_t starttime; - uint32_t error; - UNKNOWN(4); - uint32_t pmc1; - uint32_t pmc2; - uint32_t pmc3; - uint32_t pmc4; - uint32_t mmcr0; - uint32_t mmcr1; -}; -CHECK_OFFSET(OSContext, 0x00, tag); -CHECK_OFFSET(OSContext, 0x08, gpr); -CHECK_OFFSET(OSContext, 0x88, cr); -CHECK_OFFSET(OSContext, 0x8c, lr); -CHECK_OFFSET(OSContext, 0x90, ctr); -CHECK_OFFSET(OSContext, 0x94, xer); -CHECK_OFFSET(OSContext, 0x98, srr0); -CHECK_OFFSET(OSContext, 0x9c, srr1); -CHECK_OFFSET(OSContext, 0xb4, fpscr); -CHECK_OFFSET(OSContext, 0xb8, fpr); -CHECK_OFFSET(OSContext, 0x1b8, spinLockCount); -CHECK_OFFSET(OSContext, 0x1ba, state); -CHECK_OFFSET(OSContext, 0x1bc, gqr); -CHECK_OFFSET(OSContext, 0x1e0, psf); -CHECK_OFFSET(OSContext, 0x2e0, coretime); -CHECK_OFFSET(OSContext, 0x2f8, starttime); -CHECK_OFFSET(OSContext, 0x300, error); -CHECK_OFFSET(OSContext, 0x308, pmc1); -CHECK_OFFSET(OSContext, 0x30c, pmc2); -CHECK_OFFSET(OSContext, 0x310, pmc3); -CHECK_OFFSET(OSContext, 0x314, pmc4); -CHECK_OFFSET(OSContext, 0x318, mmcr0); -CHECK_OFFSET(OSContext, 0x31c, mmcr1); -CHECK_SIZE(OSContext, 0x320); - struct OSMutexQueue { OSMutex *head;