📄 di.c
字号:
byte Ind, byte Id, byte Ch, PBUFFER * RBuffer, byte MInd, word MLength){ ENTITY * this; word clength; word offset; BUFFERS *R; byte* cma = NULL;#ifdef USE_EXTENDED_DEBUGS { DBG_TRC(("<A%d Id=0x%x Ind=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Ind)) }#else dbug(dprintf("isdn_ind(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch));#endif if(a->IdTable[Id]) { this = entity_ptr(a,a->IdTable[Id]); this->IndCh = Ch; xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, 0/* rnr_valid */, 0 /* rnr */, a->IdTypeTable[this->No]); /* if the Receive More flag is not yet set, this is the */ /* first buffer of the packet */ if(this->RCurrent==0xff) { /* check for receive buffer chaining */ if(Ind==this->MInd) { this->complete = 0; this->Ind = MInd; } else { this->complete = 1; this->Ind = Ind; } /* call the application callback function for the receive */ /* look ahead */ this->RLength = MLength;#if defined(DIVA_ISTREAM) if ((a->rx_stream[this->Id] || (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA)) && ((Ind == N_DATA) || (a->protocol_capabilities & PROTCAP_CMA_ALLPR))) { PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io ; if (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA) {#if defined(DIVA_IDI_RX_DMA) dword d; diva_get_dma_map_entry (\ (struct _diva_dma_map_entry*)IoAdapter->dma_map, (int)a->rx_stream[this->Id], (void**)&cma, &d);#else cma = &a->stream_buffer[0]; cma[0] = cma[1] = cma[2] = cma[3] = 0;#endif this->RLength = MLength = (word)*(dword*)cma; cma += 4; } else { int final = 0; cma = &a->stream_buffer[0]; this->RLength = MLength = (word)diva_istream_read (a, Id, cma, sizeof(a->stream_buffer), &final, NULL, NULL); } IoAdapter->RBuffer.length = MIN(MLength, 270); if (IoAdapter->RBuffer.length != MLength) { this->complete = 0; } else { this->complete = 1; } memcpy (IoAdapter->RBuffer.P, cma, IoAdapter->RBuffer.length) ; this->RBuffer = (DBUFFER *)&IoAdapter->RBuffer ; }#endif if (!cma) { a->ram_look_ahead(a, RBuffer, this); } this->RNum = 0; CALLBACK(a, this); /* map entity ptr, selector could be re-mapped by call to */ /* IDI from within callback */ this = entity_ptr(a,a->IdTable[Id]); xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, 1/* rnr_valid */, this->RNR/* rnr */, a->IdTypeTable[this->No]); /* check for RNR */ if(this->RNR==1) { this->RNR = 0; return 1; } /* if no buffers are provided by the application, the */ /* application want to copy the data itself including */ /* N_MDATA/LL_MDATA chaining */ if(!this->RNR && !this->RNum) { xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, 2/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); return 0; } /* if there is no RNR, set the More flag */ this->RCurrent = 0; this->ROffset = 0; } if(this->RNR==2) { if(Ind!=this->MInd) { this->RCurrent = 0xff; this->RNR = 0; } return 0; } /* if we have received buffers from the application, copy */ /* the data into these buffers */ offset = 0; R = PTR_R(a,this); do { if(this->ROffset==R[this->RCurrent].PLength) { this->ROffset = 0; this->RCurrent++; } if (cma) { clength = MIN(MLength, R[this->RCurrent].PLength-this->ROffset); } else { clength = MIN(a->ram_inw(a, &RBuffer->length)-offset, R[this->RCurrent].PLength-this->ROffset); } if(R[this->RCurrent].P) { if (cma) { memcpy (PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]), &cma[offset], clength); } else { a->ram_in_buffer(a, &RBuffer->P[offset], PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]), clength); } } offset +=clength; this->ROffset +=clength; if (cma) { if (offset >= MLength) { break; } continue; } } while(offset<(a->ram_inw(a, &RBuffer->length))); /* if it's the last buffer of the packet, call the */ /* application callback function for the receive complete */ /* call */ if(Ind!=this->MInd) { R[this->RCurrent].PLength = this->ROffset; if(this->ROffset) this->RCurrent++; this->RNum = this->RCurrent; this->RCurrent = 0xff; this->Ind = Ind; this->complete = 2; xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, 3/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); CALLBACK(a, this); } return 0; } return 2;}#if defined(XDI_USE_XLOG)/* ----------------------------------------------------------- This function works in the same way as xlog on the active board ----------------------------------------------------------- */static void xdi_xlog (byte *msg, word code, int length) { xdi_dbg_xlog ("\x00\x02", msg, code, length);}#endif/* ----------------------------------------------------------- This function writes the information about the Return Code processing in the trace buffer. Trace ID is 221. INPUT: Adapter - system unicue adapter number (0 ... 255) Id - Id of the entity that had sent this return code Ch - Channel of the entity that had sent this return code Rc - return code value cb: (0...2) switch (cb) { case 0: printf ("DELIVERY"); break; case 1: printf ("CALLBACK"); break; case 2: printf ("ASSIGN"); break; } DELIVERY - have entered isdn_rc with this RC CALLBACK - about to make callback to the application for this RC ASSIGN - about to make callback for RC that is result of ASSIGN request. It is no DELIVERY message before of this message type - the Id that was sent by the ASSIGN of this entity. This should be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will cause "?-" in the front of the request. In this case the log.c is to be extended. ----------------------------------------------------------- */static void xdi_xlog_rc_event (byte Adapter, byte Id, byte Ch, byte Rc, byte cb, byte type) {#if defined(XDI_USE_XLOG) word LogInfo[4]; PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8))); PUT_WORD(&LogInfo[3], cb); xdi_xlog ((byte*)&LogInfo[0], 221, sizeof(LogInfo));#endif}/* ------------------------------------------------------------------------ This function writes the information about the request processing in the trace buffer. Trace ID is 220. INPUT: Adapter - system unicue adapter number (0 ... 255) Id - Id of the entity that had sent this request Ch - Channel of the entity that had sent this request Req - Code of the request type - the Id that was sent by the ASSIGN of this entity. This should be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will cause "?-" in the front of the request. In this case the log.c is to be extended. ------------------------------------------------------------------------ */static void xdi_xlog_request (byte Adapter, byte Id, byte Ch, byte Req, byte type) {#if defined(XDI_USE_XLOG) word LogInfo[3]; PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8))); xdi_xlog ((byte*)&LogInfo[0], 220, sizeof(LogInfo));#endif}/* ------------------------------------------------------------------------ This function writes the information about the indication processing in the trace buffer. Trace ID is 222. INPUT: Adapter - system unicue adapter number (0 ... 255) Id - Id of the entity that had sent this indication Ch - Channel of the entity that had sent this indication Ind - Code of the indication rnr_valid: (0 .. 3) supported switch (rnr_valid) { case 0: printf ("DELIVERY"); break; case 1: printf ("RNR=%d", rnr); case 2: printf ("RNum=0"); case 3: printf ("COMPLETE"); } DELIVERY - indication entered isdn_rc function RNR=... - application had returned RNR=... after the look ahead callback RNum=0 - aplication had not returned any buffer to copy this indication and will copy it self COMPLETE - XDI had copied the data to the buffers provided bu the application and is about to issue the final callback rnr: Look case 1 of the rnr_valid type: the Id that was sent by the ASSIGN of this entity. This should be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will cause "?-" in the front of the request. In this case the log.c is to be extended. ------------------------------------------------------------------------ */static void xdi_xlog_ind (byte Adapter, byte Id, byte Ch, byte Ind, byte rnr_valid, byte rnr, byte type) {#if defined(XDI_USE_XLOG) word LogInfo[4]; PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8))); PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8))); xdi_xlog ((byte*)&LogInfo[0], 222, sizeof(LogInfo));#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -