blob: 9fe21104d06f2ec980f859521d6c6a8579476b70 [file] [log] [blame] [raw]
Bob Supnik26aa6de2004-04-06 05:17:00 -07001/* pdp11_xu.h: DEUNA/DELUA ethernet controller information
2 ------------------------------------------------------------------------------
3
Bob Supnika9fd3dd2011-03-23 14:39:00 -07004 Copyright (c) 2003-2005, David T. Hittner
Bob Supnik26aa6de2004-04-06 05:17:00 -07005
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the author shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the author.
26
27 ------------------------------------------------------------------------------
28
29 Modification history:
30
Mark Pizzolato7ceba372013-01-25 14:57:01 -080031 25-Jan-13 RJ SELFTEST needs to report the READY state otherwise VMS 3.7 gets fatal controller error
Bob Supnika9fd3dd2011-03-23 14:39:00 -070032 23-Jan-08 MP Added debugging support to display packet headers and packet data
Bob Supnika12e4a12006-01-23 20:01:00 -080033 08-Dec-05 DTH Added load_server, increased UDBSIZE for system ID parameters
Bob Supnikb7c1eae2005-09-09 18:09:00 -070034 07-Jul-05 RMS Removed extraneous externs
Bob Supnik26aa6de2004-04-06 05:17:00 -070035 05-Jan-04 DTH Added network statistics
36 31-Dec-03 DTH Added reserved states
37 28-Dec-03 DTH Corrected MODE bitmasks
38 23-Dec-03 DTH Corrected TXR and RXR bitmasks
39 03-Dec-03 DTH Refitted to SIMH v3.0 platform
40 05-May-03 DTH Started XU simulation
41
42 ------------------------------------------------------------------------------
43*/
44
Mark Pizzolatod5ca5422013-03-12 11:07:58 -070045#ifndef PDP11_XU_H
46#define PDP11_XU_H
Bob Supnik26aa6de2004-04-06 05:17:00 -070047
48
Bob Supnikb7c1eae2005-09-09 18:09:00 -070049#if defined (VM_PDP10) /* PDP10 version */
Bob Supnik26aa6de2004-04-06 05:17:00 -070050#include "pdp10_defs.h"
Bob Supnikb7c1eae2005-09-09 18:09:00 -070051#define XU_RDX 8
52#define XU_WID 16
Bob Supnik26aa6de2004-04-06 05:17:00 -070053
Bob Supnikb7c1eae2005-09-09 18:09:00 -070054#elif defined (VM_VAX) /* VAX version */
Bob Supnikb6393b32004-11-23 15:49:00 -080055#include "vax_defs.h"
Mark Pizzolato68b54332013-01-22 16:14:53 -080056#define XU_RDX 16
57#define XU_WID 32
Bob Supnik26aa6de2004-04-06 05:17:00 -070058
Bob Supnikb7c1eae2005-09-09 18:09:00 -070059#else /* PDP-11 version */
Bob Supnik26aa6de2004-04-06 05:17:00 -070060#include "pdp11_defs.h"
Bob Supnikb7c1eae2005-09-09 18:09:00 -070061#define XU_RDX 8
62#define XU_WID 16
Bob Supnikb7c1eae2005-09-09 18:09:00 -070063#endif /* VM_PDP10 */
Bob Supnik26aa6de2004-04-06 05:17:00 -070064
65#include "sim_ether.h"
66
Bob Supnikb7c1eae2005-09-09 18:09:00 -070067#define XU_QUE_MAX 500 /* message queue array */
Bob Supnika9fd3dd2011-03-23 14:39:00 -070068#define XU_FILTER_MAX 12 /* mac + broadcast + 10 multicast addrs */
Bob Supnikb7c1eae2005-09-09 18:09:00 -070069#define XU_SERVICE_INTERVAL 100 /* times per second */
70#define XU_ID_TIMER_VAL 540 /* 9 min * 60 sec */
Bob Supnika12e4a12006-01-23 20:01:00 -080071#define UDBSIZE 200 /* max size of UDB (in words) */
Bob Supnik26aa6de2004-04-06 05:17:00 -070072
73enum xu_type {XU_T_DEUNA, XU_T_DELUA};
74
75struct xu_setup {
Mark Pizzolato68b54332013-01-22 16:14:53 -080076 int valid; /* is the setup block valid? */
Bob Supnikb7c1eae2005-09-09 18:09:00 -070077 int promiscuous; /* promiscuous mode enabled */
78 int multicast; /* enable all multicast addresses */
79 int mac_count; /* number of multicast mac addresses */
80 ETH_MAC macs[XU_FILTER_MAX]; /* MAC addresses to respond to */
Bob Supnik26aa6de2004-04-06 05:17:00 -070081};
82
83/* Network Statistics -
84 some of these will always be zero in the simulated environment,
85 since there is no ability for the sim_ether network driver to see
86 things like incoming runts, collision tests, babbling, etc.
87 */
88struct xu_stats {
Bob Supnikb7c1eae2005-09-09 18:09:00 -070089 uint16 secs; /* seconds since last clear */
90 uint32 frecv; /* frames received */
91 uint32 mfrecv; /* multicast frames received */
92 uint16 rxerf; /* receive error flags */
93 uint32 frecve; /* frames received with errors */
94 uint32 rbytes; /* data bytes received */
95 uint32 mrbytes; /* multicast data bytes received */
96 uint16 rlossi; /* received frames lost - internal err */
97 uint16 rlossl; /* received frames lost - local buffers */
98 uint32 ftrans; /* frames transmitted */
99 uint32 mftrans; /* multicast frames transmitted */
100 uint32 ftrans3; /* frames transmitted with 3+ tries */
101 uint32 ftrans2; /* frames transmitted - two tries */
102 uint32 ftransd; /* frames transmitted - deferred */
103 uint32 tbytes; /* data bytes transmitted */
104 uint32 mtbytes; /* multicast data bytes transmitted */
105 uint16 txerf; /* transmit error flags summary */
106 uint16 ftransa; /* transmit frames aborted */
107 uint16 txccf; /* transmit collision test failure */
108 uint16 porterr; /* port driver errors */
109 uint16 bablcnt; /* babble counter */
Bob Supnika9fd3dd2011-03-23 14:39:00 -0700110 uint32 loopf; /* loopback frames processed */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700111};
112
113struct xu_device {
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700114 /*+ initialized values - DO NOT MOVE */
115 ETH_PCALLBACK rcallback; /* read callback routine */
116 ETH_PCALLBACK wcallback; /* write callback routine */
117 ETH_MAC mac; /* MAC address */
118 enum xu_type type; /* controller type */
Mark Pizzolatoe9b312f2014-06-06 15:03:31 -0700119 uint32 throttle_time; /* ms burst time window */
120 uint32 throttle_burst; /* packets passed with throttle_time which trigger throttling */
121 uint32 throttle_delay; /* ms to delay when throttling. 0 disables throttling */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700122 /*- initialized values - DO NOT MOVE */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700123
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700124 /* I/O register storage */
125 uint32 irq; /* interrupt request flag */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700126
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700127 /* buffers, etc. */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700128 ETH_DEV* etherface;
129 ETH_PACK read_buffer;
130 ETH_PACK write_buffer;
131 ETH_QUE ReadQ;
Bob Supnika12e4a12006-01-23 20:01:00 -0800132 ETH_MAC load_server; /* load server address */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700133 int idtmr; /* countdown for ID Timer */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700134 struct xu_setup setup;
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700135 struct xu_stats stats; /* reportable network statistics */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700136
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700137 /* copied from dec_deuna.h */
138 uint16 pcsr0; /* primary DEUNA registers */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700139 uint16 pcsr1;
140 uint16 pcsr2;
141 uint16 pcsr3;
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700142 uint32 mode; /* mode register */
143 uint32 pcbb; /* port command block base */
Mark Pizzolato68b54332013-01-22 16:14:53 -0800144 uint16 stat; /* extended port status */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700145
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700146 uint32 tdrb; /* transmit desc ring base */
147 uint32 telen; /* transmit desc ring entry len */
148 uint32 trlen; /* transmit desc ring length */
149 uint32 txnext; /* transmit buffer pointer */
150 uint32 rdrb; /* receive desc ring base */
151 uint32 relen; /* receive desc ring entry len */
152 uint32 rrlen; /* receive desc ring length */
153 uint32 rxnext; /* receive buffer pointer */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700154
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700155 uint16 pcb[4]; /* copy of Port Command Block */
156 uint16 udb[UDBSIZE]; /* copy of Unibus Data Block */
157 uint16 rxhdr[4]; /* content of RX ring entry, during wait */
158 uint16 txhdr[4]; /* content of TX ring entry, during xmit */
Mark Pizzolatoae6f3b92016-05-24 08:47:01 -0700159 t_bool initialized; /* flag for one time initializations */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700160};
161
162struct xu_controller {
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700163 DEVICE* dev; /* device block */
164 UNIT* unit; /* unit block */
165 DIB* dib; /* device interface block */
166 struct xu_device* var; /* controller-specific variables */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700167};
168
169typedef struct xu_controller CTLR;
170
171/* PCSR0 register definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700172#define PCSR0_SERI 0100000 /* <15> Status Error Intr */
173#define PCSR0_PCEI 0040000 /* <14> Port Command Error Intr */
174#define PCSR0_RXI 0020000 /* <13> Receive Interrupt */
175#define PCSR0_TXI 0010000 /* <12> Transmit Interrupt */
176#define PCSR0_DNI 0004000 /* <11> Done Interrupt */
177#define PCSR0_RCBI 0002000 /* <10> Recv Buffer Unavail Intr */
Mark Pizzolato7ceba372013-01-25 14:57:01 -0800178#define PCSR0_FATL 0001000 /* <09> Fatal Internal Error */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700179#define PCSR0_USCI 0000400 /* <08> Unsolicited State Chg Inter */
180#define PCSR0_INTR 0000200 /* <07> Interrupt Summary */
181#define PCSR0_INTE 0000100 /* <06> Interrupt Enable */
182#define PCSR0_RSET 0000040 /* <05> Reset */
183#define PCSR0_PCMD 0000017 /* <03:00> Port Command field */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700184
185/* PCSR0 Port Commands */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700186#define CMD_NOOP 000 /* No-op */
187#define CMD_GETPCBB 001 /* Get PCB base */
188#define CMD_GETCMD 002 /* Get Command */
189#define CMD_SELFTEST 003 /* Self-test init */
190#define CMD_START 004 /* Start xmit/recv */
191#define CMD_BOOT 005 /* Boot */
192#define CMD_RSV06 006 /* Reserved */
193#define CMD_RSV07 007 /* Reserved */
194#define CMD_PDMD 010 /* Polling Demand */
195#define CMD_RSV11 011 /* Reserved */
196#define CMD_RSV12 012 /* Reserved */
197#define CMD_RSV13 013 /* Reserved */
198#define CMD_RSV14 014 /* Reserved */
199#define CMD_RSV15 015 /* Reserved */
200#define CMD_HALT 016 /* Halt */
201#define CMD_STOP 017 /* Stop */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700202
203/* PCSR1 register definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700204#define PCSR1_XPWR 0100000 /* <15> Tranceiver power failure */
205#define PCSR1_ICAB 0040000 /* <14> Port/Link cable failure */
206#define PCSR1_ECOD 0037400 /* <13:08> Self-test error code */
207#define PCSR1_PCTO 0000200 /* <07> Port Command Timeout */
208#define PCSR1_TYPE 0000160 /* <06:04> Interface type */
209#define PCSR1_STATE 0000017 /* <03:00> State: */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700210
211/* PCSR1 Types */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700212#define TYPE_DEUNA (0 << 4) /* Controller is a DEUNA */
213#define TYPE_DELUA (1 << 4) /* Controller is a DELUA */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700214
215/* PCSR1 States */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700216#define STATE_RESET 000 /* Reset */
217#define STATE_PLOAD 001 /* Primary Load */
218#define STATE_READY 002 /* Ready */
219#define STATE_RUNNING 003 /* Running */
220#define STATE_UHALT 005 /* UNIBUS Halted */
221#define STATE_NHALT 006 /* NI Halted */
222#define STATE_NUHALT 007 /* NI and UNIBUS Halted */
223#define STATE_HALT 010 /* Halted */
224#define STATE_SLOAD 017 /* Secondary Load */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700225
226/* Status register definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700227#define STAT_ERRS 0100000 /* <15> error summary */
228#define STAT_MERR 0040000 /* <14> multiple errors */
229#define STAT_BABL 0020000 /* <13> Transmitter on too long [DELUA only] */
230#define STAT_CERR 0010000 /* <12> collision test error */
231#define STAT_TMOT 0004000 /* <11> UNIBUS timeout */
232#define STAT_RRNG 0001000 /* <09> receive ring error */
233#define STAT_TRNG 0000400 /* <08> transmit ring error */
234#define STAT_PTCH 0000200 /* <07> ROM patch */
235#define STAT_RRAM 0000100 /* <06> running from RAM */
236#define STAT_RREV 0000077 /* <05:00> ROM version */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700237
238/* Mode definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700239#define MODE_PROM 0100000 /* <15> Promiscuous Mode */
240#define MODE_ENAL 0040000 /* <14> Enable All Multicasts */
241#define MODE_DRDC 0020000 /* <13> Disable Data Chaining */
242#define MODE_TPAD 0010000 /* <12> Transmit Msg Pad Enable */
243#define MODE_ECT 0004000 /* <11> Enable Collision Test */
244#define MODE_DMNT 0001000 /* <09> Disable Maint Message */
245#define MODE_INTL 0000200 /* <07> Internal Loopback [DELUA only] */
246#define MODE_DTCR 0000010 /* <03> Disable Transmit CRC */
247#define MODE_LOOP 0000004 /* <02> Internal Loopback Mode */
248#define MODE_HDPX 0000001 /* <00> Half-Duplex Mode */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700249
250/* Function Code definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700251#define FC_NOOP 0000000 /* no-op */
252#define FC_LSM 0000001 /* Load and Start Microaddress */
253#define FC_RDPA 0000002 /* Read Default Physical Address */
254#define FC_RPA 0000004 /* Read Physical Address */
255#define FC_WPA 0000005 /* Write Physical Address */
256#define FC_RMAL 0000006 /* Read Multicast Address List */
257#define FC_WMAL 0000007 /* Write Multicast Address List */
258#define FC_RRF 0000010 /* Read Ring Format */
259#define FC_WRF 0000011 /* Write Ring Format */
260#define FC_RDCTR 0000012 /* Read Counters */
261#define FC_RDCLCTR 0000013 /* Read and Clear Counters */
262#define FC_RMODE 0000014 /* Read Mode */
263#define FC_WMODE 0000015 /* Write Mode */
264#define FC_RSTAT 0000016 /* Read Status */
265#define FC_RCSTAT 0000017 /* Read and Clear Status */
266#define FC_DIM 0000020 /* Dump Internal Memory */
267#define FC_LIM 0000021 /* Load Internal Memory */
268#define FC_RSID 0000022 /* Read System ID parameters */
269#define FC_WSID 0000023 /* Write System ID parameters */
270#define FC_RLSA 0000024 /* Read Load Server Address */
271#define FC_WLSA 0000025 /* Write Load Server Address */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700272
273/* Transmitter Ring definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700274#define TXR_OWN 0100000 /* <15> we own it (1) */
275#define TXR_ERRS 0040000 /* <14> error summary */
276#define TXR_MTCH 0020000 /* <13> Station Match */
277#define TXR_MORE 0010000 /* <12> Mult Retries Needed */
278#define TXR_ONE 0004000 /* <11> One Collision */
279#define TXR_DEF 0002000 /* <10> Deferred */
280#define TXR_STF 0001000 /* <09> Start Of Frame */
281#define TXR_ENF 0000400 /* <08> End Of Frame */
282#define TXR_BUFL 0100000 /* <15> Buffer Length Error */
283#define TXR_UBTO 0040000 /* <14> UNIBUS TimeOut */
284#define TXR_UFLO 0020000 /* <13> Underflow Error */
285#define TXR_LCOL 0010000 /* <12> Late Collision */
286#define TXR_LCAR 0004000 /* <11> Lost Carrier */
287#define TXR_RTRY 0002000 /* <10> Retry Failure (16x) */
288#define TXR_TDR 0001777 /* <9:0> TDR value if RTRY=1 */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700289
290/* Receiver Ring definitions */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700291#define RXR_OWN 0100000 /* <15> we own it (1) */
292#define RXR_ERRS 0040000 /* <14> Error Summary */
293#define RXR_FRAM 0020000 /* <13> Frame Error */
294#define RXR_OFLO 0010000 /* <12> Message Overflow */
295#define RXR_CRC 0004000 /* <11> CRC Check Error */
296#define RXR_STF 0001000 /* <09> Start Of Frame */
297#define RXR_ENF 0000400 /* <08> End Of Frame */
298#define RXR_BUFL 0100000 /* <15> Buffer Length error */
299#define RXR_UBTO 0040000 /* <14> UNIBUS TimeOut */
300#define RXR_NCHN 0020000 /* <13> No Data Chaining */
301#define RXR_OVRN 0010000 /* <12> Overrun Error [DELUA only] */
302#define RXR_MLEN 0007777 /* <11:0> Message Length */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700303
Mark Pizzolato4dfbb982016-02-24 09:02:17 -0800304BITFIELD xu_rdes_w2[] = {
305 BITNCF(8), BIT(ENP), BIT(STP), BITNC, BIT(CRC), BIT(OFLO), BIT(FRAM), BIT(ERRS), BIT(OWN),
306 ENDBITS
307};
308BITFIELD xu_rdes_w3[] = {
309 BITFFMT(mlen,12,"0x%X"), BITNC, BIT(NCHN), BIT(UBTO), BIT(BUFL),
310 ENDBITS
311};
312
Bob Supnik26aa6de2004-04-06 05:17:00 -0700313/* debugging bitmaps */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700314#define DBG_TRC 0x0001 /* trace routine calls */
315#define DBG_REG 0x0002 /* trace read/write registers */
316#define DBG_WRN 0x0004 /* display warnings */
Bob Supnika9fd3dd2011-03-23 14:39:00 -0700317#define DBG_PCK 0x0080 /* display packet headers */
318#define DBG_DAT 0x0100 /* display packet data */
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700319#define DBG_ETH 0x8000 /* debug ethernet device */
Bob Supnik26aa6de2004-04-06 05:17:00 -0700320
Bob Supnikb7c1eae2005-09-09 18:09:00 -0700321#endif /* _PDP11_XU_H */