diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-07 13:48:17 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-07 13:49:50 -0400 |
commit | 5928e2511db179bdc809f252a3b7fcd7798726db (patch) | |
tree | e7ce827057873f803f61a94853d717ed4407e713 /arm9/lib/include | |
parent | 1762253800d072790303d8cd3b047bab25f8eaed (diff) | |
parent | d4575098dbd671e2b6fd27ad65b984502c90465b (diff) |
Merge branch 'libfs' of github.com:PikalaxALT/pokediamond into libfs
Diffstat (limited to 'arm9/lib/include')
-rw-r--r-- | arm9/lib/include/CARD_rom.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/DGT_common.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/DGT_dgt.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/FS_archive.h | 56 | ||||
-rw-r--r-- | arm9/lib/include/FS_command.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/FS_file.h | 33 | ||||
-rw-r--r-- | arm9/lib/include/FS_mw_dtor.h | 16 | ||||
-rw-r--r-- | arm9/lib/include/FS_overlay.h | 15 | ||||
-rw-r--r-- | arm9/lib/include/FS_rom.h | 7 | ||||
-rw-r--r-- | arm9/lib/include/MI_memory.h | 10 | ||||
-rw-r--r-- | arm9/lib/include/MI_uncompress.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/OS_cache.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/OS_system.h | 5 | ||||
-rw-r--r-- | arm9/lib/include/OS_thread.h | 1 |
14 files changed, 188 insertions, 0 deletions
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_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 4871b660..92e2149e 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -175,5 +175,38 @@ 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; +} + +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/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 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; |