From 17fa15ee249396ae13017490db1586b353d9383b Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 10 Sep 2017 14:01:55 +0200 Subject: [PATCH 1/4] Deleting the dynamic libs, will be added as an submodule --- src/dynamic_libs/.gitattributes | 17 - src/dynamic_libs/.gitignore | 47 -- src/dynamic_libs/README.md | 2 - src/dynamic_libs/acp_functions.c | 40 -- src/dynamic_libs/acp_functions.h | 42 -- src/dynamic_libs/aoc_functions.c | 58 --- src/dynamic_libs/aoc_functions.h | 58 --- src/dynamic_libs/ax_functions.c | 118 ----- src/dynamic_libs/ax_functions.h | 64 --- src/dynamic_libs/fs_defs.h | 61 --- src/dynamic_libs/fs_functions.c | 131 ----- src/dynamic_libs/fs_functions.h | 95 ---- src/dynamic_libs/gx2_functions.c | 173 ------- src/dynamic_libs/gx2_functions.h | 211 -------- src/dynamic_libs/gx2_types.h | 699 -------------------------- src/dynamic_libs/os_functions.c | 345 ------------- src/dynamic_libs/os_functions.h | 183 ------- src/dynamic_libs/os_types.h | 27 - src/dynamic_libs/padscore_functions.c | 61 --- src/dynamic_libs/padscore_functions.h | 171 ------- src/dynamic_libs/socket_functions.c | 81 --- src/dynamic_libs/socket_functions.h | 108 ---- src/dynamic_libs/sys_functions.c | 51 -- src/dynamic_libs/sys_functions.h | 48 -- src/dynamic_libs/syshid_functions.c | 78 --- src/dynamic_libs/syshid_functions.h | 90 ---- src/dynamic_libs/vpad_functions.c | 55 -- src/dynamic_libs/vpad_functions.h | 114 ----- 28 files changed, 3228 deletions(-) delete mode 100644 src/dynamic_libs/.gitattributes delete mode 100644 src/dynamic_libs/.gitignore delete mode 100644 src/dynamic_libs/README.md delete mode 100644 src/dynamic_libs/acp_functions.c delete mode 100644 src/dynamic_libs/acp_functions.h delete mode 100644 src/dynamic_libs/aoc_functions.c delete mode 100644 src/dynamic_libs/aoc_functions.h delete mode 100644 src/dynamic_libs/ax_functions.c delete mode 100644 src/dynamic_libs/ax_functions.h delete mode 100644 src/dynamic_libs/fs_defs.h delete mode 100644 src/dynamic_libs/fs_functions.c delete mode 100644 src/dynamic_libs/fs_functions.h delete mode 100644 src/dynamic_libs/gx2_functions.c delete mode 100644 src/dynamic_libs/gx2_functions.h delete mode 100644 src/dynamic_libs/gx2_types.h delete mode 100644 src/dynamic_libs/os_functions.c delete mode 100644 src/dynamic_libs/os_functions.h delete mode 100644 src/dynamic_libs/os_types.h delete mode 100644 src/dynamic_libs/padscore_functions.c delete mode 100644 src/dynamic_libs/padscore_functions.h delete mode 100644 src/dynamic_libs/socket_functions.c delete mode 100644 src/dynamic_libs/socket_functions.h delete mode 100644 src/dynamic_libs/sys_functions.c delete mode 100644 src/dynamic_libs/sys_functions.h delete mode 100644 src/dynamic_libs/syshid_functions.c delete mode 100644 src/dynamic_libs/syshid_functions.h delete mode 100644 src/dynamic_libs/vpad_functions.c delete mode 100644 src/dynamic_libs/vpad_functions.h diff --git a/src/dynamic_libs/.gitattributes b/src/dynamic_libs/.gitattributes deleted file mode 100644 index bdb0cab..0000000 --- a/src/dynamic_libs/.gitattributes +++ /dev/null @@ -1,17 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/src/dynamic_libs/.gitignore b/src/dynamic_libs/.gitignore deleted file mode 100644 index cd2946a..0000000 --- a/src/dynamic_libs/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk diff --git a/src/dynamic_libs/README.md b/src/dynamic_libs/README.md deleted file mode 100644 index be82302..0000000 --- a/src/dynamic_libs/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# dynamic_libs -Dynamic libs for WiiU homebrew diff --git a/src/dynamic_libs/acp_functions.c b/src/dynamic_libs/acp_functions.c deleted file mode 100644 index eb931f8..0000000 --- a/src/dynamic_libs/acp_functions.c +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "acp_functions.h" - -unsigned int acp_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, GetMetaXml, void * _ACPMetaXml); - -void InitAcquireACP(void) -{ - OSDynLoad_Acquire("nn_acp.rpl", &acp_handle); -} - -void InitACPFunctionPointers(void) -{ - InitAcquireACP(); - OSDynLoad_FindExport(acp_handle,0,"GetMetaXml__Q2_2nn3acpFP11_ACPMetaXml",&GetMetaXml); -} diff --git a/src/dynamic_libs/acp_functions.h b/src/dynamic_libs/acp_functions.h deleted file mode 100644 index dc1822d..0000000 --- a/src/dynamic_libs/acp_functions.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __ACP_FUNCTIONS_H_ -#define __ACP_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern unsigned int acp_handle; - -void InitACPFunctionPointers(void); -void InitAcquireACP(void); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/dynamic_libs/aoc_functions.c b/src/dynamic_libs/aoc_functions.c deleted file mode 100644 index e74306d..0000000 --- a/src/dynamic_libs/aoc_functions.c +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "aoc_functions.h" - -unsigned int aoc_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(s32, AOC_Initialize, void); -EXPORT_DECL(s32, AOC_Finalize, void); -EXPORT_DECL(u32, AOC_CalculateWorkBufferSize, u32 num_titles); -EXPORT_DECL(s32, AOC_ListTitle, u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_OpenTitle, char* aoc_path, void * title, void * buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_CloseTitle, void * title); -EXPORT_DECL(s32, AOC_DeleteContent, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void* buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_GetPurchaseInfo, u32 * bResult, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); - -void InitAcquireAoc(void) -{ - OSDynLoad_Acquire("nn_aoc.rpl", &aoc_handle); -} - -void InitAocFunctionPointers(void) -{ - InitAcquireAoc(); - if(aoc_handle == 0) - return; - - //! assigning those is not mandatory and it does not always work to load them - OSDynLoad_FindExport(aoc_handle, 0, "AOC_Initialize", &AOC_Initialize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_Finalize", &AOC_Finalize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_CalculateWorkBufferSize", &AOC_CalculateWorkBufferSize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_ListTitle", &AOC_ListTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_OpenTitle", &AOC_OpenTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_CloseTitle", &AOC_CloseTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_DeleteContent", &AOC_DeleteContent); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_GetPurchaseInfo", &AOC_GetPurchaseInfo); -} diff --git a/src/dynamic_libs/aoc_functions.h b/src/dynamic_libs/aoc_functions.h deleted file mode 100644 index efca771..0000000 --- a/src/dynamic_libs/aoc_functions.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __AOC_FUNCTIONS_H_ -#define __AOC_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int aoc_handle; - -#define AOC_TITLE_SIZE 104 - -typedef struct { - u64 title_ID; - u32 group_ID; - u16 version; - char path[88]; -} AOC_TitleListType; - - -void InitAocFunctionPointers(void); -void InitAcquireAoc(void); - -extern s32 (* AOC_Initialize)(void); -extern s32 (* AOC_Finalize)(void); -extern u32 (* AOC_CalculateWorkBufferSize)(u32 num_titles); -extern s32 (* AOC_ListTitle)(u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); -extern s32 (* AOC_OpenTitle)(char* aoc_path, void * title, void * buffer, u32 buffer_size); -extern s32 (* AOC_CloseTitle)(void * title); -extern s32 (* AOC_DeleteContent)(u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); -extern s32 (* AOC_GetPurchaseInfo)(u32 * bResult, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); -#ifdef __cplusplus -} -#endif - -#endif // __AOC_FUNCTIONS_H_ diff --git a/src/dynamic_libs/ax_functions.c b/src/dynamic_libs/ax_functions.c deleted file mode 100644 index e517f6d..0000000 --- a/src/dynamic_libs/ax_functions.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "common/common.h" -#include "os_functions.h" -#include "ax_functions.h" - -unsigned int sound_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, AXInitWithParams, u32 * params); -EXPORT_DECL(void, AXInit, void); -EXPORT_DECL(void, AXQuit, void); -EXPORT_DECL(u32, AXGetInputSamplesPerSec, void); -EXPORT_DECL(u32, AXGetInputSamplesPerFrame, void); -EXPORT_DECL(s32, AXVoiceBegin, void *v); -EXPORT_DECL(s32, AXVoiceEnd, void *v); -EXPORT_DECL(void, AXSetVoiceType, void *v, u16 type); -EXPORT_DECL(void, AXSetVoiceOffsets, void *v, const void *buf); -EXPORT_DECL(void, AXSetVoiceSrcType, void *v, u32 type); -EXPORT_DECL(void, AXSetVoiceVe, void *v, const void *vol); -EXPORT_DECL(s32, AXSetVoiceDeviceMix, void *v, s32 device, u32 id, void *mix); -EXPORT_DECL(void, AXSetVoiceState, void *v, u16 state); -EXPORT_DECL(void, AXSetVoiceSrc, void *v, const void *src); -EXPORT_DECL(s32, AXSetVoiceSrcRatio, void *v,f32 ratio) -EXPORT_DECL(void *, AXAcquireVoice, u32 prio, void * callback, u32 arg); -EXPORT_DECL(void, AXFreeVoice, void *v); -EXPORT_DECL(void, AXRegisterFrameCallback, void * callback); -EXPORT_DECL(u32, AXGetVoiceLoopCount, void *v); -EXPORT_DECL(void, AXSetVoiceEndOffset, void *v, u32 offset); -EXPORT_DECL(void, AXSetVoiceLoopOffset, void *v, u32 offset); - -void InitAcquireAX(void) -{ - unsigned int *funcPointer = 0; - - if(OS_FIRMWARE >= 400) - { - AXInit = 0; - - OSDynLoad_Acquire("sndcore2.rpl", &sound_handle); - OS_FIND_EXPORT(sound_handle, AXInitWithParams); - OS_FIND_EXPORT(sound_handle, AXGetInputSamplesPerSec); - } - else - { - AXInitWithParams = 0; - AXGetInputSamplesPerSec = 0; - - OSDynLoad_Acquire("snd_core.rpl", &sound_handle); - OS_FIND_EXPORT(sound_handle, AXInit); - } -} - -void InitAXFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - InitAcquireAX(); - - OS_FIND_EXPORT(sound_handle, AXQuit); - OS_FIND_EXPORT(sound_handle, AXVoiceBegin); - OS_FIND_EXPORT(sound_handle, AXVoiceEnd); - OS_FIND_EXPORT(sound_handle, AXSetVoiceType); - OS_FIND_EXPORT(sound_handle, AXSetVoiceOffsets); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcType); - OS_FIND_EXPORT(sound_handle, AXSetVoiceVe); - OS_FIND_EXPORT(sound_handle, AXSetVoiceDeviceMix); - OS_FIND_EXPORT(sound_handle, AXSetVoiceState); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrc); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcRatio); - OS_FIND_EXPORT(sound_handle, AXAcquireVoice); - OS_FIND_EXPORT(sound_handle, AXFreeVoice); - OS_FIND_EXPORT(sound_handle, AXRegisterFrameCallback); - OS_FIND_EXPORT(sound_handle, AXGetVoiceLoopCount); - OS_FIND_EXPORT(sound_handle, AXSetVoiceEndOffset); - OS_FIND_EXPORT(sound_handle, AXSetVoiceLoopOffset); -} - -void ProperlyEndTransitionAudio(void) -{ - bool (* check_os_audio_transition_flag_old)(void); - void (* AXInit_old)(void); - void (* AXQuit_old)(void); - - unsigned int *funcPointer = 0; - unsigned int sound_handle; - OSDynLoad_Acquire("snd_core.rpl", &sound_handle); - - OS_FIND_EXPORT_EX(sound_handle, check_os_audio_transition_flag, check_os_audio_transition_flag_old); - OS_FIND_EXPORT_EX(sound_handle, AXInit, AXInit_old); - OS_FIND_EXPORT_EX(sound_handle, AXQuit, AXQuit_old); - - if (check_os_audio_transition_flag_old()) - { - AXInit_old(); - AXQuit_old(); - } -} diff --git a/src/dynamic_libs/ax_functions.h b/src/dynamic_libs/ax_functions.h deleted file mode 100644 index 086346f..0000000 --- a/src/dynamic_libs/ax_functions.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __AX_FUNCTIONS_H_ -#define __AX_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern unsigned int sound_handle; - -void InitAXFunctionPointers(void); -void InitAcquireAX(void); -void ProperlyEndTransitionAudio(void); - -extern void (* AXInitWithParams)(u32 * params); -extern void (* AXInit)(void); -extern void (* AXQuit)(void); -extern u32 (* AXGetInputSamplesPerSec)(void); -extern s32 (* AXVoiceBegin)(void *v); -extern s32 (* AXVoiceEnd)(void *v); -extern void (* AXSetVoiceType)(void *v, u16 type); -extern void (* AXSetVoiceOffsets)(void *v, const void *buf); -extern void (* AXSetVoiceSrcType)(void *v, u32 type); -extern void (* AXSetVoiceVe)(void *v, const void *vol); -extern s32 (* AXSetVoiceDeviceMix)(void *v, s32 device, u32 id, void *mix); -extern void (* AXSetVoiceState)(void *v, u16 state); -extern void (* AXSetVoiceSrc)(void *v, const void *src); -extern s32 (* AXSetVoiceSrcRatio)(void *v, f32 ratio); -extern void * (* AXAcquireVoice)(u32 prio, void * callback, u32 arg); -extern void (* AXFreeVoice)(void *v); -extern void (* AXRegisterFrameCallback)(void * callback); -extern u32 (* AXGetVoiceLoopCount)(void * v); -extern void (* AXSetVoiceEndOffset)(void * v, u32 offset); -extern void (* AXSetVoiceLoopOffset)(void * v, u32 offset); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/dynamic_libs/fs_defs.h b/src/dynamic_libs/fs_defs.h deleted file mode 100644 index 1b1bc41..0000000 --- a/src/dynamic_libs/fs_defs.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef FS_DEFS_H -#define FS_DEFS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* FS defines and types */ -#define FS_MAX_LOCALPATH_SIZE 511 -#define FS_MAX_MOUNTPATH_SIZE 128 -#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE) -#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE - -#define FS_STATUS_OK 0 -#define FS_RET_UNSUPPORTED_CMD 0x0400 -#define FS_RET_NO_ERROR 0x0000 -#define FS_RET_ALL_ERROR (unsigned int)(-1) - -#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000 - -/* max length of file/dir name */ -#define FS_MAX_ENTNAME_SIZE 256 - -#define FS_SOURCETYPE_EXTERNAL 0 -#define FS_SOURCETYPE_HFIO 1 - -#define FS_MOUNT_SOURCE_SIZE 0x300 -#define FS_CLIENT_SIZE 0x1700 -#define FS_CMD_BLOCK_SIZE 0xA80 - -typedef struct -{ - uint32_t flag; - uint32_t permission; - uint32_t owner_id; - uint32_t group_id; - uint32_t size; - uint32_t alloc_size; - uint64_t quota_size; - uint32_t ent_id; - uint64_t ctime; - uint64_t mtime; - uint8_t attributes[48]; -} __attribute__((packed)) FSStat; - -typedef struct -{ - FSStat stat; - char name[FS_MAX_ENTNAME_SIZE]; -} FSDirEntry; - - -#ifdef __cplusplus -} -#endif - -#endif /* FS_DEFS_H */ - diff --git a/src/dynamic_libs/fs_functions.c b/src/dynamic_libs/fs_functions.c deleted file mode 100644 index 08a4fb6..0000000 --- a/src/dynamic_libs/fs_functions.c +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "fs_functions.h" -#include "os_functions.h" - -EXPORT_DECL(int, FSInit, void); -EXPORT_DECL(int, FSShutdown, void); -EXPORT_DECL(int, FSAddClientEx, void *pClient, int unk_zero_param, int errHandling); -EXPORT_DECL(int, FSDelClient, void *pClient); -EXPORT_DECL(void, FSInitCmdBlock, void *pCmd); -EXPORT_DECL(int, FSGetMountSource, void *pClient, void *pCmd, int type, void *source, int errHandling); - -EXPORT_DECL(int, FSMount, void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling); -EXPORT_DECL(int, FSUnmount, void *pClient, void *pCmd, const char *target, int errHandling); - -EXPORT_DECL(int, FSGetStat, void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling); -EXPORT_DECL(int, FSGetStatAsync, void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams); -EXPORT_DECL(int, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); -EXPORT_DECL(int, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); -EXPORT_DECL(int, FSRemove, void *pClient, void *pCmd, const char *path, int error); -EXPORT_DECL(int, FSRemoveAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -EXPORT_DECL(int, FSFlushQuota, void *pClient, void *pCmd, const char* path, int error); -EXPORT_DECL(int, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -EXPORT_DECL(int, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error); -EXPORT_DECL(int, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams); -EXPORT_DECL(int, FSRollbackQuota, void *pClient, void *pCmd, const char *path, int error); -EXPORT_DECL(int, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); - -EXPORT_DECL(int, FSOpenDir, void *pClient, void *pCmd, const char *path, int *dh, int errHandling); -EXPORT_DECL(int, FSOpenDirAsync, void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams); -EXPORT_DECL(int, FSReadDir, void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling); -EXPORT_DECL(int, FSRewindDir, void *pClient, void *pCmd, int dh, int errHandling); -EXPORT_DECL(int, FSCloseDir, void *pClient, void *pCmd, int dh, int errHandling); -EXPORT_DECL(int, FSChangeDir, void *pClient, void *pCmd, const char *path, int errHandling); -EXPORT_DECL(int, FSChangeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -EXPORT_DECL(int, FSMakeDir, void *pClient, void *pCmd, const char *path, int errHandling); -EXPORT_DECL(int, FSMakeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); - -EXPORT_DECL(int, FSOpenFile, void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling); -EXPORT_DECL(int, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams); -EXPORT_DECL(int, FSReadFile, void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling); -EXPORT_DECL(int, FSCloseFile, void *pClient, void *pCmd, int fd, int errHandling); - -EXPORT_DECL(int, FSFlushFile, void *pClient, void *pCmd, int fd, int error); -EXPORT_DECL(int, FSTruncateFile, void *pClient, void *pCmd, int fd, int error); -EXPORT_DECL(int, FSGetStatFile, void *pClient, void *pCmd, int fd, void *buffer, int error); -EXPORT_DECL(int, FSSetPosFile, void *pClient, void *pCmd, int fd, int pos, int error); -EXPORT_DECL(int, FSWriteFile, void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error); - -EXPORT_DECL(int, FSBindMount, void *pClient, void *pCmd, char *source, char *target, int error); -EXPORT_DECL(int, FSBindUnmount, void *pClient, void *pCmd, char *target, int error); - -EXPORT_DECL(int, FSMakeQuota, void *pClient, void *pCmd, const char *path,u32 mode, u64 size, int errHandling); -EXPORT_DECL(int, FSMakeQuotaAsync ,void *pClient, void *pCmd, const char *path,u32 mode, u64 size, int errHandling,const void *asyncParams); - -void InitFSFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - OS_FIND_EXPORT(coreinit_handle, FSInit); - OS_FIND_EXPORT(coreinit_handle, FSShutdown); - OS_FIND_EXPORT(coreinit_handle, FSAddClientEx); - OS_FIND_EXPORT(coreinit_handle, FSDelClient); - OS_FIND_EXPORT(coreinit_handle, FSInitCmdBlock); - OS_FIND_EXPORT(coreinit_handle, FSGetMountSource); - - OS_FIND_EXPORT(coreinit_handle, FSMount); - OS_FIND_EXPORT(coreinit_handle, FSUnmount); - - OS_FIND_EXPORT(coreinit_handle, FSGetStat); - OS_FIND_EXPORT(coreinit_handle, FSGetStatAsync); - OS_FIND_EXPORT(coreinit_handle, FSRename); - OS_FIND_EXPORT(coreinit_handle, FSRenameAsync); - OS_FIND_EXPORT(coreinit_handle, FSRemove); - OS_FIND_EXPORT(coreinit_handle, FSRemoveAsync); - OS_FIND_EXPORT(coreinit_handle, FSFlushQuota); - OS_FIND_EXPORT(coreinit_handle, FSFlushQuotaAsync); - OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSize); - OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSizeAsync); - OS_FIND_EXPORT(coreinit_handle, FSRollbackQuota); - OS_FIND_EXPORT(coreinit_handle, FSRollbackQuotaAsync); - - OS_FIND_EXPORT(coreinit_handle, FSOpenDir); - OS_FIND_EXPORT(coreinit_handle, FSOpenDirAsync); - OS_FIND_EXPORT(coreinit_handle, FSReadDir); - OS_FIND_EXPORT(coreinit_handle, FSRewindDir); - OS_FIND_EXPORT(coreinit_handle, FSCloseDir); - OS_FIND_EXPORT(coreinit_handle, FSChangeDir); - OS_FIND_EXPORT(coreinit_handle, FSChangeDirAsync); - OS_FIND_EXPORT(coreinit_handle, FSMakeDir); - OS_FIND_EXPORT(coreinit_handle, FSMakeDirAsync); - - - OS_FIND_EXPORT(coreinit_handle, FSOpenFile); - OS_FIND_EXPORT(coreinit_handle, FSOpenFileAsync); - OS_FIND_EXPORT(coreinit_handle, FSReadFile); - OS_FIND_EXPORT(coreinit_handle, FSCloseFile); - - OS_FIND_EXPORT(coreinit_handle, FSFlushFile); - OS_FIND_EXPORT(coreinit_handle, FSTruncateFile); - OS_FIND_EXPORT(coreinit_handle, FSGetStatFile); - OS_FIND_EXPORT(coreinit_handle, FSSetPosFile); - OS_FIND_EXPORT(coreinit_handle, FSWriteFile); - - OS_FIND_EXPORT(coreinit_handle, FSBindMount); - OS_FIND_EXPORT(coreinit_handle, FSBindUnmount); - - OS_FIND_EXPORT(coreinit_handle, FSMakeQuota); - OS_FIND_EXPORT(coreinit_handle, FSMakeQuotaAsync); -} diff --git a/src/dynamic_libs/fs_functions.h b/src/dynamic_libs/fs_functions.h deleted file mode 100644 index d024655..0000000 --- a/src/dynamic_libs/fs_functions.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __FS_FUNCTIONS_H_ -#define __FS_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "fs_defs.h" - -void InitFSFunctionPointers(void); - -extern int (* FSInit)(void); -extern int (* FSShutdown)(void); -extern int (* FSAddClientEx)(void *pClient, int unk_zero_param, int errHandling); -extern int (* FSDelClient)(void *pClient); -extern void (* FSInitCmdBlock)(void *pCmd); -extern int (* FSGetMountSource)(void *pClient, void *pCmd, int type, void *source, int errHandling); - -extern int (* FSMount)(void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling); -extern int (* FSUnmount)(void *pClient, void *pCmd, const char *target, int errHandling); -extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); -extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); -extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error); -extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); - -extern int (* FSGetStat)(void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling); -extern int (* FSGetStatAsync)(void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams); -extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); -extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); -extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error); -extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -extern int (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, int error); -extern int (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -extern int (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error); -extern int (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams); -extern int (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, int error); -extern int (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); - -extern int (* FSOpenDir)(void *pClient, void *pCmd, const char *path, int *dh, int errHandling); -extern int (* FSOpenDirAsync)(void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams); -extern int (* FSReadDir)(void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling); -extern int (* FSRewindDir)(void *pClient, void *pCmd, int dh, int errHandling); -extern int (* FSCloseDir)(void *pClient, void *pCmd, int dh, int errHandling); -extern int (* FSChangeDir)(void *pClient, void *pCmd, const char *path, int errHandling); -extern int (* FSChangeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); -extern int (* FSMakeDir)(void *pClient, void *pCmd, const char *path, int errHandling); -extern int (* FSMakeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); - -extern int (* FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling); -extern int (* FSOpenFileAsync)(void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams); -extern int (* FSReadFile)(void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling); -extern int (* FSCloseFile)(void *pClient, void *pCmd, int fd, int errHandling); - -extern int (* FSFlushFile)(void *pClient, void *pCmd, int fd, int error); -extern int (* FSTruncateFile)(void *pClient, void *pCmd, int fd, int error); -extern int (* FSGetStatFile)(void *pClient, void *pCmd, int fd, void *buffer, int error); -extern int (* FSSetPosFile)(void *pClient, void *pCmd, int fd, int pos, int error); -extern int (* FSWriteFile)(void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error); - -extern int (* FSBindMount)(void *pClient, void *pCmd, char *source, char *target, int error); -extern int (* FSBindUnmount)(void *pClient, void *pCmd, char *target, int error); - -extern int (* FSMakeQuota)( void *pClient, void *pCmd, const char *path,u32 mode, u64 size, int errHandling); -extern int (* FSMakeQuotaAsync)(void *pClient, void *pCmd, const char *path,u32 mode, u64 size, int errHandling,const void *asyncParams); - - -#ifdef __cplusplus -} -#endif - -#endif // __FS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_functions.c b/src/dynamic_libs/gx2_functions.c deleted file mode 100644 index a34807e..0000000 --- a/src/dynamic_libs/gx2_functions.c +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "gx2_types.h" - -unsigned int gx2_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, GX2Init, u32 * init_attribs); -EXPORT_DECL(void, GX2Shutdown, void); -EXPORT_DECL(void, GX2Flush, void); -EXPORT_DECL(s32, GX2GetMainCoreId, void) ; -EXPORT_DECL(s32, GX2DrawDone, void); -EXPORT_DECL(void, GX2ClearColor, GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); -EXPORT_DECL(void, GX2SetViewport, f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); -EXPORT_DECL(void, GX2SetScissor, u32 x_orig, u32 y_orig, u32 wd, u32 ht); -EXPORT_DECL(void, GX2SetContextState, const GX2ContextState* state); -EXPORT_DECL(void, GX2DrawEx, s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); -EXPORT_DECL(void, GX2DrawIndexedEx, s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); -EXPORT_DECL(void, GX2ClearDepthStencilEx, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); -EXPORT_DECL(void, GX2SetClearDepthStencil, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value); -EXPORT_DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target); -EXPORT_DECL(void, GX2SwapScanBuffers, void); -EXPORT_DECL(void, GX2SetTVEnable, s32 enable); -EXPORT_DECL(void, GX2SetSwapInterval, u32 swap_interval); -EXPORT_DECL(u32, GX2GetSwapInterval, void); -EXPORT_DECL(void, GX2WaitForVsync, void); -EXPORT_DECL(void, GX2CalcTVSize, s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); -EXPORT_DECL(void, GX2Invalidate, s32 invalidate_type, void * ptr, u32 buffer_size); -EXPORT_DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); -EXPORT_DECL(void, GX2CalcSurfaceSizeAndAlignment, GX2Surface *surface); -EXPORT_DECL(void, GX2InitDepthBufferRegs, GX2DepthBuffer *depthBuffer); -EXPORT_DECL(void, GX2InitColorBufferRegs, GX2ColorBuffer *colorBuffer); -EXPORT_DECL(void, GX2CalcColorBufferAuxInfo, GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); -EXPORT_DECL(void, GX2CalcDepthBufferHiZInfo, GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); -EXPORT_DECL(void, GX2InitDepthBufferHiZEnable, GX2DepthBuffer *depthBuffer, s32 hiZ_enable); -EXPORT_DECL(void, GX2SetupContextStateEx, GX2ContextState* state, s32 enable_profiling); -EXPORT_DECL(void, GX2SetColorBuffer, const GX2ColorBuffer *colorBuffer, s32 target); -EXPORT_DECL(void, GX2SetDepthBuffer, const GX2DepthBuffer *depthBuffer); -EXPORT_DECL(void, GX2SetAttribBuffer, u32 attr_index, u32 attr_size, u32 stride, const void* attr); -EXPORT_DECL(void, GX2InitTextureRegs, GX2Texture *texture); -EXPORT_DECL(void, GX2InitSampler, GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); -EXPORT_DECL(u32, GX2CalcFetchShaderSizeEx, u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); -EXPORT_DECL(void, GX2InitFetchShaderEx, GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); -EXPORT_DECL(void, GX2SetFetchShader, const GX2FetchShader* fs); -EXPORT_DECL(void, GX2SetVertexUniformReg, u32 offset, u32 count, const void *values); -EXPORT_DECL(void, GX2SetPixelUniformReg, u32 offset, u32 count, const void *values); -EXPORT_DECL(void, GX2SetPixelTexture, const GX2Texture *texture, u32 texture_hw_location); -EXPORT_DECL(void, GX2SetVertexTexture, const GX2Texture *texture, u32 texture_hw_location); -EXPORT_DECL(void, GX2SetPixelSampler, const GX2Sampler *sampler, u32 sampler_hw_location); -EXPORT_DECL(void, GX2SetVertexSampler, const GX2Sampler *sampler, u32 sampler_hw_location); -EXPORT_DECL(void, GX2SetPixelShader, const GX2PixelShader* pixelShader); -EXPORT_DECL(void, GX2SetVertexShader, const GX2VertexShader* vertexShader); -EXPORT_DECL(void, GX2InitSamplerZMFilter, GX2Sampler *sampler, s32 z_filter, s32 mip_filter); -EXPORT_DECL(void, GX2SetColorControl, s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); -EXPORT_DECL(void, GX2SetDepthOnlyControl, s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); -EXPORT_DECL(void, GX2SetBlendControl, s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); -EXPORT_DECL(void, GX2CalcDRCSize, s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); -EXPORT_DECL(void, GX2SetDRCBuffer, void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); -EXPORT_DECL(void, GX2SetDRCScale, u32 width, u32 height); -EXPORT_DECL(void, GX2SetDRCEnable, s32 enable); -EXPORT_DECL(void, GX2SetPolygonControl, s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); -EXPORT_DECL(void, GX2SetCullOnlyControl, s32 front_face_mode, s32 cull_front, s32 cull_back); -EXPORT_DECL(void, GX2SetDepthStencilControl, s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, - s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, - s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); -EXPORT_DECL(void, GX2SetStencilMask, u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); -EXPORT_DECL(void, GX2SetLineWidth, f32 width); -EXPORT_DECL(void, GX2SetTVGamma, f32 val); -EXPORT_DECL(void, GX2SetDRCGamma, f32 gam); -EXPORT_DECL(s32, GX2GetSystemTVScanMode, void); -EXPORT_DECL(s32, GX2GetSystemDRCScanMode, void); -EXPORT_DECL(void, GX2RSetAllocator, void * (* allocFunc)(u32, u32, u32), void (* freeFunc)(u32, void*)); -EXPORT_DECL(void, GX2CopySurface, GX2Surface * srcSurface,u32 srcMip,u32 srcSlice,GX2Surface * dstSurface,u32 dstMip,u32 dstSlice ); - -EXPORT_DECL(void, GX2ClearBuffersEx, GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,f32 r, f32 g, f32 b, f32 a,f32 depthValue,u8 stencilValue,int clearFlags); - -void InitAcquireGX2(void) -{ - OSDynLoad_Acquire("gx2.rpl", &gx2_handle); -} - -void InitGX2FunctionPointers(void) -{ - unsigned int *funcPointer = 0; - InitAcquireGX2(); - - OS_FIND_EXPORT(gx2_handle, GX2Init); - OS_FIND_EXPORT(gx2_handle, GX2Shutdown); - OS_FIND_EXPORT(gx2_handle, GX2Flush); - OS_FIND_EXPORT(gx2_handle, GX2GetMainCoreId); - OS_FIND_EXPORT(gx2_handle, GX2DrawDone); - OS_FIND_EXPORT(gx2_handle, GX2ClearColor); - OS_FIND_EXPORT(gx2_handle, GX2SetViewport); - OS_FIND_EXPORT(gx2_handle, GX2SetScissor); - OS_FIND_EXPORT(gx2_handle, GX2SetContextState); - OS_FIND_EXPORT(gx2_handle, GX2DrawEx); - OS_FIND_EXPORT(gx2_handle, GX2DrawIndexedEx); - OS_FIND_EXPORT(gx2_handle, GX2ClearDepthStencilEx); - OS_FIND_EXPORT(gx2_handle, GX2CopyColorBufferToScanBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SwapScanBuffers); - OS_FIND_EXPORT(gx2_handle, GX2SetTVEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetSwapInterval); - OS_FIND_EXPORT(gx2_handle, GX2GetSwapInterval); - OS_FIND_EXPORT(gx2_handle, GX2WaitForVsync); - OS_FIND_EXPORT(gx2_handle, GX2CalcTVSize); - OS_FIND_EXPORT(gx2_handle, GX2Invalidate); - OS_FIND_EXPORT(gx2_handle, GX2SetTVBuffer); - OS_FIND_EXPORT(gx2_handle, GX2CalcSurfaceSizeAndAlignment); - OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferRegs); - OS_FIND_EXPORT(gx2_handle, GX2InitColorBufferRegs); - OS_FIND_EXPORT(gx2_handle, GX2CalcColorBufferAuxInfo); - OS_FIND_EXPORT(gx2_handle, GX2CalcDepthBufferHiZInfo); - OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferHiZEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetupContextStateEx); - OS_FIND_EXPORT(gx2_handle, GX2SetColorBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetAttribBuffer); - OS_FIND_EXPORT(gx2_handle, GX2InitTextureRegs); - OS_FIND_EXPORT(gx2_handle, GX2InitSampler); - OS_FIND_EXPORT(gx2_handle, GX2CalcFetchShaderSizeEx); - OS_FIND_EXPORT(gx2_handle, GX2InitFetchShaderEx); - OS_FIND_EXPORT(gx2_handle, GX2SetFetchShader); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexUniformReg); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelUniformReg); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelTexture); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexTexture); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelSampler); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexSampler); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelShader); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexShader); - OS_FIND_EXPORT(gx2_handle, GX2InitSamplerZMFilter); - OS_FIND_EXPORT(gx2_handle, GX2SetColorControl); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthOnlyControl); - OS_FIND_EXPORT(gx2_handle, GX2SetBlendControl); - OS_FIND_EXPORT(gx2_handle, GX2CalcDRCSize); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCScale); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetPolygonControl); - OS_FIND_EXPORT(gx2_handle, GX2SetCullOnlyControl); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthStencilControl); - OS_FIND_EXPORT(gx2_handle, GX2SetStencilMask); - OS_FIND_EXPORT(gx2_handle, GX2SetLineWidth); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCGamma); - OS_FIND_EXPORT(gx2_handle, GX2SetTVGamma); - OS_FIND_EXPORT(gx2_handle, GX2GetSystemTVScanMode); - OS_FIND_EXPORT(gx2_handle, GX2GetSystemDRCScanMode); - OS_FIND_EXPORT(gx2_handle, GX2RSetAllocator); - OS_FIND_EXPORT(gx2_handle, GX2CopySurface); - OS_FIND_EXPORT(gx2_handle, GX2ClearBuffersEx); - OS_FIND_EXPORT(gx2_handle, GX2SetClearDepthStencil); -} diff --git a/src/dynamic_libs/gx2_functions.h b/src/dynamic_libs/gx2_functions.h deleted file mode 100644 index 0b06826..0000000 --- a/src/dynamic_libs/gx2_functions.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __GX2_FUNCTIONS_H_ -#define __GX2_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "gx2_types.h" - -extern unsigned int gx2_handle; - -void InitGX2FunctionPointers(void); -void InitAcquireGX2(void); - -extern void (* GX2Init)(u32 * init_attribs); -extern void (* GX2Shutdown)(void); -extern void (* GX2Flush)(void); -extern s32 (* GX2GetMainCoreId)(void) ; -extern s32 (* GX2DrawDone)(void); -extern void (* GX2ClearColor)(GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); -extern void (* GX2SetViewport)(f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); -extern void (* GX2SetScissor)(u32 x_orig, u32 y_orig, u32 wd, u32 ht); -extern void (* GX2SetContextState)(const GX2ContextState* state); -extern void (* GX2DrawEx)(s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); -extern void (* GX2DrawIndexedEx)(s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); -extern void (* GX2ClearDepthStencilEx)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); -extern void (* GX2SetClearDepthStencil)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value); -extern void (* GX2CopyColorBufferToScanBuffer)(const GX2ColorBuffer *colorBuffer, s32 scan_target); -extern void (* GX2SwapScanBuffers)(void); -extern void (* GX2SetTVEnable)(s32 enable); -extern void (* GX2SetSwapInterval)(u32 swap_interval); -extern u32 (* GX2GetSwapInterval)(void); -extern void (* GX2WaitForVsync)(void); -extern void (* GX2CalcTVSize)(s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); -extern void (* GX2Invalidate)(s32 invalidate_type, void * ptr, u32 buffer_size); -extern void (* GX2SetTVBuffer)(void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); -extern void (* GX2CalcSurfaceSizeAndAlignment)(GX2Surface *surface); -extern void (* GX2InitDepthBufferRegs)(GX2DepthBuffer *depthBuffer); -extern void (* GX2InitColorBufferRegs)(GX2ColorBuffer *colorBuffer); -extern void (* GX2CalcColorBufferAuxInfo)(GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); -extern void (* GX2CalcDepthBufferHiZInfo)(GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); -extern void (* GX2InitDepthBufferHiZEnable)(GX2DepthBuffer *depthBuffer, s32 hiZ_enable); -extern void (* GX2SetupContextStateEx)(GX2ContextState* state, s32 enable_profiling); -extern void (* GX2SetColorBuffer)(const GX2ColorBuffer *colorBuffer, s32 target); -extern void (* GX2SetDepthBuffer)(const GX2DepthBuffer *depthBuffer); -extern void (* GX2SetAttribBuffer)(u32 attr_index, u32 attr_size, u32 stride, const void* attr); -extern void (* GX2InitTextureRegs)(GX2Texture *texture); -extern void (* GX2InitSampler)(GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); -extern u32 (* GX2CalcFetchShaderSizeEx)(u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); -extern void (* GX2InitFetchShaderEx)(GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); -extern void (* GX2SetFetchShader)(const GX2FetchShader* fs); -extern void (* GX2SetVertexUniformReg)(u32 offset, u32 count, const void *values); -extern void (* GX2SetPixelUniformReg)(u32 offset, u32 count, const void *values); -extern void (* GX2SetPixelTexture)(const GX2Texture *texture, u32 texture_hw_location); -extern void (* GX2SetVertexTexture)(const GX2Texture *texture, u32 texture_hw_location); -extern void (* GX2SetPixelSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); -extern void (* GX2SetVertexSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); -extern void (* GX2SetPixelShader)(const GX2PixelShader* pixelShader); -extern void (* GX2SetVertexShader)(const GX2VertexShader* vertexShader); -extern void (* GX2InitSamplerZMFilter)(GX2Sampler *sampler, s32 z_filter, s32 mip_filter); -extern void (* GX2SetColorControl)(s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); -extern void (* GX2SetDepthOnlyControl)(s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); -extern void (* GX2SetBlendControl)(s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); -extern void (* GX2CalcDRCSize)(s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); -extern void (* GX2SetDRCBuffer)(void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); -extern void (* GX2SetDRCScale)(u32 width, u32 height); -extern void (* GX2SetDRCEnable)(s32 enable); -extern void (* GX2SetPolygonControl)(s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); -extern void (* GX2SetCullOnlyControl)(s32 front_face_mode, s32 cull_front, s32 cull_back); -extern void (* GX2SetDepthStencilControl)(s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, - s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, - s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); -extern void (* GX2SetStencilMask)(u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); -extern void (* GX2SetLineWidth)(f32 width); -extern void (* GX2SetTVGamma)(f32 val); -extern void (* GX2SetDRCGamma)(f32 val); -extern s32 (* GX2GetSystemTVScanMode)(void); -extern s32 (* GX2GetSystemDRCScanMode)(void); -extern void (* GX2RSetAllocator)(void * (*allocFunc)(u32, u32, u32), void (*freeFunc)(u32, void*)); -extern void (* GX2CopySurface)(GX2Surface * srcSurface,u32 srcMip,u32 srcSlice,GX2Surface * dstSurface,u32 dstMip,u32 dstSlice ); -extern void (* GX2ClearBuffersEx)(GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,f32 r, f32 g, f32 b, f32 a,f32 depthValue,u8 stencilValue,int clearFlags); - -static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) -{ - depthBuffer->surface.dimension = dimension; - depthBuffer->surface.width = width; - depthBuffer->surface.height = height; - depthBuffer->surface.depth = depth; - depthBuffer->surface.num_mips = 1; - depthBuffer->surface.format = format; - depthBuffer->surface.aa = aa; - depthBuffer->surface.use = ((format==GX2_SURFACE_FORMAT_D_D24_S8_UNORM) || (format==GX2_SURFACE_FORMAT_D_D24_S8_FLOAT)) ? GX2_SURFACE_USE_DEPTH_BUFFER : GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE; - depthBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; - depthBuffer->surface.swizzle = 0; - depthBuffer->view_mip = 0; - depthBuffer->view_first_slice = 0; - depthBuffer->view_slices_count = depth; - depthBuffer->clear_depth = 1.0f; - depthBuffer->clear_stencil = 0; - depthBuffer->hiZ_data = NULL; - depthBuffer->hiZ_size = 0; - GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface); - GX2InitDepthBufferRegs(depthBuffer); -} - -static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) -{ - colorBuffer->surface.dimension = dimension; - colorBuffer->surface.width = width; - colorBuffer->surface.height = height; - colorBuffer->surface.depth = depth; - colorBuffer->surface.num_mips = 1; - colorBuffer->surface.format = format; - colorBuffer->surface.aa = aa; - colorBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV; - colorBuffer->surface.image_size = 0; - colorBuffer->surface.image_data = NULL; - colorBuffer->surface.mip_size = 0; - colorBuffer->surface.mip_data = NULL; - colorBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; - colorBuffer->surface.swizzle = 0; - colorBuffer->surface.align = 0; - colorBuffer->surface.pitch = 0; - u32 i; - for(i = 0; i < 13; i++) - colorBuffer->surface.mip_offset[i] = 0; - colorBuffer->view_mip = 0; - colorBuffer->view_first_slice = 0; - colorBuffer->view_slices_count = depth; - colorBuffer->aux_data = NULL; - colorBuffer->aux_size = 0; - for(i = 0; i < 5; i++) - colorBuffer->regs[i] = 0; - - GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface); - GX2InitColorBufferRegs(colorBuffer); -} - -static inline void GX2InitAttribStream(GX2AttribStream* attr, u32 location, u32 buffer, u32 offset, s32 format) -{ - attr->location = location; - attr->buffer = buffer; - attr->offset = offset; - attr->format = format; - attr->index_type = 0; - attr->divisor = 0; - attr->destination_selector = attribute_dest_comp_selector[format & 0xff]; - attr->endian_swap = GX2_ENDIANSWAP_DEFAULT; -} - -static inline void GX2InitTexture(GX2Texture *tex, u32 width, u32 height, u32 depth, u32 num_mips, s32 format, s32 dimension, s32 tile) -{ - tex->surface.dimension = dimension; - tex->surface.width = width; - tex->surface.height = height; - tex->surface.depth = depth; - tex->surface.num_mips = num_mips; - tex->surface.format = format; - tex->surface.aa = GX2_AA_MODE_1X; - tex->surface.use = GX2_SURFACE_USE_TEXTURE; - tex->surface.image_size = 0; - tex->surface.image_data = NULL; - tex->surface.mip_size = 0; - tex->surface.mip_data = NULL; - tex->surface.tile = tile; - tex->surface.swizzle = 0; - tex->surface.align = 0; - tex->surface.pitch = 0; - u32 i; - for(i = 0; i < 13; i++) - tex->surface.mip_offset[i] = 0; - tex->view_first_mip = 0; - tex->view_mips_count = num_mips; - tex->view_first_slice = 0; - tex->view_slices_count = depth; - tex->component_selector = texture_comp_selector[format & 0x3f]; - for(i = 0; i < 5; i++) - tex->regs[i] = 0; - - GX2CalcSurfaceSizeAndAlignment(&tex->surface); - GX2InitTextureRegs(tex); -} - -#ifdef __cplusplus -} -#endif - -#endif // __GX2_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_types.h b/src/dynamic_libs/gx2_types.h deleted file mode 100644 index e292318..0000000 --- a/src/dynamic_libs/gx2_types.h +++ /dev/null @@ -1,699 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef _GX2_TYPES_H_ -#define _GX2_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -//!----------------------------------------------------------------------------------------------------------------------- -//! Constants -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMMAND_BUFFER_SIZE 0x400000 -#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000 -#define GX2_SHADER_ALIGNMENT 0x100 -#define GX2_CONTEXT_STATE_ALIGNMENT 0x100 -#define GX2_DISPLAY_LIST_ALIGNMENT 0x20 -#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40 -#define GX2_INDEX_BUFFER_ALIGNMENT 0x20 - -#define GX2_CONTEXT_STATE_SIZE 0xA100 - -#define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC - -//!----------------------------------------------------------------------------------------------------------------------- -//! Common -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FALSE 0 -#define GX2_TRUE 1 -#define GX2_DISABLE 0 -#define GX2_ENABLE 1 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2InitAttrib -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INIT_ATTRIB_NULL 0 -#define GX2_INIT_ATTRIB_CB_BASE 1 -#define GX2_INIT_ATTRIB_CB_SIZE 2 -#define GX2_INIT_ATTRIB_ARGC 7 -#define GX2_INIT_ATTRIB_ARGV 8 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 compare functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMPARE_NEVER 0 -#define GX2_COMPARE_LESS 1 -#define GX2_COMPARE_EQUAL 2 -#define GX2_COMPARE_LEQUAL 3 -#define GX2_COMPARE_GREATER 4 -#define GX2_COMPARE_NOTEQUAL 5 -#define GX2_COMPARE_GEQUAL 6 -#define GX2_COMPARE_ALWAYS 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 stencil functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_STENCIL_KEEP 0 -#define GX2_STENCIL_ZERO 1 -#define GX2_STENCIL_REPLACE 2 -#define GX2_STENCIL_INCR 3 -#define GX2_STENCIL_DECR 4 -#define GX2_STENCIL_INVERT 5 -#define GX2_STENCIL_INCR_WRAP 6 -#define GX2_STENCIL_DECR_WRAP 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 logic op functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_LOGIC_OP_CLEAR 0x00 -#define GX2_LOGIC_OP_NOR 0x11 -#define GX2_LOGIC_OP_INVAND 0x22 -#define GX2_LOGIC_OP_INVCOPY 0x33 -#define GX2_LOGIC_OP_REVAND 0x44 -#define GX2_LOGIC_OP_INV 0x55 -#define GX2_LOGIC_OP_XOR 0x66 -#define GX2_LOGIC_OP_NAND 0x77 -#define GX2_LOGIC_OP_AND 0x88 -#define GX2_LOGIC_OP_EQUIV 0x99 -#define GX2_LOGIC_OP_NOOP 0xAA -#define GX2_LOGIC_OP_INVOR 0xBB -#define GX2_LOGIC_OP_COPY 0xCC -#define GX2_LOGIC_OP_REVOR 0xDD -#define GX2_LOGIC_OP_OR 0xEE -#define GX2_LOGIC_OP_SET 0xFF - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 blend combination functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BLEND_COMBINE_ADD 0x00 -#define GX2_BLEND_COMBINE_SRC_MINUS_DST 0x01 -#define GX2_BLEND_COMBINE_MIN 0x02 -#define GX2_BLEND_COMBINE_MAX 0x03 -#define GX2_BLEND_COMBINE_DST_MINUS_SRC 0x04 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 blend functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BLEND_ZERO 0x00 -#define GX2_BLEND_ONE 0x01 -#define GX2_BLEND_SRC_ALPHA 0x04 -#define GX2_BLEND_ONE_MINUS_SRC_ALPHA 0x05 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 render targets -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_RENDER_TARGET_0 0 -#define GX2_RENDER_TARGET_1 1 -#define GX2_RENDER_TARGET_2 2 -#define GX2_RENDER_TARGET_3 3 -#define GX2_RENDER_TARGET_4 4 -#define GX2_RENDER_TARGET_5 5 -#define GX2_RENDER_TARGET_6 6 -#define GX2_RENDER_TARGET_7 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 cull modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FRONT_FACE_CCW 0 -#define GX2_FRONT_FACE_CW 1 -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 polygon modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_POLYGON_MODE_POINT 0 -#define GX2_POLYGON_MODE_LINE 1 -#define GX2_POLYGON_MODE_TRIANGLE 2 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 special states -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SPECIAL_STATE_CLEAR 0 -#define GX2_SPECIAL_STATE_CLEAR_HIZ 1 -#define GX2_SPECIAL_STATE_COPY 2 -#define GX2_SPECIAL_STATE_EXPAND_COLOR 3 -#define GX2_SPECIAL_STATE_EXPAND_DEPTH 4 -#define GX2_SPECIAL_STATE_CONVERT_DEPTH 5 -#define GX2_SPECIAL_STATE_CONVERT_AADEPTH 6 -#define GX2_SPECIAL_STATE_RESOLVE_COLOR 7 -#define GX2_SPECIAL_STATE_CLEAR_COLOR_AS_DEPTH 8 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 attribute formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_ATTRIB_FORMAT_8_UNORM 0x00000000 -#define GX2_ATTRIB_FORMAT_4_4_UNORM 0x00000001 -#define GX2_ATTRIB_FORMAT_16_UNORM 0x00000002 -#define GX2_ATTRIB_FORMAT_8_8_UNORM 0x00000004 -#define GX2_ATTRIB_FORMAT_16_16_UNORM 0x00000007 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UNORM 0x0000000A -#define GX2_ATTRIB_FORMAT_10_10_10_2_UNORM 0x0000000B -#define GX2_ATTRIB_FORMAT_16_16_16_16_UNORM 0x0000000E - -#define GX2_ATTRIB_FORMAT_8_UINT 0x00000100 -#define GX2_ATTRIB_FORMAT_16_UINT 0x00000102 -#define GX2_ATTRIB_FORMAT_8_8_UINT 0x00000104 -#define GX2_ATTRIB_FORMAT_32_UINT 0x00000105 -#define GX2_ATTRIB_FORMAT_16_16_UINT 0x00000107 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT 0x0000010A -#define GX2_ATTRIB_FORMAT_10_10_10_2_UINT 0x0000010B -#define GX2_ATTRIB_FORMAT_32_32_UINT 0x0000010C -#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT 0x0000010E -#define GX2_ATTRIB_FORMAT_32_32_32_UINT 0x00000110 -#define GX2_ATTRIB_FORMAT_32_32_32_32_UINT 0x00000112 - -#define GX2_ATTRIB_FORMAT_8_SNORM 0x00000200 -#define GX2_ATTRIB_FORMAT_16_SNORM 0x00000202 -#define GX2_ATTRIB_FORMAT_8_8_SNORM 0x00000204 -#define GX2_ATTRIB_FORMAT_16_16_SNORM 0x00000207 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SNORM 0x0000020A -#define GX2_ATTRIB_FORMAT_10_10_10_2_SNORM 0x0000020B -#define GX2_ATTRIB_FORMAT_16_16_16_16_SNORM 0x0000020E - -#define GX2_ATTRIB_FORMAT_8_SINT 0x00000300 -#define GX2_ATTRIB_FORMAT_16_SINT 0x00000303 -#define GX2_ATTRIB_FORMAT_8_8_SINT 0x00000304 -#define GX2_ATTRIB_FORMAT_32_SINT 0x00000305 -#define GX2_ATTRIB_FORMAT_16_16_SINT 0x00000307 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT 0x0000030A -#define GX2_ATTRIB_FORMAT_10_10_10_2_SINT 0x0000030B -#define GX2_ATTRIB_FORMAT_32_32_SINT 0x0000030C -#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT 0x0000030E -#define GX2_ATTRIB_FORMAT_32_32_32_SINT 0x00000310 -#define GX2_ATTRIB_FORMAT_32_32_32_32_SINT 0x00000312 - -#define GX2_ATTRIB_FORMAT_8_UINT_TO_FLOAT 0x00000800 -#define GX2_ATTRIB_FORMAT_16_UINT_TO_FLOAT 0x00000802 -#define GX2_ATTRIB_FORMAT_16_FLOAT 0x00000803 -#define GX2_ATTRIB_FORMAT_8_8_UINT_TO_FLOAT 0x00000804 -#define GX2_ATTRIB_FORMAT_32_FLOAT 0x00000806 -#define GX2_ATTRIB_FORMAT_16_16_UINT_TO_FLOAT 0x00000807 -#define GX2_ATTRIB_FORMAT_16_16_FLOAT 0x00000808 -#define GX2_ATTRIB_FORMAT_10_11_11_FLOAT 0x00000809 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT_TO_FLOAT 0x0000080A -#define GX2_ATTRIB_FORMAT_32_32_FLOAT 0x0000080D -#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT_TO_FLOAT 0x0000080E -#define GX2_ATTRIB_FORMAT_16_16_16_16_FLOAT 0x0000080F -#define GX2_ATTRIB_FORMAT_32_32_32_FLOAT 0x00000811 -#define GX2_ATTRIB_FORMAT_32_32_32_32_FLOAT 0x00000813 - -#define GX2_ATTRIB_FORMAT_8_SINT_TO_FLOAT 0x00000A00 -#define GX2_ATTRIB_FORMAT_16_SINT_TO_FLOAT 0x00000A02 -#define GX2_ATTRIB_FORMAT_8_8_SINT_TO_FLOAT 0x00000A04 -#define GX2_ATTRIB_FORMAT_16_16_SINT_TO_FLOAT 0x00000A07 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT_TO_FLOAT 0x00000A0A -#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT_TO_FLOAT 0x00000A0E - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 shader modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SHADER_MODE_UNIFORM_REGISTER 0 -#define GX2_SHADER_MODE_UNIFORM_BLOCK 1 -#define GX2_SHADER_MODE_GEOMETRY_SHADER 2 -#define GX2_SHADER_MODE_COMPUTE_SHADER 3 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 shader modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMP_SEL_NONE 0x04040405 -#define GX2_COMP_SEL_X001 0x00040405 -#define GX2_COMP_SEL_XY01 0x00010405 -#define GX2_COMP_SEL_XYZ1 0x00010205 -#define GX2_COMP_SEL_XYZW 0x00010203 -#define GX2_COMP_SEL_XXXX 0x00000000 -#define GX2_COMP_SEL_YYYY 0x01010101 -#define GX2_COMP_SEL_ZZZZ 0x02020202 -#define GX2_COMP_SEL_WWWW 0x03030303 -#define GX2_COMP_SEL_WZYX 0x03020100 -#define GX2_COMP_SEL_WXYZ 0x03000102 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 variable types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_VAR_TYPE_VOID 0 -#define GX2_VAR_TYPE_BOOL 1 -#define GX2_VAR_TYPE_INT 2 -#define GX2_VAR_TYPE_UINT 3 -#define GX2_VAR_TYPE_FLOAT 4 -#define GX2_VAR_TYPE_DOUBLE 5 -#define GX2_VAR_TYPE_VEC2 9 -#define GX2_VAR_TYPE_VEC3 10 -#define GX2_VAR_TYPE_VEC4 11 -#define GX2_VAR_TYPE_MAT2 21 -#define GX2_VAR_TYPE_MAT3 25 -#define GX2_VAR_TYPE_MAT4 29 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 sample types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SAMPLER_TYPE_2D 1 - - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 index formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INDEX_FORMAT_U16 4 -#define GX2_INDEX_FORMAT_U32 9 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 primitive types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_PRIMITIVE_POINTS 0x01 -#define GX2_PRIMITIVE_LINES 0x02 -#define GX2_PRIMITIVE_LINE_STRIP 0x03 -#define GX2_PRIMITIVE_TRIANGLES 0x04 -#define GX2_PRIMITIVE_TRIANGLE_FAN 0x05 -#define GX2_PRIMITIVE_TRIANGLE_STRIP 0x06 -#define GX2_PRIMITIVE_RECTS 0x11 -#define GX2_PRIMITIVE_QUADS 0x13 -#define GX2_PRIMITIVE_QUAD_STRIP 0x14 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 clear modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_CLEAR_DEPTH 0x01 -#define GX2_CLEAR_STENCIL 0x02 -#define GX2_CLEAR_BOTH (GX2_CLEAR_DEPTH | GX2_CLEAR_STENCIL) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_FORMAT_TC_R8_UNORM 0x00000001 -#define GX2_SURFACE_FORMAT_T_R4_G4_UNORM 0x00000002 -#define GX2_SURFACE_FORMAT_TCD_R16_UNORM 0x00000005 -#define GX2_SURFACE_FORMAT_TC_R8_G8_UNORM 0x00000007 -#define GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM 0x00000008 -#define GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM 0x0000000a -#define GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM 0x0000000b -#define GX2_SURFACE_FORMAT_TC_A1_B5_G5_R5_UNORM 0x0000000c -#define GX2_SURFACE_FORMAT_TC_R16_G16_UNORM 0x0000000f -#define GX2_SURFACE_FORMAT_D_D24_S8_UNORM 0x00000011 -#define GX2_SURFACE_FORMAT_T_R24_UNORM_X8 0x00000011 -#define GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM 0x00000019 -#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM 0x0000001a -#define GX2_SURFACE_FORMAT_TCS_A2_B10_G10_R10_UNORM 0x0000001b -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UNORM 0x0000001f -#define GX2_SURFACE_FORMAT_T_BC1_UNORM 0x00000031 -#define GX2_SURFACE_FORMAT_T_BC2_UNORM 0x00000032 -#define GX2_SURFACE_FORMAT_T_BC3_UNORM 0x00000033 -#define GX2_SURFACE_FORMAT_T_BC4_UNORM 0x00000034 -#define GX2_SURFACE_FORMAT_T_BC5_UNORM 0x00000035 -#define GX2_SURFACE_FORMAT_T_NV12_UNORM 0x00000081 - -#define GX2_SURFACE_FORMAT_TC_R8_UINT 0x00000101 -#define GX2_SURFACE_FORMAT_TC_R16_UINT 0x00000105 -#define GX2_SURFACE_FORMAT_TC_R8_G8_UINT 0x00000107 -#define GX2_SURFACE_FORMAT_TC_R32_UINT 0x0000010d -#define GX2_SURFACE_FORMAT_TC_R16_G16_UINT 0x0000010f -#define GX2_SURFACE_FORMAT_T_X24_G8_UINT 0x00000111 -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_UINT 0x00000119 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT 0x0000011a -#define GX2_SURFACE_FORMAT_TC_A2_B10_G10_R10_UINT 0x0000011b -#define GX2_SURFACE_FORMAT_T_X32_G8_UINT_X24 0x0000011c -#define GX2_SURFACE_FORMAT_TC_R32_G32_UINT 0x0000011d -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UINT 0x0000011f -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_UINT 0x00000122 - -#define GX2_SURFACE_FORMAT_TC_R8_SNORM 0x00000201 -#define GX2_SURFACE_FORMAT_TC_R16_SNORM 0x00000205 -#define GX2_SURFACE_FORMAT_TC_R8_G8_SNORM 0x00000207 -#define GX2_SURFACE_FORMAT_TC_R16_G16_SNORM 0x0000020f -#define GX2_SURFACE_FORMAT_T_R10_G10_B10_A2_SNORM 0x00000219 -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SNORM 0x00000219 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM 0x0000021a -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SNORM 0x0000021f -#define GX2_SURFACE_FORMAT_T_BC4_SNORM 0x00000234 -#define GX2_SURFACE_FORMAT_T_BC5_SNORM 0x00000235 - -#define GX2_SURFACE_FORMAT_TC_R8_SINT 0x00000301 -#define GX2_SURFACE_FORMAT_TC_R16_SINT 0x00000305 -#define GX2_SURFACE_FORMAT_TC_R8_G8_SINT 0x00000307 -#define GX2_SURFACE_FORMAT_TC_R32_SINT 0x0000030d -#define GX2_SURFACE_FORMAT_TC_R16_G16_SINT 0x0000030f -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SINT 0x00000319 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SINT 0x0000031a -#define GX2_SURFACE_FORMAT_TC_R32_G32_SINT 0x0000031d -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SINT 0x0000031f -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_SINT 0x00000322 - -#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB 0x0000041a -#define GX2_SURFACE_FORMAT_T_BC1_SRGB 0x00000431 -#define GX2_SURFACE_FORMAT_T_BC2_SRGB 0x00000432 -#define GX2_SURFACE_FORMAT_T_BC3_SRGB 0x00000433 - -#define GX2_SURFACE_FORMAT_TC_R16_FLOAT 0x00000806 -#define GX2_SURFACE_FORMAT_TCD_R32_FLOAT 0x0000080e -#define GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT 0x00000810 -#define GX2_SURFACE_FORMAT_D_D24_S8_FLOAT 0x00000811 -#define GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT 0x00000816 -#define GX2_SURFACE_FORMAT_D_D32_FLOAT_S8_UINT_X24 0x0000081c -#define GX2_SURFACE_FORMAT_T_R32_FLOAT_X8_X24 0x0000081c -#define GX2_SURFACE_FORMAT_TC_R32_G32_FLOAT 0x0000081e -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT 0x00000820 -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT 0x00000823 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 tile modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TILE_MODE_DEFAULT 0x00000000 -#define GX2_TILE_MODE_LINEAR_ALIGNED 0x00000001 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface use -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_USE_TEXTURE 0x00000001 -#define GX2_SURFACE_USE_COLOR_BUFFER 0x00000002 -#define GX2_SURFACE_USE_DEPTH_BUFFER 0x00000004 -#define GX2_SURFACE_USE_SCAN_BUFFER 0x00000008 -#define GX2_SURFACE_USE_FTV 0x80000000 -#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE) -#define GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE) -#define GX2_SURFACE_USE_COLOR_BUFFER_FTV (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_FTV) -#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV (GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE | GX2_SURFACE_USE_FTV) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface dim -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_DIM_1D 0x00000000 -#define GX2_SURFACE_DIM_2D 0x00000001 -#define GX2_SURFACE_DIM_3D 0x00000002 -#define GX2_SURFACE_DIM_CUBE 0x00000003 -#define GX2_SURFACE_DIM_1D_ARRAY 0x00000004 -#define GX2_SURFACE_DIM_2D_ARRAY 0x00000005 -#define GX2_SURFACE_DIM_2D_MSAA 0x00000006 -#define GX2_SURFACE_DIM_2D_MSAA_ARRAY 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 AA modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_AA_MODE_1X 0x00000000 -#define GX2_AA_MODE_2X 0x00000001 -#define GX2_AA_MODE_4X 0x00000002 -#define GX2_AA_MODE_8X 0x00000003 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 texture clamp -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TEX_CLAMP_WRAP 0x00000000 -#define GX2_TEX_CLAMP_MIRROR 0x00000001 -#define GX2_TEX_CLAMP_CLAMP 0x00000002 -#define GX2_TEX_CLAMP_MIRROR_ONCE 0x00000003 -#define GX2_TEX_CLAMP_CLAMP_HALF_BORDER 0x00000004 -#define GX2_TEX_CLAMP_MIRROR_ONCE_HALF_BORDER 0x00000005 -#define GX2_TEX_CLAMP_CLAMP_BORDER 0x00000006 -#define GX2_TEX_CLAMP_MIRROR_ONCE_BORDER 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 texture filter -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TEX_XY_FILTER_POINT 0x00000000 -#define GX2_TEX_XY_FILTER_BILINEAR 0x00000001 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 TV scan modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TV_SCAN_MODE_NONE 0x00000000 -#define GX2_TV_SCAN_MODE_576I 0x00000001 -#define GX2_TV_SCAN_MODE_480I 0x00000002 -#define GX2_TV_SCAN_MODE_480P 0x00000003 -#define GX2_TV_SCAN_MODE_720P 0x00000004 -#define GX2_TV_SCAN_MODE_1080I 0x00000006 -#define GX2_TV_SCAN_MODE_1080P 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 TV render modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TV_RENDER_480_NARROW 0x00000001 -#define GX2_TV_RENDER_480_WIDE 0x00000002 -#define GX2_TV_RENDER_720 0x00000003 -#define GX2_TV_RENDER_1080 0x00000005 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 DRC render modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_DRC_NONE 0x00000000 -#define GX2_DRC_SINGLE 0x00000001 -#define GX2_DRC_DOUBLE 0x00000002 -#define GX2_DRC_SINGLE_30HZ 0x00000004 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 buffering mode -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BUFFERING_SINGLE 0x00000001 -#define GX2_BUFFERING_DOUBLE 0x00000002 -#define GX2_BUFFERING_TRIPLE 0x00000003 -#define GX2_BUFFERING_QUAD -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 scan targets -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SCAN_TARGET_TV 0x00000001 -#define GX2_SCAN_TARGET_DRC_FIRST 0x00000004 -#define GX2_SCAN_TARGET_DRC_SECOND 0x00000008 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 invalidate types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INVALIDATE_ATTRIB_BUFFER 0x00000001 -#define GX2_INVALIDATE_TEXTURE 0x00000002 -#define GX2_INVALIDATE_UNIFORM_BLOCK 0x00000004 -#define GX2_INVALIDATE_SHADER 0x00000008 -#define GX2_INVALIDATE_COLOR_BUFFER 0x00000010 -#define GX2_INVALIDATE_DEPTH_BUFFER 0x00000020 -#define GX2_INVALIDATE_CPU 0x00000040 -#define GX2_INVALIDATE_CPU_ATTRIB_BUFFER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_ATTRIB_BUFFER) -#define GX2_INVALIDATE_CPU_TEXTURE (GX2_INVALIDATE_CPU | GX2_INVALIDATE_TEXTURE) -#define GX2_INVALIDATE_CPU_UNIFORM_BLOCK (GX2_INVALIDATE_CPU | GX2_INVALIDATE_UNIFORM_BLOCK) -#define GX2_INVALIDATE_CPU_SHADER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_SHADER) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 swap modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_ENDIANSWAP_DEFAULT 0x00000003 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 tessellation modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TESSELLATION_MODE_DISCRETE 0x00000000 -#define GX2_TESSELLATION_MODE_CONTINUOUS 0x00000001 -#define GX2_TESSELLATION_MODE_ADAPTIVE 0x00000002 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 fetch shader types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FETCH_SHADER_TESSELATION_NONE 0x00000000 -#define GX2_FETCH_SHADER_TESSELATION_LINES 0x00000001 -#define GX2_FETCH_SHADER_TESSELATION_TRIANGLES 0x00000002 -#define GX2_FETCH_SHADER_TESSELATION_QUADS 0x00000003 - - -typedef struct _GX2ContextState { - u8 data[GX2_CONTEXT_STATE_SIZE]; -} GX2ContextState; - -typedef struct _GX2Surface { - s32 dimension; - u32 width; - u32 height; - u32 depth; - u32 num_mips; - s32 format; - s32 aa; - s32 use; - u32 image_size; - void *image_data; - u32 mip_size; - void *mip_data; - s32 tile; - u32 swizzle; - u32 align; - u32 pitch; - u32 mip_offset[13]; -} GX2Surface; - -typedef struct _GX2ColorBuffer { - GX2Surface surface; - u32 view_mip; - u32 view_first_slice; - u32 view_slices_count; - void *aux_data; - u32 aux_size; - u32 regs[5]; -} GX2ColorBuffer; - -typedef struct _GX2DepthBuffer { - GX2Surface surface; - u32 view_mip; - u32 view_first_slice; - u32 view_slices_count; - void *hiZ_data; - u32 hiZ_size; - f32 clear_depth; - u32 clear_stencil; - u32 regs[7]; -} GX2DepthBuffer; - - -typedef struct _GX2Texture { - GX2Surface surface; - u32 view_first_mip; - u32 view_mips_count; - u32 view_first_slice; - u32 view_slices_count; - u32 component_selector; - u32 regs[5]; -} GX2Texture; - - -typedef struct _GX2Sampler { - u32 regs[3]; -} GX2Sampler; - -typedef struct _GX2AttribStream { - u32 location; - u32 buffer; - u32 offset; - s32 format; - s32 index_type; - u32 divisor; - u32 destination_selector; - s32 endian_swap; -} GX2AttribStream; - -typedef struct _GX2FetchShader { - s32 type; - u32 reg; - u32 shader_size; - void *shader_program; - u32 attributes_count; - u32 divisor[3]; -} GX2FetchShader; - -typedef struct _GX2AttribVar -{ - const char *name; - s32 var_type; - u32 array_count; - u32 location; -} GX2AttribVar; - - -typedef struct _GX2UniformBlock { - const char *name; - u32 location; - u32 block_size; -} GX2UniformBlock; - -typedef struct _GX2UniformInitialValue { - f32 value[4]; - u32 offset; -} GX2UniformInitialValue; - -typedef struct _GX2SamplerVar -{ - const char *name; - s32 sampler_type; - u32 location; -} GX2SamplerVar; - -typedef struct _GX2UniformVar -{ - const char *name; - s32 var_type; - u32 array_count; - u32 offset; - u32 block_index; -} GX2UniformVar; - -typedef struct _GX2VertexShader { - u32 regs[52]; - u32 shader_size; - void *shader_data; - s32 shader_mode; - u32 uniform_blocks_count; - GX2UniformBlock *uniform_block; - u32 uniform_vars_count; - GX2UniformVar *uniform_var; - u32 initial_values_count; - GX2UniformInitialValue *initial_value; - u32 loops_count; - void *loops_data; - u32 sampler_vars_count; - GX2SamplerVar *sampler_var; - u32 attribute_vars_count; - GX2AttribVar *attribute_var; - u32 data[6]; - u32 shader_program_buffer[16]; -} GX2VertexShader; - -typedef struct _GX2PixelShader { - u32 regs[41]; - u32 shader_size; - void *shader_data; - s32 shader_mode; - u32 uniform_blocks_count; - GX2UniformBlock *uniform_block; - u32 uniform_vars_count; - GX2UniformVar *uniform_var; - u32 initial_values_count; - GX2UniformInitialValue *initial_value; - u32 loops_count; - void *loops_data; - u32 sampler_vars_count; - GX2SamplerVar *sampler_var; - u32 shader_program_buffer[16]; -} GX2PixelShader; - -static const u32 attribute_dest_comp_selector[20] = { - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW -}; - -static const u32 texture_comp_selector[54] = { - GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01 -}; - -typedef struct _GX2Color { - u8 r, g, b, a; -} GX2Color; - -typedef struct _GX2ColorF32 { - f32 r, g, b, a; -} GX2ColorF32; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dynamic_libs/os_functions.c b/src/dynamic_libs/os_functions.c deleted file mode 100644 index a093cad..0000000 --- a/src/dynamic_libs/os_functions.c +++ /dev/null @@ -1,345 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "common/common.h" -#include "os_functions.h" - -unsigned int coreinit_handle __attribute__((section(".data"))) = 0; - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Lib handle functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, OSDynLoad_Acquire, const char* rpl, u32 *handle); -EXPORT_DECL(int, OSDynLoad_FindExport, u32 handle, int isdata, const char *symbol, void *address); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, OSGetSecurityLevel, void); -EXPORT_DECL(int, OSForceFullRelaunch, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Thread functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, OSCreateThread, void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); -EXPORT_DECL(int, OSResumeThread, void *thread); -EXPORT_DECL(int, OSSuspendThread, void *thread); -EXPORT_DECL(int, OSIsThreadTerminated, void *thread); -EXPORT_DECL(int, OSIsThreadSuspended, void *thread); -EXPORT_DECL(int, OSSetThreadPriority, void * thread, int priority); -EXPORT_DECL(int, OSJoinThread, void * thread, int * ret_val); -EXPORT_DECL(void, OSDetachThread, void * thread); -EXPORT_DECL(void*, OSGetCurrentThread, void); -EXPORT_DECL(int, OSGetThreadPriority, void * thread); -EXPORT_DECL(void, OSSleepTicks, u64 ticks); -EXPORT_DECL(u64, OSGetTick, void); -EXPORT_DECL(u64, OSGetTime, void); -EXPORT_DECL(void, OSTicksToCalendarTime, u64 time, OSCalendarTime * calendarTime); -EXPORT_DECL(int, OSGetCoreId, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Mutex functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, OSInitMutex, void* mutex); -EXPORT_DECL(void, OSLockMutex, void* mutex); -EXPORT_DECL(void, OSUnlockMutex, void* mutex); -EXPORT_DECL(int, OSTryLockMutex, void* mutex); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! System functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(u64, OSGetTitleID, void); -EXPORT_DECL(void, OSGetArgcArgv, int* argc, char*** argv); -EXPORT_DECL(void, __Exit, void); -EXPORT_DECL(void, OSFatal, const char* msg); -EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback); -EXPORT_DECL(void, DCFlushRange, const void *addr, u32 length); -EXPORT_DECL(void, DCStoreRange, const void *addr, u32 length); -EXPORT_DECL(void, ICInvalidateRange, const void *addr, u32 length); -EXPORT_DECL(void*, OSEffectiveToPhysical, const void*); -EXPORT_DECL(int, __os_snprintf, char* s, int n, const char * format, ...); -EXPORT_DECL(int *, __gh_errno_ptr, void); - -EXPORT_DECL(void, OSScreenInit, void); -EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx, unsigned int bufferNum); -EXPORT_DECL(int, OSScreenSetBufferEx, unsigned int bufferNum, void * addr); -EXPORT_DECL(int, OSScreenClearBufferEx, unsigned int bufferNum, unsigned int temp); -EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum); -EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); -EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Memory functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeapEx); -EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeap); -EXPORT_VAR(unsigned int *, pMEMFreeToDefaultHeap); - -EXPORT_DECL(int, MEMGetBaseHeapHandle, int mem_arena); -EXPORT_DECL(unsigned int, MEMGetAllocatableSizeForFrmHeapEx, int heap, int align); -EXPORT_DECL(void *, MEMAllocFromFrmHeapEx, int heap, unsigned int size, int align); -EXPORT_DECL(void, MEMFreeToFrmHeap, int heap, int mode); -EXPORT_DECL(void *, MEMAllocFromExpHeapEx, int heap, unsigned int size, int align); -EXPORT_DECL(int , MEMCreateExpHeapEx, void* address, unsigned int size, unsigned short flags); -EXPORT_DECL(void *, MEMDestroyExpHeap, int heap); -EXPORT_DECL(void, MEMFreeToExpHeap, int heap, void* ptr); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! MCP functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, MCP_Open, void); -EXPORT_DECL(int, MCP_Close, int handle); -EXPORT_DECL(int, MCP_GetOwnTitleInfo, int handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Loader functions (not real rpl) -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(int, LiWaitIopComplete, int unknown_syscall_arg_r3, int * remaining_bytes); -EXPORT_DECL(int, LiWaitIopCompleteWithInterrupts, int unknown_syscall_arg_r3, int * remaining_bytes); -EXPORT_DECL(void, addr_LiWaitOneChunk, void); -EXPORT_DECL(void, addr_sgIsLoadingBuffer, void); -EXPORT_DECL(void, addr_gDynloadInitialized, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Kernel function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, addr_PrepareTitle_hook, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, DCInvalidateRange, void *buffer, uint32_t length); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//Burn-in Reduction -EXPORT_DECL(int, IMEnableDim,void); -EXPORT_DECL(int, IMDisableDim,void); -EXPORT_DECL(int, IMIsDimEnabled,int * result); -//Auto power down -EXPORT_DECL(int, IMEnableAPD,void); -EXPORT_DECL(int, IMDisableAPD,void); -EXPORT_DECL(int, IMIsAPDEnabled,int * result); -EXPORT_DECL(int, IMIsAPDEnabledBySysSettings,int * result); - - -EXPORT_DECL(int, IOS_Ioctl,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); -EXPORT_DECL(int, IOS_IoctlAsync,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len, void *cb, void *cbarg); -EXPORT_DECL(int, IOS_Open,char *path, unsigned int mode); -EXPORT_DECL(int, IOS_Close,int fd); -void InitAcquireOS(void) -{ - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Lib handle functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - EXPORT_FUNC_WRITE(OSDynLoad_Acquire, (int (*)(const char*, unsigned *))OS_SPECIFICS->addr_OSDynLoad_Acquire); - EXPORT_FUNC_WRITE(OSDynLoad_FindExport, (int (*)(u32, int, const char *, void *))OS_SPECIFICS->addr_OSDynLoad_FindExport); - - OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); -} - -void InitOSFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - InitAcquireOS(); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Security functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSGetSecurityLevel); - OS_FIND_EXPORT(coreinit_handle, OSForceFullRelaunch); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! System functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSFatal); - OS_FIND_EXPORT(coreinit_handle, OSGetTitleID); - OS_FIND_EXPORT(coreinit_handle, OSGetArgcArgv); - OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback); - OS_FIND_EXPORT(coreinit_handle, DCFlushRange); - OS_FIND_EXPORT(coreinit_handle, DCStoreRange); - OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange); - OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical); - OS_FIND_EXPORT(coreinit_handle, __os_snprintf); - OS_FIND_EXPORT(coreinit_handle, __gh_errno_ptr); - - OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); - - OS_FIND_EXPORT(coreinit_handle, OSScreenInit); - OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Thread functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSCreateThread); - OS_FIND_EXPORT(coreinit_handle, OSResumeThread); - OS_FIND_EXPORT(coreinit_handle, OSSuspendThread); - OS_FIND_EXPORT(coreinit_handle, OSIsThreadTerminated); - OS_FIND_EXPORT(coreinit_handle, OSIsThreadSuspended); - OS_FIND_EXPORT(coreinit_handle, OSJoinThread); - OS_FIND_EXPORT(coreinit_handle, OSSetThreadPriority); - OS_FIND_EXPORT(coreinit_handle, OSDetachThread); - OS_FIND_EXPORT(coreinit_handle, OSGetThreadPriority); - OS_FIND_EXPORT(coreinit_handle, OSGetCurrentThread); - OS_FIND_EXPORT(coreinit_handle, OSSleepTicks); - OS_FIND_EXPORT(coreinit_handle, OSGetTick); - OS_FIND_EXPORT(coreinit_handle, OSGetTime); - OS_FIND_EXPORT(coreinit_handle, OSTicksToCalendarTime); - OS_FIND_EXPORT(coreinit_handle, OSGetCoreId); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Mutex functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSInitMutex); - OS_FIND_EXPORT(coreinit_handle, OSLockMutex); - OS_FIND_EXPORT(coreinit_handle, OSUnlockMutex); - OS_FIND_EXPORT(coreinit_handle, OSTryLockMutex); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! MCP functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, MCP_Open); - OS_FIND_EXPORT(coreinit_handle, MCP_Close); - OS_FIND_EXPORT(coreinit_handle, MCP_GetOwnTitleInfo); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Memory functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx); - OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeap", &pMEMAllocFromDefaultHeap); - OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap); - - OS_FIND_EXPORT(coreinit_handle, MEMGetBaseHeapHandle); - OS_FIND_EXPORT(coreinit_handle, MEMGetAllocatableSizeForFrmHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMAllocFromFrmHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMFreeToFrmHeap); - OS_FIND_EXPORT(coreinit_handle, MEMAllocFromExpHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap); - OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Other function addresses - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, DCInvalidateRange); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Energy Saver functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //Burn-in Reduction - OS_FIND_EXPORT(coreinit_handle, IMEnableDim); - OS_FIND_EXPORT(coreinit_handle, IMDisableDim); - OS_FIND_EXPORT(coreinit_handle, IMIsDimEnabled); - //Auto power down - OS_FIND_EXPORT(coreinit_handle, IMEnableAPD); - OS_FIND_EXPORT(coreinit_handle, IMDisableAPD); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabled); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabledBySysSettings); - - OS_FIND_EXPORT(coreinit_handle, IOS_Ioctl); - OS_FIND_EXPORT(coreinit_handle, IOS_IoctlAsync); - OS_FIND_EXPORT(coreinit_handle, IOS_Open); - OS_FIND_EXPORT(coreinit_handle, IOS_Close); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Special non library functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - if(OS_FIRMWARE == 532 || OS_FIRMWARE == 540) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100FFA4); // loader.elf - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100FE90); // loader.elf - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007EC); // loader.elf - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF18558); // kernel.elf - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19D00); // loader.elf - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE13C3C); // loader.elf - } - else if(OS_FIRMWARE == 500 || OS_FIRMWARE == 510) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100FBC4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100FAB0); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007EC); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF18534); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19D00); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE13C3C); - } - else if(OS_FIRMWARE == 410) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100F78C); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100F678); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007F8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF166DC); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19CC0); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE13BFC); - } - else if(OS_FIRMWARE == 400) //same for 402 and 403 - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100F78C); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100F678); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007F8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF15E70); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19CC0); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE13BFC); - } - else if(OS_FIRMWARE == 550) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x01010180); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0101006C); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x0100080C); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF184E4); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19E80); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE13DBC); - } - else if(OS_FIRMWARE == 310) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100C4E4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100C3D4); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010004D8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF15A0C); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19340); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE1329C); - } - else if(OS_FIRMWARE == 300) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100C4E4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100C3D4); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010004D8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF15974); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (int (*)(int, int *))0xEFE19340); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (int (*)(int, int *))0xEFE1329C); - } - else - { - OSFatal("Missing all OS specific addresses."); - } -} diff --git a/src/dynamic_libs/os_functions.h b/src/dynamic_libs/os_functions.h deleted file mode 100644 index c30b36c..0000000 --- a/src/dynamic_libs/os_functions.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __OS_FUNCTIONS_H_ -#define __OS_FUNCTIONS_H_ - -#include -#include "common/os_defs.h" -#include "os_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define BUS_SPEED 248625000 -#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4)) -#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000) -#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000) - -#define usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs)) -#define sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs)) - -#define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31))) -#define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31))) - -#define EXPORT_DECL(res, func, ...) res (* func)(__VA_ARGS__) __attribute__((section(".data"))) = 0; -#define EXPORT_VAR(type, var) type var __attribute__((section(".data"))); - - -#define EXPORT_FUNC_WRITE(func, val) *(u32*)(((u32)&func) + 0) = (u32)val - -#define OS_FIND_EXPORT(handle, func) funcPointer = 0; \ - OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \ - if(!funcPointer) \ - OSFatal("Function " # func " is NULL"); \ - EXPORT_FUNC_WRITE(func, funcPointer); - -#define OS_FIND_EXPORT_EX(handle, func, func_p) \ - funcPointer = 0; \ - OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \ - if(!funcPointer) \ - OSFatal("Function " # func " is NULL"); \ - EXPORT_FUNC_WRITE(func_p, funcPointer); - -#define OS_MUTEX_SIZE 44 - -/* Handle for coreinit */ -extern unsigned int coreinit_handle; -void InitOSFunctionPointers(void); -void InitAcquireOS(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Lib handle functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* OSDynLoad_Acquire)(const char* rpl, u32 *handle); -extern int (* OSDynLoad_FindExport)(u32 handle, int isdata, const char *symbol, void *address); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* OSGetSecurityLevel)(void); -extern int (* OSForceFullRelaunch)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Thread functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* OSCreateThread)(void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); -extern int (* OSResumeThread)(void *thread); -extern int (* OSSuspendThread)(void *thread); -extern int (* OSIsThreadTerminated)(void *thread); -extern int (* OSIsThreadSuspended)(void *thread); -extern int (* OSJoinThread)(void * thread, int * ret_val); -extern int (* OSSetThreadPriority)(void * thread, int priority); -extern void (* OSDetachThread)(void * thread); -extern void* (* OSGetCurrentThread)(void); -extern int (* OSGetThreadPriority)(void * thread); -extern void (* OSSleepTicks)(u64 ticks); -extern u64 (* OSGetTick)(void); -extern u64 (* OSGetTime)(void); -extern void (*OSTicksToCalendarTime)(u64 time, OSCalendarTime *calendarTime); -extern int (* OSGetCoreId)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Mutex functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (* OSInitMutex)(void* mutex); -extern void (* OSLockMutex)(void* mutex); -extern void (* OSUnlockMutex)(void* mutex); -extern int (* OSTryLockMutex)(void* mutex); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! System functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern u64 (* OSGetTitleID)(void); -extern void (* OSGetArgcArgv)(int* argc, char*** argv); -extern void (* __Exit)(void); -extern void (* OSFatal)(const char* msg); -extern void (* DCFlushRange)(const void *addr, u32 length); -extern void (* DCStoreRange)(const void *addr, u32 length); -extern void (* ICInvalidateRange)(const void *addr, u32 length); -extern void* (* OSEffectiveToPhysical)(const void*); -extern int (* __os_snprintf)(char* s, int n, const char * format, ...); -extern int * (* __gh_errno_ptr)(void); - -extern void (*OSScreenInit)(void); -extern unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum); -extern int (*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); -extern int (*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp); -extern int (*OSScreenFlipBuffersEx)(unsigned int bufferNum); -extern int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); -extern int (*OSScreenEnableEx)(unsigned int bufferNum, int enable); - -typedef unsigned char (*exception_callback)(void * interruptedContext); -extern void (* OSSetExceptionCallback)(u8 exceptionType, exception_callback newCallback); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! MCP functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* MCP_Open)(void); -extern int (* MCP_Close)(int handle); -extern int (* MCP_GetOwnTitleInfo)(int handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! LOADER functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (* LiWaitIopComplete)(int unknown_syscall_arg_r3, int * remaining_bytes); -extern int (* LiWaitIopCompleteWithInterrupts)(int unknown_syscall_arg_r3, int * remaining_bytes); -extern void (* addr_LiWaitOneChunk)(void); -extern void (* addr_sgIsLoadingBuffer)(void); -extern void (* addr_gDynloadInitialized)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Kernel function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (* addr_PrepareTitle_hook)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (*DCInvalidateRange)(void *buffer, uint32_t length); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -////Burn-in Reduction -extern int (*IMEnableDim)(void); -extern int (*IMDisableDim)(void); -extern int (*IMIsDimEnabled)(int * result); -//Auto power down -extern int (*IMEnableAPD)(void); -extern int (*IMDisableAPD)(void); -extern int (*IMIsAPDEnabled)(int * result); -extern int (*IMIsAPDEnabledBySysSettings)(int * result); - -extern int (*IOS_Ioctl)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); -extern int (*IOS_IoctlAsync)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len, void *cb, void *cbarg); -extern int (*IOS_Open)(char *path, unsigned int mode); -extern int (*IOS_Close)(int fd); -#ifdef __cplusplus -} -#endif - -#endif // __OS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/os_types.h b/src/dynamic_libs/os_types.h deleted file mode 100644 index aaa18fe..0000000 --- a/src/dynamic_libs/os_types.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _OS_TYPES_H_ -#define _OS_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef struct _OSCalendarTime { - int sec; - int min; - int hour; - int mday; - int mon; - int year; - int wday; - int yday; - int msec; - int usec; -} OSCalendarTime; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dynamic_libs/padscore_functions.c b/src/dynamic_libs/padscore_functions.c deleted file mode 100644 index f7ca8e9..0000000 --- a/src/dynamic_libs/padscore_functions.c +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "padscore_functions.h" - -unsigned int padscore_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, KPADInit, void); -EXPORT_DECL(void, WPADInit, void); -EXPORT_DECL(s32, WPADProbe, s32 chan, u32 * pad_type); -EXPORT_DECL(s32, WPADSetDataFormat, s32 chan, s32 format); -EXPORT_DECL(void, WPADEnableURCC, s32 enable); -EXPORT_DECL(void, WPADRead, s32 chan, void * data); -EXPORT_DECL(s32, KPADRead, s32 chan, void * data, u32 size); -EXPORT_DECL(void,WPADSetAutoSleepTime,u8 minute); -EXPORT_DECL(void,WPADDisconnect,s32 chan); - -void InitAcquirePadScore(void) -{ - OSDynLoad_Acquire("padscore.rpl", &padscore_handle); -} - -void InitPadScoreFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - InitAcquirePadScore(); - - OS_FIND_EXPORT(padscore_handle, WPADInit); - OS_FIND_EXPORT(padscore_handle, KPADInit); - OS_FIND_EXPORT(padscore_handle, WPADProbe); - OS_FIND_EXPORT(padscore_handle, WPADSetDataFormat); - OS_FIND_EXPORT(padscore_handle, WPADEnableURCC); - OS_FIND_EXPORT(padscore_handle, WPADRead); - OS_FIND_EXPORT(padscore_handle, KPADRead); - OS_FIND_EXPORT(padscore_handle, WPADSetAutoSleepTime); - OS_FIND_EXPORT(padscore_handle, WPADDisconnect); - - KPADInit(); - WPADEnableURCC(1); -} diff --git a/src/dynamic_libs/padscore_functions.h b/src/dynamic_libs/padscore_functions.h deleted file mode 100644 index 5b000b1..0000000 --- a/src/dynamic_libs/padscore_functions.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __PAD_SCORE_FUNCTIONS_H_ -#define __PAD_SCORE_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dynamic_libs/vpad_functions.h" - -extern unsigned int padscore_handle; - -#include - -#define WPAD_BUTTON_LEFT 0x0001 -#define WPAD_BUTTON_RIGHT 0x0002 -#define WPAD_BUTTON_DOWN 0x0004 -#define WPAD_BUTTON_UP 0x0008 -#define WPAD_BUTTON_PLUS 0x0010 -#define WPAD_BUTTON_2 0x0100 -#define WPAD_BUTTON_1 0x0200 -#define WPAD_BUTTON_B 0x0400 -#define WPAD_BUTTON_A 0x0800 -#define WPAD_BUTTON_MINUS 0x1000 -#define WPAD_BUTTON_Z 0x2000 -#define WPAD_BUTTON_C 0x4000 -#define WPAD_BUTTON_HOME 0x8000 - -#define WPAD_CLASSIC_BUTTON_UP 0x0001 -#define WPAD_CLASSIC_BUTTON_LEFT 0x0002 -#define WPAD_CLASSIC_BUTTON_ZR 0x0004 -#define WPAD_CLASSIC_BUTTON_X 0x0008 -#define WPAD_CLASSIC_BUTTON_A 0x0010 -#define WPAD_CLASSIC_BUTTON_Y 0x0020 -#define WPAD_CLASSIC_BUTTON_B 0x0040 -#define WPAD_CLASSIC_BUTTON_ZL 0x0080 -#define WPAD_CLASSIC_BUTTON_R 0x0200 -#define WPAD_CLASSIC_BUTTON_PLUS 0x0400 -#define WPAD_CLASSIC_BUTTON_HOME 0x0800 -#define WPAD_CLASSIC_BUTTON_MINUS 0x1000 -#define WPAD_CLASSIC_BUTTON_L 0x2000 -#define WPAD_CLASSIC_BUTTON_DOWN 0x4000 -#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000 - -#define WPAD_PRO_BUTTON_UP 0x00000001 -#define WPAD_PRO_BUTTON_LEFT 0x00000002 -#define WPAD_PRO_TRIGGER_ZR 0x00000004 -#define WPAD_PRO_BUTTON_X 0x00000008 -#define WPAD_PRO_BUTTON_A 0x00000010 -#define WPAD_PRO_BUTTON_Y 0x00000020 -#define WPAD_PRO_BUTTON_B 0x00000040 -#define WPAD_PRO_TRIGGER_ZL 0x00000080 -#define WPAD_PRO_RESERVED 0x00000100 -#define WPAD_PRO_TRIGGER_R 0x00000200 -#define WPAD_PRO_BUTTON_PLUS 0x00000400 -#define WPAD_PRO_BUTTON_HOME 0x00000800 -#define WPAD_PRO_BUTTON_MINUS 0x00001000 -#define WPAD_PRO_TRIGGER_L 0x00002000 -#define WPAD_PRO_BUTTON_DOWN 0x00004000 -#define WPAD_PRO_BUTTON_RIGHT 0x00008000 -#define WPAD_PRO_BUTTON_STICK_R 0x00010000 -#define WPAD_PRO_BUTTON_STICK_L 0x00020000 - -#define WPAD_PRO_STICK_L_EMULATION_UP 0x00200000 -#define WPAD_PRO_STICK_L_EMULATION_DOWN 0x00100000 -#define WPAD_PRO_STICK_L_EMULATION_LEFT 0x00040000 -#define WPAD_PRO_STICK_L_EMULATION_RIGHT 0x00080000 - -#define WPAD_PRO_STICK_R_EMULATION_UP 0x02000000 -#define WPAD_PRO_STICK_R_EMULATION_DOWN 0x01000000 -#define WPAD_PRO_STICK_R_EMULATION_LEFT 0x00400000 -#define WPAD_PRO_STICK_R_EMULATION_RIGHT 0x00800000 - -typedef struct _KPADData -{ - u32 btns_h; - u32 btns_d; - u32 btns_r; - u32 unused_1[5]; - f32 pos_x; - f32 pos_y; - u32 unused_2[3]; - f32 angle_x; - f32 angle_y; - u32 unused_3[8]; - u8 device_type; - u8 wpad_error; - u8 pos_valid; - u8 format; - - union - { - struct - { - f32 stick_x; - f32 stick_y; - } nunchuck; - - struct - { - u32 btns_h; - u32 btns_d; - u32 btns_r; - f32 lstick_x; - f32 lstick_y; - f32 rstick_x; - f32 rstick_y; - f32 ltrigger; - f32 rtrigger; - } classic; - - struct - { - u32 btns_h; - u32 btns_d; - u32 btns_r; - f32 lstick_x; - f32 lstick_y; - f32 rstick_x; - f32 rstick_y; - int charging; - int wired; - } pro; - - u32 unused_6[20]; - }; - u32 unused_7[16]; -} KPADData; -void InitPadScoreFunctionPointers(void); -void InitAcquirePadScore(void); - -typedef void (* wpad_connect_callback_t)(s32 chan, s32 status); - -extern void (* KPADInit)(void); -extern void (* WPADInit)(void); -extern s32 (* WPADProbe)(s32 chan, u32 * pad_type); -extern s32 (* WPADSetDataFormat)(s32 chan, s32 format); -extern void (* WPADEnableURCC)(s32 enable); -extern void (* WPADRead)(s32 chan, void * data); -extern s32 (* KPADRead)(s32 chan, void * data, u32 size); -extern s32 (* KPADReadEx)(s32 chan, KPADData * data, u32 size, s32 *error); -extern void (*WPADSetAutoSleepTime)(u8 time); -extern void (*WPADDisconnect)( s32 chan ); - -#ifdef __cplusplus -} -#endif - -#endif // __PAD_SCORE_FUNCTIONS_H_ diff --git a/src/dynamic_libs/socket_functions.c b/src/dynamic_libs/socket_functions.c deleted file mode 100644 index de2c31f..0000000 --- a/src/dynamic_libs/socket_functions.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "socket_functions.h" - -u32 hostIpAddress = 0; - -unsigned int nsysnet_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, socket_lib_init, void); -EXPORT_DECL(int, socket, int domain, int type, int protocol); -EXPORT_DECL(int, socketclose, int s); -EXPORT_DECL(int, connect, int s, void *addr, int addrlen); -EXPORT_DECL(int, bind, s32 s,struct sockaddr *name,s32 namelen); -EXPORT_DECL(int, listen, s32 s,u32 backlog); -EXPORT_DECL(int, accept, s32 s,struct sockaddr *addr,s32 *addrlen); -EXPORT_DECL(int, send, int s, const void *buffer, int size, int flags); -EXPORT_DECL(int, recv, int s, void *buffer, int size, int flags); -EXPORT_DECL(int, recvfrom,int sockfd, void *buf, int len, int flags,struct sockaddr *src_addr, int *addrlen); -EXPORT_DECL(int, sendto, int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len); -EXPORT_DECL(int, setsockopt, int s, int level, int optname, void *optval, int optlen); -EXPORT_DECL(char *, inet_ntoa, struct in_addr in); -EXPORT_DECL(int, inet_aton, const char *cp, struct in_addr *inp); - -EXPORT_DECL(int, NSSLWrite, int connection, const void* buf, int len,int * written); -EXPORT_DECL(int, NSSLRead, int connection, const void* buf, int len,int * read); -EXPORT_DECL(int, NSSLCreateConnection, int context, const char* host, int hotlen,int options,int sock,int block); - -void InitAcquireSocket(void) -{ - OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); -} - -void InitSocketFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - InitAcquireSocket(); - - OS_FIND_EXPORT(nsysnet_handle, socket_lib_init); - OS_FIND_EXPORT(nsysnet_handle, socket); - OS_FIND_EXPORT(nsysnet_handle, socketclose); - OS_FIND_EXPORT(nsysnet_handle, connect); - OS_FIND_EXPORT(nsysnet_handle, bind); - OS_FIND_EXPORT(nsysnet_handle, listen); - OS_FIND_EXPORT(nsysnet_handle, accept); - OS_FIND_EXPORT(nsysnet_handle, send); - OS_FIND_EXPORT(nsysnet_handle, recv); - OS_FIND_EXPORT(nsysnet_handle, recvfrom); - OS_FIND_EXPORT(nsysnet_handle, sendto); - OS_FIND_EXPORT(nsysnet_handle, setsockopt); - OS_FIND_EXPORT(nsysnet_handle, inet_ntoa); - OS_FIND_EXPORT(nsysnet_handle, inet_aton); - - OS_FIND_EXPORT(nsysnet_handle, NSSLWrite); - OS_FIND_EXPORT(nsysnet_handle, NSSLRead); - OS_FIND_EXPORT(nsysnet_handle, NSSLCreateConnection); - - socket_lib_init(); -} diff --git a/src/dynamic_libs/socket_functions.h b/src/dynamic_libs/socket_functions.h deleted file mode 100644 index 1e4df1a..0000000 --- a/src/dynamic_libs/socket_functions.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SOCKET_FUNCTIONS_H_ -#define __SOCKET_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int nsysnet_handle; - -#include - -#define INADDR_ANY 0 - -#define AF_INET 2 - -#define SOCK_STREAM 1 -#define SOCK_DGRAM 2 - -#define IPPROTO_IP 0 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 - -#define TCP_NODELAY 0x2004 - -#define SOL_SOCKET -1 -#define SO_REUSEADDR 0x0004 -#define SO_NONBLOCK 0x1016 -#define SO_MYADDR 0x1013 -#define SO_RCVTIMEO 0x1006 - -#define SOL_SOCKET -1 -#define MSG_DONTWAIT 32 - -#define htonl(x) x -#define htons(x) x -#define ntohl(x) x -#define ntohs(x) x - - -struct in_addr { - unsigned int s_addr; -}; -struct sockaddr_in { - short sin_family; - unsigned short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -struct sockaddr -{ - unsigned short sa_family; - char sa_data[14]; -}; - - -void InitSocketFunctionPointers(void); -void InitAcquireSocket(void); - -extern void (*socket_lib_init)(void); -extern int (*socket)(int domain, int type, int protocol); -extern int (*socketclose)(int s); -extern int (*connect)(int s, void *addr, int addrlen); -extern int (*bind)(s32 s,struct sockaddr *name,s32 namelen); -extern int (*listen)(s32 s,u32 backlog); -extern int (*accept)(s32 s,struct sockaddr *addr,s32 *addrlen); -extern int (*send)(int s, const void *buffer, int size, int flags); -extern int (*recv)(int s, void *buffer, int size, int flags); -extern int (*recvfrom)(int sockfd, void *buf, int len, int flags,struct sockaddr *src_addr, int *addrlen); - -extern int (*sendto)(int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len); -extern int (*setsockopt)(int s, int level, int optname, void *optval, int optlen); - -extern int (* NSSLWrite)(int connection, const void* buf, int len,int * written); -extern int (* NSSLRead)(int connection, const void* buf, int len,int * read); -extern int (* NSSLCreateConnection)(int context, const char* host, int hotlen,int options,int sock,int block); - -extern char * (*inet_ntoa)(struct in_addr in); -extern int (*inet_aton)(const char *cp, struct in_addr *inp); - -#ifdef __cplusplus -} -#endif - -#endif // __SOCKET_FUNCTIONS_H_ diff --git a/src/dynamic_libs/sys_functions.c b/src/dynamic_libs/sys_functions.c deleted file mode 100644 index 2cd44b8..0000000 --- a/src/dynamic_libs/sys_functions.c +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" - - unsigned int sysapp_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(int, _SYSLaunchTitleByPathFromLauncher, const char* path, int len, int zero); -EXPORT_DECL(int, SYSRelaunchTitle, int argc, char** argv); -EXPORT_DECL(int, SYSLaunchMenu, void); -EXPORT_DECL(int, SYSCheckTitleExists, u64 titleId); -EXPORT_DECL(int, SYSLaunchTitle, u64 titleId); -EXPORT_DECL(int, SYSLaunchSettings, int unk); - -void InitAcquireSys(void) -{ - OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle); -} - -void InitSysFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - InitAcquireSys(); - - OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher); - OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu); - OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchTitle); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchSettings); -} diff --git a/src/dynamic_libs/sys_functions.h b/src/dynamic_libs/sys_functions.h deleted file mode 100644 index 64fc2c7..0000000 --- a/src/dynamic_libs/sys_functions.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SYS_FUNCTIONS_H_ -#define __SYS_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int sysapp_handle; - -void InitSysFunctionPointers(void); -void InitAcquireSys(void); - -extern int(*_SYSLaunchTitleByPathFromLauncher)(const char* path, int len, int zero); -extern int (* SYSRelaunchTitle)(int argc, char** argv); -extern int (* SYSLaunchMenu)(void); -extern int (* SYSCheckTitleExists)(u64 titleId); -extern int (* SYSLaunchTitle)(u64 titleId); -extern int (* SYSLaunchSettings)(int unk); - - -#ifdef __cplusplus -} -#endif - -#endif // __SYS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/syshid_functions.c b/src/dynamic_libs/syshid_functions.c deleted file mode 100644 index 996d39d..0000000 --- a/src/dynamic_libs/syshid_functions.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "syshid_functions.h" - -unsigned int syshid_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(int, HIDSetup,void); -EXPORT_DECL(int, HIDTeardown,void); - -EXPORT_DECL(int, HIDAddClient,HIDClient *p_client, HIDAttachCallback attach_callback); -EXPORT_DECL(int, HIDDelClient,HIDClient *p_client); - -EXPORT_DECL(int, HIDGetDescriptor,unsigned int handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(int, HIDSetDescriptor,unsigned int handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); - -EXPORT_DECL(int, HIDSetProtocol,unsigned int handle,u8 interface_index,u8 protocol, HIDCallback hc, void *p_user); -EXPORT_DECL(int, HIDGetProtocol,unsigned int handle,u8 interface_index,u8 * protocol, HIDCallback hc, void *p_user); - -EXPORT_DECL(int, HIDGetReport,u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(int, HIDSetReport,u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -EXPORT_DECL(int, HIDSetIdle,unsigned int handle, u8 interface_index,u8 duration, HIDCallback hc, void *p_user); - -EXPORT_DECL(int, HIDRead,unsigned int handle, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(int, HIDWrite,unsigned int handle, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); - -void InitAcquireSysHID(void) -{ - OSDynLoad_Acquire("nsyshid.rpl", &syshid_handle); -} - -void InitSysHIDFunctionPointers(void) -{ - InitAcquireSysHID(); - - if(syshid_handle == 0){ - return; - } - - unsigned int funcPointer = 0; - - //! assigning those is not mandatory and it does not always work to load them - OS_FIND_EXPORT(syshid_handle, HIDSetup); - OS_FIND_EXPORT(syshid_handle, HIDTeardown); - OS_FIND_EXPORT(syshid_handle, HIDAddClient); - OS_FIND_EXPORT(syshid_handle, HIDDelClient); - OS_FIND_EXPORT(syshid_handle, HIDGetDescriptor); - OS_FIND_EXPORT(syshid_handle, HIDSetDescriptor); - OS_FIND_EXPORT(syshid_handle, HIDRead); - OS_FIND_EXPORT(syshid_handle, HIDWrite); - OS_FIND_EXPORT(syshid_handle, HIDSetProtocol); - OS_FIND_EXPORT(syshid_handle, HIDGetProtocol); - OS_FIND_EXPORT(syshid_handle, HIDSetIdle); - OS_FIND_EXPORT(syshid_handle, HIDGetReport); - OS_FIND_EXPORT(syshid_handle, HIDSetReport); -} diff --git a/src/dynamic_libs/syshid_functions.h b/src/dynamic_libs/syshid_functions.h deleted file mode 100644 index 08213b4..0000000 --- a/src/dynamic_libs/syshid_functions.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SYSHID_FUNCTIONS_H_ -#define __SYSHID_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int syshid_handle; - -typedef struct -{ - unsigned int handle; - unsigned int physical_device_inst; - unsigned short vid; - unsigned short pid; - unsigned char interface_index; - unsigned char sub_class; - unsigned char protocol; - - unsigned short max_packet_size_rx; - unsigned short max_packet_size_tx; - -} HIDDevice; - -typedef struct _HIDClient HIDClient; - -#define HID_DEVICE_DETACH 0 -#define HID_DEVICE_ATTACH 1 - -typedef int (*HIDAttachCallback)(HIDClient *p_hc,HIDDevice *p_hd,unsigned int attach); - -struct _HIDClient -{ - HIDClient *next; - HIDAttachCallback attach_cb; -}; - -typedef void (*HIDCallback)(unsigned int handle,int error,unsigned char *p_buffer,unsigned int bytes_transferred,void *p_user); - -void InitSysHIDFunctionPointers(void); -void InitAcquireSysHID(void); - -extern int(*HIDSetup)(void); -extern int(*HIDTeardown)(void); - -extern int(*HIDAddClient)(HIDClient *p_client, HIDAttachCallback attach_callback); -extern int(*HIDDelClient)(HIDClient *p_client); - -extern int(*HIDGetDescriptor)(unsigned int handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); -extern int(*HIDSetDescriptor)(unsigned int handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); - -extern int(*HIDGetReport)(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -extern int(*HIDSetReport)(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -extern int(*HIDSetIdle)(unsigned int handle, u8 interface_index,u8 duration, HIDCallback hc, void *p_user); - -extern int(* HIDSetProtocol)(unsigned int handle,u8 interface_index,u8 protocol, HIDCallback hc, void *p_user); -extern int(* HIDGetProtocol)(unsigned int handle,u8 interface_index,u8 * protocol, HIDCallback hc, void *p_user); - -extern int(*HIDRead)(unsigned int handle, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); -extern int(*HIDWrite)(unsigned int handle, unsigned char *p_buffer, unsigned int buffer_length, HIDCallback hc, void *p_user); - -#ifdef __cplusplus -} -#endif - -#endif // __SYSHID_FUNCTIONS_H_ diff --git a/src/dynamic_libs/vpad_functions.c b/src/dynamic_libs/vpad_functions.c deleted file mode 100644 index 201cf34..0000000 --- a/src/dynamic_libs/vpad_functions.c +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "vpad_functions.h" - -unsigned int vpad_handle __attribute__((section(".data"))) = 0; -unsigned int vpadbase_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, VPADInit, void); -EXPORT_DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error); -EXPORT_DECL(int, VPADGetLcdMode, int padnum, int *lcdmode); -EXPORT_DECL(int, VPADSetLcdMode, int padnum, int lcdmode); -EXPORT_DECL(int, VPADBASEGetMotorOnRemainingCount, int padnum); -EXPORT_DECL(int, VPADBASESetMotorOnRemainingCount, int padnum, int counter); - -void InitAcquireVPad(void) -{ - OSDynLoad_Acquire("vpad.rpl", &vpad_handle); - OSDynLoad_Acquire("vpadbase.rpl", &vpadbase_handle); -} - -void InitVPadFunctionPointers(void) -{ - unsigned int *funcPointer = 0; - - InitAcquireVPad(); - - OS_FIND_EXPORT(vpad_handle, VPADInit); - OS_FIND_EXPORT(vpad_handle, VPADRead); - OS_FIND_EXPORT(vpad_handle, VPADGetLcdMode); - OS_FIND_EXPORT(vpad_handle, VPADSetLcdMode); - OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetMotorOnRemainingCount); - OS_FIND_EXPORT(vpadbase_handle, VPADBASESetMotorOnRemainingCount); -} diff --git a/src/dynamic_libs/vpad_functions.h b/src/dynamic_libs/vpad_functions.h deleted file mode 100644 index 4fafda2..0000000 --- a/src/dynamic_libs/vpad_functions.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __VPAD_FUNCTIONS_H_ -#define __VPAD_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern unsigned int vpad_handle; -extern unsigned int vpadbase_handle; - -#include - -#define VPAD_BUTTON_A 0x8000 -#define VPAD_BUTTON_B 0x4000 -#define VPAD_BUTTON_X 0x2000 -#define VPAD_BUTTON_Y 0x1000 -#define VPAD_BUTTON_LEFT 0x0800 -#define VPAD_BUTTON_RIGHT 0x0400 -#define VPAD_BUTTON_UP 0x0200 -#define VPAD_BUTTON_DOWN 0x0100 -#define VPAD_BUTTON_ZL 0x0080 -#define VPAD_BUTTON_ZR 0x0040 -#define VPAD_BUTTON_L 0x0020 -#define VPAD_BUTTON_R 0x0010 -#define VPAD_BUTTON_PLUS 0x0008 -#define VPAD_BUTTON_MINUS 0x0004 -#define VPAD_BUTTON_HOME 0x0002 -#define VPAD_BUTTON_SYNC 0x0001 -#define VPAD_BUTTON_STICK_R 0x00020000 -#define VPAD_BUTTON_STICK_L 0x00040000 -#define VPAD_BUTTON_TV 0x00010000 - -#define VPAD_STICK_R_EMULATION_LEFT 0x04000000 -#define VPAD_STICK_R_EMULATION_RIGHT 0x02000000 -#define VPAD_STICK_R_EMULATION_UP 0x01000000 -#define VPAD_STICK_R_EMULATION_DOWN 0x00800000 - -#define VPAD_STICK_L_EMULATION_LEFT 0x40000000 -#define VPAD_STICK_L_EMULATION_RIGHT 0x20000000 -#define VPAD_STICK_L_EMULATION_UP 0x10000000 -#define VPAD_STICK_L_EMULATION_DOWN 0x08000000 - -//! Own definitions -#define VPAD_BUTTON_TOUCH 0x00080000 -#define VPAD_MASK_EMULATED_STICKS 0x7F800000 -#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS - -typedef struct -{ - f32 x,y; -} Vec2D; - -typedef struct -{ - u16 x, y; /* Touch coordinates */ - u16 touched; /* 1 = Touched, 0 = Not touched */ - u16 invalid; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */ -} VPADTPData; - -typedef struct -{ - u32 btns_h; /* Held buttons */ - u32 btns_d; /* Buttons that are pressed at that instant */ - u32 btns_r; /* Released buttons */ - Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */ - char unknown1c[0x52 - 0x1c]; /* Contains accelerometer and gyroscope data somewhere */ - VPADTPData tpdata; /* Normal touchscreen data */ - VPADTPData tpdata1; /* Modified touchscreen data 1 */ - VPADTPData tpdata2; /* Modified touchscreen data 2 */ - char unknown6a[0xa0 - 0x6a]; - uint8_t volume; - uint8_t battery; /* 0 to 6 */ - uint8_t unk_volume; /* One less than volume */ - char unknowna4[0xac - 0xa4]; -} VPADData; - -void InitVPadFunctionPointers(void); -void InitAcquireVPad(void); - -extern int (* VPADRead)(int chan, VPADData *buffer, u32 buffer_size, s32 *error); -extern int (* VPADGetLcdMode)(int padnum, int *lcdmode); -extern int (* VPADSetLcdMode)(int padnum, int lcdmode); -extern void (* VPADInit)(void); -extern int (* VPADBASEGetMotorOnRemainingCount)(int lcdmode); -extern int (* VPADBASESetMotorOnRemainingCount)(int lcdmode,int counter); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ From 8864a55a720e435c41b08b844fd85cdc3cd64ae2 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 10 Sep 2017 22:02:19 +0200 Subject: [PATCH 2/4] Added libntfs support and changed the progress format - added libntfs support via (https://github.com/Maschell/libntfs-wiiu). When dumping to a ntfs device creating the hash will be disabled because of crashes. - updated dynamic libs (and added them as a submodule) - added logging --- .gitignore | 13 + .gitmodules | 3 + Makefile | 17 +- README.md | 19 +- include/stdint.h | 15 -- src/dynamic_libs | 1 + src/main.cpp | 562 ++++++++++++++++++++++++++++++++++++++++++++ src/system/memory.c | 67 ++++-- src/system/memory.h | 6 +- src/utils/logger.c | 76 ++++++ src/utils/logger.h | 32 +++ 11 files changed, 759 insertions(+), 52 deletions(-) create mode 100644 .gitignore create mode 100644 .gitmodules delete mode 100644 include/stdint.h create mode 160000 src/dynamic_libs create mode 100644 src/main.cpp create mode 100644 src/utils/logger.c create mode 100644 src/utils/logger.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec7e40d --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.o +*.elf +*.d +build/.map +payload/* +arm_kernel/arm_kernel.bin +arm_kernel/arm_kernel_bin.h +arm_user/arm_user.bin +arm_user/arm_user_bin.h +odmhook/odmhook.bin +odmhook/odmhook_bin.h +wupserver/wupserver.bin +wupserver/wupserver_bin.h \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5b6b6a9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/dynamic_libs"] + path = src/dynamic_libs + url = https://github.com/Maschell/dynamic_libs diff --git a/Makefile b/Makefile index 0b9d6b5..4e29383 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ SOURCES := src \ src/fs \ src/system \ src/utils \ - src/polarssl + src/polarssl \ + src/utils DATA := INCLUDES := src include payload @@ -45,9 +46,9 @@ INCLUDES := src include payload # options for code generation #--------------------------------------------------------------------------------- CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ - -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) + -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ - -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) + -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) ASFLAGS := -mregnames LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections @@ -57,14 +58,15 @@ MAKEFLAGS += --no-print-directory #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lfat -liosuhax +LIBS := -lm -lgcc -lfat -lntfs -liosuhax #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(CURDIR) \ - $(DEVKITPPC)/lib + $(DEVKITPPC)/lib \ + $(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -105,14 +107,15 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 \ -I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \ - -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 + #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib + -L$(PORTLIBS)/lib export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean install diff --git a/README.md b/README.md index d4f7669..caae997 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,22 @@ # wudump dump raw images from a wiiu game disc # Usage -Download and run the .elf from homebrew launcher with a fat32 sd card/usb device inserted that has at least 23.3gb free. -The files will be dumped in 2gb parts, you will have to merge them yourself afterwards if you need the full game.wud. +Download and run the .elf from homebrew launcher with a fat32 sd card/usb device or NTFS usb device inserted that has at least 23.3gb free. +On fat32 devices the files will be dumped in 2gb parts, you will have to merge them yourself afterwards if you need the full game.wud. On NTFS devices it will be dumped into a single file. + A full dump can take a little over one and a half hours. -After it has been dumped the wud parts, common.key and game.key will be in a "wudump" folder on your sd card/usb device, to get the full game.wud you will have to merge them. +After it has been dumped the wud, common.key and game.key will be in a "wudump" folder on your sd card/usb device. + +## Merging the wud parts on FAT32 devices. +This step is not needed, when the file was dumped to a ntfs device. + +To get the full game.wud with FAT32 devices you will have to merge them. If you are on windows you can use something like this for example to merge them into a game.wud on a "wudump" folder on your C drive from a cmd in the sd/usb folder: ``` copy /b game_part1.wud + game_part2.wud + game_part3.wud + game_part4.wud + game_part5.wud + game_part6.wud + game_part7.wud + game_part8.wud + game_part9.wud + game_part10.wud + game_part11.wud + game_part12.wud C:\wudump\game.wud ``` +## wud2app If you would just like to install your game using wupinstaller then grab wud2app: https://github.com/FIX94/wud2app/releases If you dont want to merge all .wud files you can put wud2app into a folder on your pc and run it from a cmd with the wudump folder path as argument, for example if the sd/usb folder happens to be in "P:\wudump\WUP-P-TEST" on windows you can just run wud2app like: @@ -23,3 +30,9 @@ wud2app common.key game.key game.wud Make sure to copy the common.key and game.key into that folder as well if you use that method. The folder it creates can just be installed by wupinstaller. + +# Build +For building you need: +- [libfat](https://github.com/aliaspider/libfat/) +- [libiosuhax](https://github.com/dimok789/libiosuhax) (Build WITHOUT the WUT flag set.) +- [libntfs](https://github.com/Maschell/libntfs-wiiu) (Build with make wiiu-install) \ No newline at end of file diff --git a/include/stdint.h b/include/stdint.h deleted file mode 100644 index fff483d..0000000 --- a/include/stdint.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _STDINT_WRAP_H -#define _STDINT_WRAP_H - -#define int32_t dontcare_int32_t -#define uint32_t dontcare_uint32_t - -#include_next - -#undef int32_t -#undef uint32_t - -typedef signed int int32_t; -typedef unsigned int uint32_t; - -#endif \ No newline at end of file diff --git a/src/dynamic_libs b/src/dynamic_libs new file mode 160000 index 0000000..451c406 --- /dev/null +++ b/src/dynamic_libs @@ -0,0 +1 @@ +Subproject commit 451c406012c2bdf1fe8489583e685afa2fdb1dd6 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..8e002ed --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,562 @@ +/* + * Copyright (C) 2016-2017 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dynamic_libs/os_types.h" +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "dynamic_libs/sys_functions.h" +#include "dynamic_libs/vpad_functions.h" +#include "system/memory.h" +#include "common/common.h" +#include "main.h" +#include "exploit.h" +#include "utils/logger.h" +#include "../payload/wupserver_bin.h" + +//just to be able to call async +void someFunc(void *arg) +{ + (void)arg; +} + +static int mcp_hook_fd = -1; +int MCPHookOpen() +{ + //take over mcp thread + mcp_hook_fd = MCP_Open(); + if(mcp_hook_fd < 0) + return -1; + IOS_IoctlAsync(mcp_hook_fd, 0x62, (void*)0, 0, (void*)0, 0, (void*)someFunc, (void*)0); + //let wupserver start up + os_sleep(1); + if(IOSUHAX_Open("/dev/mcp") < 0) + return -1; + return 0; +} + +void MCPHookClose() +{ + if(mcp_hook_fd < 0) + return; + //close down wupserver, return control to mcp + IOSUHAX_Close(); + //wait for mcp to return + os_sleep(1); + MCP_Close(mcp_hook_fd); + mcp_hook_fd = -1; +} + +void println_noflip(int line, const char *msg) +{ + OSScreenPutFontEx(0,0,line,msg); + OSScreenPutFontEx(1,0,line,msg); +} + +void println(int line, const char *msg) +{ + int i; + for(i = 0; i < 2; i++) + { //double-buffered font write + println_noflip(line,msg); + OSScreenFlipBuffersEx(0); + OSScreenFlipBuffersEx(1); + } +} + +#define SECTOR_SIZE 2048 +#define NUM_SECTORS 1024 + +int fsa_odd_read(int fsa_fd, int fd, void *buf, int offset){ + return IOSUHAX_FSA_RawRead(fsa_fd, buf, SECTOR_SIZE, NUM_SECTORS, offset, fd); +} + +int fsa_write(int fsa_fd, int fd, void *buf, int len){ + int done = 0; + uint8_t *buf_u8 = (uint8_t*)buf; + while(done < len) + { + size_t write_size = len - done; + int result = IOSUHAX_FSA_WriteFile(fsa_fd, buf_u8 + done, 0x01, write_size, fd, 0); + if(result < 0) + return result; + else + done += result; + } + return done; +} + +static const char *hdrStr = "wudump v1.6 by FIX94"; +void printhdr_noflip(){ + println_noflip(0,hdrStr); +} + +void write_hash_file(char *fName, char *dir, unsigned int crc32, md5_context *md5ctx, sha1_context *sha1ctx){ + unsigned int md5[4]; + md5_finish(md5ctx, (unsigned char*)md5); + unsigned int sha1[5]; + sha1_finish(sha1ctx, (unsigned char*)sha1); + + char wudPath[64]; + sprintf(wudPath, "%s/%s.txt", dir, fName); + FILE *f = fopen(wudPath, "w"); + if(f) + { + fprintf(f, "%s\n\n", hdrStr); + fprintf(f, "Hashes for %s.wud:\n", fName); + fprintf(f, "CRC32: %08X\n" + "MD5: %08X%08X%08X%08X\n" + "SHA1: %08X%08X%08X%08X%08X\n", + crc32, md5[0],md5[1],md5[2],md5[3], + sha1[0],sha1[1],sha1[2],sha1[3],sha1[4]); + fclose(f); + f = NULL; + } +} + +//imported OS zlib crc32 function pointer +static unsigned int (*zlib_crc32)(unsigned int crc32, const void *buf, int bufsize) = (unsigned int (*)(unsigned int, const void*, int))0; + +static const int bufSize = SECTOR_SIZE*NUM_SECTORS; +static void *sectorBuf = NULL; +static bool threadRunning = true; +static unsigned int crc32Val = 0; +static md5_context md5ctx; +static sha1_context sha1ctx; +static unsigned int crc32PartVal = 0; +static md5_context md5PartCtx; +static sha1_context sha1PartCtx; + +static s32 hashThread(s32 argc, void *args){ + (void)argc; + (void)args; + while(threadRunning) { + //update global hashes + crc32Val = zlib_crc32(crc32Val, sectorBuf, bufSize); + md5_update(&md5ctx, (const unsigned char *) sectorBuf, bufSize); + sha1_update(&sha1ctx, (const unsigned char *)sectorBuf, bufSize); + //update hashes for part file + crc32PartVal = zlib_crc32(crc32PartVal, (const unsigned char *)sectorBuf, bufSize); + md5_update(&md5PartCtx, (const unsigned char *)sectorBuf, bufSize); + sha1_update(&sha1PartCtx, (const unsigned char *)sectorBuf, bufSize); + //go back to os_sleep + OSSuspendThread(OSGetCurrentThread()); + } + return 0; +} + +int Menu_Main(void){ + InitOSFunctionPointers(); + InitSocketFunctionPointers(); + + log_init(); + + InitSysFunctionPointers(); + InitVPadFunctionPointers(); + u32 zlib_handle = 0; + OSDynLoad_Acquire("zlib125.rpl", &zlib_handle); + OSDynLoad_FindExport(zlib_handle, 0, "crc32", &zlib_crc32); + VPADInit(); + memoryInitialize(); + + // Init screen + OSScreenInit(); + int screen_buf0_size = OSScreenGetBufferSizeEx(0); + int screen_buf1_size = OSScreenGetBufferSizeEx(1); + uint8_t *screenBuffer = (uint8_t*)MEMBucket_alloc(screen_buf0_size+screen_buf1_size, 0x100); + OSScreenSetBufferEx(0, screenBuffer); + OSScreenSetBufferEx(1, (screenBuffer + screen_buf0_size)); + OSScreenEnableEx(0, 1); + OSScreenEnableEx(1, 1); + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); + + printhdr_noflip(); + println_noflip(2,"Please make sure to take out any currently inserted disc."); + println_noflip(3,"Also make sure you have at least 23.3GB free on your device."); + println_noflip(4,"Press A to continue with a FAT32 SD Card as destination."); + println_noflip(5,"Press B to continue with a FAT32 USB Device as destination."); + println_noflip(6,"Press X to continue with a NTFS USB Device as destination."); + println_noflip(7,"Press HOME to return to the Homebrew Launcher."); + OSScreenFlipBuffersEx(0); + OSScreenFlipBuffersEx(1); + + s32 vpadError = -1; + VPADData vpad; + int action = 0; + while(1) + { + VPADRead(0, &vpad, 1, &vpadError); + if(vpadError == 0) + { + if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_HOME) + { + MEMBucket_free(screenBuffer); + memoryRelease(); + return EXIT_SUCCESS; + } + else if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_A) + break; + else if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_B) + { + action = 1; + break; + }else if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_X) + { + action = 2; + break; + } + } + os_usleep(50000); + } + int j; + for(j = 0; j < 2; j++) + { + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); + printhdr_noflip(); + OSScreenFlipBuffersEx(0); + OSScreenFlipBuffersEx(1); + os_usleep(25000); + } + int line = 2; + //will inject our custom mcp code + println(line++,"Doing IOSU Exploit..."); + *(volatile unsigned int*)0xF5E70000 = wupserver_bin_len; + memcpy((void*)0xF5E70020, &wupserver_bin, wupserver_bin_len); + DCStoreRange((void*)0xF5E70000, wupserver_bin_len + 0x40); + IOSUExploit(); + int fsaFd = -1; + int oddFd = -1; + s32 ret; + char wudumpPath[64]; + char wudPath[64]; + char keyPath[64]; + FILE *f = NULL; + + OSThread * thread = NULL; + void *stack = NULL; + int retry = 10; + + ntfs_md * ntfs_mounts = NULL; + int ntfs_mount_count = 0; + int useNTFS = 0; + + s32 apd_enabled = 0; + + bool newF = true; + int part = 0; + unsigned int readSectors = 0; + + //done with iosu exploit, take over mcp + if(MCPHookOpen() < 0) + { + println(line++,"MCP hook could not be opened!"); + goto prgEnd; + } + memset((void*)0xF5E10C00, 0, 0x20); + DCFlushRange((void*)0xF5E10C00, 0x20); + println(line++,"Done!"); + + //mount with full permissions + fsaFd = IOSUHAX_FSA_Open(); + if(fsaFd < 0) + { + println(line++,"FSA could not be opened!"); + goto prgEnd; + } + fatInitDefault(); + + println(line++,"Please insert the disc you want to dump now to begin."); + //wait for disc key to be written + while(1) + { + DCInvalidateRange((void*)0xF5E10C00, 0x20); + if(*(volatile unsigned int*)0xF5E10C00 != 0) + break; + VPADRead(0, &vpad, 1, &vpadError); + if(vpadError == 0) + { + if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_HOME) + goto prgEnd; + } + os_usleep(50000); + } + + //opening raw odd might take a bit + retry = 10; + ret = -1; + while(ret < 0) + { + ret = IOSUHAX_FSA_RawOpen(fsaFd, "/dev/odd01", &oddFd); + retry--; + if(retry < 0) + break; + os_sleep(1); + } + if(ret < 0) + { + println(line++,"Failed to open Raw ODD!"); + goto prgEnd; + } + + //get our 2MB I/O Buffer and read out first sector + sectorBuf = MEMBucket_alloc(bufSize, 0x100); + if(sectorBuf == NULL || fsa_odd_read(fsaFd, oddFd, sectorBuf, 0) < 0) + { + println(line++,"Failed to read first disc sector!"); + goto prgEnd; + } + + //get disc name for folder + char discId[11]; + discId[10] = '\0'; + memcpy(discId, sectorBuf, 10); + char discStr[64]; + sprintf(discStr, "Inserted %s", discId); + println(line++, discStr); + + // make wudump dir we will write to + char device[255]; + if(action == 0){ + sprintf(device, "%s", "sd:"); + }else if(action == 1){ + sprintf(device, "%s", "usb:"); + }else if(action == 2){ + ntfs_mount_count = ntfsMountAll((ntfs_md **) &ntfs_mounts, NTFS_DEFAULT | NTFS_RECOVER); + + // List all mounted NTFS volumes + + for (int i = 0; i < ntfs_mount_count; i++){ + useNTFS = 1; + sprintf(device, "%s:", ntfs_mounts[i].name); + break; + } + if(!useNTFS){ + println(line++,"Failed to open NTFS! No partition found!"); + goto prgEnd; + } + } + sprintf(wudumpPath, "%s/wudump", device); + mkdir(wudumpPath, 0x600); + sprintf(wudumpPath, "%s/wudump/%s", device, discId); + mkdir(wudumpPath, 0x600); + + u8 cKey[0x10]; + memcpy(cKey, (void*)0xF5E104E0, 0x10); + + sprintf(keyPath, "%s/common.key", wudumpPath); + f = fopen(keyPath, "wb"); + if(f == NULL) + { + println(line++,"Failed to write Common Key!"); + goto prgEnd; + } + fwrite(cKey, 1, 0x10, f); + fclose(f); + f = NULL; + println(line++,"Common Key dumped!"); + + u8 discKey[0x10]; + memcpy(discKey, (void*)0xF5E10C00, 0x10); + + sprintf(keyPath, "%s/game.key", wudumpPath); + f = fopen(keyPath, "wb"); + if(f == NULL) + { + println(line++,"Failed to write Disc Key!"); + goto prgEnd; + } + fwrite(discKey, 1, 0x10, f); + fclose(f); + f = NULL; + println(line++, "Disc Key dumped!"); + + apd_enabled = 0; + IMIsAPDEnabled(&apd_enabled); + if(apd_enabled) + { + if(IMDisableAPD() == 0) + println(line++, "Disabled Auto Power-Down."); + } + + sprintf(discStr, "Dumping %s...", discId); + char progress[64]; + newF = true; + part = 0; + readSectors = 0; + + //full hashes + + if(!useNTFS){ + crc32Val = 0; + md5_starts(&md5ctx); + sha1_starts(&sha1ctx); + + //part hashes + crc32PartVal = 0; + md5_starts(&md5PartCtx); + sha1_starts(&sha1PartCtx); + + //create hashing thread + + stack = MEMBucket_alloc(0x4000, 0x20); + thread = (OSThread*)memalign(8, 0x1000); //thread cant be in MEMBucket + OSCreateThread(thread, hashThread, 0, NULL, (u32)stack+0x4000, 0x4000, 20, (1<= 0) + { + if(f != NULL) + fclose(f); + fatUnmount("sd:"); + fatUnmount("usb:"); + + if (ntfs_mounts) { + int i = 0; + for (i = 0; i < ntfs_mount_count; i++){ + ntfsUnmount(ntfs_mounts[i].name, true); + } + free(ntfs_mounts); + ntfs_mounts = NULL; + ntfs_mount_count = 0; + } + + if(oddFd >= 0) + IOSUHAX_FSA_RawClose(fsaFd, oddFd); + IOSUHAX_FSA_Close(fsaFd); + if(sectorBuf != NULL) + MEMBucket_free(sectorBuf); + + + } + //close out old mcp instance + MCPHookClose(); + os_sleep(5); + //will do IOSU reboot + OSForceFullRelaunch(); + SYSLaunchMenu(); + OSScreenEnableEx(0, 0); + OSScreenEnableEx(1, 0); + MEMBucket_free(screenBuffer); + memoryRelease(); + return EXIT_RELAUNCH_ON_LOAD; +} diff --git a/src/system/memory.c b/src/system/memory.c index 91f5392..7cc7e0f 100644 --- a/src/system/memory.c +++ b/src/system/memory.c @@ -34,32 +34,32 @@ //! Memory functions //! This is the only place where those are needed so lets keep them more or less private //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern unsigned int * pMEMAllocFromDefaultHeapEx; -extern unsigned int * pMEMAllocFromDefaultHeap; -extern unsigned int * pMEMFreeToDefaultHeap; - -extern int (* MEMGetBaseHeapHandle)(int mem_arena); -extern unsigned int (* MEMGetAllocatableSizeForFrmHeapEx)(int heap, int align); -extern void *(* MEMAllocFromFrmHeapEx)(int heap, unsigned int size, int align); -extern void (* MEMFreeToFrmHeap)(int heap, int mode); -extern void *(* MEMAllocFromExpHeapEx)(int heap, unsigned int size, int align); -extern int (* MEMCreateExpHeapEx)(void* address, unsigned int size, unsigned short flags); -extern void *(* MEMDestroyExpHeap)(int heap); -extern void (* MEMFreeToExpHeap)(int heap, void* ptr); - -static int mem1_heap = -1; -static int bucket_heap = -1; +extern u32 * pMEMAllocFromDefaultHeapEx; +extern u32 * pMEMAllocFromDefaultHeap; +extern u32 * pMEMFreeToDefaultHeap; + +extern s32 (* MEMGetBaseHeapHandle)(s32 mem_arena); +extern u32 (* MEMGetAllocatableSizeForFrmHeapEx)(s32 heap, s32 align); +extern void *(* MEMAllocFromFrmHeapEx)(s32 heap, u32 size, s32 align); +extern void (* MEMFreeToFrmHeap)(s32 heap, s32 mode); +extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align); +extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); +extern void *(* MEMDestroyExpHeap)(s32 heap); +extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); + +static s32 mem1_heap = -1; +static s32 bucket_heap = -1; void memoryInitialize(void) { - int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); - unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); + s32 mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); + u32 mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); if(mem1_memory) mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); - int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); - unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); + s32 bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); + u32 bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); if(bucket_memory) bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); @@ -116,8 +116,27 @@ size_t __wrap_malloc_usable_size(void *p) return 0x7FFFFFFF; } -void *__wrap_realloc(void *p, size_t size) +void *__wrap_realloc(void *ptr, size_t size) { + void *newPtr; + + if (!ptr) { + newPtr = __wrap_malloc(size); + if (!newPtr) { goto error; } + } else { + newPtr = __wrap_malloc(size); + if (!newPtr) { goto error; } + + memcpy(newPtr, ptr, size); + + __wrap_free(ptr); + } + + return newPtr; +error: + return NULL; +} + /* void *new_ptr = __wrap_malloc(size); if (new_ptr != 0) { @@ -125,7 +144,7 @@ void *__wrap_realloc(void *p, size_t size) __wrap_free(p); } return new_ptr; -} +}*/ //!------------------------------------------------------------------------------------------- //! reent versions @@ -163,7 +182,7 @@ void *__wrap__realloc_r(struct _reent *r, void *p, size_t size) //!------------------------------------------------------------------------------------------- //! some wrappers //!------------------------------------------------------------------------------------------- -void * MEM2_alloc(unsigned int size, unsigned int align) +void * MEM2_alloc(u32 size, u32 align) { return __wrap_memalign(align, size); } @@ -173,7 +192,7 @@ void MEM2_free(void *ptr) __wrap_free(ptr); } -void * MEM1_alloc(unsigned int size, unsigned int align) +void * MEM1_alloc(u32 size, u32 align) { if (align < 4) align = 4; @@ -185,7 +204,7 @@ void MEM1_free(void *ptr) MEMFreeToExpHeap(mem1_heap, ptr); } -void * MEMBucket_alloc(unsigned int size, unsigned int align) +void * MEMBucket_alloc(u32 size, u32 align) { if (align < 4) align = 4; diff --git a/src/system/memory.h b/src/system/memory.h index 59764d0..db67a05 100644 --- a/src/system/memory.h +++ b/src/system/memory.h @@ -26,13 +26,13 @@ extern "C" { void memoryInitialize(void); void memoryRelease(void); -void * MEM2_alloc(unsigned int size, unsigned int align); +void * MEM2_alloc(u32 size, u32 align); void MEM2_free(void *ptr); -void * MEM1_alloc(unsigned int size, unsigned int align); +void * MEM1_alloc(u32 size, u32 align); void MEM1_free(void *ptr); -void * MEMBucket_alloc(unsigned int size, unsigned int align); +void * MEMBucket_alloc(u32 size, u32 align); void MEMBucket_free(void *ptr); #ifdef __cplusplus diff --git a/src/utils/logger.c b/src/utils/logger.c new file mode 100644 index 0000000..7822461 --- /dev/null +++ b/src/utils/logger.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "logger.h" + +#ifdef DEBUG_LOGGER +static int log_socket = -1; +static struct sockaddr_in connect_addr; +static volatile int log_lock = 0; + + +void log_init() +{ + int broadcastEnable = 1; + log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (log_socket < 0) + return; + + setsockopt(log_socket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable)); + + memset(&connect_addr, 0, sizeof(struct sockaddr_in)); + connect_addr.sin_family = AF_INET; + connect_addr.sin_port = 4405; + connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST); +} + +void log_print(const char *str) +{ + // socket is always 0 initially as it is in the BSS + if(log_socket < 0) { + return; + } + + while(log_lock) + os_usleep(1000); + log_lock = 1; + + int len = strlen(str); + int ret; + while (len > 0) { + int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet + ret = sendto(log_socket, str, block, 0, (struct sockaddr *)&connect_addr, sizeof(struct sockaddr_in)); + if(ret < 0) + break; + + len -= ret; + str += ret; + } + + log_lock = 0; +} + +void log_printf(const char *format, ...) +{ + if(log_socket < 0) { + return; + } + + char * tmp = NULL; + + va_list va; + va_start(va, format); + if((vasprintf(&tmp, format, va) >= 0) && tmp) + { + log_print(tmp); + } + va_end(va); + + if(tmp) + free(tmp); +} +#endif diff --git a/src/utils/logger.h b/src/utils/logger.h new file mode 100644 index 0000000..1e8dec1 --- /dev/null +++ b/src/utils/logger.h @@ -0,0 +1,32 @@ +#ifndef __LOGGER_H_ +#define __LOGGER_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ + log_printf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ + } while (0) + +#define DEBUG_LOGGER 1 + +#ifdef DEBUG_LOGGER +void log_init(); +#define log_deinit() // depreciated +void log_print(const char *str); +void log_printf(const char *format, ...); +#else +#define log_init() +#define log_deinit() +#define log_print(x) +#define log_printf(x, ...) +#endif + +#ifdef __cplusplus +} +#endif + +#endif From 30ff6e9c6c0dd9fe3b9252760abb3e8b2299b8f7 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 11 Sep 2017 18:35:22 +0200 Subject: [PATCH 3/4] added new dynamic_libs --- Makefile | 4 ++-- src/dynamic_libs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4e29383..c85c340 100644 --- a/Makefile +++ b/Makefile @@ -46,9 +46,9 @@ INCLUDES := src include payload # options for code generation #--------------------------------------------------------------------------------- CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ - -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) + -O3 -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ - -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) + -O3 -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE) ASFLAGS := -mregnames LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections diff --git a/src/dynamic_libs b/src/dynamic_libs index 451c406..c3a91eb 160000 --- a/src/dynamic_libs +++ b/src/dynamic_libs @@ -1 +1 @@ -Subproject commit 451c406012c2bdf1fe8489583e685afa2fdb1dd6 +Subproject commit c3a91ebe96477ea44b9543712cc3b06ec64b3ff5 From 51d32c4a00d1e8590f40d7c7e637fd6bdafcc74a Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 11 Sep 2017 18:43:02 +0200 Subject: [PATCH 4/4] Forgot to remove the old main.c --- src/main.c | 498 ----------------------------------------------------- 1 file changed, 498 deletions(-) delete mode 100644 src/main.c diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 1f5a74a..0000000 --- a/src/main.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (C) 2016-2017 FIX94 - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dynamic_libs/os_functions.h" -#include "dynamic_libs/sys_functions.h" -#include "dynamic_libs/vpad_functions.h" -#include "system/memory.h" -#include "common/common.h" -#include "main.h" -#include "exploit.h" -#include "../payload/wupserver_bin.h" - -//just to be able to call async -void someFunc(void *arg) -{ - (void)arg; -} - -static int mcp_hook_fd = -1; -int MCPHookOpen() -{ - //take over mcp thread - mcp_hook_fd = MCP_Open(); - if(mcp_hook_fd < 0) - return -1; - IOS_IoctlAsync(mcp_hook_fd, 0x62, (void*)0, 0, (void*)0, 0, (void*)someFunc, (void*)0); - //let wupserver start up - sleep(1); - if(IOSUHAX_Open("/dev/mcp") < 0) - return -1; - return 0; -} - -void MCPHookClose() -{ - if(mcp_hook_fd < 0) - return; - //close down wupserver, return control to mcp - IOSUHAX_Close(); - //wait for mcp to return - sleep(1); - MCP_Close(mcp_hook_fd); - mcp_hook_fd = -1; -} - -void println_noflip(int line, const char *msg) -{ - OSScreenPutFontEx(0,0,line,msg); - OSScreenPutFontEx(1,0,line,msg); -} - -void println(int line, const char *msg) -{ - int i; - for(i = 0; i < 2; i++) - { //double-buffered font write - println_noflip(line,msg); - OSScreenFlipBuffersEx(0); - OSScreenFlipBuffersEx(1); - } -} - -#define SECTOR_SIZE 2048 -#define NUM_SECTORS 1024 - -int fsa_odd_read(int fsa_fd, int fd, void *buf, int offset) -{ - return IOSUHAX_FSA_RawRead(fsa_fd, buf, SECTOR_SIZE, NUM_SECTORS, offset, fd); -} - -int fsa_write(int fsa_fd, int fd, void *buf, int len) -{ - int done = 0; - uint8_t *buf_u8 = (uint8_t*)buf; - while(done < len) - { - size_t write_size = len - done; - int result = IOSUHAX_FSA_WriteFile(fsa_fd, buf_u8 + done, 0x01, write_size, fd, 0); - if(result < 0) - return result; - else - done += result; - } - return done; -} - -static const char *hdrStr = "wudump v1.5 by FIX94"; -void printhdr_noflip() -{ - println_noflip(0,hdrStr); -} - -void write_hash_file(char *fName, char *dir, unsigned int crc32, - md5_context *md5ctx, sha1_context *sha1ctx) -{ - unsigned int md5[4]; - md5_finish(md5ctx, (unsigned char*)md5); - unsigned int sha1[5]; - sha1_finish(sha1ctx, (unsigned char*)sha1); - - char wudPath[64]; - sprintf(wudPath, "%s/%s.txt", dir, fName); - FILE *f = fopen(wudPath, "w"); - if(f) - { - fprintf(f, "%s\n\n", hdrStr); - fprintf(f, "Hashes for %s.wud:\n", fName); - fprintf(f, "CRC32: %08X\n" - "MD5: %08X%08X%08X%08X\n" - "SHA1: %08X%08X%08X%08X%08X\n", - crc32, md5[0],md5[1],md5[2],md5[3], - sha1[0],sha1[1],sha1[2],sha1[3],sha1[4]); - fclose(f); - f = NULL; - } -} - -//imported OS zlib crc32 function pointer -static unsigned int (*zlib_crc32)(unsigned int crc32, const void *buf, int bufsize) = (void*)0; - -static const int bufSize = SECTOR_SIZE*NUM_SECTORS; -static void *sectorBuf = NULL; -static bool threadRunning = true; -static unsigned int crc32Val = 0; -static md5_context md5ctx; -static sha1_context sha1ctx; -static unsigned int crc32PartVal = 0; -static md5_context md5PartCtx; -static sha1_context sha1PartCtx; - -static int hashThread(s32 argc, void *args) -{ - (void)argc; - (void)args; - while(threadRunning) - { - //update global hashes - crc32Val = zlib_crc32(crc32Val, sectorBuf, bufSize); - md5_update(&md5ctx, sectorBuf, bufSize); - sha1_update(&sha1ctx, sectorBuf, bufSize); - //update hashes for part file - crc32PartVal = zlib_crc32(crc32PartVal, sectorBuf, bufSize); - md5_update(&md5PartCtx, sectorBuf, bufSize); - sha1_update(&sha1PartCtx, sectorBuf, bufSize); - //go back to sleep - OSSuspendThread(OSGetCurrentThread()); - } - return 0; -} - -int Menu_Main(void) -{ - InitOSFunctionPointers(); - InitSysFunctionPointers(); - InitVPadFunctionPointers(); - unsigned int zlib_handle = 0; - OSDynLoad_Acquire("zlib125.rpl", &zlib_handle); - OSDynLoad_FindExport(zlib_handle, 0, "crc32", &zlib_crc32); - VPADInit(); - memoryInitialize(); - - // Init screen - OSScreenInit(); - int screen_buf0_size = OSScreenGetBufferSizeEx(0); - int screen_buf1_size = OSScreenGetBufferSizeEx(1); - uint8_t *screenBuffer = (uint8_t*)MEMBucket_alloc(screen_buf0_size+screen_buf1_size, 0x100); - OSScreenSetBufferEx(0, screenBuffer); - OSScreenSetBufferEx(1, (screenBuffer + screen_buf0_size)); - OSScreenEnableEx(0, 1); - OSScreenEnableEx(1, 1); - OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); - - printhdr_noflip(); - println_noflip(2,"Please make sure to take out any currently inserted disc."); - println_noflip(3,"Also make sure you have at least 23.3GB free on your device."); - println_noflip(4,"Press A to continue with a FAT32 SD Card as destination."); - println_noflip(5,"Press B to continue with a FAT32 USB Device as destination."); - println_noflip(6,"Press HOME to return to the Homebrew Launcher."); - OSScreenFlipBuffersEx(0); - OSScreenFlipBuffersEx(1); - - int vpadError = -1; - VPADData vpad; - int action = 0; - while(1) - { - VPADRead(0, &vpad, 1, &vpadError); - if(vpadError == 0) - { - if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_HOME) - { - MEMBucket_free(screenBuffer); - memoryRelease(); - return EXIT_SUCCESS; - } - else if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_A) - break; - else if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_B) - { - action = 1; - break; - } - } - usleep(50000); - } - int j; - for(j = 0; j < 2; j++) - { - OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); - printhdr_noflip(); - OSScreenFlipBuffersEx(0); - OSScreenFlipBuffersEx(1); - usleep(25000); - } - int line = 2; - //will inject our custom mcp code - println(line++,"Doing IOSU Exploit..."); - *(volatile unsigned int*)0xF5E70000 = wupserver_bin_len; - memcpy((void*)0xF5E70020, &wupserver_bin, wupserver_bin_len); - DCStoreRange((void*)0xF5E70000, wupserver_bin_len + 0x40); - IOSUExploit(); - int fsaFd = -1; - int oddFd = -1; - int ret; - char wudumpPath[64]; - char wudPath[64]; - char keyPath[64]; - FILE *f = NULL; - - //done with iosu exploit, take over mcp - if(MCPHookOpen() < 0) - { - println(line++,"MCP hook could not be opened!"); - goto prgEnd; - } - memset((void*)0xF5E10C00, 0, 0x20); - DCFlushRange((void*)0xF5E10C00, 0x20); - println(line++,"Done!"); - - //mount with full permissions - fsaFd = IOSUHAX_FSA_Open(); - if(fsaFd < 0) - { - println(line++,"FSA could not be opened!"); - goto prgEnd; - } - fatInitDefault(); - - println(line++,"Please insert the disc you want to dump now to begin."); - //wait for disc key to be written - while(1) - { - DCInvalidateRange((void*)0xF5E10C00, 0x20); - if(*(volatile unsigned int*)0xF5E10C00 != 0) - break; - VPADRead(0, &vpad, 1, &vpadError); - if(vpadError == 0) - { - if((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_HOME) - goto prgEnd; - } - usleep(50000); - } - - //opening raw odd might take a bit - int retry = 10; - ret = -1; - while(ret < 0) - { - ret = IOSUHAX_FSA_RawOpen(fsaFd, "/dev/odd01", &oddFd); - retry--; - if(retry < 0) - break; - sleep(1); - } - if(ret < 0) - { - println(line++,"Failed to open Raw ODD!"); - goto prgEnd; - } - - //get our 2MB I/O Buffer and read out first sector - sectorBuf = MEMBucket_alloc(bufSize, 0x100); - if(sectorBuf == NULL || fsa_odd_read(fsaFd, oddFd, sectorBuf, 0) < 0) - { - println(line++,"Failed to read first disc sector!"); - goto prgEnd; - } - - //get disc name for folder - char discId[11]; - discId[10] = '\0'; - memcpy(discId, sectorBuf, 10); - char discStr[64]; - sprintf(discStr, "Inserted %s", discId); - println(line++, discStr); - - // make wudump dir we will write to - char *device = (action == 0) ? "sd:" : "usb:"; - sprintf(wudumpPath, "%s/wudump", device); - mkdir(wudumpPath, 0x600); - sprintf(wudumpPath, "%s/wudump/%s", device, discId); - mkdir(wudumpPath, 0x600); - - u8 cKey[0x10]; - memcpy(cKey, (void*)0xF5E104E0, 0x10); - - sprintf(keyPath, "%s/common.key", wudumpPath); - f = fopen(keyPath, "wb"); - if(f == NULL) - { - println(line++,"Failed to write Common Key!"); - goto prgEnd; - } - fwrite(cKey, 1, 0x10, f); - fclose(f); - f = NULL; - println(line++,"Common Key dumped!"); - - u8 discKey[0x10]; - memcpy(discKey, (void*)0xF5E10C00, 0x10); - - sprintf(keyPath, "%s/game.key", wudumpPath); - f = fopen(keyPath, "wb"); - if(f == NULL) - { - println(line++,"Failed to write Disc Key!"); - goto prgEnd; - } - fwrite(discKey, 1, 0x10, f); - fclose(f); - f = NULL; - println(line++, "Disc Key dumped!"); - - int apd_enabled = 0; - IMIsAPDEnabled(&apd_enabled); - if(apd_enabled) - { - if(IMDisableAPD() == 0) - println(line++, "Disabled Auto Power-Down."); - } - - sprintf(discStr, "Dumping %s...", discId); - char progress[64]; - bool newF = true; - int part = 0; - unsigned int readSectors = 0; - - //full hashes - crc32Val = 0; - md5_starts(&md5ctx); - sha1_starts(&sha1ctx); - - //part hashes - crc32PartVal = 0; - md5_starts(&md5PartCtx); - sha1_starts(&sha1PartCtx); - - //create hashing thread - void *stack = MEMBucket_alloc(0x4000, 0x20); - void *thread = memalign(8, 0x1000); //thread cant be in MEMBucket - OSCreateThread(thread, hashThread, 0, NULL, (unsigned int)stack+0x4000, 0x4000, 20, (1<= 0) - { - if(f != NULL) - fclose(f); - fatUnmount("sd:"); - fatUnmount("usb:"); - if(oddFd >= 0) - IOSUHAX_FSA_RawClose(fsaFd, oddFd); - IOSUHAX_FSA_Close(fsaFd); - if(sectorBuf != NULL) - MEMBucket_free(sectorBuf); - } - //close out old mcp instance - MCPHookClose(); - sleep(5); - //will do IOSU reboot - OSForceFullRelaunch(); - SYSLaunchMenu(); - OSScreenEnableEx(0, 0); - OSScreenEnableEx(1, 0); - MEMBucket_free(screenBuffer); - memoryRelease(); - return EXIT_RELAUNCH_ON_LOAD; -}