1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - CARD - libraries
3   File:     card_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 #ifndef NITRO_LIBRARIES_CARD_ROM_H__
19 #define NITRO_LIBRARIES_CARD_ROM_H__
20 
21 
22 #include <nitro.h>
23 #include "../include/card_common.h"
24 
25 
26 // #define SDK_ARM7_READROM_SUPPORT
27 
28 
29 #ifdef __cplusplus
30 extern  "C"
31 {
32 #endif
33 
34 
35 /*---------------------------------------------------------------------------*/
36 /* Declarations */
37 
38 typedef struct CARDTransferInfo
39 {
40     u32     command;
41     void  (*callback)(void *userdata);
42     void   *userdata;
43     u32     src;
44     u32     dst;
45     u32     len;
46     u32     work;
47 }
48 CARDTransferInfo;
49 
50 typedef void (*CARDTransferCallbackFunction)(void *userdata);
51 
52 
53 /*---------------------------------------------------------------------------*/
54 /* functions */
55 
56 /*---------------------------------------------------------------------------*
57   Name:         CARDi_ReadRomWithCPU
58 
59   Description:  Uses the CPU for a ROM transfer.
60                 Even though you do not need to consider caching or per-page restrictions, note that this function will block until the transfer is complete.
61 
62 
63   Arguments:    userdata          (Dummy code for use as another callback)
64                 buffer            Buffer to transfer to
65                 offset            ROM offset to transfer from
66                 length            The transfer size
67 
68   Returns:      None.
69  *---------------------------------------------------------------------------*/
70 int CARDi_ReadRomWithCPU(void *userdata, void *buffer, u32 offset, u32 length);
71 
72 /*---------------------------------------------------------------------------*
73   Name:         CARDi_ReadRomWithDMA
74 
75   Description:  Uses DMA for a ROM transfer.
76                 The function will return immediately if a transfer operation is started for the first page.
77 
78   Arguments:    info              Transfer information
79 
80   Returns:      None.
81  *---------------------------------------------------------------------------*/
82 void CARDi_ReadRomWithDMA(CARDTransferInfo *info);
83 
84 /*---------------------------------------------------------------------------*
85   Name:         CARDi_InitRom
86 
87   Description:  Initializes information for managing ROM access.
88 
89   Arguments:    None.
90 
91   Returns:      None.
92  *---------------------------------------------------------------------------*/
93 void CARDi_InitRom(void);
94 
95 /*---------------------------------------------------------------------------*
96   Name:         CARDi_CheckPulledOutCore
97 
98   Description:  Main processing for functions that detect a card removal.
99                 The card bus must be locked.
100 
101   Arguments:    id            ROM-ID read from the card
102 
103   Returns:      None.
104  *---------------------------------------------------------------------------*/
105 void    CARDi_CheckPulledOutCore(u32 id);
106 
107 /*---------------------------------------------------------------------------*
108   Name:         CARDi_ReadRomIDCore
109 
110   Description:  Read the Card ID
111 
112   Arguments:    None.
113 
114   Returns:      Card ID
115  *---------------------------------------------------------------------------*/
116 u32     CARDi_ReadRomIDCore(void);
117 
118 #ifdef SDK_ARM7_READROM_SUPPORT
119 
120 /*---------------------------------------------------------------------------*
121   Name:         CARDi_ReadRomCore
122 
123   Description:  Accesses the card from the ARM7.
124 
125   Arguments:    src        Transfer source offset
126                 src        Transfer source memory address
127                 src        Transfer size
128 
129   Returns:      None.
130  *---------------------------------------------------------------------------*/
131 void    CARDi_ReadRomCore(const void *src, void *dst, u32 len);
132 
133 #endif // SDK_ARM7_READROM_SUPPORT
134 
135 /*---------------------------------------------------------------------------*
136   Name:         CARDi_ReadRomStatusCore
137 
138   Description:  Loads the card status.
139                 This is issued only when detecting a ROM that supports refreshing.
140                 This is necessary for NITRO applications with a supported ROM as well.
141 
142   Arguments:    None.
143 
144   Returns:      Card status
145  *---------------------------------------------------------------------------*/
146 u32 CARDi_ReadRomStatusCore(void);
147 
148 /*---------------------------------------------------------------------------*
149   Name:         CARDi_RefreshRomCore
150 
151   Description:  Refreshes bad blocks on a card's ROM.
152                 This is necessary for NITRO applications with a relevant ROM, as well.
153                 This only issues a command to the card and therefore ignores latency settings.
154 
155   Arguments:    None.
156 
157   Returns:      None.
158  *---------------------------------------------------------------------------*/
159 void CARDi_RefreshRomCore(void);
160 
161 
162 #ifdef __cplusplus
163 } // extern "C"
164 #endif
165 
166 
167 #endif // NITRO_LIBRARIES_CARD_ROM_H__
168