mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-28 01:20:58 +01:00
libexo/sc7fw: support release/debug/audit
This commit is contained in:
parent
f74527d93c
commit
71a38ae74d
@ -7,20 +7,18 @@ export ATMOSPHERE_CPU := arm7tdmi
|
||||
#---------------------------------------------------------------------------------
|
||||
# pull in common atmosphere configuration
|
||||
#---------------------------------------------------------------------------------
|
||||
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CURRENT_DIRECTORY := $(abspath $(dir $(THIS_MAKEFILE)))
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../../libraries/config/templates/exosphere.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
ifneq ($(__RECURSIVE__),1)
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
||||
@ -50,41 +48,73 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I.
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib -L$(dir)/$(ATMOSPHERE_LIBRARY_DIR))
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/$(ATMOSPHERE_LIBRARY_DIR))
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
export TOPDIR := $(CURRENT_DIRECTORY)
|
||||
|
||||
OUTPUT_BASE := $(TOPDIR)/$(notdir $(TOPDIR))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD) check_libexo
|
||||
|
||||
$(BUILD): check_libexo
|
||||
ATMOSPHERE_BUILD_CONFIGS :=
|
||||
all: release
|
||||
|
||||
define ATMOSPHERE_ADD_TARGET
|
||||
|
||||
ATMOSPHERE_BUILD_CONFIGS += $(strip $1)
|
||||
|
||||
$(strip $1): check_libexo_$(strip $1) $$(ATMOSPHERE_BUILD_DIR)/$(strip $1)
|
||||
@$$(MAKE) __RECURSIVE__=1 OUTPUT=$$(OUTPUT_BASE)$(strip $2) $(3) \
|
||||
DEPSDIR=$$(CURDIR)/$$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
||||
LIBEXOSPHERE_NAME=exosphere$(strip $2) \
|
||||
--no-print-directory -C $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
||||
-f $$(THIS_MAKEFILE)
|
||||
|
||||
check_libexo_$(strip $1):
|
||||
@$$(MAKE) --no-print-directory -C $$(ATMOSPHERE_LIBRARIES_DIR)/libexosphere $$(ATMOSPHERE_ARCH_NAME)-$(strip $1)
|
||||
|
||||
clean-$(strip $1):
|
||||
@echo clean $(strip $1) ...
|
||||
@rm -fr $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) $$(OUTPUT_BASE)$(strip $2).bin $$(OUTPUT_BASE)$(strip $2).elf
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, release, , \
|
||||
ATMOSPHERE_BUILD_SETTINGS="-DAMS_FORCE_DISABLE_DETAILED_ASSERTIONS" \
|
||||
))
|
||||
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, debug, _debug, \
|
||||
ATMOSPHERE_BUILD_SETTINGS="-DAMS_FORCE_DISABLE_DETAILED_ASSERTIONS -DAMS_BUILD_FOR_DEBUGGING" \
|
||||
))
|
||||
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, audit, _audit, \
|
||||
ATMOSPHERE_BUILD_SETTINGS="-DAMS_FORCE_DISABLE_DETAILED_ASSERTIONS -DAMS_BUILD_FOR_AUDITING" \
|
||||
))
|
||||
|
||||
$(ATMOSPHERE_BUILD_DIR)/%:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
check_libexo:
|
||||
@$(MAKE) --no-print-directory -C ../../../libraries/libexosphere arm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).elf *.lz4
|
||||
clean: $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),clean-$(config))
|
||||
|
||||
.PHONY: all clean $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),$(config) clean-$(config))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
.PHONY: all
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
all : $(OUTPUT).bin
|
||||
|
||||
$(OUTPUT).bin : $(OUTPUT).elf
|
||||
$(OBJCOPY) -S -O binary --set-section-flags .bss=alloc,load,contents $< $@
|
||||
@echo built ... $(notdir $@)
|
||||
|
||||
$(OUTPUT).elf : $(OFILES) ../../../../libraries/libexosphere/$(ATMOSPHERE_LIBRARY_DIR)/libexosphere.a
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
$(OFILES) : $(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/$(ATMOSPHERE_LIBRARY_DIR)/lib$(LIBEXOSPHERE_NAME).a
|
||||
|
||||
%.elf:
|
||||
@echo linking $(notdir $@)
|
||||
|
@ -115,4 +115,6 @@ namespace ams::diag {
|
||||
sc7fw::ExceptionHandler();
|
||||
}
|
||||
|
||||
#include <exosphere/diag/diag_detailed_assertion_impl.inc>
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
|
||||
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
|
||||
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
|
||||
|
||||
export LIBS := -lexosphere
|
||||
export LIBS := -l$(LIBEXOSPHERE_NAME)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
@ -6,16 +6,16 @@ define ATMOSPHERE_ADD_TARGET
|
||||
ATMOSPHERE_BUILD_CONFIGS += $(strip $1)
|
||||
|
||||
arm64-$(strip $1):
|
||||
$$(MAKE) -f arm64.mk $(strip $1)
|
||||
@$$(MAKE) -f arm64.mk $(strip $1)
|
||||
|
||||
arm-$(strip $1):
|
||||
$$(MAKE) -f arm.mk $(strip $1)
|
||||
@$$(MAKE) -f arm.mk $(strip $1)
|
||||
|
||||
clean-arm64-$(strip $1):
|
||||
$$(MAKE) -f arm64.mk clean-$(strip $1)
|
||||
@$$(MAKE) -f arm64.mk clean-$(strip $1)
|
||||
|
||||
clean-arm-$(strip $1):
|
||||
$$(MAKE) -f arm.mk clean-$(strip $1)
|
||||
@$$(MAKE) -f arm.mk clean-$(strip $1)
|
||||
|
||||
endef
|
||||
|
||||
@ -24,10 +24,10 @@ $(eval $(call ATMOSPHERE_ADD_TARGET, debug))
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, audit))
|
||||
|
||||
clean-arm64:
|
||||
$(MAKE) -f arm64.mk clean
|
||||
@$(MAKE) -f arm64.mk clean
|
||||
|
||||
clean-arm:
|
||||
$(MAKE) -f arm.mk clean
|
||||
@$(MAKE) -f arm.mk clean
|
||||
|
||||
clean: clean-arm64 clean-arm
|
||||
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
|
||||
{
|
||||
AMS_LOG("Abort Called\n");
|
||||
AMS_LOG(" Location: %s:%d\n", file, line);
|
||||
AMS_LOG(" Function: %s\n", func);
|
||||
AMS_LOG(" Expression: %s\n", expr);
|
||||
AMS_LOG(" Value: %016" PRIx64 "\n", value);
|
||||
AMS_LOG("\n");
|
||||
}
|
||||
#else
|
||||
AMS_UNUSED(file, line, func, expr, value);
|
||||
#endif
|
||||
AbortImpl();
|
||||
}
|
||||
|
||||
void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
|
||||
{
|
||||
AMS_LOG("Abort Called\n");
|
||||
AMS_LOG(" Location: %s:%d\n", file, line);
|
||||
AMS_LOG(" Function: %s\n", func);
|
||||
AMS_LOG(" Expression: %s\n", expr);
|
||||
AMS_LOG(" Value: %016" PRIx64 "\n", value);
|
||||
AMS_LOG("\n");
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
AMS_VLOG(format, vl);
|
||||
va_end(vl);
|
||||
AMS_LOG("\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
AMS_UNUSED(file, line, func, expr, value, format);
|
||||
#endif
|
||||
AbortImpl();
|
||||
}
|
||||
|
||||
void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
|
||||
{
|
||||
AMS_LOG("Assertion Failure\n");
|
||||
AMS_LOG(" Location: %s:%d\n", file, line);
|
||||
AMS_LOG(" Function: %s\n", func);
|
||||
AMS_LOG(" Expression: %s\n", expr);
|
||||
AMS_LOG(" Value: %016" PRIx64 "\n", value);
|
||||
AMS_LOG("\n");
|
||||
}
|
||||
#else
|
||||
AMS_UNUSED(file, line, func, expr, value);
|
||||
#endif
|
||||
AbortImpl();
|
||||
}
|
||||
|
||||
void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
|
||||
{
|
||||
AMS_LOG("Assertion Failure\n");
|
||||
AMS_LOG(" Location: %s:%d\n", file, line);
|
||||
AMS_LOG(" Function: %s\n", func);
|
||||
AMS_LOG(" Expression: %s\n", expr);
|
||||
AMS_LOG(" Value: %016" PRIx64 "\n", value);
|
||||
AMS_LOG("\n");
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
AMS_VLOG(format, vl);
|
||||
va_end(vl);
|
||||
AMS_LOG("\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
AMS_UNUSED(file, line, func, expr, value, format);
|
||||
#endif
|
||||
AbortImpl();
|
||||
}
|
@ -18,10 +18,30 @@
|
||||
|
||||
namespace ams::log {
|
||||
|
||||
#if defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
||||
#define AMS_IMPL_ENABLE_LOG
|
||||
#endif
|
||||
|
||||
#if defined(AMS_IMPL_ENABLE_LOG)
|
||||
#define AMS_LOG(...) ::ams::log::Printf(__VA_ARGS__)
|
||||
#define AMS_VLOG(...) ::ams::log::VPrintf(__VA_ARGS__)
|
||||
#define AMS_DUMP(...) ::ams::log::Dump(__VA_ARGS__)
|
||||
#define AMS_LOG_FLUSH() ::ams::log::Flush()
|
||||
#else
|
||||
#define AMS_LOG(...) static_cast<void>(0)
|
||||
#define AMS_VLOG(...) static_cast<void>(0)
|
||||
#define AMS_DUMP(...) static_cast<void>(0)
|
||||
#define AMS_LOG_FLUSH() static_cast<void>(0)
|
||||
#endif
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
void Printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
void VPrintf(const char *fmt, ::std::va_list vl);
|
||||
void Dump(const void *src, size_t size);
|
||||
|
||||
void SendText(const void *text, size_t size);
|
||||
void Flush();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* 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 <vapours.hpp>
|
||||
#include <exosphere/log.hpp>
|
||||
|
||||
#define AMS_SECMON_LOG(...) AMS_LOG(" [secmon] " __VA_ARGS__)
|
@ -155,6 +155,106 @@ signed __aeabi_idivmod(signed numerator, signed denominator)
|
||||
return ret_idivmod_values(qr.q, qr.r);
|
||||
}
|
||||
|
||||
/* struct lqr - stores qutient/remainder to handle divmod EABI interfaces. */
|
||||
struct lqr {
|
||||
unsigned long long q; /* computed quotient */
|
||||
unsigned long long r; /* computed remainder */
|
||||
unsigned q_n; /* specficies if quotient shall be negative */
|
||||
unsigned r_n; /* specficies if remainder shall be negative */
|
||||
};
|
||||
|
||||
static void ul_div_qr(unsigned long long numerator,
|
||||
unsigned long long denominator, struct lqr *qr);
|
||||
|
||||
|
||||
static void division_lqr(unsigned long long n, unsigned long long p,
|
||||
struct lqr *qr)
|
||||
{
|
||||
unsigned long long i = 1, q = 0;
|
||||
if (p == 0) {
|
||||
qr->r = 0xFFFFFFFFFFFFFFFFULL; /* division by 0 */
|
||||
return;
|
||||
}
|
||||
|
||||
while ((p >> 63) == 0) {
|
||||
i = i << 1; /* count the max division steps */
|
||||
p = p << 1; /* increase p until it has maximum size*/
|
||||
}
|
||||
|
||||
while (i > 0) {
|
||||
q = q << 1; /* write bit in q at index (size-1) */
|
||||
if (n >= p) {
|
||||
n -= p;
|
||||
q++;
|
||||
}
|
||||
p = p >> 1; /* decrease p */
|
||||
i = i >> 1; /* decrease remaining size in q */
|
||||
}
|
||||
qr->r = n;
|
||||
qr->q = q;
|
||||
}
|
||||
|
||||
static void ul_div_qr(unsigned long long numerator,
|
||||
unsigned long long denominator, struct lqr *qr)
|
||||
{
|
||||
|
||||
division_lqr(numerator, denominator, qr);
|
||||
|
||||
/* negate quotient and/or remainder according to requester */
|
||||
if (qr->q_n)
|
||||
qr->q = -qr->q;
|
||||
if (qr->r_n)
|
||||
qr->r = -qr->r;
|
||||
}
|
||||
|
||||
struct asm_ulqr {
|
||||
unsigned long long v0;
|
||||
unsigned long long v1;
|
||||
};
|
||||
|
||||
/* called from assembly function __aeabi_uldivmod */
|
||||
void __ul_divmod(struct asm_ulqr *asm_ulqr);
|
||||
void __ul_divmod(struct asm_ulqr *asm_ulqr)
|
||||
{
|
||||
unsigned long long numerator = asm_ulqr->v0;
|
||||
unsigned long long denominator = asm_ulqr->v1;
|
||||
struct lqr qr = { .q_n = 0, .r_n = 0 };
|
||||
|
||||
ul_div_qr(numerator, denominator, &qr);
|
||||
|
||||
asm_ulqr->v0 = qr.q;
|
||||
asm_ulqr->v1 = qr.r;
|
||||
}
|
||||
|
||||
struct asm_lqr {
|
||||
long long v0;
|
||||
long long v1;
|
||||
};
|
||||
|
||||
/* called from assembly function __aeabi_ldivmod */
|
||||
void __l_divmod(struct asm_lqr *asm_lqr);
|
||||
void __l_divmod(struct asm_lqr *asm_lqr)
|
||||
{
|
||||
long long numerator = asm_lqr->v0;
|
||||
long long denominator = asm_lqr->v1;
|
||||
struct lqr qr = { .q_n = 0, .r_n = 0 };
|
||||
|
||||
if (((numerator < 0) && (denominator > 0)) ||
|
||||
((numerator > 0) && (denominator < 0)))
|
||||
qr.q_n = 1; /* quotient shall be negate */
|
||||
if (numerator < 0) {
|
||||
numerator = -numerator;
|
||||
qr.r_n = 1; /* remainder shall be negate */
|
||||
}
|
||||
if (denominator < 0)
|
||||
denominator = -denominator;
|
||||
|
||||
ul_div_qr(numerator, denominator, &qr);
|
||||
|
||||
asm_lqr->v0 = qr.q;
|
||||
asm_lqr->v1 = qr.r;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
@ -28,3 +28,40 @@ ret_uidivmod_values:
|
||||
bx lr
|
||||
.type ret_uidivmod_values, %function
|
||||
.size ret_uidivmod_values, .-ret_uidivmod_values
|
||||
|
||||
/*
|
||||
* __value_in_regs lldiv_t __aeabi_ldivmod( long long n, long long d)
|
||||
*/
|
||||
.section .text.__aeabi_ldivmod, "ax", %progbits
|
||||
.globl __aeabi_ldivmod
|
||||
.align 0
|
||||
.syntax unified
|
||||
__aeabi_ldivmod:
|
||||
push {ip, lr}
|
||||
push {r0-r3}
|
||||
mov r0, sp
|
||||
bl __l_divmod
|
||||
pop {r0-r3}
|
||||
pop {ip, pc}
|
||||
|
||||
.type __aeabi_ldivmod, %function
|
||||
.size __aeabi_ldivmod, .-__aeabi_ldivmod
|
||||
|
||||
/*
|
||||
* __value_in_regs ulldiv_t __aeabi_uldivmod(
|
||||
* unsigned long long n, unsigned long long d)
|
||||
*/
|
||||
.section .text.__aeabi_uldivmod , "ax", %progbits
|
||||
.globl __aeabi_uldivmod
|
||||
.align 0
|
||||
.syntax unified
|
||||
__aeabi_uldivmod :
|
||||
push {ip, lr}
|
||||
push {r0-r3}
|
||||
mov r0, sp
|
||||
bl __ul_divmod
|
||||
pop {r0-r3}
|
||||
pop {ip, pc}
|
||||
|
||||
.type __aeabi_uldivmod, %function
|
||||
.size __aeabi_uldivmod, .-__aeabi_uldivmod
|
||||
|
@ -33,3 +33,22 @@ __gnu_thumb1_case_uqi:
|
||||
bx lr
|
||||
.type __gnu_thumb1_case_uqi, %function
|
||||
.size __gnu_thumb1_case_uqi, .-__gnu_thumb1_case_uqi
|
||||
|
||||
.section .text.__gnu_thumb1_case_uhi, "ax", %progbits
|
||||
.globl __gnu_thumb1_case_uhi
|
||||
.align 0
|
||||
.thumb_func
|
||||
.syntax unified
|
||||
__gnu_thumb1_case_uhi:
|
||||
push {r0, r1}
|
||||
mov r1, lr
|
||||
lsrs r1, r1, #1
|
||||
lsls r0, r0, #1
|
||||
lsls r1, r1, #1
|
||||
ldrh r1, [r1, r0]
|
||||
lsls r1, r1, #1
|
||||
add lr, lr, r1
|
||||
pop {r0, r1}
|
||||
bx lr
|
||||
.type __gnu_thumb1_case_uhi, %function
|
||||
.size __gnu_thumb1_case_uhi, .-__gnu_thumb1_case_uhi
|
||||
|
@ -20,8 +20,8 @@ namespace ams::log {
|
||||
namespace {
|
||||
|
||||
constexpr inline uart::Port UartLogPort = uart::Port_ReservedDebug;
|
||||
constexpr inline int UartBaudRate = 115200;
|
||||
constinit bool g_initialized_uart = false;
|
||||
constinit bool g_logging_enabled = false;
|
||||
|
||||
constexpr inline u32 UartPortFlags = [] {
|
||||
if constexpr (UartLogPort == uart::Port_ReservedDebug) {
|
||||
@ -78,20 +78,51 @@ namespace ams::log {
|
||||
g_initialized_uart = false;
|
||||
}
|
||||
|
||||
void SetDebugLogEnabled(bool en) {
|
||||
g_logging_enabled = en;
|
||||
NOINLINE void VPrintf(const char *fmt, ::std::va_list vl) {
|
||||
/* TODO: What's a good size for the log buffer? Nintendo uses 0x100, but this seems big. */
|
||||
char log_buf[0x80];
|
||||
const auto len = util::TVSNPrintf(log_buf, sizeof(log_buf), fmt, vl);
|
||||
|
||||
if (g_initialized_uart) {
|
||||
uart::SendText(UartLogPort, log_buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
NOINLINE void Printf(const char *fmt, ...) {
|
||||
::std::va_list vl;
|
||||
va_start(vl, fmt);
|
||||
VPrintf(fmt, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
NOINLINE void Dump(const void *src, size_t size) {
|
||||
const u8 *src_u8 = static_cast<const u8 *>(src);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if ((i % 0x20) == 0x00) {
|
||||
Printf("%03zx| ", i);
|
||||
}
|
||||
Printf("%02x ", src_u8[i]);
|
||||
if ((i % 0x20) == 0x1F) {
|
||||
Printf("\n");
|
||||
}
|
||||
}
|
||||
if ((size % 0x20) != 0) {
|
||||
Printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendText(const void *text, size_t size) {
|
||||
if (g_initialized_uart && g_logging_enabled) {
|
||||
if (g_initialized_uart) {
|
||||
uart::SendText(UartLogPort, text, size);
|
||||
}
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
if (g_initialized_uart && g_logging_enabled) {
|
||||
if (g_initialized_uart) {
|
||||
uart::WaitFlush(UartLogPort);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace ams::diag {
|
||||
|
||||
inline void DebugLog(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#ifdef AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
os::Mutex g_debug_log_lock(true);
|
||||
char g_debug_buffer[0x400];
|
||||
|
||||
@ -73,9 +73,9 @@ namespace ams::diag {
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog(" Value: %016" PRIx64 "\n", value);
|
||||
DebugLog("\n");
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#ifdef AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
@ -93,7 +93,7 @@ namespace ams::diag {
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog(" Value: %016" PRIx64 "\n", value);
|
||||
DebugLog("\n");
|
||||
DebugLog("\n");
|
||||
|
||||
@ -105,9 +105,9 @@ namespace ams::diag {
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog(" Value: %016" PRIx64 "\n", value);
|
||||
DebugLog("\n");
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#ifdef AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
{
|
||||
::std::va_list vl;
|
||||
va_start(vl, format);
|
||||
@ -125,7 +125,7 @@ namespace ams::diag {
|
||||
DebugLog(" Location: %s:%d\n", file, line);
|
||||
DebugLog(" Function: %s\n", func);
|
||||
DebugLog(" Expression: %s\n", expr);
|
||||
DebugLog(" Value: %016lx\n", value);
|
||||
DebugLog(" Value: %016" PRIx64 "\n", value);
|
||||
DebugLog("\n");
|
||||
DebugLog("\n");
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace ams::diag {
|
||||
|
||||
}
|
||||
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#ifdef AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
#define AMS_CALL_ASSERT_FAIL_IMPL(cond, ...) ::ams::diag::AssertionFailureImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__)
|
||||
#define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__)
|
||||
#else
|
||||
|
@ -17,15 +17,29 @@
|
||||
#include <vapours/includes.hpp>
|
||||
#include <vapours/defines.hpp>
|
||||
|
||||
#if 0
|
||||
#define AMS_BUILD_FOR_AUDITING
|
||||
#ifdef AMS_BUILD_FOR_AUDITING
|
||||
|
||||
#define AMS_BUILD_FOR_DEBUGGING
|
||||
|
||||
#if !defined(AMS_FORCE_DISABLE_DETAILED_ASSERTIONS)
|
||||
#define AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
#endif
|
||||
|
||||
#ifdef AMS_BUILD_FOR_AUDITING
|
||||
#define AMS_BUILD_FOR_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifdef AMS_BUILD_FOR_DEBUGGING
|
||||
|
||||
#define AMS_ENABLE_ASSERTIONS
|
||||
#define AMS_ENABLE_DEBUG_PRINT
|
||||
|
||||
#if !defined(AMS_ENABLE_DETAILED_ASSERTIONS) && !defined(AMS_FORCE_DISABLE_DETAILED_ASSERTIONS)
|
||||
|
||||
#if !defined(ATMOSPHERE_IS_EXOSPHERE) || defined(AMS_FORCE_ENABLE_DETAILED_ASSERTIONS)
|
||||
|
||||
#define AMS_ENABLE_DETAILED_ASSERTIONS
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user