exo/meso/fusee: support dynamic control of log port/baud rate
This commit is contained in:
@@ -409,6 +409,15 @@ namespace ams::kern::board::nintendo::nx {
|
||||
return MinimumSize;
|
||||
}
|
||||
|
||||
u8 KSystemControl::Init::GetDebugLogUartPort() {
|
||||
/* Get the log configuration. */
|
||||
u64 value = 0;
|
||||
smc::init::GetConfig(std::addressof(value), 1, smc::ConfigItem::ExosphereLogConfiguration);
|
||||
|
||||
/* Extract the port. */
|
||||
return static_cast<u8>((value >> 32) & 0xFF);
|
||||
}
|
||||
|
||||
void KSystemControl::Init::CpuOn(u64 core_id, uintptr_t entrypoint, uintptr_t arg) {
|
||||
smc::init::CpuOn(core_id, entrypoint, arg);
|
||||
}
|
||||
|
||||
@@ -55,15 +55,16 @@ namespace ams::kern::board::nintendo::nx::smc {
|
||||
Package2Hash = 17,
|
||||
|
||||
/* Extension config items for exosphere. */
|
||||
ExosphereApiVersion = 65000,
|
||||
ExosphereNeedsReboot = 65001,
|
||||
ExosphereNeedsShutdown = 65002,
|
||||
ExosphereGitCommitHash = 65003,
|
||||
ExosphereHasRcmBugPatch = 65004,
|
||||
ExosphereBlankProdInfo = 65005,
|
||||
ExosphereAllowCalWrites = 65006,
|
||||
ExosphereEmummcType = 65007,
|
||||
ExospherePayloadAddress = 65008,
|
||||
ExosphereApiVersion = 65000,
|
||||
ExosphereNeedsReboot = 65001,
|
||||
ExosphereNeedsShutdown = 65002,
|
||||
ExosphereGitCommitHash = 65003,
|
||||
ExosphereHasRcmBugPatch = 65004,
|
||||
ExosphereBlankProdInfo = 65005,
|
||||
ExosphereAllowCalWrites = 65006,
|
||||
ExosphereEmummcType = 65007,
|
||||
ExospherePayloadAddress = 65008,
|
||||
ExosphereLogConfiguration = 65009,
|
||||
};
|
||||
|
||||
enum class SmcResult {
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
#if defined(MESOSPHERE_DEBUG_LOG_USE_UART_A) || defined(MESOSPHERE_DEBUG_LOG_USE_UART_B) || defined(MESOSPHERE_DEBUG_LOG_USE_UART_C) || defined(MESOSPHERE_DEBUG_LOG_USE_UART_D)
|
||||
#if defined(MESOSPHERE_DEBUG_LOG_USE_UART)
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr bool DoSaveAndRestore = false;
|
||||
|
||||
enum UartRegister {
|
||||
UartRegister_THR = 0,
|
||||
UartRegister_IER = 1,
|
||||
@@ -38,13 +40,13 @@ namespace ams::kern {
|
||||
|
||||
KVirtualAddress g_uart_address = 0;
|
||||
|
||||
constinit u32 g_saved_registers[5];
|
||||
[[maybe_unused]] constinit u32 g_saved_registers[5];
|
||||
|
||||
NOINLINE u32 ReadUartRegister(UartRegister which) {
|
||||
ALWAYS_INLINE u32 ReadUartRegister(UartRegister which) {
|
||||
return GetPointer<volatile u32>(g_uart_address)[which];
|
||||
}
|
||||
|
||||
NOINLINE void WriteUartRegister(UartRegister which, u32 value) {
|
||||
ALWAYS_INLINE void WriteUartRegister(UartRegister which, u32 value) {
|
||||
GetPointer<volatile u32>(g_uart_address)[which] = value;
|
||||
}
|
||||
|
||||
@@ -86,43 +88,47 @@ namespace ams::kern {
|
||||
}
|
||||
|
||||
void KDebugLogImpl::Save() {
|
||||
/* Save LCR, IER, FCR. */
|
||||
g_saved_registers[0] = ReadUartRegister(UartRegister_LCR);
|
||||
g_saved_registers[1] = ReadUartRegister(UartRegister_IER);
|
||||
g_saved_registers[2] = ReadUartRegister(UartRegister_FCR);
|
||||
if constexpr (DoSaveAndRestore) {
|
||||
/* Save LCR, IER, FCR. */
|
||||
g_saved_registers[0] = ReadUartRegister(UartRegister_LCR);
|
||||
g_saved_registers[1] = ReadUartRegister(UartRegister_IER);
|
||||
g_saved_registers[2] = ReadUartRegister(UartRegister_FCR);
|
||||
|
||||
/* Set Divisor Latch Access bit, to allow access to DLL/DLH */
|
||||
WriteUartRegister(UartRegister_LCR, 0x80);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
/* Set Divisor Latch Access bit, to allow access to DLL/DLH */
|
||||
WriteUartRegister(UartRegister_LCR, 0x80);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
|
||||
/* Save DLL/DLH. */
|
||||
g_saved_registers[3] = ReadUartRegister(UartRegister_DLL);
|
||||
g_saved_registers[4] = ReadUartRegister(UartRegister_DLH);
|
||||
/* Save DLL/DLH. */
|
||||
g_saved_registers[3] = ReadUartRegister(UartRegister_DLL);
|
||||
g_saved_registers[4] = ReadUartRegister(UartRegister_DLH);
|
||||
|
||||
/* Restore Divisor Latch Access bit. */
|
||||
WriteUartRegister(UartRegister_LCR, g_saved_registers[0]);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
/* Restore Divisor Latch Access bit. */
|
||||
WriteUartRegister(UartRegister_LCR, g_saved_registers[0]);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
}
|
||||
}
|
||||
|
||||
void KDebugLogImpl::Restore() {
|
||||
/* Set Divisor Latch Access bit, to allow access to DLL/DLH */
|
||||
WriteUartRegister(UartRegister_LCR, 0x80);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
if constexpr (DoSaveAndRestore) {
|
||||
/* Set Divisor Latch Access bit, to allow access to DLL/DLH */
|
||||
WriteUartRegister(UartRegister_LCR, 0x80);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
|
||||
/* Restore DLL/DLH. */
|
||||
WriteUartRegister(UartRegister_DLL, g_saved_registers[3]);
|
||||
WriteUartRegister(UartRegister_DLH, g_saved_registers[4]);
|
||||
ReadUartRegister(UartRegister_DLH);
|
||||
/* Restore DLL/DLH. */
|
||||
WriteUartRegister(UartRegister_DLL, g_saved_registers[3]);
|
||||
WriteUartRegister(UartRegister_DLH, g_saved_registers[4]);
|
||||
ReadUartRegister(UartRegister_DLH);
|
||||
|
||||
/* Restore Divisor Latch Access bit. */
|
||||
WriteUartRegister(UartRegister_LCR, g_saved_registers[0]);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
/* Restore Divisor Latch Access bit. */
|
||||
WriteUartRegister(UartRegister_LCR, g_saved_registers[0]);
|
||||
ReadUartRegister(UartRegister_LCR);
|
||||
|
||||
/* Restore IER and FCR. */
|
||||
WriteUartRegister(UartRegister_IER, g_saved_registers[1]);
|
||||
WriteUartRegister(UartRegister_FCR, g_saved_registers[2] | 2);
|
||||
WriteUartRegister(UartRegister_IRDA_CSR, 0x02);
|
||||
ReadUartRegister(UartRegister_FCR);
|
||||
/* Restore IER and FCR. */
|
||||
WriteUartRegister(UartRegister_IER, g_saved_registers[1]);
|
||||
WriteUartRegister(UartRegister_FCR, g_saved_registers[2] | 2);
|
||||
WriteUartRegister(UartRegister_IRDA_CSR, 0x02);
|
||||
ReadUartRegister(UartRegister_FCR);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_IRAM_RINGBUFFER)
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace ams::kern {
|
||||
constexpr size_t CarveoutSizeMax = 512_MB - CarveoutAlignment;
|
||||
|
||||
ALWAYS_INLINE bool SetupUartPhysicalMemoryRegion() {
|
||||
#if defined(MESOSPHERE_DEBUG_LOG_USE_UART_A)
|
||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006000, 0x40, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_B)
|
||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006040, 0x40, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_C)
|
||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006200, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_D)
|
||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006300, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
#if defined(MESOSPHERE_DEBUG_LOG_USE_UART)
|
||||
switch (KSystemControl::Init::GetDebugLogUartPort()) {
|
||||
case 0: return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006000, 0x40, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
case 1: return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006040, 0x40, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
case 2: return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006200, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
case 3: return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006300, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
default: return false;
|
||||
}
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_IRAM_RINGBUFFER)
|
||||
return true;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user