Subject: kernel 'config', autoconfig, documentation changes (#98, 10 of 12) Index: sys,doc,etc,pdpif,.../many 2.11BSD Description: This is part 10 of 12. Updates #89 thru #100 are parts 1 thru 12 respectively. If you have tired of reading the notes in the "Repeat-By:" section please skip to the "Fix:" section for notes and instructions about this patch file (list of files updated, etc). Repeat-By: This section is repeated in each patch file. Specific directions for the individual patches are included in the "Fix:" section. Several problem areas are addressed by this series of updates. 1) The kernel configuration problems are best noticed by maintaining kernels for a variety of systems and forgetting to copy 'localopts.h' to ../h before compiling. This at best would cause compile time problems, at worst resulting in a kernel that was unusable. MANY of the changes described below are aimed at the reduction of 'localopts.h' to almost nothing. 2) There were several kernel config options which were either known not to work, have not been used within recent memory or were obsolete. UCB_FRCSWAP (to force a swap on program expansion) is a good example of an option which has been removed. The list of things which have been options at one time or another in the system's life has been removed. Many of them dated back to V7, the modules which they affected are not even present in the system any longer. Two options have been moved to the end of the 'config' script. Neither is known to work (CGL_RTP and FPSIM) and are always left NO. 3) A couple of kernel config options should not have been options so that the kernel could automatically adapt to whatever machine it found itself running on. The UNIBUS_MAP and Q22 options are good examples of this. Usage of the UNIBUS_MAP option was inconsistent, some of the drivers in the system "#ifdef"d references to the Unibus map allocation routine while other drivers did not. Since the system knows whether a Unibus Map is present or not the correct behaviour is to either test 'ubmap' or simply call 'mapalloc' (which will do the test for you). In the case of GENERIC or Unibus based kernels there is _no_ penalty (since UNIBUS_MAP was defined), in the case of Qbus systems there is about 900 bytes of code that simply never gets used (and 40 bytes or so of D space). The Q22 defined was used incorrectly in a couple of drivers to either distinquish between Digital and 3rd party controllers (DH-11 vs Emulex CS02) or to indicate whether the system was Qbus or Unibus based. The references to Q22 in dh.c were changed to CS02 (a new option in the device selection area of the config files), deleted, or replaced with tests of 'ubmap'. UCB_RUSAGE has been made standard because several applications (iostat, vmstat, etc) use the statistics and because the getrusage(2) call uses them. UCB_METER has been left as an option and will be placed in the Makefile as "-DUCB_METER" in the DEFS line. References to UCB_RUSAGE have been removed from the kernel. NONFP has been removed. Hardware floating point is mandatory for two reasons: the simulator doesn't work, and FP is very inexpensive (or standard on KDJ-11 systems). VIRUS_VFORK has been removed. Nothing depended on it in the applications and VIRUS_VFORK has never been anything but YES. 4) NSWAP has gone away. It was too easy to either forget to change it or to pick a wrong number (by guessing). Borrowing yet another concept from 4.3BSD the system now determines the amount of swap space dynamically after booting. This is done by calling a partition size routine which each disc driver provides. The bdevsw[] table (in pdp/conf.c) has been expanded to include a "d_psize" member for each device. NOTE: this change requires that 'a' and 'b' be the root and swap partitions. All drivers except the RK06/7 (hk.c) and RM02/3 (xp.c) observed this rule. Changes were made to the RK06/7 and RM02/3 partition tables (and /etc/disktab). The previous practice of using the 'e' or 'f' partitions to overlap the old 'a'+'b' partitions has gone away. THE new 'a' partition is the same size as the 'e' or 'f' partitions used to be, so there is ROOT FILESYSTEM compatibility (the system will still boot). Best to back the system up (if using RK07 or RM02 drives) before applying these changes. 5) SWAPLO has gone away. It has never been anything but 0 within recent memory (and would have resulted in filesystem corruption if an inappropriate value were chosen). The only device which possibly would need to use it (the RL02) is required to be used in pairs. Deleting SWAPLO removed a number of long word adds scattered around the kernel. One sector (.5kb) of swap space is "lost"/discarded. The previous practice was to decrement 'swplo' in compensation for entering 1 as the first swap block. Since 'swplo' has gone away, the number of blocks available ('nswap') is simply decremented by 1 and the swapmap initialized starting at block 1. This change affects a couple of the applications ('ps', 'pstat', etc.) which were looking for 'swplo'. These programs have been updated. 6) 'autoconfig' and programmable vector devices (MSCP, TMSCP, etc) have never gotten along very well. The drivers had vectors hardcoded (either via #define statments or code which allocated vectors from a base vector) into them. Changing /etc/dtab would have no effect (at best) or the system would crash (at worst) because 'autoconfig' would allocate/initialize a vector different than that assumed by the driver. Networking drivers which support programmable vectors (DEQNA for example) previously had their vectors hardcoded into them AND into pdp/net_scb.s. Changing one but forgetting to change the other was one way to generate an inoperable system! This has been fixed _at last_! There are two methods used. One for kernel devices configured by 'autoconfig' and a second used by the both 'autoconfig' and the networking drivers (which are not handled by 'autoconfig' because the networking is already running by the time 'init' starts 'autoconfig'). If a driver defines a routine "xxxVec" (where xxx is 'ra', 'tms', etc) then 'autoconfig' will call the driver with two parameters: the controller number and the vector from /etc/dtab. If the driver lacks a 'xxxVec' routine then 'autoconfig' functions as it always has. The second method is used when dynamic allocation of vectors is desired for programmable vector devices. The networking drivers (DEQNA, DEQTA, etc) use this method. In the kernel there is a location ('lastiv') which contains the next vector to assign. Usage is to decrement 'lastiv' by 4 and use the new value. If multiple vectors are needed then a multiple of 4 is subtracted ('autoconfig' counts how many "handlers" it needs for a device). To make use of this feature (second or third MSCP controllers for example) put a 0 (zero) in the vector field in /etc/dtab. NOTE: It is an error to specify a 0 vector (dynamic allocation) and not have a 'xxxVec' routine for 'autoconfig' to call. 'autoconfig' will print an error and leave the device unattached. If 'xxxVec' is used by 'autoconfig' the driver should return success (0) or failure (non-0). 'autoconfig' will print "vectorset" if a programmable vector is successfully installed. Networking drivers access 'lastiv' via the "mfkd" and "mtkd" (move from kernel data, move to kernel data) routines. The hardwired vector (400 for the DEQNA) has been removed from scb.s., NOTE: the handlers for networking devices are still present in net_scb.s, the drivers initialize the allocated vector by means of a small (1 instruction) assembly language routine (see the changes to pdpif/if_qe.c). This 'asm' routine is needed for the driver to access the handle name which does not have a leading (underscore) prepended to it. 7) The logic in the DHV-11 driver to attempt forcing a fuller silo (by turning off and on the receive interrupt enable) was removed since it did not work (for very long). After 2 silo overruns or 90% full silos the logic would disable itself by decrementing the number of delay ticks to 0. The only real fix for the DHV-11's silo handling problem is to replace the DHV-11 with a DHQ-11. 8) The kernel option UCB_NET has been renamed to INET (as 4.3BSD does). The TCP_COMPAT_42 option has been made "standard" by removing the ifdef in netinet/tcp_var.h. 9) The MAXMEM option has been moved to param.h. It is (almost) never changed and was yet one more thing to accidentally get wrong when configuring a kernel. Thought was given to removing MAXMEM entirely but it was put in with the other "never changed without a great deal of thought" parameters in param.h 10) The setup and installation documents have been revised to reflect the new kernel configuration process and to remove references to 'xpunix', 'raunix', etc (not needed now that the generic kernel adapts automatically). 11) The drivers in the OTHERS directory have been lightly edited to change UCB_NET to INET, remove UNIBUS_MAP usage, etc. No attempt has been made to port or fix the drivers. 12) Last, but by no means least, the 'config' script (/sys/conf/config) and the conf/Make.{nsunix,unix,sunix} files have been totally redone. Borrowing still another idea from 4.3BSD (not a whole lot left to 'steal' ;-)) the 'config' script now places a line: DEFS="-DKERNEL -Doption1 -Doption2 ..." at the front of the main Makefile. The CFLAGS statement has been modified to include ${DEFS}, thus the configuration options are passed thru to the secondary makefiles Make.pdp, Make.pdpuba, etc. The GENERIC config file has been redone. You should make note of your present device complement and then re-config your kernels by making a copy of GENERIC and editing it. NOTE: The PDP11 line is now only used to select the appropriate inlining method for the 'spl' instruction. You may safely set PDP11 to GENERIC, no references to PDP11 are now made anywhere in the kernel. You should only set the IDENT line to GENERIC if you either know what you are doing, or if you really are making a distribution kernel. Setting IDENT to GENERIC causes the kernel at boot time to: a) override "swapdev". A GENERIC kernel automatically assigns the 'b' partition of the booted device to be "swapdev" b) override "rootdev". A GENERIC kernel automatically assigns the 'a' partition of the booted device to be "rootdev" and "pipedev". The /GENALLSYS script is obsolete and has been removed from the system. For a GENERIC system /unix will now adapt to the bootstrapped drive and automatically determine the amount of swap space. The only change made to the secondary makefiles was to add a new ethernet driver (not yet working) to Make.net. The DEQTA driver (if_qt.c) is still being debugged, a future update will be forthcoming. Since if_qt.c does not exist, the "patch" is the whole file (the same applies to if_qtreg.h). You will need to create two 0 length files in pdpif ("touch /sys/pdpif/if_qt.c /sys/pdpif/if_qtreg.h") before applying the 'pdpif' update kit. A reminder will be placed in the part containing that patch. NOTE: localopts.h has exactly _TWO_ (2) definitions in it now: EXTERNALITIMES (mapped out time values from the inodes) and LINEHZ. The default for EXTERNALITIMES is now YES. It is recommended that this not be changed, if it is changed then applications which look at the kernel incore inode table (pstat for example) will need to be recompiled. Unless either of these two defines change you never need to worry about copying localopts.h again! Fix: The following files are modified: /usr/src/sys/pdpif/if_il.c /usr/src/sys/pdpif/if_qe.c /usr/src/sys/pdpif/if_qt.c /usr/src/sys/pdpif/if_qtreg.h /usr/src/sys/pdpif/if_uba.c /usr/src/sys/pdpif/if_uba.h /usr/src/sys/netinet/tcp_var.h References to UNIBUS_MAP and Q22 were either removed or replaced with run time tests for a Unibus Map being present. References to UCB_NET were replaced with INET. The macro NETUBAA was removed, the networking can call 'malloc(ubmap...)' using the MALLOC macro. 'if_qt.c' and 'if_qtreg.h' are new, the diff presented is that of entire files against a zero length 'if_qt.c.old' and 'if_qtreg.h.old' respectively. if_qe.c was modified to allocate an initialize its interrupt vector dynamically. Changes were also made in the way the device was reset. NNOTE: Before applying this update be sure to do: touch /sys/pdpif/if_qt.c /sys/pdpif/if_qtreg.h This will create a zero length file for "patch" to work with. 'tcp_var.h' was modified to always defined TCP_COMPAT_42, this option was removed from the kernel config time (it had never been set to anything except YES anyhow). *** /usr/src/sys/pdpif/if_il.c.old Wed Dec 19 10:20:56 1990 --- /usr/src/sys/pdpif/if_il.c Tue Dec 29 00:59:52 1992 *************** *** 3,10 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)if_il.c 1.1 (2.10BSD Berkeley) 12/1/86 * * 2.11BSD - Remove ilreset since that's a vax'ism and is never * called on a pdp-11. Since the unibus resources are * allocated in the attach routine and ubarelse is a noop --- 3,12 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)if_il.c 2.0 (2.11BSD GTE) 12/29/92 * + * 12/29/92 - sms: remove Q22 ifdefs, replacing them with runtime tests + * for a Unibus Map. * 2.11BSD - Remove ilreset since that's a vax'ism and is never * called on a pdp-11. Since the unibus resources are * allocated in the attach routine and ubarelse is a noop *************** *** 33,38 **** --- 35,41 ---- #include "if_uba.h" #include "errno.h" #include "../pdpuba/ubavar.h" + #include "uba.h" #include "../net/if.h" #include "../net/netisr.h" *************** *** 59,64 **** --- 62,68 ---- #define ILUNIT(x) minor(x) int ilinit(),iloutput(),ilioctl(),ilwatch(); int ildebug = 0; + short ilub = 0; long startnet = 0; /* *************** *** 131,136 **** --- 135,141 ---- extern memaddr netdata; startnet = mfkd(&netdata); startnet = ctob(startnet); + ilub = mfkd(&ubmap); /* get copy of kernel UBmap flag */ } ifp->if_unit = ui->ui_unit; ifp->if_name = "il"; *************** *** 144,162 **** addr->il_csr = ILC_RESET; (void)ilwait(ui, "reset"); ! #ifdef UNIBUS_MAP ! is->is_ubaddr = uballoc((caddr_t)&is->is_stats,sizeof(struct il_stats)); ! #else ! is->is_ubaddr = (long)((caddr_t)&is->is_stats) + startnet; ! #endif addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); - #ifdef Q22 - addr->il_ber = hiint(is->is_ubaddr) & 077; - addr->il_csr = ILC_STAT; - #else - addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT; - #endif (void)ilwait(ui, "status"); ubarelse(ui->ui_ubanum, &is->is_ubaddr); /* NOOP on pdp-11 */ --- 149,168 ---- addr->il_csr = ILC_RESET; (void)ilwait(ui, "reset"); ! if (ilub) ! { ! is->is_ubaddr = uballoc((caddr_t)&is->is_stats,sizeof(struct il_stats)); ! addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT; ! } ! else ! { ! is->is_ubaddr = (long)((caddr_t)&is->is_stats) + startnet; ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! addr->il_csr = ILC_STAT; ! } ! addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); (void)ilwait(ui, "status"); ubarelse(ui->ui_ubanum, &is->is_ubaddr); /* NOOP on pdp-11 */ *************** *** 255,276 **** sizeof is->is_addr); addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof is->is_addr; ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! addr->il_csr = ILC_LDPA; ! #else ! addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_LDPA; ! #endif if (ilwait(ui, "setaddr")) return; addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! addr->il_csr = ILC_STAT; ! #else ! addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT; ! #endif if (ilwait(ui, "verifying setaddr")) return; if (bcmp((caddr_t)is->is_stats.ils_addr, (caddr_t)is->is_addr, --- 261,285 ---- sizeof is->is_addr); addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof is->is_addr; ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! addr->il_csr = ILC_LDPA; ! } ! else ! addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_LDPA; if (ilwait(ui, "setaddr")) return; addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! addr->il_csr = ILC_STAT; ! } ! else ! addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT; ! if (ilwait(ui, "verifying setaddr")) return; if (bcmp((caddr_t)is->is_stats.ils_addr, (caddr_t)is->is_addr, *************** *** 291,303 **** ; addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info) & 077; ! addr->il_csr = ILC_RCV|IL_RIE; ! #else ! addr->il_csr = ! ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; ! #endif while ((addr->il_csr & IL_CDONE) == 0) ; is->is_flags = ILF_OACTIVE; --- 300,313 ---- ; addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info) & 077; ! addr->il_csr = ILC_RCV|IL_RIE; ! } ! else ! addr->il_csr = ! ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; while ((addr->il_csr & IL_CDONE) == 0) ; is->is_flags = ILF_OACTIVE; *************** *** 330,341 **** return; addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! csr = ILC_STAT|IL_RIE|IL_CIE; ! #else ! csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT|IL_RIE|IL_CIE; ! #endif is->is_flags &= ~ILF_STATPENDING; goto startcmd; } --- 340,352 ---- return; addr->il_bar = loint(is->is_ubaddr); addr->il_bcr = sizeof (struct il_stats); ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ubaddr) & 077; ! csr = ILC_STAT|IL_RIE|IL_CIE; ! } ! else ! csr = ((is->is_ubaddr >> 2) & IL_EUA)|ILC_STAT|IL_RIE|IL_CIE; is->is_flags &= ~ILF_STATPENDING; goto startcmd; } *************** *** 352,364 **** addr->il_bar = loint(is->is_ifuba.ifu_w.ifrw_info); addr->il_bcr = len; ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ifuba.ifu_w.ifrw_info) & 077; ! csr = ILC_XMIT|IL_CIE|IL_RIE; ! #else ! csr = ! ((is->is_ifuba.ifu_w.ifrw_info >> 2) & IL_EUA)|ILC_XMIT|IL_CIE|IL_RIE; ! #endif startcmd: is->is_lastcmd = csr & IL_CMD; addr->il_csr = csr; --- 363,377 ---- addr->il_bar = loint(is->is_ifuba.ifu_w.ifrw_info); addr->il_bcr = len; ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ifuba.ifu_w.ifrw_info) & 077; ! csr = ILC_XMIT|IL_CIE|IL_RIE; ! } ! else ! csr = ! ((is->is_ifuba.ifu_w.ifrw_info >> 2) & IL_EUA)|ILC_XMIT|IL_CIE|IL_RIE; ! startcmd: is->is_lastcmd = csr & IL_CMD; addr->il_csr = csr; *************** *** 392,404 **** addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info) & 077; ! addr->il_csr = ILC_RCV|IL_RIE; ! #else ! addr->il_csr = ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; - #endif s = splhigh(); while ((addr->il_csr & IL_CDONE) == 0) ; --- 405,418 ---- addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info)&077; ! addr->il_csr = ILC_RCV|IL_RIE; ! } ! else ! addr->il_csr = ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; s = splhigh(); while ((addr->il_csr & IL_CDONE) == 0) ; *************** *** 523,535 **** } addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! #ifdef Q22 ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info) & 077; ! addr->il_csr = ILC_RCV|IL_RIE; ! #else ! addr->il_csr = ! ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; ! #endif s = splhigh(); while ((addr->il_csr & IL_CDONE) == 0) ; --- 537,550 ---- } addr->il_bar = loint(is->is_ifuba.ifu_r.ifrw_info); addr->il_bcr = sizeof(struct il_rheader) + ETHERMTU + 6; ! if (!ilub) ! { ! addr->il_ber = hiint(is->is_ifuba.ifu_r.ifrw_info) & 077; ! addr->il_csr = ILC_RCV|IL_RIE; ! } ! else ! addr->il_csr = ! ((is->is_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE; s = splhigh(); while ((addr->il_csr & IL_CDONE) == 0) ; *** /usr/src/sys/pdpif/if_qe.c.old Wed Dec 19 10:21:40 1990 --- /usr/src/sys/pdpif/if_qe.c Mon Dec 28 18:22:44 1992 *************** *** 1,9 **** ! /* @(#)if_qe.c 1.0 (2.11BSD) 11/16/90 */ ! /* @(#)if_qe.c 7.1 (Berkeley) 6/5/86 */ ! ! /* from @(#)if_qe.c 1.15 (ULTRIX) 4/16/86 */ - /**************************************************************** * * * Licensed from Digital Equipment Corporation * --- 1,5 ---- ! /* @(#)if_qe.c 1.1 (2.11BSD) 12/28/92 */ /**************************************************************** * * * Licensed from Digital Equipment Corporation * *************** *** 101,107 **** * 13 Feb. 84 -- rjl * * Initial version of driver. derived from IL driver. - * * --------------------------------------------------------------------- */ --- 97,102 ---- *************** *** 113,118 **** --- 108,114 ---- #include "param.h" #include "pdp/seg.h" + #include "pdp/psl.h" #include "map.h" #include "systm.h" #include "mbuf.h" *************** *** 212,225 **** #define MAXPACKETSIZE 2048 /* Should really be ETHERMTU */ /* ! * The autoconfigure scheme presently used doesn't work terribly well with ! * programmable vector devices - MAKE SURE the value below does not conflict ! * with anything else in the system. The following location can be ! * adb'd as a stopgap until a new kernel can be rebuilt. */ ! #define QEVEC 0400 ! short QEvec = QEVEC; /* Patchable vector */ /* * Interface exists: make available by filling in network interface --- 208,222 ---- #define MAXPACKETSIZE 2048 /* Should really be ETHERMTU */ /* ! * The C compiler's propensity for prepending '_'s to names is the reason ! * for the routine below. We need the "handler" address (the code which ! * sets up the interrupt stack frame) in order to initialize the vector. */ ! static int qefoo() ! { ! asm("mov $qeintr, r0"); /* return value is in r0 */ ! } /* * Interface exists: make available by filling in network interface *************** *** 231,238 **** { register struct qe_softc *sc = &qe_softc[ui->ui_unit]; register struct ifnet *ifp = &sc->is_if; ! register struct qedevice *addr = (struct qedevice *)ui->ui_addr; register int i; ifp->if_unit = ui->ui_unit; ifp->if_name = "qe"; --- 228,236 ---- { register struct qe_softc *sc = &qe_softc[ui->ui_unit]; register struct ifnet *ifp = &sc->is_if; ! struct qedevice *addr = (struct qedevice *)ui->ui_addr; register int i; + extern int nextiv(); ifp->if_unit = ui->ui_unit; ifp->if_name = "qe"; *************** *** 242,254 **** /* * Read the address from the prom and save it. */ ! for( i=0 ; i<6 ; i++ ) sc->setup_pkt[i][1] = sc->is_addr[i] = addr->qe_sta_addr[i] & 0xff; /* ! * Save the vector for initialization at reset time. */ ! sc->qe_intvec = QEvec + (4 * ui->ui_unit); /* * map the communications area onto the device --- 240,257 ---- /* * Read the address from the prom and save it. */ ! for ( i=0 ; i<6 ; i++ ) sc->setup_pkt[i][1] = sc->is_addr[i] = addr->qe_sta_addr[i] & 0xff; /* ! * Allocate a floating vector and initialize it with the address of ! * the interrupt handler and PSW (supervisor mode, priority 4, unit ! * number in the low bits. */ ! i = SKcall(nextiv, 0); ! sc->qe_intvec = i; ! mtkd(i, qefoo()); ! mtkd(i+2, PSL_CURSUP | PSL_BR4 | ifp->if_unit); /* * map the communications area onto the device *************** *** 903,908 **** --- 906,912 ---- register i; addr->qe_csr = QE_RESET; + addr->qe_csr &= ~QE_RESET; sc->timeout = 0; qesetup( sc ); for (i = 0, rp = sc->tring; i < NXMT; rp++, i++) { *** /usr/src/sys/pdpif/if_qt.c.old Tue Oct 13 20:38:56 1992 --- /usr/src/sys/pdpif/if_qt.c Mon Dec 28 14:25:41 1992 *************** *** 0 **** --- 1,853 ---- + /* @(#)if_qt.c 1.1 (2.11BSD) 10/23/92 + * + * Modification History + * 28-Dec-92 -- sms + * Still not released. Hiatus in finding free time and thin-netting + * the systems (many thanks Terry!). + * Added logic to dynamically allocate a vector and initialize it. + * + * 23-Oct-92 -- sms + * The INIT block must (apparently) be quadword aligned [no thanks to + * the manual for not mentioning that fact]. The necessary alignment + * is achieved by allocating the INIT block from main memory ('malloc' + * guarantees click alignment) and mapping it as needed (which is _very_ + * infrequently). A check for quadword alignment of the ring descriptors + * was added - at present the descriptors are properly aligned, if this + * should change then something will have to be done (like do it "right"). + * Darned alignment restrictions! + * + * A couple of typos were corrected (missing parentheses, reversed + * arguments to printf calls, etc). + * + * 13-Oct-92 -- sms@wlv.iipo.gtegsc.com + * Created based on the DELQA-PLUS addendum to DELQA User's Guide. + * This driver ('qt') is selected at system configuration time. If the + * board * is not a DELQA-YM an error message will be printed and the + * interface will not be attached. + */ + + #include "qt.h" + #if NQT > 0 + + #include "param.h" + #include "pdp/psl.h" + #include "pdp/seg.h" + #include "map.h" + #include "systm.h" + #include "mbuf.h" + #include "buf.h" + #include "protosw.h" + #include "socket.h" + #include "ioctl.h" + #include "errno.h" + #include "syslog.h" + #include "time.h" + #include "kernel.h" + + #include "../net/if.h" + #include "../net/netisr.h" + #include "../net/route.h" + + #ifdef INET + #include "domain.h" + #include "../netinet/in.h" + #include "../netinet/in_systm.h" + #include "../netinet/in_var.h" + #include "../netinet/ip.h" + #include "../netinet/if_ether.h" + #endif + + #ifdef NS + #include "../netns/ns.h" + #include "../netns/ns_if.h" + #endif + + #include "if_qtreg.h" + #include "if_uba.h" + #include "../pdpuba/ubavar.h" + + #define NRCV 16 /* Receive descriptors (must be <= 32) */ + #define NXMT 6 /* Transmit descriptors (must be <= 12) */ + + struct qt_softc { + struct arpcom is_ac; /* common part - must be first */ + #define is_if is_ac.ac_if /* network-visible interface */ + #define is_addr is_ac.ac_enaddr /* hardware Ethernet address */ + struct ifuba qt_ifr[NRCV]; /* receive buffers descriptors */ + struct ifuba qt_ifw[NXMT]; /* xmit buffers descriptors */ + u_short initclick; /* click addr of the INIT block */ + struct qt_rring *rring; /* Receive ring address */ + struct qt_tring *tring; /* Transmit ring address */ + char r_align[32 * sizeof (struct qt_rring) + 8]; + char t_align[12 * sizeof (struct qt_tring) + 8]; + short qt_flags; /* software state */ + #define QTF_RUNNING 0x1 + #define QTF_STARTUP 0x2 /* Waiting for start interrupt */ + char rindex; /* Receive index */ + char tindex; /* Transmit index */ + char otindex; /* Old transmit index */ + char nxmit; /* # of xmits in progress */ + struct qtdevice *addr; /* device CSR addr */ + } qt_softc[NQT]; + + struct uba_device *qtinfo[NQT]; + + int qtattach(), qtintr(), qtinit(), qtoutput(), qtioctl(); + + extern struct ifnet loif; + + u_short qtstd[] = { 0 }; + + struct uba_driver qtdriver = + { 0, 0, qtattach, 0, qtstd, "qe", qtinfo }; + + /* + * Maximum packet size needs to include 4 bytes for the CRC + * on received packets. + */ + #define MAXPACKETSIZE (ETHERMTU + sizeof (struct ether_header) + 4) + #define MINPACKETSIZE 64 + + /* + * The C compiler's propensity for prepending '_'s to names is the reason + * for the hack below. We need the "handler" address (the code which + * sets up the interrupt stack frame) in order to initialize the vector. + */ + + static int qtfoo() + { + asm("mov $qtintr, r0"); /* return value is in r0 */ + } + + /* + * Interface exists. More accurately, something exists at the CSR (see + * sys/sys_net.c) -- there's no guarantee it's a DELQA-YM. + * + * The ring descriptors are initialized, the buffers allocated using first the + * DMA region allocated at network load time and then later main memory. The + * INIT block is filled in and the device is poked/probed to see if it really + * is a DELQA-YM. If the device is not a -YM then a message is printed and + * the 'if_attach' call is skipped. For a -YM the START command is issued, + * but the device is not marked as running|up - that happens at interrupt level + * when the device interrupts to say it has started. + */ + + qtattach(ui) + struct uba_device *ui; + { + register struct qt_softc *sc = &qt_softc[ui->ui_unit]; + register struct ifnet *ifp = &sc->is_if; + register struct qt_init *iniblk = (struct qt_init *)SEG5; + segm seg5; + long rxbuf_adr, txbuf_adr; + extern int nextiv(); + + ifp->if_unit = ui->ui_unit; + ifp->if_name = "qe"; + ifp->if_mtu = ETHERMTU; + ifp->if_flags = IFF_BROADCAST; + + /* + * Fill in most of the INIT block: vector, options (interrupt enable), ring + * locations. The physical address is copied from the ROMs as part of the + * -YM testing proceedure. The CSR is saved here rather than in qtinit() + * because the qtturbo() routine needs it. + * + * The INIT block must be quadword aligned. Using malloc() guarantees click + * (64 byte) alignment. Since the only time the INIT block is referenced is + * at 'startup' or 'reset' time there is really no time penalty (and a modest + * D space savings) involved. + */ + sc->addr = (struct qtdevice *)ui->ui_addr; + sc->initclick = MALLOC(coremap, btoc(sizeof (struct qt_init))); + saveseg5(seg5); + mapseg5(sc->initclick, 077406); + bzero(iniblk, sizeof (struct qt_init)); + sc->rring = (struct qt_rring *)(((int)sc->r_align + 7) & ~7); + sc->tring = (struct qt_tring *)(((int)sc->t_align + 7) & ~7); + + /* + * Fetch the next available interrupt vector. The routine is in the kernel + * (for several reasons) so use SKcall. Then initialize the vector with + * the address of our 'handler' and PSW of supervisor, priority 4 and unit + */ + iniblk->vector = SKcall(nextiv, 0); + mtkd(iniblk->vector, qtfoo()); + mtkd(iniblk->vector + 2, PSL_CURSUP | PSL_BR4 | ifp->if_unit); + + iniblk->options = INIT_OPTIONS_INT; + rxbuf_adr = startnet + (long)sc->rring; + iniblk->rx_lo = loint(rxbuf_adr); + iniblk->rx_hi = hiint(rxbuf_adr); + txbuf_adr = startnet + (long)sc->tring; + iniblk->tx_lo = loint(txbuf_adr); + iniblk->tx_hi = hiint(txbuf_adr); + restorseg5(seg5); + + /* + * Now allocate the buffers and initialize the buffers. This should _never_ + * fail because main memory is allocated after the DMA pool is used up. + */ + + if (!qbaini(sc->qt_ifr, NRCV) || !qbaini(sc->qt_ifw, NXMT)) + return; /* XXX */ + + ifp->if_init = qtinit; + ifp->if_output = qtoutput; + ifp->if_ioctl = qtioctl; + ifp->if_reset = 0; + if (qtturbo(sc)) + if_attach(ifp); + } + + qtturbo(sc) + register struct qt_softc *sc; + { + register int i; + register struct qtdevice *addr = sc->addr; + struct qt_init *iniblk = (struct qt_init *)SEG5; + segm seg5; + + /* + * Issue the software reset. Delay 150us. The board should now be in + * DELQA-Normal mode. Set ITB and DEQTA select. If both bits do not + * stay turned on then the board is not a DELQA-YM. + */ + addr->arqr = ARQR_SR; + addr->arqr = 0; + delay(150L); + + addr->srr = 0x8001; /* MS | ITB */ + i = addr->srr; + addr->srr = 0x8000; /* Turn off ITB, set DELQA select */ + if (i != 0x8001) + { + printf("qt@%o !DELQA-YM\n", addr); + return(0); + } + /* + * Board is a DELQA-YM. Send the commands to enable Turbo mode. Delay + * 1 second, testing the SRR register every millisecond to see if the + * board has shifted to Turbo mode. + */ + addr->xcr0 = 0x0baf; + addr->xcr1 = 0xff00; + for (i = 0; i < 1000; i++) + { + if ((addr->srr & SRR_RESP) == 1) + break; + delay(1000L); + } + if (i >= 1000) + { + printf("qt@%o !Turbo mode\n", addr); + return(0); + } + /* + * Board has entered Turbo mode. Now copy the physical address from the + * ROMs to the INIT block paying attention to the screwy byte order. + * Also fill in the address in the part of the structure "visible" to the + * rest of the system. + */ + saveseg5(seg5); + mapseg5(sc->initclick, 077406); + + sc->is_addr[0] = addr->sarom[0]; + sc->is_addr[1] = addr->sarom[2]; + sc->is_addr[2] = addr->sarom[4]; + sc->is_addr[3] = addr->sarom[6]; + sc->is_addr[4] = addr->sarom[8]; + sc->is_addr[5] = addr->sarom[10]; + + /* #define giggles 1 */ + #ifdef giggles + bcopy(sc->is_addr, iniblk->paddr, 6); + #else + iniblk->paddr[0] = addr->sarom[2]; + iniblk->paddr[1] = addr->sarom[0]; + iniblk->paddr[2] = addr->sarom[6]; + iniblk->paddr[3] = addr->sarom[4]; + iniblk->paddr[4] = addr->sarom[10]; + iniblk->paddr[5] = addr->sarom[8]; + #endif + + printf("%s\n", ether_sprintf(sc->is_addr)); + restorseg5(seg5); + return(1); + } + + qtinit(unit) + int unit; + { + int s; + struct uba_device *ui = qtinfo[unit]; + register struct qt_softc *sc = &qt_softc[unit]; + register struct qtdevice *addr = (struct qtdevice *)ui->ui_addr; + struct ifnet *ifp = &sc->is_if; + struct qt_rring *rp; + register int i; + long buf_adr; + + if (!ifp->if_addrlist) /* oops! */ + return; + /* + * Now initialize the receive ring descriptors. The board supports up to + * 32 buffers being handed to it. The driver only hands NRCV buffers to + * device by leaving (32 - NRCV) ring descriptors owned by the driver. + */ + bzero(sc->r_align, sizeof (sc->r_align)); + for (i = 0; i < 32; i++) + { + rp = &sc->rring[i]; + if (i >= NRCV) + { + rp->rmd3 = RMD3_OWN; + continue; + } + rp->rmd1 = MAXPACKETSIZE; + rp->rmd4 = loint(sc->qt_ifr[i].ifu_r.ifrw_info); + rp->rmd5 = hiint(sc->qt_ifr[i].ifu_r.ifrw_info); + } + /* + * Now initialize the transmit ring descriptors. The driver owns all of them, + * but will only use NXMT later on. Clear the count of current xmits + * outstanding and the index of the next buffer to use. + */ + bzero(sc->t_align, sizeof (sc->t_align)); + for (i = 0 ; i < 12; i++) + sc->tring[i].tmd3 = TMD3_OWN; + + sc->nxmit = 0; + sc->otindex = 0; + sc->tindex = 0; + sc->rindex = 0; + + s = splimp(); + /* + * Now we tell the device the address of the INIT block. The device + * _must_ be in the Turbo mode at this time. The "START" command is + * then issued to the device. A 1 second timeout is then started. + * When the interrupt occurs the IFF_UP|IFF_RUNNING state is entered and + * full operations will proceed. If the timeout expires without an interrupt + * being received an error is printed, the flags cleared and the device left + * marked down. + */ + buf_adr = ctob((long)sc->initclick); + addr->ibal = loint(buf_adr); + addr->ibah = hiint(buf_adr); + addr->srqr = 02 & SRQR_REQ; + + /* + * read the immediate status. If there is an error print a message and + * leave the device marked down. If the device has response is "started" + * then set the device state as up and running. If no error and the device + * is not "started" then start a one second timer. The timer is set to + * enter the interrupt service routine because the ISR has the necessary + * logic to check the status and enable the device. + */ + i = addr->srr; + if (i < 0) + qtsrr(unit, i); + else + { + if ((i & SRR_RESP) == 2) + qt_up(sc); + else + { + sc->qt_flags = QTF_STARTUP; + TIMEOUT(qtintr, unit, 60); + } + } + splx(s); + } + + /* + * Mark the device up and running in both the internal and external flags. + * Tell the device that receive buffers are available. + */ + + qt_up(sc) + register struct qt_softc *sc; + { + register struct qtdevice *addr = sc->addr; + + sc->qt_flags = QTF_RUNNING; + sc->is_if.if_flags |= (IFF_UP | IFF_RUNNING); + addr->arqr = ARQR_RRQ; + } + + /* + * Start output on interface. + */ + + qtstart(unit) + int unit; + { + int len, s; + struct uba_device *ui = qtinfo[unit]; + register struct qt_softc *sc = &qt_softc[unit]; + register struct qt_tring *rp; + register int index; + struct mbuf *m; + long buf_addr; + + s = splimp(); + for (index = sc->tindex; sc->nxmit < NXMT ; ) + { + IF_DEQUEUE(&sc->is_if.if_snd, m); + if (m == 0) + break; + rp = &sc->tring[index]; + if ((rp->tmd3 & TMD3_OWN) == 0) + printf("qt xmit in progress\n"); + buf_addr = sc->qt_ifw[index].ifu_w.ifrw_info; + len = if_wubaput(&sc->qt_ifw[index], m); + if (len < MINPACKETSIZE) + len = MINPACKETSIZE; + rp->tmd4 = loint(buf_addr); + rp->tmd5 = hiint(buf_addr) & TMD5_HADR; + rp->tmd3 = len & TMD3_BCT; /* set length,clear ownership */ + sc->addr->arqr = ARQR_TRQ; /* tell device it has buffer */ + printf("\nlen %d\n", len); + sc->nxmit++; + if (++index >= NXMT) + index = 0; + sc->tindex = index; + } + splx(s); + } + + /* + * General interrupt service routine. Receive, transmit, device start + * interrupts and timeouts come here. Check for hard device errors and print a + * message if any errors are found. If we are waiting for the device to + * START then check if the device is now running - if it is running/started + * then tell the device it has receive and transmit buffers and mark the + * interface up&running. + */ + + qtintr(unit) + int unit; + { + register struct qt_softc *sc = &qt_softc[unit]; + register int status; + int s; + + s = splimp(); + status = sc->addr->srr; + if (status < 0) + { + /* should we reset the device after a bunch of these errs? */ + qtsrr(unit, status); + } + if (sc->qt_flags == QTF_STARTUP) + { + if ((status & SRR_RESP) == 2) + qt_up(sc); + else + printf("qt%d !start\n", unit); + WAKEUP(sc); + } + qtrint(unit); + if (sc->nxmit) + qttint(unit); + qtstart(unit); + splx(s); + } + + /* + * Transmit interrupt service. Only called if there are outstanding transmit + * requests which could have completed. The DELQA-YM doesn't provide the + * status bits telling the kind (receive, transmit) of interrupt. + */ + + #define BBLMIS (TMD2_BBL|TMD2_MIS) + + qttint(unit) + int unit; + { + register struct qt_softc *sc = &qt_softc[unit]; + register struct qt_tring *rp; + + while (sc->nxmit > 0) + { + rp = &sc->tring[sc->otindex]; + if ((rp->tmd3 & TMD3_OWN) == 0) + break; + sc->nxmit--; + sc->is_if.if_opackets++; + /* + * Collisions don't count as output errors, but babbling and missing packets + * do count as output errors. + */ + if (rp->tmd2 & TMD2_CER) + sc->is_if.if_collisions++; + if ((rp->tmd0 & TMD0_ERR1) || + ((rp->tmd2 & TMD2_ERR2) && (rp->tmd2 & BBLMIS))) + { + /* #ifdef notnow */ + printf("qt%d tmd2 %b\n", unit, rp->tmd2, TMD2_BITS); + /* #endif */ + sc->is_if.if_oerrors++; + } + if (++sc->otindex >= NXMT) + sc->otindex = 0; + } + } + + /* + * Receive interrupt service. Pull packet off the interface and put into + * a mbuf chain for processing later. + */ + + qtrint(unit) + int unit; + { + register struct qt_softc *sc = &qt_softc[unit]; + register struct qt_rring *rp; + int len; + long bufaddr; + + printf("\nin qtrint() \n"); + while (sc->rring[sc->rindex].rmd3 & RMD3_OWN) + { + printf("\nowned buffer \n"); + rp = &sc->rring[sc->rindex]; + if ((rp->rmd0 & (RMD0_STP|RMD0_ENP)) != (RMD0_STP|RMD0_ENP)) + { + printf("qt%d chained packet\n", unit); + sc->is_if.if_ierrors++; + goto backtoring; + } + len = (rp->rmd1 & RMD1_MCNT) - 4; /* -4 for CRC */ + sc->is_if.if_ipackets++; + + if ((rp->rmd0 & RMD0_ERR3) || (rp->rmd2 & RMD2_ERR4)) + { + sc->is_if.if_ierrors++; + /* #ifdef notnow */ + printf("qt%d rmd0 %b\n", unit, rp->rmd0, RMD0_BITS); + printf("qt%d rmd2 %b\n", unit, rp->rmd2, RMD2_BITS); + /* #endif */ + } + else + qtread(sc, &sc->qt_ifr[sc->rindex], + len - sizeof (struct ether_header)); + backtoring: + bufaddr = sc->qt_ifr[sc->rindex].ifu_r.ifrw_info; + rp->rmd1 = MAXPACKETSIZE; + rp->rmd4 = loint(bufaddr); + rp->rmd5 = hiint(bufaddr); + rp->rmd3 = 0; /* clear RMD3_OWN */ + sc->addr->arqr = ARQR_RRQ; /* tell device it has buffer */ + if (++sc->rindex >= NRCV) + sc->rindex = 0; + } + } + + /* + * Place data on the appropriate queue and call the start routine to + * send the data to the device. + */ + + qtoutput(ifp, m0, dst) + struct ifnet *ifp; + struct mbuf *m0; + struct sockaddr *dst; + { + int type, s, trail; + u_char edst[6]; + struct in_addr idst; + register struct ether_header *eh; + register struct qt_softc *is = &qt_softc[ifp->if_unit]; + register struct mbuf *m = m0; + struct mbuf *mcopy = (struct mbuf *)0; + + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) + { + m_freem(m0); + return(ENETDOWN); + } + switch (dst->sa_family) + { + #ifdef INET + case AF_INET: + idst = ((struct sockaddr_in *)dst)->sin_addr; + if (!arpresolve(&is->is_ac, m, &idst, edst,&trail)) + return(0); /* wait for arp to finish */ + if (!bcmp(edst, etherbroadcastaddr,sizeof (edst))) + mcopy = m_copy(m, 0, (int)M_COPYALL); + type = ETHERTYPE_IP; + break; + #endif + #ifdef NS + case AF_NS: + type = ETHERTYPE_NS; + bcopy(&(((struct sockaddr_ns *)dst)->sns_addr.x_host), + edst, sizeof (edst)); + if (!bcmp(edst, &ns_broadcast, sizeof (edst))) + return(looutput(&loif, m, dst)); + break; + #endif + case AF_UNSPEC: + eh = (struct ether_header *)dst->sa_data; + bcopy(eh->ether_dhost, (caddr_t)edst, sizeof (edst)); + type = eh->ether_type; + break; + default: + printf("qt%d can't handle af%d\n", ifp->if_unit, + dst->sa_family); + m_freem(m); + return(EAFNOSUPPORT); + } + /* + * Add local net header. If no space in first mbuf, allocate another. + */ + if (m->m_off > MMAXOFF || + MMINOFF + sizeof (struct ether_header) > m->m_off) + { + m = m_get(M_DONTWAIT, MT_HEADER); + if (m == 0) + { + m_freem(m0); + nobufs: if (mcopy) + m_freem(mcopy); + return(ENOBUFS); + } + m->m_next = m0; + m->m_off = MMINOFF; + m->m_len = sizeof (struct ether_header); + } + else + { + m->m_off -= sizeof (struct ether_header); + m->m_len += sizeof (struct ether_header); + } + eh = mtod(m, struct ether_header *); + eh->ether_type = htons((u_short)type); + bcopy(edst, (caddr_t)eh->ether_dhost, sizeof (edst)); + bcopy(is->is_addr, (caddr_t)eh->ether_shost, sizeof (is->is_addr)); + + s = splimp(); + if (IF_QFULL(&ifp->if_snd)) + { + IF_DROP(&ifp->if_snd); + m_freem(m); + splx(s); + goto nobufs; + } + IF_ENQUEUE(&ifp->if_snd, m); + qtstart(ifp->if_unit); + splx(s); + return(mcopy ? looutput(&loif, mcopy, dst) : 0); + } + + + qtioctl(ifp, cmd, data) + register struct ifnet *ifp; + int cmd; + caddr_t data; + { + struct qt_softc *sc = &qt_softc[ifp->if_unit]; + struct ifaddr *ifa = (struct ifaddr *)data; + int s = splimp(), error = 0; + #ifdef NS + register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); + #endif + + switch (cmd) + { + case SIOCSIFADDR: + /* + * Resetting the board is probably overkill, but then again this is only + * done when the system comes up _and_ when a reset is needed after a + * major network fault (open wire, etc). + */ + if (error = qtrestart(sc)) + break; + switch (ifa->ifa_addr.sa_family) + { + #ifdef INET + case AF_INET: + ((struct arpcom *)ifp)->ac_ipaddr = + IA_SIN(ifa)->sin_addr; + arpwhohas(ifp, &IA_SIN(ifa)->sin_addr); + break; + #endif + #ifdef NS + case AF_NS: + if (ns_nullhost(*ina)) + ina->x_host = + *(union ns_host *)(sc->is_addr); + else + { + qt_ns(ina->x_host.c_host); + error = qtrestart(sc); + } + break; + #endif + } + break; + case SIOCSIFFLAGS: + if ((ifp->if_flags & IFF_UP) == 0 && + sc->qt_flags & QTF_RUNNING) + { + /* + * We've been asked to stop the board and leave it that way. qtturbo() + * does this with the side effect of placing the device back in Turbo mode. + */ + qtturbo(sc); + sc->qt_flags &= ~QTF_RUNNING; + } + else if (ifp->if_flags & IFF_UP && + !(sc->qt_flags & QTF_RUNNING)) + qtrestart(sc); + break; + default: + error = EINVAL; + } + splx(s); + return(error); + } + + #ifdef NS + qt_ns(cp) + register char *cp; + { + segm seg5; + register struct qt_init *iniblk = (struct qt_init *)SEG5; + + saveseg5(seg5); + mapseg5(sc->initclick, 077406); + bcopy(cp, sc->is_addr, 6); + iniblk->paddr[0] = cp[1]; + iniblk->paddr[1] = cp[0]; + iniblk->paddr[2] = cp[3]; + iniblk->paddr[3] = cp[2]; + iniblk->paddr[4] = cp[5]; + iniblk->paddr[5] = cp[4]; + restorseg5(seg5); + } + #endif + + /* + * Pull the data off of the board and pass back to the upper layers of + * the networking code. Trailers are counted as errors and the packet + * dropped. SEG5 is saved and restored (used to peek at the packet type). + */ + + qtread(sc, ifuba, len) + register struct qt_softc *sc; + struct ifuba *ifuba; + int len; + { + struct ether_header *eh; + struct mbuf *m; + struct ifqueue *inq; + register int type; + segm seg5; + + saveseg5(seg5); + mapseg5(ifuba->ifu_r.ifrw_click, 077406); + eh = (struct ether_header *)SEG5; + eh->ether_type = ntohs((u_short)eh->ether_type); + type = eh->ether_type; + restorseg5(seg5); + if (len == 0 || type >= ETHERTYPE_TRAIL && + type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) + { + sc->is_if.if_ierrors++; + return; + } + + m = if_rubaget(ifuba, len, 0, &sc->is_if); + if (m == 0) + return; + + switch (type) + { + #ifdef INET + case ETHERTYPE_IP: + schednetisr(NETISR_IP); + inq = &ipintrq; + break; + case ETHERTYPE_ARP: + arpinput(&sc->is_ac, m); + return; + #endif + #ifdef NS + case ETHERTYPE_NS: + schednetisr(NETISR_NS); + inq = &nsintrq; + break; + #endif + default: + m_freem(m); + return; + } + + if (IF_QFULL(inq)) + { + IF_DROP(inq); + m_freem(m); + return; + } + IF_ENQUEUE(inq, m); + } + + + qtsrr(unit, srrbits) + int unit, srrbits; + { + printf("qt%d srr=%b\n", unit, srrbits, SRR_BITS); + } + + /* + * Reset the device. This moves it from DELQA-T mode to DELQA-Normal mode. + * After the reset put the device back in -T mode. Then call qtinit() to + * reinitialize the ring structures and issue the 'timeout' for the "device + * started interrupt". This routine waits for the 'wakeup' call done in + * either the interrupt service routine (or the timeout routine). + */ + + qtrestart(sc) + register struct qt_softc *sc; + { + register struct qtdevice *addr = sc->addr; + + qtturbo(sc); + qtinit(sc - qt_softc); + while (sc->qt_flags == QTF_STARTUP) + SLEEP(sc, PZERO - 1); + if ((sc->qt_flags & QTF_RUNNING) == 0) + return(ENETDOWN); + return(0); + } + + qbaini(ifuba, num) + struct ifuba *ifuba; + int num; + { + register int i; + register memaddr click; + + for (i = 0; i < num; i++) + { + click = m_ioget(MAXPACKETSIZE); + if (click == 0) + { + click = MALLOC(coremap, btoc(MAXPACKETSIZE)); + if (click == 0) + { + printf("qt !memory\n"); + return(0); + } + } + ifuba[i].ifu_hlen = sizeof (struct ether_header); + ifuba[i].ifu_w.ifrw_click = ifuba[i].ifu_r.ifrw_click = click; + ifuba[i].ifu_w.ifrw_info = ifuba[i].ifu_r.ifrw_info = + ctob((long)click); + } + return(1); + } + #endif *** /usr/src/sys/pdpif/if_qtreg.h.old Mon Oct 12 21:26:30 1992 --- /usr/src/sys/pdpif/if_qtreg.h Thu Oct 29 21:25:52 1992 *************** *** 0 **** --- 1,176 ---- + /* @(#)if_qtreg.h 1.0 (GTE) 10/12/92 */ + + /* + * Modification History + * + * 12 Oct 92 -- Steven M. Schultz (sms1) + * Created from the DELQA-PLUS Addendum to the DELQA User's Guide. + */ + + /* Receive ring descriptor and bit/field definitions */ + + struct qt_rring + { + short rmd0; + short rmd1; + short rmd2; + short rmd3; + short rmd4; + short rmd5; + short rhost0; + short rhost1; + }; + + #define RMD0_ERR3 0x4000 /* Error summary. FRA|CRC|OFL|BUF */ + #define RMD0_FRA 0x2000 /* Framing error */ + #define RMD0_OFL 0x1000 /* Overflow error. Oversized packet */ + #define RMD0_CRC 0x0800 /* CRC error */ + #define RMD0_BUF 0x0400 /* Internal device buffer error */ + #define RMD0_STP 0x0200 /* Start of packet */ + #define RMD0_ENP 0x0100 /* End of packet */ + + #define RMD1_MCNT 0x0fff /* Message byte count */ + + #define RMD2_ERR4 0x8000 /* Error summary. BBL|CER|MIS */ + #define RMD2_BBL 0x4000 /* Babble error on transmit */ + #define RMD2_CER 0x2000 /* Collision error on transmit */ + #define RMD2_MIS 0x1000 /* Packet lost on receive */ + #define RMD2_EOR 0x0800 /* End of receive ring */ + #define RMD2_RON 0x0020 /* Receiver on */ + #define RMD2_TON 0x0010 /* Transmitter on */ + + #define RMD3_OWN 0x8000 /* Ownership field. */ + + #define RMD4_LADR 0xfff8 /* Octabyte aligned low address bits */ + + #define RMD5_HADR 0x003f /* High 6 bits of buffer address */ + + #define RMD0_BITS "\010\016FRA\015OFL\014CRC\013BUF\012STP\011ENP" + #define RMD2_BITS "\010\017BBL\014CER\013MIS\012EOR\06RON\05TON" + + /* Transmit ring descriptor and bit/field definitions */ + + struct qt_tring + { + short tmd0; + short tmd1; + short tmd2; + short tmd3; + short tmd4; + short tmd5; + short thost0; + short thost1; + }; + + #define TMD0_ERR1 0x4000 /* Error summary. LCO|LCA|RTR */ + #define TMD0_MOR 0x1000 /* More than one retry on transmit */ + #define TMD0_ONE 0x0800 /* One retry on transmit */ + #define TMD0_DEF 0x0400 /* Deferral during transmit */ + + #define TMD1_LCO 0x1000 /* Late collision on transmit */ + #define TMD1_LCA 0x0800 /* Loss of carrier on transmit */ + #define TMD1_RTR 0x0400 /* Retry error on transmit */ + #define TMD1_TDR 0x03ff /* Time Domain Reflectometry value */ + + #define TMD2_ERR2 0x8000 /* Error summary. BBL|CER|MIS */ + #define TMD2_BBL 0x4000 /* Babble error on transmit */ + #define TMD2_CER 0x2000 /* Collision error on transmit */ + #define TMD2_MIS 0x1000 /* Packet lost on receive */ + #define TMD2_EOR 0x0800 /* Endof Receive ring reached */ + #define TMD2_RON 0x0020 /* Receiver on */ + #define TMD2_TON 0x0010 /* Transmitter on */ + + #define TMD3_OWN 0x8000 /* Ownership field */ + #define TMD3_FOT 0x4000 /* First of two flag */ + #define TMD3_BCT 0x0fff /* Byte count */ + + #define TMD4_LADR 0xfff8 /* Octabyte aligned low address bits */ + + #define TMD5_HADR 0x003f /* High 6 bits of buffer address */ + + #define TMD1_BITS "\010\015LCO\014LCA\013RTR" + #define TMD2_BITS "\010\017BBL\016CER\015MIS\014EOR\06RON\05TON" + + /* DELQA-YM CSR layout */ + + struct qtcsr0 + { + short Ibal; + short Ibah; + short Icr; + short pad0; + short Srqr; + short pad1; + }; + + struct qtdevice + { + union { + u_char Sarom[12]; + struct qtcsr0 csr0; + } qt_un0; + short srr; + short arqr; + }; + + #define ibal qt_un0.csr0.Ibal + #define ibah qt_un0.csr0.Ibah + #define srqr qt_un0.csr0.Srqr + #define icr qt_un0.csr0.Icr + #define sarom qt_un0.Sarom + + /* SRR definitions */ + + #define SRR_FES 0x8000 + #define SRR_CHN 0x4000 + #define SRR_NXM 0x1000 + #define SRR_PER 0x0800 + #define SRR_IME 0x0400 + #define SRR_TBL 0x0200 + #define SRR_RESP 0x0003 + #define SRR_BITS "\010\017CHN\015NXM\014PER\013IME\012TBL" + + /* SRQR definitions */ + + #define SRQR_REQ 0x0003 + + /* ARQR definitions */ + + #define ARQR_TRQ 0x8000 + #define ARQR_RRQ 0x0080 + #define ARQR_SR 0x0002 + + /* define ICR definitions */ + + #define ICR_CMD 0x0001 + + /* DELQA registers used to shift into -T mode */ + + #define xcr0 qt_un0.csr0.Ibal + #define xcr1 qt_un0.csr0.Ibah + + /* INIT block structure and definitions */ + + struct qt_init + { + short mode; + u_char paddr[6]; /* 48 bit physical address */ + u_char laddr[8]; /* 64 bit logical address filter */ + u_short rx_lo; /* low 16 bits of receive ring addr */ + u_short rx_hi; /* high 6 bits of receive ring addr */ + u_short tx_lo; /* low 16 bits of transmit ring addr */ + u_short tx_hi; /* high 6 bits of transmit ring addr */ + u_short options; + u_short vector; + u_short hit; + char passwd[6]; + }; + + #define INIT_MODE_PRO 0x8000 /* Promiscuous mode */ + #define INIT_MODE_INT 0x0040 /* Internal Loopback */ + #define INIT_MODE_DRT 0x0020 /* Disable Retry */ + #define INIT_MODE_DTC 0x0008 /* Disable Transmit CRC */ + #define INIT_MODE_LOP 0x0004 /* Loopback */ + + #define INIT_OPTIONS_HIT 0x0002 /* Host Inactivity Timeout Flag */ + #define INIT_OPTIONS_INT 0x0001 /* Interrupt Enable Flag */ *** /usr/src/sys/pdpif/if_uba.c.old Wed Dec 19 10:22:40 1990 --- /usr/src/sys/pdpif/if_uba.c Sun Jan 3 00:52:53 1993 *************** *** 176,182 **** if (!mfkd(&ubmap)) return(paddr); nregs = (int)btoub(size); ! first = NETUBAA(nregs); ubp = &UBMAP[first]; vaddr = (ubadr_t)first << 13; while (nregs--) { --- 176,190 ---- if (!mfkd(&ubmap)) return(paddr); nregs = (int)btoub(size); ! first = MALLOC(ub_map, nregs); ! #ifdef DIAGNOSTIC ! /* ! * Should never happen since this is only called by initialization routines ! * in the network drivers. ! */ ! if (!first) ! panic("uballoc"); ! #endif ubp = &UBMAP[first]; vaddr = (ubadr_t)first << 13; while (nregs--) { *** /usr/src/sys/pdpif/if_uba.h.old Tue Jul 5 16:37:10 1988 --- /usr/src/sys/pdpif/if_uba.h Thu Dec 24 17:20:47 1992 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)if_uba.h 1.1 (2.10BSD Berkeley) 12/1/86 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)if_uba.h 1.2 (2.11BSD GTE) 12/24/92 */ /* *************** *** 46,52 **** #ifdef SUPERVISOR struct mbuf *if_rubaget(); #endif ! #if defined(KERNEL) && defined(UCB_NET) #define ubarelse(a,b) #define useracc(a,c,m) (1) ubadr_t uballoc(), ubmalloc(); --- 46,52 ---- #ifdef SUPERVISOR struct mbuf *if_rubaget(); #endif ! #if defined(KERNEL) && defined(INET) #define ubarelse(a,b) #define useracc(a,c,m) (1) ubadr_t uballoc(), ubmalloc(); *** /usr/src/sys/netinet/tcp_var.h.old Thu Apr 28 16:13:27 1988 --- /usr/src/sys/netinet/tcp_var.h Thu Dec 24 12:02:50 1992 *************** *** 21,29 **** * - Van Jacobson (van@lbl-csam.arpa) */ ! #if sun || BSD < 43 ! #define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */ ! #endif #ifndef SB_MAX #ifdef SB_MAXCOUNT --- 21,29 ---- * - Van Jacobson (van@lbl-csam.arpa) */ ! #define TCP_COMPAT_42 /* _always_ set for 2.11BSD - not worth the trouble ! * of making it conditional ! */ #ifndef SB_MAX #ifdef SB_MAXCOUNT