#include <nitro/os.h>
void OS_InitContext( OSContext* context,
u32 newpc,
u32 newsp );
context |
Context |
newpc |
Start address |
newsp |
Stack |
None.
Initializes context.
The context structure OSContext
has the following members:
u32 cpsr |
CPSR (Current Program Status Register) |
u32 r[13] |
Registers R0-R12 |
u32 sp |
Stack pointer (R13 register) |
u32 lr |
Link register (R14 register) |
u32 pc_plus4 |
Program counter + 4 (R15 register+4) |
u32 sp_svc |
Used to save to stack in Supervisor mode (see note 1) |
CPContext cp_context |
Context for the divider / square root calculator (see note 2) |
Note 1: May not exist according to compile options. Note 2: Exists only in ARM9.
With the OS_InitContext
function, the stack for SVC is allocated downward from newsp
. (Depending on the compile option, this process may not occur.) cpsr
is set appropriately by checking the processor mode (distinguishing ARM and THUMB) from the CPSR register. r[0]
– r[12]
(registers R0-R12) and lr
(register R14) are zero-cleared. pc_plus4
takes a value 4 more than the specified value of newpc
.
cp_context
exists only in ARM9 as a member of the CPContext
structure and is the context for the divider/square root calculator. CPContext structure contains the following members.
u64 div_numer |
Parameter of the divider (divisor) |
u64 div_denom |
Parameter for the divider (dividend) |
u64 sqrt |
Parameter for the square root calculator |
u16 div_mode |
Divider mode |
u16 sqrt_mode |
Square root calculator mode |
The OS_InitContext
function does not change the content of cp_context
.
OS_SaveContext
OS_LoadContext
OS_DumpContext
2004/06/30 Described cp_context
.
2003/12/01 Initial version.
CONFIDENTIAL