OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [sc/] [interrupt.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*
2
 *  $Id: interrupt.c,v 1.1 2005-12-20 10:17:12 jcastillo Exp $
3
 *  Copyright (C) 1996  SpellCaster Telecommunications Inc.
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 *
19
 *  For more information, please contact gpl-info@spellcast.com or write:
20
 *
21
 *     SpellCaster Telecommunications Inc.
22
 *     5621 Finch Avenue East, Unit #3
23
 *     Scarborough, Ontario  Canada
24
 *     M1B 2T9
25
 *     +1 (416) 297-8565
26
 *     +1 (416) 297-6433 Facsimile
27
 */
28
 
29
#define __NO_VERSION__
30
#include "includes.h"
31
#include "hardware.h"
32
#include "message.h"
33
#include "card.h"
34
 
35
extern int indicate_status(int, int, ulong, char *);
36
extern void check_phystat(unsigned long);
37
extern void dump_messages(int);
38
extern int receivemessage(int, RspMessage *);
39
extern int sendmessage(int, unsigned int, unsigned int, unsigned int,
40
        unsigned int, unsigned int, unsigned int, unsigned int *);
41
extern void rcvpkt(int, RspMessage *);
42
 
43
extern int cinst;
44
extern board *adapter[];
45
 
46
int get_card_from_irq(int irq)
47
{
48
        int i;
49
 
50
        for(i = 0 ; i < cinst ; i++) {
51
                if(adapter[i]->interrupt == irq)
52
                        return i;
53
        }
54
        return -1;
55
}
56
 
57
/*
58
 *
59
 */
60
void interrupt_handler(int interrupt, void * cardptr, struct pt_regs *regs ) {
61
 
62
        RspMessage rcvmsg;
63
        int channel;
64
        int card;
65
 
66
        card = get_card_from_irq(interrupt);
67
 
68
        if(!IS_VALID_CARD(card)) {
69
                pr_debug("Invalid param: %d is not a valid card id\n", card);
70
                return;
71
        }
72
 
73
        pr_debug("%s: Entered Interrupt handler\n", adapter[card]->devicename);
74
 
75
        /*
76
         * Pull all of the waiting messages off the response queue
77
         */
78
        while (!receivemessage(card, &rcvmsg)) {
79
                /*
80
                 * Push the message to the adapter structure for
81
                 * send_and_receive to snoop
82
                 */
83
                if(adapter[card]->want_async_messages)
84
                        memcpy(&(adapter[card]->async_msg), &rcvmsg, sizeof(RspMessage));
85
 
86
                channel = (unsigned int) rcvmsg.phy_link_no;
87
 
88
                /*
89
                 * Trap Invalid request messages
90
                 */
91
                if(IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) {
92
                        pr_debug("%s: Invalid request Message, rsp_status = %d\n",
93
                                adapter[card]->devicename, rcvmsg.rsp_status);
94
                        break;
95
                }
96
 
97
                /*
98
                 * Check for a linkRead message
99
                 */
100
                if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read))
101
                {
102
                        pr_debug("%s: Received packet 0x%x bytes long at 0x%x\n",
103
                                                adapter[card]->devicename,
104
                                                rcvmsg.msg_data.response.msg_len,
105
                                                rcvmsg.msg_data.response.buff_offset);
106
                        rcvpkt(card, &rcvmsg);
107
                        continue;
108
 
109
                }
110
 
111
                /*
112
                 * Handle a write acknoledgement
113
                 */
114
                if(IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) {
115
                        pr_debug("%s: Packet Send ACK on channel %d\n", adapter[card]->devicename,
116
                                rcvmsg.phy_link_no);
117
                        adapter[card]->channel[rcvmsg.phy_link_no-1].free_sendbufs++;
118
                        continue;
119
                }
120
 
121
                /*
122
                 * Handle a connection message
123
                 */
124
                if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect))
125
                {
126
                        unsigned int callid;
127
                        setup_parm setup;
128
                        pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n",
129
                                                adapter[card]->devicename,
130
                                                rcvmsg.phy_link_no,
131
                                                rcvmsg.rsp_status,
132
                                                rcvmsg.msg_data.byte_array[2]);
133
 
134
                        memcpy(&callid,rcvmsg.msg_data.byte_array,sizeof(int));
135
                        if(callid>=0x8000 && callid<=0xFFFF)
