From 7e4c2f13bd456d52b7eed97f2b82f325cdc25b17 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 3 Feb 2022 13:09:27 +0100 Subject: [PATCH] Format the code via clang-format Add new Dockerfile for building the lib in pull requests Fix formatting of ALIGN macro --- .clang-format | 67 +++++++++++++++ .github/workflows/pr.yml | 25 ++++++ .github/workflows/push_image.yml | 8 ++ Dockerfile | 2 +- Dockerfile.buildlocal | 3 + README.md | 4 + include/iosuhax.h | 26 +++--- include/iosuhax_disc_interface.h | 14 ++-- source/iosuhax.c | 139 ++++++++++++++++--------------- source/iosuhax_devoptab.c | 32 ++++--- source/iosuhax_disc_interface.c | 16 ++-- source/os_functions.h | 2 +- 12 files changed, 221 insertions(+), 117 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/pr.yml create mode 100644 Dockerfile.buildlocal diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..533ffee --- /dev/null +++ b/.clang-format @@ -0,0 +1,67 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +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 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..242c31d --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,25 @@ +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 ./include + build-binary: + runs-on: ubuntu-18.04 + needs: clang-format + steps: + - uses: actions/checkout@v2 + - name: build binary + run: | + docker build . -f Dockerfile.buildlocal -t builder + docker run --rm -v ${PWD}:/project builder make + - uses: actions/upload-artifact@master + with: + name: binary + path: "lib/*.a" \ No newline at end of file diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 9cd7bbd..df6eb37 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -4,8 +4,16 @@ on: branches: - master 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 ./include build: runs-on: ubuntu-latest + needs: clang-format steps: - uses: actions/checkout@master - name: Get release version diff --git a/Dockerfile b/Dockerfile index e9f1e65..9941cb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wiiuenv/devkitppc:20210920 +FROM wiiuenv/devkitppc:20211229 WORKDIR tmp_build COPY . . diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal new file mode 100644 index 0000000..080eec7 --- /dev/null +++ b/Dockerfile.buildlocal @@ -0,0 +1,3 @@ +FROM wiiuenv/devkitppc:20211229 + +WORKDIR project \ No newline at end of file diff --git a/README.md b/README.md index 1fc1235..7530765 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,7 @@ Make you to have [wut](https://github.com/devkitPro/wut/) installed and use the ``` make install ``` + +## Format the code via docker + +`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i` diff --git a/include/iosuhax.h b/include/iosuhax.h index 82c1e9e..e55b17f 100644 --- a/include/iosuhax.h +++ b/include/iosuhax.h @@ -29,18 +29,18 @@ extern "C" { #endif -#define IOS_ERROR_UNKNOWN_VALUE 0xFFFFFFD6 -#define IOS_ERROR_INVALID_ARG 0xFFFFFFE3 -#define IOS_ERROR_INVALID_SIZE 0xFFFFFFE9 -#define IOS_ERROR_UNKNOWN 0xFFFFFFF7 -#define IOS_ERROR_NOEXISTS 0xFFFFFFFA +#define IOS_ERROR_UNKNOWN_VALUE 0xFFFFFFD6 +#define IOS_ERROR_INVALID_ARG 0xFFFFFFE3 +#define IOS_ERROR_INVALID_SIZE 0xFFFFFFE9 +#define IOS_ERROR_UNKNOWN 0xFFFFFFF7 +#define IOS_ERROR_NOEXISTS 0xFFFFFFFA typedef struct { uint32_t flag; uint32_t permission; uint32_t owner_id; uint32_t group_id; - uint32_t size; // size in bytes + uint32_t size; // size in bytes uint32_t physsize; // physical size on disk in bytes uint32_t unk[3]; uint32_t id; @@ -54,27 +54,27 @@ typedef struct { char name[0x100]; } directoryEntry_s; -#define DIR_ENTRY_IS_DIRECTORY 0x80000000 +#define DIR_ENTRY_IS_DIRECTORY 0x80000000 #define FSA_MOUNTFLAGS_BINDMOUNT (1 << 0) -#define FSA_MOUNTFLAGS_GLOBAL (1 << 1) +#define FSA_MOUNTFLAGS_GLOBAL (1 << 1) -int IOSUHAX_Open(const char *dev); // if dev == NULL the default path /dev/iosuhax will be used +int IOSUHAX_Open(const char *dev); // if dev == NULL the default path /dev/iosuhax will be used int IOSUHAX_Close(void); int IOSUHAX_memwrite(uint32_t address, const uint8_t *buffer, uint32_t size); // IOSU external input int IOSUHAX_memread(uint32_t address, uint8_t *out_buffer, uint32_t size); // IOSU external output -int IOSUHAX_memcpy(uint32_t dst, uint32_t src, uint32_t size); // IOSU internal memcpy only +int IOSUHAX_memcpy(uint32_t dst, uint32_t src, uint32_t size); // IOSU internal memcpy only int IOSUHAX_kern_write32(uint32_t address, uint32_t value); int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count); -int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size); +int IOSUHAX_read_otp(uint8_t *out_buffer, uint32_t size); -int IOSUHAX_read_seeprom(uint8_t * out_buffer, uint32_t offset, uint32_t size); +int IOSUHAX_read_seeprom(uint8_t *out_buffer, uint32_t offset, uint32_t size); -int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey); +int IOSUHAX_ODM_GetDiscKey(uint8_t *discKey); int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt); diff --git a/include/iosuhax_disc_interface.h b/include/iosuhax_disc_interface.h index a4a9090..abe547a 100644 --- a/include/iosuhax_disc_interface.h +++ b/include/iosuhax_disc_interface.h @@ -24,23 +24,23 @@ #ifndef _IOSUHAX_DISC_INTERFACE_H_ #define _IOSUHAX_DISC_INTERFACE_H_ -#include #include +#include #ifdef __cplusplus extern "C" { #endif -#define DEVICE_TYPE_WII_U_SD (('W'<<24)|('U'<<16)|('S'<<8)|'D') -#define DEVICE_TYPE_WII_U_USB (('W'<<24)|('U'<<16)|('S'<<8)|'B') -#define FEATURE_WII_U_SD 0x00001000 -#define FEATURE_WII_U_USB 0x00002000 +#define DEVICE_TYPE_WII_U_SD (('W' << 24) | ('U' << 16) | ('S' << 8) | 'D') +#define DEVICE_TYPE_WII_U_USB (('W' << 24) | ('U' << 16) | ('S' << 8) | 'B') +#define FEATURE_WII_U_SD 0x00001000 +#define FEATURE_WII_U_USB 0x00002000 #ifndef OGC_DISC_IO_INCLUDE typedef uint32_t sec_t; -#define FEATURE_MEDIUM_CANREAD 0x00000001 -#define FEATURE_MEDIUM_CANWRITE 0x00000002 +#define FEATURE_MEDIUM_CANREAD 0x00000001 +#define FEATURE_MEDIUM_CANWRITE 0x00000002 typedef bool (*FN_MEDIUM_STARTUP)(void); diff --git a/source/iosuhax.c b/source/iosuhax.c index 3026329..92160ba 100644 --- a/source/iosuhax.c +++ b/source/iosuhax.c @@ -21,54 +21,55 @@ * 3. This notice may not be removed or altered from any source * distribution. ***************************************************************************/ -#include -#include -#include "os_functions.h" #include "iosuhax.h" +#include "os_functions.h" +#include +#include -#define IOSUHAX_MAGIC_WORD 0x4E696365 +#define IOSUHAX_MAGIC_WORD 0x4E696365 -#define IOCTL_MEM_WRITE 0x00 -#define IOCTL_MEM_READ 0x01 -#define IOCTL_SVC 0x02 -#define IOCTL_MEMCPY 0x04 -#define IOCTL_REPEATED_WRITE 0x05 -#define IOCTL_KERN_READ32 0x06 -#define IOCTL_KERN_WRITE32 0x07 -#define IOCTL_READ_OTP 0x08 +#define IOCTL_MEM_WRITE 0x00 +#define IOCTL_MEM_READ 0x01 +#define IOCTL_SVC 0x02 +#define IOCTL_MEMCPY 0x04 +#define IOCTL_REPEATED_WRITE 0x05 +#define IOCTL_KERN_READ32 0x06 +#define IOCTL_KERN_WRITE32 0x07 +#define IOCTL_READ_OTP 0x08 -#define IOCTL_FSA_OPEN 0x40 -#define IOCTL_FSA_CLOSE 0x41 -#define IOCTL_FSA_MOUNT 0x42 -#define IOCTL_FSA_UNMOUNT 0x43 -#define IOCTL_FSA_GETDEVICEINFO 0x44 -#define IOCTL_FSA_OPENDIR 0x45 -#define IOCTL_FSA_READDIR 0x46 -#define IOCTL_FSA_CLOSEDIR 0x47 -#define IOCTL_FSA_MAKEDIR 0x48 -#define IOCTL_FSA_OPENFILE 0x49 -#define IOCTL_FSA_READFILE 0x4A -#define IOCTL_FSA_WRITEFILE 0x4B -#define IOCTL_FSA_STATFILE 0x4C -#define IOCTL_FSA_CLOSEFILE 0x4D -#define IOCTL_FSA_SETFILEPOS 0x4E -#define IOCTL_FSA_GETSTAT 0x4F -#define IOCTL_FSA_REMOVE 0x50 -#define IOCTL_FSA_REWINDDIR 0x51 -#define IOCTL_FSA_CHDIR 0x52 -#define IOCTL_FSA_RENAME 0x53 -#define IOCTL_FSA_RAW_OPEN 0x54 -#define IOCTL_FSA_RAW_READ 0x55 -#define IOCTL_FSA_RAW_WRITE 0x56 -#define IOCTL_FSA_RAW_CLOSE 0x57 -#define IOCTL_FSA_CHANGEMODE 0x58 -#define IOCTL_FSA_FLUSHVOLUME 0x59 -#define IOCTL_CHECK_IF_IOSUHAX 0x5B +#define IOCTL_FSA_OPEN 0x40 +#define IOCTL_FSA_CLOSE 0x41 +#define IOCTL_FSA_MOUNT 0x42 +#define IOCTL_FSA_UNMOUNT 0x43 +#define IOCTL_FSA_GETDEVICEINFO 0x44 +#define IOCTL_FSA_OPENDIR 0x45 +#define IOCTL_FSA_READDIR 0x46 +#define IOCTL_FSA_CLOSEDIR 0x47 +#define IOCTL_FSA_MAKEDIR 0x48 +#define IOCTL_FSA_OPENFILE 0x49 +#define IOCTL_FSA_READFILE 0x4A +#define IOCTL_FSA_WRITEFILE 0x4B +#define IOCTL_FSA_STATFILE 0x4C +#define IOCTL_FSA_CLOSEFILE 0x4D +#define IOCTL_FSA_SETFILEPOS 0x4E +#define IOCTL_FSA_GETSTAT 0x4F +#define IOCTL_FSA_REMOVE 0x50 +#define IOCTL_FSA_REWINDDIR 0x51 +#define IOCTL_FSA_CHDIR 0x52 +#define IOCTL_FSA_RENAME 0x53 +#define IOCTL_FSA_RAW_OPEN 0x54 +#define IOCTL_FSA_RAW_READ 0x55 +#define IOCTL_FSA_RAW_WRITE 0x56 +#define IOCTL_FSA_RAW_CLOSE 0x57 +#define IOCTL_FSA_CHANGEMODE 0x58 +#define IOCTL_FSA_FLUSHVOLUME 0x59 +#define IOCTL_CHECK_IF_IOSUHAX 0x5B static int iosuhaxHandle = -1; -#define ALIGN(align) __attribute__((aligned(align))) -#define ROUNDUP(x, align) (((x) + ((align) - 1)) & ~((align) - 1)) +#define ALIGN(align) __attribute__((aligned(align))) +#define ALIGN_0x20 ALIGN(0x20) +#define ROUNDUP(x, align) (((x) + ((align) -1)) & ~((align) -1)) int IOSUHAX_Open(const char *dev) { if (iosuhaxHandle >= 0) @@ -77,7 +78,7 @@ int IOSUHAX_Open(const char *dev) { iosuhaxHandle = IOS_Open((char *) (dev ? dev : "/dev/iosuhax"), 0); if (iosuhaxHandle >= 0 && dev) //make sure device is actually iosuhax { - ALIGN(0x20) int res[0x20 >> 2]; + ALIGN_0x20 int res[0x20 >> 2]; *res = 0; IOS_Ioctl(iosuhaxHandle, IOCTL_CHECK_IF_IOSUHAX, (void *) 0, 0, res, 4); @@ -116,9 +117,9 @@ int IOSUHAX_memwrite(uint32_t address, const uint8_t *buffer, uint32_t size) { return res; } -int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey){ +int IOSUHAX_ODM_GetDiscKey(uint8_t *discKey) { int res = -1; - if(discKey == NULL){ + if (discKey == NULL) { return -2; } int odm_handle = IOS_Open("/dev/odm", 1); @@ -140,7 +141,7 @@ int IOSUHAX_memread(uint32_t address, uint8_t *out_buffer, uint32_t size) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) int io_buf[0x20 >> 2]; + ALIGN_0x20 int io_buf[0x20 >> 2]; io_buf[0] = address; void *tmp_buf = NULL; @@ -164,7 +165,7 @@ int IOSUHAX_memcpy(uint32_t dst, uint32_t src, uint32_t size) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) uint32_t io_buf[0x20 >> 2]; + ALIGN_0x20 uint32_t io_buf[0x20 >> 2]; io_buf[0] = dst; io_buf[1] = src; io_buf[2] = size; @@ -176,51 +177,51 @@ int IOSUHAX_kern_write32(uint32_t address, uint32_t value) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) uint32_t io_buf[0x20 >> 2]; + ALIGN_0x20 uint32_t io_buf[0x20 >> 2]; io_buf[0] = address; io_buf[1] = value; return IOS_Ioctl(iosuhaxHandle, IOCTL_KERN_WRITE32, io_buf, 2 * sizeof(uint32_t), 0, 0); } -int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size) { +int IOSUHAX_read_otp(uint8_t *out_buffer, uint32_t size) { if (iosuhaxHandle < 0) { return iosuhaxHandle; } - ALIGN(0x20) uint32_t io_buf[0x400 >> 2]; + ALIGN_0x20 uint32_t io_buf[0x400 >> 2]; int res = IOS_Ioctl(iosuhaxHandle, IOCTL_READ_OTP, 0, 0, io_buf, 0x400); - if (res >= 0){ + if (res >= 0) { memcpy(out_buffer, io_buf, size > 0x400 ? 0x400 : size); } return res; } -extern int bspRead(const char*, uint32_t, const char*, uint32_t, uint16_t*); +extern int bspRead(const char *, uint32_t, const char *, uint32_t, uint16_t *); -int IOSUHAX_read_seeprom(uint8_t * out_buffer, uint32_t offset, uint32_t size) { - if(out_buffer == NULL || offset > 0x200 || offset & 0x01) { +int IOSUHAX_read_seeprom(uint8_t *out_buffer, uint32_t offset, uint32_t size) { + if (out_buffer == NULL || offset > 0x200 || offset & 0x01) { return -1; - } + } uint32_t sizeInShorts = size >> 1; uint32_t offsetInShorts = offset >> 1; int32_t maxReadCount = 0x100 - offsetInShorts; - if(maxReadCount <= 0){ + if (maxReadCount <= 0) { return 0; } uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts; - uint16_t *ptr = (uint16_t *) out_buffer; + uint16_t *ptr = (uint16_t *) out_buffer; int res = 0; - for(int i = 0; i < count; i++) { - if(bspRead("EE", offsetInShorts + i, "access", 2, ptr) != 0) { + for (int i = 0; i < count; i++) { + if (bspRead("EE", offsetInShorts + i, "access", 2, ptr) != 0) { return -2; } res += 2; @@ -234,7 +235,7 @@ int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count) if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) uint32_t io_buf[0x20 >> 2]; + ALIGN_0x20 uint32_t io_buf[0x20 >> 2]; io_buf[0] = address; void *tmp_buf = NULL; @@ -258,7 +259,7 @@ int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) uint32_t arguments[0x40 >> 2]; + ALIGN_0x20 uint32_t arguments[0x40 >> 2]; arguments[0] = svc_id; if (args && arg_cnt) { @@ -268,7 +269,7 @@ int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt) { memcpy(arguments + 1, args, arg_cnt * 4); } - ALIGN(0x20) int result[0x20 >> 2]; + ALIGN_0x20 int result[0x20 >> 2]; int ret = IOS_Ioctl(iosuhaxHandle, IOCTL_SVC, arguments, (1 + arg_cnt) * 4, result, 4); if (ret < 0) return ret; @@ -280,7 +281,7 @@ int IOSUHAX_FSA_Open(void) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) int io_buf[0x20 >> 2]; + ALIGN_0x20 int io_buf[0x20 >> 2]; int res = IOS_Ioctl(iosuhaxHandle, IOCTL_FSA_OPEN, 0, 0, io_buf, sizeof(int)); if (res < 0) @@ -293,7 +294,7 @@ int IOSUHAX_FSA_Close(int fsaFd) { if (iosuhaxHandle < 0) return iosuhaxHandle; - ALIGN(0x20) int io_buf[0x20 >> 2]; + ALIGN_0x20 int io_buf[0x20 >> 2]; io_buf[0] = fsaFd; int res = IOS_Ioctl(iosuhaxHandle, IOCTL_FSA_CLOSE, io_buf, sizeof(fsaFd), io_buf, sizeof(fsaFd)); @@ -311,7 +312,7 @@ int IOSUHAX_FSA_Mount(int fsaFd, const char *device_path, const char *volume_pat int io_buf_size = (sizeof(uint32_t) * input_cnt) + strlen(device_path) + strlen(volume_path) + arg_string_len + 3; - ALIGN(0x20) int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; memset(io_buf, 0, io_buf_size); io_buf[0] = fsaFd; @@ -342,7 +343,7 @@ int IOSUHAX_FSA_Unmount(int fsaFd, const char *path, uint32_t flags) { int io_buf_size = sizeof(uint32_t) * input_cnt + strlen(path) + 1; - ALIGN(0x20) int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; io_buf[0] = fsaFd; io_buf[1] = sizeof(uint32_t) * input_cnt; @@ -364,7 +365,7 @@ int IOSUHAX_FSA_FlushVolume(int fsaFd, const char *volume_path) { int io_buf_size = sizeof(uint32_t) * input_cnt + strlen(volume_path) + 1; - ALIGN(0x20) int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 int io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; io_buf[0] = fsaFd; io_buf[1] = sizeof(uint32_t) * input_cnt; @@ -849,7 +850,7 @@ int IOSUHAX_FSA_ChangeMode(int fsaFd, const char *path, int mode) { int io_buf_size = sizeof(uint32_t) * input_cnt + strlen(path) + 1; - ALIGN(0x20) uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; io_buf[0] = fsaFd; io_buf[1] = sizeof(uint32_t) * input_cnt; @@ -871,7 +872,7 @@ int IOSUHAX_FSA_RawOpen(int fsaFd, const char *device_path, int *outHandle) { int io_buf_size = sizeof(uint32_t) * input_cnt + strlen(device_path) + 1; - ALIGN(0x20) uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; io_buf[0] = fsaFd; io_buf[1] = sizeof(uint32_t) * input_cnt; @@ -955,7 +956,7 @@ int IOSUHAX_FSA_RawClose(int fsaFd, int device_handle) { int io_buf_size = sizeof(uint32_t) * input_cnt; - ALIGN(0x20) uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; + ALIGN_0x20 uint32_t io_buf[ROUNDUP(io_buf_size, 0x20) >> 2]; io_buf[0] = fsaFd; io_buf[1] = device_handle; diff --git a/source/iosuhax_devoptab.c b/source/iosuhax_devoptab.c index df74b4b..1613bf1 100644 --- a/source/iosuhax_devoptab.c +++ b/source/iosuhax_devoptab.c @@ -21,18 +21,17 @@ * 3. This notice may not be removed or altered from any source * distribution. ***************************************************************************/ +#include "iosuhax.h" +#include "os_functions.h" #include -#include -#include -#include -#include +#include #include #include -#include #include +#include +#include #include -#include "os_functions.h" -#include "iosuhax.h" +#include typedef struct _fs_dev_private_t { char *mount_path; @@ -43,15 +42,15 @@ typedef struct _fs_dev_private_t { typedef struct _fs_dev_file_state_t { fs_dev_private_t *dev; - int fd; /* File descriptor */ - int flags; /* Opening flags */ - int read; /* True if allowed to read from file */ - int write; /* True if allowed to write to file */ - int append; /* True if allowed to append to file */ - uint32_t pos; /* Current position within the file (in bytes) */ - uint32_t len; /* Total length of the file (in bytes) */ - struct _fs_dev_file_state_t *prevOpenFile; /* The previous entry in a double-linked FILO list of open files */ - struct _fs_dev_file_state_t *nextOpenFile; /* The next entry in a double-linked FILO list of open files */ + int fd; /* File descriptor */ + int flags; /* Opening flags */ + int read; /* True if allowed to read from file */ + int write; /* True if allowed to write to file */ + int append; /* True if allowed to append to file */ + uint32_t pos; /* Current position within the file (in bytes) */ + uint32_t len; /* Total length of the file (in bytes) */ + struct _fs_dev_file_state_t *prevOpenFile; /* The previous entry in a double-linked FILO list of open files */ + struct _fs_dev_file_state_t *nextOpenFile; /* The next entry in a double-linked FILO list of open files */ } fs_dev_file_state_t; typedef struct _fs_dev_dir_entry_t { @@ -537,7 +536,6 @@ static int fs_dev_rename_r(struct _reent *r, const char *oldName, const char *ne } return 0; - } static int fs_dev_mkdir_r(struct _reent *r, const char *path, int mode) { diff --git a/source/iosuhax_disc_interface.c b/source/iosuhax_disc_interface.c index 21b74d4..3c6ef36 100644 --- a/source/iosuhax_disc_interface.c +++ b/source/iosuhax_disc_interface.c @@ -21,13 +21,13 @@ * 3. This notice may not be removed or altered from any source * distribution. ***************************************************************************/ -#include -#include -#include "iosuhax.h" #include "iosuhax_disc_interface.h" +#include "iosuhax.h" +#include +#include -#define FSA_REF_SD 0x01 -#define FSA_REF_USB 0x02 +#define FSA_REF_SD 0x01 +#define FSA_REF_USB 0x02 static int initialized = 0; @@ -152,8 +152,7 @@ const DISC_INTERFACE IOSUHAX_sdio_disc_interface = IOSUHAX_sdio_readSectors, IOSUHAX_sdio_writeSectors, IOSUHAX_sdio_clearStatus, - IOSUHAX_sdio_shutdown - }; + IOSUHAX_sdio_shutdown}; static bool IOSUHAX_usb_startup(void) { if (!IOSUHAX_disc_io_fsa_open(FSA_REF_USB)) @@ -223,5 +222,4 @@ const DISC_INTERFACE IOSUHAX_usb_disc_interface = IOSUHAX_usb_readSectors, IOSUHAX_usb_writeSectors, IOSUHAX_usb_clearStatus, - IOSUHAX_usb_shutdown - }; + IOSUHAX_usb_shutdown}; diff --git a/source/os_functions.h b/source/os_functions.h index b1faa87..49d4813 100644 --- a/source/os_functions.h +++ b/source/os_functions.h @@ -5,7 +5,7 @@ extern "C" { #endif -#define OS_MUTEX_SIZE 44 +#define OS_MUTEX_SIZE 44 //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Mutex functions