summaryrefslogtreecommitdiff
path: root/sys/dev/ic/rlnvar.h
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1999-07-30 13:43:38 +0000
committerDavid Leonard <d@cvs.openbsd.org>1999-07-30 13:43:38 +0000
commitaad8058264cfbb51ec169e8ecd7f04209b706634 (patch)
tree2663f9de72cd9918697d20aa87b1b68b296344c3 /sys/dev/ic/rlnvar.h
parenteba2c9554269da5c9fbed00b24f82a87f30fd2b5 (diff)
rename rl2->rln for sanity
Diffstat (limited to 'sys/dev/ic/rlnvar.h')
-rw-r--r--sys/dev/ic/rlnvar.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/sys/dev/ic/rlnvar.h b/sys/dev/ic/rlnvar.h
new file mode 100644
index 00000000000..2e9dae49329
--- /dev/null
+++ b/sys/dev/ic/rlnvar.h
@@ -0,0 +1,141 @@
+/* $OpenBSD: rlnvar.h,v 1.1 1999/07/30 13:43:36 d Exp $ */
+/*
+ * David Leonard <d@openbsd.org>, 1999. Public domain.
+ *
+ * Proxim RangeLAN2 soft state copy.
+ */
+
+/*
+ * Mailboxes are used to communicate card-initiated messages
+ * from the interrupt handler to other kernel threads.
+ */
+struct rln_mbox {
+ void * mb_buf; /* Message buffer */
+ size_t mb_len; /* Message buffer size */
+ size_t mb_actlen; /* Actual message size */
+ u_int8_t mb_state; /* Mailbox state */
+#define RLNMBOX_VOID 0
+#define RLNMBOX_EMPTY 1
+#define RLNMBOX_FILLING 2
+#define RLNMBOX_FILLED 3
+};
+
+#define RLN_NMBOX 0x7c /* Same as max msg seq number */
+
+/* Soft state */
+struct rln_softc {
+ struct device sc_dev;
+ void *sc_ih; /* Interrupt handler */
+ struct arpcom sc_arpcom; /* Ethernet common part */
+ bus_space_tag_t sc_iot; /* Bus cookie */
+ bus_space_handle_t sc_ioh; /* Bus i/o handle */
+
+ u_int8_t sc_width; /* Bus transfer width */
+ u_int8_t sc_irq; /* IRQ for card */
+
+ u_int16_t sc_cardtype; /* Set from config flags */
+#define RLN_CTYPE_OEM 0x01
+#define RLN_CTYPE_UISA 0x02
+#define RLN_CTYPE_ONE_PIECE 0x04
+
+ u_int8_t sc_intsel; /* Copy of INTSEL */
+ u_int8_t sc_status; /* Copy of STATUS */
+ u_int8_t sc_control; /* Copy of CONTROL */
+#ifdef RLNDEBUG_REG
+ u_int8_t dbg_oreg[8]; /* Last reg value written */
+#endif
+
+ u_int8_t sc_pktseq; /* Card message seq no */
+ u_int8_t sc_txseq; /* Tx packet seq no */
+
+ u_int16_t sc_state; /* Soft state. */
+#define RLN_STATE_SYNC 0x0001 /* Card is synchronised */
+#define RLN_STATE_NEEDINIT 0x0002 /* Card needs reset+init */
+#define RLN_STATE_PROMISC 0x0004 /* Receive all packets */
+
+ struct rln_mbox sc_mbox[0x80]; /* Per-message mailboxes */
+ struct rln_param sc_param; /* User controlled parameters */
+};
+
+#define rln_need_reset(sc) \
+ (sc)->sc_state |= RLN_STATE_NEEDINIT
+
+/* Structure used to hold partial read state for rln_rx_pdata() */
+struct rln_pdata {
+ u_int8_t p_data; /* extra data read but not consumed */
+ int p_nremain; /* size of unconsumed data */
+};
+#define RLN_PDATA_INIT {0,0}
+
+/* Structure used to hold partial transmit state for rln_msg_tx_*() */
+struct rln_msg_tx_state {
+ int ien; /* saved interrupt state */
+ u_int8_t w; /* saved wakup state */
+ struct rln_pdata pd; /* saved partial write state */
+};
+
+struct rln_mm_cmd; /* fwd decl */
+
+#define RLN_WAKEUP_SET 0xff
+#define RLN_WAKEUP_NOCHANGE (0x80|0x10)
+
+void rlnconfig __P((struct rln_softc *));
+int rlnintr __P((void *));
+void rlnread __P((struct rln_softc *, struct rln_mm_cmd *, int));
+int rln_enable __P((struct rln_softc *, int));
+int rln_reset __P((struct rln_softc *));
+u_int8_t rln_wakeup __P((struct rln_softc *, u_int8_t));
+int rln_rx_request __P((struct rln_softc *, int));
+int rln_rx_data __P((struct rln_softc *, void *, int));
+void rln_rx_pdata __P((struct rln_softc *, void *, int,
+ struct rln_pdata *));
+void rln_rx_end __P((struct rln_softc *));
+void rln_clear_nak __P((struct rln_softc *));
+u_int8_t rln_newseq __P((struct rln_softc *));
+
+void rln_msg_tx_data __P((struct rln_softc *, void *, u_int16_t,
+ struct rln_msg_tx_state *));
+int rln_msg_tx_start __P((struct rln_softc *, void *, int,
+ struct rln_msg_tx_state *));
+int rln_msg_tx_end __P((struct rln_softc *,
+ struct rln_msg_tx_state *));
+int rln_msg_txrx __P((struct rln_softc *, void *, int,
+ void *, int));
+
+int rln_mbox_create __P((struct rln_softc *, u_int8_t, void *,
+ size_t));
+int rln_mbox_wait __P((struct rln_softc *, u_int8_t, int));
+int rln_mbox_lock __P((struct rln_softc *, u_int8_t, void **,
+ size_t*));
+void rln_mbox_unlock __P((struct rln_softc *, u_int8_t, size_t));
+
+/* debug all card operations */
+#ifdef RLNDEBUG
+#define dprintf(fmt, args...) printf(fmt , ## args)
+ /* log(LOG_DEBUG, fmt , ## args) */
+#define dprinthex(buf, len) do { \
+ unsigned char *_b = (unsigned char*)(buf); \
+ int _i, _l=(len); \
+ printf("{"); \
+ for(_i = 0; _i < _l; _i++) { \
+ printf("%02x", _b[_i]); \
+ if (_i % 4 == 3 && _i != _l - 1) \
+ printf(","); \
+ } \
+ printf("}"); \
+} while (0)
+#else
+#define dprintf(fmt, args...) /* nothing */
+#define dprinthex(buf, len) /* nothing */
+#endif
+
+/* debug messages to/from card. prints 4-octet groups separated by commas */
+#define RLNDUMP
+#define RLNDUMPHEX(buf, buflen) do { \
+ int _i; \
+ for (_i = 0; _i < (buflen); _i++) { \
+ printf("%02x", ((unsigned char *)(buf))[_i]); \
+ if (_i != (buflen) - 1 && _i % 4 == 3) \
+ printf(","); \
+ } \
+} while (0)