1 /* $Id: isdnl1.c,v 2.46.2.5 2004/02/11 13:21:34 keil Exp $
3 * common low level stuff for Siemens Chipsetbased isdn cards
6 * based on the teles driver from Jan den Ouden
7 * Copyright by Karsten Keil <keil@isdn4linux.de>
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
12 * For changes and modifications please read
13 * Documentation/isdn/HiSax.cert
15 * Thanks to Jan den Ouden
21 const char *l1_revision
= "$Revision: 2.46.2.5 $";
23 #include <linux/init.h>
27 #define TIMER3_VALUE 7000
29 static struct Fsm l1fsm_b
;
30 static struct Fsm l1fsm_s
;
42 #define L1S_STATE_COUNT (ST_L1_F8+1)
44 static char *strL1SState
[] =
55 #ifdef HISAX_UINTERFACE
58 {NULL
, 0, 0, NULL
, NULL
};
67 #define L1U_STATE_COUNT (ST_L1_TRANS+1)
69 static char *strL1UState
[] =
85 #define L1B_STATE_COUNT (ST_L1_ACTIV+1)
87 static char *strL1BState
[] =
110 #define L1_EVENT_COUNT (EV_TIMER3 + 1)
112 static char *strL1Event
[] =
129 debugl1(struct IsdnCardState
*cs
, char *fmt
, ...)
135 sprintf(tmp
, "Card%d ", cs
->cardnr
+ 1);
136 VHiSax_putstatus(cs
, tmp
, fmt
, args
);
141 l1m_debug(struct FsmInst
*fi
, char *fmt
, ...)
144 struct PStack
*st
= fi
->userdata
;
145 struct IsdnCardState
*cs
= st
->l1
.hardware
;
149 sprintf(tmp
, "Card%d ", cs
->cardnr
+ 1);
150 VHiSax_putstatus(cs
, tmp
, fmt
, args
);
155 L1activated(struct IsdnCardState
*cs
)
161 if (test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
162 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
164 st
->l1
.l1l2(st
, PH_ACTIVATE
| INDICATION
, NULL
);
170 L1deactivated(struct IsdnCardState
*cs
)
176 if (test_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
177 st
->l1
.l1l2(st
, PH_PAUSE
| CONFIRM
, NULL
);
178 st
->l1
.l1l2(st
, PH_DEACTIVATE
| INDICATION
, NULL
);
181 test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
185 DChannel_proc_xmt(struct IsdnCardState
*cs
)
187 struct PStack
*stptr
;
193 while (stptr
!= NULL
) {
194 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &stptr
->l1
.Flags
)) {
195 stptr
->l1
.l1l2(stptr
, PH_PULL
| CONFIRM
, NULL
);
203 DChannel_proc_rcv(struct IsdnCardState
*cs
)
205 struct sk_buff
*skb
, *nskb
;
206 struct PStack
*stptr
= cs
->stlist
;
207 int found
, tei
, sapi
;
210 if (test_bit(FLG_L1_ACTTIMER
, &stptr
->l1
.Flags
))
211 FsmEvent(&stptr
->l1
.l1m
, EV_TIMER_ACT
, NULL
);
212 while ((skb
= skb_dequeue(&cs
->rq
))) {
213 #ifdef L2FRAME_DEBUG /* psa */
214 if (cs
->debug
& L1_DEB_LAPD
)
215 Logl2Frame(cs
, skb
, "PH_DATA", 1);
219 debugl1(cs
, "D-channel frame too short(%d)",skb
->len
);
223 if ((skb
->data
[0] & 1) || !(skb
->data
[1] &1)) {
224 debugl1(cs
, "D-channel frame wrong EA0/EA1");
228 sapi
= skb
->data
[0] >> 2;
229 tei
= skb
->data
[1] >> 1;
230 if (cs
->debug
& DEB_DLOG_HEX
)
231 LogFrame(cs
, skb
->data
, skb
->len
);
232 if (cs
->debug
& DEB_DLOG_VERBOSE
)
233 dlogframe(cs
, skb
, 1);
234 if (tei
== GROUP_TEI
) {
235 if (sapi
== CTRL_SAPI
) { /* sapi 0 */
236 while (stptr
!= NULL
) {
237 if ((nskb
= skb_clone(skb
, GFP_ATOMIC
)))
238 stptr
->l1
.l1l2(stptr
, PH_DATA
| INDICATION
, nskb
);
240 printk(KERN_WARNING
"HiSax: isdn broadcast buffer shortage\n");
243 } else if (sapi
== TEI_SAPI
) {
244 while (stptr
!= NULL
) {
245 if ((nskb
= skb_clone(skb
, GFP_ATOMIC
)))
246 stptr
->l1
.l1tei(stptr
, PH_DATA
| INDICATION
, nskb
);
248 printk(KERN_WARNING
"HiSax: tei broadcast buffer shortage\n");
253 } else if (sapi
== CTRL_SAPI
) { /* sapi 0 */
255 while (stptr
!= NULL
)
256 if (tei
== stptr
->l2
.tei
) {
257 stptr
->l1
.l1l2(stptr
, PH_DATA
| INDICATION
, skb
);
270 BChannel_proc_xmt(struct BCState
*bcs
)
272 struct PStack
*st
= bcs
->st
;
274 if (test_bit(BC_FLG_BUSY
, &bcs
->Flag
)) {
275 debugl1(bcs
->cs
, "BC_BUSY Error");
279 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
))
280 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
281 if (!test_bit(BC_FLG_ACTIV
, &bcs
->Flag
)) {
282 if (!test_bit(BC_FLG_BUSY
, &bcs
->Flag
) &&
283 skb_queue_empty(&bcs
->squeue
)) {
284 st
->l2
.l2l1(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
290 BChannel_proc_rcv(struct BCState
*bcs
)
294 if (bcs
->st
->l1
.l1m
.state
== ST_L1_WAIT_ACT
) {
295 FsmDelTimer(&bcs
->st
->l1
.timer
, 4);
296 FsmEvent(&bcs
->st
->l1
.l1m
, EV_TIMER_ACT
, NULL
);
298 while ((skb
= skb_dequeue(&bcs
->rqueue
))) {
299 bcs
->st
->l1
.l1l2(bcs
->st
, PH_DATA
| INDICATION
, skb
);
304 BChannel_proc_ack(struct BCState
*bcs
)
309 spin_lock_irqsave(&bcs
->aclock
, flags
);
312 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
314 lli_writewakeup(bcs
->st
, ack
);
318 BChannel_bh(struct BCState
*bcs
)
322 if (test_and_clear_bit(B_RCVBUFREADY
, &bcs
->event
))
323 BChannel_proc_rcv(bcs
);
324 if (test_and_clear_bit(B_XMTBUFREADY
, &bcs
->event
))
325 BChannel_proc_xmt(bcs
);
326 if (test_and_clear_bit(B_ACKPENDING
, &bcs
->event
))
327 BChannel_proc_ack(bcs
);
331 HiSax_addlist(struct IsdnCardState
*cs
,
334 st
->next
= cs
->stlist
;
339 HiSax_rmlist(struct IsdnCardState
*cs
,
344 FsmDelTimer(&st
->l1
.timer
, 0);
345 if (cs
->stlist
== st
)
346 cs
->stlist
= st
->next
;
359 init_bcstate(struct IsdnCardState
*cs
, int bc
)
361 struct BCState
*bcs
= cs
->bcs
+ bc
;
365 INIT_WORK(&bcs
->tqueue
, (void *)(void *) BChannel_bh
, bcs
);
366 spin_lock_init(&bcs
->aclock
);
367 bcs
->BC_SetStack
= NULL
;
368 bcs
->BC_Close
= NULL
;
372 #ifdef L2FRAME_DEBUG /* psa */
377 switch (cmd
& ~0x10) {
402 return "invalid command";
406 static char tmpdeb
[32];
409 l2frames(u_char
* ptr
)
411 switch (ptr
[2] & ~0x10) {
415 sprintf(tmpdeb
, "%s[%d](nr %d)", l2cmd(ptr
[2]), ptr
[3] & 1, ptr
[3] >> 1);
424 sprintf(tmpdeb
, "%s[%d]", l2cmd(ptr
[2]), (ptr
[2] & 0x10) >> 4);
428 sprintf(tmpdeb
, "I[%d](ns %d, nr %d)", ptr
[3] & 1, ptr
[2] >> 1, ptr
[3] >> 1);
431 return "invalid command";
439 Logl2Frame(struct IsdnCardState
*cs
, struct sk_buff
*skb
, char *buf
, int dir
)
445 if (ptr
[0] & 1 || !(ptr
[1] & 1))
446 debugl1(cs
, "Address not LAPD");
448 debugl1(cs
, "%s %s: %s%c (sapi %d, tei %d)",
449 (dir
? "<-" : "->"), buf
, l2frames(ptr
),
450 ((ptr
[0] & 2) >> 1) == dir
? 'C' : 'R', ptr
[0] >> 2, ptr
[1] >> 1);
455 l1_reset(struct FsmInst
*fi
, int event
, void *arg
)
457 FsmChangeState(fi
, ST_L1_F3
);
461 l1_deact_cnf(struct FsmInst
*fi
, int event
, void *arg
)
463 struct PStack
*st
= fi
->userdata
;
465 FsmChangeState(fi
, ST_L1_F3
);
466 if (test_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
467 st
->l1
.l1hw(st
, HW_ENABLE
| REQUEST
, NULL
);
471 l1_deact_req_s(struct FsmInst
*fi
, int event
, void *arg
)
473 struct PStack
*st
= fi
->userdata
;
475 FsmChangeState(fi
, ST_L1_F3
);
476 FsmRestartTimer(&st
->l1
.timer
, 550, EV_TIMER_DEACT
, NULL
, 2);
477 test_and_set_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
);
481 l1_power_up_s(struct FsmInst
*fi
, int event
, void *arg
)
483 struct PStack
*st
= fi
->userdata
;
485 if (test_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
)) {
486 FsmChangeState(fi
, ST_L1_F4
);
487 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
488 FsmRestartTimer(&st
->l1
.timer
, TIMER3_VALUE
, EV_TIMER3
, NULL
, 2);
489 test_and_set_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
);
491 FsmChangeState(fi
, ST_L1_F3
);
495 l1_go_F5(struct FsmInst
*fi
, int event
, void *arg
)
497 FsmChangeState(fi
, ST_L1_F5
);
501 l1_go_F8(struct FsmInst
*fi
, int event
, void *arg
)
503 FsmChangeState(fi
, ST_L1_F8
);
507 l1_info2_ind(struct FsmInst
*fi
, int event
, void *arg
)
509 struct PStack
*st
= fi
->userdata
;
511 #ifdef HISAX_UINTERFACE
512 if (test_bit(FLG_L1_UINT
, &st
->l1
.Flags
))
513 FsmChangeState(fi
, ST_L1_SYNC2
);
516 FsmChangeState(fi
, ST_L1_F6
);
517 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
521 l1_info4_ind(struct FsmInst
*fi
, int event
, void *arg
)
523 struct PStack
*st
= fi
->userdata
;
525 #ifdef HISAX_UINTERFACE
526 if (test_bit(FLG_L1_UINT
, &st
->l1
.Flags
))
527 FsmChangeState(fi
, ST_L1_TRANS
);
530 FsmChangeState(fi
, ST_L1_F7
);
531 st
->l1
.l1hw(st
, HW_INFO3
| REQUEST
, NULL
);
532 if (test_and_clear_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
))
533 FsmDelTimer(&st
->l1
.timer
, 4);
534 if (!test_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
)) {
535 if (test_and_clear_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
))
536 FsmDelTimer(&st
->l1
.timer
, 3);
537 FsmRestartTimer(&st
->l1
.timer
, 110, EV_TIMER_ACT
, NULL
, 2);
538 test_and_set_bit(FLG_L1_ACTTIMER
, &st
->l1
.Flags
);
543 l1_timer3(struct FsmInst
*fi
, int event
, void *arg
)
545 struct PStack
*st
= fi
->userdata
;
547 test_and_clear_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
);
548 if (test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
))
549 L1deactivated(st
->l1
.hardware
);
551 #ifdef HISAX_UINTERFACE
552 if (!test_bit(FLG_L1_UINT
, &st
->l1
.Flags
))
554 if (st
->l1
.l1m
.state
!= ST_L1_F6
) {
555 FsmChangeState(fi
, ST_L1_F3
);
556 st
->l1
.l1hw(st
, HW_ENABLE
| REQUEST
, NULL
);
561 l1_timer_act(struct FsmInst
*fi
, int event
, void *arg
)
563 struct PStack
*st
= fi
->userdata
;
565 test_and_clear_bit(FLG_L1_ACTTIMER
, &st
->l1
.Flags
);
566 test_and_set_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
);
567 L1activated(st
->l1
.hardware
);
571 l1_timer_deact(struct FsmInst
*fi
, int event
, void *arg
)
573 struct PStack
*st
= fi
->userdata
;
575 test_and_clear_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
);
576 test_and_clear_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
);
577 L1deactivated(st
->l1
.hardware
);
578 st
->l1
.l1hw(st
, HW_DEACTIVATE
| RESPONSE
, NULL
);
582 l1_activate_s(struct FsmInst
*fi
, int event
, void *arg
)
584 struct PStack
*st
= fi
->userdata
;
586 st
->l1
.l1hw(st
, HW_RESET
| REQUEST
, NULL
);
590 l1_activate_no(struct FsmInst
*fi
, int event
, void *arg
)
592 struct PStack
*st
= fi
->userdata
;
594 if ((!test_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
)) && (!test_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
))) {
595 test_and_clear_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
);
596 L1deactivated(st
->l1
.hardware
);
600 static struct FsmNode L1SFnList
[] __initdata
=
602 {ST_L1_F3
, EV_PH_ACTIVATE
, l1_activate_s
},
603 {ST_L1_F6
, EV_PH_ACTIVATE
, l1_activate_no
},
604 {ST_L1_F8
, EV_PH_ACTIVATE
, l1_activate_no
},
605 {ST_L1_F3
, EV_RESET_IND
, l1_reset
},
606 {ST_L1_F4
, EV_RESET_IND
, l1_reset
},
607 {ST_L1_F5
, EV_RESET_IND
, l1_reset
},
608 {ST_L1_F6
, EV_RESET_IND
, l1_reset
},
609 {ST_L1_F7
, EV_RESET_IND
, l1_reset
},
610 {ST_L1_F8
, EV_RESET_IND
, l1_reset
},
611 {ST_L1_F3
, EV_DEACT_CNF
, l1_deact_cnf
},
612 {ST_L1_F4
, EV_DEACT_CNF
, l1_deact_cnf
},
613 {ST_L1_F5
, EV_DEACT_CNF
, l1_deact_cnf
},
614 {ST_L1_F6
, EV_DEACT_CNF
, l1_deact_cnf
},
615 {ST_L1_F7
, EV_DEACT_CNF
, l1_deact_cnf
},
616 {ST_L1_F8
, EV_DEACT_CNF
, l1_deact_cnf
},
617 {ST_L1_F6
, EV_DEACT_IND
, l1_deact_req_s
},
618 {ST_L1_F7
, EV_DEACT_IND
, l1_deact_req_s
},
619 {ST_L1_F8
, EV_DEACT_IND
, l1_deact_req_s
},
620 {ST_L1_F3
, EV_POWER_UP
, l1_power_up_s
},
621 {ST_L1_F4
, EV_RSYNC_IND
, l1_go_F5
},
622 {ST_L1_F6
, EV_RSYNC_IND
, l1_go_F8
},
623 {ST_L1_F7
, EV_RSYNC_IND
, l1_go_F8
},
624 {ST_L1_F3
, EV_INFO2_IND
, l1_info2_ind
},
625 {ST_L1_F4
, EV_INFO2_IND
, l1_info2_ind
},
626 {ST_L1_F5
, EV_INFO2_IND
, l1_info2_ind
},
627 {ST_L1_F7
, EV_INFO2_IND
, l1_info2_ind
},
628 {ST_L1_F8
, EV_INFO2_IND
, l1_info2_ind
},
629 {ST_L1_F3
, EV_INFO4_IND
, l1_info4_ind
},
630 {ST_L1_F4
, EV_INFO4_IND
, l1_info4_ind
},
631 {ST_L1_F5
, EV_INFO4_IND
, l1_info4_ind
},
632 {ST_L1_F6
, EV_INFO4_IND
, l1_info4_ind
},
633 {ST_L1_F8
, EV_INFO4_IND
, l1_info4_ind
},
634 {ST_L1_F3
, EV_TIMER3
, l1_timer3
},
635 {ST_L1_F4
, EV_TIMER3
, l1_timer3
},
636 {ST_L1_F5
, EV_TIMER3
, l1_timer3
},
637 {ST_L1_F6
, EV_TIMER3
, l1_timer3
},
638 {ST_L1_F8
, EV_TIMER3
, l1_timer3
},
639 {ST_L1_F7
, EV_TIMER_ACT
, l1_timer_act
},
640 {ST_L1_F3
, EV_TIMER_DEACT
, l1_timer_deact
},
641 {ST_L1_F4
, EV_TIMER_DEACT
, l1_timer_deact
},
642 {ST_L1_F5
, EV_TIMER_DEACT
, l1_timer_deact
},
643 {ST_L1_F6
, EV_TIMER_DEACT
, l1_timer_deact
},
644 {ST_L1_F7
, EV_TIMER_DEACT
, l1_timer_deact
},
645 {ST_L1_F8
, EV_TIMER_DEACT
, l1_timer_deact
},
648 #define L1S_FN_COUNT (sizeof(L1SFnList)/sizeof(struct FsmNode))
650 #ifdef HISAX_UINTERFACE
652 l1_deact_req_u(struct FsmInst
*fi
, int event
, void *arg
)
654 struct PStack
*st
= fi
->userdata
;
656 FsmChangeState(fi
, ST_L1_RESET
);
657 FsmRestartTimer(&st
->l1
.timer
, 550, EV_TIMER_DEACT
, NULL
, 2);
658 test_and_set_bit(FLG_L1_DEACTTIMER
, &st
->l1
.Flags
);
659 st
->l1
.l1hw(st
, HW_ENABLE
| REQUEST
, NULL
);
663 l1_power_up_u(struct FsmInst
*fi
, int event
, void *arg
)
665 struct PStack
*st
= fi
->userdata
;
667 FsmRestartTimer(&st
->l1
.timer
, TIMER3_VALUE
, EV_TIMER3
, NULL
, 2);
668 test_and_set_bit(FLG_L1_T3RUN
, &st
->l1
.Flags
);
672 l1_info0_ind(struct FsmInst
*fi
, int event
, void *arg
)
674 FsmChangeState(fi
, ST_L1_DEACT
);
678 l1_activate_u(struct FsmInst
*fi
, int event
, void *arg
)
680 struct PStack
*st
= fi
->userdata
;
682 st
->l1
.l1hw(st
, HW_INFO1
| REQUEST
, NULL
);
685 static struct FsmNode L1UFnList
[] __initdata
=
687 {ST_L1_RESET
, EV_DEACT_IND
, l1_deact_req_u
},
688 {ST_L1_DEACT
, EV_DEACT_IND
, l1_deact_req_u
},
689 {ST_L1_SYNC2
, EV_DEACT_IND
, l1_deact_req_u
},
690 {ST_L1_TRANS
, EV_DEACT_IND
, l1_deact_req_u
},
691 {ST_L1_DEACT
, EV_PH_ACTIVATE
, l1_activate_u
},
692 {ST_L1_DEACT
, EV_POWER_UP
, l1_power_up_u
},
693 {ST_L1_DEACT
, EV_INFO2_IND
, l1_info2_ind
},
694 {ST_L1_TRANS
, EV_INFO2_IND
, l1_info2_ind
},
695 {ST_L1_RESET
, EV_DEACT_CNF
, l1_info0_ind
},
696 {ST_L1_DEACT
, EV_INFO4_IND
, l1_info4_ind
},
697 {ST_L1_SYNC2
, EV_INFO4_IND
, l1_info4_ind
},
698 {ST_L1_RESET
, EV_INFO4_IND
, l1_info4_ind
},
699 {ST_L1_DEACT
, EV_TIMER3
, l1_timer3
},
700 {ST_L1_SYNC2
, EV_TIMER3
, l1_timer3
},
701 {ST_L1_TRANS
, EV_TIMER_ACT
, l1_timer_act
},
702 {ST_L1_DEACT
, EV_TIMER_DEACT
, l1_timer_deact
},
703 {ST_L1_SYNC2
, EV_TIMER_DEACT
, l1_timer_deact
},
704 {ST_L1_RESET
, EV_TIMER_DEACT
, l1_timer_deact
},
707 #define L1U_FN_COUNT (sizeof(L1UFnList)/sizeof(struct FsmNode))
712 l1b_activate(struct FsmInst
*fi
, int event
, void *arg
)
714 struct PStack
*st
= fi
->userdata
;
716 FsmChangeState(fi
, ST_L1_WAIT_ACT
);
717 FsmRestartTimer(&st
->l1
.timer
, st
->l1
.delay
, EV_TIMER_ACT
, NULL
, 2);
721 l1b_deactivate(struct FsmInst
*fi
, int event
, void *arg
)
723 struct PStack
*st
= fi
->userdata
;
725 FsmChangeState(fi
, ST_L1_WAIT_DEACT
);
726 FsmRestartTimer(&st
->l1
.timer
, 10, EV_TIMER_DEACT
, NULL
, 2);
730 l1b_timer_act(struct FsmInst
*fi
, int event
, void *arg
)
732 struct PStack
*st
= fi
->userdata
;
734 FsmChangeState(fi
, ST_L1_ACTIV
);
735 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
739 l1b_timer_deact(struct FsmInst
*fi
, int event
, void *arg
)
741 struct PStack
*st
= fi
->userdata
;
743 FsmChangeState(fi
, ST_L1_NULL
);
744 st
->l2
.l2l1(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
747 static struct FsmNode L1BFnList
[] __initdata
=
749 {ST_L1_NULL
, EV_PH_ACTIVATE
, l1b_activate
},
750 {ST_L1_WAIT_ACT
, EV_TIMER_ACT
, l1b_timer_act
},
751 {ST_L1_ACTIV
, EV_PH_DEACTIVATE
, l1b_deactivate
},
752 {ST_L1_WAIT_DEACT
, EV_TIMER_DEACT
, l1b_timer_deact
},
755 #define L1B_FN_COUNT (sizeof(L1BFnList)/sizeof(struct FsmNode))
762 l1fsm_s
.state_count
= L1S_STATE_COUNT
;
763 l1fsm_s
.event_count
= L1_EVENT_COUNT
;
764 l1fsm_s
.strEvent
= strL1Event
;
765 l1fsm_s
.strState
= strL1SState
;
766 retval
= FsmNew(&l1fsm_s
, L1SFnList
, L1S_FN_COUNT
);
770 l1fsm_b
.state_count
= L1B_STATE_COUNT
;
771 l1fsm_b
.event_count
= L1_EVENT_COUNT
;
772 l1fsm_b
.strEvent
= strL1Event
;
773 l1fsm_b
.strState
= strL1BState
;
774 retval
= FsmNew(&l1fsm_b
, L1BFnList
, L1B_FN_COUNT
);
779 #ifdef HISAX_UINTERFACE
780 l1fsm_u
.state_count
= L1U_STATE_COUNT
;
781 l1fsm_u
.event_count
= L1_EVENT_COUNT
;
782 l1fsm_u
.strEvent
= strL1Event
;
783 l1fsm_u
.strState
= strL1UState
;
784 retval
= FsmNew(&l1fsm_u
, L1UFnList
, L1U_FN_COUNT
);
794 void Isdnl1Free(void)
796 #ifdef HISAX_UINTERFACE
804 dch_l2l1(struct PStack
*st
, int pr
, void *arg
)
806 struct IsdnCardState
*cs
= (struct IsdnCardState
*) st
->l1
.hardware
;
809 case (PH_DATA
| REQUEST
):
810 case (PH_PULL
| REQUEST
):
811 case (PH_PULL
|INDICATION
):
812 st
->l1
.l1hw(st
, pr
, arg
);
814 case (PH_ACTIVATE
| REQUEST
):
816 debugl1(cs
, "PH_ACTIVATE_REQ %s",
817 st
->l1
.l1m
.fsm
->strState
[st
->l1
.l1m
.state
]);
818 if (test_bit(FLG_L1_ACTIVATED
, &st
->l1
.Flags
))
819 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
821 test_and_set_bit(FLG_L1_ACTIVATING
, &st
->l1
.Flags
);
822 FsmEvent(&st
->l1
.l1m
, EV_PH_ACTIVATE
, arg
);
825 case (PH_TESTLOOP
| REQUEST
):
827 debugl1(cs
, "PH_TEST_LOOP B1");
829 debugl1(cs
, "PH_TEST_LOOP B2");
830 if (!(3 & (long) arg
))
831 debugl1(cs
, "PH_TEST_LOOP DISABLED");
832 st
->l1
.l1hw(st
, HW_TESTLOOP
| REQUEST
, arg
);
836 debugl1(cs
, "dch_l2l1 msg %04X unhandled", pr
);
842 l1_msg(struct IsdnCardState
*cs
, int pr
, void *arg
) {
849 case (HW_RESET
| INDICATION
):
850 FsmEvent(&st
->l1
.l1m
, EV_RESET_IND
, arg
);
852 case (HW_DEACTIVATE
| CONFIRM
):
853 FsmEvent(&st
->l1
.l1m
, EV_DEACT_CNF
, arg
);
855 case (HW_DEACTIVATE
| INDICATION
):
856 FsmEvent(&st
->l1
.l1m
, EV_DEACT_IND
, arg
);
858 case (HW_POWERUP
| CONFIRM
):
859 FsmEvent(&st
->l1
.l1m
, EV_POWER_UP
, arg
);
861 case (HW_RSYNC
| INDICATION
):
862 FsmEvent(&st
->l1
.l1m
, EV_RSYNC_IND
, arg
);
864 case (HW_INFO2
| INDICATION
):
865 FsmEvent(&st
->l1
.l1m
, EV_INFO2_IND
, arg
);
867 case (HW_INFO4_P8
| INDICATION
):
868 case (HW_INFO4_P10
| INDICATION
):
869 FsmEvent(&st
->l1
.l1m
, EV_INFO4_IND
, arg
);
873 debugl1(cs
, "l1msg %04X unhandled", pr
);
881 l1_msg_b(struct PStack
*st
, int pr
, void *arg
) {
883 case (PH_ACTIVATE
| REQUEST
):
884 FsmEvent(&st
->l1
.l1m
, EV_PH_ACTIVATE
, NULL
);
886 case (PH_DEACTIVATE
| REQUEST
):
887 FsmEvent(&st
->l1
.l1m
, EV_PH_DEACTIVATE
, NULL
);
893 setstack_HiSax(struct PStack
*st
, struct IsdnCardState
*cs
)
895 st
->l1
.hardware
= cs
;
896 st
->protocol
= cs
->protocol
;
897 st
->l1
.l1m
.fsm
= &l1fsm_s
;
898 st
->l1
.l1m
.state
= ST_L1_F3
;
900 #ifdef HISAX_UINTERFACE
901 if (test_bit(FLG_HW_L1_UINT
, &cs
->HW_Flags
)) {
902 st
->l1
.l1m
.fsm
= &l1fsm_u
;
903 st
->l1
.l1m
.state
= ST_L1_RESET
;
904 st
->l1
.Flags
= FLG_L1_UINT
;
907 st
->l1
.l1m
.debug
= cs
->debug
;
908 st
->l1
.l1m
.userdata
= st
;
909 st
->l1
.l1m
.userint
= 0;
910 st
->l1
.l1m
.printdebug
= l1m_debug
;
911 FsmInitTimer(&st
->l1
.l1m
, &st
->l1
.timer
);
913 setstack_manager(st
);
914 st
->l1
.stlistp
= &(cs
->stlist
);
915 st
->l2
.l2l1
= dch_l2l1
;
917 cs
->setstack_d(st
, cs
);
921 setstack_l1_B(struct PStack
*st
)
923 struct IsdnCardState
*cs
= st
->l1
.hardware
;
925 st
->l1
.l1m
.fsm
= &l1fsm_b
;
926 st
->l1
.l1m
.state
= ST_L1_NULL
;
927 st
->l1
.l1m
.debug
= cs
->debug
;
928 st
->l1
.l1m
.userdata
= st
;
929 st
->l1
.l1m
.userint
= 0;
930 st
->l1
.l1m
.printdebug
= l1m_debug
;
932 FsmInitTimer(&st
->l1
.l1m
, &st
->l1
.timer
);