1
2
3
4
5
6
7
8 #include <sys/timeout.h>
9
10
11
12
13
14 struct rln_mbox {
15 void * mb_buf;
16 size_t mb_len;
17 size_t mb_actlen;
18 u_int8_t mb_state;
19 #define RLNMBOX_VOID 0
20 #define RLNMBOX_EMPTY 1
21 #define RLNMBOX_FILLING 2
22 #define RLNMBOX_FILLED 3
23 };
24
25 #define RLN_NMBOX 0x7c
26
27
28 struct rln_softc {
29 struct device sc_dev;
30 void *sc_ih;
31 struct arpcom sc_arpcom;
32 bus_space_tag_t sc_iot;
33 bus_space_handle_t sc_ioh;
34 struct timeout sc_timeout;
35
36 u_int8_t sc_width;
37 u_int8_t sc_irq;
38
39 u_int16_t sc_cardtype;
40 #define RLN_CTYPE_OEM 0x01
41 #define RLN_CTYPE_UISA 0x02
42 #define RLN_CTYPE_ONE_PIECE 0x04
43
44 u_int8_t sc_intsel;
45 u_int8_t sc_status;
46 u_int8_t sc_control;
47 #ifdef RLNDEBUG_REG
48 u_int16_t dbg_oreg[8];
49 #endif
50
51 u_int8_t sc_pktseq;
52 u_int8_t sc_txseq;
53
54 u_int16_t sc_state;
55 #define RLN_STATE_SYNC 0x0001
56 #define RLN_STATE_NEEDINIT 0x0002
57 #define RLN_STATE_PROMISC 0x0004
58
59 struct rln_mbox sc_mbox[0x80];
60 struct rln_param sc_param;
61 };
62
63 #define rln_need_reset(sc) \
64 (sc)->sc_state |= RLN_STATE_NEEDINIT
65
66
67 struct rln_pdata {
68 u_int8_t p_data;
69 int p_nremain;
70 };
71 #define RLN_PDATA_INIT {0,0}
72
73
74 struct rln_msg_tx_state {
75 int ien;
76 u_int8_t w;
77 struct rln_pdata pd;
78 };
79
80 struct rln_mm_cmd;
81
82 #define RLN_WAKEUP_SET 0xff
83 #define RLN_WAKEUP_NOCHANGE (0x80|0x10)
84
85 void rlnconfig(struct rln_softc *);
86 int rlnintr(void *);
87 void rlninit(struct rln_softc *);
88 void rlnstop(struct rln_softc *);
89 void rlnread(struct rln_softc *, struct rln_mm_cmd *, int);
90 int rln_enable(struct rln_softc *, int);
91 int rln_reset(struct rln_softc *);
92 u_int8_t rln_wakeup(struct rln_softc *, u_int8_t);
93 int rln_rx_request(struct rln_softc *, int);
94 int rln_rx_data(struct rln_softc *, void *, int);
95 void rln_rx_pdata(struct rln_softc *, void *, int,
96 struct rln_pdata *);
97 void rln_rx_end(struct rln_softc *);
98 void rln_clear_nak(struct rln_softc *);
99 u_int8_t rln_newseq(struct rln_softc *);
100
101 void rln_msg_tx_data(struct rln_softc *, void *, u_int16_t,
102 struct rln_msg_tx_state *);
103 int rln_msg_tx_start(struct rln_softc *, void *, int,
104 struct rln_msg_tx_state *);
105 int rln_msg_tx_end(struct rln_softc *,
106 struct rln_msg_tx_state *);
107 int rln_msg_txrx(struct rln_softc *, void *, int,
108 void *, int);
109
110 int rln_mbox_create(struct rln_softc *, u_int8_t, void *,
111 size_t);
112 int rln_mbox_wait(struct rln_softc *, u_int8_t, int);
113 int rln_mbox_lock(struct rln_softc *, u_int8_t, void **,
114 size_t*);
115 void rln_mbox_unlock(struct rln_softc *, u_int8_t, size_t);
116
117
118 #ifdef RLNDEBUG
119 #define dprintf(fmt, args...) printf(fmt , ## args)
120
121 #define dprinthex(buf, len) do { \
122 unsigned char *_b = (unsigned char *)(buf); \
123 int _i, _l=(len); \
124 printf("{"); \
125 for(_i = 0; _i < _l; _i++) { \
126 printf("%02x", _b[_i]); \
127 if (_i % 4 == 3 && _i != _l - 1) \
128 printf(","); \
129 } \
130 printf("}"); \
131 } while (0)
132 #else
133 #define dprintf(fmt, args...)
134 #define dprinthex(buf, len)
135 #endif
136
137
138 #define RLNDUMP
139 #define RLNDUMPHEX(buf, buflen) do { \
140 int _i; \
141 for (_i = 0; _i < (buflen); _i++) { \
142 printf("%02x", ((unsigned char *)(buf))[_i]); \
143 if (_i != (buflen) - 1 && _i % 4 == 3) \
144 printf(","); \
145 } \
146 } while (0)