mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 15:28:21 -04:00
Implement support for parsing/interacting with NCAs. (#942)
* fs: implement support for interacting with ncas. * spl: extend to use virtual keyslots
This commit is contained in:
parent
3a1ccdd919
commit
81f91803ec
118 changed files with 13301 additions and 405 deletions
|
@ -22,19 +22,6 @@ namespace ams::boot {
|
|||
|
||||
namespace {
|
||||
|
||||
/* Types. */
|
||||
struct BootReasonValue {
|
||||
union {
|
||||
struct {
|
||||
u8 power_intr;
|
||||
u8 rtc_intr;
|
||||
u8 nv_erc;
|
||||
u8 boot_reason;
|
||||
};
|
||||
u32 value;
|
||||
};
|
||||
};
|
||||
|
||||
/* Globals. */
|
||||
u32 g_boot_reason = 0;
|
||||
bool g_detected_boot_reason = false;
|
||||
|
@ -90,12 +77,14 @@ namespace ams::boot {
|
|||
|
||||
/* Set boot reason for SPL. */
|
||||
if (hos::GetVersion() >= hos::Version_3_0_0) {
|
||||
BootReasonValue boot_reason_value;
|
||||
boot_reason_value.power_intr = power_intr;
|
||||
boot_reason_value.rtc_intr = rtc_intr & ~rtc_intr_m;
|
||||
boot_reason_value.nv_erc = nv_erc;
|
||||
spl::BootReasonValue boot_reason_value = {};
|
||||
|
||||
boot_reason_value.power_intr = power_intr;
|
||||
boot_reason_value.rtc_intr = rtc_intr & ~rtc_intr_m;
|
||||
boot_reason_value.nv_erc = nv_erc;
|
||||
boot_reason_value.boot_reason = g_boot_reason;
|
||||
R_ABORT_UNLESS(splSetBootReason(boot_reason_value.value));
|
||||
|
||||
R_ABORT_UNLESS(spl::SetBootReason(boot_reason_value));
|
||||
}
|
||||
|
||||
g_detected_boot_reason = true;
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace ams::boot {
|
|||
/* Globals. */
|
||||
bool g_is_display_intialized = false;
|
||||
u32 *g_frame_buffer = nullptr;
|
||||
bool g_is_mariko = false;
|
||||
spl::SocType g_soc_type = spl::SocType_Erista;
|
||||
u32 g_lcd_vendor = 0;
|
||||
Handle g_dc_das_hnd = INVALID_HANDLE;
|
||||
u8 g_frame_buffer_storage[DeviceAddressSpaceAlignSize + FrameBufferSize];
|
||||
|
@ -95,10 +95,9 @@ namespace ams::boot {
|
|||
}
|
||||
|
||||
inline void DoSocDependentRegisterWrites(uintptr_t base_address, const RegisterWrite *reg_writes_erista, size_t num_writes_erista, const RegisterWrite *reg_writes_mariko, size_t num_writes_mariko) {
|
||||
if (g_is_mariko) {
|
||||
DoRegisterWrites(base_address, reg_writes_mariko, num_writes_mariko);
|
||||
} else {
|
||||
DoRegisterWrites(base_address, reg_writes_erista, num_writes_erista);
|
||||
switch (g_soc_type) {
|
||||
case spl::SocType_Erista: DoRegisterWrites(base_address, reg_writes_erista, num_writes_erista); break;
|
||||
case spl::SocType_Mariko: DoRegisterWrites(base_address, reg_writes_mariko, num_writes_mariko); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +187,7 @@ namespace ams::boot {
|
|||
void InitializeDisplay() {
|
||||
/* Setup globals. */
|
||||
InitializeRegisterBaseAddresses();
|
||||
g_is_mariko = spl::IsMariko();
|
||||
g_soc_type = spl::GetSocType();
|
||||
InitializeFrameBuffer();
|
||||
|
||||
/* Turn on DSI/voltage rail. */
|
||||
|
@ -199,7 +198,7 @@ namespace ams::boot {
|
|||
|
||||
i2c::driver::OpenSession(&i2c_session, I2cDevice_Max77620Pmic);
|
||||
|
||||
if (g_is_mariko) {
|
||||
if (g_soc_type == spl::SocType_Mariko) {
|
||||
WriteI2cRegister(i2c_session, 0x18, 0x3A);
|
||||
WriteI2cRegister(i2c_session, 0x1F, 0x71);
|
||||
}
|
||||
|
@ -242,7 +241,7 @@ namespace ams::boot {
|
|||
|
||||
/* Configure display interface and display. */
|
||||
reg::Write(g_mipi_cal_regs + 0x060, 0);
|
||||
if (g_is_mariko) {
|
||||
if (g_soc_type == spl::SocType_Mariko) {
|
||||
reg::Write(g_mipi_cal_regs + 0x058, 0);
|
||||
reg::Write(g_apb_misc_regs + 0xAC0, 0);
|
||||
}
|
||||
|
@ -367,7 +366,7 @@ namespace ams::boot {
|
|||
DO_SOC_DEPENDENT_REGISTER_WRITES(g_dsi_regs, DisplayConfigDsi01Init11);
|
||||
DO_SOC_DEPENDENT_REGISTER_WRITES(g_mipi_cal_regs, DisplayConfigMipiCal03);
|
||||
DO_REGISTER_WRITES(g_mipi_cal_regs, DisplayConfigMipiCal04);
|
||||
if (g_is_mariko) {
|
||||
if (g_soc_type == spl::SocType_Mariko) {
|
||||
/* On Mariko the above configurations are executed twice, for some reason. */
|
||||
DO_SOC_DEPENDENT_REGISTER_WRITES(g_mipi_cal_regs, DisplayConfigMipiCal02);
|
||||
DO_SOC_DEPENDENT_REGISTER_WRITES(g_dsi_regs, DisplayConfigDsi01Init11);
|
||||
|
|
|
@ -92,7 +92,7 @@ void __appInit(void) {
|
|||
/* Initialize services we need (TODO: NCM) */
|
||||
sm::DoWithSession([&]() {
|
||||
R_ABORT_UNLESS(fsInitialize());
|
||||
R_ABORT_UNLESS(splInitialize());
|
||||
spl::Initialize();
|
||||
R_ABORT_UNLESS(pmshellInitialize());
|
||||
});
|
||||
|
||||
|
@ -102,7 +102,7 @@ void __appInit(void) {
|
|||
void __appExit(void) {
|
||||
/* Cleanup services. */
|
||||
pmshellExit();
|
||||
splExit();
|
||||
spl::Finalize();
|
||||
fsExit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue