diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp index 76318a5b7..20ea88ba8 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp @@ -341,7 +341,7 @@ namespace ams::kern { constexpr KThreadContext &GetContext() { return this->thread_context; } constexpr const KThreadContext &GetContext() const { return this->thread_context; } - constexpr const u64 GetVirtualAffinityMask() const { return this->virtual_affinity_mask; } + constexpr u64 GetVirtualAffinityMask() const { return this->virtual_affinity_mask; } constexpr const KAffinityMask &GetAffinityMask() const { return this->physical_affinity_mask; } Result GetCoreMask(int32_t *out_ideal_core, u64 *out_affinity_mask); diff --git a/libraries/libmesosphere/source/kern_debug_log_impl.board.nintendo_nx.cpp b/libraries/libmesosphere/source/kern_debug_log_impl.board.nintendo_nx.cpp index 0f54d3361..470287b9b 100644 --- a/libraries/libmesosphere/source/kern_debug_log_impl.board.nintendo_nx.cpp +++ b/libraries/libmesosphere/source/kern_debug_log_impl.board.nintendo_nx.cpp @@ -51,37 +51,22 @@ namespace ams::kern { } bool KDebugLogImpl::Initialize() { + /* Get the uart memory region. */ + const KMemoryRegion *uart_region = KMemoryLayout::GetPhysicalMemoryRegionTree().FindFirstDerived(KMemoryRegionType_Uart); + if (uart_region == nullptr) { + return false; + } + /* Set the uart register base address. */ - g_uart_address = KMemoryLayout::GetDeviceVirtualAddress(KMemoryRegionType_Uart); + g_uart_address = uart_region->GetPairAddress(); + if (g_uart_address == Null) { + return false; + } - /* Parameters for uart. */ - constexpr u32 BaudRate = 115200; - constexpr u32 Pllp = 408000000; - constexpr u32 Rate = 16 * BaudRate; - constexpr u32 Divisor = (Pllp + Rate / 2) / Rate; - - /* Initialize the UART registers. */ - /* Set Divisor Latch Access bit, to allow access to DLL/DLH */ - WriteUartRegister(UartRegister_LCR, 0x80); - ReadUartRegister(UartRegister_LCR); - - /* Program the divisor into DLL/DLH. */ - WriteUartRegister(UartRegister_DLL, Divisor & 0xFF); - WriteUartRegister(UartRegister_DLH, (Divisor >> 8) & 0xFF); - ReadUartRegister(UartRegister_DLH); - - /* Set word length to 3, clear Divisor Latch Access. */ - WriteUartRegister(UartRegister_LCR, 0x03); - ReadUartRegister(UartRegister_LCR); - - /* Disable UART interrupts. */ + /* NOTE: We assume here that UART init/config has been done by the Secure Monitor. */ + /* As such, we only need to disable interrupts. */ WriteUartRegister(UartRegister_IER, 0x00); - /* Configure the FIFO to be enabled and clear receive. */ - WriteUartRegister(UartRegister_FCR, 0x03); - WriteUartRegister(UartRegister_IRDA_CSR, 0x02); - ReadUartRegister(UartRegister_FCR); - return true; }