Update pk2ldr outline, prepare for bootup_misc_mmio() impl

This commit is contained in:
Michael Scire 2018-03-02 11:28:05 -08:00
parent 303e189559
commit b3dbfd8ee0
4 changed files with 49 additions and 8 deletions

18
exosphere/src/bootup.c Normal file
View file

@ -0,0 +1,18 @@
#include <stdint.h>
#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 */
}

10
exosphere/src/bootup.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef EXOSPHERE_BOOTUP_H
#define EXOSPHERE_BOOTUP_H
#include <stdint.h>
void bootup_misc_mmio(void);
void setup_4x_mmio(void);
#endif

View file

@ -3,6 +3,7 @@
#include "utils.h" #include "utils.h"
#include "memory_map.h" #include "memory_map.h"
#include "bootup.h"
#include "cpu_context.h" #include "cpu_context.h"
#include "package2.h" #include "package2.h"
#include "configitem.h" #include "configitem.h"
@ -376,13 +377,7 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) {
wait(1000); wait(1000);
/* TODO: bootup_misc_mmio(). */ 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. */
/* TODO: initalize cpu context */ /* TODO: initalize cpu context */
@ -406,7 +401,13 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) {
setup_boot_config(); setup_boot_config();
/* Synchronize with NX BOOTLOADER. */ /* Synchronize with NX BOOTLOADER. */
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); sync_with_nx_bootloader(NX_BOOTLOADER_STATE_LOADED_PACKAGE2);
}
/* Remove the identity mapping for iRAM-C+D & TZRAM */ /* Remove the identity mapping for iRAM-C+D & TZRAM */
identity_unmap_iram_cd_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 */ /* 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. */ /* TODO: Update SCR_EL3 depending on value in Bootconfig. */
if (MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE) { if (MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE) {

View file

@ -18,9 +18,14 @@ static inline uintptr_t get_nx_bootloader_mailbox_base(void) {
#define NX_BOOTLOADER_STATE_INIT 0 #define NX_BOOTLOADER_STATE_INIT 0
#define NX_BOOTLOADER_STATE_MOVED_BOOTCONFIG 1 #define NX_BOOTLOADER_STATE_MOVED_BOOTCONFIG 1
#define NX_BOOTLOADER_STATE_LOADED_PACKAGE2 2 #define NX_BOOTLOADER_STATE_LOADED_PACKAGE2 2
#define NX_BOOTLOADER_STATE_FINISHED 3 #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 */ /* Physaddr 0x40002EFC */
#define MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE (*((volatile uint32_t *)(MAILBOX_NX_BOOTLOADER_BASE + 0xEFCULL))) #define MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE (*((volatile uint32_t *)(MAILBOX_NX_BOOTLOADER_BASE + 0xEFCULL)))