Difference between revisions of "Coreinit.rpl"

From WiiUBrew
Jump to navigation Jump to search
m (Fixed a grammar mistake)
(The purpose of DCInvalidateRange is to change what the processor sees in memory i.e. the data is variable. This is backed up by the fact that if you feed it write protected (const) memory it will throw an exception.)
Line 13: Line 13:
 
|-
 
|-
 
|DCInvalidateRange
 
|DCInvalidateRange
|<code>void DCInvalidateRange(const void *addr, size_t length);</code>  
+
|<code>void DCInvalidateRange(void *addr, size_t length);</code>  
 
|Invalidate the specified data cache blocks
 
|Invalidate the specified data cache blocks
 
|-
 
|-

Revision as of 16:30, 7 April 2015

coreinit.rpl is the the system library that provides direct access to Cafe OS services. It provides kernel calls, thread scheduling, memory management, and filesystem services. coreinit is the first RPL loaded by the loader, even before the main executable itself.

Functions

Cache

Name Prototype Description
DCFlushRange void DCFlushRange(const void *addr, size_t length); Flush the specified data cache blocks to memory
DCInvalidateRange void DCInvalidateRange(void *addr, size_t length); Invalidate the specified data cache blocks
ICInvalidateRange void ICInvalidateRange(const void *addr, size_t length); Invalidate the specified instruction cache blocks

Dynamic Linking

Name Prototype Description
OSDynLoad_Acquire void OSDynLoad_Acquire(const char *rplname, uint32_t *handle); Acquire a handle to an RPL by name
OSDynLoad_FindExport void OSDynLoad_FindExport(uint32_t handle, bool isdata, const char *symname, void **address); Get a symbol address from a loaded RPL

Error

Name Prototype Description
OSFatal void OSFatal(const char *msg); Print a message to the screen and halts the system

Internal

Name Prototype Description
__os_snprintf int __os_snprintf(char *buf, size_t n, const char *format, ... ); Format a string and place it in a buffer (just like snprintf())

Threads

Name Prototype Description
OSCreateThread bool OSCreateThread(OSThread *thread, void (*entry)(int,void*), int argc, void *args, void *stack, size_t stack_size, int32_t priority, int16_t affinity); Create a (initially-paused) thread that starts at the specified entry point
OSResumeThread void OSResumeThread(OSThread *thread); Resume a paused thread, causing it to be scheduled
OSYieldThread void OSYieldThread(void); Yield control of the CPU, allowing another thread to run

Structures

Threads

Name Prototype
OSThread
typedef struct {
    char tag[8];                     /* 0x000 "OSContxt" */
    int32_t gpr[32];                 /* 0x008 from OSDumpContext */
    uint32_t cr;                     /* 0x088 from OSDumpContext */
    uint32_t lr;                     /* 0x08c from OSDumpContext */
    uint32_t ctr;                    /* 0x090 from context switch code */
    uint32_t xer;                    /* 0x094 from context switch code */
    uint32_t srr0;                   /* 0x098 from OSDumpContext */
    uint32_t srr1;                   /* 0x09c from OSDumpContext */
    char _unknowna0[0xb8 - 0xa0];
    uint64_t fpr[32];                /* 0x0b8 from OSDumpContext */
    int16_t spinLockCount;           /* 0x1b8 from OSDumpContext */
    char _unknown1ba[0x1bc - 0x1ba]; /* 0x1ba could genuinely be padding? */
    uint32_t gqr[8];                 /* 0x1bc from OSDumpContext */
    char _unknown1dc[0x1e0 - 0x1dc];
    uint64_t psf[32];                /* 0x1e0 from OSDumpContext */
    int64_t coretime[3];             /* 0x2e0 from OSDumpContext */
    int64_t starttime;               /* 0x2f8 from OSDumpContext */
    int32_t error;                   /* 0x300 from OSDumpContext */
    char _unknown304[0x6a0 - 0x304];
} OSThread;                          /* 0x6a0 total length from RAM dumps */