1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - MB - include 3 File: mb_child.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 This is a header for the MB library's child device. 20 When using this library in a multiboot child device as well as the IPL, additionally include this header in nitro/mb.h. 21 22 23 ==========================================================================*/ 24 25 26 #ifndef _MB_CHILD_H_ 27 #define _MB_CHILD_H_ 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <nitro/types.h> 34 #include <nitro/memorymap.h> 35 #include <nitro/mb.h> 36 #include "mb_fileinfo.h" 37 #include "mb_gameinfo.h" 38 39 /* --------------------------------------------------------------------- 40 41 define constants 42 43 ---------------------------------------------------------------------*/ 44 45 #define MB_CHILD_SYSTEM_BUF_SIZE (0x6000) 46 47 #define MB_MAX_SEND_BUFFER_SIZE (0x400) 48 #define MB_MAX_RECV_BUFFER_SIZE (0x80) 49 50 /* ---------------------------------------------------------------------------- 51 52 Multiboot RAM address definition (used internally) 53 54 ----------------------------------------------------------------------------*/ 55 56 /* 57 Possible placement range of a multiboot program. 58 59 The maximum initial load size of the ARM9 code in wireless multiboot is 2.5 MB. 60 61 The loadable region for ARM9 code is between MB_LOAD_AREA_LO and MB_LOAD_AREA_HI. 62 63 64 */ 65 #define MB_LOAD_AREA_LO ( HW_MAIN_MEM ) 66 #define MB_LOAD_AREA_HI ( HW_MAIN_MEM + 0x002c0000 ) 67 #define MB_LOAD_MAX_SIZE ( MB_LOAD_AREA_HI - MB_LOAD_AREA_LO ) 68 69 70 /* 71 Address definitions for the ARM7 static child-side temporary receive buffer during multi-boot. 72 73 The loadable range of ARM7 code is any of the following. 74 75 a) 0x02000000 - 0x02300000 76 (MB_LOAD_AREA_LO - MB_ARM7_STATIC_RECV_BUFFER_END) 77 b) 0x02300000 - 0x023fe000 78 (MB_ARM7_STATIC_RECV_BUFFER_END - 0x023fe000) 79 c) 0x037f8000 - 0x0380f000. 80 (internal WRAM) 81 82 83 84 * NOTE 85 When loading ARM7 code to internal WRAM or after 0x02300000, 86 87 0x022c0000 - 0x02300000 88 (MB_LOAD_AREA_HI - MB_ARM7_STATIC_RECV_BUFFER_END) 89 The buffer is configured as shown above, receives data, and then is relocated to the address specified at boot time. 90 91 92 * ARM7 code whose position straddles the 0x02300000 address. 93 For addresses after 0x02300000, ARM7 code larger than 0x40000 (MB_ARM7_STATIC_RECV_BUFFER_SIZE) cannot be guaranteed to run normally, so it is prohibited to create code like this. 94 95 96 */ 97 98 #define MB_ARM7_STATIC_RECV_BUFFER MB_LOAD_AREA_HI 99 #define MB_ARM7_STATIC_RECV_BUFFER_END ( HW_MAIN_MEM + 0x00300000 ) 100 #define MB_ARM7_STATIC_RECV_BUFFER_SIZE ( MB_ARM7_STATIC_RECV_BUFFER_END - MB_LOAD_AREA_HI ) 101 #define MB_ARM7_STATIC_LOAD_AREA_HI ( MB_LOAD_AREA_HI + MB_ARM7_STATIC_RECV_BUFFER_SIZE ) 102 #define MB_ARM7_STATIC_LOAD_WRAM_MAX_SIZE ( 0x18000 - 0x1000 ) // 0x18000 = HW_WRAM_SIZE + HW_PRV_WRAM_SIZE 103 104 /* Temporary storage location of BssDesc */ 105 #define MB_BSSDESC_ADDRESS ( HW_MAIN_MEM + 0x003fe800 ) 106 /* Temporary storage location of MBDownloadFileInfo */ 107 #define MB_DOWNLOAD_FILEINFO_ADDRESS ( MB_BSSDESC_ADDRESS + ( ( ( MB_BSSDESC_SIZE ) + (32) - 1 ) & ~((32) - 1) ) ) 108 /* Place for saving the ROM header of an inserted ROM card at multiboot startup time */ 109 #define MB_CARD_ROM_HEADER_ADDRESS ( MB_DOWNLOAD_FILEINFO_ADDRESS + ( ( ( MB_DOWNLOAD_FILEINFO_SIZE ) + (32) - 1 ) & ~((32) - 1) ) ) 110 /* Place for storing the ROM Header */ 111 #define MB_ROM_HEADER_ADDRESS (HW_MAIN_MEM + 0x007ffe00) 112 113 114 /* --------------------------------------------------------------------- 115 116 The API for the multiboot library (MB) child device. Used by IPL. 117 118 ---------------------------------------------------------------------*/ 119 120 /* Set child parameters and start */ 121 int MB_StartChild(void); 122 123 /* Get the size of the work memory used by the MB child */ 124 int MB_GetChildSystemBufSize(void); 125 126 /* Set the notification callback for the child state */ 127 void MB_CommSetChildStateCallback(MBCommCStateCallbackFunc callback); 128 129 /* Get the state of the child */ 130 int MB_CommGetChildState(void); 131 132 /* Start download */ 133 BOOL MB_CommStartDownload(void); 134 135 /* Get the status of the child's download progress as a percentage from 0 to 100 */ 136 u16 MB_GetChildProgressPercentage(void); 137 138 /* Try connecting to the parent and request a download file */ 139 int MB_CommDownloadRequest(int index); // Designate the parent device for which to request a connection with the list number of MbBeaconRecvStatus 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif /* _MB_CHILD_H_ */ 146