1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - MB - include 3 File: mb_private.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 Only this header file is included in each source file of the MB library 20 */ 21 22 #ifndef _MB_PRIVATE_H_ 23 #define _MB_PRIVATE_H_ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #if !defined(NITRO_FINALROM) 30 /* 31 #define PRINT_DEBUG 32 */ 33 #endif 34 35 #define CALLBACK_WM_STATE 0 36 37 #include <nitro/types.h> 38 #include <nitro/wm.h> 39 #include <nitro/mb.h> 40 #include "mb_wm_base.h" 41 #include "mb_common.h" 42 #include "mb_block.h" 43 #include "mb_rom_header.h" 44 #include "mb_gameinfo.h" 45 #include "mb_fileinfo.h" 46 #include "mb_child.h" 47 48 /* New framework for the caching method */ 49 #include "mb_cache.h" 50 #include "mb_task.h" 51 52 /* Debugging output */ 53 #ifdef PRINT_DEBUG 54 #define MB_OUTPUT( ... ) OS_TPrintf( __VA_ARGS__ ) 55 #define MB_DEBUG_OUTPUT( ... ) MBi_DebugPrint(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__ ) 56 57 #else 58 #define MB_OUTPUT( ... ) ((void)0) 59 #define MB_DEBUG_OUTPUT( ... ) ((void)0) 60 #endif 61 62 // ---------------------------------------------------------------------------- 63 // Definitions 64 65 /* ---------------------------------------------------------------------------- 66 67 Definitions related to block transfers 68 69 ----------------------------------------------------------------------------*/ 70 71 #define MB_IPL_VERSION (0x0001) 72 #define MB_MAX_BLOCK 12288 // Max 12288 * 256 = 3.0 MB 73 74 #define MB_NUM_PARENT_INFORMATIONS 16 /* Maximum number of parents */ 75 76 #define MB_SCAN_TIME_NORMAL WM_DEFAULT_SCAN_PERIOD 77 #define MB_SCAN_TIME_NORMAL_FOR_FAKE_CHILD 20 78 #define MB_SCAN_TIME_LOCKING 220 79 80 //SDK_COMPILER_ASSERT( sizeof(MBDownloadFileInfo) <= MB_COMM_BLOCK_SIZE ); 81 82 83 /* ---------------------------------------------------------------------------- 84 85 Definitions of internally used types 86 87 ----------------------------------------------------------------------------*/ 88 89 /* 90 * The work region used by the MB library 91 */ 92 93 typedef struct MB_CommCommonWork 94 { 95 // --- Common --- 96 // Send/receive buffer 97 u32 sendbuf[MB_MAX_SEND_BUFFER_SIZE / sizeof(u32)] ATTRIBUTE_ALIGN(32); 98 u32 recvbuf[MB_MAX_RECV_BUFFER_SIZE * MB_MAX_CHILD * 2 / sizeof(u32)] ATTRIBUTE_ALIGN(32); 99 MBUserInfo user; // User information for this device 100 u16 isMbInitialized; 101 int block_size_max; 102 BOOL start_mp_busy; /* WM_StartMP() is operating */ 103 BOOL is_started_ex; /* WM_StartParentEX() called */ 104 u8 padding[28]; 105 } 106 MB_CommCommonWork; 107 108 typedef struct MB_CommPWork 109 { 110 MB_CommCommonWork common; 111 112 // --- For the parent device --- 113 MBUserInfo childUser[MB_MAX_CHILD] ATTRIBUTE_ALIGN(4); 114 u16 childversion[MB_MAX_CHILD]; // Child device version information (in quantity equal to the number of child devices) 115 u32 childggid[MB_MAX_CHILD]; // Child device GGID (in quantity equal to the number of child devices) 116 MBCommPStateCallback parent_callback; // Parent state callback function pointer 117 int p_comm_state[MB_MAX_CHILD]; // Holds the state of each of the children 118 u8 file_num; // Number of registered files 119 u8 cur_fileid; // File number of the current file to send 120 s8 fileid_of_child[MB_MAX_CHILD]; // File number that a child requested (-1 when there is no request) 121 u8 child_num; // Number of entry children 122 u16 child_entry_bmp; // Child entry control bitmap 123 MbRequestPieceBuf req_data_buf; // Buffer for receiving child partition requests 124 u16 req2child[MB_MAX_CHILD]; // The request to send to the child 125 MBUserInfo childUserBuf; // Child information buffer for passing to the application 126 127 // File information 128 struct 129 { 130 // The DownloadFileInfo buffer 131 MBDownloadFileInfo dl_fileinfo; 132 MBGameInfo game_info; 133 MB_BlockInfoTable blockinfo_table; 134 MBGameRegistry *game_reg; 135 void *src_adr; // The starting address of the boot image on the parent device 136 u16 currentb; // The current block 137 u16 nextb; // The next block to send 138 u16 pollbmp; // PollBitmap for sending data 139 u16 gameinfo_child_bmp; // The current bitmap member for updating the GameInfo 140 u16 gameinfo_changed_bmp; // The bitmap member that was generated by a change for updating the GameInfo 141 u8 active; 142 u8 update; 143 144 /* 145 * Added to support cache reads 146 * These specify content in src_adr 147 */ 148 MBiCacheList *cache_list; /* Cache list */ 149 u32 *card_mapping; /* CARD address for the start of each segment */ 150 151 } 152 fileinfo[MB_MAX_FILE]; 153 154 BOOL useWvrFlag; // Flag indicating whether or not WVR is being used 155 u8 padding2[20]; 156 157 /* Added for task thread */ 158 u8 task_work[2 * 1024]; 159 MBiTaskInfo cur_task; 160 161 } 162 MB_CommPWork; 163 164 165 typedef struct MB_CommCWork 166 { 167 MB_CommCommonWork common; 168 169 // --- For child devices --- 170 WMBssDesc bssDescbuf ATTRIBUTE_ALIGN(32); // WMBssDesc backup 171 MBDownloadFileInfo dl_fileinfo; // The DownloadFileInfo buffer of the child device 172 MBCommCStateCallbackFunc child_callback; // The state callback function pointer of the child device 173 int c_comm_state; // The state of the child device 174 int connectTargetNo; // The MbBeaconRecvStatus list number of the connection target 175 u8 fileid; // The requested file number 176 u8 _padding1[1]; 177 u16 user_req; 178 u16 got_block; // The number of downloaded blocks 179 u16 total_block; // The total number of blocks of the download file 180 u8 recvflag[MB_MAX_BLOCK / 8]; // Flag that shows the block receive state 181 MB_BlockInfoTable blockinfo_table; 182 int last_recv_seq_no; // Sequence number of the block received previously 183 u8 boot_end_flag; // Flag for determining whether MB termination by BOOT_READY is being processed 184 u8 _padding2[15]; 185 } 186 MB_CommCWork; 187 188 189 /* ---------------------------------------------------------------------------- 190 191 Definitions of variables that are used internally 192 193 ----------------------------------------------------------------------------*/ 194 195 extern MB_CommCommonWork *mbc; 196 /* Pointer macro to the parent's working memory */ 197 #define pPwork ((MB_CommPWork*)mbc) 198 /* Pointer macro to the child's working memory */ 199 #define pCwork ((MB_CommCWork*)mbc) 200 201 202 #ifdef __cplusplus 203 } 204 #endif 205 206 #endif /* _MB_PRIVATE_H_ */ 207