boot.c
1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <ultra64.h>
#include <string.h>
#include "rdpvector.h"
char bootStack[STACKSIZE];
extern char _codeSegmentRomStart[];
extern char _codeSegmentRomEnd[];
extern char _codeSegmentStart[];
extern char _codeSegmentTextStart[];
extern char _codeSegmentTextEnd[];
extern char _codeSegmentDataStart[];
extern char _codeSegmentDataEnd[];
extern char _codeSegmentBssStart[];
extern char _codeSegmentBssEnd[];
/*
* The boot() function MUST be the first function in this module, otherwise
* the original boot thread (loaded at 2MB in rdram) will be unable to invoke
* this secondary boot procedure, which loads the program low in rdram.
*/
boot(void *arg)
{
void (*func)(void);
/*
* Load in the code segment. The "boot" portion of the code segment
* will load in the texture segment and the static segment.
*/
__osPiRawStartDma(OS_READ, (u32)_codeSegmentRomStart, _codeSegmentStart,
_codeSegmentRomEnd-_codeSegmentRomStart);
while(osPiGetStatus() & PI_STATUS_DMA_BUSY);
osInvalICache(_codeSegmentTextStart,
_codeSegmentTextEnd-_codeSegmentTextStart);
osInvalDCache(_codeSegmentDataStart,
_codeSegmentDataEnd-_codeSegmentDataStart);
bzero(_codeSegmentBssStart, _codeSegmentBssEnd-_codeSegmentBssStart);
func = (void (*)(void))_codeSegmentStart;
func();
}