1 /* $Id: isdnl1.c,v 2.36 1999/08/25 16:50:57 keil Exp $
3 * isdnl1.c common low level stuff for Siemens Chipsetbased isdn cards
4 * based on the teles driver from Jan den Ouden
6 * Author Karsten Keil (keil@isdn4linux.de)
8 * This file is (c) under GNU PUBLIC LICENSE
9 * For changes and modifications please read
10 * ../../../Documentation/isdn/HiSax.cert
12 * Thanks to Jan den Ouden
18 * Revision 2.36 1999/08/25 16:50:57 keil
19 * Fix bugs which cause 2.3.14 hangs (waitqueue init)
21 * Revision 2.35 1999/08/22 20:27:07 calle
22 * backported changes from kernel 2.3.14:
23 * - several #include "config.h" gone, others come.
24 * - "struct device" changed to "struct net_device" in 2.3.14, added a
25 * define in isdn_compat.h for older kernel versions.
27 * Revision 2.34 1999/07/09 13:50:15 keil
28 * remove unused variable
30 * Revision 2.33 1999/07/09 13:34:33 keil
33 * Revision 2.32 1999/07/01 08:11:47 keil
34 * Common HiSax version for 2.0, 2.1, 2.2 and 2.3 kernel
36 * Revision 2.31 1998/11/15 23:54:56 keil
39 * Revision 2.30 1998/09/30 22:27:00 keil
40 * Add init of l1.Flags
42 * Revision 2.29 1998/09/27 23:54:43 keil
45 * Revision 2.28 1998/09/27 12:52:23 keil
46 * Fix against segfault, if the driver cannot allocate an IRQ channel
48 * Revision 2.27 1998/08/13 23:36:39 keil
49 * HiSax 3.1 - don't work stable with current LinkLevel
51 * Revision 2.26 1998/07/15 15:01:31 calle
52 * Support for AVM passive PCMCIA cards:
53 * A1 PCMCIA, FRITZ!Card PCMCIA and FRITZ!Card PCMCIA 2.0
55 * Revision 2.25 1998/05/25 14:10:09 keil
57 * X.75 and leased are working again.
59 * Revision 2.24 1998/05/25 12:58:04 keil
60 * HiSax golden code from certification, Don't use !!!
61 * No leased lines, no X75, but many changes.
63 * Revision 2.22 1998/04/15 16:40:13 keil
64 * Add S0Box and Teles PCI support
65 * Fix cardnr overwrite bug
67 * Revision 2.21 1998/04/10 10:35:28 paul
68 * fixed (silly?) warnings from egcs on Alpha.
70 * Revision 2.20 1998/03/09 23:19:27 keil
73 * Revision 2.18 1998/02/12 23:07:42 keil
74 * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
76 * Revision 2.17 1998/02/11 17:28:07 keil
77 * Niccy PnP/PCI support
79 * Revision 2.16 1998/02/09 18:46:08 keil
80 * Support for Sedlbauer PCMCIA (Marcus Niemann)
82 * Revision 2.15 1998/02/09 10:54:51 keil
83 * fixes for leased mode
85 * Revision 2.14 1998/02/03 23:31:31 keil
88 * Revision 2.13 1998/02/02 13:33:02 keil
91 * Revision 2.12 1998/01/31 21:41:48 keil
92 * changes for newer 2.1 kernels
94 * Revision 2.11 1997/11/12 15:01:23 keil
97 * Revision 2.10 1997/11/08 21:35:48 keil
100 * Revision 2.9 1997/11/06 17:09:18 keil
103 * Revision 2.8 1997/10/29 19:00:05 keil
104 * new layer1,changes for 2.1
106 * Revision 2.7 1997/10/10 20:56:50 fritz
109 * Revision 2.6 1997/09/12 10:05:16 keil
110 * ISDN_CTRL_DEBUG define
112 * Revision 2.5 1997/09/11 17:24:45 keil
115 * Revision 2.4 1997/08/15 17:47:09 keil
116 * avoid oops because a uninitialised timer
118 * Revision 2.3 1997/08/01 11:16:40 keil
121 * Revision 2.2 1997/07/30 17:11:08 keil
122 * L1deactivated exported
124 * Revision 2.1 1997/07/27 21:35:38 keil
125 * new layer1 interface
127 * Revision 2.0 1997/06/26 11:02:53 keil
128 * New Layer and card interface
130 * Revision 1.15 1997/05/27 15:17:55 fritz
131 * Added changes for recent 2.1.x kernels:
132 * changed return type of isdn_close
133 * queue_task_* -> queue_task
134 * clear/set_bit -> test_and_... where apropriate.
135 * changed type of hard_header_cache parameter.
137 * old changes removed KKe
141 const char *l1_revision
= "$Revision: 2.36 $";
143 #define __NO_VERSION__
147 #define TIMER3_VALUE 7000
151 {NULL
, 0, 0, NULL
, NULL
};
155 {NULL
, 0, 0, NULL
, NULL
};
167 #define L1D_STATE_COUNT (ST_L1_F8+1)
169 static char *strL1DState
[] =
187 #define L1B_STATE_COUNT (ST_L1_ACTIV+1)
189 static char *strL1BState
[] =
212 #define L1_EVENT_COUNT (EV_TIMER3 + 1)
214 static char *strL1Event
[] =
231 debugl1(struct IsdnCardState
*cs
, char *fmt
, ...)
237 sprintf(tmp
, "Card%d ", cs
->cardnr
+ 1);
238 VHiSax_putstatus(cs
, tmp
, fmt
, args
);
243 l1m_debug(struct FsmInst
*fi
, char *fmt
, ...)
246 struct PStack
*st
= fi
->userdata
;
247 struct IsdnCardState
*cs
= st
->l1
.hardware
;
251 sprintf(tmp
, "Card%d ", cs
->cardnr
+ 1);
252 VHiSax_putstatus(cs
, tmp
, fmt
, args
);
257 L1activated(struct IsdnCardState
*cs
)
263 if (test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
264 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
266 st
->l1
.l1l2(st
, PH_ACTIVATE
| INDICATION
, NULL
);
272 L1deactivated(struct IsdnCardState
*cs
)
278 if (test_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
279 st
->l1
.l1l2(st
, PH_PAUSE
| CONFIRM
, NULL
);
280 st
->l1
.l1l2(st
, PH_DEACTIVATE
| INDICATION
, NULL
);
283 test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
287 DChannel_proc_xmt(struct IsdnCardState
*cs
)
289 struct PStack
*stptr
;
295 while (stptr
!= NULL
)
296 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &stptr
->l1
.Flags
)) {
297 stptr
->l1
.l1l2(stptr
, PH_PULL
| CONFIRM
, NULL
);
304 DChannel_proc_rcv(struct IsdnCardState
*cs
)
306 struct sk_buff
*skb
, *nskb
;
307 struct PStack
*stptr
= cs
->stlist
;
308 int found
, tei
, sapi
;
311 if (test_bit(FLG_L1_ACTTIMER
, &stptr
->l1
.Flags
))
312 FsmEvent(&stptr
->l1
.l1m
, EV_TIMER_ACT
, NULL
);
313 while ((skb
= skb_dequeue(&cs
->rq
))) {
314 #ifdef L2FRAME_DEBUG /* psa */
315 if (cs
->debug
& L1_DEB_LAPD
)
316 Logl2Frame(cs
, skb
, "PH_DATA", 1);
320 debugl1(cs
, "D-channel frame too short(%d)",skb
->len
);
321 idev_kfree_skb(skb
, FREE_READ
);
324 if ((skb
->data
[0] & 1) || !(skb
->data
[1] &1)) {
325 debugl1(cs
, "D-channel frame wrong EA0/EA1");
326 idev_kfree_skb(skb
, FREE_READ
);
329 sapi
= skb
->data
[0] >> 2;
330 tei
= skb
->data
[1] >> 1;
331 if (cs
->debug
& DEB_DLOG_HEX
)
332 LogFrame(cs
, skb
->data
, skb
->len
);
333 if (cs
->debug
& DEB_DLOG_VERBOSE
)
334 dlogframe(cs
, skb
, 1);
335 if (tei
== GROUP_TEI
) {
336 if (sapi
== CTRL_SAPI
) { /* sapi 0 */
337 while (stptr
!= NULL
) {
338 if ((nskb
= skb_clone(skb
, GFP_ATOMIC
)))
339 stptr
->l1
.l1l2(stptr
, PH_DATA
| INDICATION
, nskb
);
341 printk(KERN_WARNING
"HiSax: isdn broadcast buffer shortage\n");
344 } else if (sapi
== TEI_SAPI
) {
345 while (stptr
!= NULL
) {
346 if ((nskb
= skb_clone(skb
, GFP_ATOMIC
)))
347 stptr
->l1
.l1tei(stptr
, PH_DATA
| INDICATION
, nskb
);
349 printk(KERN_WARNING
"HiSax: tei broadcast buffer shortage\n");
353 idev_kfree_skb(skb
, FREE_READ
);
354 } else if (sapi
== CTRL_SAPI
) { /* sapi 0 */
356 while (stptr
!= NULL
)
357 if (tei
== stptr
->l2
.tei
) {
358 stptr
->l1
.l1l2(stptr
, PH_DATA
| INDICATION
, skb
);
364 idev_kfree_skb(skb
, FREE_READ
);
370 BChannel_proc_xmt(struct BCState
*bcs
)
372 struct PStack
*st
= bcs
->st
;
374 if (test_bit(BC_FLG_BUSY
, &bcs
->Flag
)) {
375 debugl1(bcs
->cs
, "BC_BUSY Error");
379 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
))
380 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
381 if (!test_bit(BC_FLG_ACTIV
, &bcs
->Flag
)) {
382 if (!test_bit(BC_FLG_BUSY
, &bcs
->Flag
) && (!skb_queue_len(&bcs
->squeue
))) {
383 st
->l2
.l2l1(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
389 BChannel_proc_rcv(struct BCState
*bcs
)
393 if (bcs
->st
->l1
.l1m
.state
== ST_L1_WAIT_ACT
) {
394 FsmDelTimer(&bcs
->st
->l1
.timer
, 4);
395 FsmEvent(&bcs
->st
->l1
.l1m
, EV_TIMER_ACT
, NULL
);
397 while ((skb
= skb_dequeue(&bcs
->rqueue
))) {
398 bcs
->st
->l1
.l1l2(bcs
->st
, PH_DATA
| INDICATION
, skb
);
403 BChannel_bh(struct BCState
*bcs
)
407 if (test_and_clear_bit(B_RCVBUFREADY
, &bcs
->event
))
408 BChannel_proc_rcv(bcs
);
409 if (test_and_clear_bit(B_XMTBUFREADY
, &bcs
->event
))
410 BChannel_proc_xmt(bcs
);
414 HiSax_addlist(struct IsdnCardState
*cs
,
417 st
->next
= cs
->stlist
;
422 HiSax_rmlist(struct IsdnCardState
*cs
,
427 FsmDelTimer(&st
->l1
.timer
, 0);
428 if (cs
->stlist
== st
)
429 cs
->stlist
= st
->next
;
442 init_bcstate(struct IsdnCardState
*cs
,
445 struct BCState
*bcs
= cs
->bcs
+ bc
;
449 bcs
->tqueue
.next
= 0;
450 bcs
->tqueue
.sync
= 0;
451 bcs
->tqueue
.routine
= (void *) (void *) BChannel_bh
;
452 bcs
->tqueue
.data
= bcs
;
453 bcs
->BC_SetStack
= NULL
;
454 bcs
->BC_Close
= NULL
;
458 #ifdef L2FRAME_DEBUG /* psa */
463 switch (cmd
& ~0x10) {
488 return "invalid command";
492 static char tmpdeb
[32];
495 l2frames(u_char
* ptr
)
497 switch (ptr
[2] & ~0x10) {
501 sprintf(tmpdeb
, "%s[%d](nr %d)", l2cmd(ptr
[2]), ptr
[3] & 1, ptr
[3] >> 1);
510 sprintf(tmpdeb
, "%s[%d]", l2cmd(ptr
[2]), (ptr
[2] & 0x10) >> 4);
514 sprintf(tmpdeb
, "I[%d](ns %d, nr %d)", ptr
[3] & 1, ptr
[2] >> 1, ptr
[3] >> 1);
517 return "invalid command";
525 Logl2Frame(struct IsdnCardState
*cs
, struct sk_buff
*skb
, char *buf
, int dir
)
531 if (ptr
[0] & 1 || !(ptr
[1] & 1))
532 debugl1(cs
, "Address not LAPD");
534 debugl1(cs
, "%s %s: %s%c (sapi %d, tei %d)",
535 (dir
? "<-" : "->"), buf
, l2frames(ptr
),
536 ((ptr
[0] & 2) >> 1) == dir
? 'C' : 'R', ptr
[0] >> 2, ptr
[1] >> 1);
541 l1_reset(struct FsmInst
*fi
, int event
, void *arg
)
543 FsmChangeState(fi
, ST_L1_F3
);
547 l1_deact_cnf(struct FsmInst
*fi
, int event
, void *arg
)
549 struct PStack
*st
= fi
->userdata
;
551 FsmChangeState(fi
, ST_L1_F3
);
552 if (test_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
553 st
->l1
.l1hw(st
, HW_ENABLE
| REQUEST
, NULL
);
557 l1_deact_req(struct FsmInst
*fi
, int event
, void *arg
)
559 struct PStack
*st
= fi
->userdata
;
561 FsmChangeState(fi
, ST_L1_F3
);
562 // if (!test_bit(FLG_L1_T3RUN, &st->l1.Flags)) {
563 FsmDelTimer(&st
->l1
.timer
, 1);
564 FsmAddTimer(&st
->l1
.timer
, 550, EV_TIMER_DEACT
, NULL
, 2);
565 test_and_set_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
);
570 l1_power_up(struct FsmInst
*fi
, int event
, void *arg
)
572 struct PStack
*st
= fi
->userdata
;
574 if (test_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
)) {
575 FsmChangeState(fi
, ST_L1_F4
);
576 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
577 FsmDelTimer(&st
->l1
.timer
, 1);
578 FsmAddTimer(&st
->l1
.timer
, TIMER3_VALUE
, EV_TIMER3
, NULL
, 2);
579 test_and_set_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
);
581 FsmChangeState(fi
, ST_L1_F3
);
585 l1_go_F5(struct FsmInst
*fi
, int event
, void *arg
)
587 FsmChangeState(fi
, ST_L1_F5
);
591 l1_go_F8(struct FsmInst
*fi
, int event
, void *arg
)
593 FsmChangeState(fi
, ST_L1_F8
);
597 l1_info2_ind(struct FsmInst
*fi
, int event
, void *arg
)
599 struct PStack
*st
= fi
->userdata
;
601 FsmChangeState(fi
, ST_L1_F6
);
602 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
606 l1_info4_ind(struct FsmInst
*fi
, int event
, void *arg
)
608 struct PStack
*st
= fi
->userdata
;
610 FsmChangeState(fi
, ST_L1_F7
);
611 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
612 if (test_and_clear_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
))
613 FsmDelTimer(&st
->l1
.timer
, 4);
614 if (!test_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
)) {
615 if (test_and_clear_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
))
616 FsmDelTimer(&st
->l1
.timer
, 3);
617 FsmAddTimer(&st
->l1
.timer
, 110, EV_TIMER_ACT
, NULL
, 2);
618 test_and_set_bit(FLG_L1_ACTTIMER
, &st
->l1
.Flags
);
623 l1_timer3(struct FsmInst
*fi
, int event
, void *arg
)
625 struct PStack
*st
= fi
->userdata
;
627 test_and_clear_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
);
628 if (test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
629 L1deactivated(st
->l1
.hardware
);
630 if (st
->l1
.l1m
.state
!= ST_L1_F6
) {
631 FsmChangeState(fi
, ST_L1_F3
);
632 st
->l1
.l1hw(st
, HW_ENABLE
| REQUEST
, NULL
);
637 l1_timer_act(struct FsmInst
*fi
, int event
, void *arg
)
639 struct PStack
*st
= fi
->userdata
;
641 test_and_clear_bit(FLG_L1_ACTTIMER
, &st
->l1
.Flags
);
642 test_and_set_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
);
643 L1activated(st
->l1
.hardware
);
647 l1_timer_deact(struct FsmInst
*fi
, int event
, void *arg
)
649 struct PStack
*st
= fi
->userdata
;
651 test_and_clear_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
);
652 test_and_clear_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
);
653 L1deactivated(st
->l1
.hardware
);
654 st
->l1
.l1hw(st
, HW_DEACTIVATE
| RESPONSE
, NULL
);
658 l1_activate(struct FsmInst
*fi
, int event
, void *arg
)
660 struct PStack
*st
= fi
->userdata
;
662 st
->l1
.l1hw(st
, HW_RESET
| REQUEST
, NULL
);
666 l1_activate_no(struct FsmInst
*fi
, int event
, void *arg
)
668 struct PStack
*st
= fi
->userdata
;
670 if ((!test_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
)) && (!test_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
))) {
671 test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
);
672 L1deactivated(st
->l1
.hardware
);
676 static struct FsmNode L1DFnList
[] HISAX_INITDATA
=
678 {ST_L1_F3
, EV_PH_ACTIVATE
, l1_activate
},
679 {ST_L1_F6
, EV_PH_ACTIVATE
, l1_activate_no
},
680 {ST_L1_F8
, EV_PH_ACTIVATE
, l1_activate_no
},
681 {ST_L1_F3
, EV_RESET_IND
, l1_reset
},
682 {ST_L1_F4
, EV_RESET_IND
, l1_reset
},
683 {ST_L1_F5
, EV_RESET_IND
, l1_reset
},
684 {ST_L1_F6
, EV_RESET_IND
, l1_reset
},
685 {ST_L1_F7
, EV_RESET_IND
, l1_reset
},
686 {ST_L1_F8
, EV_RESET_IND
, l1_reset
},
687 {ST_L1_F3
, EV_DEACT_CNF
, l1_deact_cnf
},
688 {ST_L1_F4
, EV_DEACT_CNF
, l1_deact_cnf
},
689 {ST_L1_F5
, EV_DEACT_CNF
, l1_deact_cnf
},
690 {ST_L1_F6
, EV_DEACT_CNF
, l1_deact_cnf
},
691 {ST_L1_F7
, EV_DEACT_CNF
, l1_deact_cnf
},
692 {ST_L1_F8
, EV_DEACT_CNF
, l1_deact_cnf
},
693 {ST_L1_F6
, EV_DEACT_IND
, l1_deact_req
},
694 {ST_L1_F7
, EV_DEACT_IND
, l1_deact_req
},
695 {ST_L1_F8
, EV_DEACT_IND
, l1_deact_req
},
696 {ST_L1_F3
, EV_POWER_UP
, l1_power_up
},
697 {ST_L1_F4
, EV_RSYNC_IND
, l1_go_F5
},
698 {ST_L1_F6
, EV_RSYNC_IND
, l1_go_F8
},
699 {ST_L1_F7
, EV_RSYNC_IND
, l1_go_F8
},
700 {ST_L1_F3
, EV_INFO2_IND
, l1_info2_ind
},
701 {ST_L1_F4
, EV_INFO2_IND
, l1_info2_ind
},
702 {ST_L1_F5
, EV_INFO2_IND
, l1_info2_ind
},
703 {ST_L1_F7
, EV_INFO2_IND
, l1_info2_ind
},
704 {ST_L1_F8
, EV_INFO2_IND
, l1_info2_ind
},
705 {ST_L1_F3
, EV_INFO4_IND
, l1_info4_ind
},
706 {ST_L1_F4
, EV_INFO4_IND
, l1_info4_ind
},
707 {ST_L1_F5
, EV_INFO4_IND
, l1_info4_ind
},
708 {ST_L1_F6
, EV_INFO4_IND
, l1_info4_ind
},
709 {ST_L1_F8
, EV_INFO4_IND
, l1_info4_ind
},
710 {ST_L1_F3
, EV_TIMER3
, l1_timer3
},
711 {ST_L1_F4
, EV_TIMER3
, l1_timer3
},
712 {ST_L1_F5
, EV_TIMER3
, l1_timer3
},
713 {ST_L1_F6
, EV_TIMER3
, l1_timer3
},
714 {ST_L1_F8
, EV_TIMER3
, l1_timer3
},
715 {ST_L1_F7
, EV_TIMER_ACT
, l1_timer_act
},
716 {ST_L1_F3
, EV_TIMER_DEACT
, l1_timer_deact
},
717 {ST_L1_F4
, EV_TIMER_DEACT
, l1_timer_deact
},
718 {ST_L1_F5
, EV_TIMER_DEACT
, l1_timer_deact
},
719 {ST_L1_F6
, EV_TIMER_DEACT
, l1_timer_deact
},
720 {ST_L1_F7
, EV_TIMER_DEACT
, l1_timer_deact
},
721 {ST_L1_F8
, EV_TIMER_DEACT
, l1_timer_deact
},
724 #define L1D_FN_COUNT (sizeof(L1DFnList)/sizeof(struct FsmNode))
727 l1b_activate(struct FsmInst
*fi
, int event
, void *arg
)
729 struct PStack
*st
= fi
->userdata
;
731 FsmChangeState(fi
, ST_L1_WAIT_ACT
);
732 FsmAddTimer(&st
->l1
.timer
, st
->l1
.delay
, EV_TIMER_ACT
, NULL
, 2);
736 l1b_deactivate(struct FsmInst
*fi
, int event
, void *arg
)
738 struct PStack
*st
= fi
->userdata
;
740 FsmChangeState(fi
, ST_L1_WAIT_DEACT
);
741 FsmAddTimer(&st
->l1
.timer
, 10, EV_TIMER_DEACT
, NULL
, 2);
745 l1b_timer_act(struct FsmInst
*fi
, int event
, void *arg
)
747 struct PStack
*st
= fi
->userdata
;
749 FsmChangeState(fi
, ST_L1_ACTIV
);
750 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
754 l1b_timer_deact(struct FsmInst
*fi
, int event
, void *arg
)
756 struct PStack
*st
= fi
->userdata
;
758 FsmChangeState(fi
, ST_L1_NULL
);
759 st
->l2
.l2l1(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
762 static struct FsmNode L1BFnList
[] HISAX_INITDATA
=
764 {ST_L1_NULL
, EV_PH_ACTIVATE
, l1b_activate
},
765 {ST_L1_WAIT_ACT
, EV_TIMER_ACT
, l1b_timer_act
},
766 {ST_L1_ACTIV
, EV_PH_DEACTIVATE
, l1b_deactivate
},
767 {ST_L1_WAIT_DEACT
, EV_TIMER_DEACT
, l1b_timer_deact
},
770 #define L1B_FN_COUNT (sizeof(L1BFnList)/sizeof(struct FsmNode))
772 HISAX_INITFUNC(void Isdnl1New(void))
774 l1fsm_d
.state_count
= L1D_STATE_COUNT
;
775 l1fsm_d
.event_count
= L1_EVENT_COUNT
;
776 l1fsm_d
.strEvent
= strL1Event
;
777 l1fsm_d
.strState
= strL1DState
;
778 FsmNew(&l1fsm_d
, L1DFnList
, L1D_FN_COUNT
);
779 l1fsm_b
.state_count
= L1B_STATE_COUNT
;
780 l1fsm_b
.event_count
= L1_EVENT_COUNT
;
781 l1fsm_b
.strEvent
= strL1Event
;
782 l1fsm_b
.strState
= strL1BState
;
783 FsmNew(&l1fsm_b
, L1BFnList
, L1B_FN_COUNT
);
786 void Isdnl1Free(void)
793 dch_l2l1(struct PStack
*st
, int pr
, void *arg
)
795 struct IsdnCardState
*cs
= (struct IsdnCardState
*) st
->l1
.hardware
;
798 case (PH_DATA
| REQUEST
):
799 case (PH_PULL
| REQUEST
):
800 case (PH_PULL
|INDICATION
):
801 st
->l1
.l1hw(st
, pr
, arg
);
803 case (PH_ACTIVATE
| REQUEST
):
805 debugl1(cs
, "PH_ACTIVATE_REQ %s",
806 strL1DState
[st
->l1
.l1m
.state
]);
807 if (test_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
))
808 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
810 test_and_set_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
);
811 FsmEvent(&st
->l1
.l1m
, EV_PH_ACTIVATE
, arg
);
814 case (PH_TESTLOOP
| REQUEST
):
816 debugl1(cs
, "PH_TEST_LOOP B1");
818 debugl1(cs
, "PH_TEST_LOOP B2");
819 if (!(3 & (long) arg
))
820 debugl1(cs
, "PH_TEST_LOOP DISABLED");
821 st
->l1
.l1hw(st
, HW_TESTLOOP
| REQUEST
, arg
);
825 debugl1(cs
, "dch_l2l1 msg %04X unhandled", pr
);
831 l1_msg(struct IsdnCardState
*cs
, int pr
, void *arg
) {
838 case (HW_RESET
| INDICATION
):
839 FsmEvent(&st
->l1
.l1m
, EV_RESET_IND
, arg
);
841 case (HW_DEACTIVATE
| CONFIRM
):
842 FsmEvent(&st
->l1
.l1m
, EV_DEACT_CNF
, arg
);
844 case (HW_DEACTIVATE
| INDICATION
):
845 FsmEvent(&st
->l1
.l1m
, EV_DEACT_IND
, arg
);
847 case (HW_POWERUP
| CONFIRM
):
848 FsmEvent(&st
->l1
.l1m
, EV_POWER_UP
, arg
);
850 case (HW_RSYNC
| INDICATION
):
851 FsmEvent(&st
->l1
.l1m
, EV_RSYNC_IND
, arg
);
853 case (HW_INFO2
| INDICATION
):
854 FsmEvent(&st
->l1
.l1m
, EV_INFO2_IND
, arg
);
856 case (HW_INFO4_P8
| INDICATION
):
857 case (HW_INFO4_P10
| INDICATION
):
858 FsmEvent(&st
->l1
.l1m
, EV_INFO4_IND
, arg
);
862 debugl1(cs
, "l1msg %04X unhandled", pr
);
870 l1_msg_b(struct PStack
*st
, int pr
, void *arg
) {
872 case (PH_ACTIVATE
| REQUEST
):
873 FsmEvent(&st
->l1
.l1m
, EV_PH_ACTIVATE
, NULL
);
875 case (PH_DEACTIVATE
| REQUEST
):
876 FsmEvent(&st
->l1
.l1m
, EV_PH_DEACTIVATE
, NULL
);
882 setstack_HiSax(struct PStack
*st
, struct IsdnCardState
*cs
)
884 st
->l1
.hardware
= cs
;
885 st
->protocol
= cs
->protocol
;
886 st
->l1
.l1m
.fsm
= &l1fsm_d
;
887 st
->l1
.l1m
.state
= ST_L1_F3
;
888 st
->l1
.l1m
.debug
= cs
->debug
;
889 st
->l1
.l1m
.userdata
= st
;
890 st
->l1
.l1m
.userint
= 0;
891 st
->l1
.l1m
.printdebug
= l1m_debug
;
892 FsmInitTimer(&st
->l1
.l1m
, &st
->l1
.timer
);
894 setstack_manager(st
);
895 st
->l1
.stlistp
= &(cs
->stlist
);
896 st
->l2
.l2l1
= dch_l2l1
;
898 cs
->setstack_d(st
, cs
);
902 setstack_l1_B(struct PStack
*st
)
904 struct IsdnCardState
*cs
= st
->l1
.hardware
;
906 st
->l1
.l1m
.fsm
= &l1fsm_b
;
907 st
->l1
.l1m
.state
= ST_L1_NULL
;
908 st
->l1
.l1m
.debug
= cs
->debug
;
909 st
->l1
.l1m
.userdata
= st
;
910 st
->l1
.l1m
.userint
= 0;
911 st
->l1
.l1m
.printdebug
= l1m_debug
;
913 FsmInitTimer(&st
->l1
.l1m
, &st
->l1
.timer
);