TSEC Firmware: Difference between revisions

Vale (talk | contribs)
No edit summary
Shchmue (talk | contribs)
Main: correct secureboot falcon os address memcpy source
 
(2 intermediate revisions by one other user not shown)
Line 230: Line 230:
<pre>
<pre>
     // Read data segment size from IO space
     // Read data segment size from IO space
     u32 data_seg_size = *(u32 *)UC_CAPS;
     u32 data_seg_size = *(u32 *)FALCON_HWCFG;
     data_seg_size >>= 0x09;
     data_seg_size >>= 0x09;
     data_seg_size &= 0x1FF;
     data_seg_size &= 0x1FF;
Line 496: Line 496:
   
   
     // Read data segment size from IO space
     // Read data segment size from IO space
     u32 data_seg_size = *(u32 *)UC_CAPS;
     u32 data_seg_size = *(u32 *)FALCON_HWCFG;
     data_seg_size >>= 0x09;
     data_seg_size >>= 0x09;
     data_seg_size &= 0x1FF;
     data_seg_size &= 0x1FF;
Line 695: Line 695:
     // Swap halves (b16, b32 and b16 again) and store it as the last word
     // Swap halves (b16, b32 and b16 again) and store it as the last word
     *(u32 *)(buf + 0x0C) = (
     *(u32 *)(buf + 0x0C) = (
         ((size & 0x000000FF) << 0x08 | (size & 0x0000FF00) >> 0x08) << 0x10
         ((size & 0x000000FF) << 0x08
        | (size & 0x0000FF00) >> 0x08) << 0x10
         | ((size & 0x00FF0000) >> 0x10) << 0x08
         | ((size & 0x00FF0000) >> 0x10) << 0x08
         | (size & 0xFF000000) >> 0x18
         | (size & 0xFF000000) >> 0x18
Line 735: Line 736:


===== crypto_load =====
===== crypto_load =====
This method takes '''reg''' (a crypto register) and '''buf''' (a 16 bytes buffer) as arguments and loads the supplied buffer into the crypto register.
This method takes '''reg''' (a crypto register) and '''buf''' (a 16 bytes buffer) as arguments and loads the contents of the supplied register into the supplied buffer.
<pre>
<pre>
     // The next two xfer instructions will be overridden
     // The next two xfer instructions will be overridden
Line 960: Line 961:
The main function takes '''key_addr''' and '''key_type''' as arguments from [[#KeygenLdr|KeygenLdr]].
The main function takes '''key_addr''' and '''key_type''' as arguments from [[#KeygenLdr|KeygenLdr]].
<pre>
<pre>
     u32 falcon_rev = *(u32 *)UC_CAPS2 & 0x0F;
     u32 falcon_rev = *(u32 *)FALCON_HWCFG2 & 0x0F;


     // Falcon hardware revision must be 5
     // Falcon hardware revision must be 5
Line 1,191: Line 1,192:
     // Read the SecureBoot blob's Falcon OS image from memory
     // Read the SecureBoot blob's Falcon OS image from memory
     u32 blob4_flcn_os_addr = ((((blob0_size + blob1_size) + 0x100) + blob2_size) + flcn_code_hdr_size);
     u32 blob4_flcn_os_addr = ((((blob0_size + blob1_size) + 0x100) + blob2_size) + flcn_code_hdr_size);
     memcpy_i2d(boot_base_addr, blob4_flcn_os_hdr_addr, flcn_os_size);
     memcpy_i2d(boot_base_addr, blob4_flcn_os_addr, flcn_os_size);
   
   
     // Upload the SecureBoot's Falcon OS image boot stub code segment into Falcon's CODE region
     // Upload the SecureBoot's Falcon OS image boot stub code segment into Falcon's CODE region
Line 1,261: Line 1,262:
<pre>
<pre>
     // Read data segment size from IO space
     // Read data segment size from IO space
     u32 data_seg_size = *(u32 *)UC_CAPS;
     u32 data_seg_size = *(u32 *)FALCON_HWCFG;
     data_seg_size >>= 0x01;
     data_seg_size >>= 0x01;
     data_seg_size &= 0xFF00;
     data_seg_size &= 0xFF00;
Line 1,387: Line 1,388:
      
      
     // Read data segment size from IO space
     // Read data segment size from IO space
     u32 data_seg_size = *(u32 *)UC_CAPS;
     u32 data_seg_size = *(u32 *)FALCON_HWCFG;
     data_seg_size >>= 0x01;
     data_seg_size >>= 0x01;
     data_seg_size &= 0xFF00;
     data_seg_size &= 0xFF00;
Line 1,519: Line 1,520:
      
      
     // Read data segment size from IO space
     // Read data segment size from IO space
     u32 data_seg_size = *(u32 *)UC_CAPS;
     u32 data_seg_size = *(u32 *)FALCON_HWCFG;
     data_seg_size >>= 0x01;
     data_seg_size >>= 0x01;
     data_seg_size &= 0xFF00;
     data_seg_size &= 0xFF00;