Merge pull request #14 from fre4kyC0de/master

add some nn_act, sys and os API
This commit is contained in:
Maschell 2017-09-30 11:04:45 +02:00 committed by GitHub
commit f4d1ac7906
10 changed files with 44 additions and 33 deletions

View File

@ -44,17 +44,17 @@ typedef struct FSCmdBlock_ {
typedef struct typedef struct
{ {
uint32_t flag; u32 flag;
uint32_t permission; u32 permission;
uint32_t owner_id; u32 owner_id;
uint32_t group_id; u32 group_id;
uint32_t size; u32 size;
uint32_t alloc_size; u32 alloc_size;
uint64_t quota_size; u64 quota_size;
uint32_t ent_id; u32 ent_id;
uint64_t ctime; u64 ctime;
uint64_t mtime; u64 mtime;
uint8_t attributes[48]; u8 attributes[48];
} __attribute__((packed)) FSStat; } __attribute__((packed)) FSStat;
typedef struct typedef struct
@ -63,7 +63,7 @@ typedef struct
char name[FS_MAX_ENTNAME_SIZE]; char name[FS_MAX_ENTNAME_SIZE];
} FSDirEntry; } FSDirEntry;
typedef void (*FSAsyncCallback)(FSClient * pClient, FSCmdBlock * pCmd, int result, void *context); typedef void (*FSAsyncCallback)(FSClient * pClient, FSCmdBlock * pCmd, s32 result, void *context);
typedef struct typedef struct
{ {
FSAsyncCallback userCallback; FSAsyncCallback userCallback;

View File

@ -44,8 +44,8 @@ EXPORT_DECL(s32, FSRemove, void *pClient, void *pCmd, const char *path, s32 erro
EXPORT_DECL(s32, FSRemoveAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); EXPORT_DECL(s32, FSRemoveAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);
EXPORT_DECL(s32, FSFlushQuota, void *pClient, void *pCmd, const char* path, s32 error); EXPORT_DECL(s32, FSFlushQuota, void *pClient, void *pCmd, const char* path, s32 error);
EXPORT_DECL(s32, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); EXPORT_DECL(s32, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);
EXPORT_DECL(s32, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); EXPORT_DECL(s32, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error);
EXPORT_DECL(s32, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); EXPORT_DECL(s32, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error, void *asyncParams);
EXPORT_DECL(s32, FSRollbackQuota, void *pClient, void *pCmd, const char *path, s32 error); EXPORT_DECL(s32, FSRollbackQuota, void *pClient, void *pCmd, const char *path, s32 error);
EXPORT_DECL(s32, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); EXPORT_DECL(s32, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);

View File

@ -57,8 +57,8 @@ extern s32 (* FSRemove)(void *pClient, void *pCmd, const char *path, s32 error);
extern s32 (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); extern s32 (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);
extern s32 (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, s32 error); extern s32 (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, s32 error);
extern s32 (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); extern s32 (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);
extern s32 (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); extern s32 (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error);
extern s32 (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); extern s32 (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error, void *asyncParams);
extern s32 (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, s32 error); extern s32 (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, s32 error);
extern s32 (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); extern s32 (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams);

View File

@ -29,6 +29,7 @@ u32 nn_act_handle __attribute__((section(".data"))) = 0;
EXPORT_DECL(void, nn_act_Initialize, void); EXPORT_DECL(void, nn_act_Initialize, void);
EXPORT_DECL(void, nn_act_Finalize, void); EXPORT_DECL(void, nn_act_Finalize, void);
EXPORT_DECL(u8, nn_act_GetSlotNo, void); EXPORT_DECL(u8, nn_act_GetSlotNo, void);
EXPORT_DECL(u8, nn_act_GetDefaultAccount, void);
EXPORT_DECL(u32, nn_act_GetPersistentIdEx, u8 slot); EXPORT_DECL(u32, nn_act_GetPersistentIdEx, u8 slot);
void InitAcquireACT(void) void InitAcquireACT(void)
@ -42,7 +43,8 @@ void InitACTFunctionPointers(void)
InitAcquireACT(); InitAcquireACT();
OS_FIND_EXPORT_EX(nn_act_handle, Initialize__Q2_2nn3actFv, nn_act_Initialize) OS_FIND_EXPORT_EX(nn_act_handle, Initialize__Q2_2nn3actFv, nn_act_Initialize)
OS_FIND_EXPORT_EX(nn_act_handle, Finalize__Q2_2nn3actFv, nn_act_Finalize) OS_FIND_EXPORT_EX(nn_act_handle, Finalize__Q2_2nn3actFv, nn_act_Finalize)
OS_FIND_EXPORT_EX(nn_act_handle, GetSlotNo__Q2_2nn3actFv, nn_act_GetSlotNo) OS_FIND_EXPORT_EX(nn_act_handle, GetSlotNo__Q2_2nn3actFv, nn_act_GetSlotNo)
OS_FIND_EXPORT_EX(nn_act_handle, GetPersistentIdEx__Q2_2nn3actFUc, nn_act_GetPersistentIdEx) OS_FIND_EXPORT_EX(nn_act_handle, GetDefaultAccount__Q2_2nn3actFv, nn_act_GetDefaultAccount)
OS_FIND_EXPORT_EX(nn_act_handle, GetPersistentIdEx__Q2_2nn3actFUc, nn_act_GetPersistentIdEx)
} }

View File

@ -35,6 +35,7 @@ extern u32 nn_act_handle;
extern void(* nn_act_Initialize)(void); extern void(* nn_act_Initialize)(void);
extern void(* nn_act_Finalize)(void); extern void(* nn_act_Finalize)(void);
extern u8(* nn_act_GetSlotNo)(void); extern u8(* nn_act_GetSlotNo)(void);
extern u8(* nn_act_GetDefaultAccount)(void);
extern u32(*nn_act_GetPersistentIdEx)(u8 slot); extern u32(*nn_act_GetPersistentIdEx)(u8 slot);
void InitACTFunctionPointers(void); void InitACTFunctionPointers(void);

View File

@ -95,6 +95,7 @@ EXPORT_DECL(s32, __os_snprintf, char* s, s32 n, const char * format, ...);
EXPORT_DECL(s32 *, __gh_errno_ptr, void); EXPORT_DECL(s32 *, __gh_errno_ptr, void);
EXPORT_DECL(void, OSScreenInit, void); EXPORT_DECL(void, OSScreenInit, void);
EXPORT_DECL(void, OSScreenShutdown, void);
EXPORT_DECL(u32, OSScreenGetBufferSizeEx, u32 bufferNum); EXPORT_DECL(u32, OSScreenGetBufferSizeEx, u32 bufferNum);
EXPORT_DECL(s32, OSScreenSetBufferEx, u32 bufferNum, void * addr); EXPORT_DECL(s32, OSScreenSetBufferEx, u32 bufferNum, void * addr);
EXPORT_DECL(s32, OSScreenClearBufferEx, u32 bufferNum, u32 temp); EXPORT_DECL(s32, OSScreenClearBufferEx, u32 bufferNum, u32 temp);
@ -118,9 +119,9 @@ EXPORT_DECL(void *, MEMAllocFromExpHeapEx, s32 heap, u32 size, s32 align);
EXPORT_DECL(s32 , MEMCreateExpHeapEx, void* address, u32 size, unsigned short flags); EXPORT_DECL(s32 , MEMCreateExpHeapEx, void* address, u32 size, unsigned short flags);
EXPORT_DECL(void *, MEMDestroyExpHeap, s32 heap); EXPORT_DECL(void *, MEMDestroyExpHeap, s32 heap);
EXPORT_DECL(void, MEMFreeToExpHeap, s32 heap, void* ptr); EXPORT_DECL(void, MEMFreeToExpHeap, s32 heap, void* ptr);
EXPORT_DECL(void *, OSAllocFromSystem, int size, int alignment); EXPORT_DECL(void *, OSAllocFromSystem, u32 size, s32 alignment);
EXPORT_DECL(void, OSFreeToSystem, void *addr); EXPORT_DECL(void, OSFreeToSystem, void *addr);
EXPORT_DECL(int, OSIsAddressValid, void *ptr); EXPORT_DECL(s32, OSIsAddressValid, void *ptr);
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! MCP functions //! MCP functions
@ -246,6 +247,7 @@ void InitOSFunctionPointers(void)
OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit);
OS_FIND_EXPORT(coreinit_handle, OSScreenInit); OS_FIND_EXPORT(coreinit_handle, OSScreenInit);
OS_FIND_EXPORT(coreinit_handle, OSScreenShutdown);
OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx);
OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx);
OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx);

