start_rom.c 816 Bytes
#include "cpusim.h"

   /* Please use romdump to find the entry 
	  of your rom file 
    */
#define ROM_ADDR	0x450
#define DDR_MASK	0x03FFFFFF 
unsigned int start_addr=0xbabecafe;

int main() 
{
	vu32 *p0, s1, s2;
	void (*f0)(void);
    
	test_preamble();	

	setcp0reg(C0_SR, SR_CU0|SR_CU1|SR_BEV);
	setcp0reg(C0_CONFIG, CONFIG_BE|CONFIG_NONCOHRNT);

	initICache();
	initDCache();
	init_ddr();

	message("Start rom\n");

	  /* Jump to rom start address */
	s1 = (start_addr >> 16) & 0xffff;
	s2 = start_addr & 0xffff;        /* avoid signature */
	if (s1 == 0xbabe && s2 == 0xcafe) 
		p0 = (vu32*) (PHYS_TO_K1(ROM_ADDR));
	else
		p0 = (vu32*) (PHYS_TO_K1((start_addr & DDR_MASK)));

	f0 = (void(*))(p0);

	setreg($30, 0);
	setreg($29, 0xA0800000);
	(*f0)();

	message("End rom\n");
	test_postamble();
	return 0;
}