diff options
Diffstat (limited to 'arm9/lib/include')
-rw-r--r-- | arm9/lib/include/CARD_common.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/CARD_pullOut.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/CARD_rom.h | 39 | ||||
-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 | 212 | ||||
-rw-r--r-- | arm9/lib/include/FS_command.h | 11 | ||||
-rw-r--r-- | arm9/lib/include/FS_file.h | 222 | ||||
-rw-r--r-- | arm9/lib/include/FS_mw_dtor.h | 16 | ||||
-rw-r--r-- | arm9/lib/include/FS_overlay.h | 55 | ||||
-rw-r--r-- | arm9/lib/include/FS_rom.h | 14 | ||||
-rw-r--r-- | arm9/lib/include/FSi_util.h | 46 | ||||
-rw-r--r-- | arm9/lib/include/MI_byteAccess.h | 14 | ||||
-rw-r--r-- | arm9/lib/include/MI_dma.h | 6 | ||||
-rw-r--r-- | arm9/lib/include/MI_exMemory.h | 9 | ||||
-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_printf.h | 8 | ||||
-rw-r--r-- | arm9/lib/include/OS_spinLock.h | 2 | ||||
-rw-r--r-- | arm9/lib/include/OS_system.h | 2 | ||||
-rw-r--r-- | arm9/lib/include/OS_thread.h | 3 | ||||
-rw-r--r-- | arm9/lib/include/mmap.h | 2 |
23 files changed, 709 insertions, 1 deletions
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 new file mode 100644 index 00000000..4c2e9dd5 --- /dev/null +++ b/arm9/lib/include/CARD_rom.h @@ -0,0 +1,39 @@ +#ifndef NITRO_CARD_ROM_H_ +#define NITRO_CARD_ROM_H_ + +#include "MI_exMemory.h" +#include "MI_dma.h" + +typedef struct +{ + u32 offset; + u32 length; +} +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); +} + +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/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 new file mode 100644 index 00000000..d30081d7 --- /dev/null +++ b/arm9/lib/include/FS_archive.h @@ -0,0 +1,212 @@ +#ifndef NITRO_FS_ARCHIVE_H_ +#define NITRO_FS_ARCHIVE_H_ + +#include "nitro.h" + +#include "OS_thread.h" + +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, + 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; + +/* 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) + +#define FS_ARCHIVE_PROC_ALL (~0) + +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 +{ + u32 start; + u16 index; + u16 parent; +} FSArchiveFNT; + +typedef struct +{ + u32 top; + u32 bottom; +} FSArchiveFAT; + +typedef struct FSArchive +{ + union + { + char ptr[4]; + u32 pack; + } name; + struct FSArchive * next; + struct FSArchive * prev; + 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; + +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; +} + +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; +} + +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 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; +} + +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_command.h b/arm9/lib/include/FS_command.h new file mode 100644 index 00000000..b5e73bcf --- /dev/null +++ b/arm9/lib/include/FS_command.h @@ -0,0 +1,11 @@ +#ifndef NITRO_FS_COMMAND_H_ +#define NITRO_FS_COMMAND_H_ + +#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); + +#endif //NITRO_FS_COMMAND_H_ diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h new file mode 100644 index 00000000..3a7d8730 --- /dev/null +++ b/arm9/lib/include/FS_file.h @@ -0,0 +1,222 @@ +#ifndef NITRO_FS_FILE_H_ +#define NITRO_FS_FILE_H_ + +#include "nitro.h" + +#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_NAME_MAX 127 + +typedef enum FSSeekFileMode +{ + FS_SEEK_SET = 0, + FS_SEEK_CUR, + FS_SEEK_END +} FSSeekFileMode; + +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]; + 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; + } arg; +} +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_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; +} + +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; +} + +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/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 new file mode 100644 index 00000000..6025d04a --- /dev/null +++ b/arm9/lib/include/FS_overlay.h @@ -0,0 +1,55 @@ +#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; + +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); +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/FS_rom.h b/arm9/lib/include/FS_rom.h new file mode 100644 index 00000000..ac8ad8fb --- /dev/null +++ b/arm9/lib/include/FS_rom.h @@ -0,0 +1,14 @@ +#ifndef NITRO_FS_ROM_H_ +#define NITRO_FS_ROM_H_ + +#include "FS_archive.h" +#include "CARD_rom.h" + +extern FSArchive fsi_arc_rom; +extern s32 fsi_card_lock_id; +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/FSi_util.h b/arm9/lib/include/FSi_util.h new file mode 100644 index 00000000..6e96681e --- /dev/null +++ b/arm9/lib/include/FSi_util.h @@ -0,0 +1,46 @@ +#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)) + +#define BIT_MASK(a) ((u32)((1 << (a)) - 1)) + +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_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; + 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_ diff --git a/arm9/lib/include/MI_byteAccess.h b/arm9/lib/include/MI_byteAccess.h new file mode 100644 index 00000000..cad4d518 --- /dev/null +++ b/arm9/lib/include/MI_byteAccess.h @@ -0,0 +1,14 @@ +#ifndef NITRO_MI_BYTEACCESS_H_ +#define NITRO_MI_BYTEACCESS_H_ + +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_ 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/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/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_printf.h b/arm9/lib/include/OS_printf.h new file mode 100644 index 00000000..7c02252b --- /dev/null +++ b/arm9/lib/include/OS_printf.h @@ -0,0 +1,8 @@ +#ifndef NITRO_OS_PRINTF_H_ +#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_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 diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 9a79c0d1..794e16d2 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -5,8 +5,8 @@ #ifndef POKEDIAMOND_OS_SYSTEM_H #define POKEDIAMOND_OS_SYSTEM_H -#include "consts.h" #include "function_target.h" +#include "consts.h" typedef enum { OS_PROCMODE_USER=16, diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h index 49ae9f15..15cec0c9 100644 --- a/arm9/lib/include/OS_thread.h +++ b/arm9/lib/include/OS_thread.h @@ -28,6 +28,9 @@ struct _OSThread u8 padding[0x80]; //todo: not the correct size but idfk }; +void OS_SleepThread(OSThreadQueue * queue); +void OS_WakeupThread(OSThreadQueue * queue); + static inline void OS_InitThreadQueue(OSThreadQueue * queue) { queue->head = queue->tail = NULL; diff --git a/arm9/lib/include/mmap.h b/arm9/lib/include/mmap.h index 1f8f37f9..27255115 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 |