1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - MB - include 3 File: mb_block.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 _MB_BLOCK_H_ 19 #define _MB_BLOCK_H_ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #include <nitro/types.h> 26 #include <nitro/mb.h> 27 #include <nitro/wm.h> 28 #include "mb_common.h" 29 30 31 /* ----------------------------------------------------------------------- * 32 * Structure Definitions 33 * ----------------------------------------------------------------------- */ 34 35 /* 36 * Transfer block header (header added to each block) 37 Actually sent and received in a form that is packed by Padding amount. 38 */ 39 typedef struct 40 { 41 u8 type; // Data type: 1B 42 u8 pad1[1]; 43 u16 fid; // File number value: 4B 44 u16 seqno; // Parent use: 6B 45 } 46 MBCommParentBlockHeader; 47 48 49 typedef struct 50 { 51 u8 type; // Data type: 1B 52 u8 pad1[1]; // 1B 53 union // union total: 16B 54 { 55 struct 56 { 57 u16 req; // Block number request value: 2B 58 u8 reserved[MB_COMM_CALC_REQ_DATA_PIECE_SIZE(MB_COMM_P_RECVLEN_MAX)]; // 14B 59 } 60 data; 61 62 struct 63 { 64 u8 piece; // Fragmented data number: 1B 65 // Buffer that stores fragmented data 66 u8 data[MB_COMM_CALC_REQ_DATA_PIECE_SIZE(MB_COMM_P_RECVLEN_MAX)]; // 14B 67 u8 pad2[1]; // 1B 68 } 69 req_data; 70 }; 71 // Total: 18B 72 } 73 MBCommChildBlockHeader; 74 75 76 // Receive buffer for a divided request 77 typedef struct 78 { 79 u32 data_buf[MB_MAX_CHILD][MB_COMM_CALC_REQ_DATA_BUF_SIZE(MB_COMM_P_RECVLEN_MAX) / 80 sizeof(u32) + 1]; 81 u32 data_bmp[MB_MAX_CHILD]; 82 } 83 MbRequestPieceBuf; 84 85 /* ----------------------------------------------------------------------- * 86 * Function Declarations 87 * ----------------------------------------------------------------------- */ 88 89 /* Set child MP transmission size */ 90 void MBi_SetChildMPMaxSize(u16 childMaxSize); 91 /* Set parent buffer for receiving divided requests */ 92 void MBi_SetParentPieceBuffer(MbRequestPieceBuf * buf); 93 /* Clear the buffer for receiving divided requests */ 94 void MBi_ClearParentPieceBuffer(u16 child_aid); 95 96 /* From the parent's send header information, build the actual data to be sent */ 97 u8 *MBi_MakeParentSendBuffer(const MBCommParentBlockHeader * hdr, u8 *sendbuf); 98 /* Build a structure from the data buffer received from a child */ 99 u8 *MBi_SetRecvBufferFromChild(const u8 *recvbuf, MBCommChildBlockHeader * hdr, u16 child_id); 100 101 /* From the child's send header information, build the actual data to be sent */ 102 u8 *MBi_MakeChildSendBuffer(const MBCommChildBlockHeader * hdr, u8 *sendbuf); 103 /* Divide request data to send from a child */ 104 u8 MBi_SendRequestDataPiece(u8 *pData, const MBCommRequestData *pReq); 105 /* Get the header portion from a packet received from the parent and return a pointer to the data portion */ 106 u8 *MBi_SetRecvBufferFromParent(MBCommParentBlockHeader * hdr, const u8 *recvbuf); 107 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif /* _MB_BLOCK_H_ */ 114