add uart logging feature

This commit is contained in:
souldbminersmwc
2026-07-25 12:39:31 -04:00
parent 30371125c6
commit 9d12aa5cb1
8 changed files with 330 additions and 6 deletions

View File

@@ -70,6 +70,29 @@ namespace ams::ldr::hoc {
return rc;
}
void UartLog(const char *fmt, ...) {
char line[256];
constexpr size_t PrefixLen = 13; /* "[HOC] " */
std::memcpy(line, "[Horizon OC] ", PrefixLen);
va_list args;
va_start(args, fmt);
int n = vsnprintf(line + PrefixLen, sizeof(line) - PrefixLen - 1, fmt, args);
va_end(args);
if (n < 0) {
return;
}
size_t body = static_cast<size_t>(n);
if (body > sizeof(line) - PrefixLen - 2) { /* vsnprintf returns the untruncated length */
body = sizeof(line) - PrefixLen - 2;
}
size_t len = PrefixLen + body;
line[len++] = '\n';
svc::OutputDebugString(line, len);
}
struct log_ctx_t {
u32 magic;
u32 sz;