di.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 1,030 行 · 第 1/3 页
C
1,030 行
} return FALSE;}byte pr_test_int(ADAPTER * a){ return a->ram_in(a,(void *)0x3ffc);}void pr_clear_int(ADAPTER * a){ a->ram_out(a,(void *)0x3ffc,0);}/*------------------------------------------------------------------*//* output function *//*------------------------------------------------------------------*/void scom_out(ADAPTER * a){ byte e_no; ENTITY * this; BUFFERS * X; word length; word i; word clength; byte more; byte Id; dtrc(dprintf("scom_out")); /* check if the adapter is ready to accept an request: */ e_no = look_req(a); if(!e_no) { dtrc(dprintf("no_req")); return; } if(!scom_ready(a)) { dtrc(dprintf("not_ready")); return; } this = entity_ptr(a,e_no); dtrc(dprintf("out:Req=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh)); next_req(a); /* now copy the data from the current data buffer into the */ /* adapters request buffer */ length = 0; i = this->XCurrent; X = PTR_X(a, this); while(i<this->XNum && length<270) { clength = MIN((word)(270-length),X[i].PLength-this->XOffset); a->ram_out_buffer(a, &RAM->XBuffer.P[length], PTR_P(a,this,&X[i].P[this->XOffset]), clength); length +=clength; this->XOffset +=clength; if(this->XOffset==X[i].PLength) { this->XCurrent = (byte)++i; this->XOffset = 0; } } a->ram_outw(a, &RAM->XBuffer.length, length); a->ram_out(a, &RAM->ReqId, this->Id); a->ram_out(a, &RAM->ReqCh, this->ReqCh); /* if it's a specific request (no ASSIGN) ... */ if(this->Id &0x1f) { /* if buffers are left in the list of data buffers do */ /* chaining (LL_MDATA, N_MDATA) */ this->More++; if(i<this->XNum && this->MInd) { a->ram_out(a, &RAM->Req, this->MInd); more = TRUE; } else { this->More |=XMOREF; a->ram_out(a, &RAM->Req, this->Req); more = FALSE; if (a->FlowControlIdTable[this->ReqCh] == this->Id) a->FlowControlSkipTable[this->ReqCh] = TRUE; /* Note that remove request was sent to the card */ if (this->Req == REMOVE) { a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_REMOVE_PENDING; } } if(more) { req_queue(a,this->No); } } /* else it's a ASSIGN */ else { /* save the request code used for buffer chaining */ this->MInd = 0; if (this->Id==BLLC_ID) this->MInd = LL_MDATA; if (this->Id==NL_ID || this->Id==TASK_ID || this->Id==MAN_ID ) this->MInd = N_MDATA; /* send the ASSIGN */ this->More |=XMOREF; a->ram_out(a, &RAM->Req, this->Req); /* save the reference of the ASSIGN */ assign_queue(a, this->No, 0); } /* if it is a 'unreturncoded' UREMOVE request, remove the */ /* Id from our table after sending the request */ if(this->Req==UREMOVE && this->Id) { Id = this->Id; e_no = a->IdTable[Id]; free_entity(a, e_no); for (i = 0; i < 256; i++) { if (a->FlowControlIdTable[i] == Id) a->FlowControlIdTable[i] = 0; } a->IdTable[Id] = 0; this->Id = 0; }}static byte scom_ready(ADAPTER * a){ if(a->ram_in(a, &RAM->Req)) { if(!a->ReadyInt) { a->ram_inc(a, &RAM->ReadyInt); a->ReadyInt++; } return 0; } return 1;}/*------------------------------------------------------------------*//* isdn interrupt handler *//*------------------------------------------------------------------*/byte scom_dpc(ADAPTER * a){ byte c; /* if a return code is available ... */ if(a->ram_in(a, &RAM->Rc)) { /* call return code handler, if it is not our return code */ /* the handler returns 2, if it's the return code to an */ /* ASSIGN the handler returns 1 */ c = isdn_rc(a, a->ram_in(a, &RAM->Rc), a->ram_in(a, &RAM->RcId), a->ram_in(a, &RAM->RcCh), 0, /* Scom Card does not provide extended information */ 0, 0); switch(c) { case 0: a->ram_out(a, &RAM->Rc, 0); break; case 1: a->ram_out(a, &RAM->Req, 0); a->ram_out(a, &RAM->Rc, 0); break; case 2: return TRUE; } /* call output function */ scom_out(a); } else { /* if an indications is available ... */ if(a->ram_in(a, &RAM->Ind)) { /* call indication handler, a return value of 2 means chain */ /* a return value of 1 means RNR */ c = isdn_ind(a, a->ram_in(a, &RAM->Ind), a->ram_in(a, &RAM->IndId), a->ram_in(a, &RAM->IndCh), &RAM->RBuffer, a->ram_in(a, &RAM->MInd), a->ram_inw(a, &RAM->MLength)); switch(c) { case 0: a->ram_out(a, &RAM->Ind, 0); break; case 1: dtrc(dprintf("RNR")); a->ram_out(a, &RAM->RNR, TRUE); break; case 2: return TRUE; } } } return FALSE;}byte scom_test_int(ADAPTER * a){ return a->ram_in(a,(void *)0x3fe);}void scom_clear_int(ADAPTER * a){ a->ram_out(a,(void *)0x3fe,0);}void quadro_clear_int(ADAPTER * a){ a->ram_out(a,(void *)0x3fe,0); a->ram_out(a,(void *)0x401,0);}/*------------------------------------------------------------------*//* return code handler *//*------------------------------------------------------------------*/byte isdn_rc(ADAPTER * a, byte Rc, byte Id, byte Ch, word Ref, dword extended_info_type, dword extended_info){ ENTITY * this; byte e_no; word i; int cancel_rc;#ifdef USE_EXTENDED_DEBUGS { DBG_TRC(("<A%d Id=0x%x Rc=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Rc)) }#else dbug(dprintf("isdn_rc(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch));#endif /* check for ready interrupt */ if(Rc==READY_INT) { xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, 0); if(a->ReadyInt) { a->ReadyInt--; return 0; } return 2; } /* if we know this Id ... */ e_no = a->IdTable[Id]; if(e_no) { this = entity_ptr(a,e_no); xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, a->IdTypeTable[this->No]); this->RcCh = Ch; /* if it is a return code to a REMOVE request, remove the */ /* Id from our table */ if ((a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_REMOVE_PENDING) && (Rc==OK)) { if (a->IdTypeTable[e_no] == NL_ID) { if (a->RcExtensionSupported && (extended_info_type != DIVA_RC_TYPE_REMOVE_COMPLETE)) { dtrc(dprintf("XDI: N-REMOVE, A(%02x) Id:%02x, ignore RC=OK", XDI_A_NR(a),Id)); return (0); } if (extended_info_type == DIVA_RC_TYPE_REMOVE_COMPLETE) a->RcExtensionSupported = TRUE; } a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_REMOVE_PENDING; a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_NO_RC_CANCELLING; free_entity(a, e_no); for (i = 0; i < 256; i++) { if (a->FlowControlIdTable[i] == Id) a->FlowControlIdTable[i] = 0; } a->IdTable[Id] = 0; this->Id = 0; /* --------------------------------------------------------------- If we send N_DISC or N_DISK_ACK after we have received OK_FC then the card will respond with OK_FC and later with RC==OK. If we send N_REMOVE in this state we will receive only RC==OK This will create the state in that the XDI is waiting for the additional RC and does not delivery the RC to the client. This code corrects the counter of outstanding RC's in this case. --------------------------------------------------------------- */ if ((this->More & XMOREC) > 1) { this->More &= ~XMOREC; this->More |= 1; dtrc(dprintf("XDI: correct MORE on REMOVE A(%02x) Id:%02x", XDI_A_NR(a),Id)); } } if (Rc==OK_FC) { a->FlowControlIdTable[Ch] = Id; a->FlowControlSkipTable[Ch] = FALSE; this->Rc = Rc; this->More &= ~(XBUSY | XMOREC); this->complete=0xff; xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); CALLBACK(a, this); return 0; } /* New protocol code sends return codes that comes from release of flow control condition marked with DIVA_RC_TYPE_OK_FC extended information element type. If like return code arrives then application is able to process all return codes self and XDI should not cances return codes. This return code does not decrement XMOREC partial return code counter due to fact that it was no request for this return code, also XMOREC was not incremented. */ if (extended_info_type == DIVA_RC_TYPE_OK_FC) { a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_NO_RC_CANCELLING; this->Rc = Rc; this->complete=0xff; xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); DBG_TRC(("XDI OK_FC A(%02x) Id:%02x Ch:%02x Rc:%02x", XDI_A_NR(a), Id, Ch, Rc)) CALLBACK(a, this); return 0; } cancel_rc = !(a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_NO_RC_CANCELLING); if (cancel_rc && (a->FlowControlIdTable[Ch] == Id)) { a->FlowControlIdTable[Ch] = 0; if ((Rc != OK) || !a->FlowControlSkipTable[Ch]) { this->Rc = Rc; if (Ch == this->ReqCh) { this->More &=~(XBUSY | XMOREC); this->complete=0xff; } xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); CALLBACK(a, this); } return 0; } if (this->More &XMOREC) this->More--; /* call the application callback function */ if (((!cancel_rc) || (this->More & XMOREF)) && !(this->More & XMOREC)) { this->Rc = Rc; this->More &=~XBUSY; this->complete=0xff; xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); CALLBACK(a, this); } return 0; } /* if it's an ASSIGN return code check if it's a return */ /* code to an ASSIGN request from us */ if((Rc &0xf0)==ASSIGN_RC) { e_no = get_assign(a, Ref); if(e_no) { this = entity_ptr(a,e_no); this->Id = Id;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?