Path: blob/master/drivers/isdn/hardware/eicon/di.c
15115 views
1/*2*3Copyright (c) Eicon Networks, 2002.4*5This source file is supplied for the use with6Eicon Networks range of DIVA Server Adapters.7*8Eicon File Revision : 2.19*10This program is free software; you can redistribute it and/or modify11it under the terms of the GNU General Public License as published by12the Free Software Foundation; either version 2, or (at your option)13any later version.14*15This program is distributed in the hope that it will be useful,16but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY17implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.18See the GNU General Public License for more details.19*20You should have received a copy of the GNU General Public License21along with this program; if not, write to the Free Software22Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.23*24*/25#include "platform.h"26#include "pc.h"27#include "pr_pc.h"28#include "di_defs.h"29#include "di.h"30#if !defined USE_EXTENDED_DEBUGS31#include "dimaint.h"32#else33#define dprintf34#endif35#include "io.h"36#include "dfifo.h"37#define PR_RAM ((struct pr_ram *)0)38#define RAM ((struct dual *)0)39/*------------------------------------------------------------------*/40/* local function prototypes */41/*------------------------------------------------------------------*/42void pr_out(ADAPTER * a);43byte pr_dpc(ADAPTER * a);44static byte pr_ready(ADAPTER * a);45static byte isdn_rc(ADAPTER *, byte, byte, byte, word, dword, dword);46static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word);47/* -----------------------------------------------------------------48Functions used for the extended XDI Debug49macros50global convergence counter (used by all adapters)51Look by the implementation part of the functions52about the parameters.53If you change the dubugging parameters, then you should update54the aididbg.doc in the IDI doc's.55----------------------------------------------------------------- */56#if defined(XDI_USE_XLOG)57#define XDI_A_NR(_x_) ((byte)(((ISDN_ADAPTER *)(_x_->io))->ANum))58static void xdi_xlog (byte *msg, word code, int length);59static byte xdi_xlog_sec = 0;60#else61#define XDI_A_NR(_x_) ((byte)0)62#endif63static void xdi_xlog_rc_event (byte Adapter,64byte Id, byte Ch, byte Rc, byte cb, byte type);65static void xdi_xlog_request (byte Adapter, byte Id,66byte Ch, byte Req, byte type);67static void xdi_xlog_ind (byte Adapter,68byte Id,69byte Ch,70byte Ind,71byte rnr_valid,72byte rnr,73byte type);74/*------------------------------------------------------------------*/75/* output function */76/*------------------------------------------------------------------*/77void pr_out(ADAPTER * a)78{79byte e_no;80ENTITY * this = NULL;81BUFFERS *X;82word length;83word i;84word clength;85REQ * ReqOut;86byte more;87byte ReadyCount;88byte ReqCount;89byte Id;90dtrc(dprintf("pr_out"));91/* while a request is pending ... */92e_no = look_req(a);93if(!e_no)94{95dtrc(dprintf("no_req"));96return;97}98ReadyCount = pr_ready(a);99if(!ReadyCount)100{101dtrc(dprintf("not_ready"));102return;103}104ReqCount = 0;105while(e_no && ReadyCount) {106next_req(a);107this = entity_ptr(a, e_no);108#ifdef USE_EXTENDED_DEBUGS109if ( !this )110{111DBG_FTL(("XDI: [%02x] !A%d ==> NULL entity ptr - try to ignore",112xdi_xlog_sec++, (int)((ISDN_ADAPTER *)a->io)->ANum))113e_no = look_req(a) ;114ReadyCount-- ;115continue ;116}117{118DBG_TRC((">A%d Id=0x%x Req=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, this->Id, this->Req))119}120#else121dbug(dprintf("out:Req=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh));122#endif123/* get address of next available request buffer */124ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)];125#if defined(DIVA_ISTREAM)126if (!(a->tx_stream[this->Id] &&127this->Req == N_DATA)) {128#endif129/* now copy the data from the current data buffer into the */130/* adapters request buffer */131length = 0;132i = this->XCurrent;133X = PTR_X(a,this);134while(i<this->XNum && length<270) {135clength = min((word)(270-length),(word)(X[i].PLength-this->XOffset));136a->ram_out_buffer(a,137&ReqOut->XBuffer.P[length],138PTR_P(a,this,&X[i].P[this->XOffset]),139clength);140length +=clength;141this->XOffset +=clength;142if(this->XOffset==X[i].PLength) {143this->XCurrent = (byte)++i;144this->XOffset = 0;145}146}147#if defined(DIVA_ISTREAM)148} else { /* Use CMA extension in order to transfer data to the card */149i = this->XCurrent;150X = PTR_X(a,this);151while (i < this->XNum) {152diva_istream_write (a,153this->Id,154PTR_P(a,this,&X[i].P[0]),155X[i].PLength,156((i+1) == this->XNum),1570, 0);158this->XCurrent = (byte)++i;159}160length = 0;161}162#endif163a->ram_outw(a, &ReqOut->XBuffer.length, length);164a->ram_out(a, &ReqOut->ReqId, this->Id);165a->ram_out(a, &ReqOut->ReqCh, this->ReqCh);166/* if it's a specific request (no ASSIGN) ... */167if(this->Id &0x1f) {168/* if buffers are left in the list of data buffers do */169/* do chaining (LL_MDATA, N_MDATA) */170this->More++;171if(i<this->XNum && this->MInd) {172xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->MInd,173a->IdTypeTable[this->No]);174a->ram_out(a, &ReqOut->Req, this->MInd);175more = true;176}177else {178xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->Req,179a->IdTypeTable[this->No]);180this->More |=XMOREF;181a->ram_out(a, &ReqOut->Req, this->Req);182more = false;183if (a->FlowControlIdTable[this->ReqCh] == this->Id)184a->FlowControlSkipTable[this->ReqCh] = true;185/*186Note that remove request was sent to the card187*/188if (this->Req == REMOVE) {189a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_REMOVE_PENDING;190}191}192/* if we did chaining, this entity is put back into the */193/* request queue */194if(more) {195req_queue(a,this->No);196}197}198/* else it's a ASSIGN */199else {200/* save the request code used for buffer chaining */201this->MInd = 0;202if (this->Id==BLLC_ID) this->MInd = LL_MDATA;203if (this->Id==NL_ID ||204this->Id==TASK_ID ||205this->Id==MAN_ID206) this->MInd = N_MDATA;207/* send the ASSIGN */208a->IdTypeTable[this->No] = this->Id;209xdi_xlog_request (XDI_A_NR(a),this->Id,this->ReqCh,this->Req, this->Id);210this->More |=XMOREF;211a->ram_out(a, &ReqOut->Req, this->Req);212/* save the reference of the ASSIGN */213assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference));214}215a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next));216ReadyCount--;217ReqCount++;218e_no = look_req(a);219}220/* send the filled request buffers to the ISDN adapter */221a->ram_out(a, &PR_RAM->ReqInput,222(byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount));223/* if it is a 'unreturncoded' UREMOVE request, remove the */224/* Id from our table after sending the request */225if(this && (this->Req==UREMOVE) && this->Id) {226Id = this->Id;227e_no = a->IdTable[Id];228free_entity(a, e_no);229for (i = 0; i < 256; i++)230{231if (a->FlowControlIdTable[i] == Id)232a->FlowControlIdTable[i] = 0;233}234a->IdTable[Id] = 0;235this->Id = 0;236}237}238static byte pr_ready(ADAPTER * a)239{240byte ReadyCount;241ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) -242a->ram_in(a, &PR_RAM->ReqInput));243if(!ReadyCount) {244if(!a->ReadyInt) {245a->ram_inc(a, &PR_RAM->ReadyInt);246a->ReadyInt++;247}248}249return ReadyCount;250}251/*------------------------------------------------------------------*/252/* isdn interrupt handler */253/*------------------------------------------------------------------*/254byte pr_dpc(ADAPTER * a)255{256byte Count;257RC * RcIn;258IND * IndIn;259byte c;260byte RNRId;261byte Rc;262byte Ind;263/* if return codes are available ... */264if((Count = a->ram_in(a, &PR_RAM->RcOutput)) != 0) {265dtrc(dprintf("#Rc=%x",Count));266/* get the buffer address of the first return code */267RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)];268/* for all return codes do ... */269while(Count--) {270if((Rc=a->ram_in(a, &RcIn->Rc)) != 0) {271dword tmp[2];272/*273Get extended information, associated with return code274*/275a->ram_in_buffer(a,276&RcIn->Reserved2[0],277(byte*)&tmp[0],2788);279/* call return code handler, if it is not our return code */280/* the handler returns 2 */281/* for all return codes we process, we clear the Rc field */282isdn_rc(a,283Rc,284a->ram_in(a, &RcIn->RcId),285a->ram_in(a, &RcIn->RcCh),286a->ram_inw(a, &RcIn->Reference),287tmp[0], /* type of extended information */288tmp[1]); /* extended information */289a->ram_out(a, &RcIn->Rc, 0);290}291/* get buffer address of next return code */292RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &RcIn->next)];293}294/* clear all return codes (no chaining!) */295a->ram_out(a, &PR_RAM->RcOutput ,0);296/* call output function */297pr_out(a);298}299/* clear RNR flag */300RNRId = 0;301/* if indications are available ... */302if((Count = a->ram_in(a, &PR_RAM->IndOutput)) != 0) {303dtrc(dprintf("#Ind=%x",Count));304/* get the buffer address of the first indication */305IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextInd)];306/* for all indications do ... */307while(Count--) {308/* if the application marks an indication as RNR, all */309/* indications from the same Id delivered in this interrupt */310/* are marked RNR */311if(RNRId && RNRId==a->ram_in(a, &IndIn->IndId)) {312a->ram_out(a, &IndIn->Ind, 0);313a->ram_out(a, &IndIn->RNR, true);314}315else {316Ind = a->ram_in(a, &IndIn->Ind);317if(Ind) {318RNRId = 0;319/* call indication handler, a return value of 2 means chain */320/* a return value of 1 means RNR */321/* for all indications we process, we clear the Ind field */322c = isdn_ind(a,323Ind,324a->ram_in(a, &IndIn->IndId),325a->ram_in(a, &IndIn->IndCh),326&IndIn->RBuffer,327a->ram_in(a, &IndIn->MInd),328a->ram_inw(a, &IndIn->MLength));329if(c==1) {330dtrc(dprintf("RNR"));331a->ram_out(a, &IndIn->Ind, 0);332RNRId = a->ram_in(a, &IndIn->IndId);333a->ram_out(a, &IndIn->RNR, true);334}335}336}337/* get buffer address of next indication */338IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &IndIn->next)];339}340a->ram_out(a, &PR_RAM->IndOutput, 0);341}342return false;343}344byte scom_test_int(ADAPTER * a)345{346return a->ram_in(a,(void *)0x3fe);347}348void scom_clear_int(ADAPTER * a)349{350a->ram_out(a,(void *)0x3fe,0);351}352/*------------------------------------------------------------------*/353/* return code handler */354/*------------------------------------------------------------------*/355static byte isdn_rc(ADAPTER *a,356byte Rc,357byte Id,358byte Ch,359word Ref,360dword extended_info_type,361dword extended_info)362{363ENTITY * this;364byte e_no;365word i;366int cancel_rc;367#ifdef USE_EXTENDED_DEBUGS368{369DBG_TRC(("<A%d Id=0x%x Rc=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Rc))370}371#else372dbug(dprintf("isdn_rc(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch));373#endif374/* check for ready interrupt */375if(Rc==READY_INT) {376xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, 0);377if(a->ReadyInt) {378a->ReadyInt--;379return 0;380}381return 2;382}383/* if we know this Id ... */384e_no = a->IdTable[Id];385if(e_no) {386this = entity_ptr(a,e_no);387xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, a->IdTypeTable[this->No]);388this->RcCh = Ch;389/* if it is a return code to a REMOVE request, remove the */390/* Id from our table */391if ((a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_REMOVE_PENDING) &&392(Rc==OK)) {393if (a->IdTypeTable[e_no] == NL_ID) {394if (a->RcExtensionSupported &&395(extended_info_type != DIVA_RC_TYPE_REMOVE_COMPLETE)) {396dtrc(dprintf("XDI: N-REMOVE, A(%02x) Id:%02x, ignore RC=OK",397XDI_A_NR(a),Id));398return (0);399}400if (extended_info_type == DIVA_RC_TYPE_REMOVE_COMPLETE)401a->RcExtensionSupported = true;402}403a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_REMOVE_PENDING;404a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_NO_RC_CANCELLING;405free_entity(a, e_no);406for (i = 0; i < 256; i++)407{408if (a->FlowControlIdTable[i] == Id)409a->FlowControlIdTable[i] = 0;410}411a->IdTable[Id] = 0;412this->Id = 0;413/* ---------------------------------------------------------------414If we send N_DISC or N_DISK_ACK after we have received OK_FC415then the card will respond with OK_FC and later with RC==OK.416If we send N_REMOVE in this state we will receive only RC==OK417This will create the state in that the XDI is waiting for the418additional RC and does not delivery the RC to the client. This419code corrects the counter of outstanding RC's in this case.420--------------------------------------------------------------- */421if ((this->More & XMOREC) > 1) {422this->More &= ~XMOREC;423this->More |= 1;424dtrc(dprintf("XDI: correct MORE on REMOVE A(%02x) Id:%02x",425XDI_A_NR(a),Id));426}427}428if (Rc==OK_FC) {429a->FlowControlIdTable[Ch] = Id;430a->FlowControlSkipTable[Ch] = false;431this->Rc = Rc;432this->More &= ~(XBUSY | XMOREC);433this->complete=0xff;434xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);435CALLBACK(a, this);436return 0;437}438/*439New protocol code sends return codes that comes from release440of flow control condition marked with DIVA_RC_TYPE_OK_FC extended441information element type.442If like return code arrives then application is able to process443all return codes self and XDI should not cances return codes.444This return code does not decrement XMOREC partial return code445counter due to fact that it was no request for this return code,446also XMOREC was not incremented.447*/448if (extended_info_type == DIVA_RC_TYPE_OK_FC) {449a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_NO_RC_CANCELLING;450this->Rc = Rc;451this->complete=0xff;452xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);453DBG_TRC(("XDI OK_FC A(%02x) Id:%02x Ch:%02x Rc:%02x",454XDI_A_NR(a), Id, Ch, Rc))455CALLBACK(a, this);456return 0;457}458cancel_rc = !(a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_NO_RC_CANCELLING);459if (cancel_rc && (a->FlowControlIdTable[Ch] == Id))460{461a->FlowControlIdTable[Ch] = 0;462if ((Rc != OK) || !a->FlowControlSkipTable[Ch])463{464this->Rc = Rc;465if (Ch == this->ReqCh)466{467this->More &=~(XBUSY | XMOREC);468this->complete=0xff;469}470xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);471CALLBACK(a, this);472}473return 0;474}475if (this->More &XMOREC)476this->More--;477/* call the application callback function */478if (((!cancel_rc) || (this->More & XMOREF)) && !(this->More & XMOREC)) {479this->Rc = Rc;480this->More &=~XBUSY;481this->complete=0xff;482xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);483CALLBACK(a, this);484}485return 0;486}487/* if it's an ASSIGN return code check if it's a return */488/* code to an ASSIGN request from us */489if((Rc &0xf0)==ASSIGN_RC) {490e_no = get_assign(a, Ref);491if(e_no) {492this = entity_ptr(a,e_no);493this->Id = Id;494xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 2, a->IdTypeTable[this->No]);495/* call the application callback function */496this->Rc = Rc;497this->More &=~XBUSY;498this->complete=0xff;499#if defined(DIVA_ISTREAM) /* { */500if ((Rc == ASSIGN_OK) && a->ram_offset &&501(a->IdTypeTable[this->No] == NL_ID) &&502((extended_info_type == DIVA_RC_TYPE_RX_DMA) ||503(extended_info_type == DIVA_RC_TYPE_CMA_PTR)) &&504extended_info) {505dword offset = (*(a->ram_offset)) (a);506dword tmp[2];507extended_info -= offset;508#ifdef PLATFORM_GT_32BIT509a->ram_in_dw(a, (void*)ULongToPtr(extended_info), (dword*)&tmp[0], 2);510#else511a->ram_in_dw(a, (void*)extended_info, (dword*)&tmp[0], 2);512#endif513a->tx_stream[Id] = tmp[0];514a->rx_stream[Id] = tmp[1];515if (extended_info_type == DIVA_RC_TYPE_RX_DMA) {516DBG_TRC(("Id=0x%x RxDMA=%08x:%08x",517Id, a->tx_stream[Id], a->rx_stream[Id]))518a->misc_flags_table[this->No] |= DIVA_MISC_FLAGS_RX_DMA;519} else {520DBG_TRC(("Id=0x%x CMA=%08x:%08x",521Id, a->tx_stream[Id], a->rx_stream[Id]))522a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA;523a->rx_pos[Id] = 0;524a->rx_stream[Id] -= offset;525}526a->tx_pos[Id] = 0;527a->tx_stream[Id] -= offset;528} else {529a->tx_stream[Id] = 0;530a->rx_stream[Id] = 0;531a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA;532}533#endif /* } */534CALLBACK(a, this);535if(Rc==ASSIGN_OK) {536a->IdTable[Id] = e_no;537}538else539{540free_entity(a, e_no);541for (i = 0; i < 256; i++)542{543if (a->FlowControlIdTable[i] == Id)544a->FlowControlIdTable[i] = 0;545}546a->IdTable[Id] = 0;547this->Id = 0;548}549return 1;550}551}552return 2;553}554/*------------------------------------------------------------------*/555/* indication handler */556/*------------------------------------------------------------------*/557static byte isdn_ind(ADAPTER *a,558byte Ind,559byte Id,560byte Ch,561PBUFFER *RBuffer,562byte MInd,563word MLength)564{565ENTITY * this;566word clength;567word offset;568BUFFERS *R;569byte* cma = NULL;570#ifdef USE_EXTENDED_DEBUGS571{572DBG_TRC(("<A%d Id=0x%x Ind=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Ind))573}574#else575dbug(dprintf("isdn_ind(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch));576#endif577if(a->IdTable[Id]) {578this = entity_ptr(a,a->IdTable[Id]);579this->IndCh = Ch;580xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind,5810/* rnr_valid */, 0 /* rnr */, a->IdTypeTable[this->No]);582/* if the Receive More flag is not yet set, this is the */583/* first buffer of the packet */584if(this->RCurrent==0xff) {585/* check for receive buffer chaining */586if(Ind==this->MInd) {587this->complete = 0;588this->Ind = MInd;589}590else {591this->complete = 1;592this->Ind = Ind;593}594/* call the application callback function for the receive */595/* look ahead */596this->RLength = MLength;597#if defined(DIVA_ISTREAM)598if ((a->rx_stream[this->Id] ||599(a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA)) &&600((Ind == N_DATA) ||601(a->protocol_capabilities & PROTCAP_CMA_ALLPR))) {602PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io ;603if (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA) {604#if defined(DIVA_IDI_RX_DMA)605dword d;606diva_get_dma_map_entry (\607(struct _diva_dma_map_entry*)IoAdapter->dma_map,608(int)a->rx_stream[this->Id], (void**)&cma, &d);609#else610cma = &a->stream_buffer[0];611cma[0] = cma[1] = cma[2] = cma[3] = 0;612#endif613this->RLength = MLength = (word)*(dword*)cma;614cma += 4;615} else {616int final = 0;617cma = &a->stream_buffer[0];618this->RLength = MLength = (word)diva_istream_read (a,619Id,620cma,621sizeof(a->stream_buffer),622&final, NULL, NULL);623}624IoAdapter->RBuffer.length = min(MLength, (word)270);625if (IoAdapter->RBuffer.length != MLength) {626this->complete = 0;627} else {628this->complete = 1;629}630memcpy (IoAdapter->RBuffer.P, cma, IoAdapter->RBuffer.length) ;631this->RBuffer = (DBUFFER *)&IoAdapter->RBuffer ;632}633#endif634if (!cma) {635a->ram_look_ahead(a, RBuffer, this);636}637this->RNum = 0;638CALLBACK(a, this);639/* map entity ptr, selector could be re-mapped by call to */640/* IDI from within callback */641this = entity_ptr(a,a->IdTable[Id]);642xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind,6431/* rnr_valid */, this->RNR/* rnr */, a->IdTypeTable[this->No]);644/* check for RNR */645if(this->RNR==1) {646this->RNR = 0;647return 1;648}649/* if no buffers are provided by the application, the */650/* application want to copy the data itself including */651/* N_MDATA/LL_MDATA chaining */652if(!this->RNR && !this->RNum) {653xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind,6542/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]);655return 0;656}657/* if there is no RNR, set the More flag */658this->RCurrent = 0;659this->ROffset = 0;660}661if(this->RNR==2) {662if(Ind!=this->MInd) {663this->RCurrent = 0xff;664this->RNR = 0;665}666return 0;667}668/* if we have received buffers from the application, copy */669/* the data into these buffers */670offset = 0;671R = PTR_R(a,this);672do {673if(this->ROffset==R[this->RCurrent].PLength) {674this->ROffset = 0;675this->RCurrent++;676}677if (cma) {678clength = min(MLength, (word)(R[this->RCurrent].PLength-this->ROffset));679} else {680clength = min(a->ram_inw(a, &RBuffer->length)-offset,681R[this->RCurrent].PLength-this->ROffset);682}683if(R[this->RCurrent].P) {684if (cma) {685memcpy (PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]),686&cma[offset],687clength);688} else {689a->ram_in_buffer(a,690&RBuffer->P[offset],691PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]),692clength);693}694}695offset +=clength;696this->ROffset +=clength;697if (cma) {698if (offset >= MLength) {699break;700}701continue;702}703} while(offset<(a->ram_inw(a, &RBuffer->length)));704/* if it's the last buffer of the packet, call the */705/* application callback function for the receive complete */706/* call */707if(Ind!=this->MInd) {708R[this->RCurrent].PLength = this->ROffset;709if(this->ROffset) this->RCurrent++;710this->RNum = this->RCurrent;711this->RCurrent = 0xff;712this->Ind = Ind;713this->complete = 2;714xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind,7153/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]);716CALLBACK(a, this);717}718return 0;719}720return 2;721}722#if defined(XDI_USE_XLOG)723/* -----------------------------------------------------------724This function works in the same way as xlog on the725active board726----------------------------------------------------------- */727static void xdi_xlog (byte *msg, word code, int length) {728xdi_dbg_xlog ("\x00\x02", msg, code, length);729}730#endif731/* -----------------------------------------------------------732This function writes the information about the Return Code733processing in the trace buffer. Trace ID is 221.734INPUT:735Adapter - system unicue adapter number (0 ... 255)736Id - Id of the entity that had sent this return code737Ch - Channel of the entity that had sent this return code738Rc - return code value739cb: (0...2)740switch (cb) {741case 0: printf ("DELIVERY"); break;742case 1: printf ("CALLBACK"); break;743case 2: printf ("ASSIGN"); break;744}745DELIVERY - have entered isdn_rc with this RC746CALLBACK - about to make callback to the application747for this RC748ASSIGN - about to make callback for RC that is result749of ASSIGN request. It is no DELIVERY message750before of this message751type - the Id that was sent by the ASSIGN of this entity.752This should be global Id like NL_ID, DSIG_ID, MAN_ID.753An unknown Id will cause "?-" in the front of the request.754In this case the log.c is to be extended.755----------------------------------------------------------- */756static void xdi_xlog_rc_event (byte Adapter,757byte Id, byte Ch, byte Rc, byte cb, byte type) {758#if defined(XDI_USE_XLOG)759word LogInfo[4];760PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));761PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));762PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8)));763PUT_WORD(&LogInfo[3], cb);764xdi_xlog ((byte*)&LogInfo[0], 221, sizeof(LogInfo));765#endif766}767/* ------------------------------------------------------------------------768This function writes the information about the request processing769in the trace buffer. Trace ID is 220.770INPUT:771Adapter - system unicue adapter number (0 ... 255)772Id - Id of the entity that had sent this request773Ch - Channel of the entity that had sent this request774Req - Code of the request775type - the Id that was sent by the ASSIGN of this entity.776This should be global Id like NL_ID, DSIG_ID, MAN_ID.777An unknown Id will cause "?-" in the front of the request.778In this case the log.c is to be extended.779------------------------------------------------------------------------ */780static void xdi_xlog_request (byte Adapter, byte Id,781byte Ch, byte Req, byte type) {782#if defined(XDI_USE_XLOG)783word LogInfo[3];784PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));785PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));786PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8)));787xdi_xlog ((byte*)&LogInfo[0], 220, sizeof(LogInfo));788#endif789}790/* ------------------------------------------------------------------------791This function writes the information about the indication processing792in the trace buffer. Trace ID is 222.793INPUT:794Adapter - system unicue adapter number (0 ... 255)795Id - Id of the entity that had sent this indication796Ch - Channel of the entity that had sent this indication797Ind - Code of the indication798rnr_valid: (0 .. 3) supported799switch (rnr_valid) {800case 0: printf ("DELIVERY"); break;801case 1: printf ("RNR=%d", rnr);802case 2: printf ("RNum=0");803case 3: printf ("COMPLETE");804}805DELIVERY - indication entered isdn_rc function806RNR=... - application had returned RNR=... after the807look ahead callback808RNum=0 - application had not returned any buffer to copy809this indication and will copy it self810COMPLETE - XDI had copied the data to the buffers provided811bu the application and is about to issue the812final callback813rnr: Look case 1 of the rnr_valid814type: the Id that was sent by the ASSIGN of this entity. This should815be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will816cause "?-" in the front of the request. In this case the817log.c is to be extended.818------------------------------------------------------------------------ */819static void xdi_xlog_ind (byte Adapter,820byte Id,821byte Ch,822byte Ind,823byte rnr_valid,824byte rnr,825byte type) {826#if defined(XDI_USE_XLOG)827word LogInfo[4];828PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));829PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));830PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8)));831PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8)));832xdi_xlog ((byte*)&LogInfo[0], 222, sizeof(LogInfo));833#endif834}835836837