Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 17:48:14 +01:00
parent 3068255cb9
commit 52aca6a486
8 changed files with 136 additions and 46 deletions

67
.clang-format Normal file
View 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

View File

@ -6,8 +6,16 @@ on:
- main
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:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request]
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:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -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
(`[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
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`

View File

@ -1,31 +1,31 @@
#include <cstdint>
#define k_memset ((void (*)( uint32_t , uint32_t, uint32_t))0xfff09d60)
#define KiReport ((void (*)( const char*, ... ))0xfff0ad0c)
#define k_memset ((void (*)(uint32_t, uint32_t, uint32_t)) 0xfff09d60)
#define KiReport ((void (*)(const char *, ...)) 0xfff0ad0c)
#define IopShell_AsyncCallback (0xfff1b7d8)
#define IopShell_ReadCallback (0xfff1b9a0)
#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 WaitAsyncReply ((uint32_t (*)(void* , uint32_t, uint32_t))0xfff180dc)
#define IopShell_ReadCallback (0xfff1b9a0)
#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 WaitAsyncReply ((uint32_t(*)(void *, uint32_t, uint32_t)) 0xfff180dc)
#define IPCKDriver_IoctlAsync ((int32_t (*)( \
uint32_t clientProcessId,\
uint32_t loaderProcessId,\
uint32_t handle,\
uint32_t request,\
void* inBuf,\
uint32_t inLen,\
void* outBuf,\
uint32_t outLen,\
uint32_t asyncCallback,\
void * context))0xfff0bc5c)
#define IPCKDriver_IoctlAsync ((int32_t(*)( \
uint32_t clientProcessId, \
uint32_t loaderProcessId, \
uint32_t handle, \
uint32_t request, \
void *inBuf, \
uint32_t inLen, \
void *outBuf, \
uint32_t outLen, \
uint32_t asyncCallback, \
void *context)) 0xfff0bc5c)
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);
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) {
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) {
register int r13 asm ("r13");
register int r13 asm("r13");
void *context = (void *) (r13 + 0x450);
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() {
register int r13 asm ("r13");
register int r13 asm("r13");
*((uint32_t *) (r13 + 0x450)) = 0;
*((uint32_t *) (r13 + 0x454)) = 0;
*((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) {
KiReport("####################################################################################\n");
KiReport("IopShellInit failed\n");
@ -70,7 +70,7 @@ void IopShellInitInternal() {
return;
}
*(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) {
KiReport("####################################################################################\n");
KiReport("IopShellInit failed\n");
@ -81,7 +81,7 @@ void IopShellInitInternal() {
*((uint32_t *) (r13 + 0x454)) = 0;
*((uint32_t *) (r13 + 0x458)) = 0xffffffe3;
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) {
KiReport("####################################################################################\n");
KiReport("IopShellInit failed\n");

View File

@ -1,19 +1,19 @@
#ifdef DEBUG
#include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false;
uint32_t udpLogInit = false;
uint32_t cafeLogInit = false;
uint32_t udpLogInit = false;
#endif // DEBUG
void initLogging() {
#ifdef DEBUG
if (!(moduleLogInit = WHBLogModuleInit())) {
cafeLogInit = WHBLogCafeInit();
udpLogInit = WHBLogUdpInit();
udpLogInit = WHBLogUdpInit();
}
#endif // DEBUG
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#include <whb/log.h>
#ifdef __cplusplus
extern "C" {
@ -9,26 +9,28 @@ extern "C" {
#ifdef DEBUG
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#else
#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
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus
}
#endif

View File

@ -1,9 +1,9 @@
#include <wums.h>
#include <coreinit/ios.h>
#include <coreinit/cache.h>
#include <kernel/kernel.h>
#include "kernel.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_SKIP_INIT_FINI();
@ -15,7 +15,7 @@ WUMS_INITIALIZE() {
// Start syslogging on iosu side
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
if (mcpFd >= 0) {
int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING
int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING
int out = 0;
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
IOS_Close(mcpFd);
@ -36,9 +36,9 @@ WUMS_INITIALIZE() {
deinitLogging();
}
#define IopShell_UserCallback (0x101C400 + 0x1926c)
#define IopShell_RegisterCallback ((void (*)( uint32_t,uint32_t,uint32_t,uint32_t))(0x101C400 + 0x19638))
#define IopShell_CreateThread ((void (*)( void))(0x101C400 + 0x19504))
#define IopShell_UserCallback (0x101C400 + 0x1926c)
#define IopShell_RegisterCallback ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t))(0x101C400 + 0x19638))
#define IopShell_CreateThread ((void (*)(void))(0x101C400 + 0x19504))
WUMS_APPLICATION_STARTS() {
initLogging();