diff --git a/libexosphere/include/exosphere/log.hpp b/libexosphere/include/exosphere/log.hpp index cecf8d15..2afd8e4a 100644 --- a/libexosphere/include/exosphere/log.hpp +++ b/libexosphere/include/exosphere/log.hpp @@ -35,7 +35,7 @@ namespace ams::log { #endif void Initialize(); - void Initialize(uart::Port port, u32 baud_rate); + void Initialize(uart::Port port, u32 baud_rate, u32 flags); void Finalize(); void Printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); diff --git a/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp b/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp index aa231787..7e554676 100644 --- a/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp +++ b/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp @@ -120,6 +120,10 @@ namespace ams::secmon { return GetSecmonConfiguration().GetLogPort(); } + ALWAYS_INLINE u8 GetLogFlags() { + return GetSecmonConfiguration().GetLogFlags(); + } + ALWAYS_INLINE u32 GetLogBaudRate() { return GetSecmonConfiguration().GetLogBaudRate(); } diff --git a/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp b/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp index f53a633d..6c974b1c 100644 --- a/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp +++ b/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp @@ -40,8 +40,8 @@ namespace ams::secmon { ams::TargetFirmware target_firmware; u32 flags[2]; u16 lcd_vendor; - u8 reserved0; u8 log_port; + u8 log_flags; u32 log_baud_rate; u32 reserved1[2]; EmummcConfiguration emummc_cfg; @@ -60,7 +60,8 @@ namespace ams::secmon { u8 log_port; u32 flags[2]; u16 lcd_vendor; - u16 reserved0; + u8 log_flags; + u8 reserved0; u32 log_baud_rate; u32 reserved1[(0x80 - 0x1C) / sizeof(u32)]; @@ -70,6 +71,7 @@ namespace ams::secmon { this->flags[1] = storage.flags[1]; this->lcd_vendor = storage.lcd_vendor; this->log_port = storage.log_port; + this->log_flags = storage.log_flags; this->log_baud_rate = storage.log_baud_rate != 0 ? storage.log_baud_rate : 115200; } @@ -85,6 +87,7 @@ 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 uart::Port GetLogPort() const { return static_cast(this->log_port); } + constexpr u8 GetLogFlags() const { return this->log_flags; } constexpr u16 GetLcdVendor() const { return this->lcd_vendor; } @@ -113,6 +116,7 @@ namespace ams::secmon { .log_port = uart::Port_ReservedDebug, .flags = { SecureMonitorConfigurationFlag_Default, SecureMonitorConfigurationFlag_None }, .lcd_vendor = {}, + .log_flags = {}, .reserved0 = {}, .log_baud_rate = 115200, .reserved1 = {}, diff --git a/libexosphere/source/log/log_api.cpp b/libexosphere/source/log/log_api.cpp index 5ce2831c..62b40ab0 100644 --- a/libexosphere/source/log/log_api.cpp +++ b/libexosphere/source/log/log_api.cpp @@ -20,28 +20,11 @@ namespace ams::log { namespace { constexpr inline uart::Port DefaultLogPort = uart::Port_ReservedDebug; + constexpr inline u32 DefaultLogFlags = static_cast(uart::Flag_None); constexpr inline int DefaultBaudRate = 115200; constinit uart::Port g_log_port = DefaultLogPort; constinit bool g_initialized_uart = false; - ALWAYS_INLINE u32 GetPortFlags(uart::Port port) { - switch (port) { - case uart::Port_ReservedDebug: - /* Logging to the debug port. */ - /* Don't invert transactions. */ - return uart::Flag_None; - case uart::Port_LeftJoyCon: - /* Logging to left joy-con (e.g. with Joyless). */ - /* Invert transactions. */ - return uart::Flag_Inverted; - case uart::Port_RightJoyCon: - /* Logging to right joy-con (e.g. with Joyless). */ - /* Invert transactions. */ - return uart::Flag_Inverted; - AMS_UNREACHABLE_DEFAULT_CASE(); - } - } - ALWAYS_INLINE void SetupUartClock(uart::Port port) { /* The debug port must always be set up, for compatibility with official hos. */ pinmux::SetupUartA(); @@ -64,15 +47,15 @@ namespace ams::log { } void Initialize() { - return Initialize(DefaultLogPort, DefaultBaudRate); + return Initialize(DefaultLogPort, DefaultBaudRate, DefaultLogFlags); } - void Initialize(uart::Port port, u32 baud_rate) { + void Initialize(uart::Port port, u32 baud_rate, u32 flags) { /* Initialize pinmux and clock for the target uart port. */ SetupUartClock(port); /* Initialize the target uart port. */ - uart::Initialize(port, baud_rate, GetPortFlags(port)); + uart::Initialize(port, baud_rate, flags); /* Note that we've initialized. */ g_log_port = port;