2020-02-06 10:05:35 +01:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-02-06 10:05:35 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <mesosphere/kern_common.hpp>
|
2020-07-09 22:07:38 +02:00
|
|
|
#include <mesosphere/svc/kern_svc_k_user_pointer.hpp>
|
2020-02-06 10:05:35 +01:00
|
|
|
|
|
|
|
namespace ams::kern {
|
|
|
|
|
|
|
|
class KDebugLog {
|
|
|
|
private:
|
|
|
|
static NOINLINE void VSNPrintf(char *dst, const size_t dst_size, const char *format, ::std::va_list vl);
|
|
|
|
public:
|
|
|
|
static NOINLINE void Initialize();
|
|
|
|
|
2020-02-07 15:26:01 +01:00
|
|
|
static NOINLINE void Printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
2020-02-06 10:05:35 +01:00
|
|
|
static NOINLINE void VPrintf(const char *format, ::std::va_list vl);
|
2020-07-09 22:07:38 +02:00
|
|
|
|
2021-09-18 01:44:57 +02:00
|
|
|
static NOINLINE void LogException(const char *str);
|
|
|
|
|
2020-07-09 22:07:38 +02:00
|
|
|
static NOINLINE Result PrintUserString(ams::kern::svc::KUserPointer<const char *> user_str, size_t len);
|
2020-07-24 12:29:12 +02:00
|
|
|
|
|
|
|
/* Functionality for preserving across sleep. */
|
|
|
|
static NOINLINE void Save();
|
|
|
|
static NOINLINE void Restore();
|
2020-02-06 10:05:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef MESOSPHERE_DEBUG_LOG_SELECTED
|
|
|
|
|
2020-02-15 04:58:57 +01:00
|
|
|
#ifdef ATMOSPHERE_BOARD_NINTENDO_NX
|
2020-12-08 04:25:06 +01:00
|
|
|
#define MESOSPHERE_DEBUG_LOG_USE_UART
|
2021-10-21 05:53:42 +02:00
|
|
|
#elif defined(ATMOSPHERE_BOARD_QEMU_VIRT)
|
|
|
|
#define MESOSPHERE_DEBUG_LOG_USE_SEMIHOSTING
|
2020-02-06 10:05:35 +01:00
|
|
|
#else
|
|
|
|
#error "Unknown board for Default Debug Log Source"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MESOSPHERE_DEBUG_LOG_SELECTED
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-09-18 01:44:57 +02:00
|
|
|
#define MESOSPHERE_EXCEPTION_LOG(str) ::ams::kern::KDebugLog::LogException(str)
|
|
|
|
|
2020-02-06 10:05:35 +01:00
|
|
|
#define MESOSPHERE_RELEASE_LOG(fmt, ...) ::ams::kern::KDebugLog::Printf((fmt), ## __VA_ARGS__)
|
|
|
|
#define MESOSPHERE_RELEASE_VLOG(fmt, vl) ::ams::kern::KDebugLog::VPrintf((fmt), (vl))
|
|
|
|
|
|
|
|
#ifdef MESOSPHERE_ENABLE_DEBUG_PRINT
|
|
|
|
#define MESOSPHERE_LOG(fmt, ...) MESOSPHERE_RELEASE_LOG((fmt), ## __VA_ARGS__)
|
|
|
|
#define MESOSPHERE_VLOG(fmt, vl) MESOSPHERE_RELEASE_VLOG((fmt), (vl))
|
|
|
|
#else
|
2020-02-20 19:14:27 +01:00
|
|
|
#define MESOSPHERE_LOG(fmt, ...) do { MESOSPHERE_UNUSED(fmt); MESOSPHERE_UNUSED(__VA_ARGS__); } while (0)
|
|
|
|
#define MESOSPHERE_VLOG(fmt, vl) do { MESOSPHERE_UNUSED(fmt); MESOSPHERE_UNUSED(vl); } while (0)
|
2020-02-06 10:05:35 +01:00
|
|
|
#endif
|