wut  v1.7.0
Wii U Toolchain
kernel.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <coreinit/exception.h>
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 typedef enum OSICICommand {
29  OS_ICI_COMMAND_UNKNOWN = 0xE, // Waits for rendezvous, then updates heartbeat
32 
33 typedef void (*OSExceptionCallbackExFn)(OSExceptionType exceptionType, OSContext * interruptedContext, OSContext *cbContext);
34 
35 typedef void (*KernelTimerCallbackFn)(OSExceptionType exception, OSContext *interruptedContext, OSContext *currentContext);
36 
37 typedef uint32_t KernelTimerHandle;
38 
39 typedef struct OSExceptionChainInfo {
41  void *stack;
44 WUT_CHECK_OFFSET(OSExceptionChainInfo, 0, callback);
45 WUT_CHECK_OFFSET(OSExceptionChainInfo, 4, stack);
46 WUT_CHECK_OFFSET(OSExceptionChainInfo, 8, context);
47 WUT_CHECK_SIZE(OSExceptionChainInfo, 12);
48 
49 typedef struct KernelInfo0 {
50  struct CoreinitInfo {
51  void *loaderHandle;
52  void *textAddr;
53  uint32_t textOffset;
54  uint32_t textSize;
55  void *dataAddr;
56  uint32_t dataOffset;
57  uint32_t dataSize;
58  void *loadAddr;
59  uint32_t loadOffset;
60  uint32_t loadSize;
61  };
62 
63  int32_t upid;
64  int32_t rampid;
65  uint32_t appFlags;
67  void *dataAreaEnd;
71  void *physAvailEnd;
74  void *sdaBase;
75  void *sda2Base;
76  uint32_t systemHeapSize;
77  void *stackEnd0;
78  void *stackEnd1;
79  void *stackEnd2;
80  void *stackBase0;
81  void *stackBase1;
82  void *stackBase2;
92  struct CoreinitInfo coreinit;
93  uint32_t unk0x9C;
94  uint64_t titleId;
96 WUT_CHECK_OFFSET(KernelInfo0, 0x00, upid);
97 WUT_CHECK_OFFSET(KernelInfo0, 0x04, rampid);
98 WUT_CHECK_OFFSET(KernelInfo0, 0x08, appFlags);
99 WUT_CHECK_OFFSET(KernelInfo0, 0x0C, dataAreaStart);
100 WUT_CHECK_OFFSET(KernelInfo0, 0x10, dataAreaEnd);
101 WUT_CHECK_OFFSET(KernelInfo0, 0x14, physDataAreaStart);
102 WUT_CHECK_OFFSET(KernelInfo0, 0x18, physDataAreaEnd);
103 WUT_CHECK_OFFSET(KernelInfo0, 0x1C, physAvailStart);
104 WUT_CHECK_OFFSET(KernelInfo0, 0x20, physAvailEnd);
105 WUT_CHECK_OFFSET(KernelInfo0, 0x24, physCodeGenStart);
106 WUT_CHECK_OFFSET(KernelInfo0, 0x28, physCodeGenEnd);
107 WUT_CHECK_OFFSET(KernelInfo0, 0x2C, sdaBase);
108 WUT_CHECK_OFFSET(KernelInfo0, 0x30, sda2Base);
109 WUT_CHECK_OFFSET(KernelInfo0, 0x34, systemHeapSize);
110 WUT_CHECK_OFFSET(KernelInfo0, 0x38, stackEnd0);
111 WUT_CHECK_OFFSET(KernelInfo0, 0x3C, stackEnd1);
112 WUT_CHECK_OFFSET(KernelInfo0, 0x40, stackEnd2);
113 WUT_CHECK_OFFSET(KernelInfo0, 0x44, stackBase0);
114 WUT_CHECK_OFFSET(KernelInfo0, 0x48, stackBase1);
115 WUT_CHECK_OFFSET(KernelInfo0, 0x4C, stackBase2);
116 WUT_CHECK_OFFSET(KernelInfo0, 0x50, exceptionStackEnd0);
117 WUT_CHECK_OFFSET(KernelInfo0, 0x54, exceptionStackEnd1);
118 WUT_CHECK_OFFSET(KernelInfo0, 0x58, exceptionStackEnd2);
119 WUT_CHECK_OFFSET(KernelInfo0, 0x5C, exceptionStackBase0);
120 WUT_CHECK_OFFSET(KernelInfo0, 0x60, exceptionStackBase1);
121 WUT_CHECK_OFFSET(KernelInfo0, 0x64, exceptionStackBase2);
122 WUT_CHECK_OFFSET(KernelInfo0, 0x68, lockedCacheBase0);
123 WUT_CHECK_OFFSET(KernelInfo0, 0x6C, lockedCacheBase1);
124 WUT_CHECK_OFFSET(KernelInfo0, 0x70, lockedCacheBase2);
125 WUT_CHECK_OFFSET(KernelInfo0, 0x74, coreinit);
126 WUT_CHECK_OFFSET(KernelInfo0, 0x9C, unk0x9C);
127 WUT_CHECK_OFFSET(KernelInfo0, 0xA0, titleId);
128 WUT_CHECK_SIZE(KernelInfo0, 0xA8);
129 
130 typedef struct KernelInfo6 {
131  uint64_t osTitleId;
132  uint32_t unk0x08;
133  WUT_PADDING_BYTES(0x108 - 0xC);
135 WUT_CHECK_OFFSET(KernelInfo6, 0x00, osTitleId);
136 WUT_CHECK_OFFSET(KernelInfo6, 0x08, unk0x08);
137 WUT_CHECK_SIZE(KernelInfo6, 0x108);
138 
140 
142 uint32_t __KernelPrimeTimer(KernelTimerHandle handle, uint64_t startTimeInTicks, uint64_t intervalInTicks, uint32_t unknown);
143 
144 void __KernelSendICI(OSICICommand cmd, void *arg1, uint32_t unknown1, uint32_t unknown2);
145 
146 void __KernelGetInfo(uint32_t type, void *outBuffer, uint32_t outBufferSize, uint32_t core);
147 
148 static inline void
149 __KernelGetInfo0(KernelInfo0 *outBuffer, uint32_t core)
150 {
151  __KernelGetInfo(0, outBuffer, sizeof(KernelInfo0), core);
152 }
153 
154 static inline void
155 __KernelGetInfo6(KernelInfo6 *outBuffer, uint32_t core)
156 {
157  __KernelGetInfo(6, outBuffer, sizeof(KernelInfo6), core);
158 }
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 
OSExceptionType
Definition: exception.h:27
uint64_t titleId
Definition: kernel.h:94
void * stackEnd0
Definition: kernel.h:77
void * lockedCacheBase0
Definition: kernel.h:89
void * stackBase2
Definition: kernel.h:82
void * stackEnd1
Definition: kernel.h:78
void * stackBase1
Definition: kernel.h:81
void * dataAreaStart
Definition: kernel.h:66
void * stackBase0
Definition: kernel.h:80
void * physCodeGenStart
Definition: kernel.h:72
int32_t upid
Definition: kernel.h:63
uint32_t systemHeapSize
Definition: kernel.h:76
void * exceptionStackBase1
Definition: kernel.h:87
void * physAvailEnd
Definition: kernel.h:71
void * sda2Base
Definition: kernel.h:75
void * exceptionStackBase2
Definition: kernel.h:88
OSContext * context
Definition: kernel.h:42
void * physDataAreaStart
Definition: kernel.h:68
uint32_t unk0x9C
Definition: kernel.h:93
OSExceptionCallbackExFn callback
Definition: kernel.h:40
void * lockedCacheBase2
Definition: kernel.h:91
int32_t rampid
Definition: kernel.h:64
void * exceptionStackEnd0
Definition: kernel.h:83
void * physCodeGenEnd
Definition: kernel.h:73
uint32_t unk0x08
Definition: kernel.h:132
struct CoreinitInfo coreinit
Definition: kernel.h:92
uint64_t osTitleId
Definition: kernel.h:131
void * exceptionStackBase0
Definition: kernel.h:86
void * lockedCacheBase1
Definition: kernel.h:90
void * stackEnd2
Definition: kernel.h:79
void * physAvailStart
Definition: kernel.h:70
void * dataAreaEnd
Definition: kernel.h:67
uint32_t appFlags
Definition: kernel.h:65
void * exceptionStackEnd1
Definition: kernel.h:84
void * exceptionStackEnd2
Definition: kernel.h:85
void * physDataAreaEnd
Definition: kernel.h:69
void * sdaBase
Definition: kernel.h:74
void __KernelGetInfo(uint32_t type, void *outBuffer, uint32_t outBufferSize, uint32_t core)
uint32_t __KernelPrimeTimer(KernelTimerHandle handle, uint64_t startTimeInTicks, uint64_t intervalInTicks, uint32_t unknown)
struct KernelInfo6 KernelInfo6
struct KernelInfo0 KernelInfo0
void __KernelSetUserModeExHandler(OSExceptionType exceptionType, OSExceptionChainInfo *chainInfo, OSExceptionChainInfo *prevChainInfo)
OSICICommand
Definition: kernel.h:15
void(* OSExceptionCallbackExFn)(OSExceptionType exceptionType, OSContext *interruptedContext, OSContext *cbContext)
Definition: kernel.h:33
void(* KernelTimerCallbackFn)(OSExceptionType exception, OSContext *interruptedContext, OSContext *currentContext)
Definition: kernel.h:35
static void __KernelGetInfo6(KernelInfo6 *outBuffer, uint32_t core)
Definition: kernel.h:155
uint32_t KernelTimerHandle
Definition: kernel.h:37
void __KernelSendICI(OSICICommand cmd, void *arg1, uint32_t unknown1, uint32_t unknown2)
KernelTimerHandle __KernelAllocateTimer(KernelTimerCallbackFn, void *exceptionStack, OSContext *context)
struct OSExceptionChainInfo OSExceptionChainInfo
static void __KernelGetInfo0(KernelInfo0 *outBuffer, uint32_t core)
Definition: kernel.h:149
@ OS_ICI_COMMAND_IOP_SHELL_CORE_TRACE
Definition: kernel.h:23
@ OS_ICI_COMMAND_PROC_KILL
Definition: kernel.h:27
@ OS_ICI_COMMAND_RESCHEDULE_CORE
Definition: kernel.h:17
@ OS_ICI_COMMAND_PROC_EXIT
Definition: kernel.h:19
@ OS_ICI_COMMAND_PANIC_0X15
Definition: kernel.h:26
@ OS_ICI_COMMAND_UNKNOWN
Definition: kernel.h:29
@ OS_ICI_COMMAND_INVALID_IC_RANGE
Definition: kernel.h:16
@ OS_ICI_COMMAND_OVERLAY_ARENA
Definition: kernel.h:30
@ OS_ICI_COMMAND_PROC_CRASH
Definition: kernel.h:28
@ OS_ICI_COMMAND_SYSTEM_FATAL
Definition: kernel.h:24
@ OS_ICI_COMMAND_SET_DABR
Definition: kernel.h:20
@ OS_ICI_COMMAND_HALT_CORE
Definition: kernel.h:18
@ OS_ICI_COMMAND_FAST_BG_EXIT
Definition: kernel.h:22
@ OS_ICI_COMMAND_PROC_SCHED
Definition: kernel.h:21
@ OS_ICI_COMMAND_SET_IABR
Definition: kernel.h:25