boot0.c
1.36 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
47
48
49
50
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: boot0.c,v $
$Revision: 1.2 $
$Date: 2003/04/05 17:49:42 $
*---------------------------------------------------------------------*/
#include <ultra64.h>
#include "reboot.h"
#define _256K (256*1024)
char bootStack[STACKSIZE];
extern char _boot1SegmentRomStart[];
extern char _boot1SegmentRomEnd[];
extern char _boot1SegmentStart[];
extern char _boot1SegmentTextStart[];
extern char _boot1SegmentTextEnd[];
extern char _boot1SegmentDataStart[];
extern char _boot1SegmentDataEnd[];
extern char _boot1SegmentBssStart[];
extern char _boot1SegmentBssEnd[];
boot0(void)
{
void (*func)(void);
osInitialize();
osMapTLB(0, OS_PM_256K, _boot1SegmentStart,
BOOT1_PADDR, BOOT1_PADDR + _256K, -1);
osInvalICache(_boot1SegmentTextStart,
_boot1SegmentTextEnd-_boot1SegmentTextStart);
osInvalDCache(_boot1SegmentDataStart,
_boot1SegmentDataEnd-_boot1SegmentDataStart);
__osPiRawStartDma(OS_READ, (u32)_boot1SegmentRomStart, _boot1SegmentStart,
_boot1SegmentRomEnd-_boot1SegmentRomStart);
while(osPiGetStatus() & PI_STATUS_DMA_BUSY);
bzero(_boot1SegmentBssStart, _boot1SegmentBssEnd-_boot1SegmentBssStart);
func = (void (*)(void))_boot1SegmentStart;
func();
}