1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - WM - include 3 File: wm.h 4 5 Copyright 2003-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:: 2009-01-27#$ 14 $Rev: 9922 $ 15 $Author:$ 16 *---------------------------------------------------------------------------*/ 17 #ifndef NITRO_WM_COMMON_WM_H_ 18 #define NITRO_WM_COMMON_WM_H_ 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /*===========================================================================*/ 25 26 #include <nitro/types.h> 27 #include <nitro/os.h> 28 #include <nitro_wl/common/version_wl.h> 29 30 31 /*---------------------------------------------------------------------------* 32 Constant Definitions 33 *---------------------------------------------------------------------------*/ 34 35 #undef WM_GAMEINFO_TYPE_OLD // Removed support for old version of WMGameInfo 36 37 // Switch that sets Data Sharing maximum size to 252 bytes. This makes the WMDataSharingInfo structure slimmer. 38 //#define WM_DS_DATA_SIZE_252 39 40 // TEST mode enable switch 41 //#define WM_ENABLE_TESTMODE 42 43 // Compile switch that precalculates the usable channels. 44 #if ( SDK_VERSION_WL >= 15600 ) 45 #ifdef SDK_TEG 46 #undef WM_PRECALC_ALLOWEDCHANNEL 47 #else 48 #define WM_PRECALC_ALLOWEDCHANNEL 49 #endif 50 #else 51 #undef WM_PRECALC_ALLOWEDCHANNEL 52 #endif 53 54 #define WM_SSID_MASK_CUSTOMIZE 1 55 56 57 // WM API-related =========================================================================== 58 59 // ID for each API 60 typedef enum WMApiid 61 { 62 WM_APIID_INITIALIZE = 0, // 0 : WM_Initialize() 63 WM_APIID_RESET, // 1 : WM_Reset() 64 WM_APIID_END, // 2 : WM_End() 65 66 WM_APIID_ENABLE, // 3 : WM_Enable() 67 WM_APIID_DISABLE, // 4 : WM_Disable() 68 WM_APIID_POWER_ON, // 5 : WM_PowerOn() 69 WM_APIID_POWER_OFF, // 6 : WM_PowerOff() 70 71 WM_APIID_SET_P_PARAM, // 7 : WM_SetParentParameter() 72 WM_APIID_START_PARENT, // 8 : WM_StartParent() 73 WM_APIID_END_PARENT, // 9 : WM_EndParent() 74 WM_APIID_START_SCAN, // 10 : WM_StartScan() 75 WM_APIID_END_SCAN, // 11 : WM_EndScan() 76 WM_APIID_START_CONNECT, // 12 : WM_StartConnect() 77 WM_APIID_DISCONNECT, // 13 : WM_Disconnect() 78 WM_APIID_START_MP, // 14 : WM_StartMP() 79 WM_APIID_SET_MP_DATA, // 15 : WM_SetMPData() 80 WM_APIID_END_MP, // 16 : WM_EndMP() 81 WM_APIID_START_DCF, // 17 : WM_StartDCF() 82 WM_APIID_SET_DCF_DATA, // 18 : WM_SetDCFData() 83 WM_APIID_END_DCF, // 19 : WM_EndDCF() 84 WM_APIID_SET_WEPKEY, // 20 : WM_SetWEPKey() 85 WM_APIID_START_KS, // 21 : WM_StartKeySharing() Kept for backward compatibility 86 WM_APIID_END_KS, // 22 : WM_EndKeySharing() Kept for backward compatibility 87 WM_APIID_GET_KEYSET, // 23 : WM_GetKeySet() 88 WM_APIID_SET_GAMEINFO, // 24 : WM_SetGameInfo() 89 WM_APIID_SET_BEACON_IND, // 25 : WM_SetBeaconIndication() 90 WM_APIID_START_TESTMODE, // 26 : WM_StartTestMode() 91 WM_APIID_STOP_TESTMODE, // 27 : WM_StopTestMode() 92 WM_APIID_VALARM_MP, // 28 : For starting up MP from VAlarm in ARM7 (special) 93 WM_APIID_SET_LIFETIME, // 29 : WM_SetLifeTime() 94 WM_APIID_MEASURE_CHANNEL, // 30 : WM_MeasureChannel() 95 WM_APIID_INIT_W_COUNTER, // 31 : WM_InitWirelessCounter() 96 WM_APIID_GET_W_COUNTER, // 32 : WM_GetWirelessCounter() 97 WM_APIID_SET_ENTRY, // 33 : WM_SetEntry() 98 WM_APIID_AUTO_DEAUTH, // 34 : For starting up automatic disconnection from indicate in ARM7. (special) 99 WM_APIID_SET_MP_PARAMETER, // 35 : WM_SetMPParameter() 100 WM_APIID_SET_BEACON_PERIOD, // 36 : WM_SetBeaconPeriod() 101 WM_APIID_AUTO_DISCONNECT, // 37 : For starting up automatic disconnection from indicate in ARM7. (special) 102 WM_APIID_START_SCAN_EX, // 38 : WM_StartScanEx() 103 WM_APIID_SET_WEPKEY_EX, // 39 : WM_SetWEPKeyEx() 104 WM_APIID_SET_PS_MODE, // 40 : WM_SetPowerSaveMode() 105 WM_APIID_START_TESTRXMODE, // 41 : WM_StartTestRxMode() 106 WM_APIID_STOP_TESTRXMODE, // 42 : WM_StopTestRxMode() 107 108 WM_APIID_KICK_MP_PARENT, // 43 : For starting up MP (ARM7 internal use) 109 WM_APIID_KICK_MP_CHILD, // 44 : For starting up MP (ARM7 internal use) 110 WM_APIID_KICK_MP_RESUME, // 45 : For starting up MP (ARM7 internal use) 111 112 WM_APIID_ASYNC_KIND_MAX, // 46 : Type of asynchronous process 113 114 WM_APIID_INDICATION = 128, // 128 : For indication callback 115 WM_APIID_PORT_SEND, // 129 : Notification to port of data being sent 116 WM_APIID_PORT_RECV, // 130 : Notification to port of data being received 117 WM_APIID_READ_STATUS, // 131 : WM_ReadStatus() 118 119 WM_APIID_UNKNOWN = 255 // 255 : Value returned from ARM7 at unknown command number 120 } 121 WMApiid; 122 123 // for backward compatibility 124 //#define WM_APIID_SET_MP_FREQ WM_APIID_SET_MP_PARAMETER 125 126 // Flag for completion of receiving the API requests on ARM7 side. 127 #define WM_API_REQUEST_ACCEPTED 0x8000 128 129 // WEP mode 130 #define WM_WEPMODE_NO 0 131 #define WM_WEPMODE_40BIT 1 132 #define WM_WEPMODE_104BIT 2 133 #define WM_WEPMODE_128BIT 3 134 135 // AUTH mode (used by WM_StartConnectEx) 136 #define WM_AUTHMODE_OPEN_SYSTEM 0 137 #define WM_AUTHMODE_SHARED_KEY 1 138 139 // ScanType 140 #define WM_SCANTYPE_ACTIVE 0 141 #define WM_SCANTYPE_PASSIVE 1 142 143 #if WM_SSID_MASK_CUSTOMIZE 144 #define WM_SCANTYPE_ACTIVE_CUSTOM 2 145 #define WM_SCANTYPE_PASSIVE_CUSTOM 3 146 #endif 147 148 // Maximum number of children that can connect in one BSS 149 #define WM_NUM_MAX_CHILD 15 // The maximum value possible for the AssociationID provided by the NITRO parent 150 #define WM_NUM_MAX_AP_AID 2007 // The maximum value possible for the AssociationID provided by the wireless router 151 152 // Port number 153 #define WM_NUM_OF_PORT 16 // Number of ports 154 #define WM_NUM_OF_SEQ_PORT 8 // Number of ports that perform sequential processing 155 typedef enum WMPort 156 { 157 // Group of ports that do not perform sequential control 158 WM_PORT_RAWDATA = 0, // Port for backward compatibility 159 WM_PORT_BT = 1, // Port for block transfer 160 WM_PORT_RESERVE_02 = 2, // Reserved 161 WM_PORT_RESERVE_03 = 3, // Reserved 162 163 // Group of ports that perform sequential control 164 WM_PORT_RESERVE_10 = 8, // Reserved 165 WM_PORT_RESERVE_11 = 9, // Reserved 166 WM_PORT_RESERVE_12 = 10, // Reserved 167 WM_PORT_RESERVE_13 = 11 // Reserved 168 } 169 WMPort; 170 171 // Send queue-related 172 #define WM_SEND_QUEUE_NUM 32 // Total 32 level queue list 173 #define WM_SEND_QUEUE_END ((u16)0xffff) // Value that indicates tail 174 #define WM_PRIORITY_LEVEL 4 // 4 priority levels 175 typedef enum WMPriorityLevel 176 { 177 WM_PRIORITY_URGENT = 0, 178 WM_PRIORITY_HIGH, 179 WM_PRIORITY_NORMAL, 180 WM_PRIORITY_LOW 181 } 182 WMPriorityLevel; 183 184 // Default V Count value to start the MP send operation on the ARM7 side 185 #define WM_VALARM_COUNT_CHILD_MP 240 // Child MP operation 186 #define WM_VALARM_COUNT_PARENT_MP 260 // Parent MP operation 187 #define WM_VALARM_COUNT_RANGE_TOP 220 // Highest limit on possible settings for parentVCount and childVCount (220 - 262, 0 - 190) 188 #define WM_VALARM_COUNT_RANGE_BOTTOM 190 // Lowest limit on possible settings for parentVCount and childVCount. 189 190 // Send interval 191 #define WM_MP_FREQ_CONT 16 // Send frequency that becomes continuous send 192 #define WM_MP_COUNT_LIMIT 256 // Upper limit of the counter for the number of sends remaining. 193 #define WM_DEFAULT_MP_FREQ_LIMIT 6 // Default upper limit for MP frequency 194 #define WM_DEFAULT_MP_PARENT_INTERVAL 1000 // Default parent MP interval (in microseconds) 195 #define WM_DEFAULT_MP_CHILD_INTERVAL 0 // Default child MP interval (in microseconds) 196 197 // Size of each type of data (bytes) 198 #define WM_SIZE_BSSID 6 199 #define WM_SIZE_SSID 32 200 201 #define WM_SIZE_GAMEINFO 128 // Maximum size 202 203 #define WM_SIZE_SCAN_EX_BUF 1024 // Buffer size for StartScanEx 204 205 #define WM_GAMEINFO_LENGTH_MIN 16 // Minimum size of valid GameInfo 206 #define WM_GAMEINFO_MAGIC_NUMBER 0x0001 // DS GameInfo magic number for identification purposes 207 #define WM_GAMEINFO_VERSION_NUMBER 1 // GameInfo version number 208 #define WM_GAMEINFO_PLATFORM_ID_NITRO 0 // Parent device is a DS 209 #define WM_GAMEINFO_PLATFORM_ID_REVOLUTION 8 // Parent device is a Wii 210 #define WM_SIZE_SYSTEM_GAMEINFO 16 // size up to userGameInfoLength 211 #define WM_SIZE_USER_GAMEINFO 112 // Maximum user area size for GameInfo 212 213 #define WM_SIZE_SCAN_PARAM 32 214 215 #define WM_PARENT_PARAM_SIZE 64 216 #define WM_SIZE_USERNAME 8 217 #define WM_SIZE_GAMENAME 16 218 #define WM_SIZE_GGID 4 219 220 #define WM_SIZE_WL_VERSION 8 221 #define WM_SIZE_BBP_VERSION 4 222 #define WM_SIZE_MACADDR 6 223 #define WM_SIZE_WEPKEY 80 224 225 #define WM_SIZE_CHILD_SSID 24 226 227 #if ( SDK_VERSION_WL >= 21100 ) 228 #define WM_SIZE_MP_DATA_MAX 512 229 #else 230 #define WM_SIZE_MP_DATA_MAX 508 231 #endif 232 233 #define WM_SIZE_MADATA_HEADER 44 234 235 // Number of bytes needed between packets when parent puts multiple packets in one MP communication 236 #define WM_SIZE_MP_PARENT_PADDING (WM_HEADER_SIZE + WM_HEADER_PARENT_MAX_SIZE) 237 // Number of bytes needed between packets when child puts multiple packets in one MP communication 238 #define WM_SIZE_MP_CHILD_PADDING (WM_HEADER_SIZE + WM_HEADER_CHILD_MAX_SIZE) 239 240 #define WM_SIZE_DS_PARENT_HEADER 4 241 #define WM_SIZE_KS_PARENT_DATA (2*16+WM_SIZE_DS_PARENT_HEADER) 242 #define WM_SIZE_KS_CHILD_DATA 2 243 244 // Attribute flags 245 246 #define WM_ATTR_ENTRY_SHIFT 0 247 #define WM_ATTR_MB_SHIFT 1 248 #define WM_ATTR_KS_SHIFT 2 249 #define WM_ATTR_CS_SHIFT 3 250 251 #define WM_ATTR_FLAG_ENTRY (1 << WM_ATTR_ENTRY_SHIFT) 252 #define WM_ATTR_FLAG_MB (1 << WM_ATTR_MB_SHIFT) 253 #define WM_ATTR_FLAG_KS (1 << WM_ATTR_KS_SHIFT) 254 #define WM_ATTR_FLAG_CS (1 << WM_ATTR_CS_SHIFT) 255 256 // For callback exclusive control 257 #define WM_EXCEPTION_CB_MASK 0x0001 258 259 // wmHeader 260 #define WM_HEADER_SIZE 2 // Number of bytes of shared parent/child wmHeader 261 262 //#define WM_HEADER_MP 0x0001 263 #define WM_HEADER_KS 0x4000 264 #define WM_HEADER_VSYNC 0x8000 265 266 // packetHeader 267 #define WM_HEADER_PARENT_MAX_SIZE 4 // Maximum number of bytes that can be added as header (excluding the 2 bytes of wmHeader) 268 // At present there are cases where Sequence Number and Destination Bitmap are added. 269 270 #define WM_HEADER_CHILD_MAX_SIZE 2 // Maximum number of bytes that can be added as header (excluding the 2 bytes of wmHeader) 271 // At present there are cases where Sequence Number is added. 272 273 #define WM_HEADER_PORT_MASK 0x0f00 274 #define WM_HEADER_PORT_SHIFT 8 275 #define WM_HEADER_SEQ_FLAG 0x0800 276 #define WM_HEADER_DEST_BITMAP 0x1000 277 #define WM_HEADER_LENGTH_MASK 0x00ff 278 #define WM_HEADER_LENGTH_SCALE 2 279 280 #define WM_SEQ_PORT_FLAG 0x0008 281 #define WM_SEQ_PORT_MASK 0x0007 282 283 // packetHeader Seq No Field (second byte) 284 #define WM_HEADER_SEQ_RETRY 0x8000 285 #define WM_HEADER_SEQ_NUM_MASK 0x7fff 286 287 // Maximum number of packets that can be packed into one envelope. (>= WM_SIZE_MP_DATA_MAX/WM_SIZE_MP_PARENT_PADDING + 1) 288 #define WM_PACKED_PACKET_MAX 128 289 290 291 // API result codes 292 typedef enum WMErrCode 293 { 294 WM_ERRCODE_SUCCESS = 0, 295 WM_ERRCODE_FAILED = 1, 296 WM_ERRCODE_OPERATING = 2, 297 WM_ERRCODE_ILLEGAL_STATE = 3, 298 WM_ERRCODE_WM_DISABLE = 4, 299 WM_ERRCODE_NO_KEYSET = 5, 300 WM_ERRCODE_NO_DATASET = 5, // Same value as NO_KEYSET 301 WM_ERRCODE_INVALID_PARAM = 6, 302 WM_ERRCODE_NO_CHILD = 7, 303 WM_ERRCODE_FIFO_ERROR = 8, 304 WM_ERRCODE_TIMEOUT = 9, 305 WM_ERRCODE_SEND_QUEUE_FULL = 10, 306 WM_ERRCODE_NO_ENTRY = 11, 307 WM_ERRCODE_OVER_MAX_ENTRY = 12, 308 WM_ERRCODE_INVALID_POLLBITMAP = 13, 309 WM_ERRCODE_NO_DATA = 14, 310 WM_ERRCODE_SEND_FAILED = 15, 311 312 WM_ERRCODE_DCF_TEST, // For debugging 313 WM_ERRCODE_WL_INVALID_PARAM, // For debugging (can delete) 314 WM_ERRCODE_WL_LENGTH_ERR, // For debugging (can delete) 315 316 WM_ERRCODE_FLASH_ERROR, // WL flash parameter error (freezes because it is fatal) 317 WM_ERRCODE_MAX 318 } 319 WMErrCode; 320 321 // State codes returned by the API's callback 322 typedef enum WMStateCode 323 { 324 WM_STATECODE_PARENT_START = 0, // For StartParent. Started parent operation 325 WM_STATECODE_BEACON_SENT = 2, // For StartParent. Beacon send completed 326 327 WM_STATECODE_SCAN_START = 3, // For StartScan. Started Scan operation 328 WM_STATECODE_PARENT_NOT_FOUND = 4, // For StartScan. Cannot find parent 329 WM_STATECODE_PARENT_FOUND = 5, // For StartScan. Found parent 330 331 WM_STATECODE_CONNECT_START = 6, // For StartConnect. Started connect process 332 WM_STATECODE_BEACON_LOST = 8, // For StartConnect. Lost parent's beacon 333 334 WM_STATECODE_CONNECTED = 7, // For StartParent and StartConnect, connection complete for port. 335 WM_STATECODE_CHILD_CONNECTED = 7, // Same value as WM_STATECODE_CONNECTED 336 WM_STATECODE_DISCONNECTED = 9, // Notification of disconnection for StartParent and StartConnect port. 337 WM_STATECODE_DISCONNECTED_FROM_MYSELF = 26, // Notification of disconnection from self for StartParent and StartConnect port. 338 339 WM_STATECODE_MP_START = 10, // For StartMP. Started MP communication mode. 340 WM_STATECODE_MPEND_IND = 11, // For StartMP. Parent MP sequence complete (receive) 341 WM_STATECODE_MP_IND = 12, // For StartMP. Child MP receive 342 WM_STATECODE_MPACK_IND = 13, // For StartMP. Child MPACK receive 343 344 WM_STATECODE_DCF_START = 14, // For StartDCF. Started DCF communication mode. 345 WM_STATECODE_DCF_IND = 15, // For StartDCF. Received DCF data 346 347 WM_STATECODE_BEACON_RECV = 16, // Indicate beacon received 348 WM_STATECODE_DISASSOCIATE = 17, // Indicate disconnection 349 WM_STATECODE_REASSOCIATE = 18, // Indicate reconnection 350 WM_STATECODE_AUTHENTICATE = 19, // Indicate confirmed authentication 351 352 WM_STATECODE_PORT_INIT = 25, // Initialize port 353 WM_STATECODE_PORT_SEND = 20, // Send data to port 354 WM_STATECODE_PORT_RECV = 21, // Receive data from port 355 356 WM_STATECODE_FIFO_ERROR = 22, // FIFO error occurrence notification in ARM7 357 WM_STATECODE_INFORMATION = 23, // Notification of information 358 WM_STATECODE_UNKNOWN = 24, // Unspecified notification 359 360 WM_STATECODE_MAX = 27 361 } 362 WMStateCode; 363 364 // WM state codes 365 typedef enum WMState 366 { 367 WM_STATE_READY = 0, // READY state (before Init, LED normal lighting state) 368 WM_STATE_STOP, // STOP state (Before Initialize, LED blinking state) 369 WM_STATE_IDLE, // IDLE state (After Initialize. After Reset, etc) 370 WM_STATE_CLASS1, // CLASS1 state 371 WM_STATE_TESTMODE, // TESTMODE (for applying) 372 WM_STATE_SCAN, // During StartScan 373 WM_STATE_CONNECT, // During StartConnect 374 WM_STATE_PARENT, // During StartParent 375 WM_STATE_CHILD, // Child after connect complete 376 WM_STATE_MP_PARENT, // Parent after StartMP 377 WM_STATE_MP_CHILD, // Child after StartMP 378 WM_STATE_DCF_CHILD, // Child after StartDCF 379 WM_STATE_TESTMODE_RX, // TESTMODE_RX 380 381 WM_STATE_MAX 382 } 383 WMState; 384 385 // Link strength 386 typedef enum WMLinkLevel 387 { 388 WM_LINK_LEVEL_0 = 0, 389 WM_LINK_LEVEL_1, 390 WM_LINK_LEVEL_2, 391 WM_LINK_LEVEL_3, 392 WM_LINK_LEVEL_MAX 393 } 394 WMLinkLevel; 395 396 // Data Sharing's internal state 397 typedef enum WMDataSharingState 398 { 399 WM_DS_STATE_READY = 0, // Before WM_StartDataSharing 400 WM_DS_STATE_START, // During WM_StepDataSharing 401 WM_DS_STATE_PAUSING, // While transitioning to the pause state 402 WM_DS_STATE_PAUSED, // Immediately after WM_StartDataSharing or during pause 403 WM_DS_STATE_RETRY_SEND, // Resend required because of SEND_QUEUE_FULL 404 WM_DS_STATE_ERROR // Error generated 405 } 406 WMDataSharingState; 407 408 // Reason code for disconnect 409 typedef enum WMDisconnectReason 410 { 411 // Reason value for disconnect due to external cause 412 WM_DISCONNECT_REASON_RESERVED = 0, // Reserved 413 WM_DISCONNECT_REASON_UNSPECIFIED = 1, // Error that cannot be specifically identified 414 WM_DISCONNECT_REASON_PREV_AUTH_INVALID = 2, // The immediately previous authentication is no longer valid. 415 WM_DISCONNECT_REASON_DEAUTH_LEAVING = 3, // Deauthenticated because unit has left the BSS. 416 WM_DISCONNECT_REASON_INACTIVE = 4, // Released connection due to inactivity. 417 WM_DISCONNECT_REASON_UNABLE_HANDLE = 5, // Released connection due to lack of sufficient resources for AP. 418 WM_DISCONNECT_REASON_RX_CLASS2_FROM_NONAUTH_STA = 6, // A Class2 frame was received from an unauthenticated STA. 419 WM_DISCONNECT_REASON_RX_CLASS3_FROM_NONASSOC_STA = 7, // A Class3 frame was received from an unconnected STA. 420 WM_DISCONNECT_REASON_DISASSOC_LEAVING = 8, // Released association because unit has left the BSS. 421 WM_DISCONNECT_REASON_ASSOC_STA_NOTAUTHED = 9, // An STA which has requested connection has not yet undergone authentication. 422 // Reason value specific to local DS communications 423 WM_DISCONNECT_REASON_NO_ENTRY = 19, // DS parent is not currently accepting entries. 424 // Reason value related to auto disconnect from inside the library 425 WM_DISCONNECT_REASON_MP_LIFETIME = 0x8001, // MP communication lifetime has run out. 426 WM_DISCONNECT_REASON_TGID_CHANGED = 0x8002, // TGID changed during receive beacon. 427 WM_DISCONNECT_REASON_FATAL_ERROR = 0x8003, // An unrecoverable error has occurred in the library. 428 // Reason value relating to disconnect due to library 429 WM_DISCONNECT_REASON_FROM_MYSELF = 0xf001 // Self-initiated disconnect using the WM API has been performed. 430 } 431 WMDisconnectReason; 432 433 // Notifications 434 typedef enum WMInfoCode 435 { 436 WM_INFOCODE_NONE = 0, 437 WM_INFOCODE_FATAL_ERROR // Notification regarding occurrence of fatal error 438 } 439 WMInfoCode; 440 441 // Constant for the WM_SetMPParameter function's mask 442 #define WM_MP_PARAM_MIN_FREQUENCY 0x0001 443 #define WM_MP_PARAM_FREQUENCY 0x0002 444 #define WM_MP_PARAM_MAX_FREQUENCY 0x0004 445 #define WM_MP_PARAM_PARENT_SIZE 0x0008 446 #define WM_MP_PARAM_CHILD_SIZE 0x0010 447 #define WM_MP_PARAM_PARENT_INTERVAL 0x0020 448 #define WM_MP_PARAM_CHILD_INTERVAL 0x0040 449 #define WM_MP_PARAM_PARENT_VCOUNT 0x0080 450 #define WM_MP_PARAM_CHILD_VCOUNT 0x0100 451 #define WM_MP_PARAM_DEFAULT_RETRY_COUNT 0x0200 452 #define WM_MP_PARAM_MIN_POLL_BMP_MODE 0x0400 453 #define WM_MP_PARAM_SINGLE_PACKET_MODE 0x0800 454 #define WM_MP_PARAM_IGNORE_FATAL_ERROR_MODE 0x1000 455 #define WM_MP_PARAM_IGNORE_SIZE_PRECHECK_MODE 0x2000 456 457 // List of parameters that cannot be set during MP communications 458 #define WM_MP_PARAM_MUST_SET_BEFORE_MP (WM_MP_PARAM_MIN_POLL_BMP_MODE|WM_MP_PARAM_SINGLE_PACKET_MODE|WM_MP_PARAM_IGNORE_SIZE_PRECHECK_MODE) 459 460 // Constants for WMMPTmpParam.mask 461 #define WM_MP_TMP_PARAM_MIN_FREQUENCY 0x0001 462 #define WM_MP_TMP_PARAM_FREQUENCY 0x0002 463 #define WM_MP_TMP_PARAM_MAX_FREQUENCY 0x0004 464 #define WM_MP_TMP_PARAM_DEFAULT_RETRY_COUNT 0x0200 465 #define WM_MP_TMP_PARAM_MIN_POLL_BMP_MODE 0x0400 466 #define WM_MP_TMP_PARAM_SINGLE_PACKET_MODE 0x0800 467 #define WM_MP_TMP_PARAM_IGNORE_FATAL_ERROR_MODE 0x1000 468 469 // Maximum parameter value 470 #define WM_MP_PARAM_INTERVAL_MAX 10000 // The value specified for interval must be 10000us or lower. 471 472 // miscFlags constants 473 #define WM_MISC_FLAG_LISTEN_ONLY 0x0001 474 #define WM_MISC_FLAG_NO_BLINK 0x0002 475 476 // WM API callback type 477 typedef void (*WMcallbackFunc) (void *arg); // WM API callback type 478 typedef void (*WMCallbackFunc) (void *arg); // WM API callback type 479 480 // Buffer size ======================================================================= 481 482 //������������������������ 483 //| WM9 variable | 512 484 //������������������������ 485 //| WM7 variable | 256 + 512 486 //������������������������ 487 //| WM status | 2048 488 //������������������������ 489 //| FIFO buf (9 -> 7) | 256 490 //������������������������ 491 //| FIFO buf (9 <- 7) | 256 492 //������������������������ 493 494 // Size of the buffer to use with WM functions ------------- 495 496 #define WM_ARM9WM_BUF_SIZE 512 // Size of the WM variable area on ARM9 side 497 #define WM_ARM7WM_BUF_SIZE ( 256 + 512 ) // Size of the WM variable area on ARM7 side 498 #define WM_STATUS_BUF_SIZE 2048 // Size of the WM status area 499 #define WM_FIFO_BUF_SIZE 256 // Size of the FIFO command buffer between ARM9 and ARM7 500 501 // Size of the buffer allocated by the user ------------- 502 // Size of all buffers used by WM system 512 + 256 + 512 + 2048 + 256 + 256 = 0xf00 (Notice that this is FIFO_BIF * 2) 503 #define WM_SYSTEM_BUF_SIZE (WM_ARM9WM_BUF_SIZE + WM_ARM7WM_BUF_SIZE + WM_STATUS_BUF_SIZE + WM_FIFO_BUF_SIZE + WM_FIFO_BUF_SIZE) 504 #define WM_BSS_DESC_SIZE 192 // Size of the buffer for storing parent information passed by WM_StartScan() 505 506 #define WM_DCF_MAX_SIZE 1508 // Maximum size that can be received with DCF 507 #define WM_KEYSET_SIZE 36 // Size of KeySet 508 #define WM_KEYDATA_SIZE 2 // Size of KeyData 509 510 #define WM_DS_HEADER_SIZE 4 511 512 #ifdef WM_DS_DATA_SIZE_252 // When it is OK to set 252 for WM_DS_DATA_SIZE 513 #define WM_DS_DATA_SIZE 252 514 #else // When WM_DS_DATA_SIZE == 508 (default) 515 #define WM_DS_DATA_SIZE 508 // Maximum data size of one WMDataSet (512-4) 516 // WM_DS_DATA_SIZE+WM_DS_HEADER_SIZE needs to be multiples of 32 517 #endif 518 519 #define WM_DS_DATASET_NUM 4 // How many WMDataSet to be kept in WMDataSetBuf (fixed value) 520 #define WM_DS_INFO_SIZE (sizeof(WMDataSharingInfo)) // Buffer size for DataSharing 521 522 #define WM_SCAN_EX_PARENT_MAX 16 // Maximum number of parent devices that can be found with one ScanEx 523 #define WM_SCAN_OTHER_ELEMENT_MAX 16 // Maximum number of otherElement that can be acknowledged 524 525 // Enable or disable wireless communications 526 #ifdef SDK_TWL 527 #define WM_WIRELESS_COMM_FLAG_OFF 0 // Mode with wireless communications on 528 #define WM_WIRELESS_COMM_FLAG_ON 1 // Mode with wireless communications off 529 #define WM_WIRELESS_COMM_FLAG_UNKNOWN 2 // This cannot be determined because the program is running on a DS 530 #endif 531 532 /*---------------------------------------------------------------------------* 533 Structure Definitions 534 *---------------------------------------------------------------------------*/ 535 536 // Buffer structure ======================================================================= 537 538 // Data set structure 539 typedef struct WMDataSet 540 { 541 // u16 seqNum; // data set sequential number 542 u16 aidBitmap; 543 u16 receivedBitmap; // Bit map of receive status 544 u16 data[WM_DS_DATA_SIZE / sizeof(u16)]; // Shared data 545 546 } 547 WMDataSet; 548 549 // DataSharing information structure 550 typedef struct WMDataSharingInfo 551 { 552 WMDataSet ds[WM_DS_DATASET_NUM]; 553 u16 seqNum[WM_DS_DATASET_NUM]; // Sequential Number 554 u16 writeIndex; // Next Index to write 555 u16 sendIndex; // Index currently being sent 556 u16 readIndex; // Next Index to read 557 u16 aidBitmap; // bitmap of data sharing group (including self) 558 u16 dataLength; // Amount of shared data per unit 559 u16 stationNumber; // Number of units sharing data (number of bits set to 1 in aidBitmap) 560 u16 dataSetLength; // dataLength * stationNumber 561 u16 port; // Port being used (number 8 or above) 562 u16 doubleMode; // In mode for alternately sending/receiving each frame? 563 u16 currentSeqNum; // SeqNum of the DataSet read most recently 564 u16 state; // Current DataSharing state (WMDataSharingState) 565 u16 reserved[1]; // for 32-byte alignment 566 } 567 WMDataSharingInfo; 568 569 // Key set structure 570 typedef struct WMKeySet 571 { 572 u16 seqNum; // Key set's sequential number 573 u16 rsv; 574 u16 key[16]; // Key data 575 576 } 577 WMKeySet, WMkeySet; 578 579 // Ring buffer for saving key set 580 typedef WMDataSharingInfo WMKeySetBuf, WMkeySetBuf; 581 582 //--------------------------------------- 583 // Parent/Child shared MP port send queue structure 584 typedef struct 585 { 586 u16 next; 587 u16 port; 588 u16 destBitmap; 589 u16 restBitmap; 590 u16 sentBitmap; 591 u16 sendingBitmap; 592 u16 padding; 593 u16 size; 594 u16 seqNo; 595 u16 retryCount; 596 const u16 *data; 597 WMCallbackFunc callback; 598 void *arg; 599 } 600 WMPortSendQueueData; 601 602 typedef struct 603 { 604 u16 head; 605 u16 tail; 606 } 607 WMPortSendQueue; 608 609 //--------------------------------------- 610 // Child MP receive buffer structure 611 typedef struct WMMpRecvBuf 612 { 613 u16 rsv1[3]; 614 u16 length; 615 616 u16 rsv2[1]; 617 u16 ackTimeStamp; 618 u16 timeStamp; 619 u16 rate_rssi; 620 u16 rsv3[2]; 621 622 u16 rsv4[2]; 623 u8 destAdrs[6]; 624 u8 srcAdrs[6]; 625 u16 rsv5[3]; 626 u16 seqCtrl; 627 628 u16 txop; 629 u16 bitmap; 630 u16 wmHeader; 631 u16 data[2]; 632 633 } 634 WMMpRecvBuf, WMmpRecvBuf; 635 636 //--------------------------------------- 637 // Parent MP receive buffer structure 638 typedef struct WMMpRecvData 639 { 640 u16 length; 641 u16 rate_rssi; 642 u16 aid; 643 u16 noResponse; 644 u16 wmHeader; 645 u16 cdata[1]; 646 647 } 648 WMMpRecvData, WMmpRecvData; 649 650 typedef struct WMMpRecvHeader 651 { 652 u16 bitmap; 653 #if SDK_VERSION_WL >= 20500 654 u16 errBitmap; 655 #endif 656 u16 count; 657 u16 length; 658 u16 txCount; 659 WMMpRecvData data[1]; 660 661 } 662 WMMpRecvHeader, WMmpRecvHeader; 663 664 //--------------------------------------- 665 // Child DCF receive buffer structure 666 typedef struct WMDcfRecvBuf 667 { 668 u16 frameID; 669 u16 rsv1[2]; 670 u16 length; 671 672 u16 rsv2[3]; 673 u16 rate_rssi; 674 u16 rsv3[4]; 675 u8 destAdrs[6]; 676 u8 srcAdrs[6]; 677 u16 rsv4[4]; 678 679 u16 data[2]; 680 681 } 682 WMDcfRecvBuf, WMdcfRecvBuf; 683 684 //--------------------------------------- 685 // WM parent parameter structure 686 typedef struct WMParentParam 687 { 688 u16 *userGameInfo; // Pointer to data to set in user area 689 u16 userGameInfoLength; // Length of user area 690 u16 padding; 691 692 u32 ggid; 693 u16 tgid; // Temporary GameID (generated each time a user becomes a parent) 694 u16 entryFlag; // 1: Connect possible, 0: Connect not possible 695 u16 maxEntry; // Number of child devices that can connect 696 u16 multiBootFlag; // 1: Multiboot possible, 0: Multiboot not possible 697 u16 KS_Flag; // 1: KeySharing OK, 0: No KeySharing 698 u16 CS_Flag; // 1: Continuous send, 0: Send in each frame 699 u16 beaconPeriod; // Beacon interval (ms) 700 u16 rsv1[WM_SIZE_USERNAME / sizeof(u16)]; // 701 u16 rsv2[WM_SIZE_GAMENAME / sizeof(u16)]; // 702 u16 channel; // Channel 703 u16 parentMaxSize; // Maximum parent send size 704 u16 childMaxSize; // Maximum child send size 705 706 u16 rsv[4]; // For 32-byte alignment 707 708 } 709 WMParentParam, WMpparam; 710 711 //--------------------------------------- 712 // WM GameInfo Structure 713 714 typedef struct WMGameInfo 715 { 716 u16 magicNumber; // == 0x0001 717 u8 ver; // GameInfo Version 1 718 u8 platform; // DS: 0, Wii: 8 719 u32 ggid; 720 u16 tgid; 721 u8 userGameInfoLength; // Length of user area 722 union 723 { 724 // (CS_Flag):1, (KS_Flag):1, multibootFlag:1, entryFlag:1 725 u8 gameNameCount_attribute; // Old name for compatibility purposes 726 u8 attribute; 727 }; 728 u16 parentMaxSize; //Maximum parent send size 729 u16 childMaxSize; //Maximum child send size 730 union 731 { 732 u16 userGameInfo[WM_SIZE_USER_GAMEINFO / sizeof(u16)]; // User region (Maximum: 112 bytes (provisional)) 733 struct 734 { 735 u16 userName[WM_SIZE_USERNAME / sizeof(u16)]; // WM_SIZE_USERNAME -> 8 736 u16 gameName[WM_SIZE_GAMENAME / sizeof(u16)]; // WM_SIZE_GAMENAME -> 16 737 u16 padd1[44]; // pad -> 88 738 } 739 old_type; // Total: 112 bytes 740 }; 741 } 742 WMGameInfo, WMgameInfo; 743 744 //--------------------------------------- 745 // BSSDescription. Parent information structure (Acquired with Scan. Used for specifications in Connect) 746 #if SDK_VERSION_WL < 17100 747 typedef struct WMBssDesc 748 { 749 u16 length; // 2 750 u16 rssi; // 4 751 u8 bssid[WM_SIZE_BSSID]; // 10 752 u16 ssidLength; // 12 753 u8 ssid[WM_SIZE_SSID]; // 44 754 u16 capaInfo; // 46 755 struct 756 { 757 u16 basic; // 48 758 u16 support; // 50 759 } 760 rateSet; 761 u16 beaconPeriod; // 52 762 u16 dtimPeriod; // 54 763 u16 channel; // 56 764 u16 cfpPeriod; // 58 765 u16 cfpMaxDuration; // 60 766 u16 gameInfoLength; // 62 767 WMGameInfo gameInfo; // 190 768 u16 rsv; // 192 769 770 } 771 WMBssDesc, WMbssDesc; 772 #else 773 typedef struct WMBssDesc 774 { 775 u16 length; // 2 776 u16 rssi; // 4 777 u8 bssid[WM_SIZE_BSSID]; // 10 778 u16 ssidLength; // 12 779 u8 ssid[WM_SIZE_SSID]; // 44 780 u16 capaInfo; // 46 781 struct 782 { 783 u16 basic; // 48 784 u16 support; // 50 785 } 786 rateSet; 787 u16 beaconPeriod; // 52 788 u16 dtimPeriod; // 54 789 u16 channel; // 56 790 u16 cfpPeriod; // 58 791 u16 cfpMaxDuration; // 60 792 u16 gameInfoLength; // 62 793 u16 otherElementCount; // 64 794 WMGameInfo gameInfo; // 192 795 796 } 797 WMBssDesc, WMbssDesc; 798 #endif 799 800 //--------------------------------------- 801 // Extended element structure within WM beacon 802 typedef struct WMOtherElements 803 { 804 u8 count; 805 u8 rsv[3]; 806 struct 807 { 808 u8 id; 809 u8 length; 810 u8 rsv[2]; 811 u8 *body; 812 } 813 element[WM_SCAN_OTHER_ELEMENT_MAX]; 814 } 815 WMOtherElements; 816 817 //--------------------------------------- 818 // WM Scan parameter Structure 819 typedef struct WMScanParam 820 { 821 WMBssDesc *scanBuf; // Buffer that stores parent information 822 u16 channel; // Channel which carries out Scan 823 u16 maxChannelTime; // Maximum Scan time 824 u8 bssid[WM_SIZE_BSSID]; // MacAddress of Scan target parent (if 0xff, all parents are targets) 825 u16 rsv[9]; 826 827 } 828 WMScanParam, WMscanParam; 829 830 //--------------------------------------- 831 // WM ScanEx parameter structure 832 typedef struct WMScanExParam 833 { 834 WMBssDesc *scanBuf; // Buffer that stores parent information 835 u16 scanBufSize; // Size of scanBuf 836 u16 channelList; // List of channels to do Scan for (Can specify multiple. Same format as the return value for WM_GetAllowedChannel) 837 u16 maxChannelTime; // Maximum Scan time 838 u8 bssid[WM_SIZE_BSSID]; // MacAddress of Scan target parent (if 0xff, all parents are targets) 839 u16 scanType; // Normally WM_SCANTYPE_PASSIVE. WM_SCANTYPE_ACTIVE during ActiveScan 840 u16 ssidLength; // SSID length of target parent (if 0, all parents are targets) 841 u8 ssid[WM_SIZE_SSID]; // SSID of parent that is target of Scan 842 #if WM_SSID_MASK_CUSTOMIZE 843 u16 ssidMatchLength; 844 u16 rsv2[7]; 845 #else 846 u16 rsv2[8]; 847 #endif 848 849 } 850 WMScanExParam, WMscanExParam; 851 852 //--------------------------------------- 853 // WM SetMPParameter parameter structure 854 typedef struct WMMPParam 855 { 856 u32 mask; // Which of the fields below is valid is set by bits. 857 858 u16 minFrequency; // Number of MP cycles with one picture frame (minimum value)(un-implemented) 859 u16 frequency; // Number of MP cycles in one picture frame 860 u16 maxFrequency; // Number of MP cycles in one picture frame (upper limit value) 861 u16 parentSize; // Current parent send size 862 u16 childSize; // Current child send size 863 u16 parentInterval; // If performed continuously, the parent MP communications interval within one frame (in microseconds) 864 u16 childInterval; // If performed continuously, the interval a child takes to prepare MP communications within one frame (in microseconds) 865 u16 parentVCount; // The starting V Count for parent processing when in frame synchronous communications 866 u16 childVCount; // The starting V Count for child processing when in frame synchronous communications 867 u16 defaultRetryCount; // Number of communications default retries in the Raw communications port 868 u8 minPollBmpMode; // Mode that minimizes to fit the send target of the packet that sends PollBitmap 869 u8 singlePacketMode; // Mode that only sends 1 packet in 1 MP 870 u8 ignoreFatalErrorMode; // Mode that ignores fatal errors 871 u8 ignoreSizePrecheckMode; // Mode that ignores the preliminary check of the send / receive size when starting communications 872 } 873 WMMPParam; 874 875 //--------------------------------------- 876 // Temporary parameter structure for WM StartMP 877 typedef struct WMMPTmpParam 878 { 879 u32 mask; // Which of the fields below is valid is set by bits. 880 881 u16 minFrequency; // Number of MP cycles with one picture frame (minimum value) (un-implemented) 882 u16 frequency; // Number of MP cycles in one picture frame 883 u16 maxFrequency; // Number of MP cycles in one picture frame (upper limit value) 884 u16 defaultRetryCount; // Number of communications default retries in the raw communications port 885 u8 minPollBmpMode; // Mode that minimizes to fit the send target of the packet that sends PollBitmap 886 u8 singlePacketMode; // Mode that only sends 1 packet in 1 MP 887 u8 ignoreFatalErrorMode; // Mode that ignores fatal errors 888 u8 reserved[1]; 889 } 890 WMMPTmpParam; 891 892 //--------------------------------------- 893 // WM status buffer structure (this is rewritten on the ARM7. On the ARM9, this can only be read) 894 typedef struct WMStatus 895 { 896 // State information (4 Bytes) 897 u16 state; // WM state information 898 u16 BusyApiid; // Busy APIID 899 900 // Flag (32 Bytes) 36 901 BOOL apiBusy; // API executing flag (Flag prohibiting issuing API, attributable to FIFO) 902 BOOL scan_continue; // Scan continue flag (As of 2004/07/19, not used) 903 BOOL mp_flag; // Flag that MP is in execution 904 BOOL dcf_flag; // Flag that DCF is in execution 905 BOOL ks_flag; // Flag that KeySharing is in execution 906 BOOL dcf_sendFlag; // 'Waiting for DCF send' flag 907 BOOL VSyncFlag; // 'VBlank sync OK' flag 908 909 // Version information (16 Bytes) 52 910 u8 wlVersion[WM_SIZE_WL_VERSION]; // WL version 911 u16 macVersion; // MAC version 912 u16 rfVersion; // RF version 913 u16 bbpVersion[WM_SIZE_BBP_VERSION / sizeof(u16)]; // BBP version 914 915 // MP-related (106 Bytes) 158 916 u16 mp_parentSize; // Send size in one MP communication transmission by the parent 917 u16 mp_childSize; // Send size in one MP communication transmission by the child 918 u16 mp_parentMaxSize; // Maximum send size in one MP communication transmission by the parent 919 u16 mp_childMaxSize; // Maximum send size in one MP communication transmission by the child 920 u16 mp_sendSize; // Maximum send size with current connection 921 u16 mp_recvSize; // Maximum receive size with current connection 922 u16 mp_maxSendSize; // Maximum send size with current connection (parentMaxSize+4 or childMaxSize+2) 923 u16 mp_maxRecvSize; // Maximum receive size with current connection (childMaxSize+2 or parentMaxSize+4) 924 u16 mp_parentVCount; // MP operation start VCount on the parent side 925 u16 mp_childVCount; // MP operation start VCount on the child side 926 u16 mp_parentInterval; // MP communications interval used by the parent (us) 927 u16 mp_childInterval; // MP communications interval used by the child (us) 928 929 OSTick mp_parentIntervalTick; // MP communications interval used by the parent (tick) 930 OSTick mp_childIntervalTick; // MP communications interval used by the child (tick) 931 932 u16 mp_minFreq; // Number of MP cycles in one picture frame (minimum) (un-implemented) 933 u16 mp_freq; // Number of MP cycles in one picture frame (standard value) 934 u16 mp_maxFreq; // Number of MP cycles in one picture frame (maximum value) 935 936 u16 mp_vsyncOrderedFlag; // Whether the next MP was instructed by the parent to synchronize to vsync 937 u16 mp_vsyncFlag; // Whether the next MP is performed by synchronizing to vsync 938 s16 mp_count; // How many more MP cycles for the current picture frame? 939 s16 mp_limitCount; // How many more times it is okay to MP in the current picture frame, including resends? 940 u16 mp_resumeFlag; // Flag that resume is in execution 941 u16 mp_prevPollBitmap; // PollBitmap in MP immediately before 942 u16 mp_prevWmHeader; // wmHeader in MP immediately before 943 u16 mp_prevTxop; // txop in immediately previous MP 944 u16 mp_prevDataLength; // dataLength in immediately previous MP 945 u16 mp_recvBufSel; // 'MP receive buffer selection' flag 946 u16 mp_recvBufSize; // Size of MP Receive buffer 947 WMMpRecvBuf *mp_recvBuf[2]; // Pointer to the MP receive buffer 948 u32 *mp_sendBuf; // Pointer to the MP send buffer 949 u16 mp_sendBufSize; // Size of the MP send buffer 950 951 u16 mp_ackTime; // MPACK estimated time of arrival 952 u16 mp_waitAckFlag; // Waiting for MPACK 953 954 u16 mp_readyBitmap; // Bitmap of children with MP preparations complete (for parent use) 955 956 u16 mp_newFrameFlag; // flag that becomes TRUE when a new picture frame comes 957 u8 reserved_b[2]; 958 u16 mp_sentDataFlag; // flag that reply data is sent (for child use) 959 u16 mp_bufferEmptyFlag; // 'reply data buffer is empty' flag (for child use) 960 u16 mp_isPolledFlag; // Was self polled in the last MP? (for child) 961 962 u16 mp_minPollBmpMode; // Mode that minimizes to fit the send target of the packet that sends PollBitmap 963 u16 mp_singlePacketMode; // Mode that only sends 1 packet in 1 MP 964 u8 reserved_c[2]; 965 u16 mp_defaultRetryCount; // default number of retries for communication on a port that does not do Seq control 966 u16 mp_ignoreFatalErrorMode; // Whether to ignore fatal errors 967 u16 mp_ignoreSizePrecheckMode; // Invalidates the preliminary check of the send / receive size when starting communications 968 969 u16 mp_pingFlag; // flag that is enabled with the same timing as ping 970 u16 mp_pingCounter; // counter of number of frames remaining until ping 971 972 // DCF-related (26 Bytes) 184 973 u8 dcf_destAdr[WM_SIZE_MACADDR]; // DCF send destination MAC address 974 u16 *dcf_sendData; // DCF send data pointer 975 u16 dcf_sendSize; // DCF send data size 976 u16 dcf_recvBufSel; // DCF receive buffer select flag 977 WMDcfRecvBuf *dcf_recvBuf[2]; // DCF receive buffer pointer 978 u16 dcf_recvBufSize; // DCF receive buffer size 979 980 u16 curr_tgid; // TGID of the parent that is currently connected (used with BeaconRecv.Ind) 981 982 // RSSI-related (4 Bytes) 206 983 u16 linkLevel; 984 u16 minRssi; 985 u16 rssiCounter; 986 987 // Additional parameters 988 u16 beaconIndicateFlag; // Flag that enables beacon-related notifications 989 u16 wepKeyId; // WEP key ID (0-3) 990 u16 pwrMgtMode; // Power management mode 991 u32 miscFlags; // miscellaneous flags 992 993 u16 VSyncBitmap; // Bitmap of children after V-Blank synchronization 994 u16 valarm_queuedFlag; // V-Alarm processes have accumulated in the run queue. 995 996 // V-Blank sync-related (14 Bytes) 218 997 u32 v_tsf; // For V-Blank sync. V_TSF value 998 u32 v_tsf_bak; // For V-Blank sync. Last acquired V_TSF value 999 u32 v_remain; // For V-Blank sync. Remaining adjustment 1000 u16 valarm_counter; // For V-Alarm interrupt occurrence counter 1001 1002 // Read wait flag (2 Byte) 220 1003 // u16 indbuf_read_wait; // Indication buffer read wait flag 1004 1005 u8 reserved_e[2]; 1006 1007 // Status of own self (8 Bytes) 228 1008 u8 MacAddress[WM_SIZE_MACADDR]; 1009 u16 mode; // Parent: WL_CMDLABEL_MODE_PARENT, Child: WL_CMDLABEL_MODE_CHILD 1010 1011 // Information to be used when it is parent (64 + 90 + 2 = 156 Bytes) 384 1012 WMParentParam pparam; // Parent parameter 1013 u8 childMacAddress[WM_NUM_MAX_CHILD][WM_SIZE_MACADDR]; 1014 u16 child_bitmap; // Connection status of children (used as poll bitmap) 1015 1016 // Information to be used when it is a child (14 Bytes) 398 1017 WMBssDesc *pInfoBuf; // Pointer to the buffer that is used for storing scanned parent information (given as an ARM9 API argument) 1018 u16 aid; // Current AID 1019 u8 parentMacAddress[WM_SIZE_MACADDR]; 1020 u16 scan_channel; // Channel that is currently doing Scan 1021 1022 u8 reserved_f[4]; 1023 1024 // WEP-related (86 Bytes) 488 1025 u16 wepMode; // WEP mode (how many bits is WEP?) 1026 BOOL wep_flag; // Indicates whether other party is requesting WEP 1027 u16 wepKey[WM_SIZE_WEPKEY / sizeof(u16)]; // WEP key (20Byte * 4) 1028 /* Placed wepKeyId about 40 lines above this. (2005/02/07 terui) */ 1029 1030 // Other (4 Bytes) 492 1031 u16 rate; // Utilization rate (WL_CMDLABEL_RATE_AUTO, 1M, 2M) 1032 u16 preamble; // Long:0, Short:1 1033 1034 // Various parameters (4 Bytes) 496 1035 u16 tmptt; 1036 u16 retryLimit; 1037 1038 // Usable channels (2 bytes) 498 1039 u16 enableChannel; 1040 1041 // Permitted channels (2 bytes) 500 1042 u16 allowedChannel; 1043 1044 // port-related (1316+256+20+4+256 Bytes) 1816+256+20+4+256 1045 u16 portSeqNo[WM_NUM_MAX_CHILD + 1][WM_NUM_OF_SEQ_PORT]; // 16*8*2 = 256 Bytes 1046 1047 WMPortSendQueueData sendQueueData[WM_SEND_QUEUE_NUM]; // 32*32 = 1024 bytes 1048 WMPortSendQueue sendQueueFreeList; // 4 Bytes 1049 WMPortSendQueue sendQueue[WM_PRIORITY_LEVEL]; // 16 Bytes 1050 WMPortSendQueue readyQueue[WM_PRIORITY_LEVEL]; // 16 Bytes 1051 OSMutex sendQueueMutex; // 20 bytes 1052 BOOL sendQueueInUse; // MP send wait flag 1053 1054 // Null Ack timeout ( 128 + 8 Byte ) 1055 OSTick mp_lastRecvTick[1 + WM_NUM_MAX_CHILD]; 1056 OSTick mp_lifeTimeTick; 1057 1058 // MP settings values that are currently valid 1059 // These configuration values are kept as persistent values set in the WM_SetMPParameter function and as temporary values set in the WM_StartMPEx function. They are duplicated so that the programmer does not need to keep the additional parameters specified in the WM_StartMPEx function persistent. 1060 // 1061 // 1062 // 1063 u16 mp_current_minFreq; // Number of MP cycles in one picture frame (minimum) (un-implemented) 1064 u16 mp_current_freq; // Number of MP cycles in one picture frame (standard value) 1065 u16 mp_current_maxFreq; // Number of MP cycles in one picture frame (maximum value) 1066 u16 mp_current_minPollBmpMode; // Mode that minimizes to fit the send target of the packet that sends PollBitmap 1067 u16 mp_current_singlePacketMode; // Mode that only sends 1 packet in 1 MP 1068 u16 mp_current_defaultRetryCount; // Default number of retries for communication on a port that does not do Seq control 1069 u16 mp_current_ignoreFatalErrorMode; // Whether to ignore fatal errors 1070 u8 reserved_g[2]; 1071 } 1072 WMStatus, WMstatus; 1073 1074 //--------------------------------------- 1075 // Buffer structure for variable area on WM ARM7 side 1076 typedef struct WMArm7Buf 1077 { 1078 WMStatus *status; // WM status buffer 1079 // u32 *indbuf; // Indication buffer pointer 1080 u8 reserved_a[4]; 1081 u32 *fifo7to9; // Buffer pointer for FIFO(ARM7->9) 1082 // BOOL *fifoFlag; // ARM7->ARM9 FIFO send enable flag 1083 u8 reserved_b[4]; 1084 1085 WMBssDesc connectPInfo; // Connection target parent information (190 bytes) 1086 1087 // Buffer for requests issued from inside of ARM7. 1088 u32 requestBuf[512 / sizeof(u32)]; 1089 1090 } 1091 WMArm7Buf, WMarm7Buf; 1092 1093 //--------------------------------------- 1094 // Number of CallbackTable elements 1095 #define WM_NUM_OF_CALLBACK ( WM_APIID_ASYNC_KIND_MAX - 2 ) 1096 // Buffer structure for variable area on WM ARM9 side 1097 typedef struct WMArm9Buf 1098 { 1099 // Various pointers (20 bytes) 1100 WMArm7Buf *WM7; // ARM7 side WM variable area (no access from ARM9) 1101 WMStatus *status; // WM status buffer (read only from ARM9) 1102 u32 *indbuf; // Indication buffer 1103 u32 *fifo9to7; // Buffer for FIFO (ARM9->7) 1104 u32 *fifo7to9; // Buffer for FIFO (ARM7->9) 1105 1106 // Other (4 bytes) 1107 u16 dmaNo; // DMA number that WM uses 1108 u16 scanOnlyFlag; // Scan only mode flag 1109 1110 // Callback related (172 bytes) 1111 WMCallbackFunc CallbackTable[WM_NUM_OF_CALLBACK]; // Callback table (42*4 = 168 bytes) 1112 WMCallbackFunc indCallback; 1113 1114 // Port-related (134 bytes) 1115 WMCallbackFunc portCallbackTable[WM_NUM_OF_PORT]; // 16*4 = 64 bytes 1116 void *portCallbackArgument[WM_NUM_OF_PORT]; // 16*4 = 64 bytes 1117 u32 connectedAidBitmap; // List of connection targets (allocate as u32 type since bitwise operations are used frequently) 1118 u16 myAid; // Current AID 1119 1120 /* Total of 20+4+172+134 bytes */ 1121 1122 u8 reserved1[WM_ARM9WM_BUF_SIZE - 1123 (20 + 4 + 4 * WM_NUM_OF_CALLBACK + 4 + (4 + 4) * WM_NUM_OF_PORT + 6)]; 1124 1125 } 1126 WMArm9Buf, WMarm9Buf; 1127 1128 //========================================================================================== 1129 1130 // API Arguments 1131 typedef struct WMStartScanReq 1132 { 1133 u16 apiid; 1134 u16 channel; 1135 WMBssDesc *scanBuf; 1136 u16 maxChannelTime; 1137 u8 bssid[WM_SIZE_BSSID]; 1138 1139 } 1140 WMStartScanReq, WMstartScanReq; 1141 1142 typedef struct WMStartScanExReq 1143 { 1144 u16 apiid; 1145 u16 channelList; 1146 WMBssDesc *scanBuf; 1147 u16 scanBufSize; 1148 u16 maxChannelTime; 1149 u8 bssid[WM_SIZE_BSSID]; 1150 u16 scanType; 1151 u16 ssidLength; 1152 u8 ssid[WM_SIZE_SSID]; 1153 #if WM_SSID_MASK_CUSTOMIZE 1154 u16 ssidMatchLength; 1155 u16 rsv[2]; 1156 #else 1157 u16 rsv[3]; 1158 #endif 1159 } 1160 WMStartScanExReq, WMstartScanExReq; 1161 1162 typedef struct WMStartConnectReq 1163 { 1164 u16 apiid; 1165 u16 reserved; 1166 WMBssDesc *pInfo; 1167 u8 ssid[WM_SIZE_CHILD_SSID]; 1168 BOOL powerSave; 1169 u16 reserved2; 1170 u16 authMode; 1171 1172 } 1173 WMStartConnectReq, WMstartConnectReq; 1174 1175 typedef struct WMMeasureChannelReq 1176 { 1177 u16 apiid; 1178 u16 ccaMode; 1179 u16 edThreshold; 1180 u16 channel; 1181 u16 measureTime; 1182 1183 } 1184 WMMeasureChannelReq, WMmeasureChannelReq; 1185 1186 typedef struct WMSetMPParameterReq 1187 { 1188 u16 apiid; 1189 u16 reserved; 1190 1191 WMMPParam param; 1192 } 1193 WMSetMPParameterReq; 1194 1195 typedef struct WMStartMPReq 1196 { 1197 u16 apiid; 1198 u16 rsv1; 1199 u32 *recvBuf; 1200 u32 recvBufSize; 1201 u32 *sendBuf; 1202 u32 sendBufSize; 1203 1204 WMMPParam param; // Unused 1205 WMMPTmpParam tmpParam; 1206 } 1207 WMStartMPReq; 1208 1209 typedef struct WMStartTestModeReq 1210 { 1211 u16 apiid; 1212 u16 control; 1213 u16 signal; 1214 u16 rate; 1215 u16 channel; 1216 } 1217 WMStartTestModeReq, WMstartTestModeReq; 1218 1219 typedef struct WMStartTestRxModeReq 1220 { 1221 u16 apiid; 1222 u16 channel; 1223 } 1224 WMStartTestRxModeReq, WMstartTestRxModeReq; 1225 1226 1227 //========================================================================================== 1228 1229 // Normal Callback Arguments 1230 typedef struct WMCallback 1231 { 1232 u16 apiid; 1233 u16 errcode; 1234 u16 wlCmdID; 1235 u16 wlResult; 1236 1237 } 1238 WMCallback; 1239 1240 // WM_StartParent() callback arguments 1241 typedef struct WMStartParentCallback 1242 { 1243 u16 apiid; 1244 u16 errcode; 1245 u16 wlCmdID; 1246 u16 wlResult; 1247 u16 state; // PARENT_START, BEACON_SENT, CHILD_CONNECTED, DISCONNECTED 1248 u8 macAddress[WM_SIZE_MACADDR]; // MAC address of each child that was connected 1249 u16 aid; 1250 u16 reason; // Reason code at time of disconnect 1251 u8 ssid[WM_SIZE_CHILD_SSID]; // SSID (child information) 1252 u16 parentSize; 1253 u16 childSize; 1254 1255 } 1256 WMStartParentCallback, WMstartParentCallback; 1257 1258 // WM_StartScan() callback arguments 1259 typedef struct WMStartScanCallback 1260 { 1261 u16 apiid; 1262 u16 errcode; 1263 u16 wlCmdID; 1264 u16 wlResult; 1265 u16 state; // SCAN_START, PARENT_NOT_FOUND, PARENT_FOUND 1266 u8 macAddress[WM_SIZE_MACADDR]; // MAC address of the parent that was found 1267 u16 channel; 1268 u16 linkLevel; 1269 u16 ssidLength; 1270 u16 ssid[WM_SIZE_SSID / sizeof(u16)]; 1271 u16 gameInfoLength; 1272 WMGameInfo gameInfo; 1273 1274 } 1275 WMStartScanCallback, WMstartScanCallback; 1276 1277 // Argument of WM_StartScanEx() callback 1278 typedef struct WMStartScanExCallback 1279 { 1280 u16 apiid; 1281 u16 errcode; 1282 u16 wlCmdID; 1283 u16 wlResult; 1284 u16 state; // SCAN_START, PARENT_NOT_FOUND, PARENT_FOUND 1285 u16 channelList; // Scanned channel list, regardless of whether found or not. 1286 u8 reserved[2]; // padding 1287 u16 bssDescCount; // Number of parents that were found 1288 WMBssDesc *bssDesc[WM_SCAN_EX_PARENT_MAX]; // Beginning address of the parent information 1289 u16 linkLevel[WM_SCAN_EX_PARENT_MAX]; // Reception signal strength 1290 1291 } 1292 WMStartScanExCallback, WMstartScanExCallback; 1293 1294 // Argument of WM_StartConnect() callback 1295 typedef struct WMStartConnectCallback 1296 { 1297 u16 apiid; 1298 u16 errcode; // PARENT_NOT_FOUND (timeout) 1299 u16 wlCmdID; 1300 u16 wlResult; 1301 u16 state; // CONNECT_START, BEACON_LOST, CONNECTED, DISCONNECTED 1302 u16 aid; // Only when CONNECTED. AID assigned to self 1303 u16 reason; // Reason code at time of disconnect 1304 u16 wlStatus; 1305 u8 macAddress[WM_SIZE_MACADDR]; 1306 u16 parentSize; 1307 u16 childSize; 1308 1309 } 1310 WMStartConnectCallback, WMstartConnectCallback; 1311 1312 // Callback of WM_Disconnect() and WM_DisconnectChildren 1313 typedef struct WMDisconnectCallback 1314 { 1315 u16 apiid; 1316 u16 errcode; 1317 u16 wlCmdID; 1318 u16 wlResult; 1319 u16 tryBitmap; 1320 u16 disconnectedBitmap; 1321 } 1322 WMDisconnectCallback; 1323 1324 // WM_SetMPParameter() callback arguments 1325 typedef struct WMSetMPParameterCallback 1326 { 1327 u16 apiid; 1328 u16 errcode; 1329 u32 mask; 1330 WMMPParam oldParam; 1331 } 1332 WMSetMPParameterCallback; 1333 1334 // Argument of WM_StartMP() callback 1335 typedef struct WMStartMPCallback 1336 { 1337 u16 apiid; 1338 u16 errcode; 1339 u16 state; 1340 u8 reserved[2]; // for padding 4-byte align 1341 WMMpRecvBuf *recvBuf; // Receive buffer 1342 1343 // The following only used for MPACK.Ind 1344 u16 timeStamp; 1345 u16 rate_rssi; 1346 u8 destAdrs[6]; 1347 u8 srcAdrs[6]; 1348 u16 seqNum; 1349 u16 tmptt; 1350 u16 pollbmp; 1351 u16 reserved2; 1352 } 1353 WMStartMPCallback, WMstartMPCallback; 1354 1355 // WM_StartDCF() callback arguments 1356 typedef struct WMStartDCFCallback 1357 { 1358 u16 apiid; 1359 u16 errcode; 1360 u16 state; 1361 u8 reserved[2]; // for padding 4-byte align 1362 WMDcfRecvBuf *recvBuf; // Receive buffer 1363 1364 } 1365 WMStartDCFCallback, WMstartDCFCallback; 1366 1367 // WM_MeasureChannel() callback arguments 1368 typedef struct WMMeasureChannelCallback 1369 { 1370 u16 apiid; 1371 u16 errcode; 1372 u16 wlCmdID; 1373 u16 wlResult; 1374 u16 channel; 1375 u16 ccaBusyRatio; 1376 } 1377 WMMeasureChannelCallback, WMmeasureChannelCallback; 1378 1379 // WM_GetWirelessCounter() callback arguments 1380 typedef struct WMGetWirelessCounterCallback 1381 { 1382 u16 apiid; 1383 u16 errcode; 1384 u16 wlCmdID; 1385 u16 wlResult; 1386 u32 TX_Success; // Number of successful sends 1387 u32 TX_Failed; // Number of failed sends 1388 u32 TX_Retry; // Number of resends 1389 u32 TX_AckError; // Number of times desired ACK frame could not be received 1390 u32 TX_Unicast; // Number of successfully sent Unicast addressed frames 1391 u32 TX_Multicast; // Number of successfully sent Multicast addressed frames 1392 u32 TX_WEP; // Number of successfully sent encrypted frames 1393 u32 TX_Beacon; // Number of successfully sent Beacon frames 1394 u32 RX_RTS; // NOTE: Number of times of receiving RTS and then performing CTS response 1395 u32 RX_Fragment; // Number of times fragmented frames received 1396 u32 RX_Unicast; // Number of times Unicast addressed frames received 1397 u32 RX_Multicast; // Number of times Multicast addressed frames received 1398 u32 RX_WEP; // Note: Number of times received encrypted frames that were successfully decrypted 1399 u32 RX_Beacon; // Number of times a Beacon frame was received 1400 u32 RX_FCSError; // Note: Number of times an FCS error occurred 1401 u32 RX_DuplicateError; // Note: Number of times redundant errors occurred 1402 u32 RX_MPDuplicateError; // Note: Number of times an MP frame duplicate error occurred 1403 u32 RX_ICVError; // Note: Number of times ICV errors occurred 1404 u32 RX_FrameCtrlError; // Note: Number of times received frames that have illegal FrameCtrl 1405 u32 RX_LengthError; // Note: Number of times received frames that are longer or shorter than the prescribed length 1406 u32 RX_PLCPError; // Note: Number of times that PLCP CRC error occurred 1407 u32 RX_BufferOverflowError; // Note: Number of times the receive buffer overflowed 1408 u32 RX_PathError; // Note: Number of times receive block internal errors occurred 1409 u32 RX_RateError; // Note: Number of times received frames that have an illegal receive rate 1410 u32 RX_FCSOK; // Note: Number of times received frames that have normal FCS 1411 u32 TX_MP; // Number of times MP frame sent 1412 u32 TX_KeyData; // Number of times MP-KeyData frames sent 1413 u32 TX_NullKey; // Number of times MP-NullKey frames sent 1414 u32 RX_MP; // Number of times proper MP frames received 1415 u32 RX_MPACK; // Number of times proper MPACK frames received 1416 u32 MPKeyResponseError[15]; // Number of times proper response not made to Key request 1417 /* 1418 * NOTE: Wireless hardware registers are sometimes cleared incorrectly, so the software counter that adds the hardware count registers may be less than the actual total value. NOTE: This only affects counters with a "Note:". 1419 * 1420 * 1421 */ 1422 } 1423 WMGetWirelessCounterCallback, WMgetWirelessCounterCallback; 1424 1425 // Indication Callback Arguments 1426 typedef struct WMIndCallback 1427 { 1428 u16 apiid; 1429 u16 errcode; 1430 u16 state; 1431 u16 reason; 1432 1433 } 1434 WMIndCallback, WMindCallback; 1435 1436 // MP Port Communication Send Callback Arguments 1437 typedef struct WMPortSendCallback 1438 { 1439 u16 apiid; 1440 u16 errcode; 1441 u16 wlCmdID; 1442 u16 wlResult; 1443 u16 state; 1444 u16 port; 1445 u16 destBitmap; 1446 u16 restBitmap; 1447 u16 sentBitmap; 1448 u16 rsv; 1449 const u16 *data; 1450 union 1451 { 1452 u16 size; 1453 u16 length; 1454 }; 1455 u16 seqNo; 1456 WMCallbackFunc callback; 1457 void *arg; 1458 u16 maxSendDataSize; 1459 u16 maxRecvDataSize; 1460 1461 } 1462 WMPortSendCallback; 1463 1464 // MP Port Communication Receive Callback Arguments 1465 typedef struct WMPortRecvCallback 1466 { 1467 u16 apiid; 1468 u16 errcode; 1469 u16 state; 1470 u16 port; // Port number 1471 WMMpRecvBuf *recvBuf; // Receive buffer // For compatibility with WMStartMPCallback 1472 u16 *data; // Receive data (in the case of receive data addressed to port, reference this) 1473 u16 length; // Length of received data 1474 u16 aid; // Send source AID 1475 u8 macAddress[WM_SIZE_MACADDR]; 1476 u16 seqNo; // seqNo 1477 void *arg; // Argument passed to callback (append on WM9 side) 1478 u16 myAid; // One's own AID 1479 u16 connectedAidBitmap; // AID Bitmap during connection 1480 u8 ssid[WM_SIZE_CHILD_SSID]; // SSID (child information) 1481 u16 reason; // Reason code at time of disconnect 1482 u16 rssi; // RSSI 1483 u16 maxSendDataSize; // Current possible send size 1484 u16 maxRecvDataSize; // Current possible receive size 1485 1486 } 1487 WMPortRecvCallback; 1488 1489 // BeaconRecv.Ind callback arguments 1490 typedef struct WMBeaconRecvIndCallback 1491 { 1492 u16 apiid; 1493 u16 errcode; 1494 u16 state; 1495 u16 tgid; 1496 u16 wmstate; 1497 u16 gameInfoLength; 1498 WMGameInfo gameInfo; 1499 } 1500 WMBeaconRecvIndCallback; 1501 1502 // Argument of WM_StartTestMode() callback 1503 typedef struct WMStartTestModeCallback 1504 { 1505 u16 apiid; 1506 u16 errcode; 1507 u32 RFadr5; 1508 u32 RFadr6; 1509 u16 PllLockCheck; 1510 u16 RFMDflag; 1511 1512 } 1513 WMStartTestModeCallback; 1514 1515 // Argument of WM_StopTestMode() callback 1516 typedef struct WMStopTestRxModeCallback 1517 { 1518 u16 apiid; 1519 u16 errcode; 1520 u32 fcsOk; 1521 u32 fcsErr; 1522 } 1523 WMStopTestRxModeCallback; 1524 1525 /*===========================================================================*/ 1526 1527 #ifdef __cplusplus 1528 } /* extern "C" */ 1529 #endif 1530 1531 #endif /* NITRO_WM_COMMON_WM_H_ */ 1532 1533 /*---------------------------------------------------------------------------* 1534 End of file 1535 *---------------------------------------------------------------------------*/ 1536