1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - MI - include
3   File:     card.h
4 
5   Copyright 2004-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-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_MI_CARD_H_
19 #define NITRO_MI_CARD_H_
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
27 #ifdef __DUMMY________
28 #include <nitro/os.h>
29 #include <nitro/card.h>
30 
31 
32 /******************************************************************************
33  * CARD access
34  *
35  *	These are simple CARD API wrappers for internal Lock/Unlock operations.
36  *	Future plans call for eliminating them in accordance with the shift to the CARD API.
37  *
38  ******************************************************************************/
39 
40 
41 // Use the LockID for the MI-CARD function to allocate/release CARD.
42 void    MIi_LockCard(void);
43 void    MIi_UnlockCard(void);
44 
45 // Read the card ID. (Sync)
MI_ReadCardID(void)46 static inline u32 MI_ReadCardID(void)
47 {
48     u32     ret;
49     MIi_LockCard();
50     ret = CARDi_ReadRomID();
51     MIi_UnlockCard();
52     return ret;
53 }
54 
55 // Read card. (Sync)
MIi_ReadCard(u32 dmaNo,const void * src,void * dst,u32 size)56 static inline void MIi_ReadCard(u32 dmaNo, const void *src, void *dst, u32 size)
57 {
58     MIi_LockCard();
59     /*
60      * This was changed to use interrupts for both synchronous and asynchronous processing to guarantee performance as much as possible in the low-level CARD_ReadRom.
61      *
62      * In some cases this function is used while interrupts are prohibited, however, so synchronous MI functions were changed to unconditionally use CPU transfers.
63      *
64      * (without multithreading, the efficiency is the same)
65      */
66     (void)dmaNo;
67     CARD_ReadRom((MI_DMA_MAX_NUM + 1), src, dst, size);
68     MIi_UnlockCard();
69 }
70 
71 // Read card data. (Async)
72 void    MIi_ReadCardAsync(u32 dmaNo, const void *srcp, void *dstp, u32 size,
73                           MIDmaCallback callback, void *arg);
74 
75 // Confirm completion of card data asynchronous read.
MIi_TryWaitCard(void)76 static inline BOOL MIi_TryWaitCard(void)
77 {
78     return CARD_TryWaitRomAsync();
79 }
80 
81 // Wait for card data asynchronous read to complete.
MIi_WaitCard(void)82 static inline void MIi_WaitCard(void)
83 {
84     CARD_WaitRomAsync();
85 }
86 
87 #endif
88 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
89 
90 
91 #ifdef __cplusplus
92 } /* extern "C" */
93 #endif
94 
95 
96 /* NITRO_MI_CARD_H_ */
97 #endif
98