From 69f9fb8713456470f68b7f8b5509f704e0a98809 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 18 Nov 2020 13:42:32 -0800 Subject: [PATCH] exo: receive saved lcd vendor from bl --- exosphere/mariko_fatal/source/fatal_crt0.s | 6 ++++ exosphere/mariko_fatal/source/fatal_main.cpp | 1 + .../source/fatal_save_context.cpp | 1 + ...ecmon_configuration_context.arch.arm64.hpp | 4 +++ .../secmon/secmon_monitor_context.hpp | 36 ++++++++++++------- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/exosphere/mariko_fatal/source/fatal_crt0.s b/exosphere/mariko_fatal/source/fatal_crt0.s index a49cacffe..ecc1763cc 100644 --- a/exosphere/mariko_fatal/source/fatal_crt0.s +++ b/exosphere/mariko_fatal/source/fatal_crt0.s @@ -22,11 +22,17 @@ _start: ldr x20, =0x1F00FC000 mov sp, x20 + /* Save any arguments we may have. */ + stp x0, x1, [sp, #-16]! + /* Initialize all memory to expected state. */ ldr x0, =__bss_start__ ldr x1, =__bss_end__ bl _ZN3ams6secmon5fatal10InitializeEmm + /* Restore any arguments we may have. */ + ldp x0, x1, [sp], #16 + /* Jump to the fatal program. */ ldr x16, =_ZN3ams6secmon5fatal4MainEv br x16 diff --git a/exosphere/mariko_fatal/source/fatal_main.cpp b/exosphere/mariko_fatal/source/fatal_main.cpp index 1787acc88..169a43f38 100644 --- a/exosphere/mariko_fatal/source/fatal_main.cpp +++ b/exosphere/mariko_fatal/source/fatal_main.cpp @@ -60,6 +60,7 @@ namespace ams::secmon::fatal { /* Display the fatal error. */ { + AMS_SECMON_LOG("Showing Display, LCD Vendor = %04x\n", GetLcdVendor()); InitializeDisplay(); ShowDisplay(f_ctx, result); FinalizeDisplay(); diff --git a/exosphere/mariko_fatal/source/fatal_save_context.cpp b/exosphere/mariko_fatal/source/fatal_save_context.cpp index df9db0a13..4da1ee15f 100644 --- a/exosphere/mariko_fatal/source/fatal_save_context.cpp +++ b/exosphere/mariko_fatal/source/fatal_save_context.cpp @@ -30,6 +30,7 @@ namespace ams::secmon::fatal { sdmmc::SpeedMode speed_mode; sdmmc::BusWidth bus_width; R_TRY(CheckSdCardConnection(std::addressof(speed_mode), std::addressof(bus_width))); + AMS_SECMON_LOG("Sd Card Connection:\n"); AMS_SECMON_LOG(" Speed Mode: %u\n", static_cast(speed_mode)); AMS_SECMON_LOG(" Bus Width: %u\n", static_cast(bus_width)); } diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp index fff53236b..bddcf1b75 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp @@ -112,6 +112,10 @@ namespace ams::secmon { return GetSecmonConfiguration().GetHardwareState(); } + ALWAYS_INLINE u16 GetLcdVendor() { + return GetSecmonConfiguration().GetLcdVendor(); + } + ALWAYS_INLINE bool IsProduction() { return GetSecmonConfiguration().IsProduction(); } diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp index 568812c7c..c29708018 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp @@ -37,8 +37,10 @@ namespace ams::secmon { u32 magic; ams::TargetFirmware target_firmware; - u32 flags; - u32 reserved[5]; + u32 flags[2]; + u16 lcd_vendor; + u16 reserved0; + u32 reserved1[3]; EmummcConfiguration emummc_cfg; constexpr bool IsValid() const { return this->magic == Magic; } @@ -53,12 +55,16 @@ namespace ams::secmon { u8 soc_type; u8 hardware_state; u8 pad_0B[1]; - u32 flags; - u32 reserved[(0x80 - 0x10) / sizeof(u32)]; + u32 flags[2]; + u16 lcd_vendor; + u16 reserved0; + u32 reserved1[(0x80 - 0x18) / sizeof(u32)]; constexpr void CopyFrom(const SecureMonitorStorageConfiguration &storage) { this->target_firmware = storage.target_firmware; - this->flags = storage.flags; + this->flags[0] = storage.flags[0]; + this->flags[1] = storage.flags[1]; + this->lcd_vendor = storage.lcd_vendor; } void SetFuseInfo() { @@ -73,14 +79,16 @@ namespace ams::secmon { constexpr fuse::SocType GetSocType() const { return static_cast(this->soc_type); } constexpr fuse::HardwareState GetHardwareState() const { return static_cast(this->hardware_state); } + constexpr u16 GetLcdVendor() const { return this->lcd_vendor; } + constexpr bool IsProduction() const { return this->GetHardwareState() != fuse::HardwareState_Development; } - constexpr bool IsDevelopmentFunctionEnabledForKernel() const { return (this->flags & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForKernel) != 0; } - constexpr bool IsDevelopmentFunctionEnabledForUser() const { return (this->flags & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForUser) != 0; } - constexpr bool DisableUserModeExceptionHandlers() const { return (this->flags & SecureMonitorConfigurationFlag_DisableUserModeExceptionHandlers) != 0; } - constexpr bool EnableUserModePerformanceCounterAccess() const { return (this->flags & SecureMonitorConfigurationFlag_EnableUserModePerformanceCounterAccess) != 0; } - constexpr bool ShouldUseBlankCalibrationBinary() const { return (this->flags & SecureMonitorConfigurationFlag_ShouldUseBlankCalibrationBinary) != 0; } - constexpr bool AllowWritingToCalibrationBinarySysmmc() const { return (this->flags & SecureMonitorConfigurationFlag_AllowWritingToCalibrationBinarySysmmc) != 0; } + constexpr bool IsDevelopmentFunctionEnabledForKernel() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForKernel) != 0; } + constexpr bool IsDevelopmentFunctionEnabledForUser() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForUser) != 0; } + constexpr bool DisableUserModeExceptionHandlers() const { return (this->flags[0] & SecureMonitorConfigurationFlag_DisableUserModeExceptionHandlers) != 0; } + constexpr bool EnableUserModePerformanceCounterAccess() const { return (this->flags[0] & SecureMonitorConfigurationFlag_EnableUserModePerformanceCounterAccess) != 0; } + constexpr bool ShouldUseBlankCalibrationBinary() const { return (this->flags[0] & SecureMonitorConfigurationFlag_ShouldUseBlankCalibrationBinary) != 0; } + constexpr bool AllowWritingToCalibrationBinarySysmmc() const { return (this->flags[0] & SecureMonitorConfigurationFlag_AllowWritingToCalibrationBinarySysmmc) != 0; } constexpr bool IsDevelopmentFunctionEnabled(bool for_kern) const { return for_kern ? this->IsDevelopmentFunctionEnabledForKernel() : this->IsDevelopmentFunctionEnabledForUser(); } }; @@ -94,8 +102,10 @@ namespace ams::secmon { .soc_type = {}, .hardware_state = {}, .pad_0B = {}, - .flags = SecureMonitorConfigurationFlag_Default, - .reserved = {}, + .flags = { SecureMonitorConfigurationFlag_Default, SecureMonitorConfigurationFlag_None }, + .lcd_vendor = {}, + .reserved0 = {}, + .reserved1 = {}, }; }