1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - CARD - include 3 File: common.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-18#$ 14 $Rev: 8573 $ 15 $Author: okubata_ryoma $ 16 17 *---------------------------------------------------------------------------*/ 18 #ifndef NITRO_CARD_COMMON_H_ 19 #define NITRO_CARD_COMMON_H_ 20 21 22 #include <nitro/card/types.h> 23 24 #include <nitro/memorymap.h> 25 #include <nitro/mi/dma.h> 26 #include <nitro/os.h> 27 28 29 #ifdef __cplusplus 30 extern "C" 31 { 32 #endif 33 34 35 /*---------------------------------------------------------------------------*/ 36 /* Constants */ 37 38 // Card thread's default priority level 39 #define CARD_THREAD_PRIORITY_DEFAULT 4 40 41 42 /*---------------------------------------------------------------------------*/ 43 /* Functions */ 44 45 /*---------------------------------------------------------------------------* 46 Name: CARD_Init 47 48 Description: Initializes the CARD library. 49 50 Arguments: None. 51 52 Returns: None. 53 *---------------------------------------------------------------------------*/ 54 void CARD_Init(void); 55 56 /*---------------------------------------------------------------------------* 57 Name: CARD_IsAvailable 58 59 Description: Determines if the CARD library is usable. 60 61 Arguments: None. 62 63 Returns: TRUE if the CARD_Init function has already been called. 64 *---------------------------------------------------------------------------*/ 65 BOOL CARD_IsAvailable(void); 66 67 /*---------------------------------------------------------------------------* 68 Name: CARD_IsEnabled 69 70 Description: Determines if the Game Card is accessible. 71 72 Arguments: None. 73 74 Returns: TRUE if we have access rights to the Game Card. 75 *---------------------------------------------------------------------------*/ 76 BOOL CARD_IsEnabled(void); 77 78 /*---------------------------------------------------------------------------* 79 Name: CARD_CheckEnabled 80 81 Description: Determines if we have access rights to the Game Card and performs a forced shutdown if we do not. 82 83 Arguments: None. 84 85 Returns: None. 86 *---------------------------------------------------------------------------*/ 87 void CARD_CheckEnabled(void); 88 89 /*---------------------------------------------------------------------------* 90 Name: CARD_Enable 91 92 Description: Sets access rights to the Game Card. 93 94 Arguments: enable: TRUE if we have access rights. 95 96 Returns: None. 97 *---------------------------------------------------------------------------*/ 98 void CARD_Enable(BOOL enable); 99 100 /*---------------------------------------------------------------------------* 101 Name: CARD_GetThreadPriority 102 103 Description: Gets the priority of asynchronous processing threads in the library. 104 105 Arguments: None. 106 107 Returns: Internal thread priority. 108 *---------------------------------------------------------------------------*/ 109 u32 CARD_GetThreadPriority(void); 110 111 /*---------------------------------------------------------------------------* 112 Name: CARD_SetThreadPriority 113 114 Description: Sets the priority of asynchronous processing threads in the library. 115 116 Arguments: None. 117 118 Returns: Internal thread priority before it is set. 119 *---------------------------------------------------------------------------*/ 120 u32 CARD_SetThreadPriority(u32 prior); 121 122 /*---------------------------------------------------------------------------* 123 Name: CARD_GetResultCode 124 125 Description: Gets the result of the last CARD function to be called. 126 127 Arguments: None. 128 129 Returns: The result of the last CARD function to be called. 130 *---------------------------------------------------------------------------*/ 131 CARDResult CARD_GetResultCode(void); 132 133 134 /*---------------------------------------------------------------------------* 135 * for internal use 136 *---------------------------------------------------------------------------*/ 137 138 // Internal CARD library event 139 typedef u32 CARDEvent; 140 #define CARD_EVENT_PULLEDOUT 0x00000001 141 #define CARD_EVENT_SLOTRESET 0x00000002 142 143 // Event hook callback and hook registration structure 144 typedef void (*CARDHookFunction)(void*, CARDEvent, void*); 145 146 typedef struct CARDHookContext 147 { 148 struct CARDHookContext *next; 149 void *userdata; 150 CARDHookFunction callback; 151 } 152 CARDHookContext; 153 154 /*---------------------------------------------------------------------------* 155 Name: CARDi_RegisterHook 156 157 Description: Registers an event hook within the CARD library. 158 159 Arguments: hook: Hook structure to use during registration 160 callback: Callback function to invoke when the event occurs 161 arg: Callback argument 162 163 Returns: None. 164 *---------------------------------------------------------------------------*/ 165 void CARDi_RegisterHook(CARDHookContext *hook, CARDHookFunction callback, void *arg); 166 167 /*---------------------------------------------------------------------------* 168 Name: CARDi_UnregisterHook 169 170 Description: Removes an event hook within the CARD library. 171 172 Arguments: hook: Hook structure used during registration 173 174 Returns: None. 175 *---------------------------------------------------------------------------*/ 176 void CARDi_UnregisterHook(CARDHookContext *hook); 177 178 /*---------------------------------------------------------------------------* 179 Name: CARDi_NotifyEvent 180 181 Description: Notifies all hook functions of an internal CARD library event. 182 183 Arguments: event: The event that occurred 184 arg: argument for each event 185 186 Returns: None. 187 *---------------------------------------------------------------------------*/ 188 void CARDi_NotifyEvent(CARDEvent event, void *arg); 189 190 191 #ifdef __cplusplus 192 } // extern "C" 193 #endif 194 195 196 #endif // NITRO_CARD_COMMON_H_ 197