From 95c2610b042b6209c30b108e744981c091f609e8 Mon Sep 17 00:00:00 2001 From: James Benton Date: Wed, 8 Jun 2016 00:20:34 +0100 Subject: [PATCH] Add coreinit OSGetSystemInfo. --- include/coreinit/systeminfo.h | 39 +++++++++++++++++++++++++++++++++++ rpl/libcoreinit/exports.h | 3 +++ 2 files changed, 42 insertions(+) create mode 100644 include/coreinit/systeminfo.h diff --git a/include/coreinit/systeminfo.h b/include/coreinit/systeminfo.h new file mode 100644 index 0000000..2b840fd --- /dev/null +++ b/include/coreinit/systeminfo.h @@ -0,0 +1,39 @@ +#pragma once +#include +#include "time.h" + +/** + * \defgroup coreinit_systeminfo System Info + * \ingroup coreinit + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OSSystemInfo OSSystemInfo; + +struct OSSystemInfo +{ + uint32_t clockSpeed; + UNKNOWN(0x4); + OSTime baseTime; + UNKNOWN(0x10); +}; +CHECK_OFFSET(OSSystemInfo, 0x0, clockSpeed); +CHECK_OFFSET(OSSystemInfo, 0x8, baseTime); +CHECK_SIZE(OSSystemInfo, 0x20); + + +#define OSOneSecond ((OSGetSystemInfo()->clockSpeed) / 4) +#define OSMilliseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000ull) + +OSSystemInfo * +OSGetSystemInfo(); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/rpl/libcoreinit/exports.h b/rpl/libcoreinit/exports.h index 642cfc7..6d8740a 100644 --- a/rpl/libcoreinit/exports.h +++ b/rpl/libcoreinit/exports.h @@ -214,6 +214,9 @@ EXPORT(OSUninterruptibleSpinLock_TryAcquire); EXPORT(OSUninterruptibleSpinLock_TryAcquireWithTimeout); EXPORT(OSUninterruptibleSpinLock_Release); +// coreinit/systeminfo.h +EXPORT(OSGetSystemInfo); + // coreinit/taskqueue.h EXPORT(MPInitTaskQ); EXPORT(MPTermTaskQ);