1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - FS - libraries
3   File:     rom.h
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:: 2008-09-17#$
14   $Rev: 8556 $
15   $Author: okubata_ryoma $
16 
17  *---------------------------------------------------------------------------*/
18 
19 
20 #ifndef NITRO_FS_ROM_H_
21 #define NITRO_FS_ROM_H_
22 
23 #include <nitro/misc.h>
24 #include <nitro/types.h>
25 #include <nitro/card/hash.h>
26 #include <nitro/fs/file.h>
27 #include <nitro/fs/archive.h>
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 /*---------------------------------------------------------------------------*/
36 /* functions */
37 #if defined(FS_IMPLEMENT)
38 
39 /*---------------------------------------------------------------------------*
40   Name:         FSi_InitRomArchive
41 
42   Description:  Initializes the "rom" archive.
43 
44   Arguments:    default_dma_no: The DMA channel to use for ROM access.
45                                  If this is not between 0 and 3, access will be handled by the CPU.
46 
47   Returns:      None.
48  *---------------------------------------------------------------------------*/
49 void    FSi_InitRomArchive(u32 default_dma_no);
50 
51 /*---------------------------------------------------------------------------*
52   Name:         FSi_EndRomArchive
53 
54   Description:  Deallocates the "rom" archive.
55 
56   Arguments:    None.
57 
58   Returns:      None.
59  *---------------------------------------------------------------------------*/
60 void    FSi_EndRomArchive(void);
61 
62 /*---------------------------------------------------------------------------*
63   Name:         FSi_MountSRLFile
64 
65   Description:  Mounts the ROM file system included in an SRL file.
66 
67   Arguments:    arc: The FSArchive structure to use when mounting.
68                                  The name must already be registered.
69                 file: An open file to mount.
70                                  This structure cannot be destroyed while it is mounted.
71                 hash: Hash context structure.
72 
73   Returns:      TRUE if processing is successful.
74  *---------------------------------------------------------------------------*/
75 BOOL FSi_MountSRLFile(FSArchive *arc, FSFile *file, CARDRomHashContext *hash);
76 
77 /*---------------------------------------------------------------------------*
78   Name:         FSi_ConvertPathToFATFS
79 
80   Description:  Converts the specified path name into the FATFS format.
81 
82   Arguments:    dst: Buffer to save to
83                 src: Path to convert
84                 ignorePermission: TRUE when access permissions may be ignored
85 
86   Returns:      None.
87  *---------------------------------------------------------------------------*/
88 void FSi_ConvertPathToFATFS(char *dst, const char *src, BOOL ignorePermission);
89 
90 FSResult FSi_ConvertError(u32 error);
91 
92 /*---------------------------------------------------------------------------*
93   Name:         FSi_MountFATFS
94 
95   Description:  Mounts a FATFS interface in a file system.
96 
97   Arguments:    index: Array element to use
98                 arcname: Archive name
99                 drivename: Drive name
100 
101   Returns:      TRUE if the archive is mounted correctly.
102  *---------------------------------------------------------------------------*/
103 BOOL FSi_MountFATFS(u32 index, const char *arcname, const char *drivename);
104 
105 /*---------------------------------------------------------------------------*
106   Name:         FSi_MountDefaultArchives
107 
108   Description:  Accesses the startup arguments given to the IPL and mounts the default archive.
109 
110   Arguments:    None.
111 
112   Returns:      None.
113  *---------------------------------------------------------------------------*/
114 void FSi_MountDefaultArchives(void);
115 
116 #else /* FS_IMPLEMENT */
117 
118 /*---------------------------------------------------------------------------*
119   Name:         FSi_ReadRomDirect
120 
121   Description:  Directly reads the specified ROM address.
122 
123   Arguments:    src:        Transfer source offset
124                 dst: Address to transfer to
125                 len:        Transfer size
126 
127   Returns:      None.
128  *---------------------------------------------------------------------------*/
129 void    FSi_ReadRomDirect(const void *src, void *dst, u32 len);
130 
131 #endif
132 
133 
134 #ifdef __cplusplus
135 } /* extern "C" */
136 #endif
137 
138 
139 /*---------------------------------------------------------------------------*/
140 
141 
142 #endif /* NITRO_FS_ROM_H_ */
143