mirror of
https://github.com/wiiu-env/libiosuhax.git
synced 2024-11-30 13:04:16 +01:00
Format the code via clang-format
Add new Dockerfile for building the lib in pull requests Fix formatting of ALIGN macro
This commit is contained in:
parent
9faa95af56
commit
7e4c2f13bd
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: 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
|
25
.github/workflows/pr.yml
vendored
Normal file
25
.github/workflows/pr.yml
vendored
Normal file
@ -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"
|
8
.github/workflows/push_image.yml
vendored
8
.github/workflows/push_image.yml
vendored
@ -4,8 +4,16 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
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 ./include
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- name: Get release version
|
- name: Get release version
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM wiiuenv/devkitppc:20210920
|
FROM wiiuenv/devkitppc:20211229
|
||||||
|
|
||||||
WORKDIR tmp_build
|
WORKDIR tmp_build
|
||||||
COPY . .
|
COPY . .
|
||||||
|
3
Dockerfile.buildlocal
Normal file
3
Dockerfile.buildlocal
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM wiiuenv/devkitppc:20211229
|
||||||
|
|
||||||
|
WORKDIR project
|
@ -8,3 +8,7 @@ Make you to have [wut](https://github.com/devkitPro/wut/) installed and use the
|
|||||||
```
|
```
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i`
|
||||||
|
@ -29,18 +29,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IOS_ERROR_UNKNOWN_VALUE 0xFFFFFFD6
|
#define IOS_ERROR_UNKNOWN_VALUE 0xFFFFFFD6
|
||||||
#define IOS_ERROR_INVALID_ARG 0xFFFFFFE3
|
#define IOS_ERROR_INVALID_ARG 0xFFFFFFE3
|
||||||
#define IOS_ERROR_INVALID_SIZE 0xFFFFFFE9
|
#define IOS_ERROR_INVALID_SIZE 0xFFFFFFE9
|
||||||
#define IOS_ERROR_UNKNOWN 0xFFFFFFF7
|
#define IOS_ERROR_UNKNOWN 0xFFFFFFF7
|
||||||
#define IOS_ERROR_NOEXISTS 0xFFFFFFFA
|
#define IOS_ERROR_NOEXISTS 0xFFFFFFFA
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
uint32_t permission;
|
uint32_t permission;
|
||||||
uint32_t owner_id;
|
uint32_t owner_id;
|
||||||
uint32_t group_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 physsize; // physical size on disk in bytes
|
||||||
uint32_t unk[3];
|
uint32_t unk[3];
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
@ -54,27 +54,27 @@ typedef struct {
|
|||||||
char name[0x100];
|
char name[0x100];
|
||||||
} directoryEntry_s;
|
} directoryEntry_s;
|
||||||
|
|
||||||
#define DIR_ENTRY_IS_DIRECTORY 0x80000000
|
#define DIR_ENTRY_IS_DIRECTORY 0x80000000
|
||||||
|
|
||||||
#define FSA_MOUNTFLAGS_BINDMOUNT (1 << 0)
|
#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_Close(void);
|
||||||
|
|
||||||
int IOSUHAX_memwrite(uint32_t address, const uint8_t *buffer, uint32_t size); // IOSU external input
|
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_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_write32(uint32_t address, uint32_t value);
|
||||||
|
|
||||||
int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count);
|
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);
|
int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt);
|
||||||
|
|
||||||
|
@ -24,23 +24,23 @@
|
|||||||
#ifndef _IOSUHAX_DISC_INTERFACE_H_
|
#ifndef _IOSUHAX_DISC_INTERFACE_H_
|
||||||
#define _IOSUHAX_DISC_INTERFACE_H_
|
#define _IOSUHAX_DISC_INTERFACE_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEVICE_TYPE_WII_U_SD (('W'<<24)|('U'<<16)|('S'<<8)|'D')
|
#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 DEVICE_TYPE_WII_U_USB (('W' << 24) | ('U' << 16) | ('S' << 8) | 'B')
|
||||||
#define FEATURE_WII_U_SD 0x00001000
|
#define FEATURE_WII_U_SD 0x00001000
|
||||||
#define FEATURE_WII_U_USB 0x00002000
|
#define FEATURE_WII_U_USB 0x00002000
|
||||||
|
|
||||||
#ifndef OGC_DISC_IO_INCLUDE
|
#ifndef OGC_DISC_IO_INCLUDE
|
||||||
typedef uint32_t sec_t;
|
typedef uint32_t sec_t;
|
||||||
|
|
||||||
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
||||||
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
||||||
|
|
||||||
typedef bool (*FN_MEDIUM_STARTUP)(void);
|
typedef bool (*FN_MEDIUM_STARTUP)(void);
|
||||||
|
|
||||||
|
139
source/iosuhax.c
139
source/iosuhax.c
@ -21,54 +21,55 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <string.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include "os_functions.h"
|
|
||||||
#include "iosuhax.h"
|
#include "iosuhax.h"
|
||||||
|
#include "os_functions.h"
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define IOSUHAX_MAGIC_WORD 0x4E696365
|
#define IOSUHAX_MAGIC_WORD 0x4E696365
|
||||||
|
|
||||||
#define IOCTL_MEM_WRITE 0x00
|
#define IOCTL_MEM_WRITE 0x00
|
||||||
#define IOCTL_MEM_READ 0x01
|
#define IOCTL_MEM_READ 0x01
|
||||||
#define IOCTL_SVC 0x02
|
#define IOCTL_SVC 0x02
|
||||||
#define IOCTL_MEMCPY 0x04
|
#define IOCTL_MEMCPY 0x04
|
||||||
#define IOCTL_REPEATED_WRITE 0x05
|
#define IOCTL_REPEATED_WRITE 0x05
|
||||||
#define IOCTL_KERN_READ32 0x06
|
#define IOCTL_KERN_READ32 0x06
|
||||||
#define IOCTL_KERN_WRITE32 0x07
|
#define IOCTL_KERN_WRITE32 0x07
|
||||||
#define IOCTL_READ_OTP 0x08
|
#define IOCTL_READ_OTP 0x08
|
||||||
|
|
||||||
#define IOCTL_FSA_OPEN 0x40
|
#define IOCTL_FSA_OPEN 0x40
|
||||||
#define IOCTL_FSA_CLOSE 0x41
|
#define IOCTL_FSA_CLOSE 0x41
|
||||||
#define IOCTL_FSA_MOUNT 0x42
|
#define IOCTL_FSA_MOUNT 0x42
|
||||||
#define IOCTL_FSA_UNMOUNT 0x43
|
#define IOCTL_FSA_UNMOUNT 0x43
|
||||||
#define IOCTL_FSA_GETDEVICEINFO 0x44
|
#define IOCTL_FSA_GETDEVICEINFO 0x44
|
||||||
#define IOCTL_FSA_OPENDIR 0x45
|
#define IOCTL_FSA_OPENDIR 0x45
|
||||||
#define IOCTL_FSA_READDIR 0x46
|
#define IOCTL_FSA_READDIR 0x46
|
||||||
#define IOCTL_FSA_CLOSEDIR 0x47
|
#define IOCTL_FSA_CLOSEDIR 0x47
|
||||||
#define IOCTL_FSA_MAKEDIR 0x48
|
#define IOCTL_FSA_MAKEDIR 0x48
|
||||||
#define IOCTL_FSA_OPENFILE 0x49
|
#define IOCTL_FSA_OPENFILE 0x49
|
||||||
#define IOCTL_FSA_READFILE 0x4A
|
#define IOCTL_FSA_READFILE 0x4A
|
||||||
#define IOCTL_FSA_WRITEFILE 0x4B
|
#define IOCTL_FSA_WRITEFILE 0x4B
|
||||||
#define IOCTL_FSA_STATFILE 0x4C
|
#define IOCTL_FSA_STATFILE 0x4C
|
||||||
#define IOCTL_FSA_CLOSEFILE 0x4D
|
#define IOCTL_FSA_CLOSEFILE 0x4D
|
||||||
#define IOCTL_FSA_SETFILEPOS 0x4E
|
#define IOCTL_FSA_SETFILEPOS 0x4E
|
||||||
#define IOCTL_FSA_GETSTAT 0x4F
|
#define IOCTL_FSA_GETSTAT 0x4F
|
||||||
#define IOCTL_FSA_REMOVE 0x50
|
#define IOCTL_FSA_REMOVE 0x50
|
||||||
#define IOCTL_FSA_REWINDDIR 0x51
|
#define IOCTL_FSA_REWINDDIR 0x51
|
||||||
#define IOCTL_FSA_CHDIR 0x52
|
#define IOCTL_FSA_CHDIR 0x52
|
||||||
#define IOCTL_FSA_RENAME 0x53
|
#define IOCTL_FSA_RENAME 0x53
|
||||||
#define IOCTL_FSA_RAW_OPEN 0x54
|
#define IOCTL_FSA_RAW_OPEN 0x54
|
||||||
#define IOCTL_FSA_RAW_READ 0x55
|
#define IOCTL_FSA_RAW_READ 0x55
|
||||||
#define IOCTL_FSA_RAW_WRITE 0x56
|
#define IOCTL_FSA_RAW_WRITE 0x56
|
||||||
#define IOCTL_FSA_RAW_CLOSE 0x57
|
#define IOCTL_FSA_RAW_CLOSE 0x57
|
||||||
#define IOCTL_FSA_CHANGEMODE 0x58
|
#define IOCTL_FSA_CHANGEMODE 0x58
|
||||||
#define IOCTL_FSA_FLUSHVOLUME 0x59
|
#define IOCTL_FSA_FLUSHVOLUME 0x59
|
||||||
#define IOCTL_CHECK_IF_IOSUHAX 0x5B
|
#define IOCTL_CHECK_IF_IOSUHAX 0x5B
|
||||||
|
|
||||||
static int iosuhaxHandle = -1;
|
static int iosuhaxHandle = -1;
|
||||||
|
|
||||||
#define ALIGN(align) __attribute__((aligned(align)))
|
#define ALIGN(align) __attribute__((aligned(align)))
|
||||||
#define ROUNDUP(x, align) (((x) + ((align) - 1)) & ~((align) - 1))
|
#define ALIGN_0x20 ALIGN(0x20)
|
||||||
|
#define ROUNDUP(x, align) (((x) + ((align) -1)) & ~((align) -1))
|
||||||
|
|
||||||
int IOSUHAX_Open(const char *dev) {
|
int IOSUHAX_Open(const char *dev) {
|
||||||
if (iosuhaxHandle >= 0)
|
if (iosuhaxHandle >= 0)
|
||||||
@ -77,7 +78,7 @@ int IOSUHAX_Open(const char *dev) {
|
|||||||
iosuhaxHandle = IOS_Open((char *) (dev ? dev : "/dev/iosuhax"), 0);
|
iosuhaxHandle = IOS_Open((char *) (dev ? dev : "/dev/iosuhax"), 0);
|
||||||
if (iosuhaxHandle >= 0 && dev) //make sure device is actually iosuhax
|
if (iosuhaxHandle >= 0 && dev) //make sure device is actually iosuhax
|
||||||
{
|
{
|
||||||
ALIGN(0x20) int res[0x20 >> 2];
|
ALIGN_0x20 int res[0x20 >> 2];
|
||||||
*res = 0;
|
*res = 0;
|
||||||
|
|
||||||
IOS_Ioctl(iosuhaxHandle, IOCTL_CHECK_IF_IOSUHAX, (void *) 0, 0, res, 4);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey){
|
int IOSUHAX_ODM_GetDiscKey(uint8_t *discKey) {
|
||||||
int res = -1;
|
int res = -1;
|
||||||
if(discKey == NULL){
|
if (discKey == NULL) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
int odm_handle = IOS_Open("/dev/odm", 1);
|
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)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) int io_buf[0x20 >> 2];
|
ALIGN_0x20 int io_buf[0x20 >> 2];
|
||||||
io_buf[0] = address;
|
io_buf[0] = address;
|
||||||
|
|
||||||
void *tmp_buf = NULL;
|
void *tmp_buf = NULL;
|
||||||
@ -164,7 +165,7 @@ int IOSUHAX_memcpy(uint32_t dst, uint32_t src, uint32_t size) {
|
|||||||
if (iosuhaxHandle < 0)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) uint32_t io_buf[0x20 >> 2];
|
ALIGN_0x20 uint32_t io_buf[0x20 >> 2];
|
||||||
io_buf[0] = dst;
|
io_buf[0] = dst;
|
||||||
io_buf[1] = src;
|
io_buf[1] = src;
|
||||||
io_buf[2] = size;
|
io_buf[2] = size;
|
||||||
@ -176,51 +177,51 @@ int IOSUHAX_kern_write32(uint32_t address, uint32_t value) {
|
|||||||
if (iosuhaxHandle < 0)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) uint32_t io_buf[0x20 >> 2];
|
ALIGN_0x20 uint32_t io_buf[0x20 >> 2];
|
||||||
io_buf[0] = address;
|
io_buf[0] = address;
|
||||||
io_buf[1] = value;
|
io_buf[1] = value;
|
||||||
|
|
||||||
return IOS_Ioctl(iosuhaxHandle, IOCTL_KERN_WRITE32, io_buf, 2 * sizeof(uint32_t), 0, 0);
|
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) {
|
if (iosuhaxHandle < 0) {
|
||||||
return iosuhaxHandle;
|
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);
|
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);
|
memcpy(out_buffer, io_buf, size > 0x400 ? 0x400 : size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
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) {
|
int IOSUHAX_read_seeprom(uint8_t *out_buffer, uint32_t offset, uint32_t size) {
|
||||||
if(out_buffer == NULL || offset > 0x200 || offset & 0x01) {
|
if (out_buffer == NULL || offset > 0x200 || offset & 0x01) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sizeInShorts = size >> 1;
|
uint32_t sizeInShorts = size >> 1;
|
||||||
uint32_t offsetInShorts = offset >> 1;
|
uint32_t offsetInShorts = offset >> 1;
|
||||||
int32_t maxReadCount = 0x100 - offsetInShorts;
|
int32_t maxReadCount = 0x100 - offsetInShorts;
|
||||||
|
|
||||||
if(maxReadCount <= 0){
|
if (maxReadCount <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts;
|
uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts;
|
||||||
uint16_t *ptr = (uint16_t *) out_buffer;
|
uint16_t *ptr = (uint16_t *) out_buffer;
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if(bspRead("EE", offsetInShorts + i, "access", 2, ptr) != 0) {
|
if (bspRead("EE", offsetInShorts + i, "access", 2, ptr) != 0) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
res += 2;
|
res += 2;
|
||||||
@ -234,7 +235,7 @@ int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count)
|
|||||||
if (iosuhaxHandle < 0)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) uint32_t io_buf[0x20 >> 2];
|
ALIGN_0x20 uint32_t io_buf[0x20 >> 2];
|
||||||
io_buf[0] = address;
|
io_buf[0] = address;
|
||||||
|
|
||||||
void *tmp_buf = NULL;
|
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)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) uint32_t arguments[0x40 >> 2];
|
ALIGN_0x20 uint32_t arguments[0x40 >> 2];
|
||||||
arguments[0] = svc_id;
|
arguments[0] = svc_id;
|
||||||
|
|
||||||
if (args && arg_cnt) {
|
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);
|
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);
|
int ret = IOS_Ioctl(iosuhaxHandle, IOCTL_SVC, arguments, (1 + arg_cnt) * 4, result, 4);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -280,7 +281,7 @@ int IOSUHAX_FSA_Open(void) {
|
|||||||
if (iosuhaxHandle < 0)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
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));
|
int res = IOS_Ioctl(iosuhaxHandle, IOCTL_FSA_OPEN, 0, 0, io_buf, sizeof(int));
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
@ -293,7 +294,7 @@ int IOSUHAX_FSA_Close(int fsaFd) {
|
|||||||
if (iosuhaxHandle < 0)
|
if (iosuhaxHandle < 0)
|
||||||
return iosuhaxHandle;
|
return iosuhaxHandle;
|
||||||
|
|
||||||
ALIGN(0x20) int io_buf[0x20 >> 2];
|
ALIGN_0x20 int io_buf[0x20 >> 2];
|
||||||
io_buf[0] = fsaFd;
|
io_buf[0] = fsaFd;
|
||||||
|
|
||||||
int res = IOS_Ioctl(iosuhaxHandle, IOCTL_FSA_CLOSE, io_buf, sizeof(fsaFd), io_buf, sizeof(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;
|
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);
|
memset(io_buf, 0, io_buf_size);
|
||||||
|
|
||||||
io_buf[0] = fsaFd;
|
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;
|
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[0] = fsaFd;
|
||||||
io_buf[1] = sizeof(uint32_t) * input_cnt;
|
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;
|
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[0] = fsaFd;
|
||||||
io_buf[1] = sizeof(uint32_t) * input_cnt;
|
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;
|
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[0] = fsaFd;
|
||||||
io_buf[1] = sizeof(uint32_t) * input_cnt;
|
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;
|
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[0] = fsaFd;
|
||||||
io_buf[1] = sizeof(uint32_t) * input_cnt;
|
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;
|
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[0] = fsaFd;
|
||||||
io_buf[1] = device_handle;
|
io_buf[1] = device_handle;
|
||||||
|
@ -21,18 +21,17 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#include "iosuhax.h"
|
||||||
|
#include "os_functions.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/iosupport.h>
|
#include <fcntl.h>
|
||||||
#include <sys/statvfs.h>
|
|
||||||
#include <sys/dirent.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/dirent.h>
|
||||||
#include <sys/iosupport.h>
|
#include <sys/iosupport.h>
|
||||||
#include "os_functions.h"
|
#include <sys/statvfs.h>
|
||||||
#include "iosuhax.h"
|
|
||||||
|
|
||||||
typedef struct _fs_dev_private_t {
|
typedef struct _fs_dev_private_t {
|
||||||
char *mount_path;
|
char *mount_path;
|
||||||
@ -43,15 +42,15 @@ typedef struct _fs_dev_private_t {
|
|||||||
|
|
||||||
typedef struct _fs_dev_file_state_t {
|
typedef struct _fs_dev_file_state_t {
|
||||||
fs_dev_private_t *dev;
|
fs_dev_private_t *dev;
|
||||||
int fd; /* File descriptor */
|
int fd; /* File descriptor */
|
||||||
int flags; /* Opening flags */
|
int flags; /* Opening flags */
|
||||||
int read; /* True if allowed to read from file */
|
int read; /* True if allowed to read from file */
|
||||||
int write; /* True if allowed to write to file */
|
int write; /* True if allowed to write to file */
|
||||||
int append; /* True if allowed to append to file */
|
int append; /* True if allowed to append to file */
|
||||||
uint32_t pos; /* Current position within the file (in bytes) */
|
uint32_t pos; /* Current position within the file (in bytes) */
|
||||||
uint32_t len; /* Total length of 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 *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 */
|
struct _fs_dev_file_state_t *nextOpenFile; /* The next entry in a double-linked FILO list of open files */
|
||||||
} fs_dev_file_state_t;
|
} fs_dev_file_state_t;
|
||||||
|
|
||||||
typedef struct _fs_dev_dir_entry_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;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fs_dev_mkdir_r(struct _reent *r, const char *path, int mode) {
|
static int fs_dev_mkdir_r(struct _reent *r, const char *path, int mode) {
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <string.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include "iosuhax.h"
|
|
||||||
#include "iosuhax_disc_interface.h"
|
#include "iosuhax_disc_interface.h"
|
||||||
|
#include "iosuhax.h"
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define FSA_REF_SD 0x01
|
#define FSA_REF_SD 0x01
|
||||||
#define FSA_REF_USB 0x02
|
#define FSA_REF_USB 0x02
|
||||||
|
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
|
|
||||||
@ -152,8 +152,7 @@ const DISC_INTERFACE IOSUHAX_sdio_disc_interface =
|
|||||||
IOSUHAX_sdio_readSectors,
|
IOSUHAX_sdio_readSectors,
|
||||||
IOSUHAX_sdio_writeSectors,
|
IOSUHAX_sdio_writeSectors,
|
||||||
IOSUHAX_sdio_clearStatus,
|
IOSUHAX_sdio_clearStatus,
|
||||||
IOSUHAX_sdio_shutdown
|
IOSUHAX_sdio_shutdown};
|
||||||
};
|
|
||||||
|
|
||||||
static bool IOSUHAX_usb_startup(void) {
|
static bool IOSUHAX_usb_startup(void) {
|
||||||
if (!IOSUHAX_disc_io_fsa_open(FSA_REF_USB))
|
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_readSectors,
|
||||||
IOSUHAX_usb_writeSectors,
|
IOSUHAX_usb_writeSectors,
|
||||||
IOSUHAX_usb_clearStatus,
|
IOSUHAX_usb_clearStatus,
|
||||||
IOSUHAX_usb_shutdown
|
IOSUHAX_usb_shutdown};
|
||||||
};
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OS_MUTEX_SIZE 44
|
#define OS_MUTEX_SIZE 44
|
||||||
|
|
||||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
//! Mutex functions
|
//! Mutex functions
|
||||||
|
Loading…
Reference in New Issue
Block a user