136
                        {
137
                                pr_debug("%s: Got Dial-Out Rsp\n", adapter[card]->devicename);
138
                                indicate_status(card, ISDN_STAT_DCONN,
139
                                                (unsigned long)rcvmsg.phy_link_no-1,NULL);
140
 
141
                        }
142
                        else if(callid>=0x0000 && callid<=0x7FFF)
143
                        {
144
                                pr_debug("%s: Got Incomming Call\n", adapter[card]->devicename);
145
                                strcpy(setup.phone,&(rcvmsg.msg_data.byte_array[4]));
146
                                strcpy(setup.eazmsn,adapter[card]->channel[rcvmsg.phy_link_no-1].dn);
147
                                setup.si1 = 7;
148
                                setup.si2 = 0;
149
                                setup.plan = 0;
150
                                setup.screen = 0;
151
 
152
                                indicate_status(card, ISDN_STAT_ICALL,(unsigned long)rcvmsg.phy_link_no-1,(char *)&setup);
153
                                indicate_status(card, ISDN_STAT_DCONN,(unsigned long)rcvmsg.phy_link_no-1,NULL);
154
                        }
155
                        continue;
156
                }
157
 
158
                /*
159
                 * Handle a disconnection message
160
                 */
161
                if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect))
162
                {
163
                        pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n",
164
                                                adapter[card]->devicename,
165
                                                rcvmsg.phy_link_no,
166
                                                rcvmsg.rsp_status,
167
                                                rcvmsg.msg_data.byte_array[2]);
168
 
169
                        indicate_status(card, ISDN_STAT_BHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL);
170
                        indicate_status(card, ISDN_STAT_DHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL);
171
                        continue;
172
 
173
                }
174
 
175
                /*
176
                 * Handle a startProc engine up message
177
                 */
178
                if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) {
179
                        pr_debug("%s: Received EngineUp message\n", adapter[card]->devicename);
180
                        adapter[card]->EngineUp = 1;
181
                        sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,1,0,NULL);
182
                        sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,2,0,NULL);
183
                        init_timer(&adapter[card]->stat_timer);
184
                        adapter[card]->stat_timer.function = check_phystat;
185
                        adapter[card]->stat_timer.data = card;
186
                        adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME;
187
                        add_timer(&adapter[card]->stat_timer);
188
                        continue;
189
                }
190
 
191
                /*
192
                 * Start proc response
193
                 */
194
                if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) {
195
                        pr_debug("%s: StartProc Response Status %d\n", adapter[card]->devicename,
196
                                rcvmsg.rsp_status);
197
                        continue;
198
                }
199
 
200
                /*
201
                 * Handle a GetMyNumber Rsp
202
                 */
203
                if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){
204
                        strcpy(adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array);
205
                        continue;
206
                }
207
 
208
                /*
209
                 * PhyStatus response
210
                 */
211
                if(IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) {
212
                        unsigned int b1stat, b2stat;
213
 
214
                        /*
215
                         * Covert the message data to the adapter->phystat code
216
                         */
217
                        b1stat = (unsigned int) rcvmsg.msg_data.byte_array[0];
218
                        b2stat = (unsigned int) rcvmsg.msg_data.byte_array[1];
219
 
220
                        adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */
221
                        pr_debug("%s: PhyStat is 0x%2x\n", adapter[card]->devicename,
222
                                adapter[card]->nphystat);
223
                        continue;
224
                }
225
 
226
 
227
                /*
228
                 * Handle a GetFramFormat
229
                 */
230
                if(IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) {
231
                        if(rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) {
232
                                unsigned int proto = HDLC_PROTO;
233
                                /*
234
                                 * Set board format to HDLC if it wasn't already
235
                                 */
236
                                pr_debug("%s: current frame format: 0x%x, will change to HDLC\n",
237
                                                adapter[card]->devicename,
238
                                        rcvmsg.msg_data.byte_array[0]);
239
                                sendmessage(card, CEPID, ceReqTypeCall,
240
                                                ceReqClass0,
241
                                                ceReqCallSetFrameFormat,
242
                                                (unsigned char) channel +1,
243
                                                1,&proto);
244
                                }
245
                        continue;
246
                }
247
 
248
                /*
249
                 * Hmm...
250
                 */
251
                pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n",
252
                        adapter[card]->devicename, rcvmsg.type, rcvmsg.class, rcvmsg.code,
253
                        rcvmsg.phy_link_no);
254
 
255
        }       /* while */
256
 
257
        pr_debug("%s: Exiting Interrupt Handler\n", adapter[card]->devicename);
258
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.