From b3dbfd8ee0ea99f26d40b0f96e9f149bad177577 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 2 Mar 2018 11:28:05 -0800 Subject: [PATCH] Update pk2ldr outline, prepare for bootup_misc_mmio() impl --- exosphere/src/bootup.c | 18 ++++++++++++++++++ exosphere/src/bootup.h | 10 ++++++++++ exosphere/src/package2.c | 24 ++++++++++++++++-------- exosphere/src/package2.h | 5 +++++ 4 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 exosphere/src/bootup.c create mode 100644 exosphere/src/bootup.h diff --git a/exosphere/src/bootup.c b/exosphere/src/bootup.c new file mode 100644 index 000000000..29bad2497 --- /dev/null +++ b/exosphere/src/bootup.c @@ -0,0 +1,18 @@ +#include + +#include "utils.h" +#include "bootup.h" + +void bootup_misc_mmio(void) { + /* TODO */ + /* This func will also be called on warmboot. */ + /* And will verify stored SE Test Vector, clear keyslots, */ + /* Generate an SRK, set the warmboot firmware location, */ + /* Configure the GPU uCode carveout, configure the Kernel default carveouts, */ + /* Initialize the PMC secure scratch registers, initialize MISC registers, */ + /* And assign "se_operation_completed" to Interrupt 0x5A. */ +} + +void setup_4x_mmio(void) { + /* TODO */ +} \ No newline at end of file diff --git a/exosphere/src/bootup.h b/exosphere/src/bootup.h new file mode 100644 index 000000000..c621bbd5b --- /dev/null +++ b/exosphere/src/bootup.h @@ -0,0 +1,10 @@ +#ifndef EXOSPHERE_BOOTUP_H +#define EXOSPHERE_BOOTUP_H + +#include + +void bootup_misc_mmio(void); + +void setup_4x_mmio(void); + +#endif \ No newline at end of file diff --git a/exosphere/src/package2.c b/exosphere/src/package2.c index fd7a1d717..3b87f832e 100644 --- a/exosphere/src/package2.c +++ b/exosphere/src/package2.c @@ -3,6 +3,7 @@ #include "utils.h" #include "memory_map.h" +#include "bootup.h" #include "cpu_context.h" #include "package2.h" #include "configitem.h" @@ -376,13 +377,7 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) { wait(1000); - /* TODO: bootup_misc_mmio(). */ - /* This func will also be called on warmboot. */ - /* And will verify stored SE Test Vector, clear keyslots, */ - /* Generate an SRK, set the warmboot firmware location, */ - /* Configure the GPU uCode carveout, configure the Kernel default carveouts, */ - /* Initialize the PMC secure scratch registers, initialize MISC registers, */ - /* And assign "se_operation_completed" to Interrupt 0x5A. */ + bootup_misc_mmio(); /* TODO: initalize cpu context */ @@ -406,7 +401,13 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) { setup_boot_config(); /* Synchronize with NX BOOTLOADER. */ - sync_with_nx_bootloader(NX_BOOTLOADER_STATE_LOADED_PACKAGE2); + if (mkey_get_revision() >= MASTERKEY_REVISION_400_CURRENT) { + sync_with_nx_bootloader(NX_BOOTLOADER_STATE_DRAM_INITIALIZED_4X); + /* TODO: copy_warmboot_bin_to_dram(); */ + sync_with_nx_bootloader(NX_BOOTLOADER_STATE_LOADED_PACKAGE2_4X); + } else { + sync_with_nx_bootloader(NX_BOOTLOADER_STATE_LOADED_PACKAGE2); + } /* Remove the identity mapping for iRAM-C+D & TZRAM */ identity_unmap_iram_cd_tzram(); @@ -441,6 +442,13 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) { /* TODO: lots of boring MMIO */ + if (mkey_get_revision() >= MASTERKEY_REVISION_400_CURRENT) { + sync_with_nx_bootloader(NX_BOOTLOADER_STATE_FINISHED_4X); + setup_4x_mmio(); + } else { + sync_with_nx_bootloader(NX_BOOTLOADER_STATE_FINISHED); + } + /* TODO: Update SCR_EL3 depending on value in Bootconfig. */ if (MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE) { diff --git a/exosphere/src/package2.h b/exosphere/src/package2.h index 971eaf5f7..0f257c00d 100644 --- a/exosphere/src/package2.h +++ b/exosphere/src/package2.h @@ -18,9 +18,14 @@ static inline uintptr_t get_nx_bootloader_mailbox_base(void) { #define NX_BOOTLOADER_STATE_INIT 0 #define NX_BOOTLOADER_STATE_MOVED_BOOTCONFIG 1 + #define NX_BOOTLOADER_STATE_LOADED_PACKAGE2 2 #define NX_BOOTLOADER_STATE_FINISHED 3 +#define NX_BOOTLOADER_STATE_DRAM_INITIALIZED_4X 2 +#define NX_BOOTLOADER_STATE_LOADED_PACKAGE2_4X 3 +#define NX_BOOTLOADER_STATE_FINISHED_4X 4 + /* Physaddr 0x40002EFC */ #define MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE (*((volatile uint32_t *)(MAILBOX_NX_BOOTLOADER_BASE + 0xEFCULL)))