📄 idi.c
字号:
/* * * Copyright (C) Eicon Technology Corporation, 2000. * * This source file is supplied for the exclusive use with Eicon * Technology Corporation's range of DIVA Server Adapters. * * Eicon File Revision : 1.8 * * 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. * *//* * Core driver for Diva Server cards * Implements the IDI interface */#include "idi.h"#include "adapter.h"#include "pc.h"#include "pr_pc.h"#include "sys.h"#include "uxio.h"/* IDI request functions */static void request(card_t *card, ENTITY *e);static void req_0(ENTITY *e) { request(&DivasCards[ 0], e); }static void req_1(ENTITY *e) { request(&DivasCards[ 1], e); }static void req_2(ENTITY *e) { request(&DivasCards[ 2], e); }static void req_3(ENTITY *e) { request(&DivasCards[ 3], e); }static void req_4(ENTITY *e) { request(&DivasCards[ 4], e); }static void req_5(ENTITY *e) { request(&DivasCards[ 5], e); }static void req_6(ENTITY *e) { request(&DivasCards[ 6], e); }static void req_7(ENTITY *e) { request(&DivasCards[ 7], e); }static void req_8(ENTITY *e) { request(&DivasCards[ 8], e); }static void req_9(ENTITY *e) { request(&DivasCards[ 9], e); }static void req_10(ENTITY *e) { request(&DivasCards[10], e); }static void req_11(ENTITY *e) { request(&DivasCards[11], e); }static void req_12(ENTITY *e) { request(&DivasCards[12], e); }static void req_13(ENTITY *e) { request(&DivasCards[13], e); }static void req_14(ENTITY *e) { request(&DivasCards[14], e); }static void req_15(ENTITY *e) { request(&DivasCards[15], e); }IDI_CALL DivasIdiRequest[16] ={ &req_0, &req_1, &req_2, &req_3, &req_4, &req_5, &req_6, &req_7, &req_8, &req_9, &req_10, &req_11, &req_12, &req_13, &req_14, &req_15};#define PR_RAM ((struct pr_ram *)0)#define RAM ((struct dual *)0)/*------------------------------------------------------------------*//* local function prototypes *//*------------------------------------------------------------------*/static byte isdn_rc(ADAPTER *, byte, byte, byte, word);static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word);/* * IDI related functions */staticENTITY *entity_ptr(ADAPTER *a, byte e_no){ card_t *card; card = a->io; return card->e_tbl[e_no].e;}staticvoid CALLBACK(ADAPTER *a, ENTITY *e){ card_t *card = a->io; if (card->log_types & DIVAS_LOG_IDI) { DivasLogIdi(card, e, FALSE); } (*e->callback)(e);}staticvoid *PTR_P(ADAPTER *a, ENTITY *e, void *P){ return(P);}staticvoid *PTR_R(ADAPTER *a, ENTITY *e){ return((void*)e->R);}staticvoid *PTR_X(ADAPTER *a, ENTITY *e){ return((void*)e->X);}staticvoid free_entity(ADAPTER *a, byte e_no) { card_t *card; int ipl; card = a->io; ipl = UxCardLock(card->hw); card->e_tbl[e_no].e = NULL; card->e_count--; UxCardUnlock(card->hw, ipl); return;}staticvoid assign_queue(ADAPTER * a, byte e_no, word ref){ card_t *card; int ipl; card = a->io; ipl = UxCardLock(card->hw); card->e_tbl[e_no].assign_ref = ref; card->e_tbl[e_no].next = card->assign; card->assign = e_no; UxCardUnlock(card->hw, ipl); return;}staticbyte get_assign(ADAPTER *a, word ref){ card_t *card; byte e_no; int ipl; card = a->io; ipl = UxCardLock(card->hw); e_no = (byte)card->assign; while (e_no) { if (card->e_tbl[e_no].assign_ref == ref) { break; } e_no = card->e_tbl[e_no].next; } UxCardUnlock(card->hw, ipl); return e_no;}staticvoid req_queue(ADAPTER * a, byte e_no){ card_t *card; int ipl; card = a->io; ipl = UxCardLock(card->hw); card->e_tbl[e_no].next = 0; if (card->e_head) { card->e_tbl[card->e_tail].next = e_no; card->e_tail = e_no; } else { card->e_head = e_no; card->e_tail = e_no; } UxCardUnlock(card->hw, ipl); return;}staticbyte look_req(ADAPTER * a){ card_t *card; card = a->io; return(card->e_head);}staticvoid next_req(ADAPTER * a){ card_t *card; int ipl; card = a->io; ipl = UxCardLock(card->hw); card->e_head = card->e_tbl[card->e_head].next; if (!card->e_head) { card->e_tail = 0; } UxCardUnlock(card->hw, ipl); return;}/* * IDI request function for active cards */staticvoid request(card_t *card, ENTITY *e){ word *special_req; int i; int ipl; if (card->log_types & DIVAS_LOG_IDI) { DivasLogIdi(card, e, TRUE); } if (!e->Req) { special_req = (word *) e; switch (*special_req) { case REQ_REMOVE: return; case REQ_NAME: for (i=0; i < DIM(card->cfg.name); i++) { ((struct get_name_s *) e)->name[i] = card->cfg.name[i]; } return; case REQ_SERIAL: case REQ_XLOG: DPRINTF(("IDI: attempted REQ_SERIAL or REQ_XLOG")); return; default: return; } } ipl = UxCardLock(card->hw); if (!(e->Id & 0x1f)) { DPRINTF(("IDI: ASSIGN req")); for (i = 1; i < card->e_max; i++) { if (!card->e_tbl[i].e) { break; } } if (i == card->e_max) { DPRINTF(("IDI: request all ids in use (IDI req ignored)")); UxCardUnlock(card->hw, ipl); e->Rc = OUT_OF_RESOURCES; return; } card->e_tbl[i].e = e; card->e_count++; e->No = (byte) i; e->More = 0; e->RCurrent = 0xff; } else { i = e->No; } if (e->More & XBUSY) { DPRINTF(("IDI: request - entity is busy")); UxCardUnlock(card->hw, ipl); return; } e->More |= XBUSY; e->More &= ~ XMOREF; e->XCurrent = 0; e->XOffset = 0; card->e_tbl[i].next = 0; if(card->e_head) { card->e_tbl[card->e_tail].next = i; card->e_tail = i; } else { card->e_head = i; card->e_tail = i; } UxCardUnlock(card->hw, ipl); DivasScheduleRequestDpc(); return;}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;}/*------------------------------------------------------------------*//* output function *//*------------------------------------------------------------------*/void DivasOut(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; /* while a request is pending ... */ e_no = look_req(a); if(!e_no) { return; } ReadyCount = pr_ready(a); if(!ReadyCount) { DPRINTF(("IDI: card not ready for next request")); return; } ReqCount = 0; while(e_no && ReadyCount) { next_req(a); this = entity_ptr(a, e_no);#ifdef USE_EXTENDED_DEBUGS if ( !this ) { ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; DBG_FTL(("!A%d ==> NULL entity ptr - try to ignore", (int)io->ANum)) e_no = look_req(a) ; ReadyCount-- ; continue ; } { ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; DPRINTF(("IDI: >A%d Id=0x%x Req=0x%x", io->ANum, this->Id, this->Req)) }#else DPRINTF(("IDI: >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)]; /* 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) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -