1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)mbavar.h 7.1 (Berkeley) 06/05/86 7 */ 8 9 /* 10 * This file contains definitions related to the kernel structures 11 * for dealing with the massbus adapters. 12 * 13 * Each mba has a mba_hd structure. 14 * Each massbus device has a mba_device structure. 15 * Each massbus slave has a mba_slave structure. 16 * 17 * At boot time we prowl the structures and fill in the pointers 18 * for devices which we find. 19 */ 20 21 /* 22 * Per-mba structure. 23 * 24 * The initialization routine uses the information in the mbdinit table 25 * to initialize the what is attached to each massbus slot information. 26 * It counts the number of devices on each mba (to see if bothering to 27 * search/seek is appropriate). 28 * 29 * During normal operation, the devices attached to the mba which wish 30 * to transfer are queued on the mh_act? links. 31 */ 32 struct mba_hd { 33 short mh_active; /* set if mba is active */ 34 short mh_ndrive; /* number of devices, to avoid seeks */ 35 struct mba_regs *mh_mba; /* virt addr of mba */ 36 struct mba_regs *mh_physmba; /* phys addr of mba */ 37 struct mba_device *mh_mbip[8]; /* what is attached to each dev */ 38 struct mba_device *mh_actf; /* head of queue to transfer */ 39 struct mba_device *mh_actl; /* tail of queue to transfer */ 40 }; 41 42 /* 43 * Per-device structure 44 * (one for each RM/RP disk, and one for each tape formatter). 45 * 46 * This structure is used by the device driver as its argument 47 * to the massbus driver, and by the massbus driver to locate 48 * the device driver for a particular massbus slot. 49 * 50 * The device drivers hang ready buffers on this structure, 51 * and the massbus driver will start i/o on the first such buffer 52 * when appropriate. 53 */ 54 struct mba_device { 55 struct mba_driver *mi_driver; 56 short mi_unit; /* unit number to the system */ 57 short mi_mbanum; /* the mba it is on */ 58 short mi_drive; /* controller on mba */ 59 short mi_dk; /* driver number for iostat */ 60 short mi_alive; /* device exists */ 61 short mi_type; /* driver specific unit type */ 62 struct buf mi_tab; /* head of queue for this device */ 63 struct mba_device *mi_forw; 64 /* we could compute these every time, but hereby save time */ 65 struct mba_regs *mi_mba; 66 struct mba_drv *mi_drv; 67 struct mba_hd *mi_hd; 68 }; 69 70 #define b_bdone b_bufsize /* redefinition for mi_tab XXX */ 71 72 /* 73 * Tape formatter slaves are specified by 74 * the following information which is used 75 * at boot time to initialize the tape driver 76 * internal tables. 77 */ 78 struct mba_slave { 79 struct mba_driver *ms_driver; 80 short ms_ctlr; /* which of several formatters */ 81 short ms_unit; /* which unit to system */ 82 short ms_slave; /* which slave to formatter */ 83 short ms_alive; 84 }; 85 86 /* 87 * Per device-type structure. 88 * 89 * Each massbus driver defines entries for a set of routines used 90 * by the massbus driver, as well as an array of types which are 91 * acceptable to it. 92 */ 93 struct mba_driver { 94 int (*md_attach)(); /* attach a device */ 95 int (*md_slave)(); /* attach a slave */ 96 int (*md_ustart)(); /* unit start routine */ 97 int (*md_start)(); /* setup a data transfer */ 98 int (*md_dtint)(); /* data transfer complete */ 99 int (*md_ndint)(); /* non-data transfer interrupt */ 100 short *md_type; /* array of drive type codes */ 101 char *md_dname, *md_sname; /* device, slave names */ 102 struct mba_device **md_info; /* backpointers to mbinit structs */ 103 }; 104 105 /* 106 * Possible return values from unit start routines. 107 */ 108 #define MBU_NEXT 0 /* skip to next operation */ 109 #define MBU_BUSY 1 /* dual port busy; wait for intr */ 110 #define MBU_STARTED 2 /* non-data transfer started */ 111 #define MBU_DODATA 3 /* data transfer ready; start mba */ 112 113 /* 114 * Possible return values from data transfer interrupt handling routines 115 */ 116 #define MBD_DONE 0 /* data transfer complete */ 117 #define MBD_RETRY 1 /* error occurred, please retry */ 118 #define MBD_RESTARTED 2 /* driver restarted i/o itself */ 119 #define MBD_REPOSITION 3 /* driver started unit, not transfer */ 120 121 /* 122 * Possible return values from non-data-transfer interrupt handling routines 123 */ 124 #define MBN_DONE 0 /* non-data transfer complete */ 125 #define MBN_RETRY 1 /* failed; retry the operation */ 126 #define MBN_SKIP 2 /* don't do anything */ 127 128 /* 129 * Clear attention status for specified device. 130 */ 131 #define mbclrattn(mi) ((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive) 132 133 /* 134 * Kernel definitions related to mba. 135 */ 136 #ifdef KERNEL 137 int nummba; 138 #if NMBA > 0 139 struct mba_hd mba_hd[NMBA]; 140 extern Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int(); 141 142 extern struct mba_device mbdinit[]; 143 extern struct mba_slave mbsinit[]; 144 #endif 145 #endif 146