boot0.c 1.36 KB

/*---------------------------------------------------------------------*
        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();
}