1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-15 00:16:48 +00:00

thermosphere: seriaLog => debugLog, add DEBUG macro

This commit is contained in:
TuxSH 2019-07-31 02:30:17 +02:00
parent 6d33ebceef
commit ecb4857cbb
5 changed files with 28 additions and 19 deletions

View file

@ -15,12 +15,12 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "log.h" #include "debug_log.h"
#include "platform/uart.h" #include "platform/uart.h"
#include "utils.h" #include "utils.h"
// NOTE: UNSAFE! // NOTE: UNSAFE!
int serialLog(const char *fmt, ...) int debugLog(const char *fmt, ...)
{ {
char buf[128]; char buf[128];
va_list args; va_list args;

View file

@ -17,4 +17,10 @@
#pragma once #pragma once
#include <stdarg.h> #include <stdarg.h>
int serialLog(const char *fmt, ...); #ifndef NDEBUG
#define DEBUG(...) debugLog(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
int debugLog(const char *fmt, ...);

View file

@ -20,7 +20,7 @@
#include "smc.h" #include "smc.h"
#include "core_ctx.h" #include "core_ctx.h"
#include "log.h" #include "debug_log.h"
bool spsrEvaluateConditionCode(u64 spsr, u32 conditionCode) bool spsrEvaluateConditionCode(u64 spsr, u32 conditionCode)
{ {
@ -50,18 +50,21 @@ void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
{ {
#ifndef NDEBUG #ifndef NDEBUG
for (u32 i = 0; i < 30; i += 2) { for (u32 i = 0; i < 30; i += 2) {
serialLog("x%u\t\t%016llx\t\tx%u\t\t%016llx\n", i, frame->x[i], i + 1, frame->x[i + 1]); DEBUG("x%u\t\t%016llx\t\tx%u\t\t%016llx\n", i, frame->x[i], i + 1, frame->x[i + 1]);
} }
serialLog("x30\t\t%016llx\n\n", frame->x[30]); DEBUG("x30\t\t%016llx\n\n", frame->x[30]);
serialLog("elr_el2\t\t%016llx\n", frame->elr_el2); DEBUG("elr_el2\t\t%016llx\n", frame->elr_el2);
serialLog("spsr_el2\t%016llx\n", frame->spsr_el2); DEBUG("spsr_el2\t%016llx\n", frame->spsr_el2);
if (sameEl) { if (sameEl) {
serialLog("sp_el2\t\t%016llx\n", frame->sp_el2); DEBUG("sp_el2\t\t%016llx\n", frame->sp_el2);
} else { } else {
serialLog("sp_el0\t\t%016llx\n", frame->sp_el0); DEBUG("sp_el0\t\t%016llx\n", frame->sp_el0);
} }
serialLog("sp_el1\t\t%016llx\n", frame->sp_el1); DEBUG("sp_el1\t\t%016llx\n", frame->sp_el1);
#else
(void)frame;
(void)sameEl;
#endif #endif
} }
@ -119,7 +122,7 @@ void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeReg
break; break;
default: default:
serialLog("Lower EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\n", (u64)esr.ec, esr.il, esr.iss); DEBUG("Lower EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\n", (u64)esr.ec, esr.il, esr.iss);
dumpStackFrame(frame, false); dumpStackFrame(frame, false);
break; break;
} }
@ -127,11 +130,11 @@ void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeReg
void handleSameElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr) void handleSameElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{ {
serialLog("Same EL sync exception on core %x, EC = 0x%02llx IL=%llu ISS=0x%06llx\n", currentCoreCtx->coreId, (u64)esr.ec, esr.il, esr.iss); DEBUG("Same EL sync exception on core %x, EC = 0x%02llx IL=%llu ISS=0x%06llx\n", currentCoreCtx->coreId, (u64)esr.ec, esr.il, esr.iss);
dumpStackFrame(frame, true); dumpStackFrame(frame, true);
} }
void handleUnknownException(u32 offset) void handleUnknownException(u32 offset)
{ {
serialLog("Unknown exception on core %x! (offset 0x%03lx)\n", offset, currentCoreCtx->coreId); DEBUG("Unknown exception on core %x! (offset 0x%03lx)\n", offset, currentCoreCtx->coreId);
} }

View file

@ -15,14 +15,14 @@
*/ */
#include "hvc.h" #include "hvc.h"
#include "log.h" #include "debug_log.h"
void handleHypercall(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr) void handleHypercall(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{ {
u32 id = esr.iss; u32 id = esr.iss;
switch (id) { switch (id) {
default: default:
serialLog("Unhandled hypercall: 0x%x.\n"); DEBUG("Unhandled hypercall: 0x%x.\n");
dumpStackFrame(frame, false); dumpStackFrame(frame, false);
break; break;
} }

View file

@ -1,6 +1,6 @@
#include "utils.h" #include "utils.h"
#include "core_ctx.h" #include "core_ctx.h"
#include "log.h" #include "debug_log.h"
#include "platform/uart.h" #include "platform/uart.h"
#include "traps.h" #include "traps.h"
@ -10,11 +10,11 @@ int main(void)
if (currentCoreCtx->coreId == 0) { if (currentCoreCtx->coreId == 0) {
uartInit(115200); uartInit(115200);
serialLog("Hello from Thermosphere!\n"); DEBUG("Hello from Thermosphere!\n");
__builtin_trap(); __builtin_trap();
} }
else { else {
serialLog("Core %u booted\n", currentCoreCtx->coreId); DEBUG("Core %u booted\n", currentCoreCtx->coreId);
} }
return 0; return 0;