1 /* 2 * kmc and cpu interface 3 * @(#)dkkmc.h 1.2 Garage 84/03/27 4 */ 5 6 /* 7 * structure for each datakit channel 8 */ 9 struct dkchan { 10 short dk_state ; 11 struct ifqueue dk_outq; /* Output queue */ 12 struct mpacket *dk_obuf ; /* Active mbuf output chain */ 13 struct mbuf *dk_pending; /* Rest of current mbuf chain */ 14 15 struct ifuba dk_uba; 16 17 int (*dk_endfcn)() ; 18 caddr_t dk_endparm ; 19 int (*dk_supfcn)() ; 20 unsigned dk_rlen; /* length of receive buffer */ 21 int dk_ubmbase; /* ubm base register used for this receive transaction */ 22 /* only one receive pending at a time on a channel */ 23 }; 24 25 /* 26 * structure for command to kmc from cpu and 27 * report to cpu from kmc 28 */ 29 struct dkkin { 30 short k_type ; /* cmd type or report type */ 31 short k_chan ; /* chan number */ 32 short k_len ; /* # of char */ 33 char k_ctl ; /* cntl/time */ 34 char k_mode ; /* rcv mode */ 35 long k_addr ; /* address */ 36 } ; 37 38 /* 39 * command type 40 */ 41 #define KC_INIT 0x01 /* init: 0,0,0,0 */ 42 #define KC_SEND 0x02 /* send: len, 0, 0, addr */ 43 #define KC_RCVB 0x03 /* rcv: len, time, mode, addr */ 44 #define KC_CLOSE 0x04 /* close: 0, 0, 0, 0 */ 45 #define KC_XINIT 0x05 /* re-init xmitter: 0, 0, 0, 0 */ 46 #define KC_CMD 0x06 /* cmd to kmc: cmd, 0, 0, 0 */ 47 #define KC_FLAG 0x07 /* i/oflag: iflag, oflaghi, oflaglo, 0 */ 48 #define KC_SOI 0x08 /* send express: (byte2<<8)|byte1, 0, 0, 0 */ 49 #define KC_SCTL 0x09 /* send cntl: ctl, 0, 0, 0 */ 50 51 /* 52 * report type 53 */ 54 #define KS_SEND 0x0014 /* send: 0, 0, 0, 0 */ 55 #define KS_RDB 0x0015 /* rcv: residue len, cntl, mode, 0 */ 56 #define KS_EOI 0x0016 /* rcv express: (byte2<<8)|byte1, 0, 0, 0 */ 57 #define KS_CNTL 0x0017 /* rcv tdk cntl: cntl, 0, 0, 0 */ 58 #define KS_ERR 0x0018 /* error: code, 0, 0, 0 */ 59 60 /* 61 * The circular buffer, cmdbuf, is used to pass command to kmc: 62 * while the circular buffer statbuf is used to report status. 63 * There are 8 control and status registers (csr) accessible to 64 * both cpu and kmc. 65 * Csr4-csr5 are iused to indicate the head and tail respectively 66 * of the cmdbuf. Likewise, csr6-csr7 for statbuf. 67 * At initialization time, the cpu and kmc would agree on the beginning 68 * address of both buffers and their sizes. 69 */ 70 71 /* 72 * sub command bits for KC_CMD 73 */ 74 #define OFLUSH (1<<1) /* Flush output */ 75 #define OSPND (1<<2) /* Suspend output */ 76 #define ORSME (1<<3) /* Resume output */ 77 78 /* 79 * KC_RCV mode 80 */ 81 #define RCBLOCK (1<<5) /* return on block boundary */ 82 #define RCTIME (1<<6) /* return on time expires */ 83 /* 84 * KS_RDB mode 85 */ 86 #define SFULL (1<<0) /* buffer full */ 87 #define SCNTL (1<<1) /* cntl char rcv */ 88 #define SBLOCK (1<<5) /* block boundary */ 89 #define STIME (1<<6) /* time limit expired */ 90 #define SABORT (1<<3) /* rcv aborted */ 91 /* 92 * KC_SEND mode 93 */ 94 #define SBOT 0 /* End blocks with BOT */ 95 #define SBOTM 0x80 /* End blocks with BOTM */ 96 97 /* 98 * KS_ERR codes 99 */ 100 #define E_SW 0x00 /* dispatcher switch */ 101 #define E_BUS 0x01 /* Unibus error */ 102 #define E_IPANIC 0x02 /* input routine panic */ 103 #define E_CMD 0x03 /* command unknown */ 104 #define E_NOQB 0x04 /* run out of queue or buffer */ 105 #define E_DUP 0x05 /* duplicate SEND */ 106 #define E_ODKOVF 0x06 /* output routine panic */ 107 #define E_UMETA 0x07 /* un-recognized cntl char */ 108 #define E_SYS1 0x0021 /* system error 1 (041) */ 109 #define E_SYS2 0x0022 /* system error 2 (042) */ 110