boot.c
950 Bytes
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
#include <ultra64.h>
#include <bstring.h>
#include "midiApp.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[];
boot(void *arg)
{
void (*func)(void);
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();
}