mirror of
https://github.com/wiiu-env/USBSerialLoggingModule.git
synced 2025-02-21 12:07:13 +01:00
Only do logging when built with make DEBUG=1
This commit is contained in:
parent
3bdcd6026b
commit
39cf41d163
7
Makefile
7
Makefile
@ -28,7 +28,7 @@ INCLUDES := source
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
CFLAGS := -g -Wall -Wextra -O0 -ffunction-sections\
|
CFLAGS := -Wall -Wextra -O0 -ffunction-sections\
|
||||||
$(MACHDEP)
|
$(MACHDEP)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
@ -38,6 +38,11 @@ CXXFLAGS := $(CFLAGS) -std=c++17
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libkernel.ld $(WUMSSPECS)
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libkernel.ld $(WUMSSPECS)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -DDEBUG -g
|
||||||
|
CCFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
LIBS := -lwums -lwut -lkernel
|
LIBS := -lwums -lwut -lkernel
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
36
source/logger.c
Normal file
36
source/logger.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifdef DEBUG
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
#include <whb/log_cafe.h>
|
||||||
|
#include <whb/log_module.h>
|
||||||
|
|
||||||
|
uint32_t moduleLogInit = false;
|
||||||
|
uint32_t cafeLogInit = false;
|
||||||
|
uint32_t udpLogInit = false;
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
|
void initLogging() {
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||||
|
cafeLogInit = WHBLogCafeInit();
|
||||||
|
udpLogInit = WHBLogUdpInit();
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinitLogging() {
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (moduleLogInit) {
|
||||||
|
WHBLogModuleDeinit();
|
||||||
|
moduleLogInit = false;
|
||||||
|
}
|
||||||
|
if (cafeLogInit) {
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
cafeLogInit = false;
|
||||||
|
}
|
||||||
|
if (udpLogInit) {
|
||||||
|
WHBLogUdpDeinit();
|
||||||
|
udpLogInit = false;
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <whb/log.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstring>
|
#ifdef DEBUG
|
||||||
#include <whb/log.h>
|
|
||||||
|
|
||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
@ -22,6 +22,21 @@ extern "C" {
|
|||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void initLogging();
|
||||||
|
|
||||||
|
void deinitLogging();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include <wums.h>
|
#include <wums.h>
|
||||||
#include <coreinit/ios.h>
|
#include <coreinit/ios.h>
|
||||||
#include <coreinit/debug.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <kernel/kernel.h>
|
#include <kernel/kernel.h>
|
||||||
#include <whb/log_udp.h>
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging");
|
WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging");
|
||||||
WUMS_MODULE_SKIP_INIT_FINI();
|
WUMS_MODULE_SKIP_INIT_FINI();
|
||||||
@ -12,8 +11,7 @@ WUMS_MODULE_SKIP_INIT_FINI();
|
|||||||
extern "C" void SC_0x51();
|
extern "C" void SC_0x51();
|
||||||
|
|
||||||
WUMS_INITIALIZE() {
|
WUMS_INITIALIZE() {
|
||||||
WHBLogUdpInit();
|
initLogging();
|
||||||
|
|
||||||
// Start syslogging on iosu side
|
// Start syslogging on iosu side
|
||||||
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
||||||
if (mcpFd >= 0) {
|
if (mcpFd >= 0) {
|
||||||
@ -35,14 +33,18 @@ WUMS_INITIALIZE() {
|
|||||||
|
|
||||||
// Start iopshell on kernel
|
// Start iopshell on kernel
|
||||||
SC_0x51();
|
SC_0x51();
|
||||||
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IopShell_UserCallback (0x101C400 + 0x1926c)
|
#define IopShell_UserCallback (0x101C400 + 0x1926c)
|
||||||
#define IopShell_RegisterCallback ((void (*)( uint32_t,uint32_t,uint32_t,uint32_t))(0x101C400 + 0x19638))
|
#define IopShell_RegisterCallback ((void (*)( uint32_t,uint32_t,uint32_t,uint32_t))(0x101C400 + 0x19638))
|
||||||
#define IopShell_CreateThread ((void (*)( void))(0x101C400 + 0x19504))
|
#define IopShell_CreateThread ((void (*)( void))(0x101C400 + 0x19504))
|
||||||
|
|
||||||
WUMS_APPLICATION_STARTS(){
|
WUMS_APPLICATION_STARTS() {
|
||||||
|
initLogging();
|
||||||
|
DEBUG_FUNCTION_LINE("Register IopShell_UserCallback");
|
||||||
IopShell_RegisterCallback(IopShell_UserCallback, 0x100978f8, 0x10097900, 0x10097c40);
|
IopShell_RegisterCallback(IopShell_UserCallback, 0x100978f8, 0x10097900, 0x10097c40);
|
||||||
|
DEBUG_FUNCTION_LINE("IopShell create thread");
|
||||||
IopShell_CreateThread();
|
IopShell_CreateThread();
|
||||||
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user