In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Loader"

From WiiUBrew
Jump to navigation Jump to search
(Document beginning of __LoaderStart())
(document the structure passed into LOADER_Entry)
Line 4: Line 4:
 
===__LoaderStart()===
 
===__LoaderStart()===
 
__LoaderStart() is the entry point of loader.elf, the first function called by both the kernel on process startup and loader calls from OSDynLoad. It takes a caller argument from the kernel in r3, which is 0 if called on process startup and 1 if called from OSDynLoad. There is also a loader call buffer passed in r4. If the function has been called from OSDynLoad, it goes to LOADER_Entry() and processes the loader call. Otherwise, it continues and sets up the app address space.
 
__LoaderStart() is the entry point of loader.elf, the first function called by both the kernel on process startup and loader calls from OSDynLoad. It takes a caller argument from the kernel in r3, which is 0 if called on process startup and 1 if called from OSDynLoad. There is also a loader call buffer passed in r4. If the function has been called from OSDynLoad, it goes to LOADER_Entry() and processes the loader call. Otherwise, it continues and sets up the app address space.
 +
 +
===LOADER_Entry(LoaderRequest* request)===
 +
 +
LoaderRequest structure:
 +
 +
<pre>
 +
void* context; // 0
 +
int procId; // 4
 +
void* procConfig; // 8
 +
void* anotherContext? // 12
 +
char filler[24-12];// unknown
 +
int dispatchCode; // 24
 +
</pre>
 +
 +
These are copied to the matching LoaderEntry global variables at the start of this method.
 +
 +
Dispatch codes are from 0-11 (inclusive).

Revision as of 10:38, 27 June 2015

The Cafe OS loader is responsible for loading RPL-formatted libraries and executables into memory. It is a standard ELF executable named loader.elf. It includes a statically linked copy of zlib, probably for decompressing sections of RPL files. Each userspace process has the loader mapped into its address space, and the loader is initially ran on process creation, loading coreinit.rpl, the application's dependencies, and the application RPX itself. After control passes to the application, the loader continues to be available through a special loader call interface, used by the OSDynLoad functions in coreinit.

Functions

__LoaderStart()

__LoaderStart() is the entry point of loader.elf, the first function called by both the kernel on process startup and loader calls from OSDynLoad. It takes a caller argument from the kernel in r3, which is 0 if called on process startup and 1 if called from OSDynLoad. There is also a loader call buffer passed in r4. If the function has been called from OSDynLoad, it goes to LOADER_Entry() and processes the loader call. Otherwise, it continues and sets up the app address space.

LOADER_Entry(LoaderRequest* request)

LoaderRequest structure:

void* context; // 0
int procId; // 4
void* procConfig; // 8
void* anotherContext? // 12
char filler[24-12];// unknown
int dispatchCode; // 24

These are copied to the matching LoaderEntry global variables at the start of this method.

Dispatch codes are from 0-11 (inclusive).