mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-22 18:32:05 +00:00
kern: add build-define for logging to iram ringbuffer
This commit is contained in:
parent
909397233c
commit
76957e502d
2 changed files with 52 additions and 0 deletions
|
@ -18,6 +18,8 @@
|
|||
|
||||
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 {
|
||||
|
||||
enum UartRegister {
|
||||
|
@ -138,4 +140,52 @@ namespace ams::kern {
|
|||
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);
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_UART_D)
|
||||
return KMemoryLayout::GetPhysicalMemoryRegionTree().Insert(0x70006300, 0x100, KMemoryRegionType_Uart | KMemoryRegionAttr_ShouldKernelMap);
|
||||
#elif defined(MESOSPHERE_DEBUG_LOG_USE_IRAM_RINGBUFFER)
|
||||
return true;
|
||||
#else
|
||||
#error "Unknown Debug UART device!"
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue