mirror of
https://github.com/wiiu-env/USBSerialLoggingModule.git
synced 2024-11-24 02:49:18 +01:00
Format the code via clang-format
This commit is contained in:
parent
3068255cb9
commit
52aca6a486
67
.clang-format
Normal file
67
.clang-format
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Generated from CLion C/C++ Code Style settings
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||||
|
AlignOperands: Align
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Always
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
ColumnLimit: 0
|
||||||
|
CompactNamespaces: false
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: false
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -3,8 +3,16 @@ name: CI-PR
|
|||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
[![CI-Release](https://github.com/wiiu-env/USBSerialLoggingModule/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/USBSerialLoggingModule/actions/workflows/ci.yml)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
|
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
|
||||||
|
|
||||||
@ -18,3 +20,7 @@ docker run -it --rm -v ${PWD}:/project usbserialloggermodule-builder make
|
|||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project usbserialloggermodule-builder make clean
|
docker run -it --rm -v ${PWD}:/project usbserialloggermodule-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
@ -1,31 +1,31 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define k_memset ((void (*)( uint32_t , uint32_t, uint32_t))0xfff09d60)
|
#define k_memset ((void (*)(uint32_t, uint32_t, uint32_t)) 0xfff09d60)
|
||||||
#define KiReport ((void (*)( const char*, ... ))0xfff0ad0c)
|
#define KiReport ((void (*)(const char *, ...)) 0xfff0ad0c)
|
||||||
#define IopShell_AsyncCallback (0xfff1b7d8)
|
#define IopShell_AsyncCallback (0xfff1b7d8)
|
||||||
#define IopShell_ReadCallback (0xfff1b9a0)
|
#define IopShell_ReadCallback (0xfff1b9a0)
|
||||||
#define k_memcpy ((void (*)(void*,void*, uint32_t))0xfff09e44)
|
#define k_memcpy ((void (*)(void *, void *, uint32_t)) 0xfff09e44)
|
||||||
#define IPCKDriver_OpenAsync ((int32_t (*)(uint32_t client_ram_pid, const char *device, uint32_t mode, uint32_t asyncCallback, void * context))0xfff0b9c8)
|
#define IPCKDriver_OpenAsync ((int32_t(*)(uint32_t client_ram_pid, const char *device, uint32_t mode, uint32_t asyncCallback, void *context)) 0xfff0b9c8)
|
||||||
#define WaitAsyncReply ((uint32_t (*)(void* , uint32_t, uint32_t))0xfff180dc)
|
#define WaitAsyncReply ((uint32_t(*)(void *, uint32_t, uint32_t)) 0xfff180dc)
|
||||||
|
|
||||||
#define IPCKDriver_IoctlAsync ((int32_t (*)( \
|
#define IPCKDriver_IoctlAsync ((int32_t(*)( \
|
||||||
uint32_t clientProcessId,\
|
uint32_t clientProcessId, \
|
||||||
uint32_t loaderProcessId,\
|
uint32_t loaderProcessId, \
|
||||||
uint32_t handle,\
|
uint32_t handle, \
|
||||||
uint32_t request,\
|
uint32_t request, \
|
||||||
void* inBuf,\
|
void *inBuf, \
|
||||||
uint32_t inLen,\
|
uint32_t inLen, \
|
||||||
void* outBuf,\
|
void *outBuf, \
|
||||||
uint32_t outLen,\
|
uint32_t outLen, \
|
||||||
uint32_t asyncCallback,\
|
uint32_t asyncCallback, \
|
||||||
void * context))0xfff0bc5c)
|
void *context)) 0xfff0bc5c)
|
||||||
|
|
||||||
|
|
||||||
uint32_t IPCKDriver_IOS_Open_Sync(uint32_t clientProcessId, const char *device_name, uint32_t mode) {
|
uint32_t IPCKDriver_IOS_Open_Sync(uint32_t clientProcessId, const char *device_name, uint32_t mode) {
|
||||||
register int r13 asm ("r13");
|
register int r13 asm("r13");
|
||||||
k_memcpy((void *) (r13 - 0x1180), (void *) device_name, 0x10);
|
k_memcpy((void *) (r13 - 0x1180), (void *) device_name, 0x10);
|
||||||
void *context = (void *) (r13 + 0x450);
|
void *context = (void *) (r13 + 0x450);
|
||||||
auto error = IPCKDriver_OpenAsync(clientProcessId, (const char *) (r13 - 0x1180), mode, IopShell_AsyncCallback, context);
|
auto error = IPCKDriver_OpenAsync(clientProcessId, (const char *) (r13 - 0x1180), mode, IopShell_AsyncCallback, context);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ uint32_t IPCKDriver_IOS_Open_Sync(uint32_t clientProcessId, const char *device_n
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t IPCKDriver_IOS_Ioctl_Sync(uint32_t clientProcessId, uint32_t handle, uint32_t request, void *inBuf, uint32_t inLen, void *outBuf, uint32_t ouLen) {
|
uint32_t IPCKDriver_IOS_Ioctl_Sync(uint32_t clientProcessId, uint32_t handle, uint32_t request, void *inBuf, uint32_t inLen, void *outBuf, uint32_t ouLen) {
|
||||||
register int r13 asm ("r13");
|
register int r13 asm("r13");
|
||||||
void *context = (void *) (r13 + 0x450);
|
void *context = (void *) (r13 + 0x450);
|
||||||
|
|
||||||
auto error = IPCKDriver_IoctlAsync(clientProcessId, 0xFFFFFFFF, handle, request, inBuf, inLen, outBuf, ouLen, IopShell_AsyncCallback, context);
|
auto error = IPCKDriver_IoctlAsync(clientProcessId, 0xFFFFFFFF, handle, request, inBuf, inLen, outBuf, ouLen, IopShell_AsyncCallback, context);
|
||||||
@ -47,11 +47,11 @@ uint32_t IPCKDriver_IOS_Ioctl_Sync(uint32_t clientProcessId, uint32_t handle, ui
|
|||||||
|
|
||||||
|
|
||||||
void IopShellInitInternal() {
|
void IopShellInitInternal() {
|
||||||
register int r13 asm ("r13");
|
register int r13 asm("r13");
|
||||||
*((uint32_t *) (r13 + 0x450)) = 0;
|
*((uint32_t *) (r13 + 0x450)) = 0;
|
||||||
*((uint32_t *) (r13 + 0x454)) = 0;
|
*((uint32_t *) (r13 + 0x454)) = 0;
|
||||||
*((uint32_t *) (r13 + 0x458)) = 0xffffffe3;
|
*((uint32_t *) (r13 + 0x458)) = 0xffffffe3;
|
||||||
auto handle = IPCKDriver_IOS_Open_Sync(0, "/dev/iopsh", (uint32_t) 5);
|
auto handle = IPCKDriver_IOS_Open_Sync(0, "/dev/iopsh", (uint32_t) 5);
|
||||||
if (static_cast<int>(handle) < 0) {
|
if (static_cast<int>(handle) < 0) {
|
||||||
KiReport("####################################################################################\n");
|
KiReport("####################################################################################\n");
|
||||||
KiReport("IopShellInit failed\n");
|
KiReport("IopShellInit failed\n");
|
||||||
@ -70,7 +70,7 @@ void IopShellInitInternal() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*(uint32_t *) (r13 + -0x117c) = 0x636F7300; // "cos"
|
*(uint32_t *) (r13 + -0x117c) = 0x636F7300; // "cos"
|
||||||
result = IPCKDriver_IOS_Ioctl_Sync(0, static_cast<uint32_t>(handle), 1, (void *) (r13 - 0x1180), 0x14, (void *) (r13 - 0x1140), 0x4);
|
result = IPCKDriver_IOS_Ioctl_Sync(0, static_cast<uint32_t>(handle), 1, (void *) (r13 - 0x1180), 0x14, (void *) (r13 - 0x1140), 0x4);
|
||||||
if (static_cast<int>(result) < 0) {
|
if (static_cast<int>(result) < 0) {
|
||||||
KiReport("####################################################################################\n");
|
KiReport("####################################################################################\n");
|
||||||
KiReport("IopShellInit failed\n");
|
KiReport("IopShellInit failed\n");
|
||||||
@ -81,7 +81,7 @@ void IopShellInitInternal() {
|
|||||||
*((uint32_t *) (r13 + 0x454)) = 0;
|
*((uint32_t *) (r13 + 0x454)) = 0;
|
||||||
*((uint32_t *) (r13 + 0x458)) = 0xffffffe3;
|
*((uint32_t *) (r13 + 0x458)) = 0xffffffe3;
|
||||||
k_memset((r13 - 0x1180), 0, 0x1040);
|
k_memset((r13 - 0x1180), 0, 0x1040);
|
||||||
result = IPCKDriver_IoctlAsync(0, 0xFFFFFFFF, handle, 5, nullptr, 0, (void *) (r13 - 0x1180), 0x1040, IopShell_ReadCallback, (void*) (r13 + 0x450));
|
result = IPCKDriver_IoctlAsync(0, 0xFFFFFFFF, handle, 5, nullptr, 0, (void *) (r13 - 0x1180), 0x1040, IopShell_ReadCallback, (void *) (r13 + 0x450));
|
||||||
if (static_cast<int>(result) < 0) {
|
if (static_cast<int>(result) < 0) {
|
||||||
KiReport("####################################################################################\n");
|
KiReport("####################################################################################\n");
|
||||||
KiReport("IopShellInit failed\n");
|
KiReport("IopShellInit failed\n");
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <whb/log_udp.h>
|
|
||||||
#include <whb/log_cafe.h>
|
#include <whb/log_cafe.h>
|
||||||
#include <whb/log_module.h>
|
#include <whb/log_module.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
|
||||||
uint32_t moduleLogInit = false;
|
uint32_t moduleLogInit = false;
|
||||||
uint32_t cafeLogInit = false;
|
uint32_t cafeLogInit = false;
|
||||||
uint32_t udpLogInit = false;
|
uint32_t udpLogInit = false;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
void initLogging() {
|
void initLogging() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!(moduleLogInit = WHBLogModuleInit())) {
|
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||||
cafeLogInit = WHBLogCafeInit();
|
cafeLogInit = WHBLogCafeInit();
|
||||||
udpLogInit = WHBLogUdpInit();
|
udpLogInit = WHBLogUdpInit();
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <whb/log.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -9,26 +9,28 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#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 DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
|
||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -39,4 +41,3 @@ void deinitLogging();
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <wums.h>
|
|
||||||
#include <coreinit/ios.h>
|
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include <kernel/kernel.h>
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/ios.h>
|
||||||
|
#include <kernel/kernel.h>
|
||||||
|
#include <wums.h>
|
||||||
|
|
||||||
WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging");
|
WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging");
|
||||||
WUMS_MODULE_SKIP_INIT_FINI();
|
WUMS_MODULE_SKIP_INIT_FINI();
|
||||||
@ -15,7 +15,7 @@ WUMS_INITIALIZE() {
|
|||||||
// 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) {
|
||||||
int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING
|
int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING
|
||||||
int out = 0;
|
int out = 0;
|
||||||
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
|
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
|
||||||
IOS_Close(mcpFd);
|
IOS_Close(mcpFd);
|
||||||
@ -36,9 +36,9 @@ WUMS_INITIALIZE() {
|
|||||||
deinitLogging();
|
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();
|
initLogging();
|
||||||
|
Loading…
Reference in New Issue
Block a user