View File

@ -133,6 +133,7 @@ extern s32 (* __os_snprintf)(char* s, s32 n, const char * format, ...);
extern s32 * (* __gh_errno_ptr)(void); extern s32 * (* __gh_errno_ptr)(void);
extern void (*OSScreenInit)(void); extern void (*OSScreenInit)(void);
extern void (*OSScreenShutdown)(void);
extern u32 (*OSScreenGetBufferSizeEx)(u32 bufferNum); extern u32 (*OSScreenGetBufferSizeEx)(u32 bufferNum);
extern s32 (*OSScreenSetBufferEx)(u32 bufferNum, void * addr); extern s32 (*OSScreenSetBufferEx)(u32 bufferNum, void * addr);
extern s32 (*OSScreenClearBufferEx)(u32 bufferNum, u32 temp); extern s32 (*OSScreenClearBufferEx)(u32 bufferNum, u32 temp);
@ -161,9 +162,9 @@ extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align);
extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags);
extern void *(* MEMDestroyExpHeap)(s32 heap); extern void *(* MEMDestroyExpHeap)(s32 heap);
extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr);
extern void* (* OSAllocFromSystem)(int size, int alignment); extern void* (* OSAllocFromSystem)(u32 size, s32 alignment);
extern void (* OSFreeToSystem)(void *addr); extern void (* OSFreeToSystem)(void *addr);
extern int (* OSIsAddressValid)(void *ptr); extern s32 (* OSIsAddressValid)(void *ptr);
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! MCP functions //! MCP functions

