Lines Matching defs:tcomm

754 void teac_Close(Tcomm *tcomm)
758 if (tcomm) {
762 if ((tcomm->sbuf_pull_event[0] != 0) && (tcomm->sbuf_ready[0] != NULL)) {
764 elan3_waitevent_word(tcomm->ctx, tcomm->sbuf_pull_event[i],
765 tcomm->sbuf_ready[i], 10);
769 elan3_block_inputter (tcomm->ctx, 1);
771 if (tcomm->e_dma != 0) elan3_freeElan(tcomm->ctx, tcomm->e_dma);
772 if (tcomm->s_event != 0) elan3_freeElan(tcomm->ctx, tcomm->s_event);
773 if (tcomm->r_event != NULL) {
774 if (tcomm->r_event[0] != NULL) {
775 if (tcomm->r_event[0][0] != 0) elan3_freeElan(tcomm->ctx,
776 tcomm->r_event[0][0]);
777 crFree(tcomm->r_event[0]);
779 crFree(tcomm->r_event);
781 if (tcomm->sbuf_pull_event[0] != 0)
782 elan3_freeElan(tcomm->ctx, tcomm->sbuf_pull_event[0]);
783 if (tcomm->sendWrappers[0] != NULL) {
785 if (tcomm->sendWrappers[i]->buf != NULL) {
786 elan3_free(tcomm->ctx, tcomm->sendWrappers[i]->buf);
787 tcomm->totalSendBufferBytesAllocated -=
788 tcomm->sendWrappers[i]->totSize;
791 crFree(tcomm->sendWrappers[0]);
793 if (tcomm->rbuf_pull_event != 0)
794 elan3_freeElan(tcomm->ctx, tcomm->rbuf_pull_event);
795 if (tcomm->m_snd != NULL) elan3_free(tcomm->ctx,
796 (E3_uint32*)tcomm->m_snd);
797 if (tcomm->m_rcv != NULL) {
798 if (tcomm->m_rcv[0] != NULL) elan3_free(tcomm->ctx,
799 (E3_uint32*)tcomm->m_rcv[0]);
800 crFree(tcomm->m_rcv);
802 if (tcomm->sbuf_ready[0] != NULL)
803 elan3_free(tcomm->ctx, (E3_uint32*)tcomm->sbuf_ready[0]);
804 if (tcomm->rbuf_ready != NULL) elan3_free(tcomm->ctx,
805 (E3_uint32*)tcomm->rbuf_ready);
806 if (tcomm->mbuff != NULL) {
807 if (tcomm->mbuff[0] != NULL) elan3_free(tcomm->ctx, tcomm->mbuff[0]);
808 crFree(tcomm->mbuff);
811 elan3_detach(tcomm->ctx);
812 elan3_fini(tcomm->ctx);
821 int teac_Select(Tcomm* tcomm, int *ids, int num_ids, int timeout)
825 if ((id= teac_Poll(tcomm, ids, num_ids)) >= 0) return id;
831 int teac_Poll(Tcomm* tcomm, int *ids, int num_ids)
837 int index= (j+tcomm->poll_shift) % num_ids;
840 if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[thisId][i]), 1)) {
842 tcomm->poll_shift= index;
852 int teac_sendBufferAvailable(Tcomm* tcomm)
856 if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i], 1))
862 SBuffer* teac_getSendBuffer( Tcomm* tcomm, long size )
869 if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
877 *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
882 if (tcomm->sendWrappers[i]->totSize < size) {
883 tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
884 elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
885 if (!(tcomm->sendWrappers[i]->buf=
886 (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
890 tcomm->totalSendBufferBytesAllocated += size;
892 tcomm->sendWrappers[i]->totSize= size;
893 tcomm->sendWrappers[i]->validSize= 0;
894 return tcomm->sendWrappers[i];
897 SBuffer* teac_getUnreadySendBuffer( Tcomm* tcomm, long size )
911 if (!(result->buf= (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
917 tcomm->totalSendBufferBytesAllocated += result->totSize;
922 SBuffer* teac_makeSendBufferReady( Tcomm* tcomm, SBuffer* buf )
932 if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
940 *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
943 tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
944 elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
945 tcomm->sendWrappers[i]->buf= buf->buf;
947 tcomm->sendWrappers[i]->totSize= buf->totSize;
948 tcomm->sendWrappers[i]->validSize= buf->validSize;
950 return tcomm->sendWrappers[i];
954 int teac_Send( Tcomm* tcomm, int* ids, int num_ids, SBuffer* buf, void *start )
956 int vp = tcomm->vp;
982 msg = &(tcomm->mbuff[vp][iBuf]);
983 msg->msgnum = tcomm->msgnum++;
987 msg->mptr = teac_main2elan( tcomm->ctx, start );
989 msg->mptr = teac_main2elan(tcomm->ctx, buf->buf);
990 msg->clr_event = elan3_sdram2elan(tcomm->ctx, tcomm->ctx->sdram,
991 tcomm->sbuf_pull_event[iBuf]);
995 tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_WRITE,DMA_NORMAL,0);
996 tcomm->dma->dma_size = sizeof(teacMsg);
997 tcomm->dma->dma_srcEvent =
998 elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,tcomm->s_event);
999 tcomm->dma->dma_source = teac_main2elan(tcomm->ctx, msg);
1000 elan3_primeevent(tcomm->ctx, tcomm->sbuf_pull_event[buf->bufId], num_ids);
1004 tcomm->dma->dma_srcCookieVProc =
1005 elan3_local_cookie(tcomm->ctx, vp, ids[iDest]);
1006 tcomm->dma->dma_destCookieVProc = ids[iDest];
1007 tcomm->dma->dma_destEvent =
1008 elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
1009 tcomm->r_event[vp][iBuf])
1010 + sdramAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost]
1011 - sdramAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
1012 tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx, msg)
1013 + elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost]
1014 - elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
1015 elan3_primeevent(tcomm->ctx, tcomm->s_event, 1);
1016 *(tcomm->m_snd)= 0;
1017 elan3_putdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
1020 tcomm->dma->dma_destEvent,
1021 (long)tcomm->dma->dma_dest);
1023 elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost],
1024 elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost],
1029 elan3_waitevent_word(tcomm->ctx,
1030 tcomm->s_event, tcomm->m_snd, ELAN_WAIT_EVENT);
1038 RBuffer* teac_Recv(Tcomm* tcomm, int id)
1040 int vp = tcomm->vp;
1049 if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[id][iEvent]), 1))
1059 (long)&(tcomm->mbuff[id][i]),
1060 (long)teac_main2elan(tcomm->ctx,(void*)(&tcomm->mbuff[id][i])));
1062 if (tcomm->mbuff[id][i].new) {
1064 || (tcomm->mbuff[id][i].msgnum < (E3_uint32)lowestMsgnum)) {
1065 lowestMsgnum= tcomm->mbuff[id][i].msgnum;
1075 tcomm->mbuff[id][iBuf].new= 0;
1076 tcomm->m_rcv[id][iBuf]= 0;
1077 elan3_primeevent(tcomm->ctx, tcomm->r_event[id][iBuf],1);
1080 tcomm->mbuff[id][iBuf].msgnum, iBuf, id);
1090 if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8,E_BUFFER_SIZE))) {
1096 if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8,
1097 tcomm->mbuff[id][iBuf].size))) {
1101 result->totSize= tcomm->mbuff[id][iBuf].size;
1102 tcomm->totalRecvBufferBytesAllocated+= result->totSize;
1103 result->validSize= tcomm->mbuff[id][iBuf].size;
1104 result->from= tcomm->mbuff[id][iBuf].host;
1105 result->senderMsgnum= tcomm->mbuff[id][iBuf].msgnum;
1108 tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_READ,DMA_NORMAL,0);
1109 tcomm->dma->dma_size = tcomm->mbuff[id][iBuf].size;
1110 tcomm->dma->dma_source = tcomm->mbuff[id][iBuf].mptr;
1111 tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx,result->buf);
1112 tcomm->dma->dma_srcCookieVProc =
1113 elan3_remote_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
1114 tcomm->dma->dma_destCookieVProc =
1115 elan3_local_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
1116 tcomm->dma->dma_srcEvent = tcomm->mbuff[id][iBuf].clr_event;
1117 tcomm->dma->dma_destEvent =
1118 elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
1119 tcomm->rbuf_pull_event);
1122 elan3_primeevent(tcomm->ctx, tcomm->rbuf_pull_event,1);
1123 *(tcomm->rbuf_ready)= 0;
1124 elan3_getdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
1125 elan3_waitevent_word(tcomm->ctx,
1126 tcomm->rbuf_pull_event,
1127 tcomm->rbuf_ready, ELAN_WAIT_EVENT);
1132 int teac_Dispose( Tcomm* tcomm, RBuffer* buf )
1134 tcomm->totalRecvBufferBytesAllocated -= buf->totSize;
1135 elan3_free(tcomm->ctx, buf->buf);