From 3c458e8b4893866639734a572a7d8e5ce6c7c1ce Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 5 May 2020 20:13:17 -0400 Subject: Decompile GF funcs responsible for overlays --- arm9/lib/include/CARD_rom.h | 11 +++ arm9/lib/include/FS_archive.h | 90 ++++++++++++++++++++++ arm9/lib/include/FS_file.h | 164 +++++++++++++++++++++++++++++++++++++++++ arm9/lib/include/FS_overlay.h | 42 +++++++++++ arm9/lib/include/MI_exMemory.h | 9 +++ arm9/lib/include/OS_system.h | 1 + arm9/lib/include/OS_thread.h | 8 ++ arm9/lib/include/mmap.h | 2 + arm9/lib/include/mmap_global.h | 4 + 9 files changed, 331 insertions(+) create mode 100644 arm9/lib/include/CARD_rom.h create mode 100644 arm9/lib/include/FS_archive.h create mode 100644 arm9/lib/include/FS_file.h create mode 100644 arm9/lib/include/FS_overlay.h create mode 100644 arm9/lib/include/MI_exMemory.h create mode 100644 arm9/lib/include/mmap_global.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/CARD_rom.h b/arm9/lib/include/CARD_rom.h new file mode 100644 index 00000000..327bc995 --- /dev/null +++ b/arm9/lib/include/CARD_rom.h @@ -0,0 +1,11 @@ +#ifndef NITRO_CARD_ROM_H_ +#define NITRO_CARD_ROM_H_ + +typedef struct +{ + u32 offset; + u32 length; +} +CARDRomRegion; + +#endif //NITRO_CARD_ROM_H_ diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h new file mode 100644 index 00000000..65bb2ea1 --- /dev/null +++ b/arm9/lib/include/FS_archive.h @@ -0,0 +1,90 @@ +#ifndef NITRO_FS_ARCHIVE_H_ +#define NITRO_FS_ARCHIVE_H_ + +#include "nitro.h" + +#include "OS_thread.h" + +struct FSFile; +struct FSArchive; + +typedef enum { + FS_COMMAND_ASYNC_BEGIN = 0, + FS_COMMAND_READFILE = FS_COMMAND_ASYNC_BEGIN, + FS_COMMAND_WRITEFILE, + FS_COMMAND_ASYNC_END, + + FS_COMMAND_SYNC_BEGIN = FS_COMMAND_ASYNC_END, + FS_COMMAND_SEEKDIR = FS_COMMAND_SYNC_BEGIN, + FS_COMMAND_READDIR, + FS_COMMAND_FINDPATH, + FS_COMMAND_GETPATH, + FS_COMMAND_OPENFILEFAST, + FS_COMMAND_OPENFILEDIRECT, + FS_COMMAND_CLOSEFILE, + FS_COMMAND_SYNC_END, + + FS_COMMAND_STATUS_BEGIN = FS_COMMAND_SYNC_END, + FS_COMMAND_ACTIVATE = FS_COMMAND_STATUS_BEGIN, + FS_COMMAND_IDLE, + FS_COMMAND_SUSPEND, + FS_COMMAND_RESUME, + FS_COMMAND_STATUS_END, + + FS_COMMAND_INVALID +} FSCommandType; + +typedef enum { + FS_RESULT_SUCCESS = 0, + FS_RESULT_FAILURE, + FS_RESULT_BUSY, + FS_RESULT_CANCELED, + FS_RESULT_CANCELLED = FS_RESULT_CANCELED, // SDK alias + FS_RESULT_UNSUPPORTED, + FS_RESULT_ERROR, + FS_RESULT_PROC_ASYNC, + FS_RESULT_PROC_DEFAULT, + FS_RESULT_PROC_UNKNOWN +} +FSResult; + +typedef FSResult (*FS_ARCHIVE_READ_FUNC) (struct FSArchive *p, void *dst, u32 pos, u32 size); +typedef FSResult (*FS_ARCHIVE_WRITE_FUNC) (struct FSArchive *p, const void *src, u32 pos, u32 size); +typedef FSResult (*FS_ARCHIVE_PROC_FUNC) (struct FSFile *, FSCommandType); + +typedef struct +{ + struct FSFile * prev; + struct FSFile * next; +} +FSFileLink; + +typedef struct FSArchive +{ + union + { + char ptr[4]; + u32 pack; + } name; + struct FSArchive * prev; + struct FSArchive * next; + OSThreadQueue sync_q; + OSThreadQueue stat_q; + u32 flag; + FSFileLink list; + u32 base; + u32 fat; + u32 fat_size; + u32 fnt; + u32 fnt_size; + u32 fat_bak; + u32 fnt_bak; + void * load_mem; + FS_ARCHIVE_READ_FUNC read_func; + FS_ARCHIVE_WRITE_FUNC write_func; + FS_ARCHIVE_READ_FUNC table_func; + FS_ARCHIVE_PROC_FUNC proc; + u32 proc_flag; +} FSArchive; + +#endif //NITRO_FS_ARCHIVE_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h new file mode 100644 index 00000000..08a698d0 --- /dev/null +++ b/arm9/lib/include/FS_file.h @@ -0,0 +1,164 @@ +#ifndef NITRO_FS_FILE_H_ +#define NITRO_FS_FILE_H_ + +#include "nitro.h" + +#include "FS_archive.h" + +struct FSFile; + +#define FS_DMA_NOT_USE ((u32)~0) + +typedef struct FSDirPos +{ + struct FSArchive *arc; + u16 own_id; + u16 index; + u32 pos; +} +FSDirPos; + +typedef struct FSFileID +{ + struct FSArchive *arc; + u32 file_id; +} +FSFileID; + +typedef struct +{ + union + { + FSFileID file_id; + FSDirPos dir_id; + }; + u32 is_directory; + u32 name_len; + char name[128]; +} +FSDirEntry; + + +typedef struct +{ + FSDirPos pos; +} +FSSeekDirInfo; + + +typedef struct +{ + FSDirEntry *p_entry; + BOOL skip_string; +} +FSReadDirInfo; + + +typedef struct +{ + FSDirPos pos; + const char *path; + BOOL find_directory; + union + { + FSFileID *file; + FSDirPos *dir; + } + result; +} +FSFindPathInfo; + + +typedef struct +{ + u8 *buf; + u32 buf_len; + u16 total_len; + u16 dir_id; +} +FSGetPathInfo; + + +typedef struct +{ + FSFileID id; +} +FSOpenFileFastInfo; + + +typedef struct +{ + u32 top; + u32 bottom; + u32 index; +} +FSOpenFileDirectInfo; + + +typedef struct +{ + u32 reserved; +} +FSCloseFileInfo; + + +typedef struct +{ + void *dst; + u32 len_org; + u32 len; +} +FSReadFileInfo; + + +typedef struct +{ + const void *src; + u32 len_org; + u32 len; +} +FSWriteFileInfo; + +typedef struct FSFile +{ + FSFileLink link; + struct FSArchive *arc; + u32 stat; + FSCommandType command; + FSResult error; + OSThreadQueue queue[1]; + u32 filler; // Figure out what this actually is + union { + struct + { + u32 own_id; + u32 top; + u32 bottom; + u32 pos; + } file; + struct + { + FSDirPos pos; + u32 parent; + } dir; + } prop; + + union { + FSReadFileInfo readfile; + FSWriteFileInfo writefile; + + FSSeekDirInfo seekdir; + FSReadDirInfo readdir; + FSFindPathInfo findpath; + FSGetPathInfo getpath; + FSOpenFileFastInfo openfilefast; + FSOpenFileDirectInfo openfiledirect; + FSCloseFileInfo closefile; + }; +} +FSFile; + +u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection +void FS_InitFile(FSFile * p_file); + +#endif //NITRO_FS_FILE_H_ diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h new file mode 100644 index 00000000..967169aa --- /dev/null +++ b/arm9/lib/include/FS_overlay.h @@ -0,0 +1,42 @@ +#ifndef NITRO_FS_OVERLAY_H_ +#define NITRO_FS_OVERLAY_H_ + +#include "nitro.h" +#include "MI_exMemory.h" +#include "FS_file.h" +#include "CARD_rom.h" + +typedef u32 FSOverlayID; + +typedef void (*FSOverlayInitFunc) (void); + +typedef struct FSOverlayInfoHeader +{ + u32 id; + u8 *ram_address; + u32 ram_size; + u32 bss_size; + FSOverlayInitFunc *sinit_init; + FSOverlayInitFunc *sinit_init_end; + u32 file_id; + u32 compressed:24; + u32 flag:8; +} FSOverlayInfoHeader; + +typedef struct FSOverlayInfo +{ + FSOverlayInfoHeader header; + MIProcessor target; + CARDRomRegion file_pos; +} FSOverlayInfo; + +BOOL FS_LoadOverlayInfo(FSOverlayInfo *p_ovi, MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlayImage(FSOverlayInfo *p_ovi); +void FS_StartOverlay(FSOverlayInfo *p_ovi); +BOOL FS_LoadOverlayImageAsync(FSOverlayInfo *p_ovi, FSFile *p_file); +void FS_WaitAsync(FSFile *p_file); +void FS_CloseFile(FSFile *p_file); + +#endif //NITRO_FS_OVERLAY_H_ diff --git a/arm9/lib/include/MI_exMemory.h b/arm9/lib/include/MI_exMemory.h new file mode 100644 index 00000000..4a8a10a8 --- /dev/null +++ b/arm9/lib/include/MI_exMemory.h @@ -0,0 +1,9 @@ +#ifndef NITRO_MI_EXMEMORY_H_ +#define NITRO_MI_EXMEMORY_H_ + +typedef enum { + MI_PROCESSOR_ARM9 = 0, + MI_PROCESSOR_ARM7 = 1 +} MIProcessor; + +#endif //NITRO_MI_EXMEMORY_H_ diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 93903315..794e16d2 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -5,6 +5,7 @@ #ifndef POKEDIAMOND_OS_SYSTEM_H #define POKEDIAMOND_OS_SYSTEM_H +#include "function_target.h" #include "consts.h" typedef enum { diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h index 4fb70bf7..207dac1b 100644 --- a/arm9/lib/include/OS_thread.h +++ b/arm9/lib/include/OS_thread.h @@ -7,6 +7,14 @@ typedef struct _OSThread OSThread; +struct _OSThreadQueue +{ + OSThread *head; + OSThread *tail; +}; + +typedef struct _OSThreadQueue OSThreadQueue; + typedef struct OSThreadInfo { u16 isNeedRescheduling; u16 irqDepth; diff --git a/arm9/lib/include/mmap.h b/arm9/lib/include/mmap.h index d94df843..56ae08c8 100644 --- a/arm9/lib/include/mmap.h +++ b/arm9/lib/include/mmap.h @@ -12,8 +12,10 @@ extern u32 SDK_AUTOLOAD_DTCM_START[]; #define HW_MAIN_MEM_SHARED_SIZE 0x00001000 #define HW_MAIN_MEM_DEBUGGER_OFFSET 0x00700000 +#define HW_ITCM_IMAGE 0x01000000 #define HW_ITCM 0x01FF8000 #define HW_ITCM_SIZE 0x00008000 +#define HW_ITCM_END (HW_ITCM + HW_ITCM_SIZE) #define HW_WRAM 0x037F8000 diff --git a/arm9/lib/include/mmap_global.h b/arm9/lib/include/mmap_global.h new file mode 100644 index 00000000..e657e46f --- /dev/null +++ b/arm9/lib/include/mmap_global.h @@ -0,0 +1,4 @@ +#ifndef NITRO_MMAP_GLOBAL_H_ +#define NITRO_MMAP_GLOBAL_H_ + +#endif //NITRO_MMAP_GLOBAL_H_ -- cgit v1.2.3 From cd5559a2093c2be1167eba2f2ef38eedb32a8a1d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 5 May 2020 21:59:23 -0400 Subject: Decompile FS_file.c --- arm9/lib/include/FS_archive.h | 23 +++++++++++++++++++++++ arm9/lib/include/FS_file.h | 19 +++++++++++++++++-- arm9/lib/include/FS_rom.h | 6 ++++++ arm9/lib/include/MI_byteAccess.h | 9 +++++++++ arm9/lib/include/OS_thread.h | 6 ++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 arm9/lib/include/FS_rom.h create mode 100644 arm9/lib/include/MI_byteAccess.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index 65bb2ea1..66840b32 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -8,6 +8,19 @@ struct FSFile; struct FSArchive; +#define FS_ARCHIVE_NAME_LEN_MAX 3 + +#define FS_ARCHIVE_FLAG_REGISTER 0x00000001 +#define FS_ARCHIVE_FLAG_LOADED 0x00000002 +#define FS_ARCHIVE_FLAG_TABLE_LOAD 0x00000004 +#define FS_ARCHIVE_FLAG_SUSPEND 0x00000008 +#define FS_ARCHIVE_FLAG_RUNNING 0x00000010 +#define FS_ARCHIVE_FLAG_CANCELING 0x00000020 +#define FS_ARCHIVE_FLAG_SUSPENDING 0x00000040 +#define FS_ARCHIVE_FLAG_UNLOADING 0x00000080 +#define FS_ARCHIVE_FLAG_IS_ASYNC 0x00000100 +#define FS_ARCHIVE_FLAG_IS_SYNC 0x00000200 + typedef enum { FS_COMMAND_ASYNC_BEGIN = 0, FS_COMMAND_READFILE = FS_COMMAND_ASYNC_BEGIN, @@ -87,4 +100,14 @@ typedef struct FSArchive u32 proc_flag; } FSArchive; +FSArchive * const FS_FindArchive(const char * path, int offset); + +static inline BOOL FS_IsArchiveLoaded(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_LOADED) ? TRUE : FALSE; +} + +BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); +BOOL FSi_ExecuteSyncCommand(struct FSFile * file); + #endif //NITRO_FS_ARCHIVE_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 08a698d0..4871b660 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -5,6 +5,21 @@ #include "FS_archive.h" +#define FS_FILE_STATUS_BUSY 0x00000001 +#define FS_FILE_STATUS_CANCEL 0x00000002 +#define FS_FILE_STATUS_SYNC 0x00000004 +#define FS_FILE_STATUS_ASYNC 0x00000008 +#define FS_FILE_STATUS_IS_FILE 0x00000010 +#define FS_FILE_STATUS_IS_DIR 0x00000020 +#define FS_FILE_STATUS_OPERATING 0x00000040 + +typedef enum FSSeekFileMode +{ + FS_SEEK_SET = 0, + FS_SEEK_CUR, + FS_SEEK_END +} FSSeekFileMode; + struct FSFile; #define FS_DMA_NOT_USE ((u32)~0) @@ -127,7 +142,6 @@ typedef struct FSFile FSCommandType command; FSResult error; OSThreadQueue queue[1]; - u32 filler; // Figure out what this actually is union { struct { @@ -154,11 +168,12 @@ typedef struct FSFile FSOpenFileFastInfo openfilefast; FSOpenFileDirectInfo openfiledirect; FSCloseFileInfo closefile; - }; + } arg; } FSFile; u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection void FS_InitFile(FSFile * p_file); +BOOL FS_WaitAsync(FSFile * p_file); #endif //NITRO_FS_FILE_H_ diff --git a/arm9/lib/include/FS_rom.h b/arm9/lib/include/FS_rom.h new file mode 100644 index 00000000..fc62b579 --- /dev/null +++ b/arm9/lib/include/FS_rom.h @@ -0,0 +1,6 @@ +#ifndef NITRO_FS_ROM_H_ +#define NITRO_FS_ROM_H_ + +void FSi_InitRom(u32 default_dma_no); + +#endif //NITRO_FS_ROM_H_ diff --git a/arm9/lib/include/MI_byteAccess.h b/arm9/lib/include/MI_byteAccess.h new file mode 100644 index 00000000..10dae4c9 --- /dev/null +++ b/arm9/lib/include/MI_byteAccess.h @@ -0,0 +1,9 @@ +#ifndef NITRO_MI_BYTEACCESS_H_ +#define NITRO_MI_BYTEACCESS_H_ + +static inline u8 MI_ReadByte(const void *address) +{ + return *(u8 *)address; +} + +#endif //NITRO_MI_BYTEACCESS_H_ diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h index 207dac1b..8820a7a0 100644 --- a/arm9/lib/include/OS_thread.h +++ b/arm9/lib/include/OS_thread.h @@ -28,4 +28,10 @@ struct _OSThread u8 padding[0x80]; //todo: not the correct size but idfk }; +void OS_SleepThread(OSThreadQueue * queue); +static inline void OS_InitThreadQueue(OSThreadQueue * queue) +{ + queue->head = queue->tail = NULL; +} + #endif //POKEDIAMOND_OS_THREAD_H -- cgit v1.2.3 From c8230ac1a65a367f7796a2c8afed9533ba135faf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 5 May 2020 22:08:55 -0400 Subject: Fix matching --- arm9/lib/include/FS_overlay.h | 1 - 1 file changed, 1 deletion(-) (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h index 967169aa..c2634509 100644 --- a/arm9/lib/include/FS_overlay.h +++ b/arm9/lib/include/FS_overlay.h @@ -36,7 +36,6 @@ BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); BOOL FS_LoadOverlayImage(FSOverlayInfo *p_ovi); void FS_StartOverlay(FSOverlayInfo *p_ovi); BOOL FS_LoadOverlayImageAsync(FSOverlayInfo *p_ovi, FSFile *p_file); -void FS_WaitAsync(FSFile *p_file); void FS_CloseFile(FSFile *p_file); #endif //NITRO_FS_OVERLAY_H_ -- cgit v1.2.3 From 9f3c697d9dee85da8c9bf4f708a340d5023194ec Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 May 2020 18:14:26 -0400 Subject: FS_overlay.c --- arm9/lib/include/CARD_rom.h | 9 +++++++++ arm9/lib/include/DGT_common.h | 6 ++++++ arm9/lib/include/DGT_dgt.h | 6 ++++++ arm9/lib/include/FS_file.h | 13 +++++++++++++ arm9/lib/include/FS_mw_dtor.h | 16 ++++++++++++++++ arm9/lib/include/FS_overlay.h | 15 +++++++++++++++ arm9/lib/include/FS_rom.h | 7 +++++++ arm9/lib/include/MI_memory.h | 10 ++++++++++ arm9/lib/include/MI_uncompress.h | 6 ++++++ arm9/lib/include/OS_cache.h | 9 +++++++++ arm9/lib/include/OS_system.h | 5 +++++ 11 files changed, 102 insertions(+) create mode 100644 arm9/lib/include/DGT_common.h create mode 100644 arm9/lib/include/DGT_dgt.h create mode 100644 arm9/lib/include/FS_mw_dtor.h create mode 100644 arm9/lib/include/MI_memory.h create mode 100644 arm9/lib/include/MI_uncompress.h create mode 100644 arm9/lib/include/OS_cache.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/CARD_rom.h b/arm9/lib/include/CARD_rom.h index 327bc995..c43a2f06 100644 --- a/arm9/lib/include/CARD_rom.h +++ b/arm9/lib/include/CARD_rom.h @@ -1,6 +1,8 @@ #ifndef NITRO_CARD_ROM_H_ #define NITRO_CARD_ROM_H_ +#include "MI_exMemory.h" + typedef struct { u32 offset; @@ -8,4 +10,11 @@ typedef struct } CARDRomRegion; +static inline const CARDRomRegion * CARD_GetRomRegionOVT(MIProcessor target) +{ + return (target == MI_PROCESSOR_ARM9) + ? (const CARDRomRegion *)((const u8 *)HW_ROM_HEADER_BUF + 0x50) + : (const CARDRomRegion *)((const u8 *)HW_ROM_HEADER_BUF + 0x58); +} + #endif //NITRO_CARD_ROM_H_ diff --git a/arm9/lib/include/DGT_common.h b/arm9/lib/include/DGT_common.h new file mode 100644 index 00000000..c74ae7cd --- /dev/null +++ b/arm9/lib/include/DGT_common.h @@ -0,0 +1,6 @@ +#ifndef NITRO_DGT_COMMON_H_ +#define NITRO_DGT_COMMON_H_ + +#define DGT_HASH2_DIGEST_SIZE (160/8) + +#endif //NITRO_DGT_COMMON_H_ diff --git a/arm9/lib/include/DGT_dgt.h b/arm9/lib/include/DGT_dgt.h new file mode 100644 index 00000000..1c48531c --- /dev/null +++ b/arm9/lib/include/DGT_dgt.h @@ -0,0 +1,6 @@ +#ifndef NITRO_DGT_DGT_H_ +#define NITRO_DGT_DGT_H_ + +void DGT_Hash2CalcHmac(void* digest, void* bin_ptr, int bin_len, void* key_ptr, int keylen); + +#endif //NITRO_DGT_DGT_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 4871b660..89f69d86 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -175,5 +175,18 @@ FSFile; u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection void FS_InitFile(FSFile * p_file); BOOL FS_WaitAsync(FSFile * p_file); +BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 image_bottom, u32 file_index); +int FS_ReadFile(FSFile * p_file, void * dst, s32 len); +int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); +BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); + +static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { + return p_file->prop.file.top; +} + +static inline u32 const FS_GetLength(volatile const FSFile * p_file) +{ + return p_file->prop.file.bottom - p_file->prop.file.top; +} #endif //NITRO_FS_FILE_H_ diff --git a/arm9/lib/include/FS_mw_dtor.h b/arm9/lib/include/FS_mw_dtor.h new file mode 100644 index 00000000..a746ed19 --- /dev/null +++ b/arm9/lib/include/FS_mw_dtor.h @@ -0,0 +1,16 @@ +#ifndef NITRO_FS_MW_DTOR_H_ +#define NITRO_FS_MW_DTOR_H_ + +typedef void (*MWI_DESTRUCTOR_FUNC) (void *); + +typedef struct MWiDestructorChain +{ + struct MWiDestructorChain *next; + MWI_DESTRUCTOR_FUNC dtor; + void *obj; +} +MWiDestructorChain; + +extern MWiDestructorChain *__global_destructor_chain; + +#endif //NITRO_FS_MW_DTOR_H_ diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h index c2634509..1ef6469c 100644 --- a/arm9/lib/include/FS_overlay.h +++ b/arm9/lib/include/FS_overlay.h @@ -30,6 +30,21 @@ typedef struct FSOverlayInfo CARDRomRegion file_pos; } FSOverlayInfo; +static inline u8 *const FS_GetOverlayAddress(FSOverlayInfo * p_ovi) +{ + return p_ovi->header.ram_address; +} + +static inline u32 const FS_GetOverlayImageSize(FSOverlayInfo * p_ovi) +{ + return p_ovi->header.ram_size; +} + +static inline u32 const FS_GetOverlayTotalSize(FSOverlayInfo * p_ovi) +{ + return p_ovi->header.ram_size + p_ovi->header.bss_size; +} + BOOL FS_LoadOverlayInfo(FSOverlayInfo *p_ovi, MIProcessor target, FSOverlayID id); BOOL FS_LoadOverlay(MIProcessor target, FSOverlayID id); BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); diff --git a/arm9/lib/include/FS_rom.h b/arm9/lib/include/FS_rom.h index fc62b579..0bba46bf 100644 --- a/arm9/lib/include/FS_rom.h +++ b/arm9/lib/include/FS_rom.h @@ -1,6 +1,13 @@ #ifndef NITRO_FS_ROM_H_ #define NITRO_FS_ROM_H_ +#include "FS_archive.h" +#include "CARD_rom.h" + +extern FSArchive fsi_arc_rom; +extern CARDRomRegion fsi_ovt7; +extern CARDRomRegion fsi_ovt9; + void FSi_InitRom(u32 default_dma_no); #endif //NITRO_FS_ROM_H_ diff --git a/arm9/lib/include/MI_memory.h b/arm9/lib/include/MI_memory.h new file mode 100644 index 00000000..d9935a5f --- /dev/null +++ b/arm9/lib/include/MI_memory.h @@ -0,0 +1,10 @@ +#ifndef NITRO_MI_MEMORY_H_ +#define NITRO_MI_MEMORY_H_ + +void MI_CpuFill8(void *dest, u8 data, u32 size); +void MI_CpuCopy8(void const *src, void *dest, u32 size); +static inline void MI_CpuClear8(void *dest, u32 size) { + MI_CpuFill8(dest, 0, size); +} + +#endif //NITRO_MI_MEMORY_H_ diff --git a/arm9/lib/include/MI_uncompress.h b/arm9/lib/include/MI_uncompress.h new file mode 100644 index 00000000..55f28e27 --- /dev/null +++ b/arm9/lib/include/MI_uncompress.h @@ -0,0 +1,6 @@ +#ifndef NITRO_MI_UNCOMPRESS_H_ +#define NITRO_MI_UNCOMPRESS_H_ + +void MIi_UncompressBackward(void * bottom); + +#endif //NITRO_MI_UNCOMPRESS_H_ diff --git a/arm9/lib/include/OS_cache.h b/arm9/lib/include/OS_cache.h new file mode 100644 index 00000000..bee42d45 --- /dev/null +++ b/arm9/lib/include/OS_cache.h @@ -0,0 +1,9 @@ +#ifndef NITRO_OS_CACHE_H_ +#define NITRO_OS_CACHE_H_ + +void IC_InvalidateRange(void *startAddr, u32 nBytes); +void IC_FlushRange(void *startAddr, u32 nBytes); +void DC_InvalidateRange(void *startAddr, u32 nBytes); +void DC_FlushRange(void *startAddr, u32 nBytes); + +#endif //NITRO_OS_CACHE_H_ diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 65c58f57..1b263b19 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -36,5 +36,10 @@ OSIntrMode OS_GetCpsrIrq(); OSProcMode OS_GetProcMode(); void OS_SpinWait(); void OS_WaitVBlankIntr(); +void OS_Terminate(void); +static inline void OS_TPanic(const char * message) +{ + OS_Terminate(); +} #endif //POKEDIAMOND_OS_SYSTEM_H -- cgit v1.2.3 From d4575098dbd671e2b6fd27ad65b984502c90465b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 08:52:32 -0400 Subject: FS_archive.c WIP --- arm9/lib/include/FS_archive.h | 56 +++++++++++++++++++++++++++++++++++++++++++ arm9/lib/include/FS_command.h | 9 +++++++ arm9/lib/include/FS_file.h | 20 ++++++++++++++++ arm9/lib/include/OS_thread.h | 1 + 4 files changed, 86 insertions(+) create mode 100644 arm9/lib/include/FS_command.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index 66840b32..b39e7738 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -47,6 +47,37 @@ typedef enum { FS_COMMAND_INVALID } FSCommandType; +/* Asynchronous commands*/ +#define FS_ARCHIVE_PROC_READFILE (1 << FS_COMMAND_READFILE) +#define FS_ARCHIVE_PROC_WRITEFILE (1 << FS_COMMAND_WRITEFILE) +/* All asynchronous commands*/ +#define FS_ARCHIVE_PROC_ASYNC \ + (FS_ARCHIVE_PROC_READFILE | FS_ARCHIVE_PROC_WRITEFILE) + +/* Synchronous commands*/ +#define FS_ARCHIVE_PROC_SEEKDIR (1 << FS_COMMAND_SEEKDIR) +#define FS_ARCHIVE_PROC_READDIR (1 << FS_COMMAND_READDIR) +#define FS_ARCHIVE_PROC_FINDPATH (1 << FS_COMMAND_FINDPATH) +#define FS_ARCHIVE_PROC_GETPATH (1 << FS_COMMAND_GETPATH) +#define FS_ARCHIVE_PROC_OPENFILEFAST (1 << FS_COMMAND_OPENFILEFAST) +#define FS_ARCHIVE_PROC_OPENFILEDIRECT (1 << FS_COMMAND_OPENFILEDIRECT) +#define FS_ARCHIVE_PROC_CLOSEFILE (1 << FS_COMMAND_CLOSEFILE) +/* All synchronous commands*/ +#define FS_ARCHIVE_PROC_SYNC \ + (FS_ARCHIVE_PROC_SEEKDIR | FS_ARCHIVE_PROC_READDIR | \ + FS_ARCHIVE_PROC_FINDPATH | FS_ARCHIVE_PROC_GETPATH | \ + FS_ARCHIVE_PROC_OPENFILEFAST | FS_ARCHIVE_PROC_OPENFILEDIRECT | FS_ARCHIVE_PROC_CLOSEFILE) + +/* Messages when status changes*/ +#define FS_ARCHIVE_PROC_ACTIVATE (1 << FS_COMMAND_ACTIVATE) +#define FS_ARCHIVE_PROC_IDLE (1 << FS_COMMAND_IDLE) +#define FS_ARCHIVE_PROC_SUSPENDING (1 << FS_COMMAND_SUSPEND) +#define FS_ARCHIVE_PROC_RESUME (1 << FS_COMMAND_RESUME) +/* All messages when status changes*/ +#define FS_ARCHIVE_PROC_STATUS \ + (FS_ARCHIVE_PROC_ACTIVATE | FS_ARCHIVE_PROC_IDLE | \ + FS_ARCHIVE_PROC_SUSPENDING | FS_ARCHIVE_PROC_RESUME) + typedef enum { FS_RESULT_SUCCESS = 0, FS_RESULT_FAILURE, @@ -107,6 +138,31 @@ static inline BOOL FS_IsArchiveLoaded(volatile const FSArchive * p_arc) return (p_arc->flag & FS_ARCHIVE_FLAG_LOADED) ? TRUE : FALSE; } +static inline u32 FS_GetArchiveOffset(const FSArchive * p_arc, u32 pos) +{ + return p_arc->base + pos; +} + +static inline BOOL FSi_IsArchiveCanceling(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_CANCELING) != 0; +} + +static inline BOOL FS_IsArchiveSuspended(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_SUSPEND) ? TRUE : FALSE; +} + +static inline BOOL FSi_IsArchiveSuspending(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_SUSPENDING) != 0; +} + +static inline BOOL FSi_IsArchiveRunning(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_RUNNING) != 0; +} + BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); BOOL FSi_ExecuteSyncCommand(struct FSFile * file); diff --git a/arm9/lib/include/FS_command.h b/arm9/lib/include/FS_command.h new file mode 100644 index 00000000..db878f3f --- /dev/null +++ b/arm9/lib/include/FS_command.h @@ -0,0 +1,9 @@ +#ifndef NITRO_FS_COMMAND_H_ +#define NITRO_FS_COMMAND_H_ + +#include "FS_file.h" + +void FSi_ReleaseCommand(FSFile * file, FSResult signal); +FSResult FSi_TranslateCommand(FSFile * file, FSCommandType command); + +#endif //NITRO_FS_COMMAND_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 89f69d86..92e2149e 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -189,4 +189,24 @@ static inline u32 const FS_GetLength(volatile const FSFile * p_file) return p_file->prop.file.bottom - p_file->prop.file.top; } +static inline BOOL FS_IsCanceling(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_CANCEL) ? TRUE : FALSE; +} + +static inline BOOL FS_IsFileSyncMode(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_SYNC) ? TRUE : FALSE; +} + +static inline BOOL FS_IsBusy(volatile const FSFile * p_file) +{ + return p_file->stat & FS_FILE_STATUS_BUSY ? TRUE : FALSE; +} + +static inline BOOL FS_IsSucceeded(volatile const FSFile * p_file) +{ + return (p_file->error == FS_RESULT_SUCCESS) ? TRUE : FALSE; +} + #endif //NITRO_FS_FILE_H_ diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h index 8820a7a0..c5602559 100644 --- a/arm9/lib/include/OS_thread.h +++ b/arm9/lib/include/OS_thread.h @@ -29,6 +29,7 @@ struct _OSThread }; void OS_SleepThread(OSThreadQueue * queue); +void OS_WakeupThread(OSThreadQueue * queue); static inline void OS_InitThreadQueue(OSThreadQueue * queue) { queue->head = queue->tail = NULL; -- cgit v1.2.3 From 13ecb2f5cb0bbfee814508f6d05d05074d426807 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 16:42:49 -0400 Subject: FS_archive through FS_LoadArchive --- arm9/lib/include/FS_archive.h | 7 ++++++- arm9/lib/include/FSi_util.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 arm9/lib/include/FSi_util.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index b39e7738..baf11add 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -110,8 +110,8 @@ typedef struct FSArchive char ptr[4]; u32 pack; } name; - struct FSArchive * prev; struct FSArchive * next; + struct FSArchive * prev; OSThreadQueue sync_q; OSThreadQueue stat_q; u32 flag; @@ -163,6 +163,11 @@ static inline BOOL FSi_IsArchiveRunning(volatile const FSArchive * p_arc) return (p_arc->flag & FS_ARCHIVE_FLAG_RUNNING) != 0; } +static inline BOOL FSi_IsArchiveUnloading(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_UNLOADING) != 0; +} + BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); BOOL FSi_ExecuteSyncCommand(struct FSFile * file); diff --git a/arm9/lib/include/FSi_util.h b/arm9/lib/include/FSi_util.h new file mode 100644 index 00000000..babb6d75 --- /dev/null +++ b/arm9/lib/include/FSi_util.h @@ -0,0 +1,33 @@ +#ifndef NITRO_FSI_UTIL_H_ +#define NITRO_FSI_UTIL_H_ + +static inline BOOL FSi_IsSlash(u32 c) +{ + return (c == '/') || (c == '\\'); +} + +static inline void FSi_CutFromListCore(FSFileLink *trg) +{ + FSFile *const pr = trg->prev; + FSFile *const nx = trg->next; + if (pr) + pr->link.next = nx; + if (nx) + nx->link.prev = pr; +} + +static inline void FSi_AppendToList(FSFile *elem, FSFile *list) +{ + FSFileLink *const trg = &elem->link; + FSi_CutFromListCore(trg); + { + while (list->link.next) + list = list->link.next; + list->link.next = elem; + trg->prev = list; + trg->next = NULL; + } +} + + +#endif //NITRO_FSI_UTIL_H_ -- cgit v1.2.3 From 34ec05f983cec0517765640d084f58e86aa20d79 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 17:53:16 -0400 Subject: Finish FS_archive.c --- arm9/lib/include/FS_archive.h | 12 ++++++++++++ arm9/lib/include/FS_file.h | 1 + arm9/lib/include/FS_overlay.h | 13 ++++++------- arm9/lib/include/FSi_util.h | 4 ++++ arm9/lib/include/OS_system.h | 6 ++---- 5 files changed, 25 insertions(+), 11 deletions(-) (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index baf11add..a86478e8 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -168,7 +168,19 @@ static inline BOOL FSi_IsArchiveUnloading(volatile const FSArchive * p_arc) return (p_arc->flag & FS_ARCHIVE_FLAG_UNLOADING) != 0; } +static inline BOOL FSi_IsArchiveAsync(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_IS_ASYNC) != 0; +} + +static inline BOOL FS_IsArchiveTableLoaded(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_TABLE_LOAD) ? TRUE : FALSE; +} + BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); BOOL FSi_ExecuteSyncCommand(struct FSFile * file); +BOOL FS_SuspendArchive(FSArchive * p_arc); +BOOL FS_ResumeArchive(FSArchive * p_arc); #endif //NITRO_FS_ARCHIVE_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 92e2149e..fdf6c4e2 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -179,6 +179,7 @@ BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 im int FS_ReadFile(FSFile * p_file, void * dst, s32 len); int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); +BOOL FS_CloseFile(FSFile * p_file); static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { return p_file->prop.file.top; diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h index 1ef6469c..6025d04a 100644 --- a/arm9/lib/include/FS_overlay.h +++ b/arm9/lib/include/FS_overlay.h @@ -45,12 +45,11 @@ static inline u32 const FS_GetOverlayTotalSize(FSOverlayInfo * p_ovi) return p_ovi->header.ram_size + p_ovi->header.bss_size; } -BOOL FS_LoadOverlayInfo(FSOverlayInfo *p_ovi, MIProcessor target, FSOverlayID id); -BOOL FS_LoadOverlay(MIProcessor target, FSOverlayID id); -BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); -BOOL FS_LoadOverlayImage(FSOverlayInfo *p_ovi); -void FS_StartOverlay(FSOverlayInfo *p_ovi); -BOOL FS_LoadOverlayImageAsync(FSOverlayInfo *p_ovi, FSFile *p_file); -void FS_CloseFile(FSFile *p_file); +BOOL FS_LoadOverlayInfo(FSOverlayInfo *p_ovi, MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlayImage(FSOverlayInfo *p_ovi); +void FS_StartOverlay(FSOverlayInfo *p_ovi); +BOOL FS_LoadOverlayImageAsync(FSOverlayInfo *p_ovi, FSFile *p_file); #endif //NITRO_FS_OVERLAY_H_ diff --git a/arm9/lib/include/FSi_util.h b/arm9/lib/include/FSi_util.h index babb6d75..1012df13 100644 --- a/arm9/lib/include/FSi_util.h +++ b/arm9/lib/include/FSi_util.h @@ -1,6 +1,10 @@ #ifndef NITRO_FSI_UTIL_H_ #define NITRO_FSI_UTIL_H_ +#define ALIGN_MASK(a) ((u32)((a) - 1)) + +#define ALIGN_BYTE(n, a) (((u32)(n) + ALIGN_MASK(a)) & ~ALIGN_MASK(a)) + static inline BOOL FSi_IsSlash(u32 c) { return (c == '/') || (c == '\\'); diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 1b263b19..88137c3b 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -37,9 +37,7 @@ OSProcMode OS_GetProcMode(); void OS_SpinWait(); void OS_WaitVBlankIntr(); void OS_Terminate(void); -static inline void OS_TPanic(const char * message) -{ - OS_Terminate(); -} +#define OS_TPanic(...) OS_Terminate() +#define OS_TWarning(...) ((void)0) #endif //POKEDIAMOND_OS_SYSTEM_H -- cgit v1.2.3 From 994cfcbc9a1e42043b25ae3ab6471b8ecbd55ff1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 19:39:53 -0400 Subject: FS_rom.c --- arm9/lib/include/CARD_common.h | 6 ++++++ arm9/lib/include/CARD_pullOut.h | 6 ++++++ arm9/lib/include/CARD_rom.h | 19 +++++++++++++++++++ arm9/lib/include/FS_archive.h | 8 ++++++++ arm9/lib/include/FS_rom.h | 1 + arm9/lib/include/MI_dma.h | 6 ++++++ arm9/lib/include/OS_printf.h | 6 ++++++ arm9/lib/include/OS_spinLock.h | 2 ++ 8 files changed, 54 insertions(+) create mode 100644 arm9/lib/include/CARD_common.h create mode 100644 arm9/lib/include/CARD_pullOut.h create mode 100644 arm9/lib/include/MI_dma.h create mode 100644 arm9/lib/include/OS_printf.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/CARD_common.h b/arm9/lib/include/CARD_common.h new file mode 100644 index 00000000..1396de12 --- /dev/null +++ b/arm9/lib/include/CARD_common.h @@ -0,0 +1,6 @@ +#ifndef NITRO_CARD_COMMON_H_ +#define NITRO_CARD_COMMON_H_ + +void CARD_Init(void); + +#endif //NITRO_CARD_COMMON_H_ diff --git a/arm9/lib/include/CARD_pullOut.h b/arm9/lib/include/CARD_pullOut.h new file mode 100644 index 00000000..4a64f5ae --- /dev/null +++ b/arm9/lib/include/CARD_pullOut.h @@ -0,0 +1,6 @@ +#ifndef NITRO_CARD_PULLOUT_H_ +#define NITRO_CARD_PULLOUT_H_ + +BOOL CARD_IsPulledOut(void); + +#endif //NITRO_CARD_PULLOUT_H_ diff --git a/arm9/lib/include/CARD_rom.h b/arm9/lib/include/CARD_rom.h index c43a2f06..4c2e9dd5 100644 --- a/arm9/lib/include/CARD_rom.h +++ b/arm9/lib/include/CARD_rom.h @@ -2,6 +2,7 @@ #define NITRO_CARD_ROM_H_ #include "MI_exMemory.h" +#include "MI_dma.h" typedef struct { @@ -17,4 +18,22 @@ static inline const CARDRomRegion * CARD_GetRomRegionOVT(MIProcessor target) : (const CARDRomRegion *)((const u8 *)HW_ROM_HEADER_BUF + 0x58); } +void CARDi_ReadRom(u32 dma, const void * src, void * dst, u32 len, MIDmaCallback done_cb, void * arg, BOOL is_async); + +static inline void CARD_ReadRomAsync(u32 dma, const void * src, void * dst, u32 len, MIDmaCallback callback, void * arg) +{ + CARDi_ReadRom(dma, src, dst, len, callback, arg, TRUE); +} + +void CARD_LockRom(u16 lock_id); +void CARD_UnlockRom(u16 lock_id); + +static inline const CARDRomRegion * CARD_GetRomRegionFNT() { + return (const CARDRomRegion *)((const u8 *)HW_ROM_HEADER_BUF + 0x40); +} + +static inline const CARDRomRegion * CARD_GetRomRegionFAT() { + return (const CARDRomRegion *)((const u8 *)HW_ROM_HEADER_BUF + 0x48); +} + #endif //NITRO_CARD_ROM_H_ diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index a86478e8..d7c2a785 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -78,6 +78,8 @@ typedef enum { (FS_ARCHIVE_PROC_ACTIVATE | FS_ARCHIVE_PROC_IDLE | \ FS_ARCHIVE_PROC_SUSPENDING | FS_ARCHIVE_PROC_RESUME) +#define FS_ARCHIVE_PROC_ALL (~0) + typedef enum { FS_RESULT_SUCCESS = 0, FS_RESULT_FAILURE, @@ -182,5 +184,11 @@ BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); BOOL FSi_ExecuteSyncCommand(struct FSFile * file); BOOL FS_SuspendArchive(FSArchive * p_arc); BOOL FS_ResumeArchive(FSArchive * p_arc); +void FS_NotifyArchiveAsyncEnd(FSArchive *p_arc, FSResult ret); +BOOL FS_RegisterArchiveName(FSArchive * p_arc, const char * name, int name_len); +void FS_InitArchive(FSArchive * p_arc); +void FS_SetArchiveProc(struct FSArchive * p_arc, FS_ARCHIVE_PROC_FUNC proc, u32 flags); +BOOL FS_LoadArchive(FSArchive * p_arc, u32 base, u32 fat, u32 fat_size, u32 fnt, u32 fnt_size, FS_ARCHIVE_READ_FUNC read_func, FS_ARCHIVE_WRITE_FUNC write_func); +u32 FS_LoadArchiveTables(FSArchive *p_arc, void *p_mem, u32 max_size); #endif //NITRO_FS_ARCHIVE_H_ diff --git a/arm9/lib/include/FS_rom.h b/arm9/lib/include/FS_rom.h index 0bba46bf..ac8ad8fb 100644 --- a/arm9/lib/include/FS_rom.h +++ b/arm9/lib/include/FS_rom.h @@ -5,6 +5,7 @@ #include "CARD_rom.h" extern FSArchive fsi_arc_rom; +extern s32 fsi_card_lock_id; extern CARDRomRegion fsi_ovt7; extern CARDRomRegion fsi_ovt9; diff --git a/arm9/lib/include/MI_dma.h b/arm9/lib/include/MI_dma.h new file mode 100644 index 00000000..eddcedbb --- /dev/null +++ b/arm9/lib/include/MI_dma.h @@ -0,0 +1,6 @@ +#ifndef NITRO_MI_DMA_H_ +#define NITRO_MI_DMA_H_ + +typedef void (*MIDmaCallback)(void *); + +#endif //NITRO_MI_DMA_H_ diff --git a/arm9/lib/include/OS_printf.h b/arm9/lib/include/OS_printf.h new file mode 100644 index 00000000..0fda0f51 --- /dev/null +++ b/arm9/lib/include/OS_printf.h @@ -0,0 +1,6 @@ +#ifndef NITRO_OS_PRINTF_H_ +#define NITRO_OS_PRINTF_H_ + +#define OS_Warning( ... ) ((void)0) + +#endif //NITRO_OS_PRINTF_H_ diff --git a/arm9/lib/include/OS_spinLock.h b/arm9/lib/include/OS_spinLock.h index b7f0a571..3bb8a1c2 100644 --- a/arm9/lib/include/OS_spinLock.h +++ b/arm9/lib/include/OS_spinLock.h @@ -11,4 +11,6 @@ typedef volatile struct OSLockWord { u16 extension; } OSLockWord; +s32 OS_GetLockID(void); + #endif //POKEDIAMOND_OS_SPINLOCK_H -- cgit v1.2.3 From ab5676fcf0a728374d5495c1980f1e2459d0ba4e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 19:55:15 -0400 Subject: FS_command.c --- arm9/lib/include/FS_archive.h | 5 +++++ arm9/lib/include/FS_command.h | 2 ++ arm9/lib/include/FSi_util.h | 7 +++++++ 3 files changed, 14 insertions(+) (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index d7c2a785..3bbbbff7 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -175,6 +175,11 @@ static inline BOOL FSi_IsArchiveAsync(volatile const FSArchive * p_arc) return (p_arc->flag & FS_ARCHIVE_FLAG_IS_ASYNC) != 0; } +static inline BOOL FSi_IsArchiveSync(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_IS_SYNC) != 0; +} + static inline BOOL FS_IsArchiveTableLoaded(volatile const FSArchive * p_arc) { return (p_arc->flag & FS_ARCHIVE_FLAG_TABLE_LOAD) ? TRUE : FALSE; diff --git a/arm9/lib/include/FS_command.h b/arm9/lib/include/FS_command.h index db878f3f..b5e73bcf 100644 --- a/arm9/lib/include/FS_command.h +++ b/arm9/lib/include/FS_command.h @@ -3,6 +3,8 @@ #include "FS_file.h" +extern FSResult (*const fsi_default_command[])(FSFile *); + void FSi_ReleaseCommand(FSFile * file, FSResult signal); FSResult FSi_TranslateCommand(FSFile * file, FSCommandType command); diff --git a/arm9/lib/include/FSi_util.h b/arm9/lib/include/FSi_util.h index 1012df13..1f6faf6f 100644 --- a/arm9/lib/include/FSi_util.h +++ b/arm9/lib/include/FSi_util.h @@ -20,6 +20,13 @@ static inline void FSi_CutFromListCore(FSFileLink *trg) nx->link.prev = pr; } +static inline void FSi_CutFromList(FSFile *elem) +{ + FSFileLink *const trg = &elem->link; + FSi_CutFromListCore(trg); + trg->next = trg->prev = NULL; +} + static inline void FSi_AppendToList(FSFile *elem, FSFile *list) { FSFileLink *const trg = &elem->link; -- cgit v1.2.3 From 1966623ed0516e84d8129e8f22dba502b018bcc3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 08:35:17 -0400 Subject: Finish FS_command_default.c --- arm9/lib/include/FS_archive.h | 13 +++++++++++++ arm9/lib/include/FS_file.h | 7 +++++++ arm9/lib/include/FSi_util.h | 2 ++ arm9/lib/include/MI_byteAccess.h | 5 +++++ 4 files changed, 27 insertions(+) (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index 3bbbbff7..d30081d7 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -105,6 +105,19 @@ typedef struct } FSFileLink; +typedef struct +{ + u32 start; + u16 index; + u16 parent; +} FSArchiveFNT; + +typedef struct +{ + u32 top; + u32 bottom; +} FSArchiveFAT; + typedef struct FSArchive { union diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index fdf6c4e2..55825c61 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -13,6 +13,8 @@ #define FS_FILE_STATUS_IS_DIR 0x00000020 #define FS_FILE_STATUS_OPERATING 0x00000040 +#define FS_FILE_NAME_MAX 127 + typedef enum FSSeekFileMode { FS_SEEK_SET = 0, @@ -210,4 +212,9 @@ static inline BOOL FS_IsSucceeded(volatile const FSFile * p_file) return (p_file->error == FS_RESULT_SUCCESS) ? TRUE : FALSE; } +static inline BOOL FS_IsDir(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_IS_DIR) ? TRUE : FALSE; +} + #endif //NITRO_FS_FILE_H_ diff --git a/arm9/lib/include/FSi_util.h b/arm9/lib/include/FSi_util.h index 1f6faf6f..6e96681e 100644 --- a/arm9/lib/include/FSi_util.h +++ b/arm9/lib/include/FSi_util.h @@ -5,6 +5,8 @@ #define ALIGN_BYTE(n, a) (((u32)(n) + ALIGN_MASK(a)) & ~ALIGN_MASK(a)) +#define BIT_MASK(a) ((u32)((1 << (a)) - 1)) + static inline BOOL FSi_IsSlash(u32 c) { return (c == '/') || (c == '\\'); diff --git a/arm9/lib/include/MI_byteAccess.h b/arm9/lib/include/MI_byteAccess.h index 10dae4c9..cad4d518 100644 --- a/arm9/lib/include/MI_byteAccess.h +++ b/arm9/lib/include/MI_byteAccess.h @@ -6,4 +6,9 @@ static inline u8 MI_ReadByte(const void *address) return *(u8 *)address; } +static inline void MI_WriteByte(void *address, u8 value) +{ + *(u8 *)address = value; +} + #endif //NITRO_MI_BYTEACCESS_H_ -- cgit v1.2.3 From d3bd9a77bb8ca065d295911aca7fbd2da4a846f5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 11:52:42 -0400 Subject: Some prototypes in FS_file.h --- arm9/lib/include/FS_file.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 55825c61..9857a40c 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -180,8 +180,10 @@ BOOL FS_WaitAsync(FSFile * p_file); BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 image_bottom, u32 file_index); int FS_ReadFile(FSFile * p_file, void * dst, s32 len); int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); +BOOL FS_OpenFile(FSFile * p_file, const char * path); BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); BOOL FS_CloseFile(FSFile * p_file); +BOOL FS_SeekFile(FSFile * p_file, int offset, FSSeekFileMode origin); static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { return p_file->prop.file.top; -- cgit v1.2.3 From b398a161f324f88a4d4c8682eb15c63a62753a43 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 19:39:43 -0400 Subject: Fix style inconsistencies --- arm9/lib/include/FS_file.h | 16 ++++++++-------- arm9/lib/include/OS_printf.h | 2 ++ arm9/lib/include/OS_system.h | 4 ---- arm9/lib/include/mmap_global.h | 4 ---- 4 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 arm9/lib/include/mmap_global.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 9857a40c..3a7d8730 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -5,13 +5,13 @@ #include "FS_archive.h" -#define FS_FILE_STATUS_BUSY 0x00000001 -#define FS_FILE_STATUS_CANCEL 0x00000002 -#define FS_FILE_STATUS_SYNC 0x00000004 -#define FS_FILE_STATUS_ASYNC 0x00000008 -#define FS_FILE_STATUS_IS_FILE 0x00000010 -#define FS_FILE_STATUS_IS_DIR 0x00000020 -#define FS_FILE_STATUS_OPERATING 0x00000040 +#define FS_FILE_STATUS_BUSY 0x00000001 +#define FS_FILE_STATUS_CANCEL 0x00000002 +#define FS_FILE_STATUS_SYNC 0x00000004 +#define FS_FILE_STATUS_ASYNC 0x00000008 +#define FS_FILE_STATUS_IS_FILE 0x00000010 +#define FS_FILE_STATUS_IS_DIR 0x00000020 +#define FS_FILE_STATUS_OPERATING 0x00000040 #define FS_FILE_NAME_MAX 127 @@ -81,7 +81,7 @@ typedef struct FSFileID *file; FSDirPos *dir; } - result; + result; } FSFindPathInfo; diff --git a/arm9/lib/include/OS_printf.h b/arm9/lib/include/OS_printf.h index 0fda0f51..7c02252b 100644 --- a/arm9/lib/include/OS_printf.h +++ b/arm9/lib/include/OS_printf.h @@ -2,5 +2,7 @@ #define NITRO_OS_PRINTF_H_ #define OS_Warning( ... ) ((void)0) +#define OS_TPanic(...) OS_Terminate() +#define OS_TWarning(...) ((void)0) #endif //NITRO_OS_PRINTF_H_ diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 88137c3b..794e16d2 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -7,7 +7,6 @@ #include "function_target.h" #include "consts.h" -#include "function_target.h" typedef enum { OS_PROCMODE_USER=16, @@ -36,8 +35,5 @@ OSIntrMode OS_GetCpsrIrq(); OSProcMode OS_GetProcMode(); void OS_SpinWait(); void OS_WaitVBlankIntr(); -void OS_Terminate(void); -#define OS_TPanic(...) OS_Terminate() -#define OS_TWarning(...) ((void)0) #endif //POKEDIAMOND_OS_SYSTEM_H diff --git a/arm9/lib/include/mmap_global.h b/arm9/lib/include/mmap_global.h deleted file mode 100644 index e657e46f..00000000 --- a/arm9/lib/include/mmap_global.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef NITRO_MMAP_GLOBAL_H_ -#define NITRO_MMAP_GLOBAL_H_ - -#endif //NITRO_MMAP_GLOBAL_H_ -- cgit v1.2.3