Changes

28 bytes added ,  06:29, 3 May 2008
m
no edit summary
Line 49: Line 49:  
The BOOT2 elf stub loader sets up a stack, calculates its own address, and switches to THUMB mode. Then it does the following:
 
The BOOT2 elf stub loader sets up a stack, calculates its own address, and switches to THUMB mode. Then it does the following:
    +
<source lang="c">
 
  if( ! (*((u32 *)0xD800060) & 0x20) ) {
 
  if( ! (*((u32 *)0xD800060) & 0x20) ) {
 
   *((u32 *)0xD800060) |= 0x20;
 
   *((u32 *)0xD800060) |= 0x20;
 
  }
 
  }
 +
</source>
    
0xD800000 seems to be the start of the (a?) hardware register space.
 
0xD800000 seems to be the start of the (a?) hardware register space.
    
After this, it loads the ELF file, and then '''zeroes out the memory area where the ELF file resides'''. Then it goes back to ARM mode and vectors to 0xFFFF0000 (the entrypoint of the ARM / vector table). The entire BOOT2 code seems to be position-independent: it can be loaded at any address and will still work, as long as it doesn't overlap with the destination of the ELF load. The entire BOOT2 file cleartext is loaded and then the loader is called, so the loader can calculate the offset of the header simply by subtracting 0x10 from the PC at its entrypoint.
 
After this, it loads the ELF file, and then '''zeroes out the memory area where the ELF file resides'''. Then it goes back to ARM mode and vectors to 0xFFFF0000 (the entrypoint of the ARM / vector table). The entire BOOT2 code seems to be position-independent: it can be loaded at any address and will still work, as long as it doesn't overlap with the destination of the ELF load. The entire BOOT2 file cleartext is loaded and then the loader is called, so the loader can calculate the offset of the header simply by subtracting 0x10 from the PC at its entrypoint.
3,032

edits