2005-04-17 05:20:36 +07:00
|
|
|
/* $Id: interrupt.c,v 1.4.8.3 2001/09/23 22:24:59 kai Exp $
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
* For more information, please contact gpl-info@spellcast.com or write:
|
|
|
|
*
|
|
|
|
* SpellCaster Telecommunications Inc.
|
|
|
|
* 5621 Finch Avenue East, Unit #3
|
|
|
|
* Scarborough, Ontario Canada
|
|
|
|
* M1B 2T9
|
|
|
|
* +1 (416) 297-8565
|
|
|
|
* +1 (416) 297-6433 Facsimile
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
#include "hardware.h"
|
|
|
|
#include "message.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
|
|
|
/*
|
2012-02-20 10:52:38 +07:00
|
|
|
*
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2007-10-20 06:31:27 +07:00
|
|
|
irqreturn_t interrupt_handler(int dummy, void *card_inst)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
|
|
|
|
RspMessage rcvmsg;
|
|
|
|
int channel;
|
2007-10-20 06:31:27 +07:00
|
|
|
int card = (int)(unsigned long) card_inst;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-02-20 10:52:38 +07:00
|
|
|
if (!IS_VALID_CARD(card)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
pr_debug("Invalid param: %d is not a valid card id\n", card);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_debug("%s: Entered Interrupt handler\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename);
|
|
|
|
|
|
|
|
/*
|
2005-04-17 05:20:36 +07:00
|
|
|
* Pull all of the waiting messages off the response queue
|
|
|
|
*/
|
|
|
|
while (!receivemessage(card, &rcvmsg)) {
|
|
|
|
/*
|
|
|
|
* Push the message to the adapter structure for
|
|
|
|
* send_and_receive to snoop
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (sc_adapter[card]->want_async_messages)
|
2005-04-17 05:20:36 +07:00
|
|
|
memcpy(&(sc_adapter[card]->async_msg),
|
2012-02-20 10:52:38 +07:00
|
|
|
&rcvmsg, sizeof(RspMessage));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
channel = (unsigned int) rcvmsg.phy_link_no;
|
2012-02-20 10:52:38 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Trap Invalid request messages
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) {
|
|
|
|
pr_debug("%s: Invalid request Message, rsp_status = %d\n",
|
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.rsp_status);
|
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2012-02-20 10:52:38 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Check for a linkRead message
|
|
|
|
*/
|
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read))
|
|
|
|
{
|
2006-10-03 15:16:15 +07:00
|
|
|
pr_debug("%s: Received packet 0x%x bytes long at 0x%lx\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.msg_data.response.msg_len,
|
|
|
|
rcvmsg.msg_data.response.buff_offset);
|
2005-04-17 05:20:36 +07:00
|
|
|
rcvpkt(card, &rcvmsg);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a write acknoledgement
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
pr_debug("%s: Packet Send ACK on channel %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.phy_link_no);
|
|
|
|
sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].free_sendbufs++;
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a connection message
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect))
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned int callid;
|
2012-02-20 10:52:38 +07:00
|
|
|
setup_parm setup;
|
2005-04-17 05:20:36 +07:00
|
|
|
pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.phy_link_no,
|
|
|
|
rcvmsg.rsp_status,
|
|
|
|
rcvmsg.msg_data.byte_array[2]);
|
|
|
|
|
|
|
|
memcpy(&callid, rcvmsg.msg_data.byte_array, sizeof(int));
|
|
|
|
if (callid >= 0x8000 && callid <= 0xFFFF)
|
|
|
|
{
|
2005-04-17 05:20:36 +07:00
|
|
|
pr_debug("%s: Got Dial-Out Rsp\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename);
|
2005-04-17 05:20:36 +07:00
|
|
|
indicate_status(card, ISDN_STAT_DCONN,
|
2012-02-20 10:52:38 +07:00
|
|
|
(unsigned long)rcvmsg.phy_link_no - 1, NULL);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2012-02-20 10:52:38 +07:00
|
|
|
else if (callid >= 0x0000 && callid <= 0x7FFF)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2010-10-09 00:21:22 +07:00
|
|
|
int len;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
pr_debug("%s: Got Incoming Call\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename);
|
2010-10-09 00:21:22 +07:00
|
|
|
len = strlcpy(setup.phone, &(rcvmsg.msg_data.byte_array[4]),
|
2012-02-20 10:52:38 +07:00
|
|
|
sizeof(setup.phone));
|
2010-10-09 00:21:22 +07:00
|
|
|
if (len >= sizeof(setup.phone))
|
|
|
|
continue;
|
|
|
|
len = strlcpy(setup.eazmsn,
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
|
|
|
|
sizeof(setup.eazmsn));
|
2010-10-09 00:21:22 +07:00
|
|
|
if (len >= sizeof(setup.eazmsn))
|
|
|
|
continue;
|
2005-04-17 05:20:36 +07:00
|
|
|
setup.si1 = 7;
|
|
|
|
setup.si2 = 0;
|
|
|
|
setup.plan = 0;
|
|
|
|
setup.screen = 0;
|
|
|
|
|
2012-02-20 10:52:38 +07:00
|
|
|
indicate_status(card, ISDN_STAT_ICALL, (unsigned long)rcvmsg.phy_link_no - 1, (char *)&setup);
|
|
|
|
indicate_status(card, ISDN_STAT_DCONN, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a disconnection message
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect))
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.phy_link_no,
|
|
|
|
rcvmsg.rsp_status,
|
|
|
|
rcvmsg.msg_data.byte_array[2]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-02-20 10:52:38 +07:00
|
|
|
indicate_status(card, ISDN_STAT_BHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
|
|
|
|
indicate_status(card, ISDN_STAT_DHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a startProc engine up message
|
|
|
|
*/
|
|
|
|
if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) {
|
|
|
|
pr_debug("%s: Received EngineUp message\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename);
|
2005-04-17 05:20:36 +07:00
|
|
|
sc_adapter[card]->EngineUp = 1;
|
2012-02-20 10:52:38 +07:00
|
|
|
sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 1, 0, NULL);
|
|
|
|
sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 2, 0, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
init_timer(&sc_adapter[card]->stat_timer);
|
|
|
|
sc_adapter[card]->stat_timer.function = check_phystat;
|
|
|
|
sc_adapter[card]->stat_timer.data = card;
|
|
|
|
sc_adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME;
|
|
|
|
add_timer(&sc_adapter[card]->stat_timer);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start proc response
|
|
|
|
*/
|
|
|
|
if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) {
|
|
|
|
pr_debug("%s: StartProc Response Status %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.rsp_status);
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle a GetMyNumber Rsp
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetMyNumber)) {
|
2010-10-09 00:21:22 +07:00
|
|
|
strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
|
|
|
|
rcvmsg.msg_data.byte_array,
|
|
|
|
sizeof(rcvmsg.msg_data.byte_array));
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
2012-02-20 10:52:38 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* PhyStatus response
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int b1stat, b2stat;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Covert the message data to the adapter->phystat code
|
|
|
|
*/
|
|
|
|
b1stat = (unsigned int) rcvmsg.msg_data.byte_array[0];
|
|
|
|
b2stat = (unsigned int) rcvmsg.msg_data.byte_array[1];
|
|
|
|
|
|
|
|
sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */
|
|
|
|
pr_debug("%s: PhyStat is 0x%2x\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
sc_adapter[card]->nphystat);
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-20 10:52:38 +07:00
|
|
|
/*
|
2005-04-17 05:20:36 +07:00
|
|
|
* Handle a GetFramFormat
|
|
|
|
*/
|
2012-02-20 10:52:38 +07:00
|
|
|
if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) {
|
|
|
|
if (rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) {
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int proto = HDLC_PROTO;
|
|
|
|
/*
|
|
|
|
* Set board format to HDLC if it wasn't already
|
|
|
|
*/
|
|
|
|
pr_debug("%s: current frame format: 0x%x, will change to HDLC\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.msg_data.byte_array[0]);
|
2005-04-17 05:20:36 +07:00
|
|
|
sendmessage(card, CEPID, ceReqTypeCall,
|
2012-02-20 10:52:38 +07:00
|
|
|
ceReqClass0,
|
|
|
|
ceReqCallSetFrameFormat,
|
|
|
|
(unsigned char)channel + 1,
|
|
|
|
1, &proto);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hmm...
|
|
|
|
*/
|
|
|
|
pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename,
|
|
|
|
rcvmsg.type, rcvmsg.class, rcvmsg.code,
|
|
|
|
rcvmsg.phy_link_no);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
} /* while */
|
|
|
|
|
|
|
|
pr_debug("%s: Exiting Interrupt Handler\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
sc_adapter[card]->devicename);
|
2005-04-17 05:20:36 +07:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|