View File

@ -113,7 +113,6 @@ typedef enum OSExceptionType
OS_EXCEPTION_TYPE_ICI = 14, OS_EXCEPTION_TYPE_ICI = 14,
} OSExceptionType; } OSExceptionType;
typedef int (*ThreadFunc)(int argc, void *argv); typedef int (*ThreadFunc)(int argc, void *argv);
struct OSThread_ { struct OSThread_ {
@ -129,12 +128,12 @@ struct OSThread_ {
char _[0x394 - 0x330]; char _[0x394 - 0x330];
void *stackBase; void *stackBase;
void *stackEnd; void *stackEnd;
ThreadFunc entryPoint; ThreadFunc entryPoint;
char _3A0[0x6A0 - 0x3A0]; char _3A0[0x6A0 - 0x3A0];
}; };
typedef struct _OSCalendarTime { typedef struct _OSCalendarTime {

View File

@ -28,8 +28,10 @@ u32 sysapp_handle __attribute__((section(".data"))) = 0;
EXPORT_DECL(s32, _SYSLaunchTitleByPathFromLauncher, const char* path, s32 len, s32 zero); EXPORT_DECL(s32, _SYSLaunchTitleByPathFromLauncher, const char* path, s32 len, s32 zero);
EXPORT_DECL(s32, SYSRelaunchTitle, s32 argc, char** argv); EXPORT_DECL(s32, SYSRelaunchTitle, s32 argc, char** argv);
EXPORT_DECL(s32, SYSLaunchMenu, void); EXPORT_DECL(s32, SYSLaunchMenu, void);
EXPORT_DECL(s32, _SYSLaunchMenuWithCheckingAccount, unsigned char slot);
EXPORT_DECL(s32, SYSCheckTitleExists, u64 titleId); EXPORT_DECL(s32, SYSCheckTitleExists, u64 titleId);
EXPORT_DECL(s32, SYSLaunchTitle, u64 titleId); EXPORT_DECL(s32, SYSLaunchTitle, u64 titleId);
EXPORT_DECL(s32, SYSLaunchSettings, s32 unk);
void InitAcquireSys(void) void InitAcquireSys(void)
{ {
@ -44,6 +46,8 @@ void InitSysFunctionPointers(void)
OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher); OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher);
OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle); OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle);
OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu); OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu);
OS_FIND_EXPORT(sysapp_handle, _SYSLaunchMenuWithCheckingAccount);
OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists); OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists);
OS_FIND_EXPORT(sysapp_handle, SYSLaunchTitle); OS_FIND_EXPORT(sysapp_handle, SYSLaunchTitle);
OS_FIND_EXPORT(sysapp_handle, SYSLaunchSettings);
} }

View File

@ -35,11 +35,13 @@ extern u32 sysapp_handle;
void InitSysFunctionPointers(void); void InitSysFunctionPointers(void);
void InitAcquireSys(void); void InitAcquireSys(void);
extern int(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero); extern s32(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero);
extern int (* SYSRelaunchTitle)(s32 argc, char** argv); extern s32 (* SYSRelaunchTitle)(s32 argc, char** argv);
extern int (* SYSLaunchMenu)(void); extern s32 (* SYSLaunchMenu)(void);
extern int (* SYSCheckTitleExists)(u64 titleId); extern s32 (* _SYSLaunchMenuWithCheckingAccount)(unsigned char slot);
extern int (* SYSLaunchTitle)(u64 titleId); extern s32 (* SYSCheckTitleExists)(u64 titleId);
extern s32 (* SYSLaunchTitle)(u64 titleId);
extern s32 (* SYSLaunchSettings)(s32 unk);
#ifdef __cplusplus #ifdef __cplusplus