mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-29 14:05:17 -04:00
exo: shuffle logic around to support debug code region in iram
This commit is contained in:
parent
ee3a7e7740
commit
2ef41f0027
11 changed files with 86 additions and 43 deletions
|
@ -5,7 +5,8 @@ MEMORY
|
|||
{
|
||||
NULL : ORIGIN = 0, LENGTH = 4K
|
||||
unused_region : ORIGIN = 0x1000, LENGTH = 4K
|
||||
iram_boot_code : ORIGIN = 0x040032000, LENGTH = 48K
|
||||
iram_boot_code : ORIGIN = 0x040032000, LENGTH = 4K
|
||||
iram_boot_keys : ORIGIN = 0x040033000, LENGTH = 4K
|
||||
tzram : ORIGIN = 0x07C010000, LENGTH = 64K
|
||||
|
||||
/* Warmboot code follows the vectors in memory. */
|
||||
|
@ -13,9 +14,10 @@ MEMORY
|
|||
warmboot_text : ORIGIN = ORIGIN(tzram) + 10K, LENGTH = 2K
|
||||
|
||||
main : ORIGIN = 0x1F00C0000, LENGTH = 48K
|
||||
tzram_boot : ORIGIN = 0x1F01C0000, LENGTH = 8K
|
||||
debug_code : ORIGIN = 0x1F0150000, LENGTH = 16K
|
||||
tzram_boot : ORIGIN = 0x1F01C0800, LENGTH = 6K
|
||||
|
||||
glob : ORIGIN = 0x040032000, LENGTH = 64K
|
||||
glob : ORIGIN = 0x040032000, LENGTH = 128K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
|
@ -85,19 +87,30 @@ SECTIONS
|
|||
KEEP (*(.dtors))
|
||||
} >iram_boot_code AT>glob
|
||||
|
||||
__bootcode_end__ = ABSOLUTE(.);
|
||||
|
||||
__program_start__ = ABSOLUTE(.);
|
||||
|
||||
.tzram_boot_volatile_data : {
|
||||
KEEP (*(.volatile_keys .volatile_keys.*))
|
||||
} >tzram_boot AT>glob
|
||||
|
||||
.tzram_boot_volatile_data.fill : {
|
||||
.boot_code.fill : {
|
||||
FILL(0x00000000);
|
||||
. = ORIGIN(tzram_boot) + 0x7FF;
|
||||
. = ORIGIN(iram_boot_code) + 0xFFF;
|
||||
BYTE(0x00);
|
||||
} >tzram_boot AT>glob
|
||||
} >iram_boot_code AT>glob
|
||||
|
||||
.boot_code_volatile_keys : {
|
||||
KEEP (*(.volatile_keys .volatile_keys.*))
|
||||
} >iram_boot_keys AT>glob
|
||||
|
||||
.boot_keys.fill : {
|
||||
FILL(0x00000000);
|
||||
. = ORIGIN(iram_boot_keys) + 0xFFF;
|
||||
BYTE(0x00);
|
||||
} >iram_boot_keys AT>glob
|
||||
|
||||
.debug_code : {
|
||||
KEEP (*(.text._ZN3ams3log6PrintfEPKcz .text._ZN3ams3log7VPrintfEPKcSt9__va_list .text._ZN3ams3log4DumpEPKvm))
|
||||
KEEP (*(.text._ZN3ams4util10TVSNPrintfEPcmPKcSt9__va_list .text._ZN3ams4util12_GLOBAL__N_114TVSNPrintfImplEPcmPKcSt9__va_list .text._ZZN3ams4util12_GLOBAL__N_114TVSNPrintfImplEPcmPKcSt9__va_listENKUlbmE3_clEbm))
|
||||
} >debug_code AT>glob
|
||||
|
||||
__bootcode_end__ = ABSOLUTE(.) - ORIGIN(debug_code) + 0x40034000;
|
||||
|
||||
__program_start__ = __bootcode_end__;
|
||||
|
||||
.tzram_boot_code :
|
||||
{
|
||||
|
@ -147,7 +160,6 @@ SECTIONS
|
|||
. = ALIGN(0x100);
|
||||
} >main AT>glob
|
||||
|
||||
|
||||
.warmboot :
|
||||
{
|
||||
KEEP (*(.warmboot.text.start)) /* Should be first */
|
||||
|
|
|
@ -49,9 +49,19 @@ namespace ams::secmon::boot {
|
|||
}
|
||||
}
|
||||
|
||||
void ClearIram() {
|
||||
void ClearIramBootCode() {
|
||||
/* Clear the boot code image from where it was loaded in IRAM. */
|
||||
util::ClearMemory(MemoryRegionPhysicalIramBootCodeImage.GetPointer(), MemoryRegionPhysicalIramBootCodeImage.GetSize());
|
||||
util::ClearMemory(MemoryRegionPhysicalIramBootCodeCode.GetPointer(), MemoryRegionPhysicalIramBootCodeCode.GetSize());
|
||||
}
|
||||
|
||||
void ClearIramBootKeys() {
|
||||
/* Clear the boot keys from where they were loaded in IRAM. */
|
||||
util::ClearMemory(MemoryRegionPhysicalIramBootCodeKeys.GetPointer(), MemoryRegionPhysicalIramBootCodeKeys.GetSize());
|
||||
}
|
||||
|
||||
void ClearIramDebugCode() {
|
||||
/* Clear the boot code image from where it was loaded in IRAM. */
|
||||
util::ClearMemory(MemoryRegionPhysicalDebugCode.GetPointer(), MemoryRegionPhysicalDebugCode.GetSize());
|
||||
}
|
||||
|
||||
void WaitForNxBootloader(const pkg1::SecureMonitorParameters ¶ms, pkg1::BootloaderState state) {
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
namespace ams::secmon::boot {
|
||||
|
||||
void ClearIram();
|
||||
void ClearIramBootCode();
|
||||
void ClearIramBootKeys();
|
||||
void ClearIramDebugCode();
|
||||
|
||||
void WaitForNxBootloader(const pkg1::SecureMonitorParameters ¶ms, pkg1::BootloaderState state);
|
||||
|
||||
|
|
|
@ -70,7 +70,12 @@ namespace ams::secmon {
|
|||
secmon::SetupCpuCoreContext();
|
||||
|
||||
/* Clear the crt0 code that was present in iram. */
|
||||
secmon::boot::ClearIram();
|
||||
secmon::boot::ClearIramBootCode();
|
||||
|
||||
/* Clear the debug code from iram, if we're not in debug config. */
|
||||
#if !defined(AMS_BUILD_FOR_DEBUGGING) && !defined(AMS_BUILD_FOR_AUDITING)
|
||||
secmon::boot::ClearIramDebugCode();
|
||||
#endif
|
||||
|
||||
/* Alert the bootloader that we're initialized. */
|
||||
secmon_params.secmon_state = pkg1::SecureMonitorState_Initialized;
|
||||
|
@ -117,9 +122,6 @@ namespace ams::secmon {
|
|||
std::memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
/* Unmap the identity mapping. */
|
||||
secmon::boot::UnmapPhysicalIdentityMapping();
|
||||
|
||||
/* Setup the GPU carveout's magic numbers. */
|
||||
secmon::boot::WriteGpuCarveoutMagicNumbers();
|
||||
|
||||
|
@ -172,6 +174,12 @@ namespace ams::secmon {
|
|||
/* Set the core's entrypoint and argument. */
|
||||
secmon::SetEntryContext(0, Package2LoadAddress + pkg2_meta.entrypoint, 0);
|
||||
|
||||
/* Clear the boot keys from iram. */
|
||||
secmon::boot::ClearIramBootKeys();
|
||||
|
||||
/* Unmap the identity mapping. */
|
||||
secmon::boot::UnmapPhysicalIdentityMapping();
|
||||
|
||||
/* Unmap DRAM. */
|
||||
secmon::boot::UnmapDram();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ def split_binary(data):
|
|||
assert D == 0xDDDDDDDDDDDDDDDD
|
||||
data = data[0x40:]
|
||||
|
||||
#print ('%X %X %X %X' % (START, BOOT_CODE_START, BOOT_CODE_END, PROGRAM_START))
|
||||
boot_code = data[BOOT_CODE_START - START:BOOT_CODE_END - BOOT_CODE_START]
|
||||
program = data[PROGRAM_START - START:]
|
||||
return [('boot_code%s.lz4', lz4_compress(boot_code)), ('program%s.lz4', lz4_compress(program))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue