1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - FS - libraries 3 File: fs_api.c 4 5 Copyright 2007-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2009-02-06#$ 14 $Rev: 9982 $ 15 $Author: yosizaki $ 16 17 *---------------------------------------------------------------------------*/ 18 19 20 #include <nitro/types.h> 21 #include <nitro/misc.h> 22 #include <nitro/mi.h> 23 #include <nitro/os.h> 24 #include <nitro/pxi.h> 25 #include <nitro/card/common.h> 26 27 #include <nitro/fs.h> 28 29 #include "../include/util.h" 30 #include "../include/command.h" 31 #include "../include/rom.h" 32 33 34 /*---------------------------------------------------------------------------*/ 35 /* Variables */ 36 37 static BOOL is_init = FALSE; 38 39 40 /*---------------------------------------------------------------------------*/ 41 /* Functions */ 42 43 /*---------------------------------------------------------------------------* 44 Name: FS_Init 45 46 Description: Initializes file system. 47 48 Arguments: default_dma_no: Default DMA channel for FS 49 If out of range (0-3), 50 use CpuCopy instead of DMA. 51 52 Returns: None. 53 *---------------------------------------------------------------------------*/ FS_Init(u32 default_dma_no)54void FS_Init(u32 default_dma_no) 55 { 56 #if defined(FS_IMPLEMENT) 57 SDK_ASSERTMSG(default_dma_no != 0, "cannot use DMA channel 0 for ROM access"); 58 if (!is_init) 59 { 60 is_init = TRUE; 61 #if defined(SDK_TWLLTD) 62 // Changed to explicitly initialize the FAT driver at the application's discretion to prevent always linking unnecessary Unicode-related modules. 63 // 64 // (NAND applications are expressly indicated within the FSi_OverrideRomArchive function) 65 FS_InitFatDriver(); 66 #endif 67 FSi_InitRomArchive(default_dma_no); 68 FSi_InitOverlay(); 69 } 70 #else 71 #pragma unused(default_dma_no) 72 CARD_Init(); 73 #endif /* FS_IMPLEMENT */ 74 } 75 76 /*---------------------------------------------------------------------------* 77 Name: FS_IsAvailable 78 79 Description: Checks if file system is ready. 80 81 Arguments: None. 82 83 Returns: If file system is ready, TRUE. 84 *---------------------------------------------------------------------------*/ FS_IsAvailable(void)85BOOL FS_IsAvailable(void) 86 { 87 return is_init; 88 } 89 90 /*---------------------------------------------------------------------------* 91 Name: FS_End 92 93 Description: Finalizes file system. 94 Unloads and unregisters all the archives. 95 96 Arguments: None. 97 98 Returns: None. 99 *---------------------------------------------------------------------------*/ FS_End(void)100void FS_End(void) 101 { 102 OSIntrMode bak_psr = OS_DisableInterrupts(); 103 if (is_init) 104 { 105 #if defined(FS_IMPLEMENT) 106 FSi_EndArchive(); 107 FSi_EndRomArchive(); 108 #endif /* FS_IMPLEMENT */ 109 is_init = FALSE; 110 } 111 (void)OS_RestoreInterrupts(bak_psr); 112 } 113 114 #if defined(FS_IMPLEMENT) && defined(SDK_TWL) 115 116 /*---------------------------------------------------------------------------* 117 Name: FS_InitFatDriver 118 119 Description: Initializes the FAT driver. 120 121 Arguments: None. 122 123 Returns: None. 124 *---------------------------------------------------------------------------*/ FS_InitFatDriver(void)125void FS_InitFatDriver(void) 126 { 127 static BOOL once = FALSE; 128 if (!once) 129 { 130 once = TRUE; 131 SDK_ASSERT(FS_IsAvailable()); 132 if (OS_IsRunOnTwl()) 133 { 134 FSi_MountDefaultArchives(); 135 } 136 } 137 } 138 #endif 139