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 "log.h"
#include "debug_log.h"
#include "platform/uart.h"
#include "utils.h"
// NOTE: UNSAFE!
int serialLog(const char *fmt, ...)
int debugLog(const char *fmt, ...)
{
char buf[128];
va_list args;

View file

@ -17,4 +17,10 @@
#pragma once
#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 "core_ctx.h"
#include "log.h"
#include "debug_log.h"
bool spsrEvaluateConditionCode(u64 spsr, u32 conditionCode)
{
@ -50,18 +50,21 @@ void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
{
#ifndef NDEBUG
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]);
serialLog("elr_el2\t\t%016llx\n", frame->elr_el2);
serialLog("spsr_el2\t%016llx\n", frame->spsr_el2);
DEBUG("x30\t\t%016llx\n\n", frame->x[30]);
DEBUG("elr_el2\t\t%016llx\n", frame->elr_el2);
DEBUG("spsr_el2\t%016llx\n", frame->spsr_el2);
if (sameEl) {
serialLog("sp_el2\t\t%016llx\n", frame->sp_el2);
DEBUG("sp_el2\t\t%016llx\n", frame->sp_el2);
} 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
}
@ -119,7 +122,7 @@ void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeReg
break;
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);
break;
}
@ -127,11 +130,11 @@ void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeReg
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);
}
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 "log.h"
#include "debug_log.h"
void handleHypercall(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{
u32 id = esr.iss;
switch (id) {
default:
serialLog("Unhandled hypercall: 0x%x.\n");
DEBUG("Unhandled hypercall: 0x%x.\n");
dumpStackFrame(frame, false);
break;
}

View file

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