mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-03-01 16:00:38 +01:00
kern: add build-define for logging to iram ringbuffer
This commit is contained in:
parent
28ceedb533
commit
4df583cbb6
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
namespace ams::kern {
|
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)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
enum UartRegister {
|
enum UartRegister {
|
||||||
@ -138,4 +140,52 @@ namespace ams::kern {
|
|||||||
ReadUartRegister(UartRegister_FCR);
|
ReadUartRegister(UartRegister_FCR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(MESOSPHERE_DEBUG_LOG_USE_IRAM_RINGBUFFER)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constinit KVirtualAddress g_debug_iram_address = 0;
|
||||||
|
|
||||||
|
constexpr size_t RingBufferSize = 0x5000;
|
||||||
|
constinit uintptr_t g_offset = 0;
|
||||||
|
|
||||||
|
constinit u8 g_saved_buffer[RingBufferSize];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KDebugLogImpl::Initialize() {
|
||||||
|
/* Set the base address. */
|
||||||
|
g_debug_iram_address = KMemoryLayout::GetDeviceVirtualAddress(KMemoryRegionType_LegacyLpsIram) + 0x38000;
|
||||||
|
|
||||||
|
std::memset(GetVoidPointer(g_debug_iram_address), 0xFF, RingBufferSize);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDebugLogImpl::PutChar(char c) {
|
||||||
|
GetPointer<char>(g_debug_iram_address)[g_offset++] = c;
|
||||||
|
|
||||||
|
if (g_offset == RingBufferSize) {
|
||||||
|
g_offset = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDebugLogImpl::Flush() {
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDebugLogImpl::Save() {
|
||||||
|
std::memcpy(g_saved_buffer, GetVoidPointer(g_debug_iram_address), RingBufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDebugLogImpl::Restore() {
|
||||||
|
std::memcpy(GetVoidPointer(g_debug_iram_address), g_saved_buffer, RingBufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error "Unknown Debug UART device!"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ namespace ams::kern {
|
|||||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006200, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006200, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_D)
|
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_D)
|
||||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006300, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006300, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||||
|
#elif defined(MESOSPHERE_DEBUG_LOG_USE_IRAM_RINGBUFFER)
|
||||||
|
return true;
|
||||||
#else
|
#else
|
||||||
#error "Unknown Debug UART device!"
|
#error "Unknown Debug UART device!"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user