Lines Matching refs:work

197 static void WBTi_InitBitmap(WBTContext * work, WBTPacketBitmap * pkt_bmp, s32 length, u32 *bits, u8…  in WBTi_InitBitmap()  argument
206 MI_CpuFill8(bits, 0x00, (u32)WBT_GetBitmapLength(work, length)); in WBTi_InitBitmap()
311 static u8 *WBTi_GetPacketBuffer(WBTContext * work, u32 id, s32 index) in WBTi_GetPacketBuffer() argument
314 WBTBlockInfoList *list = work->list; in WBTi_GetPacketBuffer()
348 ptr += index * work->my_data_packet_size; in WBTi_GetPacketBuffer()
364 static void WBTi_SwitchNextCommand(WBTContext * work) in WBTi_SwitchNextCommand() argument
369 WBTCommand *current = WBT_GetCurrentCommand(work); in WBTi_SwitchNextCommand()
373 if (++work->my_command_counter == 0) in WBTi_SwitchNextCommand()
375 ++work->my_command_counter; in WBTi_SwitchNextCommand()
377 current->my_cmd_counter = work->my_command_counter; in WBTi_SwitchNextCommand()
392 WBTPacketBitmap *pkt_bmp = &work->peer_param[aid].pkt_bmp; in WBTi_SwitchNextCommand()
393 WBTi_InitBitmap(work, pkt_bmp, (int)current->get.recv_data_size, in WBTi_SwitchNextCommand()
396 work->peer_data_packet_size); in WBTi_SwitchNextCommand()
430 static void WBTi_NotifySystemCallback(WBTContext * work, WBTCommandType event, int aid, in WBTi_NotifySystemCallback() argument
434 WBTRecvToken *peer = &work->peer_param[aid].recv_token; in WBTi_NotifySystemCallback()
454 WBTCommand *cmd = &work->system_cmd; in WBTi_NotifySystemCallback()
462 if (work->callback) in WBTi_NotifySystemCallback()
464 work->callback(work->userdata, cmd); in WBTi_NotifySystemCallback()
504 int WBTi_TryCreateResponse(WBTContext * work, int aid, void *buf, int size, int command, in WBTi_TryCreateResponse() argument
508 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBTi_TryCreateResponse()
516 MI_StoreLE16(&format->res_sync.block_total, (u16)WBT_GetRegisteredCount(work)); in WBTi_TryCreateResponse()
517 MI_StoreLE16(&format->res_sync.peer_packet, (u16)work->my_data_packet_size); in WBTi_TryCreateResponse()
518 MI_StoreLE16(&format->res_sync.own_packet, (u16)work->peer_data_packet_size); in WBTi_TryCreateResponse()
548 WBTBlockInfoList *list = work->list; in WBTi_TryCreateResponse()
575 if (id == work->last_block_id) in WBTi_TryCreateResponse()
578 (list->data_info.block_size + work->my_data_packet_size - in WBTi_TryCreateResponse()
579 1) / work->my_data_packet_size; in WBTi_TryCreateResponse()
582 for (i = 0; (i < 3) && ((index == work->last_seq_no_1) || in WBTi_TryCreateResponse()
583 (index == work->last_seq_no_2)); ++i) in WBTi_TryCreateResponse()
597 work->last_block_id = id; in WBTi_TryCreateResponse()
598 work->last_seq_no_2 = work->last_seq_no_1; in WBTi_TryCreateResponse()
599 work->last_seq_no_1 = index; in WBTi_TryCreateResponse()
604 u32 packet = work->my_data_packet_size; in WBTi_TryCreateResponse()
609 data_ptr = WBTi_GetPacketBuffer(work, id, block_seq_no); in WBTi_TryCreateResponse()
617 WBTCommand *system_cmd = &work->system_cmd; in WBTi_TryCreateResponse()
622 WBTi_NotifySystemCallback(work, WBT_CMD_PREPARE_SEND_DATA, aid, in WBTi_TryCreateResponse()
639 u16 target = (u16)((WBT_GetAid(work) == WBT_AID_PARENT) ? 0xFFFE : 0x0001); in WBTi_TryCreateResponse()
657 int packet = work->my_data_packet_size; in WBTi_TryCreateResponse()
658 u8 *data_ptr = WBTi_GetPacketBuffer(work, id, index); in WBTi_TryCreateResponse()
670 u16 target = (u16)((WBT_GetAid(work) == 0) ? 0xFFFF : 0x0001); in WBTi_TryCreateResponse()
685 work->req_bitmap &= ~(1 << aid); in WBTi_TryCreateResponse()
701 static int WBTi_CheckRequest(WBTContext * work, void *send_buf, int size) in WBTi_CheckRequest() argument
704 WBTCommand *current = WBT_GetCurrentCommand(work); in WBTi_CheckRequest()
716 MI_StoreLE16(&format->req_sync.peer_packet, (u16)work->my_data_packet_size); in WBTi_CheckRequest()
717 MI_StoreLE16(&format->req_sync.own_packet, (u16)work->peer_data_packet_size); in WBTi_CheckRequest()
732 WBTPacketBitmap *pkt_bmp = &work->peer_param[aid].pkt_bmp; in WBTi_CheckRequest()
801 static int WBTi_CheckBlockResponse(WBTContext * work, void *buffer, int length) in WBTi_CheckBlockResponse() argument
806 int mask = work->req_bitmap; in WBTi_CheckBlockResponse()
809 int aid = WBTi_GetFirstIterationAID(work); in WBTi_CheckBlockResponse()
813 if ((work->req_bitmap & (1 << aid)) != 0) in WBTi_CheckBlockResponse()
815 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBTi_CheckBlockResponse()
829 WBTi_TryCreateResponse(work, aid, buffer, length, WBT_CMD_REQ_GET_BLOCK, in WBTi_CheckBlockResponse()
834 work->last_target_aid = aid; in WBTi_CheckBlockResponse()
838 while (aid != work->last_target_aid); in WBTi_CheckBlockResponse()
843 int aid = WBTi_GetFirstIterationAID(work); in WBTi_CheckBlockResponse()
847 if ((work->req_bitmap & (1 << aid)) != 0) in WBTi_CheckBlockResponse()
849 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBTi_CheckBlockResponse()
853 WBTi_TryCreateResponse(work, aid, buffer, length, WBT_CMD_REQ_GET_BLOCKINFO, in WBTi_CheckBlockResponse()
858 work->last_target_aid = aid; in WBTi_CheckBlockResponse()
862 while (aid != work->last_target_aid); in WBTi_CheckBlockResponse()
879 int WBT_CallPacketSendHook(WBTContext * work, void *buffer, int length, BOOL is_parent) in WBT_CallPacketSendHook() argument
883 if (work->last_target_aid == -1) in WBT_CallPacketSendHook()
885 work->last_target_aid = (is_parent ? 1 : 0); in WBT_CallPacketSendHook()
910 int mask = work->req_bitmap; in WBT_CallPacketSendHook()
913 int aid = WBTi_GetFirstIterationAID(work); in WBT_CallPacketSendHook()
926 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBT_CallPacketSendHook()
934 WBTi_TryCreateResponse(work, aid, buffer, length, tbl[i], FALSE); in WBT_CallPacketSendHook()
939 work->last_target_aid = aid; in WBT_CallPacketSendHook()
943 while (aid != work->last_target_aid); in WBT_CallPacketSendHook()
963 retval = WBTi_CheckRequest(work, buffer, length); in WBT_CallPacketSendHook()
966 retval = WBTi_CheckBlockResponse(work, buffer, length); in WBT_CallPacketSendHook()
978 retval = WBTi_CheckBlockResponse(work, buffer, length); in WBT_CallPacketSendHook()
985 retval = WBTi_CheckRequest(work, buffer, length); in WBT_CallPacketSendHook()
1017 static void WBTi_NotifyCompletionCallback(WBTContext * work, WBTCommandType event, int aid) in WBTi_NotifyCompletionCallback() argument
1019 WBTCommandList *list = WBT_GetCurrentCommandList(work); in WBTi_NotifyCompletionCallback()
1020 WBTCommand *current = WBT_GetCurrentCommand(work); in WBTi_NotifyCompletionCallback()
1021 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBTi_NotifyCompletionCallback()
1037 list->callback(work->userdata, current); in WBTi_NotifyCompletionCallback()
1048 WBTCommandList *list = work->command; in WBTi_NotifyCompletionCallback()
1049 work->command = list->next; in WBTi_NotifyCompletionCallback()
1050 WBT_AddCommandPool(work, list, 1); in WBTi_NotifyCompletionCallback()
1051 WBTi_SwitchNextCommand(work); in WBTi_NotifyCompletionCallback()
1068 void WBT_CallPacketRecvHook(WBTContext * work, int aid, const void *buffer, int length) in WBT_CallPacketRecvHook() argument
1070 WBTRecvToken *token = &work->peer_param[aid].recv_token; in WBT_CallPacketRecvHook()
1073 work->req_bitmap &= ~(1 << aid); in WBT_CallPacketRecvHook()
1093 if ((WBT_GetAid(work) != -1) && ((bitmap & (1 << WBT_GetAid(work))) != 0)) in WBT_CallPacketRecvHook()
1112 WBTRequestSyncCallback *cb = &work->system_cmd.sync; in WBT_CallPacketRecvHook()
1117 if (WBT_GetAid(work) != 0) in WBT_CallPacketRecvHook()
1119 work->my_data_packet_size = cb->my_packet_size; in WBT_CallPacketRecvHook()
1120 work->peer_data_packet_size = cb->peer_packet_size; in WBT_CallPacketRecvHook()
1122 work->req_bitmap |= (1 << aid); in WBT_CallPacketRecvHook()
1127 WBTRecvUserDataCallback *cb = &work->system_cmd.user_data; in WBT_CallPacketRecvHook()
1134 work->req_bitmap |= (1 << aid); in WBT_CallPacketRecvHook()
1142 work->req_bitmap |= (1 << aid); in WBT_CallPacketRecvHook()
1149 WBTGetBlockDoneCallback *cb = &work->system_cmd.blockdone; in WBT_CallPacketRecvHook()
1154 work->req_bitmap |= (1 << aid); in WBT_CallPacketRecvHook()
1161 WBTCommand *current = WBT_GetCurrentCommand(work); in WBT_CallPacketRecvHook()
1191 if (WBT_GetAid(work) != 0) in WBT_CallPacketRecvHook()
1193 work->my_data_packet_size = current->sync.my_packet_size; in WBT_CallPacketRecvHook()
1194 work->peer_data_packet_size = current->sync.peer_packet_size; in WBT_CallPacketRecvHook()
1199 WBTi_NotifyCompletionCallback(work, (WBTCommandType)command, aid); in WBT_CallPacketRecvHook()
1207 WBTi_NotifyCompletionCallback(work, (WBTCommandType)command, aid); in WBT_CallPacketRecvHook()
1227 WBTPacketBitmap *pkt_bmp = &work->peer_param[aid].pkt_bmp; in WBT_CallPacketRecvHook()
1234 WBTi_NotifySystemCallback(work, WBT_CMD_RES_ERROR, aid, in WBT_CallPacketRecvHook()
1242 u32 packet = (u32)work->peer_data_packet_size; in WBT_CallPacketRecvHook()
1265 WBTi_NotifyCompletionCallback(work, in WBT_CallPacketRecvHook()
1280 WBTi_NotifySystemCallback(work, WBT_CMD_RES_ERROR, aid, in WBT_CallPacketRecvHook()
1287 if ((work->req_bitmap & (1 << aid)) != 0) in WBT_CallPacketRecvHook()
1292 WBTi_NotifySystemCallback(work, (WBTCommandType)command, aid, WBT_RESULT_SUCCESS); in WBT_CallPacketRecvHook()
1310 void WBT_InitContext(WBTContext * work, void *userdata, WBTEventCallback callback) in WBT_InitContext() argument
1312 work->userdata = userdata; in WBT_InitContext()
1313 work->callback = callback; in WBT_InitContext()
1316 work->last_block_id = (u32)-1; in WBT_InitContext()
1317 work->last_seq_no_1 = -1; in WBT_InitContext()
1318 work->last_seq_no_2 = -1; in WBT_InitContext()
1321 work->command = NULL; in WBT_InitContext()
1322 work->command_pool = NULL; in WBT_InitContext()
1323 work->my_command_counter = 0; in WBT_InitContext()
1324 work->last_target_aid = -1; in WBT_InitContext()
1325 work->req_bitmap = 0; in WBT_InitContext()
1326 MI_CpuFill8(&work->system_cmd, 0x00, sizeof(work->system_cmd)); in WBT_InitContext()
1327 MI_CpuFill8(work->peer_param, 0x00, sizeof(work->peer_param)); in WBT_InitContext()
1330 WBT_ResetContext(work, callback); in WBT_InitContext()
1343 void WBT_ResetContext(WBTContext * work, WBTEventCallback callback) in WBT_ResetContext() argument
1347 work->my_aid = -1; in WBT_ResetContext()
1348 work->peer_data_packet_size = 0; in WBT_ResetContext()
1349 work->my_data_packet_size = 0; in WBT_ResetContext()
1351 work->list = NULL; in WBT_ResetContext()
1352 work->callback = callback; in WBT_ResetContext()
1355 while (work->command) in WBT_ResetContext()
1357 WBTCommandList *list = work->command; in WBT_ResetContext()
1358 work->command = list->next; in WBT_ResetContext()
1362 work->system_cmd.command = WBT_CMD_REQ_NONE; in WBT_ResetContext()
1363 work->system_cmd.target_bmp = 0; in WBT_ResetContext()
1364 work->system_cmd.peer_bmp = 0; in WBT_ResetContext()
1368 work->peer_param[i].recv_token.last_peer_cmd_counter = 0; in WBT_ResetContext()
1386 void WBT_PostCommand(WBTContext *work, WBTCommandList *list, u16 bitmap, in WBT_PostCommand() argument
1395 for (pp = &work->command; *pp; pp = &(*pp)->next) in WBT_PostCommand()
1403 if (work->command == list) in WBT_PostCommand()
1405 WBTi_SwitchNextCommand(work); in WBT_PostCommand()
1422 int WBT_CancelCommand(WBTContext * work, int bitmap) in WBT_CancelCommand() argument
1426 WBTCommandList *list = WBT_GetCurrentCommandList(work); in WBT_CancelCommand()
1427 WBTCommand *current = WBT_GetCurrentCommand(work); in WBT_CancelCommand()
1450 list->callback(work->userdata, current); in WBT_CancelCommand()
1464 WBTCommandList *list = work->command; in WBT_CancelCommand()
1465 work->command = list->next; in WBT_CancelCommand()
1466 WBT_AddCommandPool(work, list, 1); in WBT_CancelCommand()
1467 WBTi_SwitchNextCommand(work); in WBT_CancelCommand()
1485 int WBT_GetBitmapLength(const WBTContext *work, int length) in WBT_GetBitmapLength() argument
1487 int packet = work->peer_data_packet_size; in WBT_GetBitmapLength()
1506 void WBT_GetDownloadProgress(const WBTContext *work, u32 id, int aid, int *count, int *total) in WBT_GetDownloadProgress() argument
1508 const WBTCommand *current = WBT_GetCurrentCommand(work); in WBT_GetDownloadProgress()
1512 const WBTPacketBitmap *pkt_bmp = &work->peer_param[aid].pkt_bmp; in WBT_GetDownloadProgress()
1535 BOOL WBT_SetPacketLength(WBTContext * work, int own, int peer) in WBT_SetPacketLength() argument
1543 current = WBT_GetCurrentCommand(work); in WBT_SetPacketLength()
1549 work->my_data_packet_size = (s16)(own - WBT_PACKET_SIZE_MIN); in WBT_SetPacketLength()
1550 work->peer_data_packet_size = (s16)(peer - WBT_PACKET_SIZE_MIN); in WBT_SetPacketLength()
1577 WBT_RegisterBlockInfo(WBTContext * work, WBTBlockInfoList *list, u32 id, in WBT_RegisterBlockInfo() argument
1583 for (pp = &work->list; *pp; pp = &((*pp)->next)) in WBT_RegisterBlockInfo()
1610 WBTBlockInfoList *WBT_UnregisterBlockInfo(WBTContext * work, u32 id) in WBT_UnregisterBlockInfo() argument
1616 for (pp = &work->list; *pp; pp = &(*pp)->next) in WBT_UnregisterBlockInfo()
1639 int WBT_GetRegisteredCount(const WBTContext * work) in WBT_GetRegisteredCount() argument
1644 WBTBlockInfoList *list = work->list; in WBT_GetRegisteredCount()
1645 for (list = work->list; list; list = list->next) in WBT_GetRegisteredCount()