⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 di.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *  Copyright (c) Eicon Networks, 2002. *  This source file is supplied for the use with  Eicon Networks range of DIVA Server Adapters. *  Eicon File Revision :    2.1 *  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2, or (at your option)  any later version. *  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. *  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */#include "platform.h"#include "pc.h"#include "pr_pc.h"#include "di_defs.h"#include "di.h"#if !defined USE_EXTENDED_DEBUGS  #include "dimaint.h"#else  #define dprintf#endif#include "io.h"#include "dfifo.h"#define PR_RAM  ((struct pr_ram *)0)#define RAM ((struct dual *)0)/*------------------------------------------------------------------*//* local function prototypes                                        *//*------------------------------------------------------------------*/void pr_out(ADAPTER * a);byte pr_dpc(ADAPTER * a);static byte pr_ready(ADAPTER * a);static byte isdn_rc(ADAPTER *, byte, byte, byte, word, dword, dword);static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word);/* -----------------------------------------------------------------    Functions used for the extended XDI Debug    macros    global convergence counter (used by all adapters)    Look by the implementation part of the functions    about the parameters.    If you change the dubugging parameters, then you should update    the aididbg.doc in the IDI doc's.   ----------------------------------------------------------------- */#if defined(XDI_USE_XLOG)#define XDI_A_NR(_x_) ((byte)(((ISDN_ADAPTER *)(_x_->io))->ANum))static void xdi_xlog (byte *msg, word code, int length);static byte xdi_xlog_sec = 0;#else#define XDI_A_NR(_x_) ((byte)0)#endifstatic void xdi_xlog_rc_event (byte Adapter,                               byte Id, byte Ch, byte Rc, byte cb, byte type);static void xdi_xlog_request (byte Adapter, byte Id,                              byte Ch, byte Req, byte type);static void xdi_xlog_ind (byte Adapter,                          byte Id,                          byte Ch,                          byte Ind,                          byte rnr_valid,                          byte rnr,                          byte type);/*------------------------------------------------------------------*//* output function                                                  *//*------------------------------------------------------------------*/void pr_out(ADAPTER * a){  byte e_no;  ENTITY  * this = NULL;  BUFFERS  *X;  word length;  word i;  word clength;  REQ * ReqOut;  byte more;  byte ReadyCount;  byte ReqCount;  byte Id;  dtrc(dprintf("pr_out"));        /* while a request is pending ...                           */  e_no = look_req(a);  if(!e_no)  {    dtrc(dprintf("no_req"));    return;  }  ReadyCount = pr_ready(a);  if(!ReadyCount)  {    dtrc(dprintf("not_ready"));    return;  }  ReqCount = 0;  while(e_no && ReadyCount) {    next_req(a);    this = entity_ptr(a, e_no);#ifdef USE_EXTENDED_DEBUGS    if ( !this )    {      DBG_FTL(("XDI: [%02x] !A%d ==> NULL entity ptr - try to ignore",               xdi_xlog_sec++, (int)((ISDN_ADAPTER *)a->io)->ANum))      e_no = look_req(a) ;      ReadyCount-- ;      continue ;    }    {      DBG_TRC((">A%d Id=0x%x Req=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, this->Id, this->Req))    }#else    dbug(dprintf("out:Req=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh));#endif        /* get address of next available request buffer             */    ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)];#if defined(DIVA_ISTREAM)    if (!(a->tx_stream[this->Id]   &&        this->Req == N_DATA)) {#endif        /* 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,                        &ReqOut->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;      }    }#if defined(DIVA_ISTREAM)   } else { /* Use CMA extension in order to transfer data to the card */      i = this->XCurrent;      X = PTR_X(a,this);      while (i < this->XNum) {        diva_istream_write (a,                            this->Id,                            PTR_P(a,this,&X[i].P[0]),                            X[i].PLength,                            ((i+1) == this->XNum),                            0, 0);        this->XCurrent = (byte)++i;      }      length = 0;   }#endif    a->ram_outw(a, &ReqOut->XBuffer.length, length);    a->ram_out(a, &ReqOut->ReqId, this->Id);    a->ram_out(a, &ReqOut->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       */        /* do chaining (LL_MDATA, N_MDATA)                          */      this->More++;      if(i<this->XNum && this->MInd) {        xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->MInd,                          a->IdTypeTable[this->No]);        a->ram_out(a, &ReqOut->Req, this->MInd);        more = TRUE;      }      else {        xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->Req,                          a->IdTypeTable[this->No]);        this->More |=XMOREF;        a->ram_out(a, &ReqOut->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 we did chaining, this entity is put back into the     */        /* request queue                                            */      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                                          */      a->IdTypeTable[this->No] = this->Id;      xdi_xlog_request (XDI_A_NR(a),this->Id,this->ReqCh,this->Req, this->Id);      this->More |=XMOREF;      a->ram_out(a, &ReqOut->Req, this->Req);        /* save the reference of the ASSIGN                         */      assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference));    }    a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next));    ReadyCount--;    ReqCount++;    e_no = look_req(a);  }        /* send the filled request buffers to the ISDN adapter      */  a->ram_out(a, &PR_RAM->ReqInput,             (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount));        /* if it is a 'unreturncoded' UREMOVE request, remove the  */        /* Id from our table after sending the request             */  if(this && (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 pr_ready(ADAPTER * a){  byte ReadyCount;  ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) -                      a->ram_in(a, &PR_RAM->ReqInput));  if(!ReadyCount) {    if(!a->ReadyInt) {      a->ram_inc(a, &PR_RAM->ReadyInt);      a->ReadyInt++;    }  }  return ReadyCount;}/*------------------------------------------------------------------*//* isdn interrupt handler                                           *//*------------------------------------------------------------------*/byte pr_dpc(ADAPTER * a){  byte Count;  RC * RcIn;  IND * IndIn;  byte c;  byte RNRId;  byte Rc;  byte Ind;        /* if return codes are available ...                        */  if((Count = a->ram_in(a, &PR_RAM->RcOutput)) != 0) {    dtrc(dprintf("#Rc=%x",Count));        /* get the buffer address of the first return code          */    RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)];        /* for all return codes do ...                              */    while(Count--) {      if((Rc=a->ram_in(a, &RcIn->Rc)) != 0) {        dword tmp[2];        /*          Get extended information, associated with return code          */        a->ram_in_buffer(a,                         &RcIn->Reserved2[0],                         (byte*)&tmp[0],                         8);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -