patch-2.2.11 linux/drivers/isdn/hisax/arcofi.c
Next file: linux/drivers/isdn/hisax/arcofi.h
Previous file: linux/drivers/isdn/hisax/amd7930.c
Back to the patch index
Back to the overall index
- Lines: 180
- Date:
Mon Aug 9 12:04:39 1999
- Orig file:
v2.2.10/linux/drivers/isdn/hisax/arcofi.c
- Orig date:
Thu Nov 5 09:58:43 1998
diff -u --recursive --new-file v2.2.10/linux/drivers/isdn/hisax/arcofi.c linux/drivers/isdn/hisax/arcofi.c
@@ -1,12 +1,31 @@
-/* $Id: arcofi.c,v 1.1 1997/10/29 18:51:20 keil Exp $
+/* $Id: arcofi.c,v 1.7 1999/07/01 08:11:17 keil Exp $
- * arcofi.h Ansteuerung ARCOFI 2165
+ * arcofi.c Ansteuerung ARCOFI 2165
*
* Author Karsten Keil (keil@temic-ech.spacenet.de)
*
*
*
* $Log: arcofi.c,v $
+ * Revision 1.7 1999/07/01 08:11:17 keil
+ * Common HiSax version for 2.0, 2.1, 2.2 and 2.3 kernel
+ *
+ * Revision 1.6 1998/09/30 22:21:56 keil
+ * cosmetics
+ *
+ * Revision 1.5 1998/09/27 12:52:57 keil
+ * cosmetics
+ *
+ * Revision 1.4 1998/08/20 13:50:24 keil
+ * More support for hybrid modem (not working yet)
+ *
+ * Revision 1.3 1998/05/25 12:57:38 keil
+ * HiSax golden code from certification, Don't use !!!
+ * No leased lines, no X75, but many changes.
+ *
+ * Revision 1.2 1998/04/15 16:47:16 keil
+ * new interface
+ *
* Revision 1.1 1997/10/29 18:51:20 keil
* New files
*
@@ -16,35 +35,120 @@
#include "hisax.h"
#include "isdnl1.h"
#include "isac.h"
+#include "arcofi.h"
-int
-send_arcofi(struct IsdnCardState *cs, const u_char *msg) {
+#define ARCOFI_TIMER_VALUE 20
+
+static void
+add_arcofi_timer(struct IsdnCardState *cs) {
+ if (test_and_set_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {
+ del_timer(&cs->dc.isac.arcofitimer);
+ }
+ init_timer(&cs->dc.isac.arcofitimer);
+ cs->dc.isac.arcofitimer.expires = jiffies + ((ARCOFI_TIMER_VALUE * HZ)/1000);
+ add_timer(&cs->dc.isac.arcofitimer);
+}
+
+static void
+send_arcofi(struct IsdnCardState *cs) {
u_char val;
- char tmp[32];
- long flags;
- int cnt=2;
- cs->mon_txp = 0;
- cs->mon_txc = msg[0];
- memcpy(cs->mon_tx, &msg[1], cs->mon_txc);
- cs->mocr &= 0x0f;
- cs->mocr |= 0xa0;
- test_and_clear_bit(HW_MON1_TX_END, &cs->HW_Flags);
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ add_arcofi_timer(cs);
+ cs->dc.isac.mon_txp = 0;
+ cs->dc.isac.mon_txc = cs->dc.isac.arcofi_list->len;
+ memcpy(cs->dc.isac.mon_tx, cs->dc.isac.arcofi_list->msg, cs->dc.isac.mon_txc);
+ switch(cs->dc.isac.arcofi_bc) {
+ case 0: break;
+ case 1: cs->dc.isac.mon_tx[1] |= 0x40;
+ break;
+ default: break;
+ }
+ cs->dc.isac.mocr &= 0x0f;
+ cs->dc.isac.mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
val = cs->readisac(cs, ISAC_MOSR);
- cs->writeisac(cs, ISAC_MOX1, cs->mon_tx[cs->mon_txp++]);
- cs->mocr |= 0x10;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
- save_flags(flags);
- sti();
- while (cnt && !test_bit(HW_MON1_TX_END, &cs->HW_Flags)) {
- cnt--;
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
+ cs->writeisac(cs, ISAC_MOX1, cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]);
+ cs->dc.isac.mocr |= 0x10;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+}
+
+int
+arcofi_fsm(struct IsdnCardState *cs, int event, void *data) {
+ if (cs->debug & L1_DEB_MONITOR) {
+ debugl1(cs, "arcofi state %d event %d", cs->dc.isac.arcofi_state, event);
}
- restore_flags(flags);
- sprintf(tmp, "arcofi tout %d", cnt);
- debugl1(cs, tmp);
- return(cnt);
+ if (event == ARCOFI_TIMEOUT) {
+ cs->dc.isac.arcofi_state = ARCOFI_NOP;
+ test_and_set_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags);
+ wake_up_interruptible(&cs->dc.isac.arcofi_wait);
+ return(1);
+ }
+ switch (cs->dc.isac.arcofi_state) {
+ case ARCOFI_NOP:
+ if (event == ARCOFI_START) {
+ cs->dc.isac.arcofi_list = data;
+ cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT;
+ send_arcofi(cs);
+ }
+ break;
+ case ARCOFI_TRANSMIT:
+ if (event == ARCOFI_TX_END) {
+ if (cs->dc.isac.arcofi_list->receive) {
+ add_arcofi_timer(cs);
+ cs->dc.isac.arcofi_state = ARCOFI_RECEIVE;
+ } else {
+ if (cs->dc.isac.arcofi_list->next) {
+ cs->dc.isac.arcofi_list =
+ cs->dc.isac.arcofi_list->next;
+ send_arcofi(cs);
+ } else {
+ if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {
+ del_timer(&cs->dc.isac.arcofitimer);
+ }
+ cs->dc.isac.arcofi_state = ARCOFI_NOP;
+ wake_up_interruptible(&cs->dc.isac.arcofi_wait);
+ }
+ }
+ }
+ break;
+ case ARCOFI_RECEIVE:
+ if (event == ARCOFI_RX_END) {
+ if (cs->dc.isac.arcofi_list->next) {
+ cs->dc.isac.arcofi_list =
+ cs->dc.isac.arcofi_list->next;
+ cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT;
+ send_arcofi(cs);
+ } else {
+ if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {
+ del_timer(&cs->dc.isac.arcofitimer);
+ }
+ cs->dc.isac.arcofi_state = ARCOFI_NOP;
+ wake_up_interruptible(&cs->dc.isac.arcofi_wait);
+ }
+ }
+ break;
+ default:
+ debugl1(cs, "Arcofi unknown state %x", cs->dc.isac.arcofi_state);
+ return(2);
+ }
+ return(0);
}
+static void
+arcofi_timer(struct IsdnCardState *cs) {
+ arcofi_fsm(cs, ARCOFI_TIMEOUT, NULL);
+}
+
+void
+clear_arcofi(struct IsdnCardState *cs) {
+ if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {
+ del_timer(&cs->dc.isac.arcofitimer);
+ }
+}
+
+void
+init_arcofi(struct IsdnCardState *cs) {
+ cs->dc.isac.arcofitimer.function = (void *) arcofi_timer;
+ cs->dc.isac.arcofitimer.data = (long) cs;
+ init_timer(&cs->dc.isac.arcofitimer);
+}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)