Code: Select all
void start()
{
unsigned int *ptr;
int is_end_of_bss;
sr_val = __get_CPSR() & 0xFFFFFFE0 | 0xD3;
__asm { MSR CPSR_cf, R0 }
init_all();
ptr = (unsigned int *)×tamp; // this is a pointer to start of bss area
do
{
*ptr = 0; // zero bss area
is_end_of_bss_ZF = (char *)ptr == &bss_end;
++ptr;
}
while ( !is_end_of_bss );
_sdp_mmc(); // loads 0x20000 bytes of bootloader to 0x47000000
if ( !(crypto_hwreg_disabled & 1) )
{
crypto_hwreg_cmac_addr = 0x47000000; // address of start of bootloader in ram
crypto_hwreg_cmac_size1 = 0x1FFF0; // size of bootloader to calc hash over
crypto_hwreg_cmac_size2 = 0x1FFF0; // size of bootloader to calc hash over
crypto_hwreg_cmac_cmd1 = 0xC3; // hash command?
crypto_hwreg_cmac_hash[0] = 0x210BADD; // hash at the end of bootloader
crypto_hwreg_cmac_hash[1] = 0x6C767816;
crypto_hwreg_cmac_hash[2] = 0x45EE2C72;
crypto_hwreg_cmac_hash[3] = 0x47EDCF85;
crypto_hwreg_cmac_cmd2 = 0x23; // hash command?
while ( crypto_hwreg_status ) // wait till hash calc is done?
;
while ( crypto_hwreg_result != 1 ) // if hash doesnt match?, enter infinite loop
;
}
Main(); // start main bootloader function
}