A_STATUS fwd_recv(void *context, adf_nbuf_t nbuf, a_uint8_t epid) { fwd_softc_t *sc = (fwd_softc_t *)context; a_uint8_t *pld; a_uint32_t plen, rsp, offset; fwd_rsp_t *h; adf_nbuf_peek_header(nbuf, &pld, &plen); h = (fwd_rsp_t *)pld; rsp = adf_os_ntohl(h->rsp); offset = adf_os_ntohl(h->offset); adf_os_timer_cancel(&sc->tmr); switch(rsp) { case FWD_RSP_ACK: if (offset == sc->offset) { // adf_os_printk("ACK for %#x\n", offset); adf_os_print("."); sc->offset += fwd_chunk_len(sc); fwd_send_next(sc); } break; case FWD_RSP_SUCCESS: adf_os_print("done!\n"); hif_boot_done(sc->hif_handle); break; case FWD_RSP_FAILED: if (sc->ntries < FWD_MAX_TRIES) fwd_start_upload(sc); else adf_os_print("FWD: Error: Max retries exceeded\n"); break; default: adf_os_assert(0); } adf_nbuf_free(nbuf); return A_OK; }
/* cleanup the HTC instance */ static void HTCCleanup(HTC_TARGET *target) { HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); HIF_Cleanup(target->hif_dev); /*Todo HIF should cleanup if any buffers are there*/ #ifdef HTC_HOST_CREDIT_DIST adf_os_timer_cancel(&target->host_htc_credit_debug_timer); #endif /* release htc_rdy_mutex */ adf_os_mutex_release(&target->htc_rdy_mutex); /* free our instance */ adf_os_mem_free(target); /* TODO : other cleanup */ /* free our instance */ A_FREE(target); }