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);