Changes

1,392 bytes added ,  00:05, 2 February 2024
no edit summary
Line 246: Line 246:     
=== InitializeMemory ===
 
=== InitializeMemory ===
 +
The Espresso boot ROM copies and clears several memory regions.
 +
 +
// Copy memory regions:
 +
// Source address 0xB0C, destination address 0x20000, size 0x2D58
 +
// Source address 0x3864, destination address 0xE0000000, size 0x6A0
 +
// Source address 0x3F04, destination address 0xE00006A0, size 0xD0
 +
// Source address 0x3FD4, destination address 0xE0000780, size 0xC
 +
for (int i = 0; mem_copy_array[i].size > 0; i++)
 +
{
 +
    u32 src_addr = mem_copy_array[i].src_addr;
 +
    u32 dst_addr = mem_copy_array[i].dst_addr;
 +
    u32 size = mem_copy_array[i].size;
 +
 +
    if (src_addr != dst_addr)
 +
    {
 +
        memcpy(dst_addr, src_addr, size);
 +
       
 +
        if (dst_addr == 0x20000)
 +
        {
 +
            // Set to zero data cache for the 0x24000 region
 +
            sub_5A4();
 +
           
 +
            // Invalidate instruction cache for the given range
 +
            sub_604(dst_addr, size);
 +
           
 +
            if (size)
 +
            {
 +
                if (memcmp(dst_addr, src_addr, size))
 +
                {
 +
                    MEMORY[0xC16FFFFC] = 0x1000000;
 +
                    while (1);
 +
                }
 +
            }
 +
        }
 +
    }
 +
}
 +
 +
// Clear memory regions:
 +
// Address 0xE00007A0, size 0x18
 +
// Address 0xE00007C0, size 0x2E4
 +
for (int i = 0; mem_clear_array[i].size > 0; i++)
 +
{
 +
    memset(mem_clear_array[i].addr, 0, mem_clear_array[i].size);
 +
}
 +
 +
return;
 +
 
=== LoadImg ===
 
=== LoadImg ===
 
=== Finish ===
 
=== Finish ===