diff -urN --exclude=compile --exclude=@ ../sys-altq/conf/files ./conf/files --- ../sys-altq/conf/files Wed Jan 12 15:45:57 2000 +++ ./conf/files Tue Mar 21 12:18:40 2000 @@ -97,7 +97,9 @@ dev/isp/isp.c optional isp device-driver #dev/dpt/dpt_control.c optional dpt device-driver dev/dpt/dpt_scsi.c optional dpt device-driver -dev/en/midway.c optional en device-driver +#dev/en/midway.c optional en device-driver +pci/midway.c optional en device-driver +pci/midway.c optional enp device-driver dev/hea/eni.c optional hea device-driver dev/hea/eni_buffer.c optional hea device-driver dev/hea/eni_globals.c optional hea device-driver diff -urN --exclude=compile --exclude=@ ../sys-altq/conf/options ./conf/options --- ../sys-altq/conf/options Wed Jan 12 15:45:57 2000 +++ ./conf/options Fri Feb 4 16:15:19 2000 @@ -223,6 +223,8 @@ CDNR opt_altq.h BLUE opt_altq.h ALTQ_DEBUG opt_altq.h +# mpls +LABEL_MODULE opt_label.h BOOTP opt_bootp.h BOOTP_COMPAT opt_bootp.h diff -urN --exclude=compile --exclude=@ ../sys-altq/i386/conf/ALTQ ./i386/conf/ALTQ --- ../sys-altq/i386/conf/ALTQ Thu Apr 6 13:11:13 2000 +++ ./i386/conf/ALTQ Thu Mar 23 15:12:58 2000 @@ -50,7 +50,6 @@ options NMBCLUSTERS=2048 options MROUTING # Multicast routing -#options NATM #native mode atm options ALTQ #alternate queueing options CBQ #class based queueing @@ -73,6 +72,9 @@ # especially with 100baseT options HZ=1000 +# MPLS support +options LABEL_MODULE + config kernel root on wd0 # To make an SMP kernel, the next two are needed @@ -182,7 +184,7 @@ device lpt0 at ppbus? # Printer device plip0 at ppbus? # TCP/IP over parallel device ppi0 at ppbus? # Parallel port interface device -#controller vpo0 at ppbus? # Requires scbus and da0 +controller vpo0 at ppbus? # Requires scbus and da0 # PCI Ethernet NICs. device al0 # ADMtek AL981 (``Comet'') @@ -199,6 +201,7 @@ device vx0 # 3Com 3c590, 3c595 (``Vortex'') device wb0 # Winbond W89C840F device xl0 # 3Com 3c90x (``Boomerang'', ``Cyclone'') +device ti0 # Gigabit Ethernet with Ateon Chip # ISA Ethernet NICs. # Order is important here due to intrusive probes, do *not* alphabetize @@ -236,3 +239,26 @@ # The number of devices determines the maximum number of # simultaneous BPF clients programs runnable. pseudo-device bpfilter 1 #Berkeley packet filter +# +# ATM related options +# +# The `en' device provides support for Efficient Networks (ENI) +# ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0). +# +# atm pseudo-device provides generic atm functions and is required for +# atm devices. +# NATM enables the netnatm protocol family that can be used to +# bypass TCP/IP. +# +# the current driver supports only PVC operations (no atm-arp, no multicast). +# for more details, please read the original documents at +# http://www.ccrc.wustl.edu/pub/chuck/bsdatm/wucs.html +# +pseudo-device atm +device en0 +device enp0 +options NATM +# +# Enable the kernel debugger. +# +options DDB diff -urN --exclude=compile --exclude=@ ../sys-altq/kern/kern_synch.c ./kern/kern_synch.c --- ../sys-altq/kern/kern_synch.c Wed Jan 12 15:47:28 2000 +++ ./kern/kern_synch.c Mon Mar 20 09:00:01 2000 @@ -384,8 +384,11 @@ struct callout_handle thandle; #ifdef KTRACE + if(p) + { if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 1, 0); + } #endif s = splhigh(); if (cold || panicstr) { @@ -449,8 +452,10 @@ p->p_flag &= ~P_TIMEOUT; if (sig == 0) { #ifdef KTRACE + if(p) { if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); + } #endif return (EWOULDBLOCK); } @@ -458,16 +463,20 @@ untimeout(endtsleep, (void *)p, thandle); if (catch && (sig != 0 || (sig = CURSIG(p)))) { #ifdef KTRACE + if(p) { if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); + } #endif if (p->p_sigacts->ps_sigintr & sigmask(sig)) return (EINTR); return (ERESTART); } #ifdef KTRACE +if(p) { if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); +} #endif return (0); } diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/Makefile ./modules/Makefile --- ../sys-altq/modules/Makefile Wed Jan 12 15:43:35 2000 +++ ./modules/Makefile Fri Feb 4 12:38:37 2000 @@ -13,5 +13,6 @@ .endif SUBDIR+=altq +SUBDIR+=label .include diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/.depend ./modules/label/.depend --- ../sys-altq/modules/label/.depend Wed Dec 31 19:00:00 1969 +++ ./modules/label/.depend Thu Apr 20 08:02:05 2000 @@ -0,0 +1,59 @@ +# -nostdinc -DLABEL -DLABEL_MODULE -DKERNEL -DKLD_MODULE -I- -I/usr/src/sys-mpls/modules/label -I/usr/src/sys-mpls/modules/label/@ /usr/src/sys-mpls/modules/label/../../netinet/label_table.c /usr/src/sys-mpls/modules/label/../../netinet/jenkinshash.c +label_table.o: \ + /usr/src/sys-mpls/modules/label/../../netinet/label_table.c \ + /usr/src/sys-mpls/modules/label/@/netinet/label_table.h \ + /usr/src/sys-mpls/modules/label/@/sys/param.h \ + /usr/src/sys-mpls/modules/label/@/sys/types.h \ + /usr/src/sys-mpls/modules/label/@/sys/cdefs.h \ + /usr/src/sys-mpls/modules/label/@/sys/inttypes.h \ + /usr/src/sys-mpls/modules/label/machine/ansi.h \ + /usr/src/sys-mpls/modules/label/machine/types.h \ + /usr/src/sys-mpls/modules/label/machine/endian.h \ + /usr/src/sys-mpls/modules/label/@/sys/syslimits.h \ + /usr/src/sys-mpls/modules/label/@/sys/errno.h \ + /usr/src/sys-mpls/modules/label/@/sys/time.h \ + /usr/src/sys-mpls/modules/label/machine/param.h \ + /usr/src/sys-mpls/modules/label/@/sys/malloc.h \ + /usr/src/sys-mpls/modules/label/@/sys/unistd.h \ + /usr/src/sys-mpls/modules/label/@/sys/_posix.h \ + /usr/src/sys-mpls/modules/label/@/sys/exec.h \ + /usr/src/sys-mpls/modules/label/machine/exec.h \ + /usr/src/sys-mpls/modules/label/@/sys/module.h \ + /usr/src/sys-mpls/modules/label/@/sys/conf.h \ + /usr/src/sys-mpls/modules/label/@/sys/mbuf.h \ + /usr/src/sys-mpls/modules/label/@/sys/sysent.h \ + /usr/src/sys-mpls/modules/label/@/sys/socket.h \ + /usr/src/sys-mpls/modules/label/@/sys/lkm.h \ + /usr/src/sys-mpls/modules/label/@/vm/vm.h \ + /usr/src/sys-mpls/modules/label/@/vm/vm_kern.h \ + /usr/src/sys-mpls/modules/label/@/vm/vm_extern.h \ + /usr/src/sys-mpls/modules/label/@/sys/systm.h \ + /usr/src/sys-mpls/modules/label/machine/cpufunc.h \ + /usr/src/sys-mpls/modules/label/@/sys/callout.h \ + /usr/src/sys-mpls/modules/label/@/sys/queue.h \ + /usr/src/sys-mpls/modules/label/@/sys/libkern.h \ + /usr/src/sys-mpls/modules/label/@/netinet/switch_ether.h \ + /usr/src/sys-mpls/modules/label/@/net/ethernet.h \ + /usr/src/sys-mpls/modules/label/@/netinet/lock_sleep.h \ + /usr/src/sys-mpls/modules/label/@/netinet/bitops.h \ + /usr/src/sys-mpls/modules/label/@/netinet/in.h \ + /usr/src/sys-mpls/modules/label/@/netinet/in_systm.h \ + /usr/src/sys-mpls/modules/label/@/netinet/ip.h \ + /usr/src/sys-mpls/modules/label/@/netinet/tcp.h \ + /usr/src/sys-mpls/modules/label/@/netinet/udp.h \ + /usr/src/sys-mpls/modules/label/@/net/if.h \ + /usr/src/sys-mpls/modules/label/@/net/if_var.h \ + /usr/src/sys-mpls/modules/label/@/net/if_altq.h \ + /usr/src/sys-mpls/modules/label/@/sys/kernel.h \ + /usr/src/sys-mpls/modules/label/@/sys/linker_set.h \ + /usr/src/sys-mpls/modules/label/@/sys/signal.h \ + /usr/src/sys-mpls/modules/label/machine/signal.h \ + /usr/src/sys-mpls/modules/label/machine/trap.h +jenkinshash.o: \ + /usr/src/sys-mpls/modules/label/../../netinet/jenkinshash.c \ + /usr/src/sys-mpls/modules/label/@/sys/types.h \ + /usr/src/sys-mpls/modules/label/@/sys/cdefs.h \ + /usr/src/sys-mpls/modules/label/@/sys/inttypes.h \ + /usr/src/sys-mpls/modules/label/machine/ansi.h \ + /usr/src/sys-mpls/modules/label/machine/types.h \ + /usr/src/sys-mpls/modules/label/machine/endian.h diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/Makefile ./modules/label/Makefile --- ../sys-altq/modules/label/Makefile Wed Dec 31 19:00:00 1969 +++ ./modules/label/Makefile Fri Feb 4 12:36:30 2000 @@ -0,0 +1,11 @@ +# $Id: Makefile,v 1.8 1997/09/10 04:19:07 peter Exp $ + +.PATH: ${.CURDIR}/../../netinet +KMOD= label +SRCS= label_table.c jenkinshash.c +NOMAN= +CFLAGS+= -DLABEL -DLABEL_MODULE + + +.include + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ansi.h ./modules/label/machine/ansi.h --- ../sys-altq/modules/label/machine/ansi.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ansi.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,123 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ansi.h 8.2 (Berkeley) 1/4/94 + * $FreeBSD: src/sys/i386/include/ansi.h,v 1.16.2.1 1999/08/29 16:06:16 peter Exp $ + */ + +#ifndef _MACHINE_ANSI_H_ +#define _MACHINE_ANSI_H_ + +/* + * Types which are fundamental to the implementation and must be declared + * in more than one standard header are defined here. Standard headers + * then use: + * #ifdef _BSD_SIZE_T_ + * typedef _BSD_SIZE_T_ size_t; + * #undef _BSD_SIZE_T_ + * #endif + */ +#define _BSD_CLOCK_T_ unsigned long /* clock()... */ +#define _BSD_CLOCKID_T_ int /* clock_gettime()... */ +#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ +#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */ +#define _BSD_SIZE_T_ unsigned int /* sizeof() */ +#define _BSD_SSIZE_T_ int /* byte count or error */ +#define _BSD_TIME_T_ long /* time()... */ +#define _BSD_TIMER_T_ int /* timer_gettime()... */ +#define _BSD_WCHAR_T_ _BSD_CT_RUNE_T_ /* wchar_t (see below) */ + +/* + * Types which are fundamental to the implementation and must be used + * in more than one standard header although they are only declared in + * one (perhaps nonstandard) header are defined here. Standard headers + * use _BSD_XXX_T_ without undef'ing it. + */ +#define _BSD_CT_RUNE_T_ int /* arg type for ctype funcs */ +#define _BSD_OFF_T_ __int64_t /* file offset */ +#define _BSD_PID_T_ int /* process [group] */ +#define _BSD_VA_LIST_ char * /* va_list */ + +/* + * The rune type is declared to be an ``int'' instead of the more natural + * ``unsigned long'' or ``long''. Two things are happening here. It is not + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, + * it looks like 10646 will be a 31 bit standard. This means that if your + * ints cannot hold 32 bits, you will be in trouble. The reason an int was + * chosen over a long is that the is*() and to*() routines take ints (says + * ANSI C), but they use _BSD_CT_RUNE_T_ instead of int. By changing it + * here, you lose a bit of ANSI conformance, but your programs will still + * work. + */ + +/* + * Frequencies of the clock ticks reported by clock() and times(). They + * are the same as stathz for bogus historical reasons. They should be + * 1e6 because clock() and times() are implemented using getrusage() and + * there is no good reason why they should be less accurate. There is + * the bad reason that (broken) programs might not like clock_t or + * CLOCKS_PER_SEC being ``double'' (``unsigned long'' is not large enough + * to hold the required 24 hours worth of ticks if the frequency is + * 1000000ul, and ``unsigned long long'' would be nonstandard). + */ +#define _BSD_CLK_TCK_ 128 +#define _BSD_CLOCKS_PER_SEC_ 128 + +/* + * Typedefs for especially magic types. #define's wouldn't work in the + * __GNUC__ case, since __attribute__(()) only works in certain contexts. + * This is not in , since that has too much namespace + * pollution for inclusion in ANSI headers, yet we need __int64_t in at + * least . + */ +#ifdef __GNUC__ +typedef int __attribute__((__mode__(__DI__))) __int64_t; +typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t; +#else +typedef long long __int64_t; +typedef unsigned long long __uint64_t; +#endif +/* + * Internal names for basic integral types. Omit the typedef if + * not possible for a machine/compiler combination. + */ +typedef __signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; + +typedef int __intptr_t; +typedef unsigned int __uintptr_t; + +#endif /* !_MACHINE_ANSI_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/apic.h ./modules/label/machine/apic.h --- ../sys-altq/modules/label/machine/apic.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/apic.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,465 @@ +/* + * Copyright (c) 1996, by Peter Wemm and Steve Passe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the developer may NOT be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/apic.h,v 1.12.2.1 1999/08/29 16:06:16 peter Exp $ + */ + +#ifndef _MACHINE_APIC_H_ +#define _MACHINE_APIC_H_ + +/* + * Local && I/O APIC definitions. + */ + +/* + * Pentium P54C+ Build-in APIC + * (Advanced programmable Interrupt Controller) + * + * Base Address of Build-in APIC in memory location + * is 0xfee00000. + * + * Map of APIC REgisters: + * + * Offset (hex) Description Read/Write state + * 000 Reserved + * 010 Reserved + * 020 ID Local APIC ID R/W + * 030 VER Local APIC Version R + * 040 Reserved + * 050 Reserved + * 060 Reserved + * 070 Reserved + * 080 Task Priority Register R/W + * 090 Arbitration Priority Register R + * 0A0 Processor Priority Register R + * 0B0 EOI Register W + * 0C0 RRR Remote read R + * 0D0 Logical Destination R/W + * 0E0 Destination Format Register 0..27 R; 28..31 R/W + * 0F0 SVR Spurious Interrupt Vector Reg. 0..3 R; 4..9 R/W + * 100 ISR 000-031 R + * 110 ISR 032-063 R + * 120 ISR 064-095 R + * 130 ISR 095-128 R + * 140 ISR 128-159 R + * 150 ISR 160-191 R + * 160 ISR 192-223 R + * 170 ISR 224-255 R + * 180 TMR 000-031 R + * 190 TMR 032-063 R + * 1A0 TMR 064-095 R + * 1B0 TMR 095-128 R + * 1C0 TMR 128-159 R + * 1D0 TMR 160-191 R + * 1E0 TMR 192-223 R + * 1F0 TMR 224-255 R + * 200 IRR 000-031 R + * 210 IRR 032-063 R + * 220 IRR 064-095 R + * 230 IRR 095-128 R + * 240 IRR 128-159 R + * 250 IRR 160-191 R + * 260 IRR 192-223 R + * 270 IRR 224-255 R + * 280 Error Status Register R + * 290 Reserved + * 2A0 Reserved + * 2B0 Reserved + * 2C0 Reserved + * 2D0 Reserved + * 2E0 Reserved + * 2F0 Reserved + * 300 ICR_LOW Interrupt Command Reg. (0-31) R/W + * 310 ICR_HI Interrupt Command Reg. (32-63) R/W + * 320 Local Vector Table (Timer) R/W + * 330 Reserved + * 340 Reserved + * 350 LVT1 Local Vector Table (LINT0) R/W + * 360 LVT2 Local Vector Table (LINT1) R/W + * 370 LVT3 Local Vector Table (ERROR) R/W + * 380 Initial Count Reg. for Timer R/W + * 390 Current Count of Timer R + * 3A0 Reserved + * 3B0 Reserved + * 3C0 Reserved + * 3D0 Reserved + * 3E0 Timer Divide Configuration Reg. R/W + * 3F0 Reserved + */ + + +/****************************************************************************** + * global defines, etc. + */ + + +/****************************************************************************** + * LOCAL APIC structure + */ + +#ifndef LOCORE +#include + +#define PAD3 int : 32; int : 32; int : 32 +#define PAD4 int : 32; int : 32; int : 32; int : 32 + +struct LAPIC { + /* reserved */ PAD4; + /* reserved */ PAD4; + u_int32_t id; PAD3; + u_int32_t version; PAD3; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + u_int32_t tpr; PAD3; + u_int32_t apr; PAD3; + u_int32_t ppr; PAD3; + u_int32_t eoi; PAD3; + /* reserved */ PAD4; + u_int32_t ldr; PAD3; + u_int32_t dfr; PAD3; + u_int32_t svr; PAD3; + u_int32_t isr0; PAD3; + u_int32_t isr1; PAD3; + u_int32_t isr2; PAD3; + u_int32_t isr3; PAD3; + u_int32_t isr4; PAD3; + u_int32_t isr5; PAD3; + u_int32_t isr6; PAD3; + u_int32_t isr7; PAD3; + u_int32_t tmr0; PAD3; + u_int32_t tmr1; PAD3; + u_int32_t tmr2; PAD3; + u_int32_t tmr3; PAD3; + u_int32_t tmr4; PAD3; + u_int32_t tmr5; PAD3; + u_int32_t tmr6; PAD3; + u_int32_t tmr7; PAD3; + u_int32_t irr0; PAD3; + u_int32_t irr1; PAD3; + u_int32_t irr2; PAD3; + u_int32_t irr3; PAD3; + u_int32_t irr4; PAD3; + u_int32_t irr5; PAD3; + u_int32_t irr6; PAD3; + u_int32_t irr7; PAD3; + u_int32_t esr; PAD3; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + u_int32_t icr_lo; PAD3; + u_int32_t icr_hi; PAD3; + u_int32_t lvt_timer; PAD3; + /* reserved */ PAD4; + u_int32_t lvt_pcint; PAD3; + u_int32_t lvt_lint0; PAD3; + u_int32_t lvt_lint1; PAD3; + u_int32_t lvt_error; PAD3; + u_int32_t icr_timer; PAD3; + u_int32_t ccr_timer; PAD3; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + /* reserved */ PAD4; + u_int32_t dcr_timer; PAD3; + /* reserved */ PAD4; +}; + +typedef struct LAPIC lapic_t; + +/****************************************************************************** + * I/O APIC structure + */ + +struct IOAPIC { + u_int32_t ioregsel; PAD3; + u_int32_t iowin; PAD3; +}; + +typedef struct IOAPIC ioapic_t; + +#undef PAD4 +#undef PAD3 + +#endif /* !LOCORE */ + + +/****************************************************************************** + * various code 'logical' values + */ + +/* default level for TPR */ +#define LOPRIO_LEVEL 0x00000010 /* TPR of CPU accepting INTs */ + +#ifdef GRAB_LOPRIO +#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */ +#endif /** GRAB_LOPRIO */ + +/* XXX these 2 don't really belong here... */ +#define COUNT_FIELD 0x00ffffff /* count portion of the lock */ +#define FREE_LOCK 0xffffffff /* value of lock when free */ + +/* + * XXX This code assummes that the reserved field of the + * local APIC TPR can be written with all 0s. + * This saves quite a few memory accesses. + * If the silicon ever changes then things will break! + * It affects mplock.s, swtch.s, and possibly other files. + */ +#define CHEAP_TPR + + +/****************************************************************************** + * LOCAL APIC defines + */ + +/* default physical locations of LOCAL (CPU) APICs */ +#define DEFAULT_APIC_BASE 0xfee00000 + +/* fields in VER */ +#define APIC_VER_VERSION 0x000000ff +#define APIC_VER_MAXLVT 0x00ff0000 +#define MAXLVTSHIFT 16 + +/* fields in SVR */ +#define APIC_SVR_VECTOR 0x000000ff +#define APIC_SVR_VEC_PROG 0x000000f0 +#define APIC_SVR_VEC_FIX 0x0000000f +#define APIC_SVR_ENABLE 0x00000100 +# define APIC_SVR_SWDIS 0x00000000 +# define APIC_SVR_SWEN 0x00000100 +#define APIC_SVR_FOCUS 0x00000200 +# define APIC_SVR_FEN 0x00000000 +# define APIC_SVR_FDIS 0x00000200 + +/* fields in TPR */ +#define APIC_TPR_PRIO 0x000000ff +# define APIC_TPR_INT 0x000000f0 +# define APIC_TPR_SUB 0x0000000f + + +/* fields in ICR_LOW */ +#define APIC_VECTOR_MASK 0x000000ff + +#define APIC_DELMODE_MASK 0x00000700 +# define APIC_DELMODE_FIXED 0x00000000 +# define APIC_DELMODE_LOWPRIO 0x00000100 +# define APIC_DELMODE_SMI 0x00000200 +# define APIC_DELMODE_RR 0x00000300 +# define APIC_DELMODE_NMI 0x00000400 +# define APIC_DELMODE_INIT 0x00000500 +# define APIC_DELMODE_STARTUP 0x00000600 +# define APIC_DELMODE_RESV 0x00000700 + +#define APIC_DESTMODE_MASK 0x00000800 +# define APIC_DESTMODE_PHY 0x00000000 +# define APIC_DESTMODE_LOG 0x00000800 + +#define APIC_DELSTAT_MASK 0x00001000 +# define APIC_DELSTAT_IDLE 0x00000000 +# define APIC_DELSTAT_PEND 0x00001000 + +#define APIC_RESV1_MASK 0x00002000 + +#define APIC_LEVEL_MASK 0x00004000 +# define APIC_LEVEL_DEASSERT 0x00000000 +# define APIC_LEVEL_ASSERT 0x00004000 + +#define APIC_TRIGMOD_MASK 0x00008000 +# define APIC_TRIGMOD_EDGE 0x00000000 +# define APIC_TRIGMOD_LEVEL 0x00008000 + +#define APIC_RRSTAT_MASK 0x00030000 +# define APIC_RRSTAT_INVALID 0x00000000 +# define APIC_RRSTAT_INPROG 0x00010000 +# define APIC_RRSTAT_VALID 0x00020000 +# define APIC_RRSTAT_RESV 0x00030000 + +#define APIC_DEST_MASK 0x000c0000 +# define APIC_DEST_DESTFLD 0x00000000 +# define APIC_DEST_SELF 0x00040000 +# define APIC_DEST_ALLISELF 0x00080000 +# define APIC_DEST_ALLESELF 0x000c0000 + +#define APIC_RESV2_MASK 0xfff00000 + + +/* fields in ICR_HIGH */ +#define APIC_ID_MASK 0x0f000000 + + +/* fields in LVT1/2 */ +#define APIC_LVT_VECTOR 0x000000ff +#define APIC_LVT_DM 0x00000700 +# define APIC_LVT_DM_FIXED 0x00000000 +# define APIC_LVT_DM_NMI 0x00000400 +# define APIC_LVT_DM_EXTINT 0x00000700 +#define APIC_LVT_DS 0x00001000 +#define APIC_LVT_IIPP 0x00002000 +#define APIC_LVT_IIPP_INTALO 0x00002000 +#define APIC_LVT_IIPP_INTAHI 0x00000000 +#define APIC_LVT_RIRR 0x00004000 +#define APIC_LVT_TM 0x00008000 +#define APIC_LVT_M 0x00010000 + + +/* fields in LVT Timer */ +#define APIC_LVTT_VECTOR 0x000000ff +#define APIC_LVTT_DS 0x00001000 +#define APIC_LVTT_M 0x00010000 +#define APIC_LVTT_TM 0x00020000 + + +/* fields in TDCR */ +#define APIC_TDCR_2 0x00 +#define APIC_TDCR_4 0x01 +#define APIC_TDCR_8 0x02 +#define APIC_TDCR_16 0x03 +#define APIC_TDCR_32 0x08 +#define APIC_TDCR_64 0x09 +#define APIC_TDCR_128 0x0a +#define APIC_TDCR_1 0x0b + + +/* + * fields in IRR + * ISA INTerrupts are in bits 16-31 of the 1st IRR register. + * these masks DON'T EQUAL the isa IRQs of the same name. + */ +#define APIC_IRQ0 0x00000001 +#define APIC_IRQ1 0x00000002 +#define APIC_IRQ2 0x00000004 +#define APIC_IRQ3 0x00000008 +#define APIC_IRQ4 0x00000010 +#define APIC_IRQ5 0x00000020 +#define APIC_IRQ6 0x00000040 +#define APIC_IRQ7 0x00000080 +#define APIC_IRQ8 0x00000100 +#define APIC_IRQ9 0x00000200 +#define APIC_IRQ10 0x00000400 +#define APIC_IRQ11 0x00000800 +#define APIC_IRQ12 0x00001000 +#define APIC_IRQ13 0x00002000 +#define APIC_IRQ14 0x00004000 +#define APIC_IRQ15 0x00008000 +#define APIC_IRQ16 0x00010000 +#define APIC_IRQ17 0x00020000 +#define APIC_IRQ18 0x00040000 +#define APIC_IRQ19 0x00080000 +#define APIC_IRQ20 0x00100000 +#define APIC_IRQ21 0x00200000 +#define APIC_IRQ22 0x00400000 +#define APIC_IRQ23 0x00800000 + + +/****************************************************************************** + * I/O APIC defines + */ + +/* default physical locations of an IO APIC */ +#define DEFAULT_IO_APIC_BASE 0xfec00000 + +/* window register offset */ +#define IOAPIC_WINDOW 0x10 + +/* indexes into IO APIC */ +#define IOAPIC_ID 0x00 +#define IOAPIC_VER 0x01 +#define IOAPIC_ARB 0x02 +#define IOAPIC_REDTBL 0x10 +#define IOAPIC_REDTBL0 IOAPIC_REDTBL +#define IOAPIC_REDTBL1 (IOAPIC_REDTBL+0x02) +#define IOAPIC_REDTBL2 (IOAPIC_REDTBL+0x04) +#define IOAPIC_REDTBL3 (IOAPIC_REDTBL+0x06) +#define IOAPIC_REDTBL4 (IOAPIC_REDTBL+0x08) +#define IOAPIC_REDTBL5 (IOAPIC_REDTBL+0x0a) +#define IOAPIC_REDTBL6 (IOAPIC_REDTBL+0x0c) +#define IOAPIC_REDTBL7 (IOAPIC_REDTBL+0x0e) +#define IOAPIC_REDTBL8 (IOAPIC_REDTBL+0x10) +#define IOAPIC_REDTBL9 (IOAPIC_REDTBL+0x12) +#define IOAPIC_REDTBL10 (IOAPIC_REDTBL+0x14) +#define IOAPIC_REDTBL11 (IOAPIC_REDTBL+0x16) +#define IOAPIC_REDTBL12 (IOAPIC_REDTBL+0x18) +#define IOAPIC_REDTBL13 (IOAPIC_REDTBL+0x1a) +#define IOAPIC_REDTBL14 (IOAPIC_REDTBL+0x1c) +#define IOAPIC_REDTBL15 (IOAPIC_REDTBL+0x1e) +#define IOAPIC_REDTBL16 (IOAPIC_REDTBL+0x20) +#define IOAPIC_REDTBL17 (IOAPIC_REDTBL+0x22) +#define IOAPIC_REDTBL18 (IOAPIC_REDTBL+0x24) +#define IOAPIC_REDTBL19 (IOAPIC_REDTBL+0x26) +#define IOAPIC_REDTBL20 (IOAPIC_REDTBL+0x28) +#define IOAPIC_REDTBL21 (IOAPIC_REDTBL+0x2a) +#define IOAPIC_REDTBL22 (IOAPIC_REDTBL+0x2c) +#define IOAPIC_REDTBL23 (IOAPIC_REDTBL+0x2e) + +/* fields in VER */ +#define IOART_VER_VERSION 0x000000ff +#define IOART_VER_MAXREDIR 0x00ff0000 +#define MAXREDIRSHIFT 16 + +/* + * fields in the IO APIC's redirection table entries + */ +#define IOART_DEST APIC_ID_MASK /* broadcast addr: all APICs */ + +#define IOART_RESV 0x00fe0000 /* reserved */ + +#define IOART_INTMASK 0x00010000 /* R/W: INTerrupt mask */ +# define IOART_INTMCLR 0x00000000 /* clear, allow INTs */ +# define IOART_INTMSET 0x00010000 /* set, inhibit INTs */ + +#define IOART_TRGRMOD 0x00008000 /* R/W: trigger mode */ +# define IOART_TRGREDG 0x00000000 /* edge */ +# define IOART_TRGRLVL 0x00008000 /* level */ + +#define IOART_REM_IRR 0x00004000 /* RO: remote IRR */ + +#define IOART_INTPOL 0x00002000 /* R/W: INT input pin polarity */ +# define IOART_INTAHI 0x00000000 /* active high */ +# define IOART_INTALO 0x00002000 /* active low */ + +#define IOART_DELIVS 0x00001000 /* RO: delivery status */ + +#define IOART_DESTMOD 0x00000800 /* R/W: destination mode */ +# define IOART_DESTPHY 0x00000000 /* physical */ +# define IOART_DESTLOG 0x00000800 /* logical */ + +#define IOART_DELMOD 0x00000700 /* R/W: delivery mode */ +# define IOART_DELFIXED 0x00000000 /* fixed */ +# define IOART_DELLOPRI 0x00000100 /* lowest priority */ +# define IOART_DELSMI 0x00000200 /* System Management INT */ +# define IOART_DELRSV1 0x00000300 /* reserved */ +# define IOART_DELNMI 0x00000400 /* NMI signal */ +# define IOART_DELINIT 0x00000500 /* INIT signal */ +# define IOART_DELRSV2 0x00000600 /* reserved */ +# define IOART_DELEXINT 0x00000700 /* External INTerrupt */ + +#define IOART_INTVEC 0x000000ff /* R/W: INTerrupt vector field */ + +#endif /* _MACHINE_APIC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/apm_bios.h ./modules/label/machine/apm_bios.h --- ../sys-altq/modules/label/machine/apm_bios.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/apm_bios.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,258 @@ +/* + * APM (Advanced Power Management) BIOS Device Driver + * + * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi + * + * This software may be used, modified, copied, and distributed, in + * both source and binary form provided that the above copyright and + * these terms are retained. Under no circumstances is the author + * responsible for the proper functioning of this software, nor does + * the author assume any responsibility for damages incurred with its + * use. + * + * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) + * + * $FreeBSD: src/sys/i386/include/apm_bios.h,v 1.21.2.2 1999/08/29 16:06:17 peter Exp $ + */ + +#ifndef _MACHINE_APM_BIOS_H_ +#define _MACHINE_APM_BIOS_H_ + +#ifndef KERNEL +#include +#endif +#include + +/* BIOS id */ +#ifdef PC98 +#define APM_BIOS 0x9a +#define SYSTEM_BIOS 0x1f +#else +#define APM_BIOS 0x53 +#define SYSTEM_BIOS 0x15 +#endif + +/* APM flags */ +#define APM_16BIT_SUPPORT 0x01 +#define APM_32BIT_SUPPORT 0x02 +#define APM_CPUIDLE_SLOW 0x04 +#define APM_DISABLED 0x08 +#define APM_DISENGAGED 0x10 + +/* APM initializer physical address */ +#define APM_OURADDR 0x00080000 + +/* Error code of APM initializer */ +#define APMINI_CANTFIND 0xffffffff +#define APMINI_NOT32BIT 0xfffffffe +#define APMINI_CONNECTERR 0xfffffffd + +/* APM functions */ +#define APM_INSTCHECK 0x00 +#define APM_REALCONNECT 0x01 +#define APM_PROT16CONNECT 0x02 +#define APM_PROT32CONNECT 0x03 +#define APM_DISCONNECT 0x04 +#define APM_CPUIDLE 0x05 +#define APM_CPUBUSY 0x06 +#define APM_SETPWSTATE 0x07 +#define APM_ENABLEDISABLEPM 0x08 +#define APM_RESTOREDEFAULT 0x09 +#ifdef PC98 +#define APM_GETPWSTATUS 0x3a +#else +#define APM_GETPWSTATUS 0x0a +#endif +#define APM_GETPMEVENT 0x0b +#define APM_GETPWSTATE 0x0c +#define APM_ENABLEDISABLEDPM 0x0d +#ifdef PC98 +#define APM_DRVVERSION 0x3e +#else +#define APM_DRVVERSION 0x0e +#endif +#define APM_ENGAGEDISENGAGEPM 0x0f +#define APM_GETCAPABILITIES 0x10 +#define APM_RESUMETIMER 0x11 +#define APM_RESUMEONRING 0x12 +#define APM_TIMERREQUESTS 0x13 +#define APM_OEMFUNC 0x80 + +/* error code */ +#define APME_OK 0x00 +#define APME_PMDISABLED 0x01 +#define APME_REALESTABLISHED 0x02 +#define APME_NOTCONNECTED 0x03 +#define APME_PROT16ESTABLISHED 0x05 +#define APME_PROT16NOTSUPPORTED 0x06 +#define APME_PROT32ESTABLISHED 0x07 +#define APME_PROT32NOTDUPPORTED 0x08 +#define APME_UNKNOWNDEVICEID 0x09 +#define APME_OUTOFRANGE 0x0a +#define APME_NOTENGAGED 0x0b +#define APME_CANTENTERSTATE 0x60 +#define APME_NOPMEVENT 0x80 +#define APME_NOAPMPRESENT 0x86 + + +/* device code */ +#define PMDV_APMBIOS 0x0000 +#define PMDV_ALLDEV 0x0001 +#define PMDV_DISP0 0x0100 +#define PMDV_DISP1 0x0101 +#define PMDV_2NDSTORAGE0 0x0200 +#define PMDV_2NDSTORAGE1 0x0201 +#define PMDV_2NDSTORAGE2 0x0202 +#define PMDV_2NDSTORAGE3 0x0203 +#define PMDV_PARALLEL0 0x0300 +#define PMDV_PARALLEL1 0x0301 +#define PMDV_SERIAL0 0x0400 +#define PMDV_SERIAL1 0x0401 +#define PMDV_SERIAL2 0x0402 +#define PMDV_SERIAL3 0x0403 +#define PMDV_SERIAL4 0x0404 +#define PMDV_SERIAL5 0x0405 +#define PMDV_SERIAL6 0x0406 +#define PMDV_SERIAL7 0x0407 +#define PMDV_NET0 0x0500 +#define PMDV_NET1 0x0501 +#define PMDV_NET2 0x0502 +#define PMDV_NET3 0x0503 +#define PMDV_PCMCIA0 0x0600 +#define PMDV_PCMCIA1 0x0601 +#define PMDV_PCMCIA2 0x0602 +#define PMDV_PCMCIA3 0x0603 +/* 0x0700 - 0xdfff Reserved */ +/* 0xe000 - 0xefff OEM-defined power device IDs */ +/* 0xf000 - 0xffff Reserved */ + +/* Power state */ +#define PMST_APMENABLED 0x0000 +#define PMST_STANDBY 0x0001 +#define PMST_SUSPEND 0x0002 +#define PMST_OFF 0x0003 +#define PMST_LASTREQNOTIFY 0x0004 +#define PMST_LASTREQREJECT 0x0005 +/* 0x0006 - 0x001f Reserved system states */ +/* 0x0020 - 0x003f OEM-defined system states */ +/* 0x0040 - 0x007f OEM-defined device states */ +/* 0x0080 - 0xffff Reserved device states */ + +#if !defined(ASSEMBLER) && !defined(INITIALIZER) + +/* C definitions */ +struct apmhook { + struct apmhook *ah_next; + int (*ah_fun) __P((void *ah_arg)); + void *ah_arg; + const char *ah_name; + int ah_order; +}; +#define APM_HOOK_NONE (-1) +#define APM_HOOK_SUSPEND 0 +#define APM_HOOK_RESUME 1 +#define NAPM_HOOK 2 + +#ifdef KERNEL + +void apm_suspend(int state); +struct apmhook *apm_hook_establish (int apmh, struct apmhook *); +void apm_hook_disestablish (int apmh, struct apmhook *); +void apm_cpu_idle(void); +void apm_cpu_busy(void); + +#endif /* KERNEL */ + +#endif /* !ASSEMBLER && !INITIALIZER */ + +#define APM_MIN_ORDER 0x00 +#define APM_MID_ORDER 0x80 +#define APM_MAX_ORDER 0xff + +/* power management event code */ +#define PMEV_NOEVENT 0x0000 +#define PMEV_STANDBYREQ 0x0001 +#define PMEV_SUSPENDREQ 0x0002 +#define PMEV_NORMRESUME 0x0003 +#define PMEV_CRITRESUME 0x0004 +#define PMEV_BATTERYLOW 0x0005 +#define PMEV_POWERSTATECHANGE 0x0006 +#define PMEV_UPDATETIME 0x0007 +#define PMEV_CRITSUSPEND 0x0008 +#define PMEV_USERSTANDBYREQ 0x0009 +#define PMEV_USERSUSPENDREQ 0x000a +#define PMEV_STANDBYRESUME 0x000b +#define PMEV_CAPABILITIESCHANGE 0x000c +/* 0x000d - 0x00ff Reserved system events */ +/* 0x0100 - 0x01ff Reserved device events */ +/* 0x0200 - 0x02ff OEM-defined APM events */ +/* 0x0300 - 0xffff Reserved */ +#define PMEV_DEFAULT 0xffffffff /* used for customization */ + +#if !defined(ASSEMBLER) && !defined(INITIALIZER) + +/* + * Old apm_info structure, returned by the APMIO_GETINFO_OLD ioctl. This + * is for backward compatibility with old executables. + */ +typedef struct apm_info_old { + u_int ai_major; /* APM major version */ + u_int ai_minor; /* APM minor version */ + u_int ai_acline; /* AC line status */ + u_int ai_batt_stat; /* Battery status */ + u_int ai_batt_life; /* Remaining battery life */ + u_int ai_status; /* Status of APM support (enabled/disabled) */ +} *apm_info_old_t; + +/* + * Structure returned by the APMIO_GETINFO ioctl. + * + * In the comments below, the parenthesized numbers indicate the minimum + * value of ai_infoversion for which each field is valid. + */ +typedef struct apm_info { + u_int ai_infoversion; /* Indicates which fields are valid */ + u_int ai_major; /* APM major version (0) */ + u_int ai_minor; /* APM minor version (0) */ + u_int ai_acline; /* AC line status (0) */ + u_int ai_batt_stat; /* Battery status (0) */ + u_int ai_batt_life; /* Remaining battery life in percent (0) */ + int ai_batt_time; /* Remaining battery time in seconds (0) */ + u_int ai_status; /* True if enabled (0) */ + u_int ai_batteries; /* Number of batteries (1) */ + u_int ai_capabilities;/* APM Capabilities (1) */ + u_int ai_spare[6]; /* For future expansion */ +} *apm_info_t; + +struct apm_bios_arg { + u_long eax; + u_long ebx; + u_long ecx; + u_long edx; + u_long esi; + u_long edi; +}; + +struct apm_event_info { + u_int type; + u_int index; + u_int spare[8]; +}; + +#define APMIO_SUSPEND _IO('P', 1) +#define APMIO_GETINFO_OLD _IOR('P', 2, struct apm_info_old) +#define APMIO_ENABLE _IO('P', 5) +#define APMIO_DISABLE _IO('P', 6) +#define APMIO_HALTCPU _IO('P', 7) +#define APMIO_NOTHALTCPU _IO('P', 8) +#define APMIO_DISPLAY _IOW('P', 9, int) +#define APMIO_BIOS _IOWR('P', 10, struct apm_bios_arg) +#define APMIO_GETINFO _IOR('P', 11, struct apm_info) +#define APMIO_STANDBY _IO('P', 12) +/* for /dev/apmctl */ +#define APMIO_NEXTEVENT _IOR('A', 100, struct apm_event_info) +#define APMIO_REJECTLASTREQ _IO('P', 101) + +#endif /* !ASSEMBLER && !INITIALIZER */ + +#endif /* !_MACHINE_APM_BIOS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/apm_segments.h ./modules/label/machine/apm_segments.h --- ../sys-altq/modules/label/machine/apm_segments.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/apm_segments.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,38 @@ +/* + * LP (Laptop Package) + * + * Copyright (C) 1994 by HOSOKAWA Tatsumi + * + * This software may be used, modified, copied, and distributed, in + * both source and binary form provided that the above copyright and + * these terms are retained. Under no circumstances is the author + * responsible for the proper functioning of this software, nor does + * the author assume any responsibility for damages incurred with its + * use. + * + * Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) + * + * $FreeBSD: src/sys/i386/include/apm_segments.h,v 1.7.4.1 1999/08/29 16:06:17 peter Exp $ + */ + +#ifndef _MACHINE_APM_SEGMENTS_H +#define _MACHINE_APM_SEGMENTS_H + +#define SIZEOF_GDT 8 +#define BOOTSTRAP_GDT_NUM 32 + +#define APM_INIT_CS_INDEX (BOOTSTRAP_GDT_NUM - 4) +#define APM_INIT_DS_INDEX (BOOTSTRAP_GDT_NUM - 3) +#define APM_INIT_CS16_INDEX (BOOTSTRAP_GDT_NUM - 2) +#define APM_INIT_DS16_INDEX (BOOTSTRAP_GDT_NUM - 1) +#define APM_INIT_CS_SEL (APM_INIT_CS_INDEX << 3) +#define APM_INIT_DS_SEL (APM_INIT_DS_INDEX << 3) +#define APM_INIT_CS16_SEL (APM_INIT_CS16_INDEX << 3) +#define APM_INIT_DS16_SEL (APM_INIT_DS16_INDEX << 3) + +#define CS32_ATTRIB 0x409e +#define DS32_ATTRIB 0x4092 +#define CS16_ATTRIB 0x009e +#define DS16_ATTRIB 0x0092 + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/asc_ioctl.h ./modules/label/machine/asc_ioctl.h --- ../sys-altq/modules/label/machine/asc_ioctl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/asc_ioctl.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,51 @@ +/* asc.h - programming interface to the scanner device driver `asc' + * + * + * Copyright (c) 1995 Gunther Schadow. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gunther Schadow. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_ASC_IOCTL_H_ +#define _MACHINE_ASC_IOCTL_H_ + +#include + +#define ASC_GRES _IOR('S', 1, int) /* get resolution / dpi */ +#define ASC_SRES _IOW('S', 2, int) /* set resolution / dpi */ +#define ASC_GWIDTH _IOR('S', 3, int) /* get width / pixels */ +#define ASC_SWIDTH _IOW('S', 4, int) /* set width / pixels */ +#define ASC_GHEIGHT _IOR('S', 5, int) /* get height / pixels */ +#define ASC_SHEIGHT _IOW('S', 6, int) /* set height / pixels */ + +#define ASC_GBLEN _IOR('S', 7, int) /* get buffer length / lines */ +#define ASC_SBLEN _IOW('S', 8, int) /* set buffer length / lines */ +#define ASC_GBTIME _IOR('S', 9, int) /* get buffer timeout / s */ +#define ASC_SBTIME _IOW('S', 10, int) /* set buffer timeout / s */ + +#define ASC_SRESSW _IO('S', 11) /* set resolution by switch */ + +#endif /* !_MACHINE_ASC_IOCTL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/asm.h ./modules/label/machine/asm.h --- ../sys-altq/modules/label/machine/asm.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/asm.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,164 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 + * $FreeBSD: src/sys/i386/include/asm.h,v 1.4.4.1 1999/08/29 16:06:18 peter Exp $ + */ + +#ifndef _MACHINE_ASM_H_ +#define _MACHINE_ASM_H_ + +#include + +#ifdef PIC +#define PIC_PROLOGUE \ + pushl %ebx; \ + call 1f; \ +1: \ + popl %ebx; \ + addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx +#define PIC_EPILOGUE \ + popl %ebx +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT(%ebx) +#define PIC_GOTOFF(x) x@GOTOFF(%ebx) +#else +#define PIC_PROLOGUE +#define PIC_EPILOGUE +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#define PIC_GOTOFF(x) x +#endif + +/* + * CNAME and HIDENAME manage the relationship between symbol names in C + * and the equivalent assembly language names. CNAME is given a name as + * it would be used in a C program. It expands to the equivalent assembly + * language name. HIDENAME is given an assembly-language name, and expands + * to a possibly-modified form that will be invisible to C programs. + */ +#ifdef __ELF__ +#define CNAME(csym) csym +#define HIDENAME(asmsym) __CONCAT(.,asmsym) +#else +#define CNAME(csym) __CONCAT(_,csym) +#define HIDENAME(asmsym) asmsym +#endif + +/* XXX should use .p2align 4,0x90 for -m486. */ +#define _START_ENTRY .text; .p2align 2,0x90 + +#define _ENTRY(x) _START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): + +#ifdef PROF +#define ENTRY(x) _ENTRY(x); \ + pushl %ebp; movl %esp,%ebp; \ + call PIC_PLT(HIDENAME(mcount)); \ + popl %ebp +#else +#define ENTRY(x) _ENTRY(x) +#endif + +#define RCSID(x) .text; .asciz x + +#ifdef _ARCH_INDIRECT +/* + * Generate code to select between the generic functions and _ARCH_INDIRECT + * specific ones. + * XXX nested __CONCATs don't work with non-ANSI cpp's. + */ +#define ANAME(x) CNAME(__CONCAT(__CONCAT(__,_ARCH_INDIRECT),x)) +#define ASELNAME(x) CNAME(__CONCAT(__arch_select_,x)) +#define AVECNAME(x) CNAME(__CONCAT(__arch_,x)) +#define GNAME(x) CNAME(__CONCAT(__generic_,x)) + +/* Don't bother profiling this. */ +#ifdef PIC +#define ARCH_DISPATCH(x) \ + _START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \ + PIC_PROLOGUE; \ + movl PIC_GOT(AVECNAME(x)),%eax; \ + PIC_EPILOGUE; \ + jmpl *(%eax) + +#define ARCH_SELECT(x) _START_ENTRY; \ + .type ASELNAME(x),@function; \ + ASELNAME(x): \ + PIC_PROLOGUE; \ + call PIC_PLT(CNAME(__get_hw_float)); \ + testl %eax,%eax; \ + movl PIC_GOT(ANAME(x)),%eax; \ + jne 8f; \ + movl PIC_GOT(GNAME(x)),%eax; \ + 8: \ + movl PIC_GOT(AVECNAME(x)),%edx; \ + movl %eax,(%edx); \ + PIC_EPILOGUE; \ + jmpl *%eax +#else /* !PIC */ +#define ARCH_DISPATCH(x) \ + _START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \ + jmpl *AVECNAME(x) + +#define ARCH_SELECT(x) _START_ENTRY; \ + .type ASELNAME(x),@function; \ + ASELNAME(x): \ + call CNAME(__get_hw_float); \ + testl %eax,%eax; \ + movl $ANAME(x),%eax; \ + jne 8f; \ + movl $GNAME(x),%eax; \ + 8: \ + movl %eax,AVECNAME(x); \ + jmpl *%eax +#endif /* PIC */ + +#define ARCH_VECTOR(x) .data; .p2align 2; \ + .globl AVECNAME(x); \ + .type AVECNAME(x),@object; \ + .size AVECNAME(x),4; \ + AVECNAME(x): .long ASELNAME(x) + +#undef _ENTRY +#define _ENTRY(x) ARCH_VECTOR(x); ARCH_SELECT(x); ARCH_DISPATCH(x); \ + _START_ENTRY; \ + .globl ANAME(x); .type ANAME(x),@function; ANAME(x): + +#endif /* _ARCH_INDIRECT */ + +#endif /* !_MACHINE_ASM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/asmacros.h ./modules/label/machine/asmacros.h --- ../sys-altq/modules/label/machine/asmacros.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/asmacros.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,141 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/asmacros.h,v 1.16.4.1 1999/08/29 16:06:18 peter Exp $ + */ + +#ifndef _MACHINE_ASMACROS_H_ +#define _MACHINE_ASMACROS_H_ + +#include +#include + +/* XXX too much duplication in various asm*.h's. */ + +/* + * CNAME and HIDENAME manage the relationship between symbol names in C + * and the equivalent assembly language names. CNAME is given a name as + * it would be used in a C program. It expands to the equivalent assembly + * language name. HIDENAME is given an assembly-language name, and expands + * to a possibly-modified form that will be invisible to C programs. + */ +#if defined(__ELF__) +#define CNAME(csym) csym +#define HIDENAME(asmsym) __CONCAT(.,asmsym) +#else +#define CNAME(csym) __CONCAT(_,csym) +#define HIDENAME(asmsym) asmsym +#endif + +#define ALIGN_DATA .p2align 2 /* 4 byte alignment, zero filled */ +#ifdef GPROF +#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ +#else +#define ALIGN_TEXT .p2align 2,0x90 /* 4-byte alignment, nop filled */ +#endif +#define SUPERALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ + +#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ + CNAME(name): +#define NON_GPROF_ENTRY(name) GEN_ENTRY(name) +#define NON_GPROF_RET .byte 0xc3 /* opcode for `ret' */ + +#ifdef GPROF +/* + * __mcount is like mcount except that doesn't require its caller to set + * up a frame pointer. It must be called before pushing anything onto the + * stack. gcc should eventually generate code to call __mcount in most + * cases. This would make -pg in combination with -fomit-frame-pointer + * useful. gcc has a configuration variable PROFILE_BEFORE_PROLOGUE to + * allow profiling before setting up the frame pointer, but this is + * inadequate for good handling of special cases, e.g., -fpic works best + * with profiling after the prologue. + * + * mexitcount is a new function to support non-statistical profiling if an + * accurate clock is available. For C sources, calls to it are generated + * by the FreeBSD extension `-mprofiler-epilogue' to gcc. It is best to + * call mexitcount at the end of a function like the MEXITCOUNT macro does, + * but gcc currently generates calls to it at the start of the epilogue to + * avoid problems with -fpic. + * + * mcount and __mexitcount may clobber the call-used registers and %ef. + * mexitcount may clobber %ecx and %ef. + * + * Cross-jumping makes non-statistical profiling timing more complicated. + * It is handled in many cases by calling mexitcount before jumping. It is + * handled for conditional jumps using CROSSJUMP() and CROSSJUMP_LABEL(). + * It is handled for some fault-handling jumps by not sharing the exit + * routine. + * + * ALTENTRY() must be before a corresponding ENTRY() so that it can jump to + * the main entry point. Note that alt entries are counted twice. They + * have to be counted as ordinary entries for gprof to get the call times + * right for the ordinary entries. + * + * High local labels are used in macros to avoid clashes with local labels + * in functions. + * + * Ordinary `ret' is used instead of a macro `RET' because there are a lot + * of `ret's. 0xc3 is the opcode for `ret' (`#define ret ... ret' can't + * be used because this file is sometimes preprocessed in traditional mode). + * `ret' clobbers eflags but this doesn't matter. + */ +#define ALTENTRY(name) GEN_ENTRY(name) ; MCOUNT ; MEXITCOUNT ; jmp 9f +#define CROSSJUMP(jtrue, label, jfalse) \ + jfalse 8f; MEXITCOUNT; jmp __CONCAT(to,label); 8: +#define CROSSJUMPTARGET(label) \ + ALIGN_TEXT; __CONCAT(to,label): ; MCOUNT; jmp label +#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT +#define FAKE_MCOUNT(caller) pushl caller ; call __mcount ; popl %ecx +#define MCOUNT call __mcount +#define MCOUNT_LABEL(name) GEN_ENTRY(name) ; nop ; ALIGN_TEXT +#define MEXITCOUNT call mexitcount +#define ret MEXITCOUNT ; NON_GPROF_RET + +#else /* !GPROF */ +/* + * ALTENTRY() has to align because it is before a corresponding ENTRY(). + * ENTRY() has to align to because there may be no ALTENTRY() before it. + * If there is a previous ALTENTRY() then the alignment code for ENTRY() + * is empty. + */ +#define ALTENTRY(name) GEN_ENTRY(name) +#define CROSSJUMP(jtrue, label, jfalse) jtrue label +#define CROSSJUMPTARGET(label) +#define ENTRY(name) GEN_ENTRY(name) +#define FAKE_MCOUNT(caller) +#define MCOUNT +#define MCOUNT_LABEL(name) +#define MEXITCOUNT +#endif /* GPROF */ + +#endif /* !_MACHINE_ASMACROS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/asnames.h ./modules/label/machine/asnames.h --- ../sys-altq/modules/label/machine/asnames.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/asnames.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,392 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/asnames.h,v 1.26.2.6 1999/09/10 01:18:44 msmith Exp $ + */ + +#ifndef _MACHINE_ASNAMES_H_ +#define _MACHINE_ASNAMES_H_ + +/* + * This file is used by the kernel assembly language sources to provide + * the proper mapping between the global names used in assembly language + * code and the corresponding C symbols. By convention, all C symbols + * that are referenced from assembly language are prefixed with `_'. + * That happens to be the same prefix that the a.out compiler attaches + * to each C symbol. + * + * When using the ELF compiler, C symbols are identical to the corresponding + * assembly language symbols. Thus the extra underscores cause problems. + * The defines in this file map the underscore names back to the proper + * unadorned names. + * + * Every global symbol that is referenced from both C source and assembly + * language source must have an entry in this file, or the kernel will + * not build properly using the ELF compiler. + * + * This file is included by , and it is OK to rely + * on that. + */ + +#ifdef __ELF__ + +#define _APTD APTD +#define _APTDpde APTDpde +#define _APTmap APTmap +#define _CONST_QNaN CONST_QNaN +#define _IdlePTD IdlePTD +#define _KPTphys KPTphys +#define _MP_GDT MP_GDT +#define _MPgetlock MPgetlock +#define _MPrellock MPrellock +#define _MPtrylock MPtrylock +#define _PTD PTD +#define _PTDpde PTDpde +#define _PTmap PTmap +#define _SMP_ioapic SMP_ioapic +#define _SMP_prvpt SMP_prvpt +#define _Xalign Xalign +#define _Xbnd Xbnd +#define _Xbpt Xbpt +#define _Xcpuast Xcpuast +#define _Xcpucheckstate Xcpucheckstate +#define _Xcpustop Xcpustop +#define _Xdbg Xdbg +#define _Xdiv Xdiv +#define _Xdna Xdna +#define _Xfastintr0 Xfastintr0 +#define _Xfastintr1 Xfastintr1 +#define _Xfastintr10 Xfastintr10 +#define _Xfastintr11 Xfastintr11 +#define _Xfastintr12 Xfastintr12 +#define _Xfastintr13 Xfastintr13 +#define _Xfastintr14 Xfastintr14 +#define _Xfastintr15 Xfastintr15 +#define _Xfastintr16 Xfastintr16 +#define _Xfastintr17 Xfastintr17 +#define _Xfastintr18 Xfastintr18 +#define _Xfastintr19 Xfastintr19 +#define _Xfastintr2 Xfastintr2 +#define _Xfastintr20 Xfastintr20 +#define _Xfastintr21 Xfastintr21 +#define _Xfastintr22 Xfastintr22 +#define _Xfastintr23 Xfastintr23 +#define _Xfastintr3 Xfastintr3 +#define _Xfastintr4 Xfastintr4 +#define _Xfastintr5 Xfastintr5 +#define _Xfastintr6 Xfastintr6 +#define _Xfastintr7 Xfastintr7 +#define _Xfastintr8 Xfastintr8 +#define _Xfastintr9 Xfastintr9 +#define _Xforward_irq Xforward_irq +#define _Xfpu Xfpu +#define _Xfpusegm Xfpusegm +#define _Xill Xill +#define _Xint0x80_syscall Xint0x80_syscall +#define _Xintr0 Xintr0 +#define _Xintr1 Xintr1 +#define _Xintr10 Xintr10 +#define _Xintr11 Xintr11 +#define _Xintr12 Xintr12 +#define _Xintr13 Xintr13 +#define _Xintr14 Xintr14 +#define _Xintr15 Xintr15 +#define _Xintr16 Xintr16 +#define _Xintr17 Xintr17 +#define _Xintr18 Xintr18 +#define _Xintr19 Xintr19 +#define _Xintr2 Xintr2 +#define _Xintr20 Xintr20 +#define _Xintr21 Xintr21 +#define _Xintr22 Xintr22 +#define _Xintr23 Xintr23 +#define _Xintr3 Xintr3 +#define _Xintr4 Xintr4 +#define _Xintr5 Xintr5 +#define _Xintr6 Xintr6 +#define _Xintr7 Xintr7 +#define _Xintr8 Xintr8 +#define _Xintr8254 Xintr8254 +#define _Xintr9 Xintr9 +#define _XintrRTC XintrRTC +#define _Xinvltlb Xinvltlb +#define _Xrendezvous Xrendezvous +#define _Xmchk Xmchk +#define _Xmissing Xmissing +#define _Xnmi Xnmi +#define _Xofl Xofl +#define _Xpage Xpage +#define _Xprot Xprot +#define _Xrsvd Xrsvd +#define _Xspuriousint Xspuriousint +#define _Xstk Xstk +#define _Xsyscall Xsyscall +#define _Xtss Xtss +#define __default_ldt _default_ldt +#define __ucodesel _ucodesel +#define __udatasel _udatasel +#define _alltraps alltraps +#define _ap_init ap_init +#define _apic_base apic_base +#define _apic_id_to_logical apic_id_to_logical +#define _apic_imen apic_imen +#define _apic_isrbit_location apic_isrbit_location +#define _apic_pin_trigger apic_pin_trigger +#define _apm_addr apm_addr +#define _apm_bios_call apm_bios_call +#define _apm_cs16_base apm_cs16_base +#define _apm_cs16_limit apm_cs16_limit +#define _apm_cs32_base apm_cs32_base +#define _apm_cs32_limit apm_cs32_limit +#define _apm_cs_entry apm_cs_entry +#define _apm_cs_limit apm_cs_limit +#define _apm_current_gdt_pdesc apm_current_gdt_pdesc +#define _apm_ds_base apm_ds_base +#define _apm_ds_limit apm_ds_limit +#define _apm_flags apm_flags +#define _apm_init_image apm_init_image +#define _apm_init_image_size apm_init_image_size +#define _apm_setup apm_setup +#define _apm_version apm_version +#define _arith_invalid arith_invalid +#define _arith_overflow arith_overflow +#define _arith_underflow arith_underflow +#define _bcopy bcopy +#define _bcopy_vector bcopy_vector +#define _bigJump bigJump +#define _bio_imask bio_imask +#define _bluetrap bluetrap +#define _bootCodeSeg bootCodeSeg +#define _bootDataSeg bootDataSeg +#define _bootMP bootMP +#define _bootMP_size bootMP_size +#define _bootPTD bootPTD +#define _boot_get_mplock boot_get_mplock +#define _bootdev bootdev +#define _boothowto boothowto +#define _bootinfo bootinfo +#define _bootstrap_gdt bootstrap_gdt +#define _bzero bzero +#define _cam_imask cam_imask +#define _checkstate_cpus checkstate_cpus +#define _checkstate_cpustate checkstate_cpustate +#define _checkstate_curproc checkstate_curproc +#define _checkstate_need_ast checkstate_need_ast +#define _checkstate_pc checkstate_pc +#define _checkstate_pending_ast checkstate_pending_ast +#define _checkstate_probed_cpus checkstate_probed_cpus +#define _clock_lock clock_lock +#define _cnt cnt +#define _common_tss common_tss +#define _common_tssd common_tssd +#define _copyin_vector copyin_vector +#define _copyout_vector copyout_vector +#define _cpl cpl +#define _cpl_lock cpl_lock +#define _cpu cpu +#define _cpu0prvpage cpu0prvpage +#define _cpu0prvpt cpu0prvpt +#define _cpu_apic_versions cpu_apic_versions +#define _cpu_class cpu_class +#define _cpu_feature cpu_feature +#define _cpu_high cpu_high +#define _cpu_id cpu_id +#define _cpu_num_to_apic_id cpu_num_to_apic_id +#define _cpu_switch cpu_switch +#define _cpu_vendor cpu_vendor +#define _cpuid cpuid +#define _curpcb curpcb +#define _curproc curproc +#define _currentldt currentldt +#define _cypoll cypoll +#define _default_halt default_halt +#define _denormal_operand denormal_operand +#define _div_small div_small +#define _divide_by_zero divide_by_zero +#define _divide_kernel divide_kernel +#define _do_page_zero_idle do_page_zero_idle +#define _edata edata +#define _eintrcnt eintrcnt +#define _eintrnames eintrnames +#define _end end +#define _etext etext +#define _exception exception +#define _fast_intr_lock fast_intr_lock +#define _fastmove fastmove +#define _gdt gdt +#define _generic_bcopy generic_bcopy +#define _generic_bzero generic_bzero +#define _generic_copyin generic_copyin +#define _generic_copyout generic_copyout +#define _get_align_lock get_align_lock +#define _get_altsyscall_lock get_altsyscall_lock +#define _get_fpu_lock get_fpu_lock +#define _get_isrlock get_isrlock +#define _get_mplock get_mplock +#define _get_syscall_lock get_syscall_lock +#define _getmicrouptime getmicrouptime +#define _idqs idqs +#define _ihandlers ihandlers +#define _imen imen +#define _imen_lock imen_lock +#define _in_vm86call in_vm86call +#define _init386 init386 +#define _init_secondary init_secondary +#define _initial_bioscalls initial_bioscalls +#define _inside_intr inside_intr +#define _intr_countp intr_countp +#define _intr_handler intr_handler +#define _intr_mask intr_mask +#define _intr_nesting_level intr_nesting_level +#define _intr_unit intr_unit +#define _intrcnt intrcnt +#define _intrnames intrnames +#define _invltlb_ok invltlb_ok +#define _ioapic ioapic +#define _ipending ipending +#define _isr_lock isr_lock +#define _ivectors ivectors +#define _kernelname kernelname +#define _kstack kstack +#define _lapic lapic +#define _linux_sigcode linux_sigcode +#define _linux_szsigcode linux_szsigcode +#define _main main +#define _mask8254 mask8254 +#define _maskRTC maskRTC +#define _microuptime microuptime +#define _mp_gdtbase mp_gdtbase +#define _mp_lock mp_lock +#define _mp_ncpus mp_ncpus +#define _mul64 mul64 +#define _my_idlePTD my_idlePTD +#define _my_tr my_tr +#define _net_imask net_imask +#define _netisr netisr +#define _netisrs netisrs +#define _nfs_diskless nfs_diskless +#define _nfs_diskless_valid nfs_diskless_valid +#define _normalize normalize +#define _normalize_nuo normalize_nuo +#define _npx_intrs_while_probing npx_intrs_while_probing +#define _npx_traps_while_probing npx_traps_while_probing +#define _npxintr npxintr +#define _npxproc npxproc +#define _npxsave npxsave +#define _other_cpus other_cpus +#define _ovbcopy_vector ovbcopy_vector +#define _panic panic +#define _pc98_system_parameter pc98_system_parameter +#define _poly_div16 poly_div16 +#define _poly_div2 poly_div2 +#define _poly_div4 poly_div4 +#define _polynomial polynomial +#define _private_tss private_tss +#define _probeintr probeintr +#define _probetrap probetrap +#define _proc0 proc0 +#define _proc0paddr proc0paddr +#define _prv_CMAP1 prv_CMAP1 +#define _prv_CMAP2 prv_CMAP2 +#define _prv_CMAP3 prv_CMAP3 +#define _prv_PMAP1 prv_PMAP1 +#define _prv_CPAGE1 prv_CPAGE1 +#define _prv_CPAGE2 prv_CPAGE2 +#define _prv_CPAGE3 prv_CPAGE3 +#define _prv_PPAGE1 prv_PPAGE1 +#define _qs qs +#define _rcpoll rcpoll +#define _real_2op_NaN real_2op_NaN +#define _reg_div reg_div +#define _reg_u_add reg_u_add +#define _reg_u_div reg_u_div +#define _reg_u_mul reg_u_mul +#define _reg_u_sub reg_u_sub +#define _rel_mplock rel_mplock +#define _round_reg round_reg +#define _rtqs rtqs +#define _s_lock s_lock +#define _s_unlock s_unlock +#define _secondary_main secondary_main +#define _set_precision_flag_down set_precision_flag_down +#define _set_precision_flag_up set_precision_flag_up +#define _set_user_ldt set_user_ldt +#define _shrx shrx +#define _shrxs shrxs +#define _sigcode sigcode +#define _siopoll siopoll +#define _smp_active smp_active +#define _smp_rendezvous_action smp_rendezvous_action +#define _soft_imask soft_imask +#define _softclock softclock +#define _softnet_imask softnet_imask +#define _softtty_imask softtty_imask +#define _spl0 spl0 +#define _splz splz +#define _ss_lock ss_lock +#define _ss_unlock ss_unlock +#define _started_cpus started_cpus +#define _stopped_cpus stopped_cpus +#define _swi_dispatcher swi_dispatcher +#define _swi_generic swi_generic +#define _swi_null swi_null +#define _swi_vm swi_vm +#define _switchticks switchticks +#define _switchtime switchtime +#define _syscall syscall +#define _szsigcode szsigcode +#define _ticks ticks +#define _time time +#define _timer0_max_count timer0_max_count +#define _timer0_overflow_threshold timer0_overflow_threshold +#define _timer0_prescaler_count timer0_prescaler_count +#define _trap trap +#define _trap_by_wrmsr trap_by_wrmsr +#define _trapwrite trapwrite +#define _tsc_bias tsc_bias +#define _tsc_freq tsc_freq +#define _tsc_multiplier tsc_multiplier +#define _tty_imask tty_imask +#define _userconfig_from_boot userconfig_from_boot +#define _vec vec +#define _vec8254 vec8254 +#define _vecRTC vecRTC +#define _vm86_emulate vm86_emulate +#define _vm86_prepcall vm86_prepcall +#define _vm86_sysarch vm86_sysarch +#define _vm86_trap vm86_trap +#define _vm86pa vm86pa +#define _vm86paddr vm86paddr +#define _vm86pcb vm86pcb +#define _vm_page_zero_idle vm_page_zero_idle +#define _want_resched want_resched +#define _whichidqs whichidqs +#define _whichqs whichqs +#define _whichrtqs whichrtqs +#define _wm_sqrt wm_sqrt + +#endif /* __ELF__ */ + +#endif /* !_MACHINE_ASNAMES_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/atomic.h ./modules/label/machine/atomic.h --- ../sys-altq/modules/label/machine/atomic.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/atomic.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,112 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/atomic.h,v 1.1.2.2 1999/08/29 16:06:20 peter Exp $ + */ +#ifndef _MACHINE_ATOMIC_H_ +#define _MACHINE_ATOMIC_H_ + +/* + * Various simple arithmetic on memory which is atomic in the presence + * of interrupts and multiple processors. + * + * atomic_set_char(P, V) (*(u_char*)(P) |= (V)) + * atomic_clear_char(P, V) (*(u_char*)(P) &= ~(V)) + * atomic_add_char(P, V) (*(u_char*)(P) += (V)) + * atomic_subtract_char(P, V) (*(u_char*)(P) -= (V)) + * + * atomic_set_short(P, V) (*(u_short*)(P) |= (V)) + * atomic_clear_short(P, V) (*(u_short*)(P) &= ~(V)) + * atomic_add_short(P, V) (*(u_short*)(P) += (V)) + * atomic_subtract_short(P, V) (*(u_short*)(P) -= (V)) + * + * atomic_set_int(P, V) (*(u_int*)(P) |= (V)) + * atomic_clear_int(P, V) (*(u_int*)(P) &= ~(V)) + * atomic_add_int(P, V) (*(u_int*)(P) += (V)) + * atomic_subtract_int(P, V) (*(u_int*)(P) -= (V)) + * + * atomic_set_long(P, V) (*(u_long*)(P) |= (V)) + * atomic_clear_long(P, V) (*(u_long*)(P) &= ~(V)) + * atomic_add_long(P, V) (*(u_long*)(P) += (V)) + * atomic_subtract_long(P, V) (*(u_long*)(P) -= (V)) + */ + +/* + * The above functions are expanded inline in the statically-linked + * kernel. Lock prefixes are generated if an SMP kernel is being + * built. + * + * Kernel modules call real functions which are built into the kernel. + * This allows kernel modules to be portable between UP and SMP systems. + * + * Warning: Use this version with gcc 2.7.2.x only. Newer compilers + * require different constraints in the asm statement. + */ +#if defined(KLD_MODULE) +#define ATOMIC_ASM(NAME, TYPE, OP, V) \ + extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); + +#else /* !KLD_MODULE */ +#if defined(SMP) +#define MPLOCKED "lock ; " +#else +#define MPLOCKED +#endif + +/* + * The assembly is volatilized to demark potential before-and-after side + * effects if an interrupt or SMP collision were to occur. + */ +#define ATOMIC_ASM(NAME, TYPE, OP, V) \ +static __inline void \ +atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ +{ \ + __asm __volatile(MPLOCKED OP \ + : "=m" (*p) \ + : "ir" (V)); \ +} +#endif /* KLD_MODULE */ + +ATOMIC_ASM(set, char, "orb %1,%0", v) +ATOMIC_ASM(clear, char, "andb %1,%0", ~v) +ATOMIC_ASM(add, char, "addb %1,%0", v) +ATOMIC_ASM(subtract, char, "subb %1,%0", v) + +ATOMIC_ASM(set, short, "orw %1,%0", v) +ATOMIC_ASM(clear, short, "andw %1,%0", ~v) +ATOMIC_ASM(add, short, "addw %1,%0", v) +ATOMIC_ASM(subtract, short, "subw %1,%0", v) + +ATOMIC_ASM(set, int, "orl %1,%0", v) +ATOMIC_ASM(clear, int, "andl %1,%0", ~v) +ATOMIC_ASM(add, int, "addl %1,%0", v) +ATOMIC_ASM(subtract, int, "subl %1,%0", v) + +ATOMIC_ASM(set, long, "orl %1,%0", v) +ATOMIC_ASM(clear, long, "andl %1,%0", ~v) +ATOMIC_ASM(add, long, "addl %1,%0", v) +ATOMIC_ASM(subtract, long, "subl %1,%0", v) + +#endif /* ! _MACHINE_ATOMIC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/bootinfo.h ./modules/label/machine/bootinfo.h --- ../sys-altq/modules/label/machine/bootinfo.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/bootinfo.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,74 @@ +/*- + * Copyright (C) 1994 by Rodney W. Grimes, Milwaukie, Oregon 97222 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Rodney W. Grimes. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RODNEY W. GRIMES ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL RODNEY W. GRIMES BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/bootinfo.h,v 1.12.2.1 1999/08/29 16:06:20 peter Exp $ + */ + +#ifndef _MACHINE_BOOTINFO_H_ +#define _MACHINE_BOOTINFO_H_ + +/* Only change the version number if you break compatibility. */ +#define BOOTINFO_VERSION 1 + +#define N_BIOS_GEOM 8 + +/* + * A zero bootinfo field often means that there is no info available. + * Flags are used to indicate the validity of fields where zero is a + * normal value. + */ +struct bootinfo { + u_int32_t bi_version; + u_int32_t bi_kernelname; /* represents a char * */ + u_int32_t bi_nfs_diskless; /* struct nfs_diskless * */ + /* End of fields that are always present. */ +#define bi_endcommon bi_n_bios_used + u_int32_t bi_n_bios_used; + u_int32_t bi_bios_geom[N_BIOS_GEOM]; + u_int32_t bi_size; + u_int8_t bi_memsizes_valid; + u_int8_t bi_bios_dev; /* bootdev BIOS unit number */ + u_int8_t bi_pad[2]; + u_int32_t bi_basemem; + u_int32_t bi_extmem; + u_int32_t bi_symtab; /* struct symtab * */ + u_int32_t bi_esymtab; /* struct symtab * */ + /* Items below only from advanced bootloader */ + u_int32_t bi_kernend; /* end of kernel space */ + u_int32_t bi_envp; /* environment */ + u_int32_t bi_modulep; /* preloaded modules */ +}; + +#ifdef KERNEL +extern struct bootinfo bootinfo; +#endif + +#endif /* !_MACHINE_BOOTINFO_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/bus.h ./modules/label/machine/bus.h --- ../sys-altq/modules/label/machine/bus.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/bus.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,1281 @@ +/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */ + +/*- + * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1996 Charles M. Hannum. All rights reserved. + * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* $FreeBSD: src/sys/i386/include/bus.h,v 1.4.2.1 1999/08/29 16:06:21 peter Exp $ */ + +#ifndef _I386_BUS_H_ +#define _I386_BUS_H_ + +#include + +/* + * Values for the i386 bus space tag, not to be used directly by MI code. + */ +#define I386_BUS_SPACE_IO 0 /* space is i/o space */ +#define I386_BUS_SPACE_MEM 1 /* space is mem space */ + +/* + * Bus address and size types + */ +typedef u_int bus_addr_t; +typedef u_int bus_size_t; + +#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF +#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF +#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */ +#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF +#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF +#define BUS_SPACE_MAXADDR 0xFFFFFFFF + +#define BUS_SPACE_UNRESTRICTED (~0) + +/* + * Access methods for bus resources and address space. + */ +typedef int bus_space_tag_t; +typedef u_int bus_space_handle_t; + +/* + * Map a region of device bus space into CPU virtual address space. + */ + +#define BUS_SPACE_MAP_CACHEABLE 0x01 +#define BUS_SPACE_MAP_LINEAR 0x02 + +int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size, + int flags, bus_space_handle_t *bshp); + +/* + * Unmap a region of device bus space. + */ + +void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, + bus_size_t size); + +/* + * Get a new handle for a subregion of an already-mapped area of bus space. + */ + +int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size, + bus_space_handle_t *nbshp); + +/* + * Allocate a region of memory that is accessible to devices in bus space. + */ + +int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, + bus_addr_t rend, bus_size_t size, bus_size_t align, + bus_size_t boundary, int flags, bus_addr_t *addrp, + bus_space_handle_t *bshp); + +/* + * Free a region of bus space accessible memory. + */ + +void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, + bus_size_t size); + +#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_) + +/* + * Read a 1, 2, 4, or 8 byte quantity from bus space + * described by tag/handle/offset. + */ +static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag, + bus_space_handle_t handle, + bus_size_t offset); + +static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag, + bus_space_handle_t handle, + bus_size_t offset); + +static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag, + bus_space_handle_t handle, + bus_size_t offset); + +static __inline u_int8_t +bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle, + bus_size_t offset) +{ +#if defined (_I386_BUS_PIO_H_) +#if defined (_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + return (inb(handle + offset)); +#endif +#if defined (_I386_BUS_MEMIO_H_) + return (*(volatile u_int8_t *)(handle + offset)); +#endif +} + +static __inline u_int16_t +bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle, + bus_size_t offset) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + return (inw(handle + offset)); +#endif +#if defined(_I386_BUS_MEMIO_H_) + return (*(volatile u_int16_t *)(handle + offset)); +#endif +} + +static __inline u_int32_t +bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle, + bus_size_t offset) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + return (inl(handle + offset)); +#endif +#if defined(_I386_BUS_MEMIO_H_) + return (*(volatile u_int32_t *)(handle + offset)); +#endif +} + +#if 0 /* Cause a link error for bus_space_read_8 */ +#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! +#endif + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ +static __inline void bus_space_read_multi_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, + size_t count); + +static __inline void bus_space_read_multi_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, + size_t count); + +static __inline void bus_space_read_multi_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, + size_t count); + +static __inline void +bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + insb(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: movb (%1),%%al \n\ + stosb \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "D" (addr), "c" (count) : + "%edi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + insw(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: movw (%1),%%ax \n\ + stosw \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "D" (addr), "c" (count) : + "%edi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + insl(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: movl (%1),%%eax \n\ + stosl \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "D" (addr), "c" (count) : + "%edi", "%ecx", "memory"); + } +#endif +} + +#if 0 /* Cause a link error for bus_space_read_multi_8 */ +#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! +#endif + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ +static __inline void bus_space_read_region_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, + size_t count); + +static __inline void bus_space_read_region_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, + size_t count); + +static __inline void bus_space_read_region_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, + size_t count); + + +static __inline void +bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: inb %w1,%%al \n\ + stosb \n\ + incl %1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "D" (addr), "c" (count) : + "%edx", "%edi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsb" : + : + "S" (bsh + offset), "D" (addr), "c" (count) : + "%esi", "%edi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: inw %w1,%%ax \n\ + stosw \n\ + addl $2,%1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "D" (addr), "c" (count) : + "%edx", "%edi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsw" : + : + "S" (bsh + offset), "D" (addr), "c" (count) : + "%esi", "%edi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: inl %w1,%%eax \n\ + stosl \n\ + addl $4,%1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "D" (addr), "c" (count) : + "%edx", "%edi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsl" : + : + "S" (bsh + offset), "D" (addr), "c" (count) : + "%esi", "%edi", "%ecx", "memory"); + } +#endif +} + +#if 0 /* Cause a link error for bus_space_read_region_8 */ +#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! +#endif + +/* + * Write the 1, 2, 4, or 8 byte value `value' to bus space + * described by tag/handle/offset. + */ + +static __inline void bus_space_write_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value); + +static __inline void bus_space_write_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value); + +static __inline void bus_space_write_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value); + +static __inline void +bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outb(bsh + offset, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + *(volatile u_int8_t *)(bsh + offset) = value; +#endif +} + +static __inline void +bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outw(bsh + offset, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + *(volatile u_int16_t *)(bsh + offset) = value; +#endif +} + +static __inline void +bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outl(bsh + offset, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + *(volatile u_int32_t *)(bsh + offset) = value; +#endif +} + +#if 0 /* Cause a link error for bus_space_write_8 */ +#define bus_space_write_8 !!! bus_space_write_8 not implemented !!! +#endif + +/* + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer + * provided to bus space described by tag/handle/offset. + */ + +static __inline void bus_space_write_multi_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int8_t *addr, + size_t count); +static __inline void bus_space_write_multi_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t *addr, + size_t count); + +static __inline void bus_space_write_multi_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int32_t *addr, + size_t count); + +static __inline void +bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int8_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outsb(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsb \n\ + movb %%al,(%1) \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "S" (addr), "c" (count) : + "%esi", "%ecx"); + } +#endif +} + +static __inline void +bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int16_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outsw(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsw \n\ + movw %%ax,(%1) \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "S" (addr), "c" (count) : + "%esi", "%ecx"); + } +#endif +} + +static __inline void +bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int32_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + outsl(bsh + offset, addr, count); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsl \n\ + movl %%eax,(%1) \n\ + loop 1b" : + "=&a" (__x) : + "r" (bsh + offset), "S" (addr), "c" (count) : + "%esi", "%ecx"); + } +#endif +} + +#if 0 /* Cause a link error for bus_space_write_multi_8 */ +#define bus_space_write_multi_8(t, h, o, a, c) \ + !!! bus_space_write_multi_8 unimplemented !!! +#endif + +/* + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided + * to bus space described by tag/handle starting at `offset'. + */ + +static __inline void bus_space_write_region_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int8_t *addr, + size_t count); +static __inline void bus_space_write_region_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t *addr, + size_t count); +static __inline void bus_space_write_region_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int32_t *addr, + size_t count); + +static __inline void +bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int8_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsb \n\ + outb %%al,%w1 \n\ + incl %1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "S" (addr), "c" (count) : + "%edx", "%esi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsb" : + : + "D" (bsh + offset), "S" (addr), "c" (count) : + "%edi", "%esi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int16_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsw \n\ + outw %%ax,%w1 \n\ + addl $2,%1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "S" (addr), "c" (count) : + "%edx", "%esi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsw" : + : + "D" (bsh + offset), "S" (addr), "c" (count) : + "%edi", "%esi", "%ecx", "memory"); + } +#endif +} + +static __inline void +bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, const u_int32_t *addr, size_t count) +{ +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + int __x __asm__("%eax"); + __asm __volatile(" \n\ + cld \n\ + 1: lodsl \n\ + outl %%eax,%w1 \n\ + addl $4,%1 \n\ + loop 1b" : + "=&a" (__x) : + "d" (bsh + offset), "S" (addr), "c" (count) : + "%edx", "%esi", "%ecx", "memory"); + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + __asm __volatile(" \n\ + cld \n\ + repne \n\ + movsl" : + : + "D" (bsh + offset), "S" (addr), "c" (count) : + "%edi", "%esi", "%ecx", "memory"); + } +#endif +} + +#if 0 /* Cause a link error for bus_space_write_region_8 */ +#define bus_space_write_region_8 \ + !!! bus_space_write_region_8 unimplemented !!! +#endif + +/* + * Write the 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle/offset `count' times. + */ + +static __inline void bus_space_set_multi_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + u_int8_t value, size_t count); +static __inline void bus_space_set_multi_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + u_int16_t value, size_t count); +static __inline void bus_space_set_multi_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, + u_int32_t value, size_t count); + +static __inline void +bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + while (count--) + outb(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + while (count--) + *(volatile u_int8_t *)(addr) = value; +#endif +} + +static __inline void +bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + while (count--) + outw(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + while (count--) + *(volatile u_int16_t *)(addr) = value; +#endif +} + +static __inline void +bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + while (count--) + outl(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + while (count--) + *(volatile u_int32_t *)(addr) = value; +#endif +} + +#if 0 /* Cause a link error for bus_space_set_multi_8 */ +#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!! +#endif + +/* + * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle starting at `offset'. + */ + +static __inline void bus_space_set_region_1(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value, + size_t count); +static __inline void bus_space_set_region_2(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, + size_t count); +static __inline void bus_space_set_region_4(bus_space_tag_t tag, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, + size_t count); + +static __inline void +bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + for (; count != 0; count--, addr++) + outb(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + for (; count != 0; count--, addr++) + *(volatile u_int8_t *)(addr) = value; +#endif +} + +static __inline void +bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + for (; count != 0; count--, addr += 2) + outw(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + for (; count != 0; count--, addr += 2) + *(volatile u_int16_t *)(addr) = value; +#endif +} + +static __inline void +bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + for (; count != 0; count--, addr += 4) + outl(addr, value); +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + for (; count != 0; count--, addr += 4) + *(volatile u_int32_t *)(addr) = value; +#endif +} + +#if 0 /* Cause a link error for bus_space_set_region_8 */ +#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!! +#endif + +/* + * Copy `count' 1, 2, 4, or 8 byte values from bus space starting + * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. + */ + +static __inline void bus_space_copy_region_1(bus_space_tag_t tag, + bus_space_handle_t bsh1, + bus_size_t off1, + bus_space_handle_t bsh2, + bus_size_t off2, size_t count); + +static __inline void bus_space_copy_region_2(bus_space_tag_t tag, + bus_space_handle_t bsh1, + bus_size_t off1, + bus_space_handle_t bsh2, + bus_size_t off2, size_t count); + +static __inline void bus_space_copy_region_4(bus_space_tag_t tag, + bus_space_handle_t bsh1, + bus_size_t off1, + bus_space_handle_t bsh2, + bus_size_t off2, size_t count); + +static __inline void +bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1, + bus_size_t off1, bus_space_handle_t bsh2, + bus_size_t off2, size_t count) +{ + bus_addr_t addr1 = bsh1 + off1; + bus_addr_t addr2 = bsh2 + off2; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1++, addr2++) + outb(addr2, inb(addr1)); + } else { + /* dest after src: copy backwards */ + for (addr1 += (count - 1), addr2 += (count - 1); + count != 0; count--, addr1--, addr2--) + outb(addr2, inb(addr1)); + } + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1++, addr2++) + *(volatile u_int8_t *)(addr2) = + *(volatile u_int8_t *)(addr1); + } else { + /* dest after src: copy backwards */ + for (addr1 += (count - 1), addr2 += (count - 1); + count != 0; count--, addr1--, addr2--) + *(volatile u_int8_t *)(addr2) = + *(volatile u_int8_t *)(addr1); + } + } +#endif +} + +static __inline void +bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1, + bus_size_t off1, bus_space_handle_t bsh2, + bus_size_t off2, size_t count) +{ + bus_addr_t addr1 = bsh1 + off1; + bus_addr_t addr2 = bsh2 + off2; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1 += 2, addr2 += 2) + outw(addr2, inw(addr1)); + } else { + /* dest after src: copy backwards */ + for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1); + count != 0; count--, addr1 -= 2, addr2 -= 2) + outw(addr2, inw(addr1)); + } + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1 += 2, addr2 += 2) + *(volatile u_int16_t *)(addr2) = + *(volatile u_int16_t *)(addr1); + } else { + /* dest after src: copy backwards */ + for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1); + count != 0; count--, addr1 -= 2, addr2 -= 2) + *(volatile u_int16_t *)(addr2) = + *(volatile u_int16_t *)(addr1); + } + } +#endif +} + +static __inline void +bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1, + bus_size_t off1, bus_space_handle_t bsh2, + bus_size_t off2, size_t count) +{ + bus_addr_t addr1 = bsh1 + off1; + bus_addr_t addr2 = bsh2 + off2; + +#if defined(_I386_BUS_PIO_H_) +#if defined(_I386_BUS_MEMIO_H_) + if (tag == I386_BUS_SPACE_IO) +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1 += 4, addr2 += 4) + outl(addr2, inl(addr1)); + } else { + /* dest after src: copy backwards */ + for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1); + count != 0; count--, addr1 -= 4, addr2 -= 4) + outl(addr2, inl(addr1)); + } + } +#endif +#if defined(_I386_BUS_MEMIO_H_) +#if defined(_I386_BUS_PIO_H_) + else +#endif + { + if (addr1 >= addr2) { + /* src after dest: copy forward */ + for (; count != 0; count--, addr1 += 4, addr2 += 4) + *(volatile u_int32_t *)(addr2) = + *(volatile u_int32_t *)(addr1); + } else { + /* dest after src: copy backwards */ + for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1); + count != 0; count--, addr1 -= 4, addr2 -= 4) + *(volatile u_int32_t *)(addr2) = + *(volatile u_int32_t *)(addr1); + } + } +#endif +} + +#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */ + +#if 0 /* Cause a link error for bus_space_copy_8 */ +#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!! +#endif + +/* + * Bus read/write barrier methods. + * + * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh, + * bus_size_t offset, bus_size_t len, int flags); + * + * Note: the i386 does not currently require barriers, but we must + * provide the flags to MI code. + */ +#define bus_space_barrier(t, h, o, l, f) \ + ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) +#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ +#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ + +/* + * Flags used in various bus DMA methods. + */ +#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */ +#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */ +#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */ +#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */ +#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */ +#define BUS_DMA_BUS2 0x20 +#define BUS_DMA_BUS3 0x40 +#define BUS_DMA_BUS4 0x80 + +/* Forwards needed by prototypes below. */ +struct mbuf; +struct uio; + +/* + * bus_dmasync_op_t + * + * Operations performed by bus_dmamap_sync(). + */ +typedef enum { + BUS_DMASYNC_PREREAD, + BUS_DMASYNC_POSTREAD, + BUS_DMASYNC_PREWRITE, + BUS_DMASYNC_POSTWRITE +} bus_dmasync_op_t; + +/* + * bus_dma_tag_t + * + * A machine-dependent opaque type describing the characteristics + * of how to perform DMA mappings. This structure encapsultes + * information concerning address and alignment restrictions, number + * of S/G segments, amount of data per S/G segment, etc. + */ +typedef struct bus_dma_tag *bus_dma_tag_t; + +/* + * bus_dmamap_t + * + * DMA mapping instance information. + */ +typedef struct bus_dmamap *bus_dmamap_t; + +/* + * bus_dma_segment_t + * + * Describes a single contiguous DMA transaction. Values + * are suitable for programming into DMA registers. + */ +typedef struct bus_dma_segment { + bus_addr_t ds_addr; /* DMA address */ + bus_size_t ds_len; /* length of transfer */ +} bus_dma_segment_t; + +/* + * A function that returns 1 if the address cannot be accessed by + * a device and 0 if it can be. + */ +typedef int bus_dma_filter_t(void *, bus_addr_t); + +/* + * Allocate a device specific dma_tag encapsulating the constraints of + * the parent tag in addition to other restrictions specified: + * + * alignment: alignment for segments. + * boundary: Boundary that segments cannot cross. + * lowaddr: Low restricted address that cannot appear in a mapping. + * highaddr: High restricted address that cannot appear in a mapping. + * filtfunc: An optional function to further test if an address + * within the range of lowaddr and highaddr cannot appear + * in a mapping. + * filtfuncarg: An argument that will be passed to filtfunc in addition + * to the address to test. + * maxsize: Maximum mapping size supported by this tag. + * nsegments: Number of discontinuities allowed in maps. + * maxsegsz: Maximum size of a segment in the map. + * flags: Bus DMA flags. + * dmat: A pointer to set to a valid dma tag should the return + * value of this function indicate success. + */ +/* XXX Should probably allow specification of alignment */ +int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt, + bus_size_t boundary, bus_addr_t lowaddr, + bus_addr_t highaddr, bus_dma_filter_t *filtfunc, + void *filtfuncarg, bus_size_t maxsize, int nsegments, + bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat); + +int bus_dma_tag_destroy(bus_dma_tag_t dmat); + +/* + * Allocate a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp); + +/* + * Destroy a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map); + +/* + * Allocate a piece of memory that can be efficiently mapped into + * bus device space based on the constraints lited in the dma tag. + * A dmamap to for use with dmamap_load is also allocated. + */ +int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, + bus_dmamap_t *mapp); + +/* + * Free a piece of memory and it's allociated dmamap, that was allocated + * via bus_dmamem_alloc. + */ +void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map); + +/* + * A function that processes a successfully loaded dma map or an error + * from a delayed load map. + */ +typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); + +/* + * Map the buffer buf into bus space using the dmamap map. + */ +int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, + bus_size_t buflen, bus_dmamap_callback_t *callback, + void *callback_arg, int flags); + +/* + * Perform a syncronization operation on the given map. + */ +void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); +#define bus_dmamap_sync(dmat, dmamap, op) \ + if ((dmamap) != NULL) \ + _bus_dmamap_sync(dmat, dmamap, op) + +/* + * Release the mapping held by map. + */ +void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); +#define bus_dmamap_unload(dmat, dmamap) \ + if ((dmamap) != NULL) \ + _bus_dmamap_unload(dmat, dmamap) + +#endif /* _I386_BUS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/bus_memio.h ./modules/label/machine/bus_memio.h --- ../sys-altq/modules/label/machine/bus_memio.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/bus_memio.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1997 Justin Gibbs. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/bus_memio.h,v 1.1.4.1 1999/08/29 16:06:21 peter Exp $ + */ + +#ifndef _I386_BUS_MEMIO_H_ +#define _I386_BUS_MEMIO_H_ +#endif /* _I386_BUS_MEMIO_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/bus_pio.h ./modules/label/machine/bus_pio.h --- ../sys-altq/modules/label/machine/bus_pio.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/bus_pio.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1997 Justin Gibbs. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/bus_pio.h,v 1.1.4.1 1999/08/29 16:06:22 peter Exp $ + */ + +#ifndef _I386_BUS_PIO_H_ +#define _I386_BUS_PIO_H_ +#endif /* _I386_BUS_PIO_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cdk.h ./modules/label/machine/cdk.h --- ../sys-altq/modules/label/machine/cdk.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cdk.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,495 @@ +/*****************************************************************************/ + +/* + * cdk.h -- CDK interface definitions. + * + * Copyright (c) 1994-1996 Greg Ungerer (gerg@stallion.oz.au). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Greg Ungerer. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/cdk.h,v 1.4.4.1 1999/08/29 16:06:22 peter Exp $ + */ + +/*****************************************************************************/ +#ifndef _CDK_H +#define _CDK_H +/*****************************************************************************/ + +#pragma pack(2) + +/* + * The following set of definitions is used to communicate with the + * shared memory interface of the Stallion intelligent multiport serial + * boards. The definitions in this file are taken directly from the + * document titled "Generic Stackable Interface, Downloader and + * Communications Development Kit". + */ + +/* + * Define the set of importrant shared memory addresses. These are + * required to intialize the board and get things started. All of these + * addresses are relative to the start of the shared memory. + */ +#define CDK_SIGADDR 0x200 +#define CDK_FEATADDR 0x280 +#define CDK_CDKADDR 0x300 +#define CDK_RDYADDR 0x262 + +#define CDK_ALIVEMARKER 13 + +/* + * On hardware power up the ROMs located on the EasyConnection 8/64 will + * fill out the following signature information into shared memory. This + * way the host system can quickly determine that the board is present + * and is operational. + */ +typedef struct cdkecpsig { + unsigned long magic; + unsigned short romver; + unsigned short cputype; + unsigned char panelid[8]; +} cdkecpsig_t; + +#define ECP_MAGIC 0x21504345 + +/* + * On hardware power up the ROMs located on the ONboard, Stallion and + * Brumbys will fill out the following signature information into shared + * memory. This way the host system can quickly determine that the board + * is present and is operational. + */ +typedef struct cdkonbsig { + unsigned short magic0; + unsigned short magic1; + unsigned short magic2; + unsigned short magic3; + unsigned short romver; + unsigned short memoff; + unsigned short memseg; + unsigned short amask0; + unsigned short pic; + unsigned short status; + unsigned short btype; + unsigned short clkticks; + unsigned short clkspeed; + unsigned short amask1; + unsigned short amask2; +} cdkonbsig_t; + +#define ONB_MAGIC0 0xf2a7 +#define ONB_MAGIC1 0xa149 +#define ONB_MAGIC2 0x6352 +#define ONB_MAGIC3 0xf121 + +/* + * Define the feature area structure. The feature area is the set of + * startup parameters used by the slave image when it starts executing. + * They allow for the specification of buffer sizes, debug trace, etc. + */ +typedef struct cdkfeature { + unsigned long debug; + unsigned long banner; + unsigned long etype; + unsigned long nrdevs; + unsigned long brdspec; + unsigned long txrqsize; + unsigned long rxrqsize; + unsigned long flags; +} cdkfeature_t; + +#define ETYP_DDK 0 +#define ETYP_CDK 1 + +/* + * Define the CDK header structure. This is the info that the slave + * environment sets up after it has been downloaded and started. It + * essentially provides a memory map for the shared memory interface. + */ +typedef struct cdkhdr { + unsigned short command; + unsigned short status; + unsigned short port; + unsigned short mode; + unsigned long cmd_buf[14]; + unsigned short alive_cnt; + unsigned short intrpt_mode; + unsigned char intrpt_id[8]; + unsigned char ver_release; + unsigned char ver_modification; + unsigned char ver_fix; + unsigned char deadman_restart; + unsigned short deadman; + unsigned short nrdevs; + unsigned long memp; + unsigned long hostp; + unsigned long slavep; + unsigned char hostreq; + unsigned char slavereq; + unsigned char cmd_reserved[30]; +} cdkhdr_t; + +#define MODE_DDK 0 +#define MODE_CDK 1 + +#define IMD_INTR 0x0 +#define IMD_PPINTR 0x1 +#define IMD_POLL 0xff + +/* + * Define the memory mapping structure. This structure is pointed to by + * the memp field in the stlcdkhdr struct. As many as these structures + * as required are layed out in shared memory to define how the rest of + * shared memory is divided up. There will be one for each port. + */ +typedef struct cdkmem { + unsigned short dtype; + unsigned long offset; +} cdkmem_t; + +#define TYP_UNDEFINED 0x0 +#define TYP_ASYNCTRL 0x1 +#define TYP_ASYNC 0x20 +#define TYP_PARALLEL 0x40 +#define TYP_SYNCX21 0x60 + +/*****************************************************************************/ + +/* + * Following is a set of defines and structures used to actually deal + * with the serial ports on the board. Firstly is the set of commands + * that can be applied to ports. + */ +#define ASYCMD (((unsigned long) 'a') << 8) + +#define A_NULL (ASYCMD | 0) +#define A_FLUSH (ASYCMD | 1) +#define A_BREAK (ASYCMD | 2) +#define A_GETPORT (ASYCMD | 3) +#define A_SETPORT (ASYCMD | 4) +#define A_SETPORTF (ASYCMD | 5) +#define A_SETPORTFTX (ASYCMD | 6) +#define A_SETPORTFRX (ASYCMD | 7) +#define A_GETSIGNALS (ASYCMD | 8) +#define A_SETSIGNALS (ASYCMD | 9) +#define A_SETSIGNALSF (ASYCMD | 10) +#define A_SETSIGNALSFTX (ASYCMD | 11) +#define A_SETSIGNALSFRX (ASYCMD | 12) +#define A_GETNOTIFY (ASYCMD | 13) +#define A_SETNOTIFY (ASYCMD | 14) +#define A_NOTIFY (ASYCMD | 15) +#define A_PORTCTRL (ASYCMD | 16) +#define A_GETSTATS (ASYCMD | 17) +#define A_RQSTATE (ASYCMD | 18) +#define A_FLOWSTATE (ASYCMD | 19) +#define A_CLEARSTATS (ASYCMD | 20) + +/* + * Define those arguments used for simple commands. + */ +#define FLUSHRX 0x1 +#define FLUSHTX 0x2 + +#define BREAKON -1 +#define BREAKOFF -2 + +/* + * Define the port setting structure, and all those defines that go along + * with it. Basically this structure defines the charcateristics of this + * port: baud rate, chars, parity, input/output char cooking etc. + */ +typedef struct asyport { + unsigned long baudout; + unsigned long baudin; + unsigned long iflag; + unsigned long oflag; + unsigned long lflag; + unsigned long pflag; + unsigned long flow; + unsigned long spare1; + unsigned short vtime; + unsigned short vmin; + unsigned short txlo; + unsigned short txhi; + unsigned short rxlo; + unsigned short rxhi; + unsigned short rxhog; + unsigned short spare2; + unsigned char csize; + unsigned char stopbs; + unsigned char parity; + unsigned char stopin; + unsigned char startin; + unsigned char stopout; + unsigned char startout; + unsigned char parmark; + unsigned char brkmark; + unsigned char cc[11]; +} asyport_t; + +#define PT_STOP1 0x0 +#define PT_STOP15 0x1 +#define PT_STOP2 0x2 + +#define PT_NOPARITY 0x0 +#define PT_ODDPARITY 0x1 +#define PT_EVENPARITY 0x2 +#define PT_MARKPARITY 0x3 +#define PT_SPACEPARITY 0x4 + +#define F_NONE 0x0 +#define F_IXON 0x1 +#define F_IXOFF 0x2 +#define F_IXANY 0x4 +#define F_IOXANY 0x8 +#define F_RTSFLOW 0x10 +#define F_CTSFLOW 0x20 +#define F_DTRFLOW 0x40 +#define F_DCDFLOW 0x80 +#define F_DSROFLOW 0x100 +#define F_DSRIFLOW 0x200 + +#define FI_NORX 0x1 +#define FI_RAW 0x2 +#define FI_ISTRIP 0x4 +#define FI_UCLC 0x8 +#define FI_INLCR 0x10 +#define FI_ICRNL 0x20 +#define FI_IGNCR 0x40 +#define FI_IGNBREAK 0x80 +#define FI_DSCRDBREAK 0x100 +#define FI_1MARKBREAK 0x200 +#define FI_2MARKBREAK 0x400 +#define FI_XCHNGBREAK 0x800 +#define FI_IGNRXERRS 0x1000 +#define FI_DSCDRXERRS 0x2000 +#define FI_1MARKRXERRS 0x4000 +#define FI_2MARKRXERRS 0x8000 +#define FI_XCHNGRXERRS 0x10000 +#define FI_DSCRDNULL 0x20000 + +#define FO_OLCUC 0x1 +#define FO_ONLCR 0x2 +#define FO_OOCRNL 0x4 +#define FO_ONOCR 0x8 +#define FO_ONLRET 0x10 +#define FO_ONL 0x20 +#define FO_OBS 0x40 +#define FO_OVT 0x80 +#define FO_OFF 0x100 +#define FO_OTAB1 0x200 +#define FO_OTAB2 0x400 +#define FO_OTAB3 0x800 +#define FO_OCR1 0x1000 +#define FO_OCR2 0x2000 +#define FO_OCR3 0x4000 +#define FO_OFILL 0x8000 +#define FO_ODELL 0x10000 + +#define P_RTSLOCK 0x1 +#define P_CTSLOCK 0x2 +#define P_MAPRTS 0x4 +#define P_MAPCTS 0x8 +#define P_LOOPBACK 0x10 +#define P_DTRFOLLOW 0x20 +#define P_FAKEDCD 0x40 + +/* + * Define a structure to communicate serial port signal and data state + * information. + */ +typedef struct asysigs { + unsigned long data; + unsigned long signal; + unsigned long sigvalue; +} asysigs_t; + +#define DT_TXBUSY 0x1 +#define DT_TXEMPTY 0x2 +#define DT_TXLOW 0x4 +#define DT_TXHIGH 0x8 +#define DT_TXFULL 0x10 +#define DT_TXHOG 0x20 +#define DT_TXFLOWED 0x40 +#define DT_TXBREAK 0x80 + +#define DT_RXBUSY 0x100 +#define DT_RXEMPTY 0x200 +#define DT_RXLOW 0x400 +#define DT_RXHIGH 0x800 +#define DT_RXFULL 0x1000 +#define DT_RXHOG 0x2000 +#define DT_RXFLOWED 0x4000 +#define DT_RXBREAK 0x8000 + +#define SG_DTR 0x1 +#define SG_DCD 0x2 +#define SG_RTS 0x4 +#define SG_CTS 0x8 +#define SG_DSR 0x10 +#define SG_RI 0x20 + +/* + * Define the notification setting structure. This is used to tell the + * port what events we want to be informed about. Fields here use the + * same defines as for the asysigs structure above. + */ +typedef struct asynotify { + unsigned long ctrl; + unsigned long data; + unsigned long signal; + unsigned long sigvalue; +} asynotify_t; + +/* + * Define the port control structure. It is used to do fine grain + * control operations on the port. + */ +typedef struct { + unsigned long rxctrl; + unsigned long txctrl; + char rximdch; + char tximdch; + char spare1; + char spare2; +} asyctrl_t; + +#define CT_ENABLE 0x1 +#define CT_DISABLE 0x2 +#define CT_STOP 0x4 +#define CT_START 0x8 +#define CT_STARTFLOW 0x10 +#define CT_STOPFLOW 0x20 +#define CT_SENDCHR 0x40 + +/* + * Define the stats structure kept for each port. This is a useful set + * of data collected for each port on the slave. The A_GETSTATS command + * is used to retrive this data from the slave. + */ +typedef struct asystats { + unsigned long opens; + unsigned long txchars; + unsigned long rxchars; + unsigned long txringq; + unsigned long rxringq; + unsigned long txmsgs; + unsigned long rxmsgs; + unsigned long txflushes; + unsigned long rxflushes; + unsigned long overruns; + unsigned long framing; + unsigned long parity; + unsigned long ringover; + unsigned long lost; + unsigned long rxstart; + unsigned long rxstop; + unsigned long txstart; + unsigned long txstop; + unsigned long dcdcnt; + unsigned long dtrcnt; + unsigned long ctscnt; + unsigned long rtscnt; + unsigned long dsrcnt; + unsigned long ricnt; + unsigned long txbreaks; + unsigned long rxbreaks; + unsigned long signals; + unsigned long state; + unsigned long hwid; +} asystats_t; + +/*****************************************************************************/ + +/* + * All command and control communication with a device on the slave is + * via a control block in shared memory. Each device has its own control + * block, defined by the following structure. The control block allows + * the host to open, close and control the device on the slave. + */ +typedef struct cdkctrl { + unsigned char open; + unsigned char close; + unsigned long openarg; + unsigned long closearg; + unsigned long cmd; + unsigned long status; + unsigned long args[32]; +} cdkctrl_t; + +/* + * Each device on the slave passes data to and from the host via a ring + * queue in shared memory. Define a ring queue structure to hold the + * vital information about each ring queue. Two ring queues will be + * allocated for each port, one for reveice data and one for transmit + * data. + */ +typedef struct cdkasyrq { + unsigned long offset; + unsigned short size; + unsigned short head; + unsigned short tail; +} cdkasyrq_t; + +/* + * Each asynchronous port is defined in shared memory by the following + * structure. It contains a control block to command a device, and also + * the neccessary data channel information as well. + */ +typedef struct cdkasy { + cdkctrl_t ctrl; + unsigned short notify; + asynotify_t changed; + unsigned short receive; + cdkasyrq_t rxq; + unsigned short transmit; + cdkasyrq_t txq; +} cdkasy_t; + +#pragma pack() + +/*****************************************************************************/ + +/* + * Define the set of ioctls used by the driver to do special things + * to the board. These include interrupting it, and initializeing + * the driver after board startup and shutdown. + */ +#define STL_BINTR _IO('s', 20) +#define STL_BSTART _IO('s', 21) +#define STL_BSTOP _IO('s', 22) +#define STL_BRESET _IO('s', 23) + +/* + * Define a set of ioctl extensions, used to get at special stuff. + */ +#define STL_GETPFLAG _IOR('s', 80, unsigned long) +#define STL_SETPFLAG _IOW('s', 81, unsigned long) + +/*****************************************************************************/ +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/clock.h ./modules/label/machine/clock.h --- ../sys-altq/modules/label/machine/clock.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/clock.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,50 @@ +/* + * Kernel interface to machine-dependent clock driver. + * Garrett Wollman, September 1994. + * This file is in the public domain. + * + * $FreeBSD: src/sys/i386/include/clock.h,v 1.34.2.2 1999/08/29 16:06:23 peter Exp $ + */ + +#ifndef _MACHINE_CLOCK_H_ +#define _MACHINE_CLOCK_H_ + +#ifdef KERNEL +/* + * i386 to clock driver interface. + * XXX large parts of the driver and its interface are misplaced. + */ +extern int adjkerntz; +extern int disable_rtc_set; +extern int statclock_disable; +extern u_int timer_freq; +extern int timer0_max_count; +extern u_int tsc_freq; +extern int tsc_is_broken; +extern int wall_cmos_clock; +#ifdef APIC_IO +extern int apic_8254_intr; +#endif + +/* + * Driver to clock driver interface. + */ +struct clockframe; + +void DELAY __P((int usec)); +int acquire_timer0 __P((int rate, + void (*function)(struct clockframe *frame))); +int acquire_timer2 __P((int mode)); +int release_timer0 __P((void)); +int release_timer2 __P((void)); +#ifndef PC98 +int rtcin __P((int val)); +#else +int acquire_timer1 __P((int mode)); +int release_timer1 __P((void)); +#endif +int sysbeep __P((int pitch, int period)); + +#endif /* KERNEL */ + +#endif /* !_MACHINE_CLOCK_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/comstats.h ./modules/label/machine/comstats.h --- ../sys-altq/modules/label/machine/comstats.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/comstats.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,122 @@ +/*****************************************************************************/ + +/* + * comstats.h -- Serial Port Stats. + * + * Copyright (c) 1994-1996 Greg Ungerer (gerg@stallion.oz.au). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Greg Ungerer. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/comstats.h,v 1.4.4.1 1999/08/29 16:06:24 peter Exp $ + */ + +/*****************************************************************************/ +#ifndef _COMSTATS_H +#define _COMSTATS_H +/*****************************************************************************/ + +/* + * Serial port stats structure. The structure itself is UART + * independent, but some fields may be UART/driver specific (for + * example state). + */ + +typedef struct { + unsigned long brd; + unsigned long panel; + unsigned long port; + unsigned long hwid; + unsigned long type; + unsigned long txtotal; + unsigned long rxtotal; + unsigned long txbuffered; + unsigned long rxbuffered; + unsigned long rxoverrun; + unsigned long rxparity; + unsigned long rxframing; + unsigned long rxlost; + unsigned long txbreaks; + unsigned long rxbreaks; + unsigned long txxon; + unsigned long txxoff; + unsigned long rxxon; + unsigned long rxxoff; + unsigned long txctson; + unsigned long txctsoff; + unsigned long rxrtson; + unsigned long rxrtsoff; + unsigned long modem; + unsigned long state; + unsigned long flags; + unsigned long ttystate; + unsigned long cflags; + unsigned long iflags; + unsigned long oflags; + unsigned long lflags; + unsigned long signals; +} comstats_t; + + +/* + * Board stats structure. Returns usefull info about the board. + */ + +#define COM_MAXPANELS 8 + +typedef struct { + unsigned long panel; + unsigned long type; + unsigned long hwid; + unsigned long nrports; +} companel_t; + +typedef struct { + unsigned long brd; + unsigned long type; + unsigned long hwid; + unsigned long state; + unsigned long ioaddr; + unsigned long ioaddr2; + unsigned long memaddr; + unsigned long irq; + unsigned long nrpanels; + unsigned long nrports; + companel_t panels[COM_MAXPANELS]; +} combrd_t; + + +/* + * Define the ioctl operations for stats stuff. + */ +#define COM_GETPORTSTATS _IOWR('c', 30, comstats_t) +#define COM_CLRPORTSTATS _IOWR('c', 31, comstats_t) +#define COM_GETBRDSTATS _IOWR('c', 32, combrd_t) + +/*****************************************************************************/ +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cons.h ./modules/label/machine/cons.h --- ../sys-altq/modules/label/machine/cons.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cons.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,8 @@ +/* + * Console support headers should be in since MI software + * needs to access these functions. In the mean time, just include the + * header where it sits. + * + * $FreeBSD: src/sys/i386/include/cons.h,v 1.4.4.1 1999/08/29 16:06:24 peter Exp $ + */ +#include diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/console.h ./modules/label/machine/console.h --- ../sys-altq/modules/label/machine/console.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/console.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,635 @@ +/*- + * Copyright (c) 1991-1996 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/console.h,v 1.43.2.3 1999/08/29 16:06:25 peter Exp $ + */ + +#ifndef _MACHINE_CONSOLE_H_ +#define _MACHINE_CONSOLE_H_ + +#ifndef KERNEL +#include +#endif +#include + +#define KDGKBMODE _IOR('K', 6, int) +#define KDSKBMODE _IO('K', 7 /*, int */) +#define KDMKTONE _IO('K', 8 /*, int */) +#define KDGETMODE _IOR('K', 9, int) +#define KDSETMODE _IO('K', 10 /*, int */) +#define KDSBORDER _IO('K', 13 /*, int */) +#define KDGKBSTATE _IOR('K', 19, int) +#define KDSKBSTATE _IO('K', 20 /*, int */) +#define KDENABIO _IO('K', 60) +#define KDDISABIO _IO('K', 61) +#define KIOCSOUND _IO('K', 63 /*, int */) +#define KDGKBTYPE _IOR('K', 64, int) +#define KDGETLED _IOR('K', 65, int) +#define KDSETLED _IO('K', 66 /*, int */) +#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */ +#define KDRASTER _IOW('K', 100, scr_size_t) +#define KDGKBINFO _IOR('K', 101, keyboard_info_t) +#define KDSETREPEAT _IOW('K', 102, keyboard_delay_t) + +#define GETFKEY _IOWR('k', 0, fkeyarg_t) +#define SETFKEY _IOWR('k', 1, fkeyarg_t) +#define GIO_SCRNMAP _IOR('k', 2, scrmap_t) +#define PIO_SCRNMAP _IOW('k', 3, scrmap_t) +#define GIO_KEYMAP _IOR('k', 6, keymap_t) +#define PIO_KEYMAP _IOW('k', 7, keymap_t) +#define GIO_DEADKEYMAP _IOR('k', 8, accentmap_t) +#define PIO_DEADKEYMAP _IOW('k', 9, accentmap_t) +#define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t) +#define PIO_KEYMAPENT _IOW('k', 11, keyarg_t) + +#define GIO_ATTR _IOR('a', 0, int) +#define GIO_COLOR _IOR('c', 0, int) +#define CONS_CURRENT _IOR('c', 1, int) +#define CONS_GET _IOR('c', 2, int) +#define CONS_IO _IO('c', 3) +#define CONS_BLANKTIME _IOW('c', 4, int) +#define CONS_SSAVER _IOW('c', 5, ssaver_t) +#define CONS_GSAVER _IOWR('c', 6, ssaver_t) +#define CONS_CURSORTYPE _IOW('c', 7, int) +#define CONS_BELLTYPE _IOW('c', 8, int) +#define CONS_HISTORY _IOW('c', 9, int) +#define CONS_MOUSECTL _IOWR('c', 10, mouse_info_t) +#define CONS_IDLE _IOR('c', 11, int) +#define CONS_SAVERMODE _IOW('c', 12, int) +#define CONS_SAVERSTART _IOW('c', 13, int) +#define PIO_FONT8x8 _IOW('c', 64, fnt8_t) +#define GIO_FONT8x8 _IOR('c', 65, fnt8_t) +#define PIO_FONT8x14 _IOW('c', 66, fnt14_t) +#define GIO_FONT8x14 _IOR('c', 67, fnt14_t) +#define PIO_FONT8x16 _IOW('c', 68, fnt16_t) +#define GIO_FONT8x16 _IOR('c', 69, fnt16_t) +#define CONS_GETINFO _IOWR('c', 73, vid_info_t) +#define CONS_GETVERS _IOR('c', 74, int) +#define CONS_CURRENTADP _IOR('c', 100, int) +#define CONS_ADPINFO _IOWR('c', 101, video_adapter_info_t) +#define CONS_MODEINFO _IOWR('c', 102, video_info_t) +#define CONS_FINDMODE _IOWR('c', 103, video_info_t) +#define CONS_SETWINORG _IO('c', 104 /* u_int */) + +#define CONS_SETKBD _IO('c', 110 /* int */) +#define CONS_RELKBD _IO('c', 111) + +/* CONS_SAVERMODE */ +#define CONS_LKM_SAVER 0 +#define CONS_USR_SAVER 1 + +#ifdef PC98 +#define ADJUST_CLOCK _IO('t',100) /* for 98note resume */ +#endif + +#define VT_OPENQRY _IOR('v', 1, int) +#define VT_SETMODE _IOW('v', 2, vtmode_t) +#define VT_GETMODE _IOR('v', 3, vtmode_t) +#define VT_RELDISP _IO('v', 4 /*, int */) +#define VT_ACTIVATE _IO('v', 5 /*, int */) +#define VT_WAITACTIVE _IO('v', 6 /*, int */) +#define VT_GETACTIVE _IOR('v', 7, int) + +#define VT_FALSE 0 +#define VT_TRUE 1 +#define VT_ACKACQ 2 + +#define VT_AUTO 0 /* switching is automatic */ +#define VT_PROCESS 1 /* switching controlled by prog */ +#define VT_KERNEL 255 /* switching controlled in kernel */ + +#ifndef _VT_MODE_DECLARED +#define _VT_MODE_DECLARED +struct vt_mode { + char mode; + char waitv; /* not implemented yet SOS */ + short relsig; + short acqsig; + short frsig; /* not implemented yet SOS */ +}; + +typedef struct vt_mode vtmode_t; +#endif /* !_VT_MODE_DECLARED */ + +struct mouse_data { + int x; + int y; + int z; + int buttons; +}; + +struct mouse_mode { + int mode; + int signal; +}; + +struct mouse_event { + int id; /* one based */ + int value; +}; + +#define MOUSE_SHOW 0x01 +#define MOUSE_HIDE 0x02 +#define MOUSE_MOVEABS 0x03 +#define MOUSE_MOVEREL 0x04 +#define MOUSE_GETINFO 0x05 +#define MOUSE_MODE 0x06 +#define MOUSE_ACTION 0x07 +#define MOUSE_MOTION_EVENT 0x08 +#define MOUSE_BUTTON_EVENT 0x09 + +struct mouse_info { + int operation; + union { + struct mouse_data data; + struct mouse_mode mode; + struct mouse_event event; + }u; +}; + +#define KD_MONO 1 /* monochrome adapter */ +#define KD_HERCULES 2 /* hercules adapter */ +#define KD_CGA 3 /* color graphics adapter */ +#define KD_EGA 4 /* enhanced graphics adapter */ +#define KD_VGA 5 /* video graphics adapter */ +#define KD_PC98 6 /* PC-98 display */ + +#define KD_TEXT 0 /* set text mode restore fonts */ +#define KD_TEXT0 0 /* ditto */ +#define KD_TEXT1 2 /* set text mode !restore fonts */ +#define KD_GRAPHICS 1 /* set graphics mode */ +#define KD_PIXEL 3 /* set pixel mode */ + +#define K_RAW 0 /* keyboard returns scancodes */ +#define K_XLATE 1 /* keyboard returns ascii */ +#define K_CODE 2 /* keyboard returns keycodes */ + +#define KB_84 1 /* 'old' 84 key AT-keyboard */ +#define KB_101 2 /* MF-101 or MF-102 keyboard */ +#define KB_OTHER 3 /* keyboard not known */ + +#define CLKED 1 /* Caps locked */ +#define NLKED 2 /* Num locked */ +#define SLKED 4 /* Scroll locked */ +#define ALKED 8 /* AltGr locked */ +#define LOCK_MASK (CLKED | NLKED | SLKED | ALKED) +#define LED_CAP 1 /* Caps lock LED */ +#define LED_NUM 2 /* Num lock LED */ +#define LED_SCR 4 /* Scroll lock LED */ +#define LED_MASK (LED_CAP | LED_NUM | LED_SCR) + +/* possible flag values */ +#define FLAG_LOCK_O 0 +#define FLAG_LOCK_C 1 +#define FLAG_LOCK_N 2 + +#define NUM_KEYS 256 /* number of keys in table */ +#define NUM_STATES 8 /* states per key */ +#define ALTGR_OFFSET 128 /* offset for altlock keys */ + +#ifndef _KEYMAP_DECLARED +#define _KEYMAP_DECLARED +struct keyent_t { + u_char map[NUM_STATES]; + u_char spcl; + u_char flgs; +}; + +struct keymap { + u_short n_keys; + struct keyent_t key[NUM_KEYS]; +}; + +typedef struct keymap keymap_t; + +struct keyarg { + u_short keynum; + struct keyent_t key; +}; + +typedef struct keyarg keyarg_t; +#endif /* !_KEYMAP_DECLARED */ + +#define NUM_DEADKEYS 15 /* number of accent keys */ +#define NUM_ACCENTCHARS 52 /* max number of accent chars */ + +struct acc_t { + u_char accchar; + u_char map[NUM_ACCENTCHARS][2]; +}; + +struct accentmap { + u_short n_accs; + struct acc_t acc[NUM_DEADKEYS]; +}; + +#define MAXFK 16 +#define NUM_FKEYS 96 + +struct fkeytab { + u_char str[MAXFK]; + u_char len; +}; + +struct fkeyarg { + u_short keynum; + char keydef[MAXFK]; + char flen; +}; + +struct colors { + char fore; + char back; +}; + +struct vid_info { + short size; + short m_num; + u_short mv_row, mv_col; + u_short mv_rsz, mv_csz; + struct colors mv_norm, + mv_rev, + mv_grfc; + u_char mv_ovscan; + u_char mk_keylock; +}; + +#define MAXSSAVER 16 + +struct ssaver { + char name[MAXSSAVER]; + int num; + long time; +}; + +/* video mode information block */ +struct video_info { + int vi_mode; + int vi_flags; +#define V_INFO_COLOR (1<<0) +#define V_INFO_GRAPHICS (1<<1) +#define V_INFO_LINEAR (1<<2) +#define V_INFO_VESA (1<<3) + int vi_width; + int vi_height; + int vi_cwidth; + int vi_cheight; + int vi_depth; + int vi_planes; + u_int vi_window; /* physical address */ + size_t vi_window_size; + size_t vi_window_gran; + u_int vi_buffer; /* physical address */ + size_t vi_buffer_size; + /* XXX pixel format, memory model,... */ +}; + +/* adapter infromation block */ +struct video_adapter { + int va_index; + int va_type; + char *va_name; + int va_unit; + int va_minor; + int va_flags; +#define V_ADP_COLOR (1<<0) +#define V_ADP_MODECHANGE (1<<1) +#define V_ADP_STATESAVE (1<<2) +#define V_ADP_STATELOAD (1<<3) +#define V_ADP_FONT (1<<4) +#define V_ADP_PALETTE (1<<5) +#define V_ADP_BORDER (1<<6) +#define V_ADP_VESA (1<<7) +#define V_ADP_PROBED (1<<16) +#define V_ADP_INITIALIZED (1<<17) +#define V_ADP_REGISTERED (1<<18) + int va_io_base; + int va_io_size; + int va_crtc_addr; + int va_mem_base; + int va_mem_size; + u_int va_window; /* virtual address */ + size_t va_window_size; + size_t va_window_gran; + u_int va_buffer; /* virtual address */ + size_t va_buffer_size; + int va_initial_mode; + int va_initial_bios_mode; + int va_mode; + struct video_info va_info; + int va_line_width; + void *va_token; +}; + +struct video_adapter_info { + int va_index; + int va_type; + char va_name[16]; + int va_unit; + int va_flags; + int va_io_base; + int va_io_size; + int va_crtc_addr; + int va_mem_base; + int va_mem_size; + u_int va_window; /* virtual address */ + size_t va_window_size; + size_t va_window_gran; + u_int va_buffer; /* virtual address */ + size_t va_buffer_size; + int va_initial_mode; + int va_initial_bios_mode; + int va_mode; + int va_line_width; +}; + +#define V_ADP_PRIMARY 0 +#define V_ADP_SECONDARY 1 + +struct keyboard_info { + int kb_index; /* kbdio index# */ + char kb_name[16]; /* driver name */ + int kb_unit; /* unit# */ + int kb_type; /* KB_84, KB_101, KB_OTHER,... */ + int kb_config; /* device configuration flags */ + int kb_flags; /* internal flags */ +}; + +typedef struct accentmap accentmap_t; +typedef struct fkeytab fkeytab_t; +typedef struct fkeyarg fkeyarg_t; +typedef struct vid_info vid_info_t; +typedef struct mouse_info mouse_info_t; +typedef struct {char scrmap[256];} scrmap_t; +typedef struct {char fnt8x8[8*256];} fnt8_t; +typedef struct {char fnt8x14[14*256];} fnt14_t; +typedef struct {char fnt8x16[16*256];} fnt16_t; +typedef struct ssaver ssaver_t; +typedef struct video_adapter video_adapter_t; +typedef struct video_adapter_info video_adapter_info_t; +typedef struct video_info video_info_t; +typedef struct keyboard_info keyboard_info_t; +typedef struct {int scr_size[3];} scr_size_t; +typedef struct {int kbd_delay[2];} keyboard_delay_t; + +/* defines for "special" keys (spcl bit set in keymap) */ +#define NOP 0x00 /* nothing (dead key) */ +#define LSH 0x02 /* left shift key */ +#define RSH 0x03 /* right shift key */ +#define CLK 0x04 /* caps lock key */ +#define NLK 0x05 /* num lock key */ +#define SLK 0x06 /* scroll lock key */ +#define LALT 0x07 /* left alt key */ +#define BTAB 0x08 /* backwards tab */ +#define LCTR 0x09 /* left control key */ +#define NEXT 0x0a /* switch to next screen */ +#define F_SCR 0x0b /* switch to first screen */ +#define L_SCR 0x1a /* switch to last screen */ +#define F_FN 0x1b /* first function key */ +#define L_FN 0x7a /* last function key */ +/* 0x7b-0x7f reserved do not use ! */ +#define RCTR 0x80 /* right control key */ +#define RALT 0x81 /* right alt (altgr) key */ +#define ALK 0x82 /* alt lock key */ +#define ASH 0x83 /* alt shift key */ +#define META 0x84 /* meta key */ +#define RBT 0x85 /* boot machine */ +#define DBG 0x86 /* call debugger */ +#define SUSP 0x87 /* suspend power (APM) */ +#define SPSC 0x88 /* toggle splash/text screen */ + +#define F_ACC DGRA /* first accent key */ +#define DGRA 0x89 /* grave */ +#define DACU 0x8a /* acute */ +#define DCIR 0x8b /* circumflex */ +#define DTIL 0x8c /* tilde */ +#define DMAC 0x8d /* macron */ +#define DBRE 0x8e /* breve */ +#define DDOT 0x8f /* dot */ +#define DUML 0x90 /* umlaut/diaresis */ +#define DDIA 0x90 /* diaresis */ +#define DSLA 0x91 /* slash */ +#define DRIN 0x92 /* ring */ +#define DCED 0x93 /* cedilla */ +#define DAPO 0x94 /* apostrophe */ +#define DDAC 0x95 /* double acute */ +#define DOGO 0x96 /* ogonek */ +#define DCAR 0x97 /* caron */ +#define L_ACC DCAR /* last accent key */ + +#define STBY 0x98 /* Go into standby mode (apm) */ + +#define F(x) ((x)+F_FN-1) +#define S(x) ((x)+F_SCR-1) +#define ACC(x) ((x)+F_ACC) +#define NOKEY 0x100 /* no key pressed marker */ +#define FKEY 0x200 /* function key marker */ +#define MKEY 0x400 /* meta key marker (prepend ESC)*/ +#define BKEY 0x800 /* backtab (ESC [ Z) */ + +#define SPCLKEY 0x8000 /* special key */ +#define RELKEY 0x4000 /* key released */ +#define ERRKEY 0x2000 /* error */ + +#define KEYCHAR(c) ((c) & 0x00ff) +#define KEYFLAGS(c) ((c) & ~0x00ff) + +/* video mode definitions */ +#define M_B40x25 0 /* black & white 40 columns */ +#define M_C40x25 1 /* color 40 columns */ +#define M_B80x25 2 /* black & white 80 columns */ +#define M_C80x25 3 /* color 80 columns */ +#define M_BG320 4 /* black & white graphics 320x200 */ +#define M_CG320 5 /* color graphics 320x200 */ +#define M_BG640 6 /* black & white graphics 640x200 hi-res */ +#define M_EGAMONO80x25 7 /* ega-mono 80x25 */ +#define M_CG320_D 13 /* ega mode D */ +#define M_CG640_E 14 /* ega mode E */ +#define M_EGAMONOAPA 15 /* ega mode F */ +#define M_CG640x350 16 /* ega mode 10 */ +#define M_ENHMONOAPA2 17 /* ega mode F with extended memory */ +#define M_ENH_CG640 18 /* ega mode 10* */ +#define M_ENH_B40x25 19 /* ega enhanced black & white 40 columns */ +#define M_ENH_C40x25 20 /* ega enhanced color 40 columns */ +#define M_ENH_B80x25 21 /* ega enhanced black & white 80 columns */ +#define M_ENH_C80x25 22 /* ega enhanced color 80 columns */ +#define M_VGA_C40x25 23 /* vga 8x16 font on color */ +#define M_VGA_C80x25 24 /* vga 8x16 font on color */ +#define M_VGA_M80x25 25 /* vga 8x16 font on mono */ + +#define M_VGA11 26 /* vga 640x480 2 colors */ +#define M_BG640x480 26 +#define M_VGA12 27 /* vga 640x480 16 colors */ +#define M_CG640x480 27 +#define M_VGA13 28 /* vga 640x200 256 colors */ +#define M_VGA_CG320 28 + +#define M_VGA_C80x50 30 /* vga 8x8 font on color */ +#define M_VGA_M80x50 31 /* vga 8x8 font on color */ +#define M_VGA_C80x30 32 /* vga 8x16 font on color */ +#define M_VGA_M80x30 33 /* vga 8x16 font on color */ +#define M_VGA_C80x60 34 /* vga 8x8 font on color */ +#define M_VGA_M80x60 35 /* vga 8x8 font on color */ +#define M_VGA_CG640 36 /* vga 640x400 256 color */ +#define M_VGA_MODEX 37 /* vga 320x240 256 color */ + +#define M_ENH_B80x43 0x70 /* ega black & white 80x43 */ +#define M_ENH_C80x43 0x71 /* ega color 80x43 */ + +#define M_PC98_80x25 98 /* PC98 80x25 */ +#define M_PC98_80x30 99 /* PC98 80x30 */ + +#define M_HGC_P0 0xe0 /* hercules graphics - page 0 @ B0000 */ +#define M_HGC_P1 0xe1 /* hercules graphics - page 1 @ B8000 */ +#define M_MCA_MODE 0xff /* monochrome adapter mode */ + +#define M_TEXT_80x25 200 /* generic text modes */ +#define M_TEXT_80x30 201 +#define M_TEXT_80x43 202 +#define M_TEXT_80x50 203 +#define M_TEXT_80x60 204 +#define M_TEXT_132x25 205 +#define M_TEXT_132x30 206 +#define M_TEXT_132x43 207 +#define M_TEXT_132x50 208 +#define M_TEXT_132x60 209 + +#define SW_PC98_80x25 _IO('S', M_PC98_80x25) +#define SW_PC98_80x30 _IO('S', M_PC98_80x30) +#define SW_B40x25 _IO('S', M_B40x25) +#define SW_C40x25 _IO('S', M_C40x25) +#define SW_B80x25 _IO('S', M_B80x25) +#define SW_C80x25 _IO('S', M_C80x25) +#define SW_BG320 _IO('S', M_BG320) +#define SW_CG320 _IO('S', M_CG320) +#define SW_BG640 _IO('S', M_BG640) +#define SW_EGAMONO80x25 _IO('S', M_EGAMONO80x25) +#define SW_CG320_D _IO('S', M_CG320_D) +#define SW_CG640_E _IO('S', M_CG640_E) +#define SW_EGAMONOAPA _IO('S', M_EGAMONOAPA) +#define SW_CG640x350 _IO('S', M_CG640x350) +#define SW_ENH_MONOAPA2 _IO('S', M_ENHMONOAPA2) +#define SW_ENH_CG640 _IO('S', M_ENH_CG640) +#define SW_ENH_B40x25 _IO('S', M_ENH_B40x25) +#define SW_ENH_C40x25 _IO('S', M_ENH_C40x25) +#define SW_ENH_B80x25 _IO('S', M_ENH_B80x25) +#define SW_ENH_C80x25 _IO('S', M_ENH_C80x25) +#define SW_ENH_B80x43 _IO('S', M_ENH_B80x43) +#define SW_ENH_C80x43 _IO('S', M_ENH_C80x43) +#define SW_MCAMODE _IO('S', M_MCA_MODE) +#define SW_VGA_C40x25 _IO('S', M_VGA_C40x25) +#define SW_VGA_C80x25 _IO('S', M_VGA_C80x25) +#define SW_VGA_C80x30 _IO('S', M_VGA_C80x30) +#define SW_VGA_C80x50 _IO('S', M_VGA_C80x50) +#define SW_VGA_C80x60 _IO('S', M_VGA_C80x60) +#define SW_VGA_M80x25 _IO('S', M_VGA_M80x25) +#define SW_VGA_M80x30 _IO('S', M_VGA_M80x30) +#define SW_VGA_M80x50 _IO('S', M_VGA_M80x50) +#define SW_VGA_M80x60 _IO('S', M_VGA_M80x60) +#define SW_VGA11 _IO('S', M_VGA11) +#define SW_BG640x480 _IO('S', M_VGA11) +#define SW_VGA12 _IO('S', M_VGA12) +#define SW_CG640x480 _IO('S', M_VGA12) +#define SW_VGA13 _IO('S', M_VGA13) +#define SW_VGA_CG320 _IO('S', M_VGA13) +#define SW_VGA_CG640 _IO('S', M_VGA_CG640) +#define SW_VGA_MODEX _IO('S', M_VGA_MODEX) + +#define SW_TEXT_80x25 _IO('S', M_TEXT_80x25) +#define SW_TEXT_80x30 _IO('S', M_TEXT_80x30) +#define SW_TEXT_80x43 _IO('S', M_TEXT_80x43) +#define SW_TEXT_80x50 _IO('S', M_TEXT_80x50) +#define SW_TEXT_80x60 _IO('S', M_TEXT_80x60) +#define SW_TEXT_132x25 _IO('S', M_TEXT_132x25) +#define SW_TEXT_132x30 _IO('S', M_TEXT_132x30) +#define SW_TEXT_132x43 _IO('S', M_TEXT_132x43) +#define SW_TEXT_132x50 _IO('S', M_TEXT_132x50) +#define SW_TEXT_132x60 _IO('S', M_TEXT_132x60) + +#define M_VESA_BASE 0x100 /* VESA mode number base */ + +#define M_VESA_CG640x400 0x100 /* 640x400, 256 color */ +#define M_VESA_CG640x480 0x101 /* 640x480, 256 color */ +#define M_VESA_800x600 0x102 /* 800x600, 16 color */ +#define M_VESA_CG800x600 0x103 /* 800x600, 256 color */ +#define M_VESA_1024x768 0x104 /* 1024x768, 16 color */ +#define M_VESA_CG1024x768 0x105 /* 1024x768, 256 color */ +#define M_VESA_1280x1024 0x106 /* 1280x1024, 16 color */ +#define M_VESA_CG1280x1024 0x107 /* 1280x1024, 256 color */ +#define M_VESA_C80x60 0x108 /* 8x8 font */ +#define M_VESA_C132x25 0x109 /* 8x16 font */ +#define M_VESA_C132x43 0x10a /* 8x14 font */ +#define M_VESA_C132x50 0x10b /* 8x8 font */ +#define M_VESA_C132x60 0x10c /* 8x8 font */ +#define M_VESA_32K_320 0x10d /* 320x200, 5:5:5 */ +#define M_VESA_64K_320 0x10e /* 320x200, 5:6:5 */ +#define M_VESA_FULL_320 0x10f /* 320x200, 8:8:8 */ +#define M_VESA_32K_640 0x110 /* 640x480, 5:5:5 */ +#define M_VESA_64K_640 0x111 /* 640x480, 5:6:5 */ +#define M_VESA_FULL_640 0x112 /* 640x480, 8:8:8 */ +#define M_VESA_32K_800 0x113 /* 800x600, 5:5:5 */ +#define M_VESA_64K_800 0x114 /* 800x600, 5:6:5 */ +#define M_VESA_FULL_800 0x115 /* 800x600, 8:8:8 */ +#define M_VESA_32K_1024 0x116 /* 1024x768, 5:5:5 */ +#define M_VESA_64K_1024 0x117 /* 1024x768, 5:6:5 */ +#define M_VESA_FULL_1024 0x118 /* 1024x768, 8:8:8 */ +#define M_VESA_32K_1280 0x119 /* 1280x1024, 5:5:5 */ +#define M_VESA_64K_1280 0x11a /* 1280x1024, 5:6:5 */ +#define M_VESA_FULL_1280 0x11b /* 1280x1024, 8:8:8 */ +#define M_VESA_MODE_MAX 0x1ff + +#define SW_VESA_CG640x400 _IO('V', M_VESA_CG640x400 - M_VESA_BASE) +#define SW_VESA_CG640x480 _IO('V', M_VESA_CG640x480 - M_VESA_BASE) +#define SW_VESA_800x600 _IO('V', M_VESA_800x600 - M_VESA_BASE) +#define SW_VESA_CG800x600 _IO('V', M_VESA_CG800x600 - M_VESA_BASE) +#define SW_VESA_1024x768 _IO('V', M_VESA_1024x768 - M_VESA_BASE) +#define SW_VESA_CG1024x768 _IO('V', M_VESA_CG1024x768 - M_VESA_BASE) +#define SW_VESA_1280x1024 _IO('V', M_VESA_1280x1024 - M_VESA_BASE) +#define SW_VESA_CG1280x1024 _IO('V', M_VESA_CG1280x1024 - M_VESA_BASE) +#define SW_VESA_C80x60 _IO('V', M_VESA_C80x60 - M_VESA_BASE) +#define SW_VESA_C132x25 _IO('V', M_VESA_C132x25 - M_VESA_BASE) +#define SW_VESA_C132x43 _IO('V', M_VESA_C132x43 - M_VESA_BASE) +#define SW_VESA_C132x50 _IO('V', M_VESA_C132x50 - M_VESA_BASE) +#define SW_VESA_C132x60 _IO('V', M_VESA_C132x60 - M_VESA_BASE) +#define SW_VESA_32K_320 _IO('V', M_VESA_32K_320 - M_VESA_BASE) +#define SW_VESA_64K_320 _IO('V', M_VESA_64K_320 - M_VESA_BASE) +#define SW_VESA_FULL_320 _IO('V', M_VESA_FULL_320 - M_VESA_BASE) +#define SW_VESA_32K_640 _IO('V', M_VESA_32K_640 - M_VESA_BASE) +#define SW_VESA_64K_640 _IO('V', M_VESA_64K_640 - M_VESA_BASE) +#define SW_VESA_FULL_640 _IO('V', M_VESA_FULL_640 - M_VESA_BASE) +#define SW_VESA_32K_800 _IO('V', M_VESA_32K_800 - M_VESA_BASE) +#define SW_VESA_64K_800 _IO('V', M_VESA_64K_800 - M_VESA_BASE) +#define SW_VESA_FULL_800 _IO('V', M_VESA_FULL_800 - M_VESA_BASE) +#define SW_VESA_32K_1024 _IO('V', M_VESA_32K_1024 - M_VESA_BASE) +#define SW_VESA_64K_1024 _IO('V', M_VESA_64K_1024 - M_VESA_BASE) +#define SW_VESA_FULL_1024 _IO('V', M_VESA_FULL_1024 - M_VESA_BASE) +#define SW_VESA_32K_1280 _IO('V', M_VESA_32K_1280 - M_VESA_BASE) +#define SW_VESA_64K_1280 _IO('V', M_VESA_64K_1280 - M_VESA_BASE) +#define SW_VESA_FULL_1280 _IO('V', M_VESA_FULL_1280 - M_VESA_BASE) + +#endif /* !_MACHINE_CONSOLE_H_ */ + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cpu.h ./modules/label/machine/cpu.h --- ../sys-altq/modules/label/machine/cpu.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cpu.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,138 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 + * $FreeBSD: src/sys/i386/include/cpu.h,v 1.36.2.2 1999/08/29 16:06:25 peter Exp $ + */ + +#ifndef _MACHINE_CPU_H_ +#define _MACHINE_CPU_H_ + +/* + * Definitions unique to i386 cpu support. + */ +#include +#include +#include + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ + +#define cpu_exec(p) /* nothing */ +#define cpu_swapin(p) /* nothing */ +#define cpu_setstack(p, ap) ((p)->p_md.md_regs[SP] = (ap)) +#define cpu_set_init_frame(p, fp) ((p)->p_md.md_regs = (fp)) + +#define CLKF_USERMODE(framep) \ + ((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM)) + +#define CLKF_INTR(framep) (intr_nesting_level >= 2) +#if 0 +/* + * XXX splsoftclock() is very broken and barely worth fixing. It doesn't + * turn off the clock bit in imen or in the icu. (This is not a serious + * problem at 100 Hz but it is serious at 16000 Hz for pcaudio. softclock() + * can take more than 62.5 usec so clock interrupts are lost.) It doesn't + * check for pending interrupts being unmasked. clkintr() and Xintr0() + * assume that the ipl is high when hardclock() returns. Our SWI_AST + * handling is efficient enough that little is gained by calling + * softclock() directly. + */ +#define CLKF_BASEPRI(framep) (((framep)->cf_ppl & ~SWI_AST_MASK) == 0) +#else +#define CLKF_BASEPRI(framep) (0) +#endif +#define CLKF_PC(framep) ((framep)->cf_eip) + +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ +#define need_resched() { want_resched = 1; aston(); } + +#define resched_wanted() want_resched + +/* + * Arrange to handle pending profiling ticks before returning to user mode. + * + * XXX this is now poorly named and implemented. It used to handle only a + * single tick and the P_OWEUPC flag served as a counter. Now there is a + * counter in the proc table and flag isn't really necessary. + */ +#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); } + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define signotify(p) aston() + +#define aston() setsoftast() +#define astoff() + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CONSDEV 1 /* dev_t: console terminal device */ +#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ +#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ +#define CPU_BOOTINFO 4 /* struct: bootinfo */ +#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ +#define CPU_MAXID 6 /* number of valid machdep ids */ + +#define CTL_MACHDEP_NAMES { \ + { 0, 0 }, \ + { "console_device", CTLTYPE_STRUCT }, \ + { "adjkerntz", CTLTYPE_INT }, \ + { "disable_rtc_set", CTLTYPE_INT }, \ + { "bootinfo", CTLTYPE_STRUCT }, \ + { "wall_cmos_clock", CTLTYPE_INT }, \ +} + +#ifdef KERNEL +extern char btext[]; +extern char etext[]; +extern u_char intr_nesting_level; +extern int want_resched; /* resched was called */ + +void fork_trampoline __P((void)); +void fork_return __P((struct proc *, struct trapframe)); +void cpu_set_fork_handler __P((struct proc *, void (*pc)(void *), void *)); +#endif + +#endif /* !_MACHINE_CPU_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cpufunc.h ./modules/label/machine/cpufunc.h --- ../sys-altq/modules/label/machine/cpufunc.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cpufunc.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,470 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/cpufunc.h,v 1.85.2.1 1999/08/29 16:06:26 peter Exp $ + */ + +/* + * Functions to provide access to special i386 instructions. + */ + +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ + +#define readb(va) (*(volatile u_int8_t *) (va)) +#define readw(va) (*(volatile u_int16_t *) (va)) +#define readl(va) (*(volatile u_int32_t *) (va)) + +#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d)) +#define writew(va, d) (*(volatile u_int16_t *) (va) = (d)) +#define writel(va, d) (*(volatile u_int32_t *) (va) = (d)) + +#ifdef __GNUC__ + +#ifdef SMP +#include /* XXX */ +#endif + +#ifdef SWTCH_OPTIM_STATS +extern int tlb_flush_count; /* XXX */ +#endif + +static __inline void +breakpoint(void) +{ + __asm __volatile("int $3"); +} + +static __inline void +disable_intr(void) +{ + __asm __volatile("cli" : : : "memory"); +#ifdef SMP + MPINTR_LOCK(); +#endif +} + +static __inline void +enable_intr(void) +{ +#ifdef SMP + MPINTR_UNLOCK(); +#endif + __asm __volatile("sti"); +} + +#define HAVE_INLINE_FFS + +static __inline int +ffs(int mask) +{ + int result; + /* + * bsfl turns out to be not all that slow on 486's. It can beaten + * using a binary search to reduce to 4 bits and then a table lookup, + * but only if the code is inlined and in the cache, and the code + * is quite large so inlining it probably busts the cache. + * + * Note that gcc-2's builtin ffs would be used if we didn't declare + * this inline or turn off the builtin. The builtin is faster but + * broken in gcc-2.4.5 and slower but working in gcc-2.5 and 2.6. + */ + __asm __volatile("testl %0,%0; je 1f; bsfl %0,%0; incl %0; 1:" + : "=r" (result) : "0" (mask)); + return (result); +} + +#define HAVE_INLINE_FLS + +static __inline int +fls(int mask) +{ + int result; + __asm __volatile("testl %0,%0; je 1f; bsrl %0,%0; incl %0; 1:" + : "=r" (result) : "0" (mask)); + return (result); +} + +#if __GNUC__ < 2 + +#define inb(port) inbv(port) +#define outb(port, data) outbv(port, data) + +#else /* __GNUC >= 2 */ + +/* + * The following complications are to get around gcc not having a + * constraint letter for the range 0..255. We still put "d" in the + * constraint because "i" isn't a valid constraint when the port + * isn't constant. This only matters for -O0 because otherwise + * the non-working version gets optimized away. + * + * Use an expression-statement instead of a conditional expression + * because gcc-2.6.0 would promote the operands of the conditional + * and produce poor code for "if ((inb(var) & const1) == const2)". + * + * The unnecessary test `(port) < 0x10000' is to generate a warning if + * the `port' has type u_short or smaller. Such types are pessimal. + * This actually only works for signed types. The range check is + * careful to avoid generating warnings. + */ +#define inb(port) __extension__ ({ \ + u_char _data; \ + if (__builtin_constant_p(port) && ((port) & 0xffff) < 0x100 \ + && (port) < 0x10000) \ + _data = inbc(port); \ + else \ + _data = inbv(port); \ + _data; }) + +#define outb(port, data) ( \ + __builtin_constant_p(port) && ((port) & 0xffff) < 0x100 \ + && (port) < 0x10000 \ + ? outbc(port, data) : outbv(port, data)) + +static __inline u_char +inbc(u_int port) +{ + u_char data; + + __asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port))); + return (data); +} + +static __inline void +outbc(u_int port, u_char data) +{ + __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); +} + +#endif /* __GNUC <= 2 */ + +static __inline u_char +inbv(u_int port) +{ + u_char data; + /* + * We use %%dx and not %1 here because i/o is done at %dx and not at + * %edx, while gcc generates inferior code (movw instead of movl) + * if we tell it to load (u_short) port. + */ + __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +static __inline u_int +inl(u_int port) +{ + u_int data; + + __asm __volatile("inl %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +static __inline void +insb(u_int port, void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; insb" + : "=D" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port) + : "memory"); +} + +static __inline void +insw(u_int port, void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; insw" + : "=D" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port) + : "memory"); +} + +static __inline void +insl(u_int port, void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; insl" + : "=D" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port) + : "memory"); +} + +static __inline void +invd(void) +{ + __asm __volatile("invd"); +} + +#if defined(SMP) && defined(KERNEL) + +/* + * When using APIC IPI's, invlpg() is not simply the invlpg instruction + * (this is a bug) and the inlining cost is prohibitive since the call + * executes into the IPI transmission system. + */ +void invlpg __P((u_int addr)); +void invltlb __P((void)); + +static __inline void +cpu_invlpg(void *addr) +{ + __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); +} + +static __inline void +cpu_invltlb(void) +{ + u_int temp; + /* + * This should be implemented as load_cr3(rcr3()) when load_cr3() + * is inlined. + */ + __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp) + : : "memory"); +#if defined(SWTCH_OPTIM_STATS) + ++tlb_flush_count; +#endif +} + +#else /* !(SMP && KERNEL) */ + +static __inline void +invlpg(u_int addr) +{ + __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); +} + +static __inline void +invltlb(void) +{ + u_int temp; + /* + * This should be implemented as load_cr3(rcr3()) when load_cr3() + * is inlined. + */ + __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp) + : : "memory"); +#ifdef SWTCH_OPTIM_STATS + ++tlb_flush_count; +#endif +} + +#endif /* SMP && KERNEL */ + +static __inline u_short +inw(u_int port) +{ + u_short data; + + __asm __volatile("inw %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +static __inline u_int +loadandclear(u_int *addr) +{ + u_int result; + + __asm __volatile("xorl %0,%0; xchgl %1,%0" + : "=&r" (result) : "m" (*addr)); + return (result); +} + +static __inline void +outbv(u_int port, u_char data) +{ + u_char al; + /* + * Use an unnecessary assignment to help gcc's register allocator. + * This make a large difference for gcc-1.40 and a tiny difference + * for gcc-2.6.0. For gcc-1.40, al had to be ``asm("ax")'' for + * best results. gcc-2.6.0 can't handle this. + */ + al = data; + __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); +} + +static __inline void +outl(u_int port, u_int data) +{ + /* + * outl() and outw() aren't used much so we haven't looked at + * possible micro-optimizations such as the unnecessary + * assignment for them. + */ + __asm __volatile("outl %0,%%dx" : : "a" (data), "d" (port)); +} + +static __inline void +outsb(u_int port, const void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; outsb" + : "=S" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port)); +} + +static __inline void +outsw(u_int port, const void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; outsw" + : "=S" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port)); +} + +static __inline void +outsl(u_int port, const void *addr, size_t cnt) +{ + __asm __volatile("cld; rep; outsl" + : "=S" (addr), "=c" (cnt) + : "0" (addr), "1" (cnt), "d" (port)); +} + +static __inline void +outw(u_int port, u_short data) +{ + __asm __volatile("outw %0,%%dx" : : "a" (data), "d" (port)); +} + +static __inline u_int +rcr2(void) +{ + u_int data; + + __asm __volatile("movl %%cr2,%0" : "=r" (data)); + return (data); +} + +static __inline u_int +read_eflags(void) +{ + u_int ef; + + __asm __volatile("pushfl; popl %0" : "=r" (ef)); + return (ef); +} + +static __inline u_int64_t +rdmsr(u_int msr) +{ + u_int64_t rv; + + __asm __volatile(".byte 0x0f, 0x32" : "=A" (rv) : "c" (msr)); + return (rv); +} + +static __inline u_int64_t +rdpmc(u_int pmc) +{ + u_int64_t rv; + + __asm __volatile(".byte 0x0f, 0x33" : "=A" (rv) : "c" (pmc)); + return (rv); +} + +static __inline u_int64_t +rdtsc(void) +{ + u_int64_t rv; + + __asm __volatile(".byte 0x0f, 0x31" : "=A" (rv)); + return (rv); +} + +static __inline void +setbits(volatile u_int *addr, u_int bits) +{ + __asm __volatile( +#ifdef SMP + "lock; " +#endif + "orl %1,%0" : "=m" (*addr) : "ir" (bits)); +} + +static __inline void +wbinvd(void) +{ + __asm __volatile("wbinvd"); +} + +static __inline void +write_eflags(u_int ef) +{ + __asm __volatile("pushl %0; popfl" : : "r" (ef)); +} + +static __inline void +wrmsr(u_int msr, u_int64_t newval) +{ + __asm __volatile(".byte 0x0f, 0x30" : : "A" (newval), "c" (msr)); +} + +#else /* !__GNUC__ */ + +int breakpoint __P((void)); +void disable_intr __P((void)); +void enable_intr __P((void)); +u_char inb __P((u_int port)); +u_int inl __P((u_int port)); +void insb __P((u_int port, void *addr, size_t cnt)); +void insl __P((u_int port, void *addr, size_t cnt)); +void insw __P((u_int port, void *addr, size_t cnt)); +void invd __P((void)); +void invlpg __P((u_int addr)); +void invltlb __P((void)); +u_short inw __P((u_int port)); +u_int loadandclear __P((u_int *addr)); +void outb __P((u_int port, u_char data)); +void outl __P((u_int port, u_int data)); +void outsb __P((u_int port, void *addr, size_t cnt)); +void outsl __P((u_int port, void *addr, size_t cnt)); +void outsw __P((u_int port, void *addr, size_t cnt)); +void outw __P((u_int port, u_short data)); +u_int rcr2 __P((void)); +u_int64_t rdmsr __P((u_int msr)); +u_int64_t rdpmc __P((u_int pmc)); +u_int64_t rdtsc __P((void)); +u_int read_eflags __P((void)); +void setbits __P((volatile u_int *addr, u_int bits)); +void wbinvd __P((void)); +void write_eflags __P((u_int ef)); +void wrmsr __P((u_int msr, u_int64_t newval)); + +#endif /* __GNUC__ */ + +void load_cr0 __P((u_int cr0)); +void load_cr3 __P((u_int cr3)); +void load_cr4 __P((u_int cr4)); +void ltr __P((u_short sel)); +u_int rcr0 __P((void)); +u_int rcr3 __P((void)); +u_int rcr4 __P((void)); + +#endif /* !_MACHINE_CPUFUNC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cputypes.h ./modules/label/machine/cputypes.h --- ../sys-altq/modules/label/machine/cputypes.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cputypes.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1993 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/cputypes.h,v 1.11.2.2 1999/08/29 16:06:26 peter Exp $ + */ + +#ifndef _MACHINE_CPUTYPES_H_ +#define _MACHINE_CPUTYPES_H_ + +/* + * Classes of processor. + */ +#define CPUCLASS_286 0 +#define CPUCLASS_386 1 +#define CPUCLASS_486 2 +#define CPUCLASS_586 3 +#define CPUCLASS_686 4 + +/* + * Kinds of processor. + */ +#define CPU_286 0 /* Intel 80286 */ +#define CPU_386SX 1 /* Intel 80386SX */ +#define CPU_386 2 /* Intel 80386DX */ +#define CPU_486SX 3 /* Intel 80486SX */ +#define CPU_486 4 /* Intel 80486DX */ +#define CPU_586 5 /* Intel P.....m (I hate lawyers; it's TM) */ +#define CPU_486DLC 6 /* Cyrix 486DLC */ +#define CPU_686 7 /* Pentium Pro */ +#define CPU_M1SC 8 /* Cyrix M1sc (aka 5x86) */ +#define CPU_M1 9 /* Cyrix M1 (aka 6x86) */ +#define CPU_BLUE 10 /* IBM BlueLighting CPU */ +#define CPU_M2 11 /* Cyrix M2 (aka enhanced 6x86 with MMX */ +#define CPU_NX586 12 /* NexGen (now AMD) 586 */ +#define CPU_CY486DX 13 /* Cyrix 486S/DX/DX2/DX4 */ +#define CPU_PII 14 /* Intel Pentium II */ +#define CPU_PIII 15 /* Intel Pentium III */ + +#ifndef LOCORE +struct cpu_nameclass { + char *cpu_name; + int cpu_class; +}; + +extern int cpu; +extern int cpu_class; +#endif + +#endif /* !_MACHINE_CPUTYPES_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/cronyx.h ./modules/label/machine/cronyx.h --- ../sys-altq/modules/label/machine/cronyx.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/cronyx.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,482 @@ +/* + * Defines for Cronyx-Sigma adapter driver. + * + * Copyright (C) 1994 Cronyx Ltd. + * Author: Serge Vakulenko, + * + * This software is distributed with NO WARRANTIES, not even the implied + * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Authors grant any other persons or organizations permission to use + * or modify this software as long as this message is kept with the software, + * all derivative works or modified versions. + * + * Version 1.9, Wed Oct 4 18:58:15 MSK 1995 + */ +/* + * Asynchronous channel mode ------------------------------------------------- + */ + +/* Parity */ +#define PAR_EVEN 0 /* even parity */ +#define PAR_ODD 1 /* odd parity */ + +/* Parity mode */ +#define PARM_NOPAR 0 /* no parity */ +#define PARM_FORCE 1 /* force parity (odd = force 1, even = 0) */ +#define PARM_NORMAL 2 /* normal parity */ + +/* Flow control transparency mode */ +#define FLOWCC_PASS 0 /* pass flow ctl chars as exceptions */ +#define FLOWCC_NOTPASS 1 /* don't pass flow ctl chars to the host */ + +/* Stop bit length */ +#define STOPB_1 2 /* 1 stop bit */ +#define STOPB_15 3 /* 1.5 stop bits */ +#define STOPB_2 4 /* 2 stop bits */ + +/* Action on break condition */ +#define BRK_INTR 0 /* generate an exception interrupt */ +#define BRK_NULL 1 /* translate to a NULL character */ +#define BRK_RESERVED 2 /* reserved */ +#define BRK_DISCARD 3 /* discard character */ + +/* Parity/framing error actions */ +#define PERR_INTR 0 /* generate an exception interrupt */ +#define PERR_NULL 1 /* translate to a NULL character */ +#define PERR_IGNORE 2 /* ignore error; char passed as good data */ +#define PERR_DISCARD 3 /* discard error character */ +#define PERR_FFNULL 5 /* translate to FF NULL char */ + +typedef struct { /* async channel option register 1 */ + unsigned charlen : 4; /* character length, 5..8 */ + unsigned ignpar : 1; /* ignore parity */ + unsigned parmode : 2; /* parity mode */ + unsigned parity : 1; /* parity */ +} cx_cor1_async_t; + +typedef struct { /* async channel option register 2 */ + unsigned dsrae : 1; /* DSR automatic enable */ + unsigned ctsae : 1; /* CTS automatic enable */ + unsigned rtsao : 1; /* RTS automatic output enable */ + unsigned rlm : 1; /* remote loopback mode enable */ + unsigned zero : 1; + unsigned etc : 1; /* embedded transmitter cmd enable */ + unsigned ixon : 1; /* in-band XON/XOFF enable */ + unsigned ixany : 1; /* XON on any character */ +} cx_cor2_async_t; + +typedef struct { /* async channel option register 3 */ + unsigned stopb : 3; /* stop bit length */ + unsigned zero : 1; + unsigned scde : 1; /* special char detection enable */ + unsigned flowct : 1; /* flow control transparency mode */ + unsigned rngde : 1; /* range detect enable */ + unsigned escde : 1; /* extended spec. char detect enable */ +} cx_cor3_async_t; + +typedef struct { /* async channel option register 6 */ + unsigned parerr : 3; /* parity/framing error actions */ + unsigned brk : 2; /* action on break condition */ + unsigned inlcr : 1; /* translate NL to CR on input */ + unsigned icrnl : 1; /* translate CR to NL on input */ + unsigned igncr : 1; /* discard CR on input */ +} cx_cor6_async_t; + +typedef struct { /* async channel option register 7 */ + unsigned ocrnl : 1; /* translate CR to NL on output */ + unsigned onlcr : 1; /* translate NL to CR on output */ + unsigned zero : 3; + unsigned fcerr : 1; /* process flow ctl err chars enable */ + unsigned lnext : 1; /* LNext option enable */ + unsigned istrip : 1; /* strip 8-bit on input */ +} cx_cor7_async_t; + +typedef struct { /* async channel options */ + cx_cor1_async_t cor1; /* channel option register 1 */ + cx_cor2_async_t cor2; /* channel option register 2 */ + cx_cor3_async_t cor3; /* option register 3 */ + cx_cor6_async_t cor6; /* channel option register 6 */ + cx_cor7_async_t cor7; /* channel option register 7 */ + unsigned char schr1; /* special character register 1 (XON) */ + unsigned char schr2; /* special character register 2 (XOFF) */ + unsigned char schr3; /* special character register 3 */ + unsigned char schr4; /* special character register 4 */ + unsigned char scrl; /* special character range low */ + unsigned char scrh; /* special character range high */ + unsigned char lnxt; /* LNext character */ +} cx_opt_async_t; + +/* + * HDLC channel mode --------------------------------------------------------- + */ +/* Address field length option */ +#define AFLO_1OCT 0 /* address field is 1 octet in length */ +#define AFLO_2OCT 1 /* address field is 2 octet in length */ + +/* Clear detect for X.21 data transfer phase */ +#define CLRDET_DISABLE 0 /* clear detect disabled */ +#define CLRDET_ENABLE 1 /* clear detect enabled */ + +/* Addressing mode */ +#define ADMODE_NOADDR 0 /* no address */ +#define ADMODE_4_1 1 /* 4 * 1 byte */ +#define ADMODE_2_2 2 /* 2 * 2 byte */ + +/* FCS append */ +#define FCS_NOTPASS 0 /* receive CRC is not passed to the host */ +#define FCS_PASS 1 /* receive CRC is passed to the host */ + +/* CRC modes */ +#define CRC_INVERT 0 /* CRC is transmitted inverted (CRC V.41) */ +#define CRC_DONT_INVERT 1 /* CRC is not transmitted inverted (CRC-16) */ + +/* Send sync pattern */ +#define SYNC_00 0 /* send 00h as pad char (NRZI encoding) */ +#define SYNC_AA 1 /* send AAh (Manchester/NRZ encoding) */ + +/* FCS preset */ +#define FCSP_ONES 0 /* FCS is preset to all ones (CRC V.41) */ +#define FCSP_ZEROS 1 /* FCS is preset to all zeros (CRC-16) */ + +/* idle mode */ +#define IDLE_FLAG 0 /* idle in flag */ +#define IDLE_MARK 1 /* idle in mark */ + +/* CRC polynomial select */ +#define POLY_V41 0 /* x^16+x^12+x^5+1 (HDLC, preset to 1) */ +#define POLY_16 1 /* x^16+x^15+x^2+1 (bisync, preset to 0) */ + +typedef struct { /* hdlc channel option register 1 */ + unsigned ifflags : 4; /* number of inter-frame flags sent */ + unsigned admode : 2; /* addressing mode */ + unsigned clrdet : 1; /* clear detect for X.21 data transfer phase */ + unsigned aflo : 1; /* address field length option */ +} cx_cor1_hdlc_t; + +typedef struct { /* hdlc channel option register 2 */ + unsigned dsrae : 1; /* DSR automatic enable */ + unsigned ctsae : 1; /* CTS automatic enable */ + unsigned rtsao : 1; /* RTS automatic output enable */ + unsigned zero1 : 1; + unsigned crcninv : 1; /* CRC inversion option */ + unsigned zero2 : 1; + unsigned fcsapd : 1; /* FCS append */ + unsigned zero3 : 1; +} cx_cor2_hdlc_t; + +typedef struct { /* hdlc channel option register 3 */ + unsigned padcnt : 3; /* pad character count */ + unsigned idle : 1; /* idle mode */ + unsigned nofcs : 1; /* FCS disable */ + unsigned fcspre : 1; /* FCS preset */ + unsigned syncpat : 1; /* send sync pattern */ + unsigned sndpad : 1; /* send pad characters before flag enable */ +} cx_cor3_hdlc_t; + +typedef struct { /* hdlc channel options */ + cx_cor1_hdlc_t cor1; /* hdlc channel option register 1 */ + cx_cor2_hdlc_t cor2; /* hdlc channel option register 2 */ + cx_cor3_hdlc_t cor3; /* hdlc channel option register 3 */ + unsigned char rfar1; /* receive frame address register 1 */ + unsigned char rfar2; /* receive frame address register 2 */ + unsigned char rfar3; /* receive frame address register 3 */ + unsigned char rfar4; /* receive frame address register 4 */ + unsigned char cpsr; /* CRC polynomial select */ +} cx_opt_hdlc_t; + +/* + * BISYNC channel mode ------------------------------------------------------- + */ + +/* Longitudinal redundancy check */ +#define BCC_CRC16 0 /* CRC16 is used for BCC */ +#define BCC_LRC 1 /* LRC is used for BCC */ + +/* Send pad pattern */ +#define PAD_AA 0 /* send AAh as pad character */ +#define PAD_55 1 /* send 55h as pad character */ + +typedef struct { /* channel option register 1 */ + unsigned charlen : 4; /* character length, 5..8 */ + unsigned ignpar : 1; /* ignore parity */ + unsigned parmode : 2; /* parity mode */ + unsigned parity : 1; /* parity */ +} cx_cor1_bisync_t; + +typedef struct { /* channel option register 2 */ + unsigned syns : 4; /* number of extra SYN chars before a frame */ + unsigned crcninv : 1; /* CRC inversion option */ + unsigned ebcdic : 1; /* use EBCDIC as char set (instead of ASCII) */ + unsigned bcc : 1; /* BCC append enable */ + unsigned lrc : 1; /* longitudinal redundancy check */ +} cx_cor2_bisync_t; + +typedef struct { /* channel option register 3 */ + unsigned padcnt : 3; /* pad character count */ + unsigned idle : 1; /* idle mode */ + unsigned nofcs : 1; /* FCS disable */ + unsigned fcspre : 1; /* FCS preset */ + unsigned padpat : 1; /* send pad pattern */ + unsigned sndpad : 1; /* send pad characters before SYN enable */ +} cx_cor3_bisync_t; + +typedef struct { /* channel option register 6 */ + unsigned char specterm; /* special termination character */ +} cx_cor6_bisync_t; + +typedef struct { /* bisync channel options */ + cx_cor1_bisync_t cor1; /* channel option register 1 */ + cx_cor2_bisync_t cor2; /* channel option register 2 */ + cx_cor3_bisync_t cor3; /* channel option register 3 */ + cx_cor6_bisync_t cor6; /* channel option register 6 */ + unsigned char cpsr; /* CRC polynomial select */ +} cx_opt_bisync_t; + +/* + * X.21 channel mode --------------------------------------------------------- + */ + +/* The number of SYN chars on receive */ +#define X21SYN_2 0 /* two SYN characters are required */ +#define X21SYN_1 1 /* one SYN character is required */ + +typedef struct { /* channel option register 1 */ + unsigned charlen : 4; /* character length, 5..8 */ + unsigned ignpar : 1; /* ignore parity */ + unsigned parmode : 2; /* parity mode */ + unsigned parity : 1; /* parity */ +} cx_cor1_x21_t; + +typedef struct { /* channel option register 2 */ + unsigned zero1 : 5; + unsigned etc : 1; /* embedded transmitter command enable */ + unsigned zero2 : 2; +} cx_cor2_x21_t; + +typedef struct { /* channel option register 3 */ + unsigned zero : 4; + unsigned scde : 1; /* special character detect enable */ + unsigned stripsyn : 1; /* treat SYN chars as special condition */ + unsigned ssde : 1; /* steady state detect enable */ + unsigned syn : 1; /* the number of SYN chars on receive */ +} cx_cor3_x21_t; + +typedef struct { /* channel option register 6 */ + unsigned char synchar; /* syn character */ +} cx_cor6_x21_t; + +typedef struct { /* x21 channel options */ + cx_cor1_x21_t cor1; /* channel option register 1 */ + cx_cor2_x21_t cor2; /* channel option register 2 */ + cx_cor3_x21_t cor3; /* channel option register 3 */ + cx_cor6_x21_t cor6; /* channel option register 6 */ + unsigned char schr1; /* special character register 1 */ + unsigned char schr2; /* special character register 2 */ + unsigned char schr3; /* special character register 3 */ +} cx_opt_x21_t; + +/* + * CD2400 channel state structure -------------------------------------------- + */ + +/* Signal encoding */ +#define ENCOD_NRZ 0 /* NRZ mode */ +#define ENCOD_NRZI 1 /* NRZI mode */ +#define ENCOD_MANCHESTER 2 /* Manchester mode */ + +/* Clock source */ +#define CLK_0 0 /* clock 0 */ +#define CLK_1 1 /* clock 1 */ +#define CLK_2 2 /* clock 2 */ +#define CLK_3 3 /* clock 3 */ +#define CLK_4 4 /* clock 4 */ +#define CLK_EXT 6 /* external clock */ +#define CLK_RCV 7 /* receive clock */ + +/* Channel type */ +#define T_NONE 0 /* no channel */ +#define T_ASYNC 1 /* pure asynchronous RS-232 channel */ +#define T_SYNC_RS232 2 /* pure synchronous RS-232 channel */ +#define T_SYNC_V35 3 /* pure synchronous V.35 channel */ +#define T_SYNC_RS449 4 /* pure synchronous RS-449 channel */ +#define T_UNIV_RS232 5 /* sync/async RS-232 channel */ +#define T_UNIV_RS449 6 /* sync/async RS-232/RS-449 channel */ +#define T_UNIV_V35 7 /* sync/async RS-232/V.35 channel */ + +typedef enum { /* channel mode */ + M_ASYNC, /* asynchronous mode */ + M_HDLC, /* HDLC mode */ + M_BISYNC, /* BISYNC mode */ + M_X21 /* X.21 mode */ +} cx_chan_mode_t; + +typedef struct { /* channel option register 4 */ + unsigned thr : 4; /* FIFO threshold */ + unsigned zero : 1; + unsigned cts_zd : 1; /* detect 1 to 0 transition on the CTS */ + unsigned cd_zd : 1; /* detect 1 to 0 transition on the CD */ + unsigned dsr_zd : 1; /* detect 1 to 0 transition on the DSR */ +} cx_cor4_t; + +typedef struct { /* channel option register 5 */ + unsigned rx_thr : 4; /* receive flow control FIFO threshold */ + unsigned zero : 1; + unsigned cts_od : 1; /* detect 0 to 1 transition on the CTS */ + unsigned cd_od : 1; /* detect 0 to 1 transition on the CD */ + unsigned dsr_od : 1; /* detect 0 to 1 transition on the DSR */ +} cx_cor5_t; + +typedef struct { /* receive clock option register */ + unsigned clk : 3; /* receive clock source */ + unsigned encod : 2; /* signal encoding NRZ/NRZI/Manchester */ + unsigned dpll : 1; /* DPLL enable */ + unsigned zero : 1; + unsigned tlval : 1; /* transmit line value */ +} cx_rcor_t; + +typedef struct { /* transmit clock option register */ + unsigned zero1 : 1; + unsigned llm : 1; /* local loopback mode */ + unsigned zero2 : 1; + unsigned ext1x : 1; /* external 1x clock mode */ + unsigned zero3 : 1; + unsigned clk : 3; /* transmit clock source */ +} cx_tcor_t; + +typedef struct { + cx_cor4_t cor4; /* channel option register 4 */ + cx_cor5_t cor5; /* channel option register 5 */ + cx_rcor_t rcor; /* receive clock option register */ + cx_tcor_t tcor; /* transmit clock option register */ +} cx_chan_opt_t; + +typedef enum { /* line break mode */ + BRK_IDLE, /* normal line mode */ + BRK_SEND, /* start sending break */ + BRK_STOP /* stop sending break */ +} cx_break_t; + +typedef struct { + unsigned cisco : 1; /* cisco mode */ + unsigned keepalive : 1; /* keepalive enable */ + unsigned ext : 1; /* use external ppp implementation */ + unsigned lock : 1; /* channel locked for use by driver */ + unsigned norts : 1; /* disable automatic RTS control */ +} cx_soft_opt_t; + +#define NCHIP 4 /* the number of controllers per board */ +#define NCHAN 16 /* the number of channels on the board */ + +typedef struct { + unsigned char board; /* adapter number, 0..2 */ + unsigned char channel; /* channel number, 0..15 */ + unsigned char type; /* channel type (read only) */ + unsigned char iftype; /* chan0 interface RS-232/RS-449/V.35 */ + unsigned long rxbaud; /* receiver speed */ + unsigned long txbaud; /* transmitter speed */ + cx_chan_mode_t mode; /* channel mode */ + cx_chan_opt_t opt; /* common channel options */ + cx_opt_async_t aopt; /* async mode options */ + cx_opt_hdlc_t hopt; /* hdlc mode options */ + cx_opt_bisync_t bopt; /* bisync mode options */ + cx_opt_x21_t xopt; /* x.21 mode options */ + cx_soft_opt_t sopt; /* software options and state flags */ + char master[16]; /* master interface name or \0 */ +} cx_options_t; /* user settable options */ + +typedef struct _chan_t { + unsigned char type; /* channel type */ + unsigned char num; /* channel number, 0..15 */ + struct _board_t *board; /* board pointer */ + struct _chip_t *chip; /* controller pointer */ + struct _stat_t *stat; /* statistics */ + unsigned long rxbaud; /* receiver speed */ + unsigned long txbaud; /* transmitter speed */ + cx_chan_mode_t mode; /* channel mode */ + cx_chan_opt_t opt; /* common channel options */ + cx_opt_async_t aopt; /* async mode options */ + cx_opt_hdlc_t hopt; /* hdlc mode options */ + cx_opt_bisync_t bopt; /* bisync mode options */ + cx_opt_x21_t xopt; /* x.21 mode options */ + unsigned char *arbuf; /* receiver A dma buffer */ + unsigned char *brbuf; /* receiver B dma buffer */ + unsigned char *atbuf; /* transmitter A dma buffer */ + unsigned char *btbuf; /* transmitter B dma buffer */ + unsigned long arphys; /* receiver A phys address */ + unsigned long brphys; /* receiver B phys address */ + unsigned long atphys; /* transmitter A phys address */ + unsigned long btphys; /* transmitter B phys address */ + unsigned char dtr; /* DTR signal value */ + unsigned char rts; /* RTS signal value */ +#ifdef KERNEL + struct tty *ttyp; /* tty structure pointer */ + struct ifnet *ifp; /* network interface data */ + struct ifnet *master; /* master interface, or ==ifp */ + struct _chan_t *slaveq; /* slave queue pointer, or NULL */ + cx_soft_opt_t sopt; /* software options and state flags */ + cx_break_t brk; /* line break mode */ +#ifdef __bsdi__ + struct ttydevice_tmp *ttydev; /* tty statistics structure */ +#endif +#endif +} cx_chan_t; + +typedef struct _chip_t { + unsigned short port; /* base port address, or 0 if no chip */ + unsigned char num; /* controller number, 0..3 */ + struct _board_t *board; /* board pointer */ + unsigned long oscfreq; /* oscillator frequency in Hz */ +} cx_chip_t; + +typedef struct _stat_t { + unsigned char board; /* adapter number, 0..2 */ + unsigned char channel; /* channel number, 0..15 */ + unsigned long rintr; /* receive interrupts */ + unsigned long tintr; /* transmit interrupts */ + unsigned long mintr; /* modem interrupts */ + unsigned long ibytes; /* input bytes */ + unsigned long ipkts; /* input packets */ + unsigned long ierrs; /* input errors */ + unsigned long obytes; /* output bytes */ + unsigned long opkts; /* output packets */ + unsigned long oerrs; /* output errors */ +} cx_stat_t; + +typedef struct _board_t { + unsigned short port; /* base board port, 0..3f0 */ + unsigned short num; /* board number, 0..2 */ + unsigned char irq; /* interrupt request {3 5 7 10 11 12 15} */ + unsigned char dma; /* DMA request {5 6 7} */ + unsigned char if0type; /* chan0 interface RS-232/RS-449/V.35 */ + unsigned char if8type; /* chan8 interface RS-232/RS-449/V.35 */ + unsigned short bcr0; /* BCR0 image */ + unsigned short bcr0b; /* BCR0b image */ + unsigned short bcr1; /* BCR1 image */ + unsigned short bcr1b; /* BCR1b image */ + cx_chip_t chip[NCHIP]; /* controller structures */ + cx_chan_t chan[NCHAN]; /* channel structures */ + cx_stat_t stat[NCHAN]; /* channel statistics */ + char name[16]; /* board version name */ + unsigned char nuniv; /* number of universal channels */ + unsigned char nsync; /* number of sync. channels */ + unsigned char nasync; /* number of async. channels */ +} cx_board_t; + +#define CX_SPEED_DFLT 9600 + +#ifdef KERNEL +int cx_probe_board (int port); +void cx_init (cx_board_t *b, int num, int port, int irq, int dma); +void cx_setup_board (cx_board_t *b); +void cx_setup_chan (cx_chan_t *c); +void cx_chan_dtr (cx_chan_t *c, int on); +void cx_chan_rts (cx_chan_t *c, int on); +void cx_cmd (int base, int cmd); +int cx_chan_cd (cx_chan_t *c); +void cx_clock (long hz, long ba, int *clk, int *div); +#endif + +#define CXIOCGETMODE _IOWR('x', 1, cx_options_t) /* get channel options */ +#define CXIOCSETMODE _IOW('x', 2, cx_options_t) /* set channel options */ +#define CXIOCGETSTAT _IOWR('x', 3, cx_stat_t) /* get channel stats */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/db_machdep.h ./modules/label/machine/db_machdep.h --- ../sys-altq/modules/label/machine/db_machdep.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/db_machdep.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,90 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + * + * $FreeBSD: src/sys/i386/include/db_machdep.h,v 1.13.4.1 1999/08/29 16:06:27 peter Exp $ + */ + +#ifndef _MACHINE_DB_MACHDEP_H_ +#define _MACHINE_DB_MACHDEP_H_ + +#include +#include + +#define i386_saved_state trapframe + +typedef vm_offset_t db_addr_t; /* address - unsigned */ +typedef int db_expr_t; /* expression - signed */ + +typedef struct i386_saved_state db_regs_t; +extern db_regs_t ddb_regs; /* register state */ +#define DDB_REGS (&ddb_regs) + +#define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip) + +#define BKPT_INST 0xcc /* breakpoint instruction */ +#define BKPT_SIZE (1) /* size of breakpoint inst */ +#define BKPT_SET(inst) (BKPT_INST) + +#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1; + +#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T) +#define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T) + +#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) +/* + * Watchpoints are not supported. The debug exception type is in %dr6 + * and not yet in the args to this macro. + */ +#define IS_WATCHPOINT_TRAP(type, code) 0 + +#define I_CALL 0xe8 +#define I_CALLI 0xff +#define I_RET 0xc3 +#define I_IRET 0xcf + +#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) +#define inst_return(ins) (((ins)&0xff) == I_RET) +#define inst_call(ins) (((ins)&0xff) == I_CALL || \ + (((ins)&0xff) == I_CALLI && \ + ((ins)&0x3800) == 0x1000)) +#define inst_load(ins) 0 +#define inst_store(ins) 0 + +/* + * There no interesting addresses below _kstack = 0xefbfe000. There + * are small absolute values for GUPROF, but we don't want to see them. + * Treat "negative" addresses below _kstack as non-small to allow for + * future reductions of _kstack and to avoid sign extension problems. + * + * There is one interesting symbol above -db_maxoff = 0xffff0000, + * namely _APTD = 0xfffff000. Accepting this would mess up the + * printing of small negative offsets. The next largest symbol is + * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is + * set to >= 0x400000 - (max stack offset)). + */ +#define DB_SMALL_VALUE_MAX 0x7fffffff +#define DB_SMALL_VALUE_MIN (-0x400001) + +#endif /* !_MACHINE_DB_MACHDEP_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/dvcfg.h ./modules/label/machine/dvcfg.h --- ../sys-altq/modules/label/machine/dvcfg.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/dvcfg.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,64 @@ +/* $NetBSD$ */ +/* + * [NetBSD for NEC PC98 series] + * Copyright (c) 1996 NetBSD/pc98 porting staff. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/* + * Copyright (c) 1996 Naofumi HONDA. All rights reserved. + */ + +#ifndef _I386_DVCFG_H_ +#define _I386_DVCFG_H_ + +typedef void *dvcfg_hw_t; + +struct dvcfg_hwsel { + int cfg_max; + + dvcfg_hw_t *cfg_sel; +}; + +#define DVCFG_MAJOR(dvcfg) (((u_int)(dvcfg)) >> 16) +#define DVCFG_MINOR(dvcfg) (((u_int)(dvcfg)) & 0xffff) + +#define DVCFG_MKCFG(major, minor) ((((u_int)(major)) << 16) | ((minor) & 0xffff)) + +#define DVCFG_HWSEL_SZ(array) (sizeof(array) / sizeof(dvcfg_hw_t)) + +static __inline dvcfg_hw_t dvcfg_hw __P((struct dvcfg_hwsel *, u_int)); + +static __inline dvcfg_hw_t +dvcfg_hw(selp, num) + struct dvcfg_hwsel *selp; + u_int num; +{ + + return ((num >= selp->cfg_max) ? 0 : selp->cfg_sel[num]); +} + +#define DVCFG_HW(SELP, NUM) dvcfg_hw((SELP), (NUM)) +#endif /* _I386_DVCFG_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/elf.h ./modules/label/machine/elf.h --- ../sys-altq/modules/label/machine/elf.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/elf.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,133 @@ +/*- + * Copyright (c) 1996-1997 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/elf.h,v 1.5.2.3 1999/08/29 16:06:28 peter Exp $ + */ + +#ifndef _MACHINE_ELF_H_ +#define _MACHINE_ELF_H_ 1 + +/* + * ELF definitions for the i386 architecture. + */ + +#include /* Definitions common to all 32 bit architectures. */ + +#define __ELF_WORD_SIZE 32 /* Used by */ +#include + +#define ELF_ARCH EM_386 + +#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486) + +/* + * Auxiliary vector entries for passing information to the interpreter. + * + * The i386 supplement to the SVR4 ABI specification names this "auxv_t", + * but POSIX lays claim to all symbols ending with "_t". + */ + +typedef struct { /* Auxiliary vector entry on initial stack */ + int a_type; /* Entry type. */ + union { + long a_val; /* Integer value. */ + void *a_ptr; /* Address. */ + void (*a_fcn)(void); /* Function pointer (not used). */ + } a_un; +} Elf32_Auxinfo; + +__ElfType(Auxinfo); + +/* Values for a_type. */ +#define AT_NULL 0 /* Terminates the vector. */ +#define AT_IGNORE 1 /* Ignored entry. */ +#define AT_EXECFD 2 /* File descriptor of program to load. */ +#define AT_PHDR 3 /* Program header of program already loaded. */ +#define AT_PHENT 4 /* Size of each program header entry. */ +#define AT_PHNUM 5 /* Number of program header entries. */ +#define AT_PAGESZ 6 /* Page size in bytes. */ +#define AT_BASE 7 /* Interpreter's base address. */ +#define AT_FLAGS 8 /* Flags (unused for i386). */ +#define AT_ENTRY 9 /* Where interpreter should transfer control. */ + +/* + * The following non-standard values are used for passing information + * from John Polstra's testbed program to the dynamic linker. These + * are expected to go away soon. + * + * Unfortunately, these overlap the Linux non-standard values, so they + * must not be used in the same context. + */ +#define AT_BRK 10 /* Starting point for sbrk and brk. */ +#define AT_DEBUG 11 /* Debugging level. */ + +/* + * The following non-standard values are used in Linux ELF binaries. + */ +#define AT_NOTELF 10 /* Program is not ELF ?? */ +#define AT_UID 11 /* Real uid. */ +#define AT_EUID 12 /* Effective uid. */ +#define AT_GID 13 /* Real gid. */ +#define AT_EGID 14 /* Effective gid. */ + +#define AT_COUNT 15 /* Count of defined aux entry types. */ + +/* + * Relocation types. + */ + +#define R_386_NONE 0 /* No relocation. */ +#define R_386_32 1 /* Add symbol value. */ +#define R_386_PC32 2 /* Add PC-relative symbol value. */ +#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ +#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ +#define R_386_COPY 5 /* Copy data from shared object. */ +#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_386_RELATIVE 8 /* Add load address of shared object. */ +#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ +#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ + +#define R_386_COUNT 11 /* Count of defined relocation types. */ + +/* Define "machine" characteristics */ +#define ELF_TARG_CLASS ELFCLASS32 +#define ELF_TARG_DATA ELFDATA2LSB +#define ELF_TARG_MACH EM_386 +#define ELF_TARG_VER 1 + +#ifdef KERNEL + +/* + * On the i386 we load the dynamic linker where a userland call + * to mmap(0, ...) would put it. The rationale behind this + * calculation is that it leaves room for the heap to grow to + * its maximum allowed size. + */ +#define ELF_RTLD_ADDR(vmspace) \ + (round_page((vm_offset_t)(vmspace)->vm_daddr + MAXDSIZ)) + +#endif /* KERNEL */ +#endif /* !_MACHINE_ELF_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/endian.h ./modules/label/machine/endian.h --- ../sys-altq/modules/label/machine/endian.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/endian.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1987, 1991 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)endian.h 7.8 (Berkeley) 4/3/91 + * $FreeBSD: src/sys/i386/include/endian.h,v 1.16.2.1 1999/08/29 16:06:28 peter Exp $ + */ + +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +/* + * Define the order of 32-bit words in 64-bit words. + */ +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 + +#ifndef _POSIX_SOURCE + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +#define BYTE_ORDER LITTLE_ENDIAN + +#ifndef KERNEL +#include +#endif + +__BEGIN_DECLS +unsigned long htonl __P((unsigned long)); +unsigned short htons __P((unsigned short)); +unsigned long ntohl __P((unsigned long)); +unsigned short ntohs __P((unsigned short)); +__END_DECLS + +#define __word_swap_long(x) \ +__extension__ ({ register u_long __X = (x); \ + __asm ("rorl $16, %1" \ + : "=r" (__X) \ + : "0" (__X)); \ + __X; }) + +#if defined(KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU) + +#define __byte_swap_long(x) \ +__extension__ ({ register u_long __X = (x); \ + __asm ("bswap %0" \ + : "=r" (__X) \ + : "0" (__X)); \ + __X; }) +#else + +#define __byte_swap_long(x) \ +__extension__ ({ register u_long __X = (x); \ + __asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" \ + : "=q" (__X) \ + : "0" (__X)); \ + __X; }) +#endif + +#define __byte_swap_word(x) \ +__extension__ ({ register u_short __X = (x); \ + __asm ("xchgb %h1, %b1" \ + : "=q" (__X) \ + : "0" (__X)); \ + __X; }) + +/* + * Macros for network/external number representation conversion. + */ +#ifdef __GNUC__ +#define ntohl __byte_swap_long +#define ntohs __byte_swap_word +#define htonl __byte_swap_long +#define htons __byte_swap_word +#endif + +#define NTOHL(x) ((x) = ntohl((u_long)(x))) +#define NTOHS(x) ((x) = ntohs((u_short)(x))) +#define HTONL(x) ((x) = htonl((u_long)(x))) +#define HTONS(x) ((x) = htons((u_short)(x))) + +#endif /* ! _POSIX_SOURCE */ + +#endif /* !_MACHINE_ENDIAN_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/exec.h ./modules/label/machine/exec.h --- ../sys-altq/modules/label/machine/exec.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/exec.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)exec.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD: src/sys/i386/include/exec.h,v 1.7.4.1 1999/08/29 16:06:29 peter Exp $ + */ + +#ifndef _EXEC_H_ +#define _EXEC_H_ + +#define __LDPGSZ 4096 + +#endif /* !_EXEC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/float.h ./modules/label/machine/float.h --- ../sys-altq/modules/label/machine/float.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/float.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)float.h 7.1 (Berkeley) 5/8/90 + * $FreeBSD: src/sys/i386/include/float.h,v 1.7.4.1 1999/08/29 16:06:29 peter Exp $ + */ + +#ifndef _MACHINE_FLOAT_H_ +#define _MACHINE_FLOAT_H_ 1 + +#define FLT_RADIX 2 /* b */ +#define FLT_ROUNDS 1 /* FP addition rounds to nearest */ + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MAX_10_EXP 308 + +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON DBL_EPSILON +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN DBL_MIN +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX DBL_MAX +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP +#endif /* _MACHINE_FLOAT_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/floatingpoint.h ./modules/label/machine/floatingpoint.h --- ../sys-altq/modules/label/machine/floatingpoint.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/floatingpoint.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,121 @@ +/*- + * Copyright (c) 1993 Andrew Moore, Talke Studio + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 + * $FreeBSD: src/sys/i386/include/floatingpoint.h,v 1.9.2.1 1999/08/29 16:06:29 peter Exp $ + */ + +#ifndef _FLOATINGPOINT_H_ +#define _FLOATINGPOINT_H_ + +/* + * IEEE floating point structure and function definitions + */ + +/*- + * XXX the following undocumented pollution is exported: + * fpsetsticky(). + * FP*FLD, FP*OFF and FP*REG from + */ + +#include +#include + +#ifdef __GNUC__ + +#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr))) +#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr))) +#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr))) +#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr))) + +/* + * return the contents of a FP register + */ +static __inline__ int +__fpgetreg(int _reg) +{ + unsigned short _mem; + + /*- + * This is more efficient than it looks. The switch gets optimized + * away if _reg is constant. + * + * The default case only supports _reg == 0. We could handle more + * registers (e.g., tags) using fnstenv, but the interface doesn't + * support more. + */ + switch(_reg) { + default: + __fnstcw(&_mem); + break; + case FP_STKY_REG: + __fnstsw(&_mem); + break; + } + return _mem; +} + +/* + * set a FP mode; return previous mode + */ +static __inline__ int +__fpsetreg(int _m, int _reg, int _fld, int _off) +{ + unsigned _env[7]; + unsigned _p; + + /* + * _reg == 0 could be handled better using fnstcw/fldcw. + */ + __fnstenv(_env); + _p = (_env[_reg] & _fld) >> _off; + _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld); + __fldenv(_env); + return _p; +} + +#endif /* __GNUC__ */ + +/* + * SysV/386 FP control interface + */ +#define fpgetround() ((fp_rnd_t) ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF)) +#define fpsetround(m) ((fp_rnd_t) __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF)) +#define fpgetprec() ((fp_prec_t) ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF)) +#define fpsetprec(m) ((fp_prec_t) __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF)) +#define fpgetmask() ((fp_except_t) ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF)) +#define fpsetmask(m) ((fp_except_t) (__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF))) +#define fpgetsticky() ((fp_except_t) ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF)) +#define fpresetsticky(m) ((fp_except_t) __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF)) +#define fpsetsticky(m) fpresetsticky(m) + +#endif /* !_FLOATINGPOINT_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/frame.h ./modules/label/machine/frame.h --- ../sys-altq/modules/label/machine/frame.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/frame.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,171 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/frame.h,v 1.15.2.1 1999/08/29 16:06:30 peter Exp $ + */ + +#ifndef _MACHINE_FRAME_H_ +#define _MACHINE_FRAME_H_ 1 + +#include + +/* + * System stack frames. + */ + +/* + * Exception/Trap Stack Frame + */ + +struct trapframe { + int tf_es; + int tf_ds; + int tf_edi; + int tf_esi; + int tf_ebp; + int tf_isp; + int tf_ebx; + int tf_edx; + int tf_ecx; + int tf_eax; + int tf_trapno; + /* below portion defined in 386 hardware */ + int tf_err; + int tf_eip; + int tf_cs; + int tf_eflags; + /* below only when crossing rings (e.g. user to kernel) */ + int tf_esp; + int tf_ss; +}; + +/* Superset of trap frame, for traps from virtual-8086 mode */ + +struct trapframe_vm86 { + int tf_es; + int tf_ds; + int tf_edi; + int tf_esi; + int tf_ebp; + int tf_isp; + int tf_ebx; + int tf_edx; + int tf_ecx; + int tf_eax; + int tf_trapno; + /* below portion defined in 386 hardware */ + int tf_err; + int tf_eip; + int tf_cs; + int tf_eflags; + /* below only when crossing rings (e.g. user to kernel) */ + int tf_esp; + int tf_ss; + /* below only when switching out of VM86 mode */ + int tf_vm86_es; + int tf_vm86_ds; + int tf_vm86_fs; + int tf_vm86_gs; +}; + +/* Interrupt stack frame */ + +struct intrframe { + int if_vec; + int if_ppl; + int if_es; + int if_ds; + int if_edi; + int if_esi; + int if_ebp; + int :32; + int if_ebx; + int if_edx; + int if_ecx; + int if_eax; + int :32; /* for compat with trap frame - trapno */ + int :32; /* for compat with trap frame - err */ + /* below portion defined in 386 hardware */ + int if_eip; + int if_cs; + int if_eflags; + /* below only when crossing rings (e.g. user to kernel) */ + int if_esp; + int if_ss; +}; + +/* frame of clock (same as interrupt frame) */ + +struct clockframe { + int cf_vec; + int cf_ppl; + int cf_es; + int cf_ds; + int cf_edi; + int cf_esi; + int cf_ebp; + int :32; + int cf_ebx; + int cf_edx; + int cf_ecx; + int cf_eax; + int :32; /* for compat with trap frame - trapno */ + int :32; /* for compat with trap frame - err */ + /* below portion defined in 386 hardware */ + int cf_eip; + int cf_cs; + int cf_eflags; + /* below only when crossing rings (e.g. user to kernel) */ + int cf_esp; + int cf_ss; +}; + +/* + * Signal frame + */ +struct sigframe { + int sf_signum; + int sf_code; + struct sigcontext *sf_scp; + char *sf_addr; + sig_t sf_handler; + struct sigcontext sf_sc; +}; + +int kdb_trap __P((int, int, struct trapframe *)); +extern int (*pmath_emulate) __P((struct trapframe *)); + +#endif /* _MACHINE_FRAME_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/globaldata.h ./modules/label/machine/globaldata.h --- ../sys-altq/modules/label/machine/globaldata.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/globaldata.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,105 @@ +/*- + * Copyright (c) Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.6.2.2 1999/08/29 16:06:30 peter Exp $ + */ + +/* + * This structure maps out the global data that needs to be kept on a + * per-cpu basis. genassym uses this to generate offsets for the assembler + * code, which also provides external symbols so that C can get at them as + * though they were really globals. + * + * The SMP parts are setup in pmap.c and locore.s for the BSP, and + * mp_machdep.c sets up the data for the AP's to "see" when they awake. + * The reason for doing it via a struct is so that an array of pointers + * to each CPU's data can be set up for things like "check curproc on all + * other processors" + */ +struct globaldata { + struct proc *curproc; + struct proc *npxproc; + struct pcb *curpcb; + struct i386tss common_tss; + struct timeval switchtime; + int switchticks; +#ifdef VM86 + struct segment_descriptor common_tssd; + u_int private_tss; + u_int my_tr; +#endif +#ifdef USER_LDT + int currentldt; +#endif +#ifdef SMP + u_int cpuid; + u_int cpu_lockid; + u_int other_cpus; + pd_entry_t *my_idlePTD; + u_int ss_eflags; + pt_entry_t *prv_CMAP1; + pt_entry_t *prv_CMAP2; + pt_entry_t *prv_CMAP3; + pt_entry_t *prv_PMAP1; + int inside_intr; +#endif +}; + +#ifdef SMP +/* + * This is the upper (0xff800000) address space layout that is per-cpu. + * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for + * each AP. genassym helps export this to the assembler code. + */ +struct privatespace { + /* page 0 - data page */ + struct globaldata globaldata; + char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; + + /* page 1 - page table page */ + pt_entry_t prvpt[NPTEPG]; + + /* page 2 - local apic mapping */ + lapic_t lapic; + char __filler1[PAGE_SIZE - sizeof(lapic_t)]; + + /* page 3..2+UPAGES - idle stack (UPAGES pages) */ + char idlestack[UPAGES * PAGE_SIZE]; + + /* page 3+UPAGES..6+UPAGES - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ + char CPAGE1[PAGE_SIZE]; + char CPAGE2[PAGE_SIZE]; + char CPAGE3[PAGE_SIZE]; + char PPAGE1[PAGE_SIZE]; + + /* page 7+UPAGES..15 - spare, unmapped */ + char __filler2[(9-UPAGES) * PAGE_SIZE]; + + /* page 16-31 - space for IO apics */ + char ioapics[16 * PAGE_SIZE]; + + /* page 32-47 - maybe other cpu's globaldata pages? */ +}; +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/gsc.h ./modules/label/machine/gsc.h --- ../sys-altq/modules/label/machine/gsc.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/gsc.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,51 @@ +/* gsc.h - programming interface to the scanner device driver `gsc' + * + * + * Copyright (c) 1995 Gunther Schadow. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gunther Schadow. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_GSC_H_ +#define _MACHINE_GSC_H_ + +#include + +#define GSC_GRES _IOR('S', 1, int) /* get resolution / dpi */ +#define GSC_SRES _IOW('S', 2, int) /* set resolution / dpi */ +#define GSC_GWIDTH _IOR('S', 3, int) /* get width / pixels */ +#define GSC_SWIDTH _IOW('S', 4, int) /* set width / pixels */ +#define GSC_GHEIGHT _IOR('S', 5, int) /* get height / pixels */ +#define GSC_SHEIGHT _IOW('S', 6, int) /* set height / pixels */ + +#define GSC_GBLEN _IOR('S', 7, int) /* get buffer length / lines */ +#define GSC_SBLEN _IOW('S', 8, int) /* set buffer length / lines */ +#define GSC_GBTIME _IOR('S', 9, int) /* get buffer timeout / s */ +#define GSC_SBTIME _IOW('S', 10, int) /* set buffer timeout / s */ + +#define GSC_SRESSW _IO('S', 11) /* set resolution by switch */ + +#endif /* !_MACHINE_GSC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/i4b_cause.h ./modules/label/machine/i4b_cause.h --- ../sys-altq/modules/label/machine/i4b_cause.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/i4b_cause.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4b_cause.h - causes and cause handling for i4b + * ----------------------------------------------- + * + * $FreeBSD: src/sys/i386/include/i4b_cause.h,v 1.1.2.1 1999/08/29 16:06:31 peter Exp $ + * + * last edit-date: [Sat Dec 5 18:36:30 1998] + * + *---------------------------------------------------------------------------*/ + +#ifndef _I4B_CAUSE_H_ +#define _I4B_CAUSE_H_ + +/*---------------------------------------------------------------------------* + * ISDN4BSD internal causes specification + *---------------------------------------------------------------------------*/ + +#define CAUSE_VAL 0x000000ff /* cause value */ +#define CAUSE_TYPE 0x0000ff00 /* cause type */ +#define CAUSET_Q850 0 /* value coded according to Q.850 */ +#define CAUSET_I4B 1 /* i4b protocol independent causes*/ + +#define GET_CAUSE_VAL(cause) ((cause) & 0xff) +#define SET_CAUSE_VAL(dest, val) ((dest) = ((dest & 0xffffff00) | \ + (val & 0x000000ff))) + +#define GET_CAUSE_TYPE(cause) (((cause) >> 8) & 0xff) +#define SET_CAUSE_TYPE(dest, type) ((dest) = ((dest & 0xffff00ff) | \ + ((type << 8) & 0x0000ff00))) + +#define SET_CAUSE_TV(dest, type, val) ((dest) = ((val & 0x000000ff) | \ + ((type << 8) & 0x0000ff00))) + +/* CAUSET_I4B - protocol independent cause values */ + +#define CAUSE_I4B_NORMAL 0 /* normal call clearing */ +#define CAUSE_I4B_BUSY 1 /* user busy */ +#define CAUSE_I4B_NOCHAN 2 /* circuit/channel not available*/ +#define CAUSE_I4B_INCOMP 3 /* incompatible source/dest */ +#define CAUSE_I4B_REJECT 4 /* call rejected */ +#define CAUSE_I4B_OOO 5 /* destination out of order */ +#define CAUSE_I4B_TMPFAIL 6 /* temporary failure */ +#define CAUSE_I4B_L1ERROR 7 /* L1 error / persistent deact */ +#define CAUSE_I4B_MAX 8 + +/* CAUSET_Q850 - causes defined in Q.850 */ + +#define CAUSE_Q850_SHUTDN 0x00 /* normal D-channel shutdown */ +#define CAUSE_Q850_NUNALLC 0x01 /* Unallocated (unassigned) number */ +#define CAUSE_Q850_NRTTN 0x02 /* No route to specified transit network */ +#define CAUSE_Q850_NRTDST 0x03 /* No route to destination */ +#define CAUSE_Q850_SSINFTN 0x04 /* Send special information tone */ +#define CAUSE_Q850_MDIALTP 0x05 /* Misdialled trunk prefix */ +#define CAUSE_Q850_CHUNACC 0x06 /* Channel unacceptable */ +#define CAUSE_Q850_CALLAWD 0x07 /* Call awarded and being delivered in an established channel */ +#define CAUSE_Q850_PREEMPT 0x08 /* Preemption */ +#define CAUSE_Q850_PREECRR 0x09 /* Preemption - circuit reserved for reuse */ +#define CAUSE_Q850_NCCLR 0x10 /* Normal call clearing */ +#define CAUSE_Q850_USRBSY 0x11 /* User busy */ +#define CAUSE_Q850_NOUSRRSP 0x12 /* No user responding */ +#define CAUSE_Q850_NOANSWR 0x13 /* No answer from user (user alerted) */ +#define CAUSE_Q850_SUBSABS 0x14 /* Subscriber absent */ +#define CAUSE_Q850_CALLREJ 0x15 /* Call rejected */ +#define CAUSE_Q850_NUCHNG 0x16 /* Number changed */ +#define CAUSE_Q850_NONSELUC 0x1A /* Non-selected user clearing */ +#define CAUSE_Q850_DSTOOORDR 0x1B /* Destination out of order */ +#define CAUSE_Q850_INVNUFMT 0x1C /* Invalid number format */ +#define CAUSE_Q850_FACREJ 0x1D /* Facility rejected */ +#define CAUSE_Q850_STENQRSP 0x1E /* Response to STATUS ENQUIRY */ +#define CAUSE_Q850_NORMUNSP 0x1F /* Normal, unspecified */ +#define CAUSE_Q850_NOCAVAIL 0x22 /* No circuit / channel available */ +#define CAUSE_Q850_NETOOORDR 0x26 /* Network out of order */ +#define CAUSE_Q850_PFMCDOOSERV 0x27 /* Permanent frame mode connection out of service */ +#define CAUSE_Q850_PFMCOPER 0x28 /* Permanent frame mode connection operational */ +#define CAUSE_Q850_TMPFAIL 0x29 /* Temporary failure */ +#define CAUSE_Q850_SWEQCONG 0x2A /* Switching equipment congestion */ +#define CAUSE_Q850_ACCINFDIS 0x2B /* Access information discarded */ +#define CAUSE_Q850_REQCNOTAV 0x2C /* Requested circuit/channel not available */ +#define CAUSE_Q850_PRECALBLK 0x2E /* Precedence call blocked */ +#define CAUSE_Q850_RESUNAVAIL 0x2F /* Resources unavailable, unspecified */ +#define CAUSE_Q850_QOSUNAVAIL 0x31 /* Quality of service unavailable */ +#define CAUSE_Q850_REQSERVNS 0x32 /* Requested facility not subscribed */ +#define CAUSE_Q850_OCBARRCUG 0x35 /* Outgoing calls barred within CUG */ +#define CAUSE_Q850_ICBARRCUG 0x36 /* Incoming calls barred within CUG */ +#define CAUSE_Q850_BCAPNAUTH 0x39 /* Bearer capability not authorized */ +#define CAUSE_Q850_BCAPNAVAIL 0x3A /* Bearer capability not presently available */ +#define CAUSE_Q850_INCSTOACISC 0x3E /* Inconsistenciy in designated outgoing access information and subscriber class */ +#define CAUSE_Q850_SOONOTAVAIL 0x3F /* Service or option not available, unspecified */ +#define CAUSE_Q850_BCAPNOTIMPL 0x41 /* Bearer capability not implemented */ +#define CAUSE_Q850_CHTYPNIMPL 0x42 /* Channel type not implemented */ +#define CAUSE_Q850_REQFACNIMPL 0x45 /* Requested facility not implemented */ +#define CAUSE_Q850_ORDINBCAVL 0x46 /* Only restricted digital information bearer capability is available */ +#define CAUSE_Q850_SOONOTIMPL 0x4F /* Service or option not implemented, unspecified */ +#define CAUSE_Q850_INVCLRFVAL 0x51 /* Invalid call reference value */ +#define CAUSE_Q850_IDCHDNOEX 0x52 /* Identified channel does not exist */ +#define CAUSE_Q850_SUSCAEXIN 0x53 /* A suspended call exists, but this call identity does not */ +#define CAUSE_Q850_CLIDINUSE 0x54 /* Call identity in use */ +#define CAUSE_Q850_NOCLSUSP 0x55 /* No call suspended */ +#define CAUSE_Q850_CLIDCLRD 0x56 /* Call having the requested call identity has been cleared */ +#define CAUSE_Q850_UNOTMEMCUG 0x57 /* User not member of CUG */ +#define CAUSE_Q850_INCDEST 0x58 /* Incompatible destination */ +#define CAUSE_Q850_NONEXCUG 0x5A /* Non-existent CUG */ +#define CAUSE_Q850_INVNTWSEL 0x5B /* Invalid transit network selection */ +#define CAUSE_Q850_INVMSG 0x5F /* Invalid message, unspecified */ +#define CAUSE_Q850_MIEMISS 0x60 /* Mandatory information element is missing */ +#define CAUSE_Q850_MSGTNI 0x61 /* Message type non-existent or not implemented */ +#define CAUSE_Q850_MSGNCMPT 0x62 /* Message not compatible with call state or message type non-existent or not implemented */ +#define CAUSE_Q850_IENENI 0x63 /* Information element/parameter non-existent or not implemented */ +#define CAUSE_Q850_INVIEC 0x64 /* Invalid information element contents */ +#define CAUSE_Q850_MSGNCWCS 0x65 /* Message not compatible with call state */ +#define CAUSE_Q850_RECOTIMEXP 0x66 /* Recovery on timer expiry */ +#define CAUSE_Q850_PARMNENIPO 0x67 /* Parameter non-existent or not implemented, passed on */ +#define CAUSE_Q850_MSGUNRDPRM 0x6E /* Message with unrecognized parameter, discarded */ +#define CAUSE_Q850_PROTERR 0x6F /* Protocol error, unspecified */ +#define CAUSE_Q850_INTWRKU 0x7F /* Interworking, unspecified */ + +#define CAUSE_Q850_MAX 128 + +#endif /* _I4B_CAUSE_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/i4b_debug.h ./modules/label/machine/i4b_debug.h --- ../sys-altq/modules/label/machine/i4b_debug.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/i4b_debug.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,219 @@ +/* + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4b_debug.h - i4b debug header file + * ----------------------------------- + * + * $FreeBSD: src/sys/i386/include/i4b_debug.h,v 1.1.2.1 1999/08/29 16:06:31 peter Exp $ + * + * last edit-date: [Sat Dec 5 18:36:47 1998] + * + *---------------------------------------------------------------------------*/ + +#define DO_I4B_DEBUG /* enable debugging code inclusion */ + +#undef DO_I4B_MAXDEBUG /* enable ALL debug messages by default */ + +#ifdef DO_I4B_DEBUG + +extern unsigned int i4b_l1_debug; +extern unsigned int i4b_l2_debug; +extern unsigned int i4b_l3_debug; +extern unsigned int i4b_l4_debug; + +#define DBGL1(bits, routine, what) \ + if(bits & i4b_l1_debug) \ + { \ + printf("i4b-L1-%s: ", routine); \ + printf what ; \ + } + +#define DBGL2(bits, routine, what) \ + if(bits & i4b_l2_debug) \ + { \ + printf("i4b-L2-%s: ", routine); \ + printf what ; \ + } + +#define DBGL3(bits, routine, what) \ + if(bits & i4b_l3_debug) \ + { \ + printf("i4b-L3-%s: ", routine); \ + printf what ; \ + } + +#define DBGL4(bits, routine, what) \ + if(bits & i4b_l4_debug) \ + { \ + printf("i4b-L4-%s: ", routine); \ + printf what ; \ + } +#else /* !DO_I4B_DEBUG */ + +#define DBGL1(bits, routine, what); +#define DBGL2(bits, routine, what); +#define DBGL3(bits, routine, what); +#define DBGL4(bits, routine, what); + +#endif /* DO_I4B_DEBUG */ + +/* Layer 1 */ + +#define L1_ERROR 0x0001 /* general error message*/ +#define L1_PRIM 0x0002 /* interlayer primitives*/ +#define L1_BCHAN 0x0004 /* B channel action */ +#define L1_H_ERR 0x0008 /* HSCX errors */ +#define L1_H_IRQ 0x0010 /* HSCX IRQ messages */ +#define L1_I_ERR 0x0020 /* ISAC errors */ +#define L1_I_MSG 0x0040 /* ISAC messages */ +#define L1_I_SETUP 0x0080 /* ISAC setup messages */ +#define L1_F_MSG 0x0100 /* FSM messages */ +#define L1_F_ERR 0x0200 /* FSM error messages */ +#define L1_T_MSG 0x0400 /* Timer messages */ +#define L1_T_ERR 0x0800 /* Timer error messages */ +#define L1_H_XFRERR 0x1000 /* HSCX data xfer error */ +#define L1_I_CICO 0x2000 /* ISAC command in/out */ + +#define L1_DEBUG_MAX 0x3fef /* all messages on except IRQ! */ +#define L1_DEBUG_ERR (L1_H_ERR | L1_I_ERR | L1_F_ERR | L1_T_ERR | L1_ERROR) + +#ifndef L1_DEBUG_DEFAULT +#ifdef DO_I4B_MAXDEBUG +#define L1_DEBUG_DEFAULT L1_DEBUG_MAX +#else +#define L1_DEBUG_DEFAULT L1_DEBUG_ERR +#endif +#endif + +/* Layer 2 */ + +#define L2_ERROR 0x0001 /* general error message */ +#define L2_PRIM 0x0002 /* interlayer primitives */ +#define L2_U_MSG 0x0004 /* U frame messages */ +#define L2_U_ERR 0x0008 /* U frame error messages */ +#define L2_S_MSG 0x0010 /* S frame messages */ +#define L2_S_ERR 0x0020 /* S frame error messages */ +#define L2_I_MSG 0x0040 /* I frame messages */ +#define L2_I_ERR 0x0080 /* I frame error messages */ +#define L2_F_MSG 0x0100 /* FSM messages */ +#define L2_F_ERR 0x0200 /* FSM error messages */ +#define L2_T_MSG 0x0400 /* timer messages */ +#define L2_T_ERR 0x0800 /* timer error messages */ +#define L2_TEI_MSG 0x1000 /* TEI messages */ +#define L2_TEI_ERR 0x2000 /* TEI error messages */ + +#define L2_DEBUG_MAX 0x3fff /* all messages on */ +#define L2_DEBUG_ERR (L2_ERROR | L2_I_ERR | L2_F_ERR | L2_T_ERR | L2_S_ERR | L2_TEI_ERR | L2_U_ERR ) + +#ifndef L2_DEBUG_DEFAULT +#ifdef DO_I4B_MAXDEBUG +#define L2_DEBUG_DEFAULT L2_DEBUG_MAX +#else +#define L2_DEBUG_DEFAULT L2_DEBUG_ERR +#endif +#endif + +/* Layer 3 */ + +#define L3_ERR 0x0001 /* general error message */ +#define L3_MSG 0x0002 /* general message */ +#define L3_F_MSG 0x0004 /* FSM messages */ +#define L3_F_ERR 0x0008 /* FSM error messages */ +#define L3_T_MSG 0x0010 /* timer messages */ +#define L3_T_ERR 0x0020 /* timer error messages */ +#define L3_P_MSG 0x0040 /* protocol messages */ +#define L3_P_ERR 0x0080 /* protocol error messages */ +#define L3_A_MSG 0x0100 /* AOC messages */ +#define L3_A_ERR 0x0200 /* AOC error messages */ +#define L3_PRIM 0x0400 /* messages exchanged */ + +#define L3_DEBUG_MAX 0x07ff /* all messages on */ +#define L3_DEBUG_ERR (L3_ERR | L3_F_ERR | L3_T_ERR | L3_P_ERR | L3_A_ERR) + +#ifndef L3_DEBUG_DEFAULT +#ifdef DO_I4B_MAXDEBUG +#define L3_DEBUG_DEFAULT L3_DEBUG_MAX +#else +#define L3_DEBUG_DEFAULT L3_DEBUG_ERR +#endif +#endif + +/* Layer 4 */ + +#define L4_ERR 0x0001 /* general error message */ +#define L4_MSG 0x0002 /* general message */ +#define L4_TIMO 0x0004 /* b channel idle timeout msgs */ +#define L4_DIALST 0x0008 /* network driver dial states */ +#define L4_IPRDBG 0x0010 /* ipr driver debug messages */ +#define L4_RBCHDBG 0x0020 /* rbch driver debug messages */ + +#define L4_DEBUG_MAX 0x003f /* all messages on */ +#define L4_DEBUG_ERR (L4_ERR) + +#ifndef L4_DEBUG_DEFAULT +#ifdef DO_I4B_MAXDEBUG +#define L4_DEBUG_DEFAULT L4_DEBUG_MAX +#else +#define L4_DEBUG_DEFAULT L4_DEBUG_ERR +#endif +#endif + +/*---------------------------------------------------------------------------* + * ioctl via /dev/i4bctl: + * get/set current debug bits settings + *---------------------------------------------------------------------------*/ + +typedef struct { + unsigned int l1; + unsigned int l2; + unsigned int l3; + unsigned int l4; +} ctl_debug_t; + +#define I4B_CTL_GET_DEBUG _IOR('C', 0, ctl_debug_t) + +#define I4B_CTL_SET_DEBUG _IOW('C', 1, ctl_debug_t) + +/*---------------------------------------------------------------------------* + * get hscx statistics + *---------------------------------------------------------------------------*/ + +typedef struct { + int unit; /* controller number */ + int chan; /* channel number */ + int vfr; + int rdo; + int crc; + int rab; + int xdu; + int rfo; +} hscxstat_t; + +#define I4B_CTL_GET_HSCXSTAT _IOWR('C', 2, hscxstat_t) + +#define I4B_CTL_CLR_HSCXSTAT _IOW('C', 3, hscxstat_t) + +/* EOF */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/i4b_ioctl.h ./modules/label/machine/i4b_ioctl.h --- ../sys-altq/modules/label/machine/i4b_ioctl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/i4b_ioctl.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,606 @@ +/* + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4b_ioctl.h - messages kernel <--> userland + * ------------------------------------------- + * + * $FreeBSD: src/sys/i386/include/i4b_ioctl.h,v 1.1.2.1 1999/08/29 16:06:32 peter Exp $ + * + * last edit-date: [Tue Dec 22 20:33:46 1998] + * + *---------------------------------------------------------------------------*/ + +#ifndef _I4B_IOCTL_H_ +#define _I4B_IOCTL_H_ + +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 +#ifndef _MACHINE_TYPES_H_ +#include +#endif /* _MACHINE_TYPES_H_ */ +#endif /* __FreeBSD__ */ + +/*---------------------------------------------------------------------------* + * version and release number for isdn4bsd package + *---------------------------------------------------------------------------*/ +#define VERSION 0 /* version number */ +#define REL 70 /* release number */ +#define STEP 00 /* release step */ + +/*---------------------------------------------------------------------------* + * date/time format in i4b log messages + * ------------------------------------ + * Being year 2000 clean is not easy with the current state of the + * ANSI C library standard and it's implementation for some locales. + * You might like to use the "%c" format of "strftime" sometimes, + * but this breaks Y2K in some locales. Also the old standard logfile + * format "%d.%m.%y %H:%M:%S" is non compliant. + * NetBSD's current toolset warns about this problems, and we compile + * with -Werror, so this problems need to be resolved. + *---------------------------------------------------------------------------*/ +#define I4B_TIME_FORMAT "%d.%m.%Y %H:%M:%S" + +/*---------------------------------------------------------------------------* + * max number of controllers in system + *---------------------------------------------------------------------------*/ +#define MAX_CONTROLLERS 8 /* max number of controllers */ + +/*---------------------------------------------------------------------------* + * controller types + *---------------------------------------------------------------------------*/ +#define CTRL_INVALID (-1) /* invalid, error */ +#define CTRL_UNKNOWN 0 /* unknown controller type */ +#define CTRL_PASSIVE 1 /* passive ISDN controller cards*/ +#define CTRL_DAIC 2 /* Diehl active controller cards*/ +#define CTRL_NUMTYPES 3 /* number of controller types */ + +/*---------------------------------------------------------------------------* + * card types for CTRL_PASSIVE + *---------------------------------------------------------------------------*/ +#define CARD_TYPEP_INVAL (-1) /* invalid, error */ +#define CARD_TYPEP_UNK 0 /* unknown */ +#define CARD_TYPEP_8 1 /* Teles, S0/8 */ +#define CARD_TYPEP_16 2 /* Teles, S0/16 */ +#define CARD_TYPEP_16_3 3 /* Teles, S0/16.3 */ +#define CARD_TYPEP_AVMA1 4 /* AVM A1 or AVM Fritz!Card */ +#define CARD_TYPEP_163P 5 /* Teles, S0/16.3 PnP */ +#define CARD_TYPEP_CS0P 6 /* Creatix, S0 PnP */ +#define CARD_TYPEP_USRTA 7 /* US Robotics ISDN TA internal */ +#define CARD_TYPEP_DRNNGO 8 /* Dr. Neuhaus Niccy GO@ */ +#define CARD_TYPEP_SWS 9 /* Sedlbauer Win Speed */ +#define CARD_TYPEP_DYNALINK 10 /* Dynalink IS64PH */ +#define CARD_TYPEP_BLMASTER 11 /* ISDN Blaster / ISDN Master */ +#define CARD_TYPEP_PCFRITZ 12 /* AVM PCMCIA Fritz!Card */ +#define CARD_TYPEP_ELSAQS1ISA 13 /* ELSA QuickStep 1000pro ISA */ +#define CARD_TYPEP_ELSAQS1PCI 14 /* ELSA QuickStep 1000pro PCI */ +#define CARD_TYPEP_SIEMENSITALK 15 /* Siemens I-Talk */ +#define CARD_TYPEP_ELSAMLIMC 16 /* ELSA MicroLink ISDN/MC */ +#define CARD_TYPEP_ELSAMLMCALL 17 /* ELSA MicroLink MCall */ +#define CARD_TYPEP_ITKIX1 18 /* ITK ix1 micro */ + +/* + * in case you add support for more cards, please update: + * + * isdnd: support.c, name_of_controller() + * diehl/diehlctl: main.c, listall() + * + * and adjust CARD_TYPEP_MAX below. + */ + +#define CARD_TYPEP_MAX 18 /* max type */ + +/*---------------------------------------------------------------------------* + * card types for CTRL_DAIC + *---------------------------------------------------------------------------*/ +#define CARD_TYPEA_DAIC_UNK 0 +#define CARD_TYPEA_DAIC_S 1 +#define CARD_TYPEA_DAIC_SX 2 +#define CARD_TYPEA_DAIC_SCOM 3 +#define CARD_TYPEA_DAIC_QUAD 4 + +/*---------------------------------------------------------------------------* + * max length of some strings + *---------------------------------------------------------------------------*/ +#define TELNO_MAX 41 /* max length of a telephone number (+ '\0') */ +#define DISPLAY_MAX 91 /* max length of display information (+ '\0') */ +#define DATETIME_MAX 21 /* max length of datetime information (+ '\0')*/ + +/*---------------------------------------------------------------------------* + * in case the src or dst telephone number is empty + *---------------------------------------------------------------------------*/ +#define TELNO_EMPTY "NotAvailable" + +/*---------------------------------------------------------------------------* + * B channel parameters + *---------------------------------------------------------------------------*/ +#define BCH_MAX_DATALEN 2048 /* max length of a B channel frame */ + +/*---------------------------------------------------------------------------* + * userland driver types + * --------------------- + * a "driver" is defined here as a piece of software interfacing an + * ISDN B channel with a userland service, such as IP, Telephony etc. + *---------------------------------------------------------------------------*/ +#define BDRV_RBCH 0 /* raw b-channel interface driver */ +#define BDRV_TEL 1 /* telephone (speech) interface driver */ +#define BDRV_IPR 2 /* IP over raw HDLC interface driver */ +#define BDRV_ISPPP 3 /* sync Kernel PPP interface driver */ + +/*---------------------------------------------------------------------------* + * B channel protocol + *---------------------------------------------------------------------------*/ +#define BPROT_NONE 0 /* no protocol at all, raw data */ +#define BPROT_RHDLC 1 /* raw HDLC: flag, data, crc, flag */ + +/*---------------------------------------------------------------------------* + * causes data type + *---------------------------------------------------------------------------*/ +typedef unsigned int cause_t; /* 32 bit unsigned int */ + +/*---------------------------------------------------------------------------* + * call descriptor id (cdid) definitions + *---------------------------------------------------------------------------*/ +#define CDID_UNUSED 0 /* cdid is invalid and unused */ +#define CDID_MAX 99999 /* highest valid cdid, wraparound to 1 */ + + +/**************************************************************************** + + outgoing call: + -------------- + + userland kernel + -------- ------ + + CDID_REQ -----------------> + + <------------------ cdid + + CONNECT_REQ --------------> + + <------------------ PROCEEDING_IND (if connect req ok) + + <------------------ CONNECT_ACTIVE_IND (if connection ok) + + or + + <------------------ DISCONNECT_IND (if connection failed) + + + + incoming call: + -------------- + + userland kernel + -------- ------ + + <------------------ CONNECT_IND + + CONNECT_RESP -------------> + + <------------------ CONNECT_ACTIVE_IND (if accepted) + + + + active disconnect: + ------------------ + + userland kernel + -------- ------ + + DISCONNECT_REQ ------------> + + <------------------ DISCONNECT_IND + + + passive disconnect: + ------------------- + + userland kernel + -------- ------ + + <------------------ DISCONNECT_IND + + +****************************************************************************/ + + +/*===========================================================================* + *===========================================================================* + * "read" messages from kernel -> userland + *===========================================================================* + *===========================================================================*/ + + +/*---------------------------------------------------------------------------* + * message header, included in every message + *---------------------------------------------------------------------------*/ +typedef struct { + char type; /* message identifier */ +#define MSG_CONNECT_IND 'a' +#define MSG_CONNECT_ACTIVE_IND 'b' +#define MSG_DISCONNECT_IND 'c' +#define MSG_DIALOUT_IND 'd' +#define MSG_IDLE_TIMEOUT_IND 'e' +#define MSG_ACCT_IND 'f' +#define MSG_CHARGING_IND 'g' +#define MSG_PROCEEDING_IND 'h' +#define MSG_ALERT_IND 'i' +#define MSG_DRVRDISC_REQ 'j' +#define MSG_L12STAT_IND 'k' +#define MSG_TEIASG_IND 'l' +#define MSG_PDEACT_IND 'm' +#define MSG_NEGCOMP_IND 'n' +#define MSG_IFSTATE_CHANGED_IND 'o' + int cdid; /* call descriptor id */ +} msg_hdr_t; + +/*---------------------------------------------------------------------------* + * connect indication + * indicates incoming connection + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller number */ + int channel; /* channel number */ +#define CHAN_B1 0 /* this _must_ be 0, HSCX B1 is also 0 */ +#define CHAN_B2 1 /* this _must_ be 1, HSCX B2 is also 1 */ +#define CHAN_ANY (-1) /* outgoing, not possible for incoming */ +#define CHAN_NO (-2) /* call waiting (CW) for incoming */ + int bprot; /* b channel protocot, see BPROT_XXX */ + char dst_telno[TELNO_MAX]; /* destination telno */ + char src_telno[TELNO_MAX]; /* source telno */ + int scr_ind;/* screening indicator */ +#define SCR_NONE 0 /* no screening indicator transmitted */ +#define SCR_USR_NOSC 1 /* screening user provided, not screened*/ +#define SCR_USR_PASS 2 /* screening user provided, verified & passed */ +#define SCR_USR_FAIL 3 /* screening user provided, verified & failed */ +#define SCR_NET 4 /* screening network provided */ + char display[DISPLAY_MAX]; /* content of display IE*/ +} msg_connect_ind_t; + +/*---------------------------------------------------------------------------* + * connect active indication + * indicates active connection + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller number actually used */ + int channel; /* channel number actually used */ + char datetime[DATETIME_MAX]; /* content of date/time IE */ +} msg_connect_active_ind_t; + +/*---------------------------------------------------------------------------* + * disconnect indication + * indicates a disconnect + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + cause_t cause; /* cause code */ +} msg_disconnect_ind_t; + +/*---------------------------------------------------------------------------* + * negotiation complete + * indicates an interface is completely up & running + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ +} msg_negcomplete_ind_t; + +/*---------------------------------------------------------------------------* + * interface changes internal state + * indicates an interface has somehow switched its FSM + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int state; /* new interface state */ +} msg_ifstatechg_ind_t; + +/*---------------------------------------------------------------------------* + * initiate a call to a remote site + * i.e. the IP driver got a packet and wants a connection + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int driver; /* driver type */ + int driver_unit; /* driver unit number */ +} msg_dialout_ind_t; + +/*---------------------------------------------------------------------------* + * idle timeout disconnect sent indication + * kernel has sent disconnect request because of b-ch idle + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ +} msg_idle_timeout_ind_t; + +/*---------------------------------------------------------------------------* + * accounting information from userland interface driver to daemon + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int accttype; /* accounting type */ +#define ACCT_DURING 0 +#define ACCT_FINAL 1 + int driver; /* driver type */ + int driver_unit; /* driver unit number */ + int ioutbytes; /* ISDN # of bytes sent */ + int iinbytes; /* ISDN # of bytes received */ + int outbps; /* bytes per sec out */ + int inbps; /* bytes per sec in */ + int outbytes; /* driver # of bytes sent */ + int inbytes; /* driver # of bytes received */ +} msg_accounting_ind_t; + +/*---------------------------------------------------------------------------* + * charging information from isdn driver to daemon + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int units; /* number of units */ + int units_type; /* type of units info */ +#define CHARGE_INVALID 0 /* invalid, unknown */ +#define CHARGE_AOCD 1 /* advice of charge during call */ +#define CHARGE_AOCE 2 /* advice of charge at end of call */ +#define CHARGE_CALC 3 /* locally calculated from rates information */ +} msg_charging_ind_t; + +/*---------------------------------------------------------------------------* + * call proceeding indication + * indicates outgoing SETUP has been acknowleged + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller number actually used */ + int channel; /* channel number actually used */ +} msg_proceeding_ind_t; + +/*---------------------------------------------------------------------------* + * alert indication + * indicates remote user side "rings" + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ +} msg_alert_ind_t; + +/*---------------------------------------------------------------------------* + * driver requests to disconnect line + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int driver; /* driver type */ + int driver_unit; /* driver unit number */ +} msg_drvrdisc_req_t; + +/*---------------------------------------------------------------------------* + * state of layer 1/2 + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller unit */ + int layer; /* layer number (1/2) */ +#define LAYER_ONE 1 +#define LAYER_TWO 2 + int state; /* state info */ +#define LAYER_IDLE 0 +#define LAYER_ACTIVE 1 +} msg_l12stat_ind_t; + +/*---------------------------------------------------------------------------* + * TEI assignment messages + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller unit */ + int tei; /* TEI or -1 if invalid */ +} msg_teiasg_ind_t; + +/*---------------------------------------------------------------------------* + * persistent deactivation state of stack + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int controller; /* controller unit */ + int numactive; /* number of active connections */ +} msg_pdeact_ind_t; + + +/*===========================================================================* + *===========================================================================* + * "ioctl" messages from userland -> kernel + *===========================================================================* + *===========================================================================*/ + + +/*---------------------------------------------------------------------------* + * request a unique cdid (to setup an outgoing call) + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ +} msg_cdid_req_t; + +#define I4B_CDID_REQ _IOWR('4', 0, int) + +/*---------------------------------------------------------------------------* + * connect request + * requests an outgoing connection + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ + int controller; /* controller to use */ + int channel; /* channel to use */ + int txdelay; /* tx delay after connect */ + int bprot; /* b channel protocol */ + int driver; /* driver to route b channel data to */ + int driver_unit; /* unit number for above driver */ + int unitlen_time; /* length of a charging unit */ + int idle_time; /* time without activity on b ch */ + int earlyhup_time; /* safety area at end of unit */ + int unitlen_method; /* how to calculate the unitlength */ +#define ULEN_METHOD_STATIC 0 /* use unitlen_time value (see above) */ +#define ULEN_METHOD_DYNAMIC 1 /* use AOCD */ + char dst_telno[TELNO_MAX]; /* destination telephone no */ + char src_telno[TELNO_MAX]; /* source telephone number */ +} msg_connect_req_t; + +#define I4B_CONNECT_REQ _IOW('4', 1, msg_connect_req_t) + +/*---------------------------------------------------------------------------* + * connect response + * this is the answer to an incoming connect indication + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ + int response; /* what to do with incoming call */ +#define SETUP_RESP_DNTCRE 0 /* dont care, call is not for me */ +#define SETUP_RESP_REJECT 1 /* reject call */ +#define SETUP_RESP_ACCEPT 2 /* accept call */ + cause_t cause; /* cause for case SETUP_RESP_REJECT */ + /* the following are only used for SETUP_RESP_ACCEPT !! */ + int txdelay; /* tx delay after connect */ + int bprot; /* B chan protocol */ + int driver; /* driver to route b channel data to */ + int driver_unit; /* unit number for above driver */ + int max_idle_time; /* max time without activity on b ch */ +} msg_connect_resp_t; + +#define I4B_CONNECT_RESP _IOW('4', 2, msg_connect_resp_t) + +/*---------------------------------------------------------------------------* + * disconnect request + * active disconnect request + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ + cause_t cause; /* protocol independent cause */ +} msg_discon_req_t; + +#define I4B_DISCONNECT_REQ _IOW('4', 3, msg_discon_req_t) + +/*---------------------------------------------------------------------------* + * controller info request + *---------------------------------------------------------------------------*/ +typedef struct { + int controller; /* controller number */ + int ncontroller; /* number of controllers in system */ + int ctrl_type; /* controller type passive/active */ + int card_type; /* brand / version */ + int tei; /* tei controller probably has */ +} msg_ctrl_info_req_t; + +#define I4B_CTRL_INFO_REQ _IOWR('4', 4, msg_ctrl_info_req_t) + +/*---------------------------------------------------------------------------* + * dialout response + * status report to driver who requested a dialout + *---------------------------------------------------------------------------*/ +typedef struct { + int driver; /* driver to route b channel data to */ + int driver_unit; /* unit number for above driver */ + int stat; /* state of dialout request */ +#define DSTAT_NONE 0 +#define DSTAT_TFAIL 1 /* transient failure */ +#define DSTAT_PFAIL 2 /* permanent failure */ +#define DSTAT_INONLY 3 /* no outgoing dials allowed */ +} msg_dialout_resp_t; + +#define I4B_DIALOUT_RESP _IOW('4', 5, msg_dialout_resp_t) + +/*---------------------------------------------------------------------------* + * timeout value update + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ + int unitlen_time; /* length of a charging unit */ + int idle_time; /* time without activity on b ch */ + int earlyhup_time; /* safety area at end of unit */ +} msg_timeout_upd_t; + +#define I4B_TIMEOUT_UPD _IOW('4', 6, msg_timeout_upd_t) + +/*---------------------------------------------------------------------------* + * soft enable/disable + *---------------------------------------------------------------------------*/ +typedef struct { + int driver; /* driver to route b channel data to */ + int driver_unit; /* unit number for above driver */ + int updown; /* what to do */ +#define SOFT_ENA 0 /* enable interface */ +#define SOFT_DIS 1 /* disable interface */ +} msg_updown_ind_t; + +#define I4B_UPDOWN_IND _IOW('4', 7, msg_updown_ind_t) + +/*---------------------------------------------------------------------------* + * send alert request + *---------------------------------------------------------------------------*/ +typedef struct { + int cdid; /* call descriptor id */ +} msg_alert_req_t; + +#define I4B_ALERT_REQ _IOW('4', 8, msg_alert_req_t) + +/*---------------------------------------------------------------------------* + * request version and release info from kernel part + *---------------------------------------------------------------------------*/ +typedef struct { + int version; /* version number */ + int release; /* release number */ + int step; /* release step number */ +} msg_vr_req_t; + +#define I4B_VR_REQ _IOR('4', 9, msg_vr_req_t) + +/*---------------------------------------------------------------------------* + * Protocol download to active cards + *---------------------------------------------------------------------------*/ +struct isdn_dr_prot { + size_t bytecount; /* length of code */ + u_int8_t *microcode; /* pointer to microcode */ +}; + +struct isdn_download_request { + int controller; /* controller number */ + int numprotos; /* number of protocols in 'protocols' */ + struct isdn_dr_prot *protocols; +}; + +#define I4B_CTRL_DOWNLOAD _IOW('4', 100, struct isdn_download_request) + +/*---------------------------------------------------------------------------* + * Generic diagnostic interface for active cards + *---------------------------------------------------------------------------*/ +struct isdn_diagnostic_request { + int controller; /* controller number */ + u_int32_t cmd; /* diagnostic command to execute */ + size_t in_param_len; /* length of additional input parameter */ + void *in_param; /* optional input parameter */ + size_t out_param_len; /* available output space */ + void *out_param; /* output data goes here */ +}; + +#define I4B_ACTIVE_DIAGNOSTIC _IOW('4', 102, struct isdn_diagnostic_request) + +#endif /* _I4B_IOCTL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/i4b_tel_ioctl.h ./modules/label/machine/i4b_tel_ioctl.h --- ../sys-altq/modules/label/machine/i4b_tel_ioctl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/i4b_tel_ioctl.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4b_tel_ioctl.h telephony interface ioctls + * ------------------------------------------ + * + * $FreeBSD: src/sys/i386/include/i4b_tel_ioctl.h,v 1.1.2.1 1999/08/29 16:06:32 peter Exp $ + * + * last edit-date: [Sat Dec 5 18:37:36 1998] + * + *---------------------------------------------------------------------------*/ + +#ifndef _I4B_TEL_IOCTL_H_ +#define _I4B_TEL_IOCTL_H_ + +/* supported audio format conversions for /dev/i4btelXX devices */ + +#define CVT_NONE 0 /* no format conversion */ +#define CVT_ALAW2ULAW 1 /* kernel A-law, userland mu-law */ + +/*---------------------------------------------------------------------------* + * get / set audio format + *---------------------------------------------------------------------------*/ + +#define I4B_TEL_GETAUDIOFMT _IOR('A', 0, int) +#define I4B_TEL_SETAUDIOFMT _IOW('A', 1, int) +#define I4B_TEL_EMPTYINPUTQUEUE _IOW('A', 2, int) + +#endif /* _I4B_TEL_IOCTL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/i4b_trace.h ./modules/label/machine/i4b_trace.h --- ../sys-altq/modules/label/machine/i4b_trace.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/i4b_trace.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4b_trace.h - header file for trace data read device + * ---------------------------------------------------- + * + * $FreeBSD: src/sys/i386/include/i4b_trace.h,v 1.1.2.1 1999/08/29 16:06:32 peter Exp $ + * + * last edit-date: [Sat Dec 5 18:37:49 1998] + * + *---------------------------------------------------------------------------*/ + +#ifndef _I4B_TRACE_H_ +#define _I4B_TRACE_H_ + +/*---------------------------------------------------------------------------* + * structure of the header at the beginning of every trace mbuf + *---------------------------------------------------------------------------*/ +typedef struct { + int length; /* length of the following mbuf */ + int unit; /* controller unit number */ + int type; /* type of channel */ +#define TRC_CH_I 0 /* Layer 1 INFO's */ +#define TRC_CH_D 1 /* D channel */ +#define TRC_CH_B1 2 /* B1 channel */ +#define TRC_CH_B2 3 /* B2 channel */ + int dir; /* direction */ +#define FROM_TE 0 /* user -> network */ +#define FROM_NT 1 /* network -> user */ + int trunc; /* # of truncated bytes (frame > MCLBYTES) */ + unsigned int count; /* frame count for this unit/type */ + struct timeval time; /* timestamp for this frame */ +} i4b_trace_hdr_t; + +#define INFO0 0 /* layer 1 */ +#define INFO1_8 1 +#define INFO1_10 2 +#define INFO2 3 +#define INFO3 4 +#define INFO4_8 5 +#define INFO4_10 6 + +/*---------------------------------------------------------------------------* + * ioctl via /dev/i4btrc device(s): + * get/set current trace flag settings + *---------------------------------------------------------------------------*/ + +#define I4B_TRC_GET _IOR('T', 0, int) /* get trace settings */ +#define I4B_TRC_SET _IOW('T', 1, int) /* set trace settings */ + +#define TRACE_OFF 0x00 /* tracing off */ +#define TRACE_I 0x01 /* trace L1 INFO's on */ +#define TRACE_D_TX 0x02 /* trace D channel on */ +#define TRACE_D_RX 0x04 /* trace D channel on */ +#define TRACE_B_TX 0x08 /* trace B channel on */ +#define TRACE_B_RX 0x10 /* trace B channel on */ + +typedef struct { + int rxunit; /* unit # for rx frames */ + int rxflags; /* d and/or b channel */ + int txunit; /* unit # for tx frames */ + int txflags; /* d and/or b channel */ +} i4b_trace_setupa_t; + +#define I4B_TRC_SETA _IOW('T', 2, i4b_trace_setupa_t) /* set analyze mode */ +#define I4B_TRC_RESETA _IOW('T', 3, int) /* reset analyze mode */ + +#endif /* _I4B_TRACE_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ieeefp.h ./modules/label/machine/ieeefp.h --- ../sys-altq/modules/label/machine/ieeefp.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ieeefp.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 1990 Andrew Moore, Talke Studio + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 + * $FreeBSD: src/sys/i386/include/ieeefp.h,v 1.5.4.1 1999/08/29 16:06:33 peter Exp $ + */ + +/* + * IEEE floating point type and constant definitions. + */ + +#ifndef _MACHINE_IEEEFP_H_ +#define _MACHINE_IEEEFP_H_ + +/* + * FP rounding modes + */ +typedef enum { + FP_RN=0, /* round to nearest */ + FP_RM, /* round down to minus infinity */ + FP_RP, /* round up to plus infinity */ + FP_RZ /* truncate */ +} fp_rnd_t; + +/* + * FP precision modes + */ +typedef enum { + FP_PS=0, /* 24 bit (single-precision) */ + FP_PRS, /* reserved */ + FP_PD, /* 53 bit (double-precision) */ + FP_PE /* 64 bit (extended-precision) */ +} fp_prec_t; + +#define fp_except_t int + +/* + * FP exception masks + */ +#define FP_X_INV 0x01 /* invalid operation */ +#define FP_X_DNML 0x02 /* denormal */ +#define FP_X_DZ 0x04 /* zero divide */ +#define FP_X_OFL 0x08 /* overflow */ +#define FP_X_UFL 0x10 /* underflow */ +#define FP_X_IMP 0x20 /* (im)precision */ + +/* + * FP registers + */ +#define FP_MSKS_REG 0 /* exception masks */ +#define FP_PRC_REG 0 /* precision */ +#define FP_RND_REG 0 /* direction */ +#define FP_STKY_REG 1 /* sticky flags */ + +/* + * FP register bit field masks + */ +#define FP_MSKS_FLD 0x3f /* exception masks field */ +#define FP_PRC_FLD 0x300 /* precision control field */ +#define FP_RND_FLD 0xc00 /* round control field */ +#define FP_STKY_FLD 0x3f /* sticky flags field */ + +/* + * FP register bit field offsets + */ +#define FP_MSKS_OFF 0 /* exception masks offset */ +#define FP_PRC_OFF 8 /* precision control offset */ +#define FP_RND_OFF 10 /* round control offset */ +#define FP_STKY_OFF 0 /* sticky flags offset */ + +#endif /* !_MACHINE_IEEEFP_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/if_wavelan_ieee.h ./modules/label/machine/if_wavelan_ieee.h --- ../sys-altq/modules/label/machine/if_wavelan_ieee.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/if_wavelan_ieee.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,281 @@ +/* + * Copyright (c) 1997, 1998, 1999 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/if_wavelan_ieee.h,v 1.1.2.2 1999/08/29 16:06:33 peter Exp $ + */ + +#ifndef _IF_WAVELAN_IEEE_H +#define _IF_WAVELAN_IEEE_H + +/* + * This header defines a simple command interface to the FreeBSD + * WaveLAN/IEEE driver (wi) driver, which is used to set certain + * device-specific parameters which can't be easily managed through + * ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_ + * interface, didn't I. + */ + +#ifndef SIOCSWAVELAN +#define SIOCSWAVELAN SIOCSIFGENERIC +#endif + +#ifndef SIOCGWAVELAN +#define SIOCGWAVELAN SIOCGIFGENERIC +#endif + +/* + * Technically I don't think there's a limit to a record + * length. The largest record is the one that contains the CIS + * data, which is 240 words long, so 256 should be a safe + * value. + */ +#define WI_MAX_DATALEN 512 + +struct wi_req { + u_int16_t wi_len; + u_int16_t wi_type; + u_int16_t wi_val[WI_MAX_DATALEN]; +}; + +/* + * Private LTV records (interpreted only by the driver). This is + * a minor kludge to allow reading the interface statistics from + * the driver. + */ +#define WI_RID_IFACE_STATS 0x0100 +#define WI_RID_MGMT_XMIT 0x0200 + +struct wi_80211_hdr { + u_int16_t frame_ctl; + u_int16_t dur_id; + u_int8_t addr1[6]; + u_int8_t addr2[6]; + u_int8_t addr3[6]; + u_int16_t seq_ctl; + u_int8_t addr4[6]; +}; + +#define WI_FCTL_VERS 0x0002 +#define WI_FCTL_FTYPE 0x000C +#define WI_FCTL_STYPE 0x00F0 +#define WI_FCTL_TODS 0x0100 +#define WI_FCTL_FROMDS 0x0200 +#define WI_FCTL_MOREFRAGS 0x0400 +#define WI_FCTL_RETRY 0x0800 +#define WI_FCTL_PM 0x1000 +#define WI_FCTL_MOREDATA 0x2000 +#define WI_FCTL_WEP 0x4000 +#define WI_FCTL_ORDER 0x8000 + +#define WI_FTYPE_MGMT 0x0000 +#define WI_FTYPE_CTL 0x0004 +#define WI_FTYPE_DATA 0x0008 + +#define WI_STYPE_MGMT_ASREQ 0x0000 /* association request */ +#define WI_STYPE_MGMT_ASRESP 0x0010 /* association response */ +#define WI_STYPE_MGMT_REASREQ 0x0020 /* reassociation request */ +#define WI_STYPE_MGMT_REASRESP 0x0030 /* reassociation response */ +#define WI_STYPE_MGMT_PROBEREQ 0x0040 /* probe request */ +#define WI_STYPE_MGMT_PROBERESP 0x0050 /* probe response */ +#define WI_STYPE_MGMT_BEACON 0x0080 /* beacon */ +#define WI_STYPE_MGMT_ATIM 0x0090 /* announcement traffic ind msg */ +#define WI_STYPE_MGMT_DISAS 0x00A0 /* disassociation */ +#define WI_STYPE_MGMT_AUTH 0x00B0 /* authentication */ +#define WI_STYPE_MGMT_DEAUTH 0x00C0 /* deauthentication */ + +struct wi_mgmt_hdr { + u_int16_t frame_ctl; + u_int16_t duration; + u_int8_t dst_addr[6]; + u_int8_t src_addr[6]; + u_int8_t bssid[6]; + u_int16_t seq_ctl; +}; + +#ifndef KERNEL +struct wi_counters { + u_int32_t wi_tx_unicast_frames; + u_int32_t wi_tx_multicast_frames; + u_int32_t wi_tx_fragments; + u_int32_t wi_tx_unicast_octets; + u_int32_t wi_tx_multicast_octets; + u_int32_t wi_tx_deferred_xmits; + u_int32_t wi_tx_single_retries; + u_int32_t wi_tx_multi_retries; + u_int32_t wi_tx_retry_limit; + u_int32_t wi_tx_discards; + u_int32_t wi_rx_unicast_frames; + u_int32_t wi_rx_multicast_frames; + u_int32_t wi_rx_fragments; + u_int32_t wi_rx_unicast_octets; + u_int32_t wi_rx_multicast_octets; + u_int32_t wi_rx_fcs_errors; + u_int32_t wi_rx_discards_nobuf; + u_int32_t wi_tx_discards_wrong_sa; + u_int32_t wi_rx_WEP_cant_decrypt; + u_int32_t wi_rx_msg_in_msg_frags; + u_int32_t wi_rx_msg_in_bad_msg_frags; +}; + +/* + * These are all the LTV record types that we can read or write + * from the WaveLAN. Not all of them are temendously useful, but I + * list as many as I know about here for completeness. + */ + +#define WI_RID_DNLD_BUF 0xFD01 +#define WI_RID_MEMSZ 0xFD02 +#define WI_RID_DOMAINS 0xFD11 +#define WI_RID_CIS 0xFD13 +#define WI_RID_COMMQUAL 0xFD43 +#define WI_RID_SCALETHRESH 0xFD46 +#define WI_RID_PCF 0xFD87 + +/* + * Network parameters, static configuration entities. + */ +#define WI_RID_PORTTYPE 0xFC00 /* Connection control characteristics */ +#define WI_RID_MAC_NODE 0xFC01 /* MAC address of this station */ +#define WI_RID_DESIRED_SSID 0xFC02 /* Service Set ID for connection */ +#define WI_RID_OWN_CHNL 0xFC03 /* Comm channel for BSS creation */ +#define WI_RID_OWN_SSID 0xFC04 /* IBSS creation ID */ +#define WI_RID_OWN_ATIM_WIN 0xFC05 /* ATIM window time for IBSS creation */ +#define WI_RID_SYSTEM_SCALE 0xFC06 /* scale that specifies AP density */ +#define WI_RID_MAX_DATALEN 0xFC07 /* Max len of MAC frame body data */ +#define WI_RID_MAC_WDS 0xFC08 /* MAC addr of corresponding WDS node */ +#define WI_RID_PM_ENABLED 0xFC09 /* ESS power management enable */ +#define WI_RID_PM_EPS 0xFC0A /* PM EPS/PS mode */ +#define WI_RID_MCAST_RX 0xFC0B /* ESS PM mcast reception */ +#define WI_RID_MAX_SLEEP 0xFC0C /* max sleep time for ESS PM */ +#define WI_RID_HOLDOVER 0xFC0D /* holdover time for ESS PM */ +#define WI_RID_NODENAME 0xFC0E /* ID name of this node for diag */ +#define WI_RID_DTIM_PERIOD 0xFC10 /* beacon interval between DTIMs */ +#define WI_RID_WDS_ADDR1 0xFC11 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR2 0xFC12 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR3 0xFC13 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR4 0xFC14 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR5 0xFC15 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR6 0xFC16 /* port 1 MAC of WDS link node */ +#define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */ + +/* + * Network parameters, dynamic configuration entities + */ +#define WI_RID_MCAST_LIST 0xFC80 /* list of multicast addrs */ +#define WI_RID_CREATE_IBSS 0xFC81 /* create IBSS */ +#define WI_RID_FRAG_THRESH 0xFC82 /* frag len, unicast msg xmit */ +#define WI_RID_RTS_THRESH 0xFC83 /* frame len for RTS/CTS handshake */ +#define WI_RID_TX_RATE 0xFC84 /* data rate for message xmit */ +#define WI_RID_PROMISC 0xFC85 /* enable promisc mode */ +#define WI_RID_FRAG_THRESH0 0xFC90 +#define WI_RID_FRAG_THRESH1 0xFC91 +#define WI_RID_FRAG_THRESH2 0xFC92 +#define WI_RID_FRAG_THRESH3 0xFC93 +#define WI_RID_FRAG_THRESH4 0xFC94 +#define WI_RID_FRAG_THRESH5 0xFC95 +#define WI_RID_FRAG_THRESH6 0xFC96 +#define WI_RID_RTS_THRESH0 0xFC97 +#define WI_RID_RTS_THRESH1 0xFC98 +#define WI_RID_RTS_THRESH2 0xFC99 +#define WI_RID_RTS_THRESH3 0xFC9A +#define WI_RID_RTS_THRESH4 0xFC9B +#define WI_RID_RTS_THRESH5 0xFC9C +#define WI_RID_RTS_THRESH6 0xFC9D +#define WI_RID_TX_RATE0 0xFC9E +#define WI_RID_TX_RATE1 0xFC9F +#define WI_RID_TX_RATE2 0xFCA0 +#define WI_RID_TX_RATE3 0xFCA1 +#define WI_RID_TX_RATE4 0xFCA2 +#define WI_RID_TX_RATE5 0xFCA3 +#define WI_RID_TX_RATE6 0xFCA4 +#define WI_RID_TICK_TIME 0xFCE0 + +/* + * NIC information + */ +#define WI_RID_FIRM_ID 0xFD02 /* Primary func firmware ID. */ +#define WI_RID_PRI_SUP_RANGE 0xFD03 /* primary supplier compatibility */ +#define WI_RID_CIF_ACT_RANGE 0xFD04 /* controller sup. compatibility */ +#define WI_RID_SERIALNO 0xFD0A /* card serial number */ +#define WI_RID_CARD_ID 0xFD0B /* card identification */ +#define WI_RID_MFI_SUP_RANGE 0xFD0C /* modem supplier compatibility */ +#define WI_RID_CFI_SUP_RANGE 0xFD0D /* controller sup. compatibility */ +#define WI_RID_CHANNEL_LIST 0xFD10 /* allowd comm. frequencies. */ +#define WI_RID_REG_DOMAINS 0xFD11 /* list of intendted regulatory doms */ +#define WI_RID_TEMP_TYPE 0xFD12 /* hw temp range code */ +#define WI_RID_CIS 0xFD13 /* PC card info struct */ +#define WI_RID_STA_IDENEITY 0xFD20 /* station funcs firmware ident */ +#define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */ +#define WI_RID_MFI_ACT_RANGE 0xFD22 +#define WI_RID_CFI_ACT_RANGE 0xFD33 + +/* + * MAC information + */ +#define WI_RID_PORT_STAT 0xFD40 /* actual MAC port con control stat */ +#define WI_RID_CURRENT_SSID 0xFD41 /* ID of actually connected SS */ +#define WI_RID_CURRENT_BSSID 0xFD42 /* ID of actually connected BSS */ +#define WI_RID_COMMS_QUALITY 0xFD43 /* quality of BSS connection */ +#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ +#define WI_RID_OWN_BEACON_INT 0xFD45 /* beacon xmit time for BSS creation */ +#define WI_RID_CUR_SCALE_THRESH 0xFD46 /* actual system scane thresh setting */ +#define WI_RID_PROT_RESP_TIME 0xFD47 /* time to wait for resp to req msg */ +#define WI_RID_SHORT_RTR_LIM 0xFD48 /* max tx attempts for short frames */ +#define WI_RID_LONG_RTS_LIM 0xFD49 /* max tx attempts for long frames */ +#define WI_RID_MAX_TX_LIFE 0xFD4A /* max tx frame handling duration */ +#define WI_RID_MAX_RX_LIFE 0xFD4B /* max rx frame handling duration */ +#define WI_RID_CF_POLL 0xFD4C /* contention free pollable ind */ +#define WI_RID_AUTH_ALGS 0xFD4D /* auth algorithms available */ +#define WI_RID_AUTH_TYPE 0xFD4E /* availanle auth types */ +#define WI_RID_WEP_AVAIL 0xFD4F /* WEP privacy option available */ +#define WI_RID_CUR_TX_RATE1 0xFD80 +#define WI_RID_CUR_TX_RATE2 0xFD81 +#define WI_RID_CUR_TX_RATE3 0xFD82 +#define WI_RID_CUR_TX_RATE4 0xFD83 +#define WI_RID_CUR_TX_RATE5 0xFD84 +#define WI_RID_CUR_TX_RATE6 0xFD85 +#define WI_RID_OWN_MAC 0xFD86 /* unique local MAC addr */ +#define WI_RID_PCI_INFO 0xFD87 /* point coordination func cap */ + +/* + * Modem information + */ +#define WI_RID_PHY_TYPE 0xFDC0 /* phys layer type indication */ +#define WI_RID_CURRENT_CHAN 0xFDC1 /* current frequency */ +#define WI_RID_PWR_STATE 0xFDC2 /* pwr consumption status */ +#define WI_RID_CCA_MODE 0xFDC3 /* clear chan assess mode indication */ +#define WI_RID_CCA_TIME 0xFDC4 /* clear chan assess time */ +#define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */ +#define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */ +#endif + + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/if_wl_wavelan.h ./modules/label/machine/if_wl_wavelan.h --- ../sys-altq/modules/label/machine/if_wl_wavelan.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/if_wl_wavelan.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,167 @@ +/* $FreeBSD: src/sys/i386/include/if_wl_wavelan.h,v 1.3.2.1 1999/08/29 16:06:33 peter Exp $ */ +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain all copyright + * notices, this list of conditions and the following disclaimer. + * 2. The names of the authors may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _CHIPS_WAVELAN_H +#define _CHIPS_WAVELAN_H + +/* This file contains definitions that are common for all versions of + * the NCR WaveLAN + */ + +#define WAVELAN_ADDR_SIZE 6 /* Size of a MAC address */ +#define WAVELAN_MTU 1500 /* Maximum size of Wavelan packet */ + +/* Modem Management Controler write commands */ +#define MMC_ENCR_KEY 0x00 /* to 0x07 */ +#define MMC_ENCR_ENABLE 0x08 +#define MMC_DES_IO_INVERT 0x0a +#define MMC_LOOPT_SEL 0x10 +#define MMC_JABBER_ENABLE 0x11 +#define MMC_FREEZE 0x12 +#define MMC_ANTEN_SEL 0x13 +#define MMC_IFS 0x14 +#define MMC_MOD_DELAY 0x15 +#define MMC_JAM_TIME 0x16 +#define MMC_THR_PRE_SET 0x18 +#define MMC_DECAY_PRM 0x19 +#define MMC_DECAY_UPDAT_PRM 0x1a +#define MMC_QUALITY_THR 0x1b +#define MMC_NETW_ID_L 0x1c +#define MMC_NETW_ID_H 0x1d +#define MMC_MODE_SEL 0x1e +#define MMC_EECTRL 0x20 /* 2.4 Gz */ +#define MMC_EEADDR 0x21 /* 2.4 Gz */ +#define MMC_EEDATAL 0x22 /* 2.4 Gz */ +#define MMC_EEDATAH 0x23 /* 2.4 Gz */ +#define MMC_ANALCTRL 0x24 /* 2.4 Gz */ + +/* fields in MMC registers that relate to EEPROM in WaveMODEM daughtercard */ +#define MMC_EECTRL_EEPRE 0x10 /* 2.4 Gz EEPROM Protect Reg Enable */ +#define MMC_EECTRL_DWLD 0x08 /* 2.4 Gz EEPROM Download Synths */ +#define MMC_EECTRL_EEOP 0x07 /* 2.4 Gz EEPROM Opcode mask */ +#define MMC_EECTRL_EEOP_READ 0x06 /* 2.4 Gz EEPROM Read Opcode */ +#define MMC_EEADDR_CHAN 0xf0 /* 2.4 Gz EEPROM Channel # mask */ +#define MMC_EEADDR_WDCNT 0x0f /* 2.4 Gz EEPROM DNLD WordCount-1 */ +#define MMC_ANALCTRL_ANTPOL 0x02 /* 2.4 Gz Antenna Polarity mask */ +#define MMC_ANALCTRL_EXTANT 0x01 /* 2.4 Gz External Antenna mask */ + +/* MMC read register names */ +#define MMC_DCE_STATUS 0x10 +#define MMC_CORRECT_NWID_L 0x14 +#define MMC_CORRECT_NWID_H 0x15 +#define MMC_WRONG_NWID_L 0x16 +#define MMC_WRONG_NWID_H 0x17 +#define MMC_THR_PRE_SET 0x18 +#define MMC_SIGNAL_LVL 0x19 +#define MMC_SILENCE_LVL 0x1a +#define MMC_SIGN_QUAL 0x1b +#define MMC_DES_AVAIL 0x09 +#define MMC_EECTRLstat 0x20 /* 2.4 Gz EEPROM r/w/dwld status */ +#define MMC_EEDATALrv 0x22 /* 2.4 Gz EEPROM read value */ +#define MMC_EEDATAHrv 0x23 /* 2.4 Gz EEPROM read value */ + +/* fields in MMC registers that relate to EEPROM in WaveMODEM daughtercard */ +#define MMC_EECTRLstat_ID24 0xf0 /* 2.4 Gz =A0 rev-A, =B0 rev-B */ +#define MMC_EECTRLstat_DWLD 0x08 /* 2.4 Gz Synth/Tx-Pwr DWLD busy */ +#define MMC_EECTRLstat_EEBUSY 0x04 /* 2.4 Gz EEPROM busy */ + +/* additional socket ioctl params for wl card + * see sys/sockio.h for numbers. The 2nd params here + * must be greater than any values in sockio.h + */ + +#define SIOCGWLCNWID _IOWR('i', 60, struct ifreq) /* get wlan current nwid */ +#define SIOCSWLCNWID _IOWR('i', 61, struct ifreq) /* set wlan current nwid */ +#define SIOCGWLPSA _IOWR('i', 62, struct ifreq) /* get wlan PSA (all) */ +#define SIOCSWLPSA _IOWR('i', 63, struct ifreq) /* set wlan PSA (all) */ +#define SIOCDWLCACHE _IOW('i', 64, struct ifreq) /* clear SNR cache */ +#define SIOCSWLTHR _IOW('i', 65, struct ifreq) /* set new quality threshold */ +#define SIOCGWLEEPROM _IOWR('i', 66, struct ifreq) /* get modem EEPROM */ +#define SIOCGWLCACHE _IOWR('i', 67, struct ifreq) /* get SNR cache */ +#define SIOCGWLCITEM _IOWR('i', 68, struct ifreq) /* get cache element count */ + +/* PSA address definitions */ +#define WLPSA_ID 0x0 /* ID byte (0 for ISA, 0x14 for MCA) */ +#define WLPSA_IO1 0x1 /* I/O address 1 */ +#define WLPSA_IO2 0x2 /* I/O address 2 */ +#define WLPSA_IO3 0x3 /* I/O address 3 */ +#define WLPSA_BR1 0x4 /* Bootrom address 1 */ +#define WLPSA_BR2 0x5 /* Bootrom address 2 */ +#define WLPSA_BR3 0x6 /* Bootrom address 3 */ +#define WLPSA_HWCONF 0x7 /* HW config bits */ +#define WLPSA_IRQNO 0x8 /* IRQ value */ +#define WLPSA_UNIMAC 0x10 /* Universal MAC address */ +#define WLPSA_LOCALMAC 0x16 /* Locally configured MAC address */ +#define WLPSA_MACSEL 0x1c /* MAC selector */ +#define WLPSA_COMPATNO 0x1d /* compatability number */ +#define WLPSA_THRESH 0x1e /* RF modem threshold preset */ +#define WLPSA_FEATSEL 0x1f /* feature select */ +#define WLPSA_SUBBAND 0x20 /* subband selector */ +#define WLPSA_QUALTHRESH 0x21 /* RF modem quality threshold preset */ +#define WLPSA_HWVERSION 0x22 /* hardware version indicator */ +#define WLPSA_NWID 0x23 /* network ID */ +#define WLPSA_NWIDENABLE 0x24 /* network ID enable */ +#define WLPSA_SECURITY 0x25 /* datalink security enable */ +#define WLPSA_DESKEY 0x26 /* datalink security DES key */ +#define WLPSA_DBWIDTH 0x2f /* databus width select */ +#define WLPSA_CALLCODE 0x30 /* call code (japan only) */ +#define WLPSA_CONFIGURED 0x3c /* configuration status */ +#define WLPSA_CRCLOW 0x3d /* CRC-16 (lowbyte) */ +#define WLPSA_CRCHIGH 0x3e /* (highbyte) */ +#define WLPSA_CRCOK 0x3f /* CRC OK flag */ + +#define WLPSA_COMPATNO_WL24B 0x04 /* 2.4 Gz WaveMODEM ISA rev-B */ + +/* + * signal strength cache + * + * driver (wlp only at the moment) keeps cache of last + * IP (only) packets to arrive including signal strength info. + * daemons may read this with kvm. See if_wlp.c for globals + * that may be accessed through kvm. + * + * Each entry in the w_sigcache has a unique macsrc and age. + * Each entry is identified by its macsrc field. + * Age of the packet is identified by its age field. + */ + +#define MAXCACHEITEMS 10 +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif +#define MAX_AGE (INT_MAX - MAXCACHEITEMS) + +/* signal is 7 bits, 0..63, although it doesn't seem to get to 63. + * silence is 7 bits, 0..63 + * quality is 4 bits, 0..15 + */ +struct w_sigcache { + char macsrc[6]; /* unique MAC address for entry */ + int ipsrc; /* ip address associated with packet */ + int signal; /* signal strength of the packet */ + int silence; /* silence of the packet */ + int quality; /* quality of the packet */ + int snr; /* packet has unique age between 1 to MAX_AGE - 1 */ +}; + +#endif /* _CHIPS_WAVELAN_H */ + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/iic.h ./modules/label/machine/iic.h --- ../sys-altq/modules/label/machine/iic.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/iic.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/iic.h,v 1.2.2.1 1999/08/29 16:06:34 peter Exp $ + * + */ +#ifndef __IIC_H +#define __IIC_H + +#include + +struct iiccmd { + u_char slave; + int count; + int last; + char *buf; +}; + +#define I2CSTART _IOW('i', 1, struct iiccmd) /* start condition */ +#define I2CSTOP _IO('i', 2) /* stop condition */ +#define I2CRSTCARD _IOW('i', 3, struct iiccmd) /* reset the card */ +#define I2CWRITE _IOW('i', 4, struct iiccmd) /* send data */ +#define I2CREAD _IOW('i', 5, struct iiccmd) /* receive data */ + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/in_cksum.h ./modules/label/machine/in_cksum.h --- ../sys-altq/modules/label/machine/in_cksum.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/in_cksum.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * $FreeBSD: src/sys/i386/include/in_cksum.h,v 1.5.2.1 1999/08/29 16:06:34 peter Exp $ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __GNUC__ +static __inline u_int +in_cksum_hdr(const struct ip *ip) +{ + register u_int sum = 0; + +#define ADD(n) __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip)) +#define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip)) +#define MOP __asm("adcl $0, %0" : "=r" (sum) : "0" (sum)) + + ADD(0); + ADDC(4); + ADDC(8); + ADDC(12); + ADDC(16); + MOP; +#undef ADD +#undef ADDC +#undef MOP + sum = (sum & 0xffff) + (sum >> 16); + if (sum > 0xffff) + sum -= 0xffff; + + return ~sum & 0xffff; +} + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else +u_int in_cksum_hdr __P((const struct ip *)); +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +typedef unsigned in_psum_t; +#ifdef KERNEL +in_psum_t in_cksum_partial(in_psum_t psum, const u_short *w, int len); +int in_cksum_finalize(in_psum_t psum); +#endif /* KERNEL */ + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ioctl_bt848.h ./modules/label/machine/ioctl_bt848.h --- ../sys-altq/modules/label/machine/ioctl_bt848.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ioctl_bt848.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,281 @@ +/* + * extensions to ioctl_meteor.h for the bt848 cards + * + * $FreeBSD: src/sys/i386/include/ioctl_bt848.h,v 1.19.2.4 1999/09/08 08:43:08 roger Exp $ + */ + +/* + * frequency sets + */ +#define CHNLSET_NABCST 1 +#define CHNLSET_CABLEIRC 2 +#define CHNLSET_CABLEHRC 3 +#define CHNLSET_WEUROPE 4 +#define CHNLSET_JPNBCST 5 +#define CHNLSET_JPNCABLE 6 +#define CHNLSET_XUSSR 7 +#define CHNLSET_AUSTRALIA 8 +#define CHNLSET_MIN CHNLSET_NABCST +#define CHNLSET_MAX CHNLSET_AUSTRALIA + + +/* + * constants for various tuner registers + */ +#define BT848_HUEMIN (-90) +#define BT848_HUEMAX 90 +#define BT848_HUECENTER 0 +#define BT848_HUERANGE 179.3 +#define BT848_HUEREGMIN (-128) +#define BT848_HUEREGMAX 127 +#define BT848_HUESTEPS 256 + +#define BT848_BRIGHTMIN (-50) +#define BT848_BRIGHTMAX 50 +#define BT848_BRIGHTCENTER 0 +#define BT848_BRIGHTRANGE 99.6 +#define BT848_BRIGHTREGMIN (-128) +#define BT848_BRIGHTREGMAX 127 +#define BT848_BRIGHTSTEPS 256 + +#define BT848_CONTRASTMIN 0 +#define BT848_CONTRASTMAX 237 +#define BT848_CONTRASTCENTER 100 +#define BT848_CONTRASTRANGE 236.57 +#define BT848_CONTRASTREGMIN 0 +#define BT848_CONTRASTREGMAX 511 +#define BT848_CONTRASTSTEPS 512 + +#define BT848_CHROMAMIN 0 +#define BT848_CHROMAMAX 284 +#define BT848_CHROMACENTER 100 +#define BT848_CHROMARANGE 283.89 +#define BT848_CHROMAREGMIN 0 +#define BT848_CHROMAREGMAX 511 +#define BT848_CHROMASTEPS 512 + +#define BT848_SATUMIN 0 +#define BT848_SATUMAX 202 +#define BT848_SATUCENTER 100 +#define BT848_SATURANGE 201.18 +#define BT848_SATUREGMIN 0 +#define BT848_SATUREGMAX 511 +#define BT848_SATUSTEPS 512 + +#define BT848_SATVMIN 0 +#define BT848_SATVMAX 284 +#define BT848_SATVCENTER 100 +#define BT848_SATVRANGE 283.89 +#define BT848_SATVREGMIN 0 +#define BT848_SATVREGMAX 511 +#define BT848_SATVSTEPS 512 + + +/* + * audio stuff + */ +#define AUDIO_TUNER 0x00 /* command for the audio routine */ +#define AUDIO_EXTERN 0x01 /* don't confuse them with bit */ +#define AUDIO_INTERN 0x02 /* settings */ +#define AUDIO_MUTE 0x80 +#define AUDIO_UNMUTE 0x81 + + +/* + * EEProm stuff + */ +struct eeProm { + short offset; + short count; + u_char bytes[ 256 ]; +}; + + +/* + * XXX: this is a hack, should be in ioctl_meteor.h + * here to avoid touching that file for now... + */ +#define TVTUNER_SETCHNL _IOW('x', 32, unsigned int) /* set channel */ +#define TVTUNER_GETCHNL _IOR('x', 32, unsigned int) /* get channel */ +#define TVTUNER_SETTYPE _IOW('x', 33, unsigned int) /* set tuner type */ +#define TVTUNER_GETTYPE _IOR('x', 33, unsigned int) /* get tuner type */ +#define TVTUNER_GETSTATUS _IOR('x', 34, unsigned int) /* get tuner status */ +#define TVTUNER_SETFREQ _IOW('x', 35, unsigned int) /* set frequency */ +#define TVTUNER_GETFREQ _IOR('x', 36, unsigned int) /* get frequency */ + + +#define BT848_SHUE _IOW('x', 37, int) /* set hue */ +#define BT848_GHUE _IOR('x', 37, int) /* get hue */ +#define BT848_SBRIG _IOW('x', 38, int) /* set brightness */ +#define BT848_GBRIG _IOR('x', 38, int) /* get brightness */ +#define BT848_SCSAT _IOW('x', 39, int) /* set chroma sat */ +#define BT848_GCSAT _IOR('x', 39, int) /* get UV saturation */ +#define BT848_SCONT _IOW('x', 40, int) /* set contrast */ +#define BT848_GCONT _IOR('x', 40, int) /* get contrast */ +#define BT848_SVSAT _IOW('x', 41, int) /* set chroma V sat */ +#define BT848_GVSAT _IOR('x', 41, int) /* get V saturation */ +#define BT848_SUSAT _IOW('x', 42, int) /* set chroma U sat */ +#define BT848_GUSAT _IOR('x', 42, int) /* get U saturation */ + +#define BT848_SCBARS _IOR('x', 43, int) /* set colorbar */ +#define BT848_CCBARS _IOR('x', 44, int) /* clear colorbar */ + + +#define BT848_SAUDIO _IOW('x', 46, int) /* set audio channel */ +#define BT848_GAUDIO _IOR('x', 47, int) /* get audio channel */ +#define BT848_SBTSC _IOW('x', 48, int) /* set audio channel */ + +#define BT848_GSTATUS _IOR('x', 49, unsigned int) /* reap status */ + +#define BT848_WEEPROM _IOWR('x', 50, struct eeProm) /* write to EEProm */ +#define BT848_REEPROM _IOWR('x', 51, struct eeProm) /* read from EEProm */ + +#define BT848_SIGNATURE _IOWR('x', 52, struct eeProm) /* read card sig */ + +#define TVTUNER_SETAFC _IOW('x', 53, int) /* turn AFC on/off */ +#define TVTUNER_GETAFC _IOR('x', 54, int) /* query AFC on/off */ +#define BT848_SLNOTCH _IOW('x', 55, int) /* set luma notch */ +#define BT848_GLNOTCH _IOR('x', 56, int) /* get luma notch */ + +/* Read/Write the BT848's I2C bus directly + * b7-b0: data (read/write) + * b15-b8: internal peripheral register (write) + * b23-b16: i2c addr (write) + * b31-b24: 1 = write, 0 = read + */ +#define BT848_I2CWR _IOWR('x', 57, u_long) /* i2c read-write */ + +/* Support for radio tuner */ +#define RADIO_SETMODE _IOW('x', 58, unsigned int) /* set radio modes */ +#define RADIO_GETMODE _IOR('x', 58, unsigned char) /* get radio modes */ +#define RADIO_AFC 0x01 /* These modes will probably not */ +#define RADIO_MONO 0x02 /* work on the FRxxxx. It does */ +#define RADIO_MUTE 0x08 /* work on the FMxxxx. */ +#define RADIO_SETFREQ _IOW('x', 59, unsigned int) /* set frequency */ +#define RADIO_GETFREQ _IOR('x', 59, unsigned int) /* set frequency */ + /* Argument is frequency*100MHz */ + +/* + * XXX: more bad magic, + * we need to fix the METEORGINPUT to return something public + * duplicate them here for now... + */ +#define METEOR_DEV0 0x00001000 +#define METEOR_DEV1 0x00002000 +#define METEOR_DEV2 0x00004000 +#define METEOR_DEV3 0x00008000 +#define METEOR_DEV_SVIDEO 0x00006000 +/* + * right now I don't know were to put these, but as they are suppose to be + * a part of a common video capture interface, these should be relocated to + * another place. Probably most of the METEOR_xxx defines need to be + * renamed and moved to a common header + */ + +typedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV, + METEOR_PIXTYPE_YUV_PACKED, + METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE; + + +struct meteor_pixfmt { + u_int index; /* Index in supported pixfmt list */ + METEOR_PIXTYPE type; /* What's the board gonna feed us */ + u_int Bpp; /* Bytes per pixel */ + u_long masks[3]; /* R,G,B or Y,U,V masks, respectively */ + unsigned swap_bytes :1; /* Bytes swapped within shorts */ + unsigned swap_shorts:1; /* Shorts swapped within longs */ +}; + + +struct bktr_clip { + int x_min; + int x_max; + int y_min; + int y_max; +}; + +#define BT848_MAX_CLIP_NODE 100 +struct _bktr_clip { + struct bktr_clip x[BT848_MAX_CLIP_NODE]; +}; + +/* + * I'm using METEOR_xxx just because that will be common to other interface + * and less of a surprise + */ +#define METEORSACTPIXFMT _IOW('x', 64, int ) +#define METEORGACTPIXFMT _IOR('x', 64, int ) +#define METEORGSUPPIXFMT _IOWR('x', 65, struct meteor_pixfmt) + +/* set clip list */ +#define BT848SCLIP _IOW('x', 66, struct _bktr_clip ) +#define BT848GCLIP _IOR('x', 66, struct _bktr_clip ) + + +/* set input format */ +#define BT848SFMT _IOW('x', 67, unsigned long ) +#define BT848GFMT _IOR('x', 67, unsigned long ) + +/* set clear-buffer-on-start */ +#define BT848SCBUF _IOW('x', 68, int) +#define BT848GCBUF _IOR('x', 68, int) + +/* set capture area */ +/* The capture area is the area of the video image which is grabbed */ +/* Usually the capture area is 640x480 (768x576 PAL) pixels */ +/* This area is then scaled to the dimensions the user requires */ +/* using the METEORGEO ioctl */ +/* However, the capture area could be 400x300 pixels from the top right */ +/* corner of the video image */ +struct bktr_capture_area { + int x_offset; + int y_offset; + int x_size; + int y_size; +}; +#define BT848_SCAPAREA _IOW('x', 69, struct bktr_capture_area) +#define BT848_GCAPAREA _IOR('x', 69, struct bktr_capture_area) + + +/* Get channel Set */ +#define BT848_MAX_CHNLSET_NAME_LEN 16 +struct bktr_chnlset { + short index; + short max_channel; + char name[BT848_MAX_CHNLSET_NAME_LEN]; +}; +#define TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset) + + + +/* Infra Red Remote Control */ +struct bktr_remote { + unsigned char data[3]; +}; +#define REMOTE_GETKEY _IOR('x', 71, struct bktr_remote)/*read the remote */ + /*control receiver*/ + /*returns raw data*/ + + +/* + * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel + * configuration file to use these + */ +#define BT848_GPIO_SET_EN _IOW('x', 72, int) /* set gpio_out_en */ +#define BT848_GPIO_GET_EN _IOR('x', 73, int) /* get gpio_out_en */ +#define BT848_GPIO_SET_DATA _IOW('x', 74, int) /* set gpio_data */ +#define BT848_GPIO_GET_DATA _IOR('x', 75, int) /* get gpio_data */ + + + +/* XXX - Copied from /sys/pci/brktree_reg.h */ +#define BT848_IFORM_FORMAT (0x7<<0) +# define BT848_IFORM_F_RSVD (0x7) +# define BT848_IFORM_F_SECAM (0x6) +# define BT848_IFORM_F_PALN (0x5) +# define BT848_IFORM_F_PALM (0x4) +# define BT848_IFORM_F_PALBDGHI (0x3) +# define BT848_IFORM_F_NTSCJ (0x2) +# define BT848_IFORM_F_NTSCM (0x1) +# define BT848_IFORM_F_AUTO (0x0) + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ioctl_ctx.h ./modules/label/machine/ioctl_ctx.h --- ../sys-altq/modules/label/machine/ioctl_ctx.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ioctl_ctx.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,31 @@ +/* + * + * Copyright (C) 1994, Paul S. LaFollette, Jr. This software may be used, + * modified, copied, distributed, and sold, in both source and binary form + * provided that the above copyright and these terms are retained. Under + * no circumstances is the author responsible for the proper functioning + * of this software, nor does the author assume any responsibility + * for damages incurred with its use + * + * $FreeBSD: src/sys/i386/include/ioctl_ctx.h,v 1.5.4.1 1999/08/29 16:06:35 peter Exp $ + */ + +/* + * ioctl constants for Cortex-I frame grabber + */ + +#ifndef _MACHINE_IOCTL_CTX_H_ +#define _MACHINE_IOCTL_CTX_H_ + +#include + +typedef char _CTX_LUTBUF[256]; /* look up table buffer */ + +#define CTX_LIVE _IO('x', 1) /* live video */ +#define CTX_GRAB _IO('x', 2) /* frame grab */ +#define CTX_H_ORGANIZE _IO('x', 3) /* file goes across screen (horiz. read) */ +#define CTX_V_ORGANIZE _IO('x', 4) /* file goes down screen (vert. read) */ +#define CTX_SET_LUT _IOW('x', 5, _CTX_LUTBUF) /* set lookup table */ +#define CTX_GET_LUT _IOR('x', 6, _CTX_LUTBUF) /* get lookup table */ + +#endif /* !_MACHINE_IOCTL_CTX_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ioctl_fd.h ./modules/label/machine/ioctl_fd.h --- ../sys-altq/modules/label/machine/ioctl_fd.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ioctl_fd.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,125 @@ +/* + * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * $FreeBSD: src/sys/i386/include/ioctl_fd.h,v 1.11.4.1 1999/08/29 16:06:35 peter Exp $ + */ + +#ifndef _MACHINE_IOCTL_FD_H_ +#define _MACHINE_IOCTL_FD_H_ + +#ifndef KERNEL +#include +#endif +#include + +#define FD_FORMAT_VERSION 110 /* used to validate before formatting */ +#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */ + /* 2.88 MB drives */ + +struct fd_formb { + int format_version; /* == FD_FORMAT_VERSION */ + int cyl, head; + int transfer_rate; /* fdreg.h: FDC_???KBPS */ + + union { + struct fd_form_data { + /* + * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS + * it is hardware-dependent since it exactly + * matches the byte sequence to write to FDC + * during its `format track' operation + */ + u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */ + u_char nsecs; /* must be <= FD_MAX_NSEC */ + u_char gaplen; /* GAP 3 length; usually 84 */ + u_char fillbyte; /* usually 0xf6 */ + struct fd_idfield_data { + /* + * data to write into id fields; + * for obscure formats, they mustn't match + * the real values (but mostly do) + */ + u_char cylno; /* 0 thru 79 (or 39) */ + u_char headno; /* 0, or 1 */ + u_char secno; /* starting at 1! */ + u_char secsize; /* usually 2 */ + } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ + } structured; + u_char raw[1]; /* to have continuous indexed access */ + } format_info; +}; + +/* make life easier */ +# define fd_formb_secshift format_info.structured.secshift +# define fd_formb_nsecs format_info.structured.nsecs +# define fd_formb_gaplen format_info.structured.gaplen +# define fd_formb_fillbyte format_info.structured.fillbyte +/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ +# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno +# define fd_formb_headno(i) format_info.structured.idfields[i].headno +# define fd_formb_secno(i) format_info.structured.idfields[i].secno +# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize + +struct fd_type { + int sectrac; /* sectors per track */ + int secsize; /* size code for sectors */ + int datalen; /* data len when secsize = 0 */ + int gap; /* gap len between sectors */ + int tracks; /* total num of tracks */ + int size; /* size of disk in sectors */ + int steptrac; /* steps per cylinder */ + int trans; /* transfer speed code */ + int heads; /* number of heads */ + int f_gap; /* format gap len */ + int f_inter; /* format interleave factor */ +}; + +#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */ +#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */ +#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */ + +#define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */ +#define FD_SOPTS _IOW('F', 65, int) + +#define FD_DEBUG _IOW('F', 66, int) + +#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */ + +/* + * The following definitions duplicate those in sys/i386/isa/fdreg.h + * They are here since their values are to be used in the above + * structure when formatting a floppy. For very obvious reasons, both + * definitions must match ;-) + */ +#ifndef FDC_500KBPS +#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ +#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ +#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ +#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ + /* for some controllers 1MPBS instead */ +#endif /* FDC_500KBPS */ + +#endif /* !_MACHINE_IOCTL_FD_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ioctl_meteor.h ./modules/label/machine/ioctl_meteor.h --- ../sys-altq/modules/label/machine/ioctl_meteor.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ioctl_meteor.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1995 Mark Tinguely and Jim Lowe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Mark Tinguely and Jim Lowe + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/* + * ioctl constants for Matrox Meteor Capture card. + */ + +#ifndef _MACHINE_IOCTL_METEOR_H_ +#define _MACHINE_IOCTL_METEOR_H_ + +#ifndef KERNEL +#include +#endif +#include + +struct meteor_capframe { + short command; /* see below for valid METEORCAPFRM commands */ + short lowat; /* start transfer if < this number */ + short hiwat; /* stop transfer if > this number */ +} ; + +/* structure for METEOR[GS]ETGEO - get/set geometry */ +struct meteor_geomet { + u_short rows; + u_short columns; + u_short frames; + u_long oformat; +} ; + +/* structure for METEORGCOUNT-get count of frames, fifo errors and dma errors */ +struct meteor_counts { + u_long fifo_errors; /* count of fifo errors since open */ + u_long dma_errors; /* count of dma errors since open */ + u_long frames_captured; /* count of frames captured since open */ + u_long even_fields_captured; /* count of even fields captured */ + u_long odd_fields_captured; /* count of odd fields captured */ +} ; + +/* structure for getting and setting direct transfers to vram */ +struct meteor_video { + u_long addr; /* Address of location to dma to */ + u_long width; /* Width of memory area */ + u_long banksize; /* Size of Vram bank */ + u_long ramsize; /* Size of Vram */ +}; + +#define METEORCAPTUR _IOW('x', 1, int) /* capture a frame */ +#define METEORCAPFRM _IOW('x', 2, struct meteor_capframe) /* sync capture */ +#define METEORSETGEO _IOW('x', 3, struct meteor_geomet) /* set geometry */ +#define METEORGETGEO _IOR('x', 4, struct meteor_geomet) /* get geometry */ +#define METEORSTATUS _IOR('x', 5, unsigned short) /* get status */ +#define METEORSHUE _IOW('x', 6, signed char) /* set hue */ +#define METEORGHUE _IOR('x', 6, signed char) /* get hue */ +#define METEORSFMT _IOW('x', 7, unsigned long) /* set format */ +#define METEORGFMT _IOR('x', 7, unsigned long) /* get format */ +#define METEORSINPUT _IOW('x', 8, unsigned long) /* set input dev */ +#define METEORGINPUT _IOR('x', 8, unsigned long) /* get input dev */ +#define METEORSCHCV _IOW('x', 9, unsigned char) /* set uv gain */ +#define METEORGCHCV _IOR('x', 9, unsigned char) /* get uv gain */ +#define METEORSCOUNT _IOW('x',10, struct meteor_counts) +#define METEORGCOUNT _IOR('x',10, struct meteor_counts) +#define METEORSFPS _IOW('x',11, unsigned short) /* set fps */ +#define METEORGFPS _IOR('x',11, unsigned short) /* get fps */ +#define METEORSSIGNAL _IOW('x', 12, unsigned int) /* set signal */ +#define METEORGSIGNAL _IOR('x', 12, unsigned int) /* get signal */ +#define METEORSVIDEO _IOW('x', 13, struct meteor_video) /* set video */ +#define METEORGVIDEO _IOR('x', 13, struct meteor_video) /* get video */ +#define METEORSBRIG _IOW('x', 14, unsigned char) /* set brightness */ +#define METEORGBRIG _IOR('x', 14, unsigned char) /* get brightness */ +#define METEORSCSAT _IOW('x', 15, unsigned char) /* set chroma sat */ +#define METEORGCSAT _IOR('x', 15, unsigned char) /* get uv saturation */ +#define METEORSCONT _IOW('x', 16, unsigned char) /* set contrast */ +#define METEORGCONT _IOR('x', 16, unsigned char) /* get contrast */ +#define METEORSBT254 _IOW('x', 17, unsigned short) /* set Bt254 reg */ +#define METEORGBT254 _IOR('x', 17, unsigned short) /* get Bt254 reg */ +#define METEORSHWS _IOW('x', 18, unsigned char) /* set hor start reg */ +#define METEORGHWS _IOR('x', 18, unsigned char) /* get hor start reg */ +#define METEORSVWS _IOW('x', 19, unsigned char) /* set vert start reg */ +#define METEORGVWS _IOR('x', 19, unsigned char) /* get vert start reg */ +#define METEORSTS _IOW('x', 20, unsigned char) /* set time stamp */ +#define METEORGTS _IOR('x', 20, unsigned char) /* get time stamp */ + +#define METEOR_STATUS_ID_MASK 0xf000 /* ID of 7196 */ +#define METEOR_STATUS_DIR 0x0800 /* Direction of Expansion port YUV */ +#define METEOR_STATUS_OEF 0x0200 /* Field detected: Even/Odd */ +#define METEOR_STATUS_SVP 0x0100 /* State of VRAM Port:inactive/active */ +#define METEOR_STATUS_STTC 0x0080 /* Time Constant: TV/VCR */ +#define METEOR_STATUS_HCLK 0x0040 /* Horiz PLL: locked/unlocked */ +#define METEOR_STATUS_FIDT 0x0020 /* Field detect: 50/60hz */ +#define METEOR_STATUS_ALTD 0x0002 /* Line alt: no line alt/line alt */ +#define METEOR_STATUS_CODE 0x0001 /* Colour info: no colour/colour */ + + /* METEORCAPTUR capture options */ +#define METEOR_CAP_SINGLE 0x0001 /* capture one frame */ +#define METEOR_CAP_CONTINOUS 0x0002 /* continuously capture */ +#define METEOR_CAP_STOP_CONT 0x0004 /* stop the continuous capture */ + + /* METEORCAPFRM capture commands */ +#define METEOR_CAP_N_FRAMES 0x0001 /* capture N frames */ +#define METEOR_CAP_STOP_FRAMES 0x0002 /* stop capture N frames */ +#define METEOR_HALT_N_FRAMES 0x0003 /* halt of capture N frames */ +#define METEOR_CONT_N_FRAMES 0x0004 /* continue after above halt */ + + /* valid video input formats: */ +#define METEOR_FMT_NTSC 0x00100 /* NTSC -- initialized default */ +#define METEOR_FMT_PAL 0x00200 /* PAL */ +#define METEOR_FMT_SECAM 0x00400 /* SECAM */ +#define METEOR_FMT_AUTOMODE 0x00800 /* auto-mode */ +#define METEOR_INPUT_DEV0 0x01000 /* camera input 0 -- default */ +#define METEOR_INPUT_DEV_RCA METEOR_INPUT_DEV0 +#define METEOR_INPUT_DEV1 0x02000 /* camera input 1 */ +#define METEOR_INPUT_DEV2 0x04000 /* camera input 2 */ +#define METEOR_INPUT_DEV3 0x08000 /* camera input 3 */ +#define METEOR_INPUT_DEV_RGB 0x0a000 /* for rgb version of meteor */ +#define METEOR_INPUT_DEV_SVIDEO 0x06000 /* S-video input port */ + + /* valid video output formats: */ +#define METEOR_GEO_RGB16 0x0010000 /* packed -- initialized default */ +#define METEOR_GEO_RGB24 0x0020000 /* RBG 24 bits packed */ + /* internally stored in 32 bits */ +#define METEOR_GEO_YUV_PACKED 0x0040000 /* 4-2-2 YUV 16 bits packed */ +#define METEOR_GEO_YUV_PLANAR 0x0080000 /* 4-2-2 YUV 16 bits planer */ +#define METEOR_GEO_YUV_PLANER METEOR_GEO_YUV_PLANAR +#define METEOR_GEO_UNSIGNED 0x0400000 /* unsigned uv outputs */ +#define METEOR_GEO_EVEN_ONLY 0x1000000 /* set for even only field capture */ +#define METEOR_GEO_ODD_ONLY 0x2000000 /* set for odd only field capture */ +#define METEOR_GEO_FIELD_MASK 0x3000000 +#define METEOR_GEO_YUV_422 0x4000000 /* 4-2-2 YUV in Y-U-V combined */ +#define METEOR_GEO_OUTPUT_MASK 0x40f0000 +#define METEOR_GEO_YUV_12 0x10000000 /* YUV 12 format */ +#define METEOR_GEO_YUV_9 0x40000000 /* YUV 9 format */ + +#define METEOR_FIELD_MODE 0x80000000 /* Field cap or Frame cap */ + +#define METEOR_SIG_MODE_MASK 0xffff0000 +#define METEOR_SIG_FRAME 0x00000000 /* signal every frame */ +#define METEOR_SIG_FIELD 0x00010000 /* signal every field */ + + /* following structure is used to coordinate the synchronous */ + +struct meteor_mem { + /* kernel write only */ + int frame_size; /* row*columns*depth */ + unsigned num_bufs; /* number of frames in buffer (1-32) */ + /* user and kernel change these */ + int lowat; /* kernel starts capture if < this number */ + int hiwat; /* kernel stops capture if > this number. + hiwat <= numbufs */ + unsigned active; /* bit mask of active frame buffers + kernel sets, user clears */ + int num_active_bufs; /* count of active frame buffer + kernel increments, user decrements */ + + /* reference to mmapped data */ + caddr_t buf; /* The real space (virtual addr) */ +} ; + +#endif /* !_MACHINE_IOCTL_METEOR_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ipl.h ./modules/label/machine/ipl.h --- ../sys-altq/modules/label/machine/ipl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ipl.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,115 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/ipl.h,v 1.15.2.1 1999/08/29 16:06:36 peter Exp $ + */ + +#ifndef _MACHINE_IPL_H_ +#define _MACHINE_IPL_H_ + +#ifdef APIC_IO +#include +#else +#include +#endif + +/* + * Software interrupt bit numbers in priority order. The priority only + * determines which swi will be dispatched next; a higher priority swi + * may be dispatched when a nested h/w interrupt handler returns. + */ +#define SWI_TTY (NHWI + 0) +#define SWI_NET (NHWI + 1) +#define SWI_CAMNET (NHWI + 2) +#define SWI_CAMBIO (NHWI + 3) +#define SWI_VM (NHWI + 4) +#define SWI_CLOCK 30 +#define SWI_AST 31 +#define NSWI (32 - NHWI) + +/* + * Corresponding interrupt-pending bits for ipending. + */ +#define SWI_TTY_PENDING (1 << SWI_TTY) +#define SWI_NET_PENDING (1 << SWI_NET) +#define SWI_CAMNET_PENDING (1 << SWI_CAMNET) +#define SWI_CAMBIO_PENDING (1 << SWI_CAMBIO) +#define SWI_VM_PENDING (1 << SWI_VM) +#define SWI_CLOCK_PENDING (1 << SWI_CLOCK) +#define SWI_AST_PENDING (1 << SWI_AST) + +/* + * Corresponding interrupt-disable masks for cpl. The ordering is now by + * inclusion (where each mask is considered as a set of bits). Everything + * except SWI_AST_MASK includes SWI_CLOCK_MASK so that softclock() doesn't + * run while other swi handlers are running and timeout routines can call + * swi handlers. Everything includes SWI_AST_MASK so that AST's are masked + * until just before return to user mode. SWI_TTY_MASK includes SWI_NET_MASK + * in case tty interrupts are processed at splsofttty() for a tty that is in + * SLIP or PPP line discipline (this is weaker than merging net_imask with + * tty_imask in isa.c - splimp() must mask hard and soft tty interrupts, but + * spltty() apparently only needs to mask soft net interrupts). + */ +#define SWI_TTY_MASK (SWI_TTY_PENDING | SWI_CLOCK_MASK | SWI_NET_MASK) +#define SWI_CAMNET_MASK (SWI_CAMNET_PENDING | SWI_CLOCK_MASK) +#define SWI_CAMBIO_MASK (SWI_CAMBIO_PENDING | SWI_CLOCK_MASK) +#define SWI_NET_MASK (SWI_NET_PENDING | SWI_CLOCK_MASK) +#define SWI_VM_MASK (SWI_VM_PENDING | SWI_CLOCK_MASK) +#define SWI_CLOCK_MASK (SWI_CLOCK_PENDING | SWI_AST_MASK) +#define SWI_AST_MASK SWI_AST_PENDING +#define SWI_MASK (~HWI_MASK) + +#ifndef LOCORE + +/* + * cpl is preserved by interrupt handlers so it is effectively nonvolatile. + * ipending and idelayed are changed by interrupt handlers so they are + * volatile. + */ +#ifdef notyet /* in until pci drivers stop hacking on them */ +extern unsigned bio_imask; /* group of interrupts masked with splbio() */ +#endif +extern unsigned cpl; /* current priority level mask */ +#ifdef SMP +extern unsigned cil; /* current INTerrupt level mask */ +#endif +extern volatile unsigned idelayed; /* interrupts to become pending */ +extern volatile unsigned ipending; /* active interrupts masked by cpl */ +#ifdef notyet /* in until pci drivers stop hacking on them */ +extern unsigned net_imask; /* group of interrupts masked with splimp() */ +extern unsigned stat_imask; /* interrupts masked with splstatclock() */ +extern unsigned tty_imask; /* group of interrupts masked with spltty() */ +#endif + +#endif /* !LOCORE */ + +#endif /* !_MACHINE_IPL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/joystick.h ./modules/label/machine/joystick.h --- ../sys-altq/modules/label/machine/joystick.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/joystick.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,20 @@ +#ifndef _MACHINE_JOYSTICK_H_ +#define _MACHINE_JOYSTICK_H_ + +#include + +struct joystick { + int x; + int y; + int b1; + int b2; +}; + +#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */ +#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */ +#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */ +#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on X-axis */ +#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */ +#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */ + +#endif /* !_MACHINE_JOYSTICK_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/limits.h ./modules/label/machine/limits.h --- ../sys-altq/modules/label/machine/limits.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/limits.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 8.3 (Berkeley) 1/4/94 + * $FreeBSD: src/sys/i386/include/limits.h,v 1.11.4.1 1999/08/29 16:06:37 peter Exp $ + */ + +#ifndef _MACHINE_LIMITS_H_ +#define _MACHINE_LIMITS_H_ + +#define CHAR_BIT 8 /* number of bits in a char */ +#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ + +/* + * According to ANSI (section 2.2.4.2), the values below must be usable by + * #if preprocessing directives. Additionally, the expression must have the + * same type as would an expression that is an object of the corresponding + * type converted according to the integral promotions. The subtraction for + * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values + * are written as hex so that GCC will be quiet about large integer constants. + */ +#define SCHAR_MAX 127 /* min value for a signed char */ +#define SCHAR_MIN (-128) /* max value for a signed char */ + +#define UCHAR_MAX 255 /* max value for an unsigned char */ +#define CHAR_MAX 127 /* max value for a char */ +#define CHAR_MIN (-128) /* min value for a char */ + +#define USHRT_MAX 65535 /* max value for an unsigned short */ +#define SHRT_MAX 32767 /* max value for a short */ +#define SHRT_MIN (-32768) /* min value for a short */ + +#define UINT_MAX 0xffffffff /* max value for an unsigned int */ +#define INT_MAX 2147483647 /* max value for an int */ +#define INT_MIN (-2147483647-1) /* min value for an int */ + +#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ +#define LONG_MAX 2147483647 /* max value for a long */ +#define LONG_MIN (-2147483647-1) /* min value for a long */ + +#if !defined(_ANSI_SOURCE) +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ + +#if !defined(_POSIX_SOURCE) +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ + +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !_ANSI_SOURCE */ + +#endif /* !_MACHINE_LIMITS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/lock.h ./modules/label/machine/lock.h --- ../sys-altq/modules/label/machine/lock.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/lock.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,252 @@ +/* + * Copyright (c) 1997, by Steve Passe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the developer may NOT be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/lock.h,v 1.6.2.1 1999/08/29 16:06:38 peter Exp $ + */ + + +#ifndef _MACHINE_LOCK_H_ +#define _MACHINE_LOCK_H_ + + +#ifdef LOCORE + +#ifdef SMP + +#define MPLOCKED lock ; + +/* + * Some handy macros to allow logical organization and + * convenient reassignment of various locks. + */ + +#define FPU_LOCK call _get_fpu_lock +#define ALIGN_LOCK call _get_align_lock +#define SYSCALL_LOCK call _get_syscall_lock +#define ALTSYSCALL_LOCK call _get_altsyscall_lock + +/* + * Protects INTR() ISRs. + */ +#define ISR_TRYLOCK \ + pushl $_mp_lock ; /* GIANT_LOCK */ \ + call _MPtrylock ; /* try to get lock */ \ + add $4, %esp + +#define ISR_RELLOCK \ + pushl $_mp_lock ; /* GIANT_LOCK */ \ + call _MPrellock ; \ + add $4, %esp + +/* + * Protects the IO APIC and apic_imen as a critical region. + */ +#define IMASK_LOCK \ + pushl $_imen_lock ; /* address of lock */ \ + call _s_lock ; /* MP-safe */ \ + addl $4, %esp + +#define IMASK_UNLOCK \ + pushl $_imen_lock ; /* address of lock */ \ + call _s_unlock ; /* MP-safe */ \ + addl $4, %esp + +/* + * Variations of CPL_LOCK protect spl updates as a critical region. + * Items within this 'region' include: + * cpl + * cml + * cil + * ipending + */ + +/* + * Botom half routines, ie. those already protected from INTs. + * + * Used in: + * sys/i386/isa/ipl.s: _doreti + * sys/i386/isa/apic_vector.s: _Xintr0, ..., _Xintr23 + */ +#define CPL_LOCK \ + pushl $_cpl_lock ; /* address of lock */ \ + call _s_lock ; /* MP-safe */ \ + addl $4, %esp + +#define CPL_UNLOCK \ + pushl $_cpl_lock ; /* address of lock */ \ + call _s_unlock ; /* MP-safe */ \ + addl $4, %esp + +/* + * INT safe version for top half of kernel. + * + * Used in: + * sys/i386/i386/exception.s: _Xfpu, _Xalign, _Xsyscall, _Xint0x80_syscall + * sys/i386/isa/apic_ipl.s: splz() + */ +#define SCPL_LOCK \ + pushl $_cpl_lock ; \ + call _ss_lock ; \ + addl $4, %esp + +#define SCPL_UNLOCK \ + pushl $_cpl_lock ; \ + call _ss_unlock ; \ + addl $4, %esp + +#else /* SMP */ + +#define MPLOCKED /* NOP */ + +#define FPU_LOCK /* NOP */ +#define ALIGN_LOCK /* NOP */ +#define SYSCALL_LOCK /* NOP */ +#define ALTSYSCALL_LOCK /* NOP */ + +#endif /* SMP */ + +#else /* LOCORE */ + +#ifdef SMP + +#include /** xxx_LOCK */ + +/* + * Locks regions protected in UP kernel via cli/sti. + */ +#ifdef USE_MPINTRLOCK +#define MPINTR_LOCK() s_lock(&mpintr_lock) +#define MPINTR_UNLOCK() s_unlock(&mpintr_lock) +#else +#define MPINTR_LOCK() +#define MPINTR_UNLOCK() +#endif /* USE_MPINTRLOCK */ + +/* + * Protects cpl/cml/cil/ipending data as a critical region. + * + * Used in: + * sys/i386/isa/ipl_funcs.c: DO_SETBITS, softclockpending(), GENSPL, + * spl0(), splx(), splq() + */ +#define CPL_LOCK() s_lock(&cpl_lock) /* Bottom end */ +#define CPL_UNLOCK() s_unlock(&cpl_lock) +#define SCPL_LOCK() ss_lock(&cpl_lock) /* INT safe: top end */ +#define SCPL_UNLOCK() ss_unlock(&cpl_lock) + +/* + * sio/cy lock. + * XXX should rc (RISCom/8) use this? + */ +#ifdef USE_COMLOCK +#define COM_LOCK() s_lock(&com_lock) +#define COM_UNLOCK() s_unlock(&com_lock) +#define COM_DISABLE_INTR() \ + { __asm __volatile("cli" : : : "memory"); COM_LOCK(); } +#define COM_ENABLE_INTR() \ + { COM_UNLOCK(); __asm __volatile("sti"); } +#else +#define COM_LOCK() +#define COM_UNLOCK() +#define COM_DISABLE_INTR() disable_intr() +#define COM_ENABLE_INTR() enable_intr() +#endif /* USE_COMLOCK */ + +/* + * Clock hardware/struct lock. + * XXX pcaudio and friends still need this lock installed. + */ +#ifdef USE_CLOCKLOCK +#define CLOCK_LOCK() s_lock(&clock_lock) +#define CLOCK_UNLOCK() s_unlock(&clock_lock) +#define CLOCK_DISABLE_INTR() \ + { __asm __volatile("cli" : : : "memory"); CLOCK_LOCK(); } +#define CLOCK_ENABLE_INTR() \ + { CLOCK_UNLOCK(); __asm __volatile("sti"); } +#else +#define CLOCK_LOCK() +#define CLOCK_UNLOCK() +#define CLOCK_DISABLE_INTR() disable_intr() +#define CLOCK_ENABLE_INTR() enable_intr() +#endif /* USE_CLOCKLOCK */ + +#else /* SMP */ + +#define MPINTR_LOCK() +#define MPINTR_UNLOCK() + +#define CPL_LOCK() +#define CPL_UNLOCK() +#define SCPL_LOCK() +#define SCPL_UNLOCK() + +#define COM_LOCK() +#define COM_UNLOCK() +#define CLOCK_LOCK() +#define CLOCK_UNLOCK() + +#endif /* SMP */ + +/* + * Simple spin lock. + * It is an error to hold one of these locks while a process is sleeping. + */ +struct simplelock { + volatile int lock_data; +}; + +/* functions in simplelock.s */ +void s_lock_init __P((struct simplelock *)); +void s_lock __P((struct simplelock *)); +int s_lock_try __P((struct simplelock *)); +void s_unlock __P((struct simplelock *)); +void ss_lock __P((struct simplelock *)); +void ss_unlock __P((struct simplelock *)); +void s_lock_np __P((struct simplelock *)); +void s_unlock_np __P((struct simplelock *)); + +/* global data in mp_machdep.c */ +extern struct simplelock imen_lock; +extern struct simplelock cpl_lock; +extern struct simplelock fast_intr_lock; +extern struct simplelock intr_lock; +extern struct simplelock clock_lock; +extern struct simplelock com_lock; +extern struct simplelock mpintr_lock; +extern struct simplelock mcount_lock; + +#if !defined(SIMPLELOCK_DEBUG) && NCPUS > 1 +/* + * This set of defines turns on the real functions in i386/isa/apic_ipl.s. + */ +#define simple_lock_init(alp) s_lock_init(alp) +#define simple_lock(alp) s_lock(alp) +#define simple_lock_try(alp) s_lock_try(alp) +#define simple_unlock(alp) s_unlock(alp) + +#endif /* !SIMPLELOCK_DEBUG && NCPUS > 1 */ + +#endif /* LOCORE */ + +#endif /* !_MACHINE_LOCK_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/lpt.h ./modules/label/machine/lpt.h --- ../sys-altq/modules/label/machine/lpt.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/lpt.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,24 @@ +/* + * Copyright (C) 1994 Geoffrey M. Rehmet + * + * This program is free software; you may redistribute it and/or + * modify it, provided that it retain the above copyright notice + * and the following disclaimer. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Geoff Rehmet, Rhodes University, South Africa + * + * $FreeBSD: src/sys/i386/include/lpt.h,v 1.6.4.1 1999/08/29 16:06:38 peter Exp $ + */ + +#ifndef _MACHINE_LPT_H_ +#define _MACHINE_LPT_H_ + +#include + +#define LPT_IRQ _IOW('p', 1, long) /* set interrupt status */ + +#endif /* !_MACHINE_LPT_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/md_var.h ./modules/label/machine/md_var.h --- ../sys-altq/modules/label/machine/md_var.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/md_var.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 1995 Bruce D. Evans. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/md_var.h,v 1.28.2.1 1999/08/29 16:06:39 peter Exp $ + */ + +#ifndef _MACHINE_MD_VAR_H_ +#define _MACHINE_MD_VAR_H_ + +/* + * Miscellaneous machine-dependent declarations. + */ + +extern int Maxmem; +extern u_int atdevbase; /* offset in virtual memory of ISA io mem */ +extern void (*bcopy_vector) __P((const void *from, void *to, size_t len)); +extern int busdma_swi_pending; +extern int (*copyin_vector) __P((const void *udaddr, void *kaddr, + size_t len)); +extern int (*copyout_vector) __P((const void *kaddr, void *udaddr, + size_t len)); +extern u_int cpu_feature; +extern u_int cpu_high; +extern u_int cpu_id; +extern char cpu_vendor[]; +extern u_int cyrix_did; +extern char kstack[]; +#ifdef PC98 +extern int need_pre_dma_flush; +extern int need_post_dma_flush; +#endif +extern void (*netisrs[32]) __P((void)); +extern int nfs_diskless_valid; +extern void (*ovbcopy_vector) __P((const void *from, void *to, size_t len)); +extern char sigcode[]; +extern int szsigcode; + +typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss)); +struct proc; +struct reg; +struct fpreg; + +void bcopyb __P((const void *from, void *to, size_t len)); +void busdma_swi __P((void)); +void cpu_halt __P((void)); +void cpu_reset __P((void)); +void cpu_switch_load_fs __P((void)) __asm(__STRING(cpu_switch_load_fs)); +void cpu_switch_load_gs __P((void)) __asm(__STRING(cpu_switch_load_gs)); +void doreti_iret __P((void)) __asm(__STRING(doreti_iret)); +void doreti_iret_fault __P((void)) __asm(__STRING(doreti_iret_fault)); +void doreti_popl_ds __P((void)) __asm(__STRING(doreti_popl_ds)); +void doreti_popl_ds_fault __P((void)) __asm(__STRING(doreti_popl_ds_fault)); +void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es)); +void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault)); +int fill_fpregs __P((struct proc *, struct fpreg *)); +int fill_regs __P((struct proc *p, struct reg *regs)); +void fillw __P((int /*u_short*/ pat, void *base, size_t cnt)); +void i486_bzero __P((void *buf, size_t len)); +void i586_bcopy __P((const void *from, void *to, size_t len)); +void i586_bzero __P((void *buf, size_t len)); +int i586_copyin __P((const void *udaddr, void *kaddr, size_t len)); +int i586_copyout __P((const void *kaddr, void *udaddr, size_t len)); +void i686_pagezero __P((void *addr)); +int is_physical_memory __P((vm_offset_t addr)); +u_long kvtop __P((void *addr)); +void setidt __P((int idx, alias_for_inthand_t *func, int typ, int dpl, + int selec)); +void swi_vm __P((void)); +void userconfig __P((void)); +int vm_page_zero_idle __P((void)); + +#endif /* !_MACHINE_MD_VAR_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/mouse.h ./modules/label/machine/mouse.h --- ../sys-altq/modules/label/machine/mouse.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/mouse.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,295 @@ +/*- + * Copyright (c) 1992, 1993 Erik Forsberg. + * Copyright (c) 1996, 1997 Kazutaka YOKOTA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/mouse.h,v 1.11.2.2 1999/08/29 16:06:39 peter Exp $ + */ + +#ifndef _MACHINE_MOUSE_H_ +#define _MACHINE_MOUSE_H_ + +#include +#include + +/* ioctls */ +#define MOUSE_GETSTATUS _IOR('M', 0, mousestatus_t) +#define MOUSE_GETHWINFO _IOR('M', 1, mousehw_t) +#define MOUSE_GETMODE _IOR('M', 2, mousemode_t) +#define MOUSE_SETMODE _IOW('M', 3, mousemode_t) +#define MOUSE_GETLEVEL _IOR('M', 4, int) +#define MOUSE_SETLEVEL _IOW('M', 5, int) +#define MOUSE_GETVARS _IOR('M', 6, mousevar_t) +#define MOUSE_SETVARS _IOW('M', 7, mousevar_t) +#define MOUSE_READSTATE _IOWR('M', 8, mousedata_t) +#define MOUSE_READDATA _IOWR('M', 9, mousedata_t) + +#if notyet +#define MOUSE_SETRESOLUTION _IOW('M', 10, int) +#define MOUSE_SETSCALING _IOW('M', 11, int) +#define MOUSE_SETRATE _IOW('M', 12, int) +#define MOUSE_GETHWID _IOR('M', 13, int) +#endif + +/* mouse status block */ +typedef struct mousestatus { + int flags; /* state change flags */ + int button; /* button status */ + int obutton; /* previous button status */ + int dx; /* x movement */ + int dy; /* y movement */ + int dz; /* z movement */ +} mousestatus_t; + +/* button */ +#define MOUSE_BUTTON1DOWN 0x0001 /* left */ +#define MOUSE_BUTTON2DOWN 0x0002 /* middle */ +#define MOUSE_BUTTON3DOWN 0x0004 /* right */ +#define MOUSE_BUTTON4DOWN 0x0008 +#define MOUSE_BUTTON5DOWN 0x0010 +#define MOUSE_BUTTON6DOWN 0x0020 +#define MOUSE_BUTTON7DOWN 0x0040 +#define MOUSE_BUTTON8DOWN 0x0080 +#define MOUSE_MAXBUTTON 31 +#define MOUSE_STDBUTTONS 0x0007 /* buttons 1-3 */ +#define MOUSE_EXTBUTTONS 0x7ffffff8 /* the others (28 of them!) */ +#define MOUSE_BUTTONS (MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS) + +/* flags */ +#define MOUSE_STDBUTTONSCHANGED MOUSE_STDBUTTONS +#define MOUSE_EXTBUTTONSCHANGED MOUSE_EXTBUTTONS +#define MOUSE_BUTTONSCHANGED MOUSE_BUTTONS +#define MOUSE_POSCHANGED 0x80000000 + +typedef struct mousehw { + int buttons; /* -1 if unknown */ + int iftype; /* MOUSE_IF_XXX */ + int type; /* mouse/track ball/pad... */ + int model; /* I/F dependent model ID: MOUSE_MODEL_XXX */ + int hwid; /* I/F dependent hardware ID + * for the PS/2 mouse, it will be PSM_XXX_ID + */ +} mousehw_t; + +/* iftype */ +#define MOUSE_IF_UNKNOWN (-1) +#define MOUSE_IF_SERIAL 0 +#define MOUSE_IF_BUS 1 +#define MOUSE_IF_INPORT 2 +#define MOUSE_IF_PS2 3 +#define MOUSE_IF_SYSMOUSE 4 +#define MOUSE_IF_USB 5 + +/* type */ +#define MOUSE_UNKNOWN (-1) /* should be treated as a mouse */ +#define MOUSE_MOUSE 0 +#define MOUSE_TRACKBALL 1 +#define MOUSE_STICK 2 +#define MOUSE_PAD 3 + +/* model */ +#define MOUSE_MODEL_UNKNOWN (-1) +#define MOUSE_MODEL_GENERIC 0 +#define MOUSE_MODEL_GLIDEPOINT 1 +#define MOUSE_MODEL_NETSCROLL 2 +#define MOUSE_MODEL_NET 3 +#define MOUSE_MODEL_INTELLI 4 +#define MOUSE_MODEL_THINK 5 +#define MOUSE_MODEL_EASYSCROLL 6 +#define MOUSE_MODEL_MOUSEMANPLUS 7 +#define MOUSE_MODEL_KIDSPAD 8 +#define MOUSE_MODEL_VERSAPAD 9 + +typedef struct mousemode { + int protocol; /* MOUSE_PROTO_XXX */ + int rate; /* report rate (per sec), -1 if unknown */ + int resolution; /* MOUSE_RES_XXX, -1 if unknown */ + int accelfactor; /* accelation factor (must be 1 or greater) */ + int level; /* driver operation level */ + int packetsize; /* the length of the data packet */ + unsigned char syncmask[2]; /* sync. data bits in the header byte */ +} mousemode_t; + +/* protocol */ +#define MOUSE_PROTO_UNKNOWN (-1) +#define MOUSE_PROTO_MS 0 /* Microsoft Serial, 3 bytes */ +#define MOUSE_PROTO_MSC 1 /* Mouse Systems, 5 bytes */ +#define MOUSE_PROTO_LOGI 2 /* Logitech, 3 bytes */ +#define MOUSE_PROTO_MM 3 /* MM series, 3 bytes */ +#define MOUSE_PROTO_LOGIMOUSEMAN 4 /* Logitech MouseMan 3/4 bytes */ +#define MOUSE_PROTO_BUS 5 /* MS/Logitech bus mouse */ +#define MOUSE_PROTO_INPORT 6 /* MS/ATI InPort mouse */ +#define MOUSE_PROTO_PS2 7 /* PS/2 mouse, 3 bytes */ +#define MOUSE_PROTO_HITTAB 8 /* Hitachi Tablet 3 bytes */ +#define MOUSE_PROTO_GLIDEPOINT 9 /* ALPS GlidePoint, 3/4 bytes */ +#define MOUSE_PROTO_INTELLI 10 /* MS IntelliMouse, 4 bytes */ +#define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */ +#define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */ +#define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */ +#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */ +#define MOUSE_PROTO_VERSAPAD 15 /* Interlink VersaPad, 6 bytes */ + +#define MOUSE_RES_UNKNOWN (-1) +#define MOUSE_RES_DEFAULT 0 +#define MOUSE_RES_LOW (-2) +#define MOUSE_RES_MEDIUMLOW (-3) +#define MOUSE_RES_MEDIUMHIGH (-4) +#define MOUSE_RES_HIGH (-5) + +typedef struct mousedata { + int len; /* # of data in the buffer */ + int buf[16]; /* data buffer */ +} mousedata_t; + +#if (defined(MOUSE_GETVARS)) + +typedef struct mousevar { + int var[16]; +} mousevar_t; + +/* magic numbers in var[0] */ +#define MOUSE_VARS_PS2_SIG 0x00325350 /* 'PS2' */ +#define MOUSE_VARS_BUS_SIG 0x00535542 /* 'BUS' */ +#define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */ + +#endif /* MOUSE_GETVARS */ + +/* Microsoft Serial mouse data packet */ +#define MOUSE_MSS_PACKETSIZE 3 +#define MOUSE_MSS_SYNCMASK 0x40 +#define MOUSE_MSS_SYNC 0x40 +#define MOUSE_MSS_BUTTONS 0x30 +#define MOUSE_MSS_BUTTON1DOWN 0x20 /* left */ +#define MOUSE_MSS_BUTTON2DOWN 0x00 /* no middle button */ +#define MOUSE_MSS_BUTTON3DOWN 0x10 /* right */ + +/* Logitech MouseMan data packet (M+ protocol) */ +#define MOUSE_LMAN_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ + +/* ALPS GlidePoint extention (variant of M+ protocol) */ +#define MOUSE_ALPS_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ +#define MOUSE_ALPS_TAP 0x10 /* `tapping' action, the 4th byte */ + +/* Kinsington Thinking Mouse extention (variant of M+ protocol) */ +#define MOUSE_THINK_BUTTON2DOWN 0x20 /* lower-left button, the 4th byte */ +#define MOUSE_THINK_BUTTON4DOWN 0x10 /* lower-right button, the 4th byte */ + +/* MS IntelliMouse (variant of MS Serial) */ +#define MOUSE_INTELLI_PACKETSIZE 4 +#define MOUSE_INTELLI_BUTTON2DOWN 0x10 /* middle button the 4th byte */ + +/* Mouse Systems Corp. mouse data packet */ +#define MOUSE_MSC_PACKETSIZE 5 +#define MOUSE_MSC_SYNCMASK 0xf8 +#define MOUSE_MSC_SYNC 0x80 +#define MOUSE_MSC_BUTTONS 0x07 +#define MOUSE_MSC_BUTTON1UP 0x04 /* left */ +#define MOUSE_MSC_BUTTON2UP 0x02 /* middle */ +#define MOUSE_MSC_BUTTON3UP 0x01 /* right */ +#define MOUSE_MSC_MAXBUTTON 3 + +/* MM series mouse data packet */ +#define MOUSE_MM_PACKETSIZE 3 +#define MOUSE_MM_SYNCMASK 0xe0 +#define MOUSE_MM_SYNC 0x80 +#define MOUSE_MM_BUTTONS 0x07 +#define MOUSE_MM_BUTTON1DOWN 0x04 /* left */ +#define MOUSE_MM_BUTTON2DOWN 0x02 /* middle */ +#define MOUSE_MM_BUTTON3DOWN 0x01 /* right */ +#define MOUSE_MM_XPOSITIVE 0x10 +#define MOUSE_MM_YPOSITIVE 0x08 + +/* PS/2 mouse data packet */ +#define MOUSE_PS2_PACKETSIZE 3 +#define MOUSE_PS2_SYNCMASK 0xc8 +#define MOUSE_PS2_SYNC 0x08 +#define MOUSE_PS2_BUTTONS 0x07 /* 0x03 for 2 button mouse */ +#define MOUSE_PS2_BUTTON1DOWN 0x01 /* left */ +#define MOUSE_PS2_BUTTON2DOWN 0x04 /* middle */ +#define MOUSE_PS2_BUTTON3DOWN 0x02 /* right */ +#define MOUSE_PS2_TAP MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping' + * Yes! this is the same bit + * as SYNC! + */ +#define MOUSE_PS2PLUS_BUTTON4DOWN 0x10 /* 4th button on MouseMan+ */ +#define MOUSE_PS2PLUS_BUTTON5DOWN 0x20 + +#define MOUSE_PS2_XNEG 0x10 +#define MOUSE_PS2_YNEG 0x20 +#define MOUSE_PS2_XOVERFLOW 0x40 +#define MOUSE_PS2_YOVERFLOW 0x80 +#define MOUSE_PS2PLUS_ZNEG 0x08 /* MouseMan+ negative wheel movement */ +#define MOUSE_PS2PLUS_SYNCMASK 0x48 +#define MOUSE_PS2PLUS_SYNC 0x48 + +/* Interlink VersaPad (serial I/F) data packet */ +#define MOUSE_VERSA_PACKETSIZE 6 +#define MOUSE_VERSA_IN_USE 0x04 +#define MOUSE_VERSA_SYNCMASK 0xc3 +#define MOUSE_VERSA_SYNC 0xc0 +#define MOUSE_VERSA_BUTTONS 0x30 +#define MOUSE_VERSA_BUTTON1DOWN 0x20 /* left */ +#define MOUSE_VERSA_BUTTON2DOWN 0x00 /* middle */ +#define MOUSE_VERSA_BUTTON3DOWN 0x10 /* right */ +#define MOUSE_VERSA_TAP 0x08 + +/* Interlink VersaPad (PS/2 I/F) data packet */ +#define MOUSE_PS2VERSA_PACKETSIZE 6 +#define MOUSE_PS2VERSA_IN_USE 0x10 +#define MOUSE_PS2VERSA_SYNCMASK 0xe8 +#define MOUSE_PS2VERSA_SYNC 0xc8 +#define MOUSE_PS2VERSA_BUTTONS 0x05 +#define MOUSE_PS2VERSA_BUTTON1DOWN 0x04 /* left */ +#define MOUSE_PS2VERSA_BUTTON2DOWN 0x00 /* middle */ +#define MOUSE_PS2VERSA_BUTTON3DOWN 0x01 /* right */ +#define MOUSE_PS2VERSA_TAP 0x02 + +/* sysmouse extended data packet */ +/* + * /dev/sysmouse sends data in two formats, depending on the protocol + * level. At the level 0, format is exactly the same as MousSystems' + * five byte packet. At the level 1, the first five bytes are the same + * as at the level 0. There are additional three bytes which shows + * `dz' and the states of additional buttons. `dz' is expressed as the + * sum of the byte 5 and 6 which contain signed seven bit values. + * The states of the button 4 though 10 are in the bit 0 though 6 in + * the byte 7 respectively: 1 indicates the button is up. + */ +#define MOUSE_SYS_PACKETSIZE 8 +#define MOUSE_SYS_SYNCMASK 0xf8 +#define MOUSE_SYS_SYNC 0x80 +#define MOUSE_SYS_BUTTON1UP 0x04 /* left, 1st byte */ +#define MOUSE_SYS_BUTTON2UP 0x02 /* middle, 1st byte */ +#define MOUSE_SYS_BUTTON3UP 0x01 /* right, 1st byte */ +#define MOUSE_SYS_BUTTON4UP 0x0001 /* 7th byte */ +#define MOUSE_SYS_BUTTON5UP 0x0002 +#define MOUSE_SYS_BUTTON6UP 0x0004 +#define MOUSE_SYS_BUTTON7UP 0x0008 +#define MOUSE_SYS_BUTTON8UP 0x0010 +#define MOUSE_SYS_BUTTON9UP 0x0020 +#define MOUSE_SYS_BUTTON10UP 0x0040 +#define MOUSE_SYS_MAXBUTTON 10 +#define MOUSE_SYS_STDBUTTONS 0x07 +#define MOUSE_SYS_EXTBUTTONS 0x7f /* the others */ + +/* Mouse remote socket */ +#define _PATH_MOUSEREMOTE "/var/run/MouseRemote" + +#endif /* _MACHINE_MOUSE_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/mpapic.h ./modules/label/machine/mpapic.h --- ../sys-altq/modules/label/machine/mpapic.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/mpapic.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1996, by Steve Passe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the developer may NOT be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/mpapic.h,v 1.11.2.1 1999/08/29 16:06:40 peter Exp $ + */ + +#ifndef _MACHINE_MPAPIC_H_ +#define _MACHINE_MPAPIC_H_ + +#include + +#include + +/* number of busses */ +#if !defined(NBUS) +# define NBUS 4 +#endif /* NBUS */ + +/* total number of APIC INTs, including SHARED INTs */ +#if !defined(NINTR) +#define NINTR 48 +#endif /* NINTR */ + + +/* + * Size of APIC ID list. + * Also used a MAX size of various other arrays. + */ +#define NAPICID 16 + +/* these don't really belong in here... */ +enum busTypes { + CBUS = 1, + CBUSII = 2, + EISA = 3, + ISA = 6, + PCI = 13, + XPRESS = 18, + MAX_BUSTYPE = 18, + UNKNOWN_BUSTYPE = 0xff +}; + + +/* + * the physical/logical APIC ID management macors + */ +#define CPU_TO_ID(CPU) (cpu_num_to_apic_id[CPU]) +#define ID_TO_CPU(ID) (apic_id_to_logical[ID]) +#define IO_TO_ID(IO) (io_num_to_apic_id[IO]) +#define ID_TO_IO(ID) (apic_id_to_logical[ID]) + + +/* + * send an IPI INTerrupt containing 'vector' to CPUs in 'targetMap' + * 'targetMap' is a bitfiled of length 14, + * APIC #0 == bit 0, ..., APIC #14 == bit 14 + * NOTE: these are LOGICAL APIC IDs + */ +static __inline int +selected_procs_ipi(int targetMap, int vector) +{ + return selected_apic_ipi(targetMap, vector, APIC_DELMODE_FIXED); +} + +/* + * send an IPI INTerrupt containing 'vector' to all CPUs, including myself + */ +static __inline int +all_procs_ipi(int vector) +{ + return apic_ipi(APIC_DEST_ALLISELF, vector, APIC_DELMODE_FIXED); +} + +/* + * send an IPI INTerrupt containing 'vector' to all CPUs EXCEPT myself + */ +static __inline int +all_but_self_ipi(int vector) +{ + return apic_ipi(APIC_DEST_ALLESELF, vector, APIC_DELMODE_FIXED); +} + +/* + * send an IPI INTerrupt containing 'vector' to myself + */ +static __inline int +self_ipi(int vector) +{ + return apic_ipi(APIC_DEST_SELF, vector, APIC_DELMODE_FIXED); +} + +#endif /* _MACHINE_MPAPIC_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/mtpr.h ./modules/label/machine/mtpr.h --- ../sys-altq/modules/label/machine/mtpr.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/mtpr.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,4 @@ +/* + * Unused in 386BSD port + * $FreeBSD: src/sys/i386/include/mtpr.h,v 1.4.4.1 1999/08/29 16:06:40 peter Exp $ + */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/npx.h ./modules/label/machine/npx.h --- ../sys-altq/modules/label/machine/npx.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/npx.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,146 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/npx.h,v 1.14.2.1 1999/08/29 16:06:41 peter Exp $ + */ + +/* + * 287/387 NPX Coprocessor Data Structures and Constants + * W. Jolitz 1/90 + */ + +#ifndef _MACHINE_NPX_H_ +#define _MACHINE_NPX_H_ + +/* Environment information of floating point unit */ +struct env87 { + long en_cw; /* control word (16bits) */ + long en_sw; /* status word (16bits) */ + long en_tw; /* tag word (16bits) */ + long en_fip; /* floating point instruction pointer */ + u_short en_fcs; /* floating code segment selector */ + u_short en_opcode; /* opcode last executed (11 bits ) */ + long en_foo; /* floating operand offset */ + long en_fos; /* floating operand segment selector */ +}; + +/* Contents of each floating point accumulator */ +struct fpacc87 { +#ifdef dontdef /* too unportable */ + u_long fp_mantlo; /* mantissa low (31:0) */ + u_long fp_manthi; /* mantissa high (63:32) */ + int fp_exp:15; /* exponent */ + int fp_sgn:1; /* mantissa sign */ +#else + u_char fp_bytes[10]; +#endif +}; + +/* Floating point context */ +struct save87 { + struct env87 sv_env; /* floating point control/status */ + struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ + u_long sv_ex_sw; /* status word for last exception */ + /* + * Bogus padding for emulators. Emulators should use their own + * struct and arrange to store into this struct (ending here) + * before it is inspected for ptracing or for core dumps. Some + * emulators overwrite the whole struct. We have no good way of + * knowing how much padding to leave. Leave just enough for the + * GPL emulator's i387_union (176 bytes total). + */ + u_char sv_pad[64]; /* padding; used by emulators */ +}; + +/* Intel prefers long real (53 bit) precision */ +#define __iBCS_NPXCW__ 0x262 +/* wfj prefers temporary real (64 bit) precision */ +#define __386BSD_NPXCW__ 0x362 +/* + * bde prefers 53 bit precision and all exceptions masked. + * + * The standard control word from finit is 0x37F, giving: + * + * round to nearest + * 64-bit precision + * all exceptions masked. + * + * Now I want: + * + * affine mode for 287's (if they work at all) (1 in bitfield 1<<12) + * 53-bit precision (2 in bitfield 3<<8) + * overflow exception unmasked (0 in bitfield 1<<3) + * zero divide exception unmasked (0 in bitfield 1<<2) + * invalid-operand exception unmasked (0 in bitfield 1<<0). + * + * 64-bit precision often gives bad results with high level languages + * because it makes the results of calculations depend on whether + * intermediate values are stored in memory or in FPU registers. + * + * The "Intel" and wfj control words have: + * + * underflow exception unmasked (0 in bitfield 1<<4) + * + * but that causes an unexpected exception in the test program 'paranoia' + * and makes denormals useless (DBL_MIN / 2 underflows). It doesn't make + * a lot of sense to trap underflow without trapping denormals. + * + * Later I will want the IEEE default of all exceptions masked. See the + * 0.0 math manpage for why this is better. The 0.1 math manpage is empty. + */ +#define __BDE_NPXCW__ 0x1272 +#define __BETTER_BDE_NPXCW__ 0x127f + +#ifdef __BROKEN_NPXCW__ +#ifdef __FreeBSD__ +#define __INITIAL_NPXCW__ __386BSD_NPXCW__ +#else +#define __INITIAL_NPXCW__ __iBCS_NPXCW__ +#endif +#else +#define __INITIAL_NPXCW__ __BDE_NPXCW__ +#endif + +#ifdef KERNEL +extern struct proc *npxproc; + +int npxdna __P((void)); +void npxexit __P((struct proc *p)); +void npxinit __P((int control)); +void npxsave __P((struct save87 *addr)); +#endif + +#endif /* !_MACHINE_NPX_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/param.h ./modules/label/machine/param.h --- ../sys-altq/modules/label/machine/param.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/param.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,150 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD: src/sys/i386/include/param.h,v 1.48.2.1 1999/08/29 16:06:41 peter Exp $ + */ + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +/* + * Machine dependent constants for Intel 386. + */ +#define _MACHINE i386 +#define MACHINE "i386" +#define _MACHINE_ARCH i386 +#define MACHINE_ARCH "i386" +#define MID_MACHINE MID_I386 + +/* + * OBJFORMAT_NAMES is a comma-separated list of the object formats + * that are supported on the architecture. + */ +#define OBJFORMAT_NAMES "elf", "aout" +#define OBJFORMAT_DEFAULT "elf" + +#ifdef SMP +#define NCPUS 2 +#else +#define NCPUS 1 +#endif + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define ALIGNBYTES (sizeof(int) - 1) +#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) + +#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ +#define PAGE_SIZE (1<>PAGE_SHIFT) + +/* + * btodb() is messy and perhaps slow because `bytes' may be an off_t. We + * want to shift an unsigned type to avoid sign extension and we don't + * want to widen `bytes' unnecessarily. Assume that the result fits in + * a daddr_t. + */ +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + (sizeof (bytes) > sizeof(long) \ + ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ + : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) + +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((off_t)(db) << DEV_BSHIFT) + +/* + * Mach derived conversion macros + */ +#define trunc_page(x) ((x) & ~PAGE_MASK) +#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) +#define trunc_4mpage(x) ((unsigned)(x) & ~PDRMASK) +#define round_4mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) + +#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) +#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) + +#define i386_btop(x) ((unsigned)(x) >> PAGE_SHIFT) +#define i386_ptob(x) ((unsigned)(x) << PAGE_SHIFT) + +#endif /* !_MACHINE_PARAM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pc/bios.h ./modules/label/machine/pc/bios.h --- ../sys-altq/modules/label/machine/pc/bios.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pc/bios.h Wed Dec 1 17:28:06 1999 @@ -0,0 +1,112 @@ +/*- + * Copyright (c) 1997 Michael Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/pc/bios.h,v 1.2.2.1 1999/08/29 16:07:04 peter Exp $ + */ + +/* + * Signature structure for the BIOS32 Service Directory header + */ +struct bios32_SDheader +{ + u_int8_t sig[4]; + u_int32_t entry; + u_int8_t revision; + u_int8_t len; + u_int8_t cksum; + u_int8_t pad[5]; +}; + +/* + * BIOS32 Service Directory entry. Caller supplies name, bios32_SDlookup + * fills in the rest of the details. + */ +struct bios32_SDentry +{ + union + { + u_int8_t name[4]; /* service identifier */ + u_int32_t id; /* as a 32-bit value */ + } ident; + u_int32_t base; /* base of service */ + u_int32_t len; /* service length */ + u_int32_t entry; /* entrypoint offset from base */ +}; + +extern int bios32_SDlookup(struct bios32_SDentry *ent); +extern u_int32_t bios_sigsearch(u_int32_t start, u_char *sig, int siglen, + int paralen, int sigofs); + +/* + * Call a 32-bit BIOS function + */ +struct bios32_args { + u_long eax; + u_long ebx; + u_long ecx; + u_long edx; +}; +extern void bios32(caddr_t func_addr, struct bios32_args *args); + +#define BIOS_PADDRTOVADDR(x) (((x) - ISA_HOLE_START) + atdevbase) +#define BIOS_VADDRTOPADDR(x) (((x) - atdevbase) + ISA_HOLE_START) + + +/* + * System Management BIOS / Desktop Management Interface tables + */ + +struct DMI_table +{ + u_int8_t sig[5]; /* "_DMI_" */ + u_int8_t cksum; /* checksum */ + u_int16_t st_size; /* total length of SMBIOS table (bytes)*/ + u_int32_t st_base; /* base address of the SMBIOS table (physical) */ + u_int16_t st_entries; /* total number of structures present in the table */ + u_int8_t bcd_revision; /* interface revision number */ +}; + +struct SMBIOS_table +{ + u_int8_t sig[4]; /* "_SM_" */ + u_int8_t cksum; /* checksum */ + u_int8_t len; /* structure length */ + u_int8_t major, minor; /* major/minor revision numbers */ + u_int16_t st_maxsize; /* largest structure size (bytes) */ + u_int8_t revision; /* entrypoint revision */ + u_int8_t pad[5]; + struct DMI_table dmi; /* follows immediately */ +}; + + +/* + * Exported lookup results + */ +extern struct bios32_SDentry PCIbios; +extern struct SMBIOS_table *SMBIOS_table; +extern struct DMI_table *DMI_table; + + + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pc/display.h ./modules/label/machine/pc/display.h --- ../sys-altq/modules/label/machine/pc/display.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pc/display.h Wed Dec 1 17:28:06 1999 @@ -0,0 +1,45 @@ +/* + * IBM PC display definitions + * + * $FreeBSD: src/sys/i386/include/pc/display.h,v 1.4.4.1 1999/08/29 16:07:05 peter Exp $ + */ + +/* Color attributes for foreground text */ + +#define FG_BLACK 0 +#define FG_BLUE 1 +#define FG_GREEN 2 +#define FG_CYAN 3 +#define FG_RED 4 +#define FG_MAGENTA 5 +#define FG_BROWN 6 +#define FG_LIGHTGREY 7 +#define FG_DARKGREY 8 +#define FG_LIGHTBLUE 9 +#define FG_LIGHTGREEN 10 +#define FG_LIGHTCYAN 11 +#define FG_LIGHTRED 12 +#define FG_LIGHTMAGENTA 13 +#define FG_YELLOW 14 +#define FG_WHITE 15 +#define FG_BLINK 0x80 + +/* Color attributes for text background */ + +#define BG_BLACK 0x00 +#define BG_BLUE 0x10 +#define BG_GREEN 0x20 +#define BG_CYAN 0x30 +#define BG_RED 0x40 +#define BG_MAGENTA 0x50 +#define BG_BROWN 0x60 +#define BG_LIGHTGREY 0x70 + +/* Monochrome attributes for foreground text */ + +#define FG_UNDERLINE 0x01 +#define FG_INTENSE 0x08 + +/* Monochrome attributes for text background */ + +#define BG_INTENSE 0x10 diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pc/msdos.h ./modules/label/machine/pc/msdos.h --- ../sys-altq/modules/label/machine/pc/msdos.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pc/msdos.h Wed Dec 1 17:28:06 1999 @@ -0,0 +1,65 @@ +/* + * msdos common header file + * [obtained from mtools -wfj] + * how to decipher DOS disk structures in coexisting with DOS + * + * $FreeBSD: src/sys/i386/include/pc/msdos.h,v 1.4.4.1 1999/08/29 16:07:05 peter Exp $ + */ + +#define MSECTOR_SIZE 512 /* MSDOS sector size in bytes */ +#define MDIR_SIZE 32 /* MSDOS directory size in bytes */ +#define MAX_CLUSTER 8192 /* largest cluster size */ +#define MAX_PATH 128 /* largest MSDOS path length */ +#define MAX_DIR_SECS 64 /* largest directory (in sectors) */ + +#define NEW 1 +#define OLD 0 + +struct directory { + unsigned char name[8]; /* file name */ + unsigned char ext[3]; /* file extension */ + unsigned char attr; /* attribute byte */ + unsigned char reserved[10]; /* ?? */ + unsigned char time[2]; /* time stamp */ + unsigned char date[2]; /* date stamp */ + unsigned char start[2]; /* starting cluster number */ + unsigned char size[4]; /* size of the file */ +}; + +struct bootsector { + unsigned char jump[3]; /* Jump to boot code */ + unsigned char banner[8]; /* OEM name & version */ + unsigned char secsiz[2]; /* Bytes per sector hopefully 512 */ + unsigned char clsiz; /* Cluster size in sectors */ + unsigned char nrsvsect[2]; /* Number of reserved (boot) sectors */ + unsigned char nfat; /* Number of FAT tables hopefully 2 */ + unsigned char dirents[2]; /* Number of directory slots */ + unsigned char psect[2]; /* Total sectors on disk */ + unsigned char descr; /* Media descriptor=first byte of FAT */ + unsigned char fatlen[2]; /* Sectors in FAT */ + unsigned char nsect[2]; /* Sectors/track */ + unsigned char nheads[2]; /* Heads */ + unsigned char nhs[4]; /* number of hidden sectors */ + unsigned char bigsect[4]; /* big total sectors */ + unsigned char junk[476]; /* who cares? */ +}; + +/* DOS partition table -- located in boot block */ + +#define DOSBBSECTOR 0 /* DOS boot block relative sector number */ +#define DOSPARTOFF 446 +#define NDOSPART 4 + +struct dos_partition { + unsigned char dp_flag; /* bootstrap flags */ + unsigned char dp_shd; /* starting head */ + unsigned char dp_ssect; /* starting sector */ + unsigned char dp_scyl; /* starting cylinder */ + unsigned char dp_typ; /* partition type */ +#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */ + unsigned char dp_ehd; /* end head */ + unsigned char dp_esect; /* end sector */ + unsigned char dp_ecyl; /* end cylinder */ + unsigned long dp_start; /* absolute starting sector number */ + unsigned long dp_size; /* partition size in sectors */ +} dos_partitions[NDOSPART]; diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pc/vesa.h ./modules/label/machine/pc/vesa.h --- ../sys-altq/modules/label/machine/pc/vesa.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pc/vesa.h Wed Dec 1 17:28:07 1999 @@ -0,0 +1,120 @@ +/*- + * Copyright (c) 1998 Michael Smith and Kazutaka YOKOTA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/pc/vesa.h,v 1.4.2.2 1999/08/29 16:07:06 peter Exp $ + */ + +#ifndef _MACHINE_PC_VESA_H +#define _MACHINE_PC_VESA_H + +struct vesa_info +{ + /* mandatory fields */ + u_int8_t v_sig[4] __attribute__ ((packed)); /* VESA */ + u_int16_t v_version __attribute__ ((packed)); /* ver in BCD */ + u_int32_t v_oemstr __attribute__ ((packed)); /* OEM string */ + u_int32_t v_flags __attribute__ ((packed)); /* flags */ +#define V_DAC8 (1<<0) +#define V_NONVGA (1<<1) +#define V_SNOW (1<<2) + u_int32_t v_modetable __attribute__ ((packed)); /* modes */ + u_int16_t v_memsize __attribute__ ((packed)); /* in 64K */ + /* 2.0 */ + u_int16_t v_revision __attribute__ ((packed)); /* software rev */ + u_int32_t v_venderstr __attribute__ ((packed)); /* vender */ + u_int32_t v_prodstr __attribute__ ((packed)); /* product name */ + u_int32_t v_revstr __attribute__ ((packed)); /* product rev */ +}; + +struct vesa_mode +{ + /* mandatory fields */ + u_int16_t v_modeattr; +#define V_MODESUPP (1<<0) /* VESA mode attributes */ +#define V_MODEOPTINFO (1<<1) +#define V_MODEBIOSOUT (1<<2) +#define V_MODECOLOR (1<<3) +#define V_MODEGRAPHICS (1<<4) +#define V_MODENONVGA (1<<5) +#define V_MODENONBANK (1<<6) +#define V_MODELFB (1<<7) +#define V_MODEVESA (1<<16) /* Private attributes */ + u_int8_t v_waattr; + u_int8_t v_wbattr; +#define V_WATTREXIST (1<<0) +#define V_WATTRREAD (1<<1) +#define V_WATTRWRITE (1<<2) + u_int16_t v_wgran; + u_int16_t v_wsize; + u_int16_t v_waseg; + u_int16_t v_wbseg; + u_int32_t v_posfunc; + u_int16_t v_bpscanline; + /* fields optional for 1.0/1.1 implementations */ + u_int16_t v_width; + u_int16_t v_height; + u_int8_t v_cwidth; + u_int8_t v_cheight; + u_int8_t v_planes; + u_int8_t v_bpp; + u_int8_t v_banks; + u_int8_t v_memmodel; +#define V_MMTEXT 0 +#define V_MMCGA 1 +#define V_MMHGC 2 +#define V_MMEGA 3 +#define V_MMPACKED 4 +#define V_MMSEQU256 5 +#define V_MMDIRCOLOR 6 +#define V_MMYUV 7 + u_int8_t v_banksize; + u_int8_t v_ipages; + u_int8_t v_reserved0; + /* fields for 1.2+ implementations */ + u_int8_t v_redmasksize; + u_int8_t v_redfieldpos; + u_int8_t v_greenmasksize; + u_int8_t v_greenfieldpos; + u_int8_t v_bluemasksize; + u_int8_t v_bluefieldpos; + u_int8_t v_resmasksize; + u_int8_t v_resfieldpos; + u_int8_t v_dircolormode; + /* 2.0 implementations */ + u_int32_t v_lfb; + u_int32_t v_offscreen; + u_int16_t v_offscreensize; +}; + +#ifdef KERNEL + +#define VESA_MODE(x) ((x) >= M_VESA_BASE) + +int vesa_load_ioctl(void); +int vesa_unload_ioctl(void); + +#endif /* KERNEL */ + +#endif /* !_MACHINE_PC_VESA_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pcaudioio.h ./modules/label/machine/pcaudioio.h --- ../sys-altq/modules/label/machine/pcaudioio.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pcaudioio.h Wed Dec 1 17:28:08 1999 @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 1994 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/pcaudioio.h,v 1.9.4.1 1999/08/29 16:06:42 peter Exp $ + */ + +#ifndef _MACHINE_PCAUDIOIO_H_ +#define _MACHINE_PCAUDIOIO_H_ + +#include + +typedef struct audio_prinfo { + unsigned sample_rate; /* samples per second */ + unsigned channels; /* # of channels (interleaved) */ + unsigned precision; /* sample size in bits */ + unsigned encoding; /* encoding method used */ + + unsigned gain; /* volume level: 0 - 255 */ + unsigned port; /* input/output device */ + unsigned _fill1[4]; + + unsigned samples; /* samples played */ + unsigned eof; /* ?!? */ + unsigned char pause; /* !=0 pause, ==0 continue */ + unsigned char error; /* !=0 if overflow/underflow */ + unsigned char waiting; /* !=0 if others wants access */ + unsigned char _fill2[3]; + + unsigned char open; /* is device open */ + unsigned char active; /* !=0 if sound hardware is active */ +} audio_prinfo_t; + +typedef struct audio_info { + audio_prinfo_t play; + audio_prinfo_t record; + unsigned monitor_gain; + unsigned _fill[4]; +} audio_info_t; + +#define AUDIO_ENCODING_ULAW (1) /* u-law encoding */ +#define AUDIO_ENCODING_ALAW (2) /* A-law encoding */ +#define AUDIO_ENCODING_RAW (3) /* linear encoding */ + +#define AUDIO_MIN_GAIN (0) /* minimum volume value */ +#define AUDIO_MAX_GAIN (255) /* maximum volume value */ + +#define AUDIO_INITINFO(i) memset((void*)i, 0xff, sizeof(audio_info_t)) + +#define AUDIO_GETINFO _IOR('A', 1, audio_info_t) +#define AUDIO_SETINFO _IOWR('A', 2, audio_info_t) +#define AUDIO_DRAIN _IO('A', 3) +#define AUDIO_FLUSH _IO('A', 4) + +/* compatibility to /dev/audio */ +#define AUDIO_COMPAT_DRAIN _IO('P', 1) +#define AUDIO_COMPAT_FLUSH _IO('P', 0) + +#endif /* !_MACHINE_PCAUDIOIO_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pcb.h ./modules/label/machine/pcb.h --- ../sys-altq/modules/label/machine/pcb.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pcb.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,91 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 + * $FreeBSD: src/sys/i386/include/pcb.h,v 1.26.2.1 1999/08/29 16:06:43 peter Exp $ + */ + +#ifndef _I386_PCB_H_ +#define _I386_PCB_H_ + +/* + * Intel 386 process control block + */ +#include + +struct pcb { + int pcb_cr3; + int pcb_edi; + int pcb_esi; + int pcb_ebp; + int pcb_esp; + int pcb_ebx; + int pcb_eip; + caddr_t pcb_ldt; /* per process (user) LDT */ + int pcb_ldt_len; /* number of LDT entries */ + struct save87 pcb_savefpu; /* floating point state for 287/387 */ + u_char pcb_flags; +#define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */ + caddr_t pcb_onfault; /* copyin/out fault recovery */ +#ifdef SMP + u_long pcb_mpnest; +#else + u_long pcb_mpnest_dontuse; +#endif + int pcb_fs; + int pcb_gs; +#ifdef VM86 + struct pcb_ext *pcb_ext; /* optional pcb extension */ +#else + struct pcb_ext *pcb_ext_dontuse; +#endif + u_long __pcb_spare[1]; /* adjust to avoid core dump size changes */ +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. For the i386: ??? + */ +struct md_coredump { +}; + +#ifdef KERNEL + +extern struct pcb *curpcb; /* our current running pcb */ + +void savectx __P((struct pcb *)); +#endif + +#endif /* _I386_PCB_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pcb_ext.h ./modules/label/machine/pcb_ext.h --- ../sys-altq/modules/label/machine/pcb_ext.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pcb_ext.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1997 Jonathan Lemon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/pcb_ext.h,v 1.1.2.1 1999/08/29 16:06:44 peter Exp $ + */ + +#ifndef _I386_PCB_EXT_H_ +#define _I386_PCB_EXT_H_ + +/* + * Extension to the 386 process control block + */ +#include +#include +#include + +struct pcb_ext { + struct segment_descriptor ext_tssd; /* tss descriptor */ + struct i386tss ext_tss; /* per-process i386tss */ + caddr_t ext_iomap; /* i/o permission bitmap */ + struct vm86_kernel ext_vm86; /* vm86 area */ +}; + +#endif /* _I386_PCB_EXT_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pcvt_ioctl.h ./modules/label/machine/pcvt_ioctl.h --- ../sys-altq/modules/label/machine/pcvt_ioctl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pcvt_ioctl.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,589 @@ +/* + * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. + * + * Copyright (c) 1992, 1993 Brian Dunford-Shore and Holger Veit. + * + * Copyright (C) 1992, 1993 Soeren Schmidt. + * + * All rights reserved. + * + * For the sake of compatibility, portions of this code regarding the + * X server interface are taken from Soeren Schmidt's syscons driver. + * + * This code is derived from software contributed to 386BSD by + * Holger Veit. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz and Don Ahn. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by + * Hellmuth Michaelis, Brian Dunford-Shore, Joerg Wunsch, Holger Veit + * and Soeren Schmidt. + * 4. The name authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @(#)ioctl_pcvt.h, 3.20, Last Edit-Date: [Fri Apr 7 10:17:13 1995] + * + */ + +/*--------------------------------------------------------------------------- + * + * pcvt_ioctl.h ioctl's for the VT220 video driver 'pcvt' + * --------------------------------------------------------- + * -hm ------------ Release 3.00 -------------- + * -hm some new PCVT_xxx (and CONF_xxx) values + * -hm version definitions moved to begin of file + * -hm removed PCVT_FAKE_SYSCONS10 + * -hm accept KERNEL or _KERNEL + * -hm changed _IOCTL_PCVT_H_ to _MACHINE_PCVT_IOCTL_H_ (bde) + * + *---------------------------------------------------------------------------*/ + +#ifndef _MACHINE_PCVT_IOCTL_H_ +#define _MACHINE_PCVT_IOCTL_H_ + +/* pcvt version information for VGAPCVTID ioctl */ + +#define PCVTIDNAME "pcvt-b24" /* driver id - string */ +#define PCVTIDMAJOR 3 /* driver id - major release */ +#define PCVTIDMINOR 20 /* driver id - minor release */ + +#if !defined(KERNEL) && !defined(_KERNEL) +#include +#endif +#include + +/*---------------------------------------------------------------------------* + * IOCTLs for MF II and AT Keyboards + *---------------------------------------------------------------------------*/ + +#define KBDRESET _IO('K', 1) /* reset keyboard / set defaults */ +#define KBDGTPMAT _IOR('K', 2, int) /* get current typematic value */ +#define KBDSTPMAT _IOW('K', 3, int) /* set current typematic value */ + +/* Typematic Delay Values */ + +#define KBD_TPD250 0x00 /* 250 ms */ +#define KBD_TPD500 0x20 /* 500 ms */ +#define KBD_TPD750 0x40 /* 750 ms */ +#define KBD_TPD1000 0x60 /* 1000 ms */ + +/* Typematic Repeat Rate */ + +#define KBD_TPM300 0x00 /* 30.0 char/second */ +#define KBD_TPM267 0x01 /* 26.7 char/second */ +#define KBD_TPM240 0x02 /* 24.0 char/second */ +#define KBD_TPM218 0x03 /* 21.8 char/second */ +#define KBD_TPM200 0x04 /* 20.0 char/second */ +#define KBD_TPM185 0x05 /* 18.5 char/second */ +#define KBD_TPM171 0x06 /* 17.1 char/second */ +#define KBD_TPM160 0x07 /* 16.0 char/second */ +#define KBD_TPM150 0x08 /* 15.0 char/second */ +#define KBD_TPM133 0x09 /* 13.3 char/second */ +#define KBD_TPM120 0x0A /* 12.0 char/second */ +#define KBD_TPM109 0x0B /* 10.9 char/second */ +#define KBD_TPM100 0x0C /* 10.0 char/second */ +#define KBD_TPM92 0x0D /* 9.2 char/second */ +#define KBD_TPM86 0x0E /* 8.6 char/second */ +#define KBD_TPM80 0x0F /* 8.0 char/second */ +#define KBD_TPM75 0x10 /* 7.5 char/second */ +#define KBD_TPM67 0x11 /* 6.7 char/second */ +#define KBD_TPM60 0x12 /* 6.0 char/second */ +#define KBD_TPM55 0x13 /* 5.5 char/second */ +#define KBD_TPM50 0x14 /* 5.0 char/second */ +#define KBD_TPM46 0x15 /* 4.6 char/second */ +#define KBD_TPM43 0x16 /* 4.3 char/second */ +#define KBD_TPM40 0x17 /* 4.0 char/second */ +#define KBD_TPM37 0x18 /* 3.7 char/second */ +#define KBD_TPM33 0x19 /* 3.3 char/second */ +#define KBD_TPM30 0x1A /* 3.0 char/second */ +#define KBD_TPM27 0x1B /* 2.7 char/second */ +#define KBD_TPM25 0x1C /* 2.5 char/second */ +#define KBD_TPM23 0x1D /* 2.3 char/second */ +#define KBD_TPM21 0x1E /* 2.1 char/second */ +#define KBD_TPM20 0x1F /* 2.0 char/second */ + +#define KBDGREPSW _IOR('K', 4, int) /* get key repetition switch */ +#define KBDSREPSW _IOW('K', 5, int) /* set key repetition switch */ +#define KBD_REPEATOFF 0 +#define KBD_REPEATON 1 + +#define KBDGLEDS _IOR('K', 6, int) /* get LED state */ +#define KBDSLEDS _IOW('K', 7, int) /* set LED state, does not influence */ +#define KBD_SCROLLLOCK 0x0001 /* the driver's idea of lock key state */ +#define KBD_NUMLOCK 0x0002 +#define KBD_CAPSLOCK 0x0004 +#define KBDGLOCK _IOR('K', 8, int) /* gets state of SCROLL,NUM,CAPS */ +#define KBDSLOCK _IOW('K', 9, int) /* sets state of SCROLL,NUM,CAPS + LEDs */ + +#define KBDMAXOVLKEYSIZE 15 /* + zero byte */ + +struct kbd_ovlkey /* complete definition of a key */ +{ + u_short keynum; /* the key itself */ + u_short type; /* type of key, see below */ + u_char subu; /* subtype, ignored on write */ + char unshift[KBDMAXOVLKEYSIZE+1]; /* emitted string, unshifted */ + u_char subs; /* subtype, ignored on write */ + char shift[KBDMAXOVLKEYSIZE+1]; /* emitted string, shifted */ + u_char subc; /* subtype, ignored on write */ + char ctrl[KBDMAXOVLKEYSIZE+1]; /* emitted string, control */ + u_char suba; /* subtype, ignored on write */ + char altgr[KBDMAXOVLKEYSIZE+1]; /* emitted string, altgr */ +}; + +/* Max value for keynum field */ + +#define KBDMAXKEYS 128 /* Max No. of Keys */ + +/* Values for type field */ + +#define KBD_NONE 0 /* no function, key is disabled */ +#define KBD_SHIFT 1 /* keyboard shift */ +#define KBD_META 2 /* alternate shift, sets bit8 to ASCII code */ +#define KBD_NUM 3 /* numeric shift, keypad num / appl */ +#define KBD_CTL 4 /* control code generation */ +#define KBD_CAPS 5 /* caps shift - swaps case of letter */ +#define KBD_ASCII 6 /* ascii code generating key */ +#define KBD_SCROLL 7 /* stop output */ +#define KBD_FUNC 8 /* function key */ +#define KBD_KP 9 /* keypad keys */ +#define KBD_BREAK 10 /* ignored */ +#define KBD_ALTGR 11 /* AltGr Translation feature */ +#define KBD_SHFTLOCK 12 /* shiftlock */ +#define KBD_CURSOR 13 /* cursor keys */ +#define KBD_RETURN 14 /* RETURN/ENTER keys */ + +/* Values for subtype field */ + +#define KBD_SUBT_STR 0 /* key is bound to a string */ +#define KBD_SUBT_FNC 1 /* key is bound to a function */ + + +#define KBD_OVERLOAD 0x8000 /* Key is overloaded, ignored in ioctl */ +#define KBD_MASK (~KBD_OVERLOAD) /* mask for type */ + +#define KBDGCKEY _IOWR('K',16, struct kbd_ovlkey) /* get current key values */ +#define KBDSCKEY _IOW('K',17, struct kbd_ovlkey) /* set new key assignment values*/ +#define KBDGOKEY _IOWR('K',18, struct kbd_ovlkey) /* get original key assignment values*/ + +#define KBDRMKEY _IOW('K',19, int) /* remove a key assignment */ +#define KBDDEFAULT _IO('K',20) /* remove all key assignments */ + +/* mouse emulator definitions */ + +struct mousedefs { + int leftbutton; /* (PC) scan code for "left button" key */ + int middlebutton; /* (PC) scan code for "mid button" key */ + int rightbutton; /* (PC) scan code for "right button" key */ + int stickybuttons; /* if true, the buttons are "sticky" */ + int acceltime; /* timeout in microseconds to start pointer */ + /* movement acceleration */ + /* defaults to: scan(F1), scan(F2), scan(F3), false, 500000 */ +}; + +#define KBDMOUSEGET _IOR('K', 25, struct mousedefs) /* read defs */ +#define KBDMOUSESET _IOW('K', 26, struct mousedefs) /* set defs */ + +/*---------------------------------------------------------------------------* + * IOCTLs for Video Adapter + *---------------------------------------------------------------------------*/ + +/* Definition of PC Video Adaptor Types */ + +#define UNKNOWN_ADAPTOR 0 /* Unidentified adaptor ... */ +#define MDA_ADAPTOR 1 /* Monochrome Display Adaptor/Hercules Graphics Card */ +#define CGA_ADAPTOR 2 /* Color Graphics Adaptor */ +#define EGA_ADAPTOR 3 /* Enhanced Graphics Adaptor */ +#define VGA_ADAPTOR 4 /* Video Graphics Adaptor/Array */ + +/* Definitions of Monitor types */ + +#define MONITOR_MONO 0 /* Monochrome Monitor */ +#define MONITOR_COLOR 1 /* Color Monitor */ + +/* Types of VGA chips detectable by current driver version */ + +#define VGA_F_NONE 0 /* FAMILY NOT KNOWN */ +#define VGA_UNKNOWN 0 /* default, no 132 columns */ + +#define VGA_F_TSENG 1 /* FAMILY TSENG */ +#define VGA_ET4000 1 /* Tseng Labs ET4000 */ +#define VGA_ET3000 2 /* Tseng Labs ET3000 */ + +#define VGA_F_WD 2 /* FAMILY WD */ +#define VGA_PVGA 3 /* Western Digital Paradise VGA */ +#define VGA_WD90C00 4 /* Western Digital WD90C00 */ +#define VGA_WD90C10 5 /* Western Digital WD90C10 */ +#define VGA_WD90C11 6 /* Western Digital WD90C11 */ + +#define VGA_F_V7 3 /* FAMILY VIDEO 7 */ +#define VGA_V7VEGA 7 /* Video 7 VEGA VGA */ +#define VGA_V7FWVR 8 /* Video 7 FASTWRITE/VRAM */ +#define VGA_V7V5 9 /* Video 7 Version 5 */ +#define VGA_V71024I 10 /* Video 7 1024i */ +#define VGA_V7UNKNOWN 11 /* Video 7 unknown board .. */ + +#define VGA_F_TRI 4 /* FAMILY TRIDENT */ +#define VGA_TR8800BR 12 /* Trident TVGA 8800BR */ +#define VGA_TR8800CS 13 /* Trident TVGA 8800CS */ +#define VGA_TR8900B 14 /* Trident TVGA 8900B */ +#define VGA_TR8900C 15 /* Trident TVGA 8900C */ +#define VGA_TR8900CL 16 /* Trident TVGA 8900CL */ +#define VGA_TR9000 17 /* Trident TVGA 9000 */ +#define VGA_TR9100 18 /* Trident TVGA 9100 */ +#define VGA_TR9200 19 /* Trident TVGA 9200 */ +#define VGA_TRUNKNOWN 20 /* Trident unknown */ + +#define VGA_F_S3 5 /* FAMILY S3 */ +#define VGA_S3_911 21 /* S3 911 */ +#define VGA_S3_924 22 /* S3 924 */ +#define VGA_S3_80x 23 /* S3 801/805 */ +#define VGA_S3_928 24 /* S3 928 */ +#define VGA_S3_UNKNOWN 25 /* unknown S3 chipset */ + +#define VGA_F_CIR 6 /* FAMILY CIRRUS */ +#define VGA_CL_GD5402 26 /* Cirrus CL-GD5402 */ +#define VGA_CL_GD5402r1 27 /* Cirrus CL-GD5402r1 */ +#define VGA_CL_GD5420 28 /* Cirrus CL-GD5420 */ +#define VGA_CL_GD5420r1 29 /* Cirrus CL-GD5420r1 */ +#define VGA_CL_GD5422 30 /* Cirrus CL-GD5422 */ +#define VGA_CL_GD5424 31 /* Cirrus CL-GD5424 */ +#define VGA_CL_GD5426 32 /* Cirrus CL-GD5426 */ +#define VGA_CL_GD5428 33 /* Cirrus CL-GD5428 */ + +/*****************************************************************************/ +/* NOTE: update the 'scon' utility when adding support for more chipsets !!! */ +/*****************************************************************************/ + +/* Definitions of Vertical Screen Sizes for EGA/VGA Adaptors */ + +#define SIZ_25ROWS 0 /* VGA: 25 lines, 8x16 font */ + /* EGA: 25 lines, 8x14 font */ +#define SIZ_28ROWS 1 /* VGA: 28 lines, 8x14 font */ +#define SIZ_35ROWS 2 /* EGA: 35 lines, 8x10 font */ +#define SIZ_40ROWS 3 /* VGA: 40 lines, 8x10 font */ +#define SIZ_43ROWS 4 /* EGA: 43 lines, 8x8 font */ +#define SIZ_50ROWS 5 /* VGA: 50 lines, 8x8 font */ + +/* Definitions of Font Sizes for EGA/VGA Adaptors */ + +#define FNT_8x16 0 /* 8x16 Pixel Font, only VGA */ +#define FNT_8x14 1 /* 8x14 Pixel Font, EGA/VGA */ +#define FNT_8x10 2 /* 8x10 Pixel Font, EGA/VGA */ +#define FNT_8x8 3 /* 8x8 Pixel Font, EGA/VGA */ + +/* Definitions of Character Set (Font) Numbers */ + +#define CH_SET0 0 /* Character Set (Font) 0, EGA/VGA */ +#define CH_SET1 1 /* Character Set (Font) 1, EGA/VGA */ +#define CH_SET2 2 /* Character Set (Font) 2, EGA/VGA */ +#define CH_SET3 3 /* Character Set (Font) 3, EGA/VGA */ +#define CH_SETMAX_EGA 3 /* EGA has 4 Character Sets / Fonts */ +#define CH_SET4 4 /* Character Set (Font) 4, VGA */ +#define CH_SET5 5 /* Character Set (Font) 5, VGA */ +#define CH_SET6 6 /* Character Set (Font) 6, VGA */ +#define CH_SET7 7 /* Character Set (Font) 7, VGA */ +#define CH_SETMAX_VGA 7 /* VGA has 8 Character Sets / Fonts */ + +/* Definitions of Terminal Emulation Modes */ + +#define M_HPVT 0 /* VTxxx and HP Mode, Labels & Status Line on */ +#define M_PUREVT 1 /* only VTxxx Sequences recognized, no Labels */ + +/*---*/ + +#define VGACURSOR _IOW('V',100, struct cursorshape) /* set cursor shape */ + +struct cursorshape { + int screen_no; /* screen number for which to set, */ + /* or -1 to set on current active screen */ + int start; /* top scanline, range 0... Character Height - 1 */ + int end; /* end scanline, range 0... Character Height - 1 */ +}; + +#define VGALOADCHAR _IOW('V',101, struct vgaloadchar) /* load vga char */ + +struct vgaloadchar { + int character_set; /* VGA character set to load into */ + int character; /* Character to load */ + int character_scanlines; /* Scanlines per character */ + u_char char_table[32]; /* VGA character shape table */ +}; + +#define VGASETFONTATTR _IOW('V',102, struct vgafontattr) /* set font attr */ +#define VGAGETFONTATTR _IOWR('V',103, struct vgafontattr) /* get font attr */ + +struct vgafontattr { + int character_set; /* VGA character set */ + int font_loaded; /* Mark font loaded or unloaded */ + int screen_size; /* Character rows per screen */ + int character_scanlines; /* Scanlines per character - 1 */ + int screen_scanlines; /* Scanlines per screen - 1 byte */ +}; + +#define VGASETSCREEN _IOW('V',104, struct screeninfo) /* set screen info */ +#define VGAGETSCREEN _IOWR('V',105, struct screeninfo) /* get screen info */ + +struct screeninfo { + int adaptor_type; /* type of video adaptor installed */ + /* read only, ignored on write */ + int monitor_type; /* type of monitor (mono/color)installed*/ + /* read only, ignored on write */ + int totalfonts; /* no of downloadable fonts */ + /* read only, ignored on write */ + int totalscreens; /* no of virtual screens */ + /* read only, ignored on write */ + int screen_no; /* screen number, this was got from */ + /* on write, if -1, apply pure_vt_mode */ + /* and/or screen_size to current screen */ + /* else to screen_no supplied */ + int current_screen; /* screen number, which is displayed. */ + /* on write, if -1, make this screen */ + /* the current screen, else set current */ + /* displayed screen to parameter */ + int pure_vt_mode; /* flag, pure VT mode or HP/VT mode */ + /* on write, if -1, no change */ + int screen_size; /* screen size */ + /* on write, if -1, no change */ + int force_24lines; /* force 24 lines if 25 lines VT mode */ + /* or 28 lines HP mode to get pure */ + /* VT220 screen size */ + /* on write, if -1, no change */ + int vga_family; /* if adaptor_type = VGA, this reflects */ + /* the chipset family after a read */ + /* nothing happens on write ... */ + int vga_type; /* if adaptor_type = VGA, this reflects */ + /* the chipset after a read */ + /* nothing happens on write ... */ + int vga_132; /* set to 1 if driver has support for */ + /* 132 column operation for chipset */ + /* currently ignored on write */ +}; + +#define VGAREADPEL _IOWR('V', 110, struct vgapel) /*r VGA palette entry */ +#define VGAWRITEPEL _IOW('V', 111, struct vgapel) /*w VGA palette entry */ + +struct vgapel { + unsigned idx; /* index into palette, 0 .. 255 valid */ + unsigned r, g, b; /* RGB values, masked by VGA_PMASK (63) */ +}; + +/* NOTE: The next ioctl is only valid if option PCVT_SCREENSAVER is configured*/ +/* this is *not* restricted to VGA's, but won't introduce new garbage... */ + +#define VGASCREENSAVER _IOW('V', 112, int) /* set timeout for screen */ + /* saver in seconds; 0 turns */ + /* it off */ + +#define VGAPCVTID _IOWR('V',113, struct pcvtid) /* get driver id */ + +struct pcvtid { /* THIS STRUCTURE IS NOW FROZEN !!! */ +#define PCVTIDNAMELN 16 /* driver id - string length */ + char name[PCVTIDNAMELN]; /* driver name, == PCVTIDSTR */ + int rmajor; /* revision number, major */ + int rminor; /* revision number, minor */ +}; /* END OF COLD PART ... */ + +#define VGAPCVTINFO _IOWR('V',114, struct pcvtinfo) /* get driver info */ + +struct pcvtinfo { /* compile time option values */ + u_int opsys; /* PCVT_xxx(x)BSD */ +#define CONF_UNKNOWNOPSYS 0 +#define CONF_386BSD 1 /* unsupported */ +#define CONF_NETBSD 2 +#define CONF_FREEBSD 3 + u_int opsysrel; /* Release */ + u_int nscreens; /* PCVT_NSCREENS */ + u_int scanset; /* PCVT_SCANSET */ + u_int updatefast; /* PCVT_UPDATEFAST */ + u_int updateslow; /* PCVT_UPDATESLOW */ + u_int sysbeepf; /* PCVT_SYSBEEPF */ + u_int pcburst; /* PCVT_PCBURST */ + u_int kbd_fifo_sz; /* PCVT_KBD_FIFO_SZ */ + +/* config booleans */ + + u_long compile_opts; /* PCVT_xxxxxxxxxxxxxxx */ + +#define CONF_VT220KEYB 0x00000001 +#define CONF_SCREENSAVER 0x00000002 +#define CONF_PRETTYSCRNS 0x00000004 +#define CONF_CTRL_ALT_DEL 0x00000008 +#define CONF_USEKBDSEC 0x00000010 +#define CONF_24LINESDEF 0x00000020 +#define CONF_EMU_MOUSE 0x00000040 +#define CONF_SHOWKEYS 0x00000080 +#define CONF_KEYBDID 0x00000100 +#define CONF_SIGWINCH 0x00000200 +#define CONF_NULLCHARS 0x00000400 +#define CONF_BACKUP_FONTS 0x00000800 +#define CONF_SW0CNOUTP 0x00001000 /* was FORCE8BIT */ + /* 0x00002000 was NEEDPG */ +#define CONF_SETCOLOR 0x00004000 +#define CONF_132GENERIC 0x00008000 +#define CONF_PALFLICKER 0x00010000 +#define CONF_WAITRETRACE 0x00020000 +#define CONF_XSERVER 0x00040000 +#define CONF_USL_VT_COMPAT 0x00080000 +#define CONF_PORTIO_DELAY 0x00100000 /* was FAKE_SYSCONS10 */ +#define CONF_INHIBIT_NUMLOCK 0x00200000 +#define CONF_META_ESC 0x00400000 +#define CONF_NOFASTSCROLL 0x00800000 +#define CONF_SLOW_INTERRUPT 0x01000000 +#define CONF_KBD_FIFO 0x02000000 +#define CONF_NO_LED_UPDATE 0x04000000 +}; + +#define VGASETCOLMS _IOW('V', 115, int) /* set number of columns (80/132)*/ + +/* + * only useful if compiled with ``XSERVER'' defined, but always here: + * WARNING: DO NOT CHANGE THESE DEFINITIONS, the X server relies on + * it since it's defining its own values and doesn't know nothing about + * this header file. + */ + +#define CONSOLE_X_MODE_ON _IO('t', 121) /* turn off pcvt, grant IOPL for X */ + +#define CONSOLE_X_MODE_OFF _IO('t', 122) /* back to pcvt */ + +#define CONSOLE_X_BELL _IOW('t', 123, int[2]) /* set bell behaviour */ + +/* + * start of USL VT compatibility stuff + * these definitions must match those ones used by syscons + * + * Note that some of the ioctl command definitions below break the Berkeley + * style. They accept a parameter of type "int" (instead of Berkeley style + * "int *") in order to pass a single integer to the ioctl. These macros + * below are marked with a dummy "int" comment. Dont blame anyone else + * than USL for that braindeadness. It is done here to be a bit source- + * level compatible to SysV. (N.B., within the ioctl, the argument is + * dereferenced by "int *" anyway. The translation is done by the upper- + * level ioctl stuff.) + */ + +/* + * NB: Some of the definitions below apparently override the definitions + * in the KBD section above. But, due to BSDs encoding of the IO direction + * and transfer size, the resulting ioctl cmds differ, so we can take them + * here. The only real conflict would appear if we implemented KDGKBMODE, + * which would be identical to KBDGLEDS above. Since this command is not + * necessary for XFree86 2.0, we omit it. + */ + +/* #define KDGKBMODE _IOR('K', 6, int) */ /* not yet implemented */ + +#define KDSKBMODE _IO('K', 7 /*, int */) +#define K_RAW 0 /* keyboard returns scancodes */ +#define K_XLATE 1 /* keyboard returns ascii */ + +#define KDMKTONE _IO('K', 8 /*, int */) + +/* #define KDGETMODE _IOR('K', 9, int) */ /* not yet implemented */ + +#define KDSETMODE _IO('K', 10 /*, int */) +#define KD_TEXT 0 /* set text mode restore fonts */ +#define KD_GRAPHICS 1 /* set graphics mode */ + +/* we cannot see any sense to support KD_TEXT0 or KD_TEXT1 */ + +#define KDENABIO _IO('K', 60) /* only allowed if euid == 0 */ +#define KDDISABIO _IO('K', 61) + +#define KDGETLED _IOR('K', 65, int) +#define KDSETLED _IO('K', 66 /*, int */) +#define LED_CAP 1 +#define LED_NUM 2 +#define LED_SCR 4 + +#define KDSETRAD _IO('K', 67 /*, int */) + +/* + * Note that since our idea of key mapping is much different from the + * SysV style, we _only_ support mapping layers base (0), shifted (1), + * alt (4), and alt-shift (5), and only for the basic keys (without + * any function keys). This is what XFree86 2.0+ needs to establish + * the default X keysym mapping. + */ +#define GIO_KEYMAP _IOR('k', 6, keymap_t) + +#define VT_OPENQRY _IOR('v', 1, int) +#define VT_SETMODE _IOW('v', 2, vtmode_t) +#define VT_GETMODE _IOR('v', 3, vtmode_t) + +#define VT_RELDISP _IO('v', 4 /*, int */) + +/* acceptable values for the VT_RELDISP command */ + +#define VT_FALSE 0 /* release of VT refused */ +#define VT_TRUE 1 /* VT released */ +#define VT_ACKACQ 2 /* acknowledging VT acquisition */ + + +#define VT_ACTIVATE _IO('v', 5 /*, int */) +#define VT_WAITACTIVE _IO('v', 6 /*, int */) +#define VT_GETACTIVE _IOR('v', 7, int) + +#ifndef _VT_MODE_DECLARED +#define _VT_MODE_DECLARED +struct vt_mode { + char mode; + +#define VT_AUTO 0 /* switching controlled by drvr */ +#define VT_PROCESS 1 /* switching controlled by prog */ + + char waitv; /* not implemented yet SOS */ + short relsig; + short acqsig; + short frsig; /* not implemented yet SOS */ +}; + +typedef struct vt_mode vtmode_t; +#endif /* !_VT_MODE_DECLARED */ + +#define NUM_KEYS 256 +#define NUM_STATES 8 + +#ifndef _KEYMAP_DECLARED +#define _KEYMAP_DECLARED +struct keyent_t { + u_char map[NUM_STATES]; + u_char spcl; + u_char flgs; +}; + +struct keymap { + u_short n_keys; + struct keyent_t key[NUM_KEYS]; +}; + +typedef struct keymap keymap_t; +#endif /* !_KEYMAP_DECLARED */ + +/* end of USL VT compatibility stuff */ + +#endif /* !_MACHINE_PCVT_IOCTL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/perfmon.h ./modules/label/machine/perfmon.h --- ../sys-altq/modules/label/machine/perfmon.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/perfmon.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,262 @@ +/* + * Copyright 1996 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/perfmon.h,v 1.4.4.1 1999/08/29 16:06:44 peter Exp $ + */ + +/* + * Interface to performance-monitoring counters for Intel Pentium and + * Pentium Pro CPUs. + */ + +#ifndef _MACHINE_PERFMON_H_ +#define _MACHINE_PERFMON_H_ + +#ifndef KERNEL +#include +#endif +#include + +#define NPMC 2 + +#define PMIOSETUP _IOW('5', 1, struct pmc) +#define PMIOGET _IOWR('5', 7, struct pmc) +#define PMIOSTART _IOW('5', 2, int) +#define PMIOSTOP _IOW('5', 3, int) +#define PMIOREAD _IOWR('5', 4, struct pmc_data) +#define PMIORESET _IOW('5', 5, int) +#define PMIOTSTAMP _IOR('5', 6, struct pmc_tstamp) + +struct pmc { + int pmc_num; + union { + struct { + unsigned char pmcus_event; + unsigned char pmcus_unit; + unsigned char pmcus_flags; + unsigned char pmcus_mask; + } pmcu_s; + unsigned int pmcu_val; + } pmc_pmcu; +}; + +#define PMC_ALL (-1) + +#define pmc_event pmc_pmcu.pmcu_s.pmcus_event +#define pmc_unit pmc_pmcu.pmcu_s.pmcus_unit +#define pmc_flags pmc_pmcu.pmcu_s.pmcus_flags +#define pmc_mask pmc_pmcu.pmcu_s.pmcus_mask +#define pmc_val pmc_pmcu.pmcu_val + +#define PMCF_USR 0x01 /* count events in user mode */ +#define PMCF_OS 0x02 /* count events in kernel mode */ +#define PMCF_E 0x04 /* use edge-detection mode */ +#define PMCF_PC 0x08 /* PMx output pin control */ +#define PMCF_INT 0x10 /* APIC interrupt enable (do not use) */ +#define PMCF_EN 0x40 /* enable counters */ +#define PMCF_INV 0x80 /* invert counter mask comparison */ + +#define PMCF_SYS_FLAGS (PMCF_INT | PMCF_EN) /* user cannot set */ + +struct pmc_data { + int pmcd_num; + quad_t pmcd_value; +}; + +struct pmc_tstamp { + int pmct_rate; + quad_t pmct_value; +}; + +#ifndef KERNEL + +#define _PATH_PERFMON "/dev/perfmon" + +#else + +/* + * Intra-kernel interface to performance monitoring counters + */ +void perfmon_init __P((void)); +int perfmon_avail __P((void)); +int perfmon_setup __P((int, unsigned int)); +int perfmon_get __P((int, unsigned int *)); +int perfmon_fini __P((int)); +int perfmon_start __P((int)); +int perfmon_stop __P((int)); +int perfmon_read __P((int, quad_t *)); +int perfmon_reset __P((int)); + +/* + * We pass the device down this interface because in the future + * the different counters might be accessed through separate devices. + */ +int perfmon_close __P((dev_t, int, int, struct proc *)); +int perfmon_open __P((dev_t, int, int, struct proc *)); +int perfmon_ioctl __P((dev_t, int, caddr_t, int, struct proc *)); +#endif /* KERNEL */ + +/* + * Pentium Pro performance counters, from Appendix B. + */ +/* Data Cache Unit */ +#define PMC6_DATA_MEM_REFS 0x43 +#define PMC6_DCU_LINES_IN 0x45 +#define PMC6_DCU_M_LINES_IN 0x46 +#define PMC6_DCU_M_LINES_OUT 0x47 +#define PMC6_DCU_MISS_OUTSTANDING 0x48 + +/* Instruction Fetch Unit */ +#define PMC6_IFU_IFETCH 0x80 +#define PMC6_IFU_IFETCH_MISS 0x81 +#define PMC6_ITLB_MISS 0x85 +#define PMC6_IFU_MEM_STALL 0x86 +#define PMC6_ILD_STALL 0x87 + +/* L2 Cache */ +#define PMC6_L2_IFETCH 0x28 /* MESI */ +#define PMC6_L2_LD 0x29 /* MESI */ +#define PMC6_L2_ST 0x2a /* MESI */ +#define PMC6_L2_LINES_IN 0x24 +#define PMC6_L2_LINES_OUT 0x26 +#define PMC6_L2_M_LINES_INM 0x25 +#define PMC6_L2_M_LINES_OUTM 0x27 +#define PMC6_L2_RQSTS 0x2e /* MESI */ +#define PMC6_L2_ADS 0x21 +#define PMC6_L2_DBUS_BUSY 0x22 +#define PMC6_L2_DBUS_BUSY_RD 0x23 + +/* External Bus Logic */ +#define PMC6_BUS_DRDY_CLOCKS 0x62 +#define PMC6_BUS_LOCK_CLOCKS 0x63 +#define PMC6_BUS_REQ_OUTSTANDING 0x60 +#define PMC6_BUS_TRAN_BRD 0x65 +#define PMC6_BUS_TRAN_RFO 0x66 +#define PMC6_BUS_TRAN_WB 0x67 +#define PMC6_BUS_TRAN_IFETCH 0x68 +#define PMC6_BUS_TRAN_INVAL 0x69 +#define PMC6_BUS_TRAN_PWR 0x6a +#define PMC6_BUS_TRAN_P 0x6b +#define PMC6_BUS_TRAN_IO 0x6c +#define PMC6_BUS_TRAN_DEF 0x6d +#define PMC6_BUS_TRAN_BURST 0x6e +#define PMC6_BUS_TRAN_ANY 0x70 +#define PMC6_BUS_TRAN_MEM 0x6f +#define PMC6_BUS_DATA_RCV 0x64 +#define PMC6_BUS_BNR_DRV 0x61 +#define PMC6_BUS_HIT_DRV 0x7a +#define PMC6_BUS_HITM_DRV 0x7b +#define PMC6_BUS_SNOOP_STALL 0x7e + +/* Floating Point Unit */ +#define PMC6_FLOPS 0xc1 /* counter 0 only */ +#define PMC6_FP_COMP_OPS_EXE 0x10 /* counter 0 only */ +#define PMC6_FP_ASSIST 0x11 /* counter 1 only */ +#define PMC6_MUL 0x12 /* counter 1 only */ +#define PMC6_DIV 0x13 /* counter 1 only */ +#define PMC6_CYCLES_DIV_BUSY 0x14 /* counter 0 only */ + +/* Memory Ordering */ +#define PMC6_LD_BLOCKS 0x03 +#define PMC6_SB_DRAINS 0x04 +#define PMC6_MISALIGN_MEM_REF 0x05 + +/* Instruction Decoding and Retirement */ +#define PMC6_INST_RETIRED 0xc0 +#define PMC6_UOPS_RETIRED 0xc2 +#define PMC6_INST_DECODER 0xd0 /* (sic) */ + +/* Interrupts */ +#define PMC6_HW_INT_RX 0xc8 +#define PMC6_CYCLES_INT_MASKED 0xc6 +#define PMC6_CYCLES_INT_PENDING_AND_MASKED 0xc7 + +/* Branches */ +#define PMC6_BR_INST_RETIRED 0xc4 +#define PMC6_BR_MISS_PRED_RETIRED 0xc5 +#define PMC6_BR_TAKEN_RETIRED 0xc9 +#define PMC6_BR_MISS_PRED_TAKEN_RET 0xca +#define PMC6_BR_INST_DECODED 0xe0 +#define PMC6_BTB_MISSES 0xe2 +#define PMC6_BR_BOGUS 0xe4 +#define PMC6_BACLEARS 0xe6 + +/* Stalls */ +#define PMC6_RESOURCE_STALLS 0xa2 +#define PMC6_PARTIAL_RAT_STALLS 0xd2 + +/* Segment Register Loads */ +#define PMC6_SEGMENT_REG_LOADS 0x06 + +/* Clocks */ +#define PMC6_CPU_CLK_UNHALTED 0x79 + +/* + * Pentium Performance Counters + * This list comes from the Harvard people, not Intel. + */ +#define PMC5_DATA_READ 0 +#define PMC5_DATA_WRITE 1 +#define PMC5_DATA_TLB_MISS 2 +#define PMC5_DATA_READ_MISS 3 +#define PMC5_DATA_WRITE_MISS 4 +#define PMC5_WRITE_M_E 5 +#define PMC5_DATA_LINES_WBACK 6 +#define PMC5_DATA_CACHE_SNOOP 7 +#define PMC5_DATA_CACHE_SNOOP_HIT 8 +#define PMC5_MEM_ACCESS_BOTH 9 +#define PMC5_BANK_CONFLICTS 10 +#define PMC5_MISALIGNED_DATA 11 +#define PMC5_INST_READ 12 +#define PMC5_INST_TLB_MISS 13 +#define PMC5_INST_CACHE_MISS 14 +#define PMC5_SEGMENT_REG_LOAD 15 +#define PMC5_BRANCHES 18 +#define PMC5_BTB_HITS 19 +#define PMC5_BRANCH_TAKEN 20 +#define PMC5_PIPELINE_FLUSH 21 +#define PMC5_INST_EXECUTED 22 +#define PMC5_INST_EXECUTED_V 23 +#define PMC5_BUS_UTILIZATION 24 +#define PMC5_WRITE_BACKUP_STALL 25 +#define PMC5_DATA_READ_STALL 26 +#define PMC5_WRITE_E_M_STALL 27 +#define PMC5_LOCKED_BUS 28 +#define PMC5_IO_CYCLE 29 +#define PMC5_NONCACHE_MEMORY 30 +#define PMC5_ADDR_GEN_INTERLOCK 31 +#define PMC5_FLOPS 34 +#define PMC5_BP0_MATCH 35 +#define PMC5_BP1_MATCH 36 +#define PMC5_BP2_MATCH 37 +#define PMC5_BP3_MATCH 38 +#define PMC5_HW_INTR 39 +#define PMC5_DATA_RW 40 +#define PMC5_DATA_RW_MISS 41 + +#endif /* !_MACHINE_PERFMON_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/pmap.h ./modules/label/machine/pmap.h --- ../sys-altq/modules/label/machine/pmap.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/pmap.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,273 @@ +/* + * Copyright (c) 1991 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and William Jolitz of UUNET Technologies Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Derived from hp300 version by Mike Hibler, this version by William + * Jolitz uses a recursive map [a pde points to the page directory] to + * map the page tables using the pagetables themselves. This is done to + * reduce the impact on kernel virtual memory for lots of sparse address + * space, and to reduce the cost of memory to each process. + * + * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 + * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 + * $FreeBSD: src/sys/i386/include/pmap.h,v 1.57.2.4 1999/08/29 16:06:45 peter Exp $ + */ + +#ifndef _MACHINE_PMAP_H_ +#define _MACHINE_PMAP_H_ + +/* + * Page-directory and page-table entires follow this format, with a few + * of the fields not present here and there, depending on a lot of things. + */ + /* ---- Intel Nomenclature ---- */ +#define PG_V 0x001 /* P Valid */ +#define PG_RW 0x002 /* R/W Read/Write */ +#define PG_U 0x004 /* U/S User/Supervisor */ +#define PG_NC_PWT 0x008 /* PWT Write through */ +#define PG_NC_PCD 0x010 /* PCD Cache disable */ +#define PG_A 0x020 /* A Accessed */ +#define PG_M 0x040 /* D Dirty */ +#define PG_PS 0x080 /* PS Page size (0=4k,1=4M) */ +#define PG_G 0x100 /* G Global */ +#define PG_AVAIL1 0x200 /* / Available for system */ +#define PG_AVAIL2 0x400 /* < programmers use */ +#define PG_AVAIL3 0x800 /* \ */ + + +/* Our various interpretations of the above */ +#define PG_W PG_AVAIL1 /* "Wired" pseudoflag */ +#define PG_MANAGED PG_AVAIL2 +#define PG_FRAME (~PAGE_MASK) +#define PG_PROT (PG_RW|PG_U) /* all protection bits . */ +#define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ + +/* + * Page Protection Exception bits + */ + +#define PGEX_P 0x01 /* Protection violation vs. not present */ +#define PGEX_W 0x02 /* during a Write cycle */ +#define PGEX_U 0x04 /* access from User mode (UPL) */ + +/* + * Pte related macros + */ +#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)< 0xffbfffff + */ +#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */ +#ifdef SMP +#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */ +#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */ +#else +#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */ +#endif /* SMP */ +#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */ +#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */ +#define UMAXPTEOFF (NPTEPG-UPAGES_HOLE) /* pte entry for user space end */ + +/* + * XXX doesn't really belong here I guess... + */ +#define ISA_HOLE_START 0xa0000 +#define ISA_HOLE_LENGTH (0x100000-ISA_HOLE_START) + +#ifndef LOCORE + +#include + +typedef unsigned int *pd_entry_t; +typedef unsigned int *pt_entry_t; + +#define PDESIZE sizeof(pd_entry_t) /* for assembly files */ +#define PTESIZE sizeof(pt_entry_t) /* for assembly files */ + +/* + * Address of current and alternate address space page table maps + * and directories. + */ +#ifdef KERNEL +extern pt_entry_t PTmap[], APTmap[], Upte; +extern pd_entry_t PTD[], APTD[], PTDpde, APTDpde, Upde; + +extern pd_entry_t IdlePTD; /* physical address of "Idle" state directory */ +#endif + +#ifdef KERNEL +/* + * virtual address to page table entry and + * to physical address. Likewise for alternate address space. + * Note: these work recursively, thus vtopte of a pte will give + * the corresponding pde that in turn maps it. + */ +#define vtopte(va) (PTmap + i386_btop(va)) + +#define avtopte(va) (APTmap + i386_btop(va)) + +/* + * Routine: pmap_kextract + * Function: + * Extract the physical page address associated + * kernel virtual address. + */ +static __inline vm_offset_t +pmap_kextract(vm_offset_t va) +{ + vm_offset_t pa; + if ((pa = (vm_offset_t) PTD[va >> PDRSHIFT]) & PG_PS) { + pa = (pa & ~(NBPDR - 1)) | (va & (NBPDR - 1)); + } else { + pa = *(vm_offset_t *)vtopte(va); + pa = (pa & PG_FRAME) | (va & PAGE_MASK); + } + return pa; +} + +#if 0 +#define vtophys(va) (((vm_offset_t) (*vtopte(va))&PG_FRAME) | ((vm_offset_t)(va) & PAGE_MASK)) +#else +#define vtophys(va) pmap_kextract(((vm_offset_t) (va))) +#endif + +#define avtophys(va) (((vm_offset_t) (*avtopte(va))&PG_FRAME) | ((vm_offset_t)(va) & PAGE_MASK)) + +#endif + +/* + * Pmap stuff + */ +struct pv_entry; +typedef struct { + int pv_list_count; + struct vm_page *pv_vm_page; + TAILQ_HEAD(,pv_entry) pv_list; +} pv_table_t; + +struct pmap { + pd_entry_t *pm_pdir; /* KVA of page directory */ + vm_object_t pm_pteobj; /* Container for pte's */ + TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ + int pm_count; /* reference count */ + int pm_flags; /* pmap flags */ + struct pmap_statistics pm_stats; /* pmap statistics */ + struct vm_page *pm_ptphint; /* pmap ptp hint */ +}; + +#define pmap_resident_count(pmap) (pmap)->pm_stats.resident_count + +#define PM_FLAG_LOCKED 0x1 +#define PM_FLAG_WANTED 0x2 + +typedef struct pmap *pmap_t; + +#ifdef KERNEL +extern pmap_t kernel_pmap; +#endif + +/* + * For each vm_page_t, there is a list of all currently valid virtual + * mappings of that page. An entry is a pv_entry_t, the list is pv_table. + */ +typedef struct pv_entry { + pmap_t pv_pmap; /* pmap where mapping lies */ + vm_offset_t pv_va; /* virtual address for mapping */ + TAILQ_ENTRY(pv_entry) pv_list; + TAILQ_ENTRY(pv_entry) pv_plist; + vm_page_t pv_ptem; /* VM page for pte */ +} *pv_entry_t; + +#define PV_ENTRY_NULL ((pv_entry_t) 0) + +#define PV_CI 0x01 /* all entries must be cache inhibited */ +#define PV_PTPAGE 0x02 /* entry maps a page table page */ + +#ifdef KERNEL + +#define NPPROVMTRR 8 +#define PPRO_VMTRRphysBase0 0x200 +#define PPRO_VMTRRphysMask0 0x201 +struct ppro_vmtrr { + u_int64_t base, mask; +}; +extern struct ppro_vmtrr PPro_vmtrr[NPPROVMTRR]; + +extern caddr_t CADDR1; +extern pt_entry_t *CMAP1; +extern vm_offset_t avail_end; +extern vm_offset_t avail_start; +extern vm_offset_t clean_eva; +extern vm_offset_t clean_sva; +extern vm_offset_t phys_avail[]; +extern char *ptvmmap; /* poor name! */ +extern vm_offset_t virtual_avail; +extern vm_offset_t virtual_end; + +void pmap_bootstrap __P(( vm_offset_t, vm_offset_t)); +pmap_t pmap_kernel __P((void)); +void *pmap_mapdev __P((vm_offset_t, vm_size_t)); +unsigned *pmap_pte __P((pmap_t, vm_offset_t)) __pure2; +vm_page_t pmap_use_pt __P((pmap_t, vm_offset_t)); +void pmap_set_opt __P((unsigned *)); +void pmap_set_opt_bsp __P((void)); +void getmtrr __P((void)); +void putmtrr __P((void)); +void putfmtrr __P((void)); +void pmap_setdevram __P((unsigned long long, unsigned)); +void pmap_setvidram __P((void)); + +#endif /* KERNEL */ + +#endif /* !LOCORE */ + +#endif /* !_MACHINE_PMAP_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/proc.h ./modules/label/machine/proc.h --- ../sys-altq/modules/label/machine/proc.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/proc.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1991 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 + * $FreeBSD: src/sys/i386/include/proc.h,v 1.8.4.1 1999/08/29 16:06:45 peter Exp $ + */ + +#ifndef _MACHINE_PROC_H_ +#define _MACHINE_PROC_H_ + +/* + * Machine-dependent part of the proc structure for i386. + */ +struct mdproc { + struct trapframe *md_regs; /* registers on current frame */ +}; + +#endif /* !_MACHINE_PROC_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/profile.h ./modules/label/machine/profile.h --- ../sys-altq/modules/label/machine/profile.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/profile.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,162 @@ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD: src/sys/i386/include/profile.h,v 1.18.2.1 1999/08/29 16:06:45 peter Exp $ + */ + +#ifndef _MACHINE_PROFILE_H_ +#define _MACHINE_PROFILE_H_ + +#ifdef KERNEL + +/* + * Config generates something to tell the compiler to align functions on 16 + * byte boundaries. A strict alignment is good for keeping the tables small. + */ +#define FUNCTION_ALIGNMENT 16 + +/* + * The kernel uses assembler stubs instead of unportable inlines. + * This is mainly to save a little time when profiling is not enabled, + * which is the usual case for the kernel. + */ +#define _MCOUNT_DECL void mcount +#define MCOUNT + +#ifdef GUPROF +#define CALIB_SCALE 1000 +#define KCOUNT(p,index) ((p)->kcount[(index) \ + / (HISTFRACTION * sizeof(HISTCOUNTER))]) +#define MCOUNT_DECL(s) +#define MCOUNT_ENTER(s) +#define MCOUNT_EXIT(s) +#define PC_TO_I(p, pc) ((uintfptr_t)(pc) - (uintfptr_t)(p)->lowpc) +#else +#define MCOUNT_DECL(s) u_long s; +#ifdef SMP +#define MCOUNT_ENTER(s) { s = read_eflags(); \ + __asm __volatile("cli" : : : "memory"); \ + s_lock_np(&mcount_lock); } +#define MCOUNT_EXIT(s) { s_unlock_np(&mcount_lock); write_eflags(s); } +#else +#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); } +#define MCOUNT_EXIT(s) (write_eflags(s)) +#endif +#endif /* GUPROF */ + +#else /* !KERNEL */ + +#define FUNCTION_ALIGNMENT 4 + +#define _MCOUNT_DECL static __inline void _mcount + +#define MCOUNT \ +void \ +mcount() \ +{ \ + uintfptr_t selfpc, frompc; \ + /* \ + * Find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by call to mcount \ + */ \ + asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \ + /* \ + * frompc = pc pushed by call to mcount's caller. \ + * The caller's stack frame has already been built, so %ebp is \ + * the caller's frame pointer. The caller's raddr is in the \ + * caller's frame following the caller's caller's frame pointer. \ + */ \ + asm("movl (%%ebp),%0" : "=r" (frompc)); \ + frompc = ((uintfptr_t *)frompc)[1]; \ + _mcount(frompc, selfpc); \ +} + +typedef unsigned int uintfptr_t; + +#endif /* KERNEL */ + +/* + * An unsigned integral type that can hold non-negative difference between + * function pointers. + */ +typedef u_int fptrdiff_t; + +#ifdef KERNEL + +void mcount __P((uintfptr_t frompc, uintfptr_t selfpc)); + +#ifdef GUPROF +struct gmonparam; + +void nullfunc_loop_profiled __P((void)); +void nullfunc_profiled __P((void)); +void startguprof __P((struct gmonparam *p)); +void stopguprof __P((struct gmonparam *p)); +#else +#define startguprof(p) +#define stopguprof(p) +#endif /* GUPROF */ + +#else /* !KERNEL */ + +#include + +__BEGIN_DECLS +#ifdef __GNUC__ +#ifdef __ELF__ +void mcount __P((void)) __asm(".mcount"); +#else +void mcount __P((void)) __asm("mcount"); +#endif +#endif +static void _mcount __P((uintfptr_t frompc, uintfptr_t selfpc)); +__END_DECLS + +#endif /* KERNEL */ + +#ifdef GUPROF +/* XXX doesn't quite work outside kernel yet. */ +extern int cputime_bias; + +__BEGIN_DECLS +int cputime __P((void)); +void empty_loop __P((void)); +void mexitcount __P((uintfptr_t selfpc)); +void nullfunc __P((void)); +void nullfunc_loop __P((void)); +__END_DECLS +#endif + +#endif /* !_MACHINE_PROFILE_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/psl.h ./modules/label/machine/psl.h --- ../sys-altq/modules/label/machine/psl.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/psl.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)psl.h 5.2 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/psl.h,v 1.9.4.1 1999/08/29 16:06:46 peter Exp $ + */ + +#ifndef _MACHINE_PSL_H_ +#define _MACHINE_PSL_H_ + +/* + * 386 processor status longword. + */ +#define PSL_C 0x00000001 /* carry bit */ +#define PSL_PF 0x00000004 /* parity bit */ +#define PSL_AF 0x00000010 /* bcd carry bit */ +#define PSL_Z 0x00000040 /* zero bit */ +#define PSL_N 0x00000080 /* negative bit */ +#define PSL_T 0x00000100 /* trace enable bit */ +#define PSL_I 0x00000200 /* interrupt enable bit */ +#define PSL_D 0x00000400 /* string instruction direction bit */ +#define PSL_V 0x00000800 /* overflow bit */ +#define PSL_IOPL 0x00003000 /* i/o privilege level */ +#define PSL_NT 0x00004000 /* nested task bit */ +#define PSL_RF 0x00010000 /* resume flag bit */ +#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ +#define PSL_AC 0x00040000 /* alignment checking */ +#define PSL_VIF 0x00080000 /* virtual interrupt enable */ +#define PSL_VIP 0x00100000 /* virtual interrupt pending */ +#define PSL_ID 0x00200000 /* identification bit */ + +/* + * The i486 manual says that we are not supposed to change reserved flags, + * but this is too much trouble since the reserved flags depend on the cpu + * and setting them to their historical values works in practice. + */ +#define PSL_RESERVED_DEFAULT 0x00000002 + +/* + * Initial flags for kernel and user mode. The kernel later inherits + * PSL_I and some other flags from user mode. + */ +#define PSL_KERNEL PSL_RESERVED_DEFAULT +#define PSL_USER (PSL_RESERVED_DEFAULT | PSL_I) + +/* + * Bits that can be changed in user mode on 486's. We allow these bits + * to be changed using ptrace(), sigreturn() and procfs. Setting PS_NT + * is undesirable but it may as well be allowed since users can inflict + * it on the kernel directly. Changes to PSL_AC are silently ignored on + * 386's. + */ +#define PSL_USERCHANGE (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_T \ + | PSL_D | PSL_V | PSL_NT | PSL_AC) + +#endif /* !_MACHINE_PSL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ptrace.h ./modules/label/machine/ptrace.h --- ../sys-altq/modules/label/machine/ptrace.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ptrace.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD: src/sys/i386/include/ptrace.h,v 1.6.2.1 1999/08/29 16:06:46 peter Exp $ + */ + +#ifndef _MACHINE_PTRACE_H_ +#define _MACHINE_PTRACE_H_ + +/* + * Machine dependent trace commands. + */ +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) + +#ifdef KERNEL +int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len)); +#endif /* !KERNEL */ + +#endif + diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/random.h ./modules/label/machine/random.h --- ../sys-altq/modules/label/machine/random.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/random.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,90 @@ +/* + * random.h -- A strong random number generator + * + * $FreeBSD: src/sys/i386/include/random.h,v 1.16.2.1 1999/08/29 16:06:47 peter Exp $ + * + * Version 0.95, last modified 18-Oct-95 + * + * Copyright Theodore Ts'o, 1994, 1995. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * ALTERNATIVELY, this product may be distributed under the terms of + * the GNU Public License, in which case the provisions of the GPL are + * required INSTEAD OF the above restrictions. (This clause is + * necessary due to a potential bad interaction between the GPL and + * the restrictions contained in a BSD-style copyright.) + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Many kernel routines will have a use for good random numbers, + * for example, for truely random TCP sequence numbers, which prevent + * certain forms of TCP spoofing attacks. + * + */ + +#ifndef _MACHINE_RANDOM_H_ +#define _MACHINE_RANDOM_H_ + +#include + +#define MEM_SETIRQ _IOW('r', 1, u_int16_t) /* set interrupt */ +#define MEM_CLEARIRQ _IOW('r', 2, u_int16_t) /* clear interrupt */ +#define MEM_RETURNIRQ _IOR('r', 3, u_int16_t) /* return interrupt */ + +#ifdef KERNEL + +/* Type of the cookie passed to add_interrupt_randomness. */ + +struct random_softc { + inthand2_t *sc_handler; + void *sc_arg; + int sc_intr; +}; + +/* Exported functions */ + +void rand_initialize(void); +void add_keyboard_randomness(u_char scancode); +inthand2_t add_interrupt_randomness; +#ifdef notused +void add_blkdev_randomness(int major); +#endif + +#ifdef notused +void get_random_bytes(void *buf, u_int nbytes); +#endif +u_int read_random(void *buf, u_int size); +u_int read_random_unlimited(void *buf, u_int size); +#ifdef notused +u_int write_random(const char *buf, u_int nbytes); +#endif +int random_poll(dev_t dev, int events, struct proc *p); + +#endif /* KERNEL */ + +#endif /* !_MACHINE_RANDOM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/reg.h ./modules/label/machine/reg.h --- ../sys-altq/modules/label/machine/reg.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/reg.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,130 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/reg.h,v 1.16.2.2 1999/08/29 16:06:47 peter Exp $ + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Indices for registers in `struct trapframe' and `struct regs'. + * + * This interface is deprecated. In the kernel, it is only used in FPU + * emulators to convert from register numbers encoded in instructions to + * register values. Everything else just accesses the relevant struct + * members. In userland, debuggers tend to abuse this interface since + * they don't understand that `struct regs' is a struct. I hope they have + * stopped accessing the registers in the trap frame via PT_{READ,WRITE}_U + * and we can stop supporting the user area soon. + */ +#define tES (0) +#define tDS (1) +#define tEDI (2) +#define tESI (3) +#define tEBP (4) +#define tISP (5) +#define tEBX (6) +#define tEDX (7) +#define tECX (8) +#define tEAX (9) +#define tERR (11) +#define tEIP (12) +#define tCS (13) +#define tEFLAGS (14) +#define tESP (15) +#define tSS (16) + +/* + * Indices for registers in `struct regs' only. + * + * Some registers live in the pcb and are only in an "array" with the + * other registers in application interfaces that copy all the registers + * to or from a `struct regs'. + */ +#define tFS (17) +#define tGS (18) + +/* + * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS. + */ +struct reg { + unsigned int r_es; + unsigned int r_ds; + unsigned int r_edi; + unsigned int r_esi; + unsigned int r_ebp; + unsigned int r_isp; + unsigned int r_ebx; + unsigned int r_edx; + unsigned int r_ecx; + unsigned int r_eax; + unsigned int r_trapno; + unsigned int r_err; + unsigned int r_eip; + unsigned int r_cs; + unsigned int r_eflags; + unsigned int r_esp; + unsigned int r_ss; + unsigned int r_fs; + unsigned int r_gs; +}; + +/* + * Register set accessible via /proc/$pid/fpregs. + */ +struct fpreg { + /* + * XXX should get struct from npx.h. Here we give a slightly + * simplified struct. This may be too much detail. Perhaps + * an array of unsigned longs is best. + */ + unsigned long fpr_env[7]; + unsigned char fpr_acc[8][10]; + unsigned long fpr_ex_sw; + unsigned char fpr_pad[64]; +}; + +#ifdef KERNEL +/* + * XXX these interfaces are MI, so they should be declared in a MI place. + */ +int set_fpregs __P((struct proc *, struct fpreg *)); +int set_regs __P((struct proc *p, struct reg *regs)); +void setregs __P((struct proc *, u_long, u_long, u_long)); +#endif + +#endif /* !_MACHINE_REG_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/reloc.h ./modules/label/machine/reloc.h --- ../sys-altq/modules/label/machine/reloc.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/reloc.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)reloc.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/i386/include/reloc.h,v 1.6.4.1 1999/08/29 16:06:48 peter Exp $ + */ + +#ifndef _I386_MACHINE_RELOC_H_ +#define _I386_MACHINE_RELOC_H_ + +/* Relocation format. */ +struct relocation_info { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_pcrel : 1, /* 1 if value should be pc-relative */ + r_length : 2, /* log base 2 of value's width */ + r_extern : 1, /* 1 if need to add symbol to value */ + r_baserel : 1, /* linkage table relative */ + r_jmptable : 1, /* relocate to jump table */ + r_relative : 1, /* load address relative */ + r_copy : 1; /* run time copy */ +}; + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/resource.h ./modules/label/machine/resource.h --- ../sys-altq/modules/label/machine/resource.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/resource.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,43 @@ +/* + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_RESOURCE_H_ +#define _MACHINE_RESOURCE_H_ 1 + +/* + * Definitions of resource types for Intel Architecture machines + * with support for legacy ISA devices and drivers. + */ + +#define SYS_RES_IRQ 1 +#define SYS_RES_DRQ 2 +#define SYS_RES_MEMORY 3 +#define SYS_RES_IOPORT 4 + +#endif /* !_MACHINE_RESOURCE_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/segments.h ./modules/label/machine/segments.h --- ../sys-altq/modules/label/machine/segments.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/segments.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,255 @@ +/*- + * Copyright (c) 1989, 1990 William F. Jolitz + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 + * $FreeBSD: src/sys/i386/include/segments.h,v 1.17.2.1 1999/08/29 16:06:48 peter Exp $ + */ + +#ifndef _MACHINE_SEGMENTS_H_ +#define _MACHINE_SEGMENTS_H_ + +/* + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +/* + * Selectors + */ + +#define ISPL(s) ((s)&3) /* what is the priority level of a selector */ +#define SEL_KPL 0 /* kernel priority level */ +#define SEL_UPL 3 /* user priority level */ +#define ISLDT(s) ((s)&SEL_LDT) /* is it local or global */ +#define SEL_LDT 4 /* local descriptor table */ +#define IDXSEL(s) (((s)>>3) & 0x1fff) /* index of selector */ +#define LSEL(s,r) (((s)<<3) | SEL_LDT | r) /* a local selector */ +#define GSEL(s,r) (((s)<<3) | r) /* a global selector */ + +/* + * Memory and System segment descriptors + */ +struct segment_descriptor { + unsigned sd_lolimit:16 ; /* segment extent (lsb) */ + unsigned sd_lobase:24 __attribute__ ((packed)); + /* segment base address (lsb) */ + unsigned sd_type:5 ; /* segment type */ + unsigned sd_dpl:2 ; /* segment descriptor priority level */ + unsigned sd_p:1 ; /* segment descriptor present */ + unsigned sd_hilimit:4 ; /* segment extent (msb) */ + unsigned sd_xx:2 ; /* unused */ + unsigned sd_def32:1 ; /* default 32 vs 16 bit size */ + unsigned sd_gran:1 ; /* limit granularity (byte/page units)*/ + unsigned sd_hibase:8 ; /* segment base address (msb) */ +} ; + +/* + * Gate descriptors (e.g. indirect descriptors) + */ +struct gate_descriptor { + unsigned gd_looffset:16 ; /* gate offset (lsb) */ + unsigned gd_selector:16 ; /* gate segment selector */ + unsigned gd_stkcpy:5 ; /* number of stack wds to cpy */ + unsigned gd_xx:3 ; /* unused */ + unsigned gd_type:5 ; /* segment type */ + unsigned gd_dpl:2 ; /* segment descriptor priority level */ + unsigned gd_p:1 ; /* segment descriptor present */ + unsigned gd_hioffset:16 ; /* gate offset (msb) */ +} ; + +/* + * Generic descriptor + */ +union descriptor { + struct segment_descriptor sd; + struct gate_descriptor gd; +}; + + /* system segments and gate types */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYS386TSS 9 /* system 386 TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYS386BSY 11 /* system 386 TSS busy */ +#define SDT_SYS386CGT 12 /* system 386 call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ +#define SDT_SYS386TGT 15 /* system 386 trap gate */ + + /* memory segment types */ +#define SDT_MEMRO 16 /* memory read only */ +#define SDT_MEMROA 17 /* memory read only accessed */ +#define SDT_MEMRW 18 /* memory read write */ +#define SDT_MEMRWA 19 /* memory read write accessed */ +#define SDT_MEMROD 20 /* memory read only expand dwn limit */ +#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */ +#define SDT_MEME 24 /* memory execute only */ +#define SDT_MEMEA 25 /* memory execute only accessed */ +#define SDT_MEMER 26 /* memory execute read */ +#define SDT_MEMERA 27 /* memory execute read accessed */ +#define SDT_MEMEC 28 /* memory execute only conforming */ +#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ +#define SDT_MEMERC 30 /* memory execute read conforming */ +#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ + +/* is memory segment descriptor pointer ? */ +#define ISMEMSDP(s) ((s->d_type) >= SDT_MEMRO && (s->d_type) <= SDT_MEMERAC) + +/* is 286 gate descriptor pointer ? */ +#define IS286GDP(s) (((s->d_type) >= SDT_SYS286CGT \ + && (s->d_type) < SDT_SYS286TGT)) + +/* is 386 gate descriptor pointer ? */ +#define IS386GDP(s) (((s->d_type) >= SDT_SYS386CGT \ + && (s->d_type) < SDT_SYS386TGT)) + +/* is gate descriptor pointer ? */ +#define ISGDP(s) (IS286GDP(s) || IS386GDP(s)) + +/* is segment descriptor pointer ? */ +#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s)) + +/* is system segment descriptor pointer ? */ +#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s)) + +/* + * Software definitions are in this convenient format, + * which are translated into inconvenient segment descriptors + * when needed to be used by the 386 hardware + */ + +struct soft_segment_descriptor { + unsigned ssd_base ; /* segment base address */ + unsigned ssd_limit ; /* segment extent */ + unsigned ssd_type:5 ; /* segment type */ + unsigned ssd_dpl:2 ; /* segment descriptor priority level */ + unsigned ssd_p:1 ; /* segment descriptor present */ + unsigned ssd_xx:4 ; /* unused */ + unsigned ssd_xx1:2 ; /* unused */ + unsigned ssd_def32:1 ; /* default 32 vs 16 bit size */ + unsigned ssd_gran:1 ; /* limit granularity (byte/page units)*/ +}; + +/* + * region descriptors, used to load gdt/idt tables before segments yet exist. + */ +struct region_descriptor { + unsigned rd_limit:16; /* segment extent */ + unsigned rd_base:32 __attribute__ ((packed)); /* base address */ +}; + +/* + * Segment Protection Exception code bits + */ + +#define SEGEX_EXT 0x01 /* recursive or externally induced */ +#define SEGEX_IDT 0x02 /* interrupt descriptor table */ +#define SEGEX_TI 0x04 /* local descriptor table */ + /* other bits are affected descriptor index */ +#define SEGEX_IDX(s) ((s)>>3)&0x1fff) + +/* + * Size of IDT table + */ + +#if defined(SMP) || defined(APIC_IO) +#define NIDT 256 /* we use them all */ +#else +#define NIDT 129 /* 32 reserved, 16 h/w, 0 s/w, linux's 0x80 */ +#endif /* SMP || APIC_IO */ +#define NRSVIDT 32 /* reserved entries for cpu exceptions */ + +/* + * Entries in the Global Descriptor Table (GDT) + */ +#define GNULL_SEL 0 /* Null Descriptor */ +#define GCODE_SEL 1 /* Kernel Code Descriptor */ +#define GDATA_SEL 2 /* Kernel Data Descriptor */ +#define GLDT_SEL 3 /* LDT - eventually one per process */ +#define GTGATE_SEL 4 /* Process task switch gate */ +#define GPANIC_SEL 5 /* Task state to consider panic from */ +#define GPROC0_SEL 6 /* Task state process slot zero and up */ +#define GUSERLDT_SEL 7 /* User LDT */ +#define GAPMCODE32_SEL 8 /* APM BIOS 32-bit interface (32bit Code) */ +#define GAPMCODE16_SEL 9 /* APM BIOS 32-bit interface (16bit Code) */ +#define GAPMDATA_SEL 10 /* APM BIOS 32-bit interface (Data) */ + +#ifdef BDE_DEBUGGER +#define NGDT 18 /* some of 11-17 are reserved for debugger */ +#else +#define NGDT (GAPMDATA_SEL + 1) +#endif + +/* + * Entries in the Local Descriptor Table (LDT) + */ +#define LSYS5CALLS_SEL 0 /* forced by intel BCS */ +#define LSYS5SIGR_SEL 1 +#define L43BSDCALLS_SEL 2 /* notyet */ +#define LUCODE_SEL 3 +#define LUDATA_SEL 4 +/* separate stack, es,fs,gs sels ? */ +/* #define LPOSIXCALLS_SEL 5*/ /* notyet */ +#define LBSDICALLS_SEL 16 /* BSDI system call gate */ +#define NLDT (LBSDICALLS_SEL + 1) + +#ifdef KERNEL +extern int currentldt; +extern int _default_ldt; +extern union descriptor gdt[]; +extern struct soft_segment_descriptor gdt_segs[]; +extern struct gate_descriptor idt[NIDT]; +extern union descriptor ldt[NLDT]; + +void lgdt __P((struct region_descriptor *rdp)); +void lidt __P((struct region_descriptor *rdp)); +void lldt __P((u_short sel)); +void sdtossd __P((struct segment_descriptor *sdp, + struct soft_segment_descriptor *ssdp)); +void ssdtosd __P((struct soft_segment_descriptor *ssdp, + struct segment_descriptor *sdp)); +#endif /* KERNEL */ + +#endif /* !_MACHINE_SEGMENTS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/setjmp.h ./modules/label/machine/setjmp.h --- ../sys-altq/modules/label/machine/setjmp.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/setjmp.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,46 @@ +/* $FreeBSD: src/sys/i386/include/setjmp.h,v 1.2.2.1 1999/08/29 16:06:48 peter Exp $ */ +/* + * Copyright (c) 1998 John Birrell . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Birrell. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#define _JBLEN 8 /* Size of the jmp_buf on x86. */ + +/* + * jmp_buf and sigjmp_buf are encapsulated in different structs to force + * compile-time diagnostics for mismatches. The structs are the same + * internally to avoid some run-time errors for mismatches. + */ +#ifndef _ANSI_SOURCE +typedef struct { int _sjb[_JBLEN + 1]; } sigjmp_buf[1]; +#endif /* not ANSI */ + +typedef struct { int _jb[_JBLEN + 1]; } jmp_buf[1]; diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/si.h ./modules/label/machine/si.h --- ../sys-altq/modules/label/machine/si.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/si.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,495 @@ +/* + * Device driver for Specialix range (SI/XIO) of serial line multiplexors. + * 'C' definitions for Specialix serial multiplex driver. + * + * Copyright (C) 1990, 1992, 1998 Specialix International, + * Copyright (C) 1993, Andy Rutter + * Copyright (C) 1995, Peter Wemm + * + * Derived from: SunOS 4.x version + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notices, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notices, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Andy Rutter of + * Advanced Methods and Tools Ltd. based on original information + * from Specialix International. + * 4. Neither the name of Advanced Methods and Tools, nor Specialix + * International may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHORS BE LIABLE. + * + * $FreeBSD: src/sys/i386/include/si.h,v 1.13.2.1 1999/08/29 16:06:49 peter Exp $ + */ + +#include + +/* + * Macro to turn a device number into various parameters, and test for + * CONTROL device. + * max of 4 controllers with up to 32 ports per controller. + * minor device allocation is: + * adapter port + * 0 0-31 + * 1 32-63 + * 2 64-95 + * 3 96-127 + */ +#define SI_MAXPORTPERCARD 32 +#define SI_MAXCONTROLLER 4 + + +/* + * breakup of minor device number: + * lowest 5 bits: port number on card 0x1f + * next 2 bits: card number 0x60 + * top bit: callout 0x80 + * next 8 bits is the major number + * next 2 bits select initial/lock states + * next 1 bit selects the master control device + */ + +#define SI_PORT_MASK 0x1f +#define SI_CARD_MASK 0x60 +#define SI_TTY_MASK 0x7f +#define SI_CALLOUT_MASK 0x80 +#define SI_INIT_STATE_MASK 0x10000 +#define SI_LOCK_STATE_MASK 0x20000 +#define SI_STATE_MASK 0x30000 +#define SI_CONTROLDEV_MASK 0x40000 +#define SI_SPECIAL_MASK 0x70000 + +#define SI_CARDSHIFT 5 +#define SI_PORT(m) (m & SI_PORT_MASK) +#define SI_CARD(m) ((m & SI_CARD_MASK) >> SI_CARDSHIFT) +#define SI_TTY(m) (m & SI_TTY_MASK) + +#define IS_CALLOUT(m) (m & SI_CALLOUT_MASK) +#define IS_STATE(m) (m & SI_STATE_MASK) +#define IS_CONTROLDEV(m) (m & SI_CONTROLDEV_MASK) +#define IS_SPECIAL(m) (m & SI_SPECIAL_MASK) + +#define MINOR2SC(m) (&si_softc[SI_CARD(m)]) +#define MINOR2PP(m) (MINOR2SC((m))->sc_ports + SI_PORT((m))) +#define MINOR2TP(m) (MINOR2PP((m))->sp_tty) +#define TP2PP(tp) (MINOR2PP(SI_TTY(minor((tp)->t_dev)))) + +/* Adapter types */ +#define SIEMPTY 0 +#define SIHOST 1 +#define SIMCA 2 +#define SIHOST2 3 +#define SIEISA 4 +#define SIPCI 5 +#define SIJETPCI 6 +#define SIJETISA 7 + +#define SI_ISJET(x) (((x) == SIJETPCI) || ((x) == SIJETISA)) + +/* Buffer parameters */ +#define SI_BUFFERSIZE 256 + +typedef unsigned char BYTE; /* Type cast for unsigned 8 bit */ +typedef unsigned short WORD; /* Type cast for unsigned 16 bit */ + + +/* + * Hardware `registers', stored in the shared memory. + * These are related to the firmware running on the Z280. + */ + +struct si_reg { + BYTE initstat; + BYTE memsize; + WORD int_count; + WORD revision; + BYTE rx_int_count; /* isr_count on Jet */ + BYTE main_count; /* spare on Z-280 */ + WORD int_pending; + WORD int_counter; + BYTE int_scounter; + BYTE res[0x80 - 13]; +}; + +/* + * Per module control structure, stored in shared memory. + */ +struct si_module { + WORD sm_next; /* Next module */ + BYTE sm_type; /* Number of channels */ + BYTE sm_number; /* Module number on cable */ + BYTE sm_dsr; /* Private dsr copy */ + BYTE sm_res[0x80 - 5]; /* Reserve space to 128 bytes */ +}; + +/* + * The 'next' pointer & with 0x7fff + SI base addres give + * the address of the next module block if fitted. (else 0) + * Note that next points to the TX buffer so 0x60 must be + * subtracted to find the true base. + */ +#define TA4 0x00 +#define TA8 0x08 +#define TA4_ASIC 0x0A +#define TA8_ASIC 0x0B +#define MTA 0x28 +#define SXDC 0x48 + +/* + * Per channel(port) control structure, stored in shared memory. + */ +struct si_channel { + /* + * Generic stuff + */ + WORD next; /* Next Channel */ + WORD addr_uart; /* Uart address */ + WORD module; /* address of module struct */ + BYTE type; /* Uart type */ + BYTE fill; + /* + * Uart type specific stuff + */ + BYTE x_status; /* XON / XOFF status */ + BYTE c_status; /* cooking status */ + BYTE hi_rxipos; /* stuff into rx buff */ + BYTE hi_rxopos; /* stuff out of rx buffer */ + BYTE hi_txopos; /* Stuff into tx ptr */ + BYTE hi_txipos; /* ditto out */ + BYTE hi_stat; /* Command register */ + BYTE dsr_bit; /* Magic bit for DSR */ + BYTE txon; /* TX XON char */ + BYTE txoff; /* ditto XOFF */ + BYTE rxon; /* RX XON char */ + BYTE rxoff; /* ditto XOFF */ + BYTE hi_mr1; /* mode 1 image */ + BYTE hi_mr2; /* mode 2 image */ + BYTE hi_csr; /* clock register */ + BYTE hi_op; /* Op control */ + BYTE hi_ip; /* Input pins */ + BYTE hi_state; /* status */ + BYTE hi_prtcl; /* Protocol */ + BYTE hi_txon; /* host copy tx xon stuff */ + BYTE hi_txoff; + BYTE hi_rxon; + BYTE hi_rxoff; + BYTE close_prev; /* Was channel previously closed */ + BYTE hi_break; /* host copy break process */ + BYTE break_state; /* local copy ditto */ + BYTE hi_mask; /* Mask for CS7 etc. */ + BYTE mask_z280; /* Z280's copy */ + BYTE res[0x60 - 36]; + BYTE hi_txbuf[SI_BUFFERSIZE]; + BYTE hi_rxbuf[SI_BUFFERSIZE]; + BYTE res1[0xA0]; +}; + +/* + * Register definitions + */ + +/* + * Break input control register definitions + */ +#define BR_IGN 0x01 /* Ignore any received breaks */ +#define BR_INT 0x02 /* Interrupt on received break */ +#define BR_PARMRK 0x04 /* Enable parmrk parity error processing */ +#define BR_PARIGN 0x08 /* Ignore chars with parity errors */ + +/* + * Protocol register provided by host for XON/XOFF and cooking + */ +#define SP_TANY 0x01 /* Tx XON any char */ +#define SP_TXEN 0x02 /* Tx XON/XOFF enabled */ +#define SP_CEN 0x04 /* Cooking enabled */ +#define SP_RXEN 0x08 /* Rx XON/XOFF enabled */ +#define SP_DCEN 0x20 /* DCD / DTR check */ +#define SP_PAEN 0x80 /* Parity checking enabled */ + +/* + * HOST STATUS / COMMAND REGISTER + */ +#define IDLE_OPEN 0x00 /* Default mode, TX and RX polled + buffer updated etc */ +#define LOPEN 0x02 /* Local open command (no modem ctl */ +#define MOPEN 0x04 /* Open and monitor modem lines (blocks + for DCD */ +#define MPEND 0x06 /* Wating for DCD */ +#define CONFIG 0x08 /* Channel config has changed */ +#define CLOSE 0x0A /* Close channel */ +#define SBREAK 0x0C /* Start break */ +#define EBREAK 0x0E /* End break */ +#define IDLE_CLOSE 0x10 /* Closed channel */ +#define IDLE_BREAK 0x12 /* In a break */ +#define FCLOSE 0x14 /* Force a close */ +#define RESUME 0x16 /* Clear a pending xoff */ +#define WFLUSH 0x18 /* Flush output buffer */ +#define RFLUSH 0x1A /* Flush input buffer */ + +/* + * Host status register + */ +#define ST_BREAK 0x01 /* Break received (clear with config) */ + +/* + * OUTPUT PORT REGISTER + */ +#define OP_CTS 0x01 /* Enable CTS */ +#define OP_DSR 0x02 /* Enable DSR */ +/* + * INPUT PORT REGISTER + */ +#define IP_DCD 0x04 /* DCD High */ +#define IP_DTR 0x20 /* DTR High */ +#define IP_RTS 0x02 /* RTS High */ +#define IP_RI 0x40 /* RI High */ + +/* + * Mode register and uart specific stuff + */ +/* + * MODE REGISTER 1 + */ +#define MR1_5_BITS 0x00 +#define MR1_6_BITS 0x01 +#define MR1_7_BITS 0x02 +#define MR1_8_BITS 0x03 +/* + * Parity + */ +#define MR1_ODD 0x04 +#define MR1_EVEN 0x00 +/* + * Parity mode + */ +#define MR1_WITH 0x00 +#define MR1_FORCE 0x08 +#define MR1_NONE 0x10 +#define MR1_SPECIAL 0x18 +/* + * Error mode + */ +#define MR1_CHAR 0x00 +#define MR1_BLOCK 0x20 +/* + * Request to send line automatic control + */ +#define MR1_CTSCONT 0x80 + +/* + * MODE REGISTER 2 + */ +/* + * Number of stop bits + */ +#define MR2_1_STOP 0x07 +#define MR2_2_STOP 0x0F +/* + * Clear to send automatic testing before character sent + */ +#define MR2_RTSCONT 0x10 +/* + * Reset RTS automatically after sending character? + */ +#define MR2_CTSCONT 0x20 +/* + * Channel mode + */ +#define MR2_NORMAL 0x00 +#define MR2_AUTO 0x40 +#define MR2_LOCAL 0x80 +#define MR2_REMOTE 0xC0 + +/* + * CLOCK SELECT REGISTER - this and the code assumes ispeed == ospeed + */ +/* + * Clocking rates are in lower and upper nibbles.. R = upper, T = lower + */ +#define CLK75 0x0 +#define CLK110 0x1 /* 110 on XIO!! */ +#define CLK38400 0x2 /* out of sequence */ +#define CLK150 0x3 +#define CLK300 0x4 +#define CLK600 0x5 +#define CLK1200 0x6 +#define CLK2000 0x7 +#define CLK2400 0x8 +#define CLK4800 0x9 +#define CLK7200 0xa /* unchecked */ +#define CLK9600 0xb +#define CLK19200 0xc +#define CLK57600 0xd + +/* + * Per-port (channel) soft information structure, stored in the driver. + * This is visible via ioctl()'s. + */ +struct si_port { + volatile struct si_channel *sp_ccb; + struct tty *sp_tty; + int sp_pend; /* pending command */ + int sp_last_hi_ip; /* cached DCD */ + int sp_state; + int sp_active_out; /* callout is open */ + int sp_dtr_wait; /* DTR holddown in hz */ + int sp_delta_overflows; + u_int sp_wopeners; /* # procs waiting DCD */ + u_char sp_hotchar; /* ldisc specific ASAP char */ + /* Initial state. */ + struct termios sp_iin; + struct termios sp_iout; + /* Lock state. */ + struct termios sp_lin; + struct termios sp_lout; + struct callout_handle lstart_ch;/* For canceling our timeout */ +#ifdef SI_DEBUG + int sp_debug; /* debug mask */ +#endif +}; + +/* sp_state */ +#define SS_CLOSED 0x0000 +#define SS_OPEN 0x0001 /* Port is active */ +/* 0x0002 -- */ +/* 0x0004 -- */ +/* 0x0008 -- */ +/* 0x0010 -- */ +/* 0x0020 -- */ +/* 0x0040 -- */ +/* 0x0080 -- */ +#define SS_LSTART 0x0100 /* lstart timeout pending */ +#define SS_INLSTART 0x0200 /* running an lstart induced t_oproc */ +#define SS_CLOSING 0x0400 /* in the middle of a siclose() */ +/* 0x0800 -- */ +#define SS_WAITWRITE 0x1000 +#define SS_BLOCKWRITE 0x2000 +#define SS_DTR_OFF 0x4000 /* DTR held off */ + +/* + * Command post flags + */ +#define SI_NOWAIT 0x00 /* Don't wait for command */ +#define SI_WAIT 0x01 /* Wait for complete */ + +/* + * Extensive debugging stuff - manipulated using siconfig(8) + */ +#define DBG_ENTRY 0x00000001 +#define DBG_DRAIN 0x00000002 +#define DBG_OPEN 0x00000004 +#define DBG_CLOSE 0x00000008 +#define DBG_READ 0x00000010 +#define DBG_WRITE 0x00000020 +#define DBG_PARAM 0x00000040 +#define DBG_INTR 0x00000080 +#define DBG_IOCTL 0x00000100 +/* 0x00000200 */ +#define DBG_SELECT 0x00000400 +#define DBG_OPTIM 0x00000800 +#define DBG_START 0x00001000 +#define DBG_EXIT 0x00002000 +#define DBG_FAIL 0x00004000 +#define DBG_STOP 0x00008000 +#define DBG_AUTOBOOT 0x00010000 +#define DBG_MODEM 0x00020000 +#define DBG_DOWNLOAD 0x00040000 +#define DBG_LSTART 0x00080000 +#define DBG_POLL 0x00100000 +#define DBG_ALL 0xffffffff + +/* + * SI ioctls + */ +/* + * struct for use by Specialix ioctls - used by siconfig(8) + */ +typedef struct { + unsigned char + sid_port:5, /* 0 - 31 ports per card */ + sid_card:2, /* 0 - 3 cards */ + sid_control:1; /* controlling device (all cards) */ +} sidev_t; +struct si_tcsi { + sidev_t tc_dev; + union { + int x_int; + int x_dbglvl; + } tc_action; +#define tc_card tc_dev.sid_card +#define tc_port tc_dev.sid_port +#define tc_int tc_action.x_int +#define tc_dbglvl tc_action.x_dbglvl +}; + +struct si_pstat { + sidev_t tc_dev; + union { + struct si_port x_siport; + struct si_channel x_ccb; + struct tty x_tty; + } tc_action; +#define tc_siport tc_action.x_siport +#define tc_ccb tc_action.x_ccb +#define tc_tty tc_action.x_tty +}; + +#define IOCTL_MIN 96 +#define TCSIDEBUG _IOW('S', 96, struct si_tcsi) /* Toggle debug */ +#define TCSIRXIT _IOW('S', 97, struct si_tcsi) /* RX int throttle */ +#define TCSIIT _IOW('S', 98, struct si_tcsi) /* TX int throttle */ + /* 99 defunct */ + /* 100 defunct */ + /* 101 defunct */ + /* 102 defunct */ + /* 103 defunct */ + /* 104 defunct */ +#define TCSISTATE _IOWR('S', 105, struct si_tcsi) /* get current state of RTS + DCD and DTR pins */ + /* 106 defunct */ +#define TCSIPORTS _IOR('S', 107, int) /* Number of ports found */ +#define TCSISDBG_LEVEL _IOW('S', 108, struct si_tcsi) /* equivalent of TCSIDEBUG which sets a + * particular debug level (DBG_??? bit + * mask), default is 0xffff */ +#define TCSIGDBG_LEVEL _IOWR('S', 109, struct si_tcsi) +#define TCSIGRXIT _IOWR('S', 110, struct si_tcsi) +#define TCSIGIT _IOWR('S', 111, struct si_tcsi) + /* 112 defunct */ + /* 113 defunct */ + /* 114 defunct */ + /* 115 defunct */ + /* 116 defunct */ + /* 117 defunct */ + +#define TCSISDBG_ALL _IOW('S', 118, int) /* set global debug level */ +#define TCSIGDBG_ALL _IOR('S', 119, int) /* get global debug level */ + + /* 120 defunct */ + /* 121 defunct */ + /* 122 defunct */ + /* 123 defunct */ +#define TCSIMODULES _IOR('S', 124, int) /* Number of modules found */ + +/* Various stats and monitoring hooks per tty device */ +#define TCSI_PORT _IOWR('S', 125, struct si_pstat) /* get si_port */ +#define TCSI_CCB _IOWR('S', 126, struct si_pstat) /* get si_ccb */ +#define TCSI_TTY _IOWR('S', 127, struct si_pstat) /* get tty struct */ + +#define IOCTL_MAX 127 + +#define IS_SI_IOCTL(cmd) ((u_int)((cmd)&0xff00) == ('S'<<8) && \ + (u_int)((cmd)&0xff) >= IOCTL_MIN && \ + (u_int)((cmd)&0xff) <= IOCTL_MAX) + +#define CONTROLDEV "/dev/si_control" diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/signal.h ./modules/label/machine/signal.h --- ../sys-altq/modules/label/machine/signal.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/signal.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1986, 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.1 (Berkeley) 6/11/93 + * $FreeBSD: src/sys/i386/include/signal.h,v 1.8.2.1 1999/08/29 16:06:50 peter Exp $ + */ + +#ifndef _MACHINE_SIGNAL_H_ +#define _MACHINE_SIGNAL_H_ + +/* + * Machine-dependent signal definitions + */ + +typedef int sig_atomic_t; + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) + +#include /* codes for SIGILL, SIGFPE */ + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore */ + int sc_esp; /* machine state */ + int sc_ebp; + int sc_isp; + int sc_eip; + int sc_efl; + int sc_es; + int sc_ds; + int sc_cs; + int sc_ss; + int sc_edi; + int sc_esi; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + int sc_gs; + int sc_fs; +# define sc_sp sc_esp +# define sc_fp sc_ebp +# define sc_pc sc_eip +# define sc_ps sc_efl +# define sc_eflags sc_efl + int sc_trapno; + int sc_err; +}; + +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +#endif /* !_MACHINE_SIGNAL_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/smb.h ./modules/label/machine/smb.h --- ../sys-altq/modules/label/machine/smb.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/smb.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/smb.h,v 1.2.2.1 1999/08/29 16:06:50 peter Exp $ + * + */ +#ifndef __SMB_H +#define __SMB_H + +#include + +struct smbcmd { + char cmd; + int count; + u_char slave; + union { + char byte; + short word; + + char *byte_ptr; + short *word_ptr; + + struct { + short sdata; + short *rdata; + } process; + } data; +}; + +#define SMB_QUICK_WRITE _IOW('i', 1, struct smbcmd) +#define SMB_QUICK_READ _IOW('i', 2, struct smbcmd) +#define SMB_SENDB _IOW('i', 3, struct smbcmd) +#define SMB_RECVB _IOW('i', 4, struct smbcmd) +#define SMB_WRITEB _IOW('i', 5, struct smbcmd) +#define SMB_WRITEW _IOW('i', 6, struct smbcmd) +#define SMB_READB _IOW('i', 7, struct smbcmd) +#define SMB_READW _IOW('i', 8, struct smbcmd) +#define SMB_PCALL _IOW('i', 9, struct smbcmd) +#define SMB_BWRITE _IOW('i', 10, struct smbcmd) +#define SMB_BREAD _IOW('i', 11, struct smbcmd) + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/smp.h ./modules/label/machine/smp.h --- ../sys-altq/modules/label/machine/smp.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/smp.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,192 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $FreeBSD: src/sys/i386/include/smp.h,v 1.44.2.2 1999/08/31 01:19:22 msmith Exp $ + * + */ + +#ifndef _MACHINE_SMP_H_ +#define _MACHINE_SMP_H_ + +#ifdef KERNEL + +#if defined(SMP) && !defined(APIC_IO) +# error APIC_IO required for SMP, add "options APIC_IO" to your config file. +#endif /* SMP && !APIC_IO */ + +/* Number of CPUs. */ +#if defined(SMP) && !defined(NCPU) +# define NCPU 2 +#endif /* SMP && NCPU */ + +/* Number of IO APICs. */ +#if defined(APIC_IO) && !defined(NAPIC) +# define NAPIC 1 +#endif /* SMP && NAPIC */ + + +#if defined(SMP) || defined(APIC_IO) + +#ifndef LOCORE + +/* + * For sending values to POST displays. + * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? + */ +extern int current_postcode; /** XXX currently in mp_machdep.c */ +#define POSTCODE(X) current_postcode = (X), \ + outb(0x80, current_postcode) +#define POSTCODE_LO(X) current_postcode &= 0xf0, \ + current_postcode |= ((X) & 0x0f), \ + outb(0x80, current_postcode) +#define POSTCODE_HI(X) current_postcode &= 0x0f, \ + current_postcode |= (((X) << 4) & 0xf0), \ + outb(0x80, current_postcode) + + +#include + +/* global data in mpboot.s */ +extern int bootMP_size; + +/* functions in mpboot.s */ +void bootMP __P((void)); + +/* global data in mplock.s */ +extern u_int mp_lock; +extern u_int isr_lock; +#ifdef RECURSIVE_MPINTRLOCK +extern u_int mpintr_lock; +#endif /* RECURSIVE_MPINTRLOCK */ + +/* functions in mplock.s */ +void get_mplock __P((void)); +void rel_mplock __P((void)); +int try_mplock __P((void)); +#ifdef RECURSIVE_MPINTRLOCK +void get_mpintrlock __P((void)); +void rel_mpintrlock __P((void)); +int try_mpintrlock __P((void)); +#endif /* RECURSIVE_MPINTRLOCK */ + +/* global data in apic_vector.s */ +extern volatile u_int stopped_cpus; +extern volatile u_int started_cpus; + +extern volatile u_int checkstate_probed_cpus; +extern volatile u_int checkstate_need_ast; +extern volatile u_int resched_cpus; +extern void (*cpustop_restartfunc) __P((void)); + +/* functions in apic_ipl.s */ +void apic_eoi __P((void)); +u_int io_apic_read __P((int, int)); +void io_apic_write __P((int, int, u_int)); + +/* global data in mp_machdep.c */ +extern int bsp_apic_ready; +extern int mp_ncpus; +extern int mp_naps; +extern int mp_nbusses; +extern int mp_napics; +extern int mp_picmode; +extern int boot_cpu_id; +extern vm_offset_t cpu_apic_address; +extern vm_offset_t io_apic_address[]; +extern u_int32_t cpu_apic_versions[]; +extern u_int32_t io_apic_versions[]; +extern int cpu_num_to_apic_id[]; +extern int io_num_to_apic_id[]; +extern int apic_id_to_logical[]; +#define APIC_INTMAPSIZE 24 +struct apic_intmapinfo { + int ioapic; + int int_pin; + volatile void *apic_address; + int redirindex; +}; +extern struct apic_intmapinfo int_to_apicintpin[]; +extern u_int all_cpus; +extern u_char SMP_ioapic[]; +extern struct pcb stoppcbs[]; + +/* functions in mp_machdep.c */ +u_int mp_bootaddress __P((u_int)); +int mp_probe __P((void)); +void mp_start __P((void)); +void mp_announce __P((void)); +u_int isa_apic_mask __P((u_int)); +int isa_apic_irq __P((int)); +int pci_apic_irq __P((int, int, int)); +int apic_irq __P((int, int)); +int next_apic_irq __P((int)); +int undirect_isa_irq __P((int)); +int undirect_pci_irq __P((int)); +int apic_bus_type __P((int)); +int apic_src_bus_id __P((int, int)); +int apic_src_bus_irq __P((int, int)); +int apic_int_type __P((int, int)); +int apic_trigger __P((int, int)); +int apic_polarity __P((int, int)); +void bsp_apic_configure __P((void)); +void init_secondary __P((void)); +void smp_invltlb __P((void)); +int stop_cpus __P((u_int)); +int restart_cpus __P((u_int)); +#ifdef BETTER_CLOCK +void forward_statclock __P((int pscnt)); +void forward_hardclock __P((int pscnt)); +#endif /* BETTER_CLOCK */ +void forward_signal __P((struct proc *)); +void forward_roundrobin __P((void)); +#ifdef APIC_INTR_REORDER +void set_lapic_isrloc __P((int, int)); +#endif /* APIC_INTR_REORDER */ +void smp_rendezvous_action __P((void)); +void smp_rendezvous __P((void (*)(void *), + void (*)(void *), + void (*)(void *), + void *arg)); + +/* global data in mpapic.c */ +extern volatile lapic_t lapic; +extern volatile ioapic_t *ioapic[]; + +/* functions in mpapic.c */ +void apic_dump __P((char*)); +void apic_initialize __P((void)); +void imen_dump __P((void)); +int apic_ipi __P((int, int, int)); +int selected_apic_ipi __P((u_int, int, int)); +int io_apic_setup __P((int)); +int ext_int_setup __P((int, int)); + +#if defined(READY) +void clr_io_apic_mask24 __P((int, u_int32_t)); +void set_io_apic_mask24 __P((int, u_int32_t)); +#endif /* READY */ + +void set_apic_timer __P((int)); +int read_apic_timer __P((void)); +void u_sleep __P((int)); + +/* global data in init_smp.c */ +extern int invltlb_ok; +extern int smp_active; +extern volatile int smp_idle_loops; + +/* 'private' global data in locore.s */ +extern volatile u_int cpuid; +extern volatile u_int cpu_lockid; +extern int inside_intr; +extern volatile u_int other_cpus; + +#endif /* !LOCORE */ +#endif /* SMP || APIC_IO */ +#endif /* KERNEL */ +#endif /* _MACHINE_SMP_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/smptests.h ./modules/label/machine/smptests.h --- ../sys-altq/modules/label/machine/smptests.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/smptests.h Wed Dec 1 17:28:09 1999 @@ -0,0 +1,402 @@ +/* + * Copyright (c) 1996, by Steve Passe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the developer may NOT be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/smptests.h,v 1.32.2.1 1999/08/29 16:06:52 peter Exp $ + */ + +#ifndef _MACHINE_SMPTESTS_H_ +#define _MACHINE_SMPTESTS_H_ + + +/* + * Various 'tests in progress' and configuration parameters. + */ + + +/* + * Tor's clock improvements. + * + * When the giant kernel lock disappears, a different strategy should + * probably be used, thus this patch can only be considered a temporary + * measure. + * + * This patch causes (NCPU-1)*(128+100) extra IPIs per second. + * During profiling, the number is (NCPU-1)*(1024+100) extra IPIs/s + * in addition to extra IPIs due to forwarding ASTs to other CPUs. + * + * Having a shared AST flag in an SMP configuration is wrong, and I've + * just kludged around it, based upon the kernel lock blocking other + * processors from entering the kernel while handling an AST for one + * processor. When the giant kernel lock disappers, this kludge breaks. + * + * -- Tor + */ +#define BETTER_CLOCK + + +/* + * Control the "giant lock" pushdown by logical steps. + */ +#define PUSHDOWN_LEVEL_1 +#define PUSHDOWN_LEVEL_2 +#define PUSHDOWN_LEVEL_3_NOT +#define PUSHDOWN_LEVEL_4_NOT + + +/* + * XXX some temp debug control of cpl locks + */ +#ifdef PUSHDOWN_LEVEL_2 +#define REAL_ECPL /* exception.s: SCPL_LOCK/SCPL_UNLOCK */ +#define REAL_ICPL /* ipl.s: CPL_LOCK/CPL_UNLOCK/FAST */ +#define REAL_AICPL /* apic_ipl.s: SCPL_LOCK/SCPL_UNLOCK */ +#define REAL_AVCPL /* apic_vector.s: CPL_LOCK/CPL_UNLOCK */ +#define REAL_IFCPL /* ipl_funcs.c: SCPL_LOCK/SCPL_UNLOCK */ +#endif /* PUSHDOWN_LEVEL_2 */ + +/* + * The xCPL_LOCK/xCPL_UNLOCK defines control the spinlocks + * that protect cpl/cml/cil and the spl functions. + */ +#ifdef REAL_ECPL +#define ECPL_LOCK SCPL_LOCK +#define ECPL_UNLOCK SCPL_UNLOCK +#else +#define ECPL_LOCK +#define ECPL_UNLOCK +#endif /* REAL_ECPL */ + +#ifdef REAL_ICPL +#define ICPL_LOCK CPL_LOCK +#define ICPL_UNLOCK CPL_UNLOCK +#define FAST_ICPL_UNLOCK movl $0, _cpl_lock +#else +#define ICPL_LOCK +#define ICPL_UNLOCK +#define FAST_ICPL_UNLOCK +#endif /* REAL_ICPL */ + +#ifdef REAL_AICPL +#define AICPL_LOCK SCPL_LOCK +#define AICPL_UNLOCK SCPL_UNLOCK +#else +#define AICPL_LOCK +#define AICPL_UNLOCK +#endif /* REAL_AICPL */ + +#ifdef REAL_AVCPL +#define AVCPL_LOCK CPL_LOCK +#define AVCPL_UNLOCK CPL_UNLOCK +#else +#define AVCPL_LOCK +#define AVCPL_UNLOCK +#endif /* REAL_AVCPL */ + +#ifdef REAL_IFCPL +#define IFCPL_LOCK() SCPL_LOCK() +#define IFCPL_UNLOCK() SCPL_UNLOCK() +#else +#define IFCPL_LOCK() +#define IFCPL_UNLOCK() +#endif /* REAL_IFCPL */ + + +/* + * Debug version of simple_lock. This will store the CPU id of the + * holding CPU along with the lock. When a CPU fails to get the lock + * it compares its own id to the holder id. If they are the same it + * panic()s, as simple locks are binary, and this would cause a deadlock. + * + */ +#define SL_DEBUG + + +/* + * Put FAST_INTR() ISRs at an APIC priority above the regular INTs. + * Allow the mp_lock() routines to handle FAST interrupts while spinning. + */ +#ifdef PUSHDOWN_LEVEL_1 +#define FAST_HI +#endif + + +/* + * These defines enable critical region locking of areas that were + * protected via cli/sti in the UP kernel. + * + * MPINTRLOCK protects all the generic areas. + * COMLOCK protects the sio/cy drivers. + * CLOCKLOCK protects clock hardware and data + * known to be incomplete: + * joystick lkm + * ? + */ +#ifdef PUSHDOWN_LEVEL_1 +#define USE_MPINTRLOCK +#define USE_COMLOCK +#define USE_CLOCKLOCK +#endif + + +/* + * Regular INTerrupts without the giant lock, NOT READY YET!!! + */ +#ifdef PUSHDOWN_LEVEL_4 +#define INTR_SIMPLELOCK +#endif + + +/* + * Separate the INTR() portion of cpl into another variable: cml. + */ +#ifdef PUSHDOWN_LEVEL_3 +#define CPL_AND_CML +#endif + + +/* + * Forces spl functions to spin while waiting for safe time to change cpl. + * +#define SPL_DEBUG_POSTCODE (slows the system down noticably) + */ +#ifdef PUSHDOWN_LEVEL_3 +#define INTR_SPL +#define SPL_DEBUG +#endif + + +/* + * Ignore the ipending bits when exiting FAST_INTR() routines. + * + *** + * according to Bruce: + * + * setsoft*() may set ipending. setsofttty() is actually used in the + * FAST_INTR handler in some serial drivers. This is necessary to get + * output completions and other urgent events handled as soon as possible. + * The flag(s) could be set in a variable other than ipending, but they + * needs to be checked against cpl to decide whether the software interrupt + * handler can/should run. + * + * (FAST_INTR used to just return + * in all cases until rev.1.7 of vector.s. This worked OK provided there + * were no user-mode CPU hogs. CPU hogs caused an average latency of 1/2 + * clock tick for output completions...) + *** + * + * So I need to restore cpl handling someday, but AFTER + * I finish making spl/cpl MP-safe. + */ +#ifdef PUSHDOWN_LEVEL_1 +#define FAST_WITHOUTCPL +#endif + + +/* + * Use a simplelock to serialize FAST_INTR()s. + * sio.c, and probably other FAST_INTR() drivers, never expected several CPUs + * to be inside them at once. Things such as global vars prevent more + * than 1 thread of execution from existing at once, so we serialize + * the access of FAST_INTR()s via a simple lock. + * One optimization on this would be a simple lock per DRIVER, but I'm + * not sure how to organize that yet... + */ +#ifdef PUSHDOWN_LEVEL_1 +#define FAST_SIMPLELOCK +#endif + + +/* + * Portions of the old TEST_LOPRIO code, back from the grave! + */ +#define GRAB_LOPRIO + + +/* + * Send CPUSTOP IPI for stop/restart of other CPUs on DDB break. + * +#define VERBOSE_CPUSTOP_ON_DDBBREAK + */ +#define CPUSTOP_ON_DDBBREAK + + +/* + * Bracket code/comments relevant to the current 'giant lock' model. + * Everything is now the 'giant lock' model, but we will use this as + * we start to "push down" the lock. + */ +#define GIANT_LOCK + +#ifdef APIC_IO +/* + * Enable extra counters for some selected locations in the interrupt handlers. + * Look in apic_vector.s, apic_ipl.s and ipl.s for APIC_ITRACE or + * APIC_INTR_DIAGNOSTIC. + */ +#undef APIC_INTR_DIAGNOSTIC + +/* + * Add extra tracking of a specific interrupt. Look in apic_vector.s, + * apic_ipl.s and ipl.s for APIC_ITRACE and log_intr_event. + * APIC_INTR_DIAGNOSTIC must be defined for this to work. + */ +#ifdef APIC_INTR_DIAGNOSTIC +#define APIC_INTR_DIAGNOSTIC_IRQ 17 +#endif + +/* + * Don't assume that slow interrupt handler X is called from vector + * X + ICU_OFFSET. + */ +#define APIC_INTR_REORDER + +/* + * Redirect clock interrupts to a higher priority (fast intr) vector, + * while still using the slow interrupt handler. Only effective when + * APIC_INTR_REORDER is defined. + */ +#define APIC_INTR_HIGHPRI_CLOCK + +#endif /* APIC_IO */ + +/* + * Misc. counters. + * +#define COUNT_XINVLTLB_HITS + */ + + +/** + * Hack to "fake-out" kernel into thinking it is running on a 'default config'. + * + * value == default type +#define TEST_DEFAULT_CONFIG 6 + */ + + +/* + * Simple test code for IPI interaction, save for future... + * +#define TEST_TEST1 +#define IPI_TARGET_TEST1 1 + */ + + +/* + * Address of POST hardware port. + * Defining this enables POSTCODE macros. + * +#define POST_ADDR 0x80 + */ + + +/* + * POST hardware macros. + */ +#ifdef POST_ADDR +#define ASMPOSTCODE_INC \ + pushl %eax ; \ + movl _current_postcode, %eax ; \ + incl %eax ; \ + andl $0xff, %eax ; \ + movl %eax, _current_postcode ; \ + outb %al, $POST_ADDR ; \ + popl %eax + +/* + * Overwrite the current_postcode value. + */ +#define ASMPOSTCODE(X) \ + pushl %eax ; \ + movl $X, %eax ; \ + movl %eax, _current_postcode ; \ + outb %al, $POST_ADDR ; \ + popl %eax + +/* + * Overwrite the current_postcode low nibble. + */ +#define ASMPOSTCODE_LO(X) \ + pushl %eax ; \ + movl _current_postcode, %eax ; \ + andl $0xf0, %eax ; \ + orl $X, %eax ; \ + movl %eax, _current_postcode ; \ + outb %al, $POST_ADDR ; \ + popl %eax + +/* + * Overwrite the current_postcode high nibble. + */ +#define ASMPOSTCODE_HI(X) \ + pushl %eax ; \ + movl _current_postcode, %eax ; \ + andl $0x0f, %eax ; \ + orl $(X<<4), %eax ; \ + movl %eax, _current_postcode ; \ + outb %al, $POST_ADDR ; \ + popl %eax +#else +#define ASMPOSTCODE_INC +#define ASMPOSTCODE(X) +#define ASMPOSTCODE_LO(X) +#define ASMPOSTCODE_HI(X) +#endif /* POST_ADDR */ + + +/* + * These are all temps for debugging... + * +#define GUARD_INTS + */ + +/* + * This macro traps unexpected INTs to a specific CPU, eg. GUARD_CPU. + */ +#ifdef GUARD_INTS +#define GUARD_CPU 1 +#define MAYBE_PANIC(irq_num) \ + cmpl $GUARD_CPU, _cpuid ; \ + jne 9f ; \ + cmpl $1, _ok_test1 ; \ + jne 9f ; \ + pushl lapic_isr3 ; \ + pushl lapic_isr2 ; \ + pushl lapic_isr1 ; \ + pushl lapic_isr0 ; \ + pushl lapic_irr3 ; \ + pushl lapic_irr2 ; \ + pushl lapic_irr1 ; \ + pushl lapic_irr0 ; \ + pushl $irq_num ; \ + pushl _cpuid ; \ + pushl $panic_msg ; \ + call _printf ; \ + addl $44, %esp ; \ +9: +#else +#define MAYBE_PANIC(irq_num) +#endif /* GUARD_INTS */ + +#endif /* _MACHINE_SMPTESTS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/soundcard.h ./modules/label/machine/soundcard.h --- ../sys-altq/modules/label/machine/soundcard.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/soundcard.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,1364 @@ +/* + * soundcard.h + * + * Copyright by Hannu Savolainen 1993 + * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SOUNDCARD_H +#define SOUNDCARD_H + /* + * If you make modifications to this file, please contact me before + * distributing the modified version. There is already enough + * diversity in the world. + * + * Regards, + * Hannu Savolainen + * hannu@voxware.pp.fi + * + ********************************************************************** + * PS. The Hacker's Guide to VoxWare available from + * nic.funet.fi:pub/OS/Linux/ALPHA/sound. The file is + * snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains + * some useful information about programming with VoxWare. + * (NOTE! The pub/OS/Linux/ALPHA/ directories are hidden. You have + * to cd inside them before the files are accessible.) + ********************************************************************** + */ + +/* + * SOUND_VERSION is only used by the voxware driver. Hopefully apps + * should not depend on it, but rather look at the capabilities + * of the driver in the kernel! + */ +#define SOUND_VERSION 301 +#define VOXWARE /* does this have any use ? */ + +/* + * Supported card ID numbers (Should be somewhere else? We keep + * them here just for compativility with the old driver, but these + * constants are of little or no use). + */ + +#define SNDCARD_ADLIB 1 +#define SNDCARD_SB 2 +#define SNDCARD_PAS 3 +#define SNDCARD_GUS 4 +#define SNDCARD_MPU401 5 +#define SNDCARD_SB16 6 +#define SNDCARD_SB16MIDI 7 +#define SNDCARD_UART6850 8 +#define SNDCARD_GUS16 9 +#define SNDCARD_MSS 10 +#define SNDCARD_PSS 11 +#define SNDCARD_SSCAPE 12 +#define SNDCARD_PSS_MPU 13 +#define SNDCARD_PSS_MSS 14 +#define SNDCARD_SSCAPE_MSS 15 +#define SNDCARD_TRXPRO 16 +#define SNDCARD_TRXPRO_SB 17 +#define SNDCARD_TRXPRO_MPU 18 +#define SNDCARD_MAD16 19 +#define SNDCARD_MAD16_MPU 20 +#define SNDCARD_CS4232 21 +#define SNDCARD_CS4232_MPU 22 +#define SNDCARD_MAUI 23 +#define SNDCARD_PSEUDO_MSS 24 +#define SNDCARD_AWE32 25 +#define SNDCARD_NSS 26 + +#include +#ifndef _IOWR +#include +#endif /* !_IOWR */ + +/* + * The first part of this file contains the new FreeBSD sound ioctl + * interface. Tries to minimize the number of different ioctls, and + * to be reasonably general. + * + * 970821: some of the new calls have not been implemented yet. + */ + +/* + * the following three calls extend the generic file descriptor + * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max + * number of bytes for a write operation to be non-blocking. + * + * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device, + * from a character device (default) to a block device. In block mode, + * (not to be confused with blocking mode) the main difference for the + * application is that select() will return only when a complete + * block can be read/written to the device, whereas in character mode + * select will return true when one byte can be exchanged. For audio + * devices, character mode makes select almost useless since one byte + * will always be ready by the next sample time (which is often only a + * handful of microseconds away). + * Use a size of 0 or 1 to return to character mode. + */ +#define AIONWRITE _IOR('A', 10, int) /* get # bytes to write */ +struct snd_size { + int play_size; + int rec_size; +}; +#define AIOGSIZE _IOR('A', 11, struct snd_size)/* read current blocksize */ +#define AIOSSIZE _IOWR('A', 11, struct snd_size) /* sets blocksize */ + +/* + * The following constants define supported audio formats. The + * encoding follows voxware conventions, i.e. 1 bit for each supported + * format. We extend it by using bit 31 (RO) to indicate full-duplex + * capability, and bit 29 (RO) to indicate that the card supports/ + * needs different formats on capture & playback channels. + * Bit 29 (RW) is used to indicate/ask stereo. + */ + +# define AFMT_QUERY 0x00000000 /* Return current fmt */ +# define AFMT_MU_LAW 0x00000001 +# define AFMT_A_LAW 0x00000002 +# define AFMT_IMA_ADPCM 0x00000004 +# define AFMT_U8 0x00000008 +# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ +# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ +# define AFMT_S8 0x00000040 +# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ +# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ +# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ + +# define AFMT_STEREO 0x10000000 /* can do/want stereo */ + +/* + * the following are really capabilities + */ +# define AFMT_WEIRD 0x20000000 /* weird hardware... */ + /* + * AFMT_WEIRD reports that the hardware might need to operate + * with different formats in the playback and capture + * channels when operating in full duplex. + * As an example, SoundBlaster16 cards only support U8 in one + * direction and S16 in the other one, and applications should + * be aware of this limitation. + */ +# define AFMT_FULLDUPLEX 0x80000000 /* can do full duplex */ + +/* + * The following structure is used to get/set format and sampling rate. + * While it would be better to have things such as stereo, bits per + * sample, endiannes, etc split in different variables, it turns out + * that formats are not that many, and not all combinations are possible. + * So we followed the Voxware approach of associating one bit to each + * format. + */ + +typedef struct _snd_chan_param { + u_long play_rate; /* sampling rate */ + u_long rec_rate; /* sampling rate */ + u_long play_format; /* everything describing the format */ + u_long rec_format; /* everything describing the format */ +} snd_chan_param; +#define AIOGFMT _IOR('f', 12, snd_chan_param) /* get format */ +#define AIOSFMT _IOWR('f', 12, snd_chan_param) /* sets format */ + +/* + * The following structure is used to get/set the mixer setting. + * Up to 32 mixers are supported, each one with up to 32 channels. + */ +typedef struct _snd_mix_param { + u_char subdev; /* which output */ + u_char line; /* which input */ + u_char left,right; /* volumes, 0..255, 0 = mute */ +} snd_mix_param ; + +/* XXX AIOGMIX, AIOSMIX not implemented yet */ +#define AIOGMIX _IOWR('A', 13, snd_mix_param) /* return mixer status */ +#define AIOSMIX _IOWR('A', 14, snd_mix_param) /* sets mixer status */ + +/* + * channel specifiers used in AIOSTOP and AIOSYNC + */ +#define AIOSYNC_PLAY 0x1 /* play chan */ +#define AIOSYNC_CAPTURE 0x2 /* capture chan */ +/* AIOSTOP stop & flush a channel, returns the residual count */ +#define AIOSTOP _IOWR ('A', 15, int) + +/* alternate method used to notify the sync condition */ +#define AIOSYNC_SIGNAL 0x100 +#define AIOSYNC_SELECT 0x200 + +/* what the 'pos' field refers to */ +#define AIOSYNC_READY 0x400 +#define AIOSYNC_FREE 0x800 + +typedef struct _snd_sync_parm { + long chan ; /* play or capture channel, plus modifier */ + long pos; +} snd_sync_parm; +#define AIOSYNC _IOWR ('A', 15, snd_sync_parm) /* misc. synchronization */ + +/* + * The following is used to return device capabilities. If the structure + * passed to the ioctl is zeroed, default values are returned for rate + * and formats, a bitmap of available mixers is returned, and values + * (inputs, different levels) for the first one are returned. + * + * If formats, mixers, inputs are instantiated, then detailed info + * are returned depending on the call. + */ +typedef struct _snd_capabilities { + u_long rate_min, rate_max; /* min-max sampling rate */ + u_long formats; + u_long bufsize; /* DMA buffer size */ + u_long mixers; /* bitmap of available mixers */ + u_long inputs; /* bitmap of available inputs (per mixer) */ + u_short left, right; /* how many levels are supported */ +} snd_capabilities; +#define AIOGCAP _IOWR('A', 15, snd_capabilities) /* get capabilities */ + +/* + * here is the old (Voxware) ioctl interface + */ + +/* + * IOCTL Commands for /dev/sequencer + */ + +#define SNDCTL_SEQ_RESET _IO ('Q', 0) +#define SNDCTL_SEQ_SYNC _IO ('Q', 1) +#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) +#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */ +#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) +#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) +#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) +#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ +#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) +#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) +#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) +#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) +#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) +#define SNDCTL_SEQ_THRESHOLD _IOW ('Q',13, int) +#define SNDCTL_SEQ_TRESHOLD SNDCTL_SEQ_THRESHOLD /* there was once a typo */ +#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ +#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ +#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) +#define SNDCTL_SEQ_PANIC _IO ('Q',17) +#define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) + +struct seq_event_rec { + u_char arr[8]; +}; + +#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) +#define SNDCTL_TMR_START _IO ('T', 2) +#define SNDCTL_TMR_STOP _IO ('T', 3) +#define SNDCTL_TMR_CONTINUE _IO ('T', 4) +#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) +#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) +# define TMR_INTERNAL 0x00000001 +# define TMR_EXTERNAL 0x00000002 +# define TMR_MODE_MIDI 0x00000010 +# define TMR_MODE_FSK 0x00000020 +# define TMR_MODE_CLS 0x00000040 +# define TMR_MODE_SMPTE 0x00000080 +#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) +#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) + +/* + * Endian aware patch key generation algorithm. + */ + +#if defined(_AIX) || defined(AIX) +# define _PATCHKEY(id) (0xfd00|id) +#else +# define _PATCHKEY(id) ((id<<8)|0xfd) +#endif + +/* + * Sample loading mechanism for internal synthesizers (/dev/sequencer) + * The following patch_info structure has been designed to support + * Gravis UltraSound. It tries to be universal format for uploading + * sample based patches but is probably too limited. + */ + +struct patch_info { +/* u_short key; Use GUS_PATCH here */ + short key; /* Use GUS_PATCH here */ +#define GUS_PATCH _PATCHKEY(0x04) +#define OBSOLETE_GUS_PATCH _PATCHKEY(0x02) + + short device_no; /* Synthesizer number */ + short instr_no; /* Midi pgm# */ + + u_long mode; +/* + * The least significant byte has the same format than the GUS .PAT + * files + */ +#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ +#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ +#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ +#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ +#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ +#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ +#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ + /* (use the env_rate/env_offs fields). */ +/* Linux specific bits */ +#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ +#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ +#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ +/* Other bits must be zeroed */ + + long len; /* Size of the wave data in bytes */ + long loop_start, loop_end; /* Byte offsets from the beginning */ + +/* + * The base_freq and base_note fields are used when computing the + * playback speed for a note. The base_note defines the tone frequency + * which is heard if the sample is played using the base_freq as the + * playback speed. + * + * The low_note and high_note fields define the minimum and maximum note + * frequencies for which this sample is valid. It is possible to define + * more than one samples for a instrument number at the same time. The + * low_note and high_note fields are used to select the most suitable one. + * + * The fields base_note, high_note and low_note should contain + * the note frequency multiplied by 1000. For example value for the + * middle A is 440*1000. + */ + + u_int base_freq; + u_long base_note; + u_long high_note; + u_long low_note; + int panning; /* -128=left, 127=right */ + int detuning; + +/* New fields introduced in version 1.99.5 */ + + /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ + u_char env_rate[ 6 ]; /* GUS HW ramping rate */ + u_char env_offset[ 6 ]; /* 255 == 100% */ + + /* + * The tremolo, vibrato and scale info are not supported yet. + * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or + * WAVE_SCALE + */ + + u_char tremolo_sweep; + u_char tremolo_rate; + u_char tremolo_depth; + + u_char vibrato_sweep; + u_char vibrato_rate; + u_char vibrato_depth; + + int scale_frequency; + u_int scale_factor; /* from 0 to 2048 or 0 to 2 */ + + int volume; + int spare[4]; + char data[1]; /* The waveform data starts here */ +}; + +struct sysex_info { + short key; /* Use GUS_PATCH here */ +#define SYSEX_PATCH _PATCHKEY(0x05) +#define MAUI_PATCH _PATCHKEY(0x06) + short device_no; /* Synthesizer number */ + long len; /* Size of the sysex data in bytes */ + u_char data[1]; /* Sysex data starts here */ +}; + +/* + * Patch management interface (/dev/sequencer, /dev/patmgr#) + * Don't use these calls if you want to maintain compatibility with + * the future versions of the driver. + */ + +#define PS_NO_PATCHES 0 /* No patch support on device */ +#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ +#define PS_MGR_OK 2 /* Patch manager supported */ +#define PS_MANAGED 3 /* Patch manager running */ + +#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) + +/* + * The patmgr_info is a fixed size structure which is used for two + * different purposes. The intended use is for communication between + * the application using /dev/sequencer and the patch manager daemon + * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). + * + * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows + * a patch manager daemon to read and write device parameters. This + * ioctl available through /dev/sequencer also. Avoid using it since it's + * extremely hardware dependent. In addition access trough /dev/sequencer + * may confuse the patch manager daemon. + */ + +struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ + u_long key; /* Don't worry. Reserved for communication + between the patch manager and the driver. */ +#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ +#define PM_K_COMMAND 2 /* Request from a application */ +#define PM_K_RESPONSE 3 /* From patmgr to application */ +#define PM_ERROR 4 /* Error returned by the patmgr */ + int device; + int command; + +/* + * Commands 0x000 to 0xfff reserved for patch manager programs + */ +#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ +#define PMTYPE_FM2 1 /* 2 OP fm */ +#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ +#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ +#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ +#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ +#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ +#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ +#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ +#define PM_READ_PATCH 7 /* Read patch (wave) data */ +#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ + +/* + * Commands 0x1000 to 0xffff are for communication between the patch manager + * and the client + */ +#define _PM_LOAD_PATCH 0x100 + +/* + * Commands above 0xffff reserved for device specific use + */ + + long parm1; + long parm2; + long parm3; + + union { + u_char data8[4000]; + u_short data16[2000]; + u_long data32[1000]; + struct patch_info patch; + } data; +}; + +/* + * When a patch manager daemon is present, it will be informed by the + * driver when something important happens. For example when the + * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is + * returned. The command field contains the event type: + */ +#define PM_E_OPENED 1 /* /dev/sequencer opened */ +#define PM_E_CLOSED 2 /* /dev/sequencer closed */ +#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ +#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ + +/* + * /dev/sequencer input events. + * + * The data written to the /dev/sequencer is a stream of events. Events + * are records of 4 or 8 bytes. The first byte defines the size. + * Any number of events can be written with a write call. There + * is a set of macros for sending these events. Use these macros if you + * want to maximize portability of your program. + * + * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. + * (All input events are currently 4 bytes long. Be prepared to support + * 8 byte events also. If you receive any event having first byte >= 128, + * it's a 8 byte event. + * + * The events are documented at the end of this file. + * + * Normal events (4 bytes) + * There is also a 8 byte version of most of the 4 byte events. The + * 8 byte one is recommended. + */ +#define SEQ_NOTEOFF 0 +#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ +#define SEQ_NOTEON 1 +#define SEQ_FMNOTEON SEQ_NOTEON +#define SEQ_WAIT TMR_WAIT_ABS +#define SEQ_PGMCHANGE 3 +#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE +#define SEQ_SYNCTIMER TMR_START +#define SEQ_MIDIPUTC 5 +#define SEQ_DRUMON 6 /*** OBSOLETE ***/ +#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ +#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ +#define SEQ_AFTERTOUCH 9 +#define SEQ_CONTROLLER 10 + +/* + * Midi controller numbers + * + * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f) + * are continuous controllers. + * In the MIDI 1.0 these controllers are sent using two messages. + * Controller numbers 0 to 31 are used to send the MSB and the + * controller numbers 32 to 63 are for the LSB. Note that just 7 bits + * are used in MIDI bytes. + */ + +#define CTL_BANK_SELECT 0x00 +#define CTL_MODWHEEL 0x01 +#define CTL_BREATH 0x02 +/* undefined 0x03 */ +#define CTL_FOOT 0x04 +#define CTL_PORTAMENTO_TIME 0x05 +#define CTL_DATA_ENTRY 0x06 +#define CTL_MAIN_VOLUME 0x07 +#define CTL_BALANCE 0x08 +/* undefined 0x09 */ +#define CTL_PAN 0x0a +#define CTL_EXPRESSION 0x0b +/* undefined 0x0c - 0x0f */ +#define CTL_GENERAL_PURPOSE1 0x10 +#define CTL_GENERAL_PURPOSE2 0x11 +#define CTL_GENERAL_PURPOSE3 0x12 +#define CTL_GENERAL_PURPOSE4 0x13 +/* undefined 0x14 - 0x1f */ + +/* undefined 0x20 */ + +/* + * The controller numbers 0x21 to 0x3f are reserved for the + * least significant bytes of the controllers 0x00 to 0x1f. + * These controllers are not recognised by the driver. + * + * Controllers 64 to 69 (0x40 to 0x45) are on/off switches. + * 0=OFF and 127=ON (intermediate values are possible) + */ +#define CTL_DAMPER_PEDAL 0x40 +#define CTL_SUSTAIN CTL_DAMPER_PEDAL /* Alias */ +#define CTL_HOLD CTL_DAMPER_PEDAL /* Alias */ +#define CTL_PORTAMENTO 0x41 +#define CTL_SOSTENUTO 0x42 +#define CTL_SOFT_PEDAL 0x43 +/* undefined 0x44 */ +#define CTL_HOLD2 0x45 +/* undefined 0x46 - 0x4f */ + +#define CTL_GENERAL_PURPOSE5 0x50 +#define CTL_GENERAL_PURPOSE6 0x51 +#define CTL_GENERAL_PURPOSE7 0x52 +#define CTL_GENERAL_PURPOSE8 0x53 +/* undefined 0x54 - 0x5a */ +#define CTL_EXT_EFF_DEPTH 0x5b +#define CTL_TREMOLO_DEPTH 0x5c +#define CTL_CHORUS_DEPTH 0x5d +#define CTL_DETUNE_DEPTH 0x5e +#define CTL_CELESTE_DEPTH CTL_DETUNE_DEPTH /* Alias for the above one */ +#define CTL_PHASER_DEPTH 0x5f +#define CTL_DATA_INCREMENT 0x60 +#define CTL_DATA_DECREMENT 0x61 +#define CTL_NONREG_PARM_NUM_LSB 0x62 +#define CTL_NONREG_PARM_NUM_MSB 0x63 +#define CTL_REGIST_PARM_NUM_LSB 0x64 +#define CTL_REGIST_PARM_NUM_MSB 0x65 +/* undefined 0x66 - 0x78 */ +/* reserved 0x79 - 0x7f */ + +/* Pseudo controllers (not midi compatible) */ +#define CTRL_PITCH_BENDER 255 +#define CTRL_PITCH_BENDER_RANGE 254 +#define CTRL_EXPRESSION 253 /* Obsolete */ +#define CTRL_MAIN_VOLUME 252 /* Obsolete */ + +#define SEQ_BALANCE 11 +#define SEQ_VOLMODE 12 + +/* + * Volume mode decides how volumes are used + */ + +#define VOL_METHOD_ADAGIO 1 +#define VOL_METHOD_LINEAR 2 + +/* + * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as + * input events. + */ + +/* + * Event codes 0xf0 to 0xfc are reserved for future extensions. + */ + +#define SEQ_FULLSIZE 0xfd /* Long events */ +/* + * SEQ_FULLSIZE events are used for loading patches/samples to the + * synthesizer devices. These events are passed directly to the driver + * of the associated synthesizer device. There is no limit to the size + * of the extended events. These events are not queued but executed + * immediately when the write() is called (execution can take several + * seconds of time). + * + * When a SEQ_FULLSIZE message is written to the device, it must + * be written using exactly one write() call. Other events cannot + * be mixed to the same write. + * + * For FM synths (YM3812/OPL3) use struct sbi_instrument and write + * it to the /dev/sequencer. Don't write other data together with + * the instrument structure Set the key field of the structure to + * FM_PATCH. The device field is used to route the patch to the + * corresponding device. + * + * For Gravis UltraSound use struct patch_info. Initialize the key field + * to GUS_PATCH. + */ +#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ +#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ + +/* + * Record for FM patches + */ + +typedef u_char sbi_instr_data[32]; + +struct sbi_instrument { + u_short key; /* FM_PATCH or OPL3_PATCH */ +#define FM_PATCH _PATCHKEY(0x01) +#define OPL3_PATCH _PATCHKEY(0x03) + short device; /* Synth# (0-4) */ + int channel; /* Program# to be initialized */ + sbi_instr_data operators; /* Reg. settings for operator cells + * (.SBI format) */ +}; + +struct synth_info { /* Read only */ + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + int synth_type; +#define SYNTH_TYPE_FM 0 +#define SYNTH_TYPE_SAMPLE 1 +#define SYNTH_TYPE_MIDI 2 /* Midi interface */ + + int synth_subtype; +#define FM_TYPE_ADLIB 0x00 +#define FM_TYPE_OPL3 0x01 + +#define SAMPLE_TYPE_BASIC 0x10 +#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC +#define SAMPLE_TYPE_AWE32 0x20 + + int perc_mode; /* No longer supported */ + int nr_voices; + int nr_drums; /* Obsolete field */ + int instr_bank_size; + u_long capabilities; +#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ +#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ +#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ + int dummies[19]; /* Reserve space */ +}; + +struct sound_timer_info { + char name[32]; + int caps; +}; + +#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ + +struct midi_info { + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + u_long capabilities; /* To be defined later */ + int dev_type; + int dummies[18]; /* Reserve space */ +}; + +/* + * ioctl commands for the /dev/midi## + */ +typedef struct { + u_char cmd; + char nr_args, nr_returns; + u_char data[30]; +} mpu_command_rec; + +#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) +#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) +#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) + +/* + * IOCTL commands for /dev/dsp and /dev/audio + */ + +#define SNDCTL_DSP_RESET _IO ('P', 0) +#define SNDCTL_DSP_SYNC _IO ('P', 1) +#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) +#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) +#define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int) +#define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int) +#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ + +/* + * SOUND_PCM_WRITE_CHANNELS is not that different + * from SNDCTL_DSP_STEREO + */ +#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) +#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) +#define SNDCTL_DSP_POST _IO ('P', 8) + +/* + * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do + * the same thing, i.e. set the block size used in DMA transfers. + */ +#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) +#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) + + +#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ +/* + * Buffer status queries. + */ +typedef struct audio_buf_info { + int fragments; /* # of avail. frags (partly used ones not counted) */ + int fragstotal; /* Total # of fragments allocated */ + int fragsize; /* Size of a fragment in bytes */ + + int bytes; /* Avail. space in bytes (includes partly used fragments) */ + /* Note! 'bytes' could be more than fragments*fragsize */ +} audio_buf_info; + +#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info) +#define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info) + +/* + * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the + * action cannot be undone) of FIONBIO. The same can be achieved + * by opening the device with O_NDELAY + */ +#define SNDCTL_DSP_NONBLOCK _IO ('P',14) + +#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int) +#define DSP_CAP_REVISION 0x000000ff /* revision level (0 to 255) */ +#define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ +#define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ +#define DSP_CAP_BATCH 0x00000400 + /* + * Device has some kind of internal buffers which may + * cause some delays and decrease precision of timing + */ +#define DSP_CAP_COPROC 0x00000800 + /* Has a coprocessor, sometimes it's a DSP but usually not */ +#define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ +#define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ + +/* + * What do these function do ? + */ +#define SNDCTL_DSP_GETTRIGGER _IOR ('P',16, int) +#define SNDCTL_DSP_SETTRIGGER _IOW ('P',16, int) +#define PCM_ENABLE_INPUT 0x00000001 +#define PCM_ENABLE_OUTPUT 0x00000002 + +typedef struct count_info { + int bytes; /* Total # of bytes processed */ + int blocks; /* # of fragment transitions since last time */ + int ptr; /* Current DMA pointer value */ +} count_info; + +/* + * GETIPTR and GETISPACE are not that different... same for out. + */ +#define SNDCTL_DSP_GETIPTR _IOR ('P',17, count_info) +#define SNDCTL_DSP_GETOPTR _IOR ('P',18, count_info) + +typedef struct buffmem_desc { + caddr_t buffer; + int size; +} buffmem_desc; + +#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, buffmem_desc) +#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, buffmem_desc) +#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21) + +/* + * I guess these are the readonly version of the same + * functions that exist above as SNDCTL_DSP_... + */ +#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) +#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) +#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) +#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) + +/* + * ioctl calls to be used in communication with coprocessors and + * DSP chips. + */ + +typedef struct copr_buffer { + int command; /* Set to 0 if not used */ + int flags; +#define CPF_NONE 0x0000 +#define CPF_FIRST 0x0001 /* First block */ +#define CPF_LAST 0x0002 /* Last block */ + int len; + int offs; /* If required by the device (0 if not used) */ + + u_char data[4000]; /* NOTE! 4000 is not 4k */ +} copr_buffer; + +typedef struct copr_debug_buf { + int command; /* Used internally. Set to 0 */ + int parm1; + int parm2; + int flags; + int len; /* Length of data in bytes */ +} copr_debug_buf; + +typedef struct copr_msg { + int len; + u_char data[4000]; +} copr_msg; + +#define SNDCTL_COPR_RESET _IO ('C', 0) +#define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer) +#define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf) +#define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf) +#define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf) +#define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf) +#define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf) +#define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf) +#define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg) +#define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg) + +/* + * IOCTL commands for /dev/mixer + */ + +/* + * Mixer devices + * + * There can be up to 20 different analog mixer channels. The + * SOUND_MIXER_NRDEVICES gives the currently supported maximum. + * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells + * the devices supported by the particular mixer. + */ + +#define SOUND_MIXER_NRDEVICES 25 +#define SOUND_MIXER_VOLUME 0 +#define SOUND_MIXER_BASS 1 +#define SOUND_MIXER_TREBLE 2 +#define SOUND_MIXER_SYNTH 3 +#define SOUND_MIXER_PCM 4 +#define SOUND_MIXER_SPEAKER 5 +#define SOUND_MIXER_LINE 6 +#define SOUND_MIXER_MIC 7 +#define SOUND_MIXER_CD 8 +#define SOUND_MIXER_IMIX 9 /* Recording monitor */ +#define SOUND_MIXER_ALTPCM 10 +#define SOUND_MIXER_RECLEV 11 /* Recording level */ +#define SOUND_MIXER_IGAIN 12 /* Input gain */ +#define SOUND_MIXER_OGAIN 13 /* Output gain */ +/* + * The AD1848 codec and compatibles have three line level inputs + * (line, aux1 and aux2). Since each card manufacturer have assigned + * different meanings to these inputs, it's inpractical to assign + * specific meanings (line, cd, synth etc.) to them. + */ +#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ +#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ +#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ +#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ +#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ +#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ +#define SOUND_MIXER_PHONEIN 20 /* Phone input */ +#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ +#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ +#define SOUND_MIXER_RADIO 23 /* Radio in */ +#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ + + +/* + * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) + * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space + */ +#define SOUND_ONOFF_MIN 28 +#define SOUND_ONOFF_MAX 30 +#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ +#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ +#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ + +/* Note! Number 31 cannot be used since the sign bit is reserved */ +#define SOUND_MIXER_NONE 31 + +#define SOUND_DEVICE_LABELS { \ + "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ + "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ + "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ + "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} + +#define SOUND_DEVICE_NAMES { \ + "vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ + "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ + "line1", "line2", "line3", "dig1", "dig2", "dig3", \ + "phin", "phout", "video", "radio", "monitor"} + +/* Device bitmask identifiers */ + +#define SOUND_MIXER_RECSRC 0xff /* 1 bit per recording source */ +#define SOUND_MIXER_DEVMASK 0xfe /* 1 bit per supported device */ +#define SOUND_MIXER_RECMASK 0xfd /* 1 bit per supp. recording source */ +#define SOUND_MIXER_CAPS 0xfc +#define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only 1 rec. src at a time */ +#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ + +/* Device mask bits */ + +#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) +#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) +#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) +#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) +#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) +#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) +#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) +#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) +#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) +#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) +#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) +#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) +#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) +#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) +#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) +#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) +#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) +#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) +#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) +#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) +#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) +#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) +#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) +#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) +#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) + +/* Obsolete macros */ +#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) +#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) +#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) + +#define MIXER_READ(dev) _IOR('M', dev, int) +#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) +#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) +#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) +#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) +#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) +#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) +#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) +#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) +#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) +#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) +#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) + +/* Obsolete macros */ +#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) +#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) +#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) +#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) +#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) +#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) + +#define MIXER_WRITE(dev) _IOWR('M', dev, int) +#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) +#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) +#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) +#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) +#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) +#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) +#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) +#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) +#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) +#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) +#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) +#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) +#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) + +#define LEFT_CHN 0 +#define RIGHT_CHN 1 + +/* + * Level 2 event types for /dev/sequencer + */ + +/* + * The 4 most significant bits of byte 0 specify the class of + * the event: + * + * 0x8X = system level events, + * 0x9X = device/port specific events, event[1] = device/port, + * The last 4 bits give the subtype: + * 0x02 = Channel event (event[3] = chn). + * 0x01 = note event (event[4] = note). + * (0x01 is not used alone but always with bit 0x02). + * event[2] = MIDI message code (0x80=note off etc.) + * + */ + +#define EV_SEQ_LOCAL 0x80 +#define EV_TIMING 0x81 +#define EV_CHN_COMMON 0x92 +#define EV_CHN_VOICE 0x93 +#define EV_SYSEX 0x94 +/* + * Event types 200 to 220 are reserved for application use. + * These numbers will not be used by the driver. + */ + +/* + * Events for event type EV_CHN_VOICE + */ + +#define MIDI_NOTEOFF 0x80 +#define MIDI_NOTEON 0x90 +#define MIDI_KEY_PRESSURE 0xA0 + +/* + * Events for event type EV_CHN_COMMON + */ + +#define MIDI_CTL_CHANGE 0xB0 +#define MIDI_PGM_CHANGE 0xC0 +#define MIDI_CHN_PRESSURE 0xD0 +#define MIDI_PITCH_BEND 0xE0 + +#define MIDI_SYSTEM_PREFIX 0xF0 + +/* + * Timer event types + */ +#define TMR_WAIT_REL 1 /* Time relative to the prev time */ +#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ +#define TMR_STOP 3 +#define TMR_START 4 +#define TMR_CONTINUE 5 +#define TMR_TEMPO 6 +#define TMR_ECHO 8 +#define TMR_CLOCK 9 /* MIDI clock */ +#define TMR_SPP 10 /* Song position pointer */ +#define TMR_TIMESIG 11 /* Time signature */ + +/* + * Local event types + */ +#define LOCL_STARTAUDIO 1 + +#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) +/* + * Some convenience macros to simplify programming of the + * /dev/sequencer interface + * + * These macros define the API which should be used when possible. + */ + +#ifndef USE_SIMPLE_MACROS +void seqbuf_dump(void); /* This function must be provided by programs */ + +/* Sample seqbuf_dump() implementation: + * + * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes + * + * int seqfd; -- The file descriptor for /dev/sequencer. + * + * void + * seqbuf_dump () + * { + * if (_seqbufptr) + * if (write (seqfd, _seqbuf, _seqbufptr) == -1) + * { + * perror ("write /dev/sequencer"); + * exit (-1); + * } + * _seqbufptr = 0; + * } + */ + +#define SEQ_DEFINEBUF(len) \ + u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 +#define SEQ_USE_EXTBUF() \ + extern u_char _seqbuf[]; \ + extern int _seqbuflen;extern int _seqbufptr +#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() +#define SEQ_PM_DEFINES struct patmgr_info _pm_info +#define _SEQ_NEEDBUF(len) \ + if ((_seqbufptr+(len)) > _seqbuflen) \ + seqbuf_dump() +#define _SEQ_ADVBUF(len) _seqbufptr += len +#define SEQ_DUMPBUF seqbuf_dump +#else +/* + * This variation of the sequencer macros is used just to format one event + * using fixed buffer. + * + * The program using the macro library must define the following macros before + * using this library. + * + * #define _seqbuf name of the buffer (u_char[]) + * #define _SEQ_ADVBUF(len) If the applic needs to know the exact + * size of the event, this macro can be used. + * Otherwise this must be defined as empty. + * #define _seqbufptr Define the name of index variable or 0 if + * not required. + */ +#define _SEQ_NEEDBUF(len) /* empty */ +#endif + +#define PM_LOAD_PATCH(dev, bank, pgm) \ + (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ + _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ + _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ + ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) +#define PM_LOAD_PATCHES(dev, bank, pgm) \ + (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ + _pm_info.device=dev, bcopy( pgm, _pm_info.data.data8, 128), \ + _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ + ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) + +#define SEQ_VOLUME_MODE(dev, mode) { \ + _SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ + _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ + _seqbuf[_seqbufptr+2] = (dev);\ + _seqbuf[_seqbufptr+3] = (mode);\ + _seqbuf[_seqbufptr+4] = 0;\ + _seqbuf[_seqbufptr+5] = 0;\ + _seqbuf[_seqbufptr+6] = 0;\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +/* + * Midi voice messages + */ + +#define _CHN_VOICE(dev, event, chn, note, parm) { \ + _SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (note);\ + _seqbuf[_seqbufptr+5] = (parm);\ + _seqbuf[_seqbufptr+6] = (0);\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +#define SEQ_START_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) + +#define SEQ_STOP_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) + +#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ + _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) + +/* + * Midi channel messages + */ + +#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \ + _SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (p1);\ + _seqbuf[_seqbufptr+5] = (p2);\ + *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ + _SEQ_ADVBUF(8);} +/* + * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits + * sending any MIDI bytes but it's absolutely not possible. Trying to do + * so _will_ cause problems with MPU401 intelligent mode). + * + * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be + * sent by calling SEQ_SYSEX() several times (there must be no other events + * between them). First sysex fragment must have 0xf0 in the first byte + * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte + * between these sysex start and end markers cannot be larger than 0x7f. Also + * lengths of each fragments (except the last one) must be 6. + * + * Breaking the above rules may work with some MIDI ports but is likely to + * cause fatal problems with some other devices (such as MPU401). + */ +#define SEQ_SYSEX(dev, buf, len) { \ + int i, l=(len); if (l>6)l=6;\ + _SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_SYSEX;\ + for(i=0;i + * + * $FreeBSD: src/sys/i386/include/speaker.h,v 1.5.4.1 1999/08/29 16:06:52 peter Exp $ + */ + +#ifndef _MACHINE_SPEAKER_H_ +#define _MACHINE_SPEAKER_H_ + +#include + +#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */ +#define SPKRTUNE _IO('S', 2) /* emit tone sequence*/ + +typedef struct +{ + int frequency; /* in hertz */ + int duration; /* in 1/100ths of a second */ +} +tone_t; + +/* + * Strings written to the speaker device are interpreted as tunes and played; + * see the spkr(4) man page for details. + */ + +#endif /* !_MACHINE_SPEAKER_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/specialreg.h ./modules/label/machine/specialreg.h --- ../sys-altq/modules/label/machine/specialreg.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/specialreg.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,340 @@ +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91 + * $FreeBSD: src/sys/i386/include/specialreg.h,v 1.16.2.2 1999/08/31 01:19:23 msmith Exp $ + */ + +#ifndef _MACHINE_SPECIALREG_H_ +#define _MACHINE_SPECIALREG_H_ + +/* + * Bits in 386 special registers: + */ +#define CR0_PE 0x00000001 /* Protected mode Enable */ +#define CR0_MP 0x00000002 /* "Math" Present (NPX or NPX emulator) */ +#define CR0_EM 0x00000004 /* EMulate non-NPX coproc. (trap ESC only) */ +#define CR0_TS 0x00000008 /* Task Switched (if MP, trap ESC and WAIT) */ +#ifdef notused +#define CR0_ET 0x00000010 /* Extension Type (387 (if set) vs 287) */ +#endif +#define CR0_PG 0x80000000 /* PaGing enable */ + +/* + * Bits in 486 special registers: + */ +#define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */ +#define CR0_WP 0x00010000 /* Write Protect (honor page protect in + all modes) */ +#define CR0_AM 0x00040000 /* Alignment Mask (set to enable AC flag) */ +#define CR0_NW 0x20000000 /* Not Write-through */ +#define CR0_CD 0x40000000 /* Cache Disable */ + +/* + * Bits in PPro special registers + */ +#define CR4_VME 0x00000001 /* Virtual 8086 mode extensions */ +#define CR4_PVI 0x00000002 /* Protected-mode virtual interrupts */ +#define CR4_TSD 0x00000004 /* Time stamp disable */ +#define CR4_DE 0x00000008 /* Debugging extensions */ +#define CR4_PSE 0x00000010 /* Page size extensions */ +#define CR4_PAE 0x00000020 /* Physical address extension */ +#define CR4_MCE 0x00000040 /* Machine check enable */ +#define CR4_PGE 0x00000080 /* Page global enable */ +#define CR4_PCE 0x00000100 /* Performance monitoring counter enable */ + +/* + * CPUID instruction features register + */ +#define CPUID_FPU 0x0001 +#define CPUID_VME 0x0002 +#define CPUID_DE 0x0004 +#define CPUID_PSE 0x0008 +#define CPUID_TSC 0x0010 +#define CPUID_MSR 0x0020 +#define CPUID_PAE 0x0040 +#define CPUID_MCE 0x0080 +#define CPUID_CX8 0x0100 +#define CPUID_APIC 0x0200 +#define CPUID_B10 0x0400 +#define CPUID_B11 0x0800 +#define CPUID_MTRR 0x1000 +#define CPUID_PGE 0x2000 +#define CPUID_MCA 0x4000 +#define CPUID_CMOV 0x8000 + +/* + * Model-specific registers for the i386 family + */ +#define MSR_P5_MC_ADDR 0x000 +#define MSR_P5_MC_TYPE 0x001 +#define MSR_TSC 0x010 +#define MSR_APICBASE 0x01b +#define MSR_EBL_CR_POWERON 0x02a +#define MSR_BIOS_UPDT_TRIG 0x079 +#define MSR_BIOS_SIGN 0x08b +#define MSR_PERFCTR0 0x0c1 +#define MSR_PERFCTR1 0x0c2 +#define MSR_MTRRcap 0x0fe +#define MSR_MCG_CAP 0x179 +#define MSR_MCG_STATUS 0x17a +#define MSR_MCG_CTL 0x17b +#define MSR_EVNTSEL0 0x186 +#define MSR_EVNTSEL1 0x187 +#define MSR_DEBUGCTLMSR 0x1d9 +#define MSR_LASTBRANCHFROMIP 0x1db +#define MSR_LASTBRANCHTOIP 0x1dc +#define MSR_LASTINTFROMIP 0x1dd +#define MSR_LASTINTTOIP 0x1de +#define MSR_ROB_CR_BKUPTMPDR6 0x1e0 +#define MSR_MTRRVarBase 0x200 +#define MSR_MTRR64kBase 0x250 +#define MSR_MTRR16kBase 0x258 +#define MSR_MTRR4kBase 0x268 +#define MSR_MTRRdefType 0x2ff +#define MSR_MC0_CTL 0x400 +#define MSR_MC0_STATUS 0x401 +#define MSR_MC0_ADDR 0x402 +#define MSR_MC0_MISC 0x403 +#define MSR_MC1_CTL 0x404 +#define MSR_MC1_STATUS 0x405 +#define MSR_MC1_ADDR 0x406 +#define MSR_MC1_MISC 0x407 +#define MSR_MC2_CTL 0x408 +#define MSR_MC2_STATUS 0x409 +#define MSR_MC2_ADDR 0x40a +#define MSR_MC2_MISC 0x40b +#define MSR_MC4_CTL 0x40c +#define MSR_MC4_STATUS 0x40d +#define MSR_MC4_ADDR 0x40e +#define MSR_MC4_MISC 0x40f +#define MSR_MC3_CTL 0x410 +#define MSR_MC3_STATUS 0x411 +#define MSR_MC3_ADDR 0x412 +#define MSR_MC3_MISC 0x413 + +/* + * Constants related to MTRRs + */ +#define MTRR_N64K 8 /* numbers of fixed-size entries */ +#define MTRR_N16K 16 +#define MTRR_N4K 64 + +/* + * Cyrix configuration registers, accessible as IO ports. + */ +#define CCR0 0xc0 /* Configuration control register 0 */ +#define CCR0_NC0 0x01 /* First 64K of each 1M memory region is + non-cacheable */ +#define CCR0_NC1 0x02 /* 640K-1M region is non-cacheable */ +#define CCR0_A20M 0x04 /* Enables A20M# input pin */ +#define CCR0_KEN 0x08 /* Enables KEN# input pin */ +#define CCR0_FLUSH 0x10 /* Enables FLUSH# input pin */ +#define CCR0_BARB 0x20 /* Flushes internal cache when entering hold + state */ +#define CCR0_CO 0x40 /* Cache org: 1=direct mapped, 0=2x set + assoc */ +#define CCR0_SUSPEND 0x80 /* Enables SUSP# and SUSPA# pins */ + +#define CCR1 0xc1 /* Configuration control register 1 */ +#define CCR1_RPL 0x01 /* Enables RPLSET and RPLVAL# pins */ +#define CCR1_SMI 0x02 /* Enables SMM pins */ +#define CCR1_SMAC 0x04 /* System management memory access */ +#define CCR1_MMAC 0x08 /* Main memory access */ +#define CCR1_NO_LOCK 0x10 /* Negate LOCK# */ +#define CCR1_SM3 0x80 /* SMM address space address region 3 */ + +#define CCR2 0xc2 +#define CCR2_WB 0x02 /* Enables WB cache interface pins */ +#define CCR2_SADS 0x02 /* Slow ADS */ +#define CCR2_LOCK_NW 0x04 /* LOCK NW Bit */ +#define CCR2_SUSP_HLT 0x08 /* Suspend on HALT */ +#define CCR2_WT1 0x10 /* WT region 1 */ +#define CCR2_WPR1 0x10 /* Write-protect region 1 */ +#define CCR2_BARB 0x20 /* Flushes write-back cache when entering + hold state. */ +#define CCR2_BWRT 0x40 /* Enables burst write cycles */ +#define CCR2_USE_SUSP 0x80 /* Enables suspend pins */ + +#define CCR3 0xc3 +#define CCR3_SMILOCK 0x01 /* SMM register lock */ +#define CCR3_NMI 0x02 /* Enables NMI during SMM */ +#define CCR3_LINBRST 0x04 /* Linear address burst cycles */ +#define CCR3_SMMMODE 0x08 /* SMM Mode */ +#define CCR3_MAPEN0 0x10 /* Enables Map0 */ +#define CCR3_MAPEN1 0x20 /* Enables Map1 */ +#define CCR3_MAPEN2 0x40 /* Enables Map2 */ +#define CCR3_MAPEN3 0x80 /* Enables Map3 */ + +#define CCR4 0xe8 +#define CCR4_IOMASK 0x07 +#define CCR4_MEM 0x08 /* Enables momory bypassing */ +#define CCR4_DTE 0x10 /* Enables directory table entry cache */ +#define CCR4_FASTFPE 0x20 /* Fast FPU exception */ +#define CCR4_CPUID 0x80 /* Enables CPUID instruction */ + +#define CCR5 0xe9 +#define CCR5_WT_ALLOC 0x01 /* Write-through allocate */ +#define CCR5_SLOP 0x02 /* LOOP instruction slowed down */ +#define CCR5_LBR1 0x10 /* Local bus region 1 */ +#define CCR5_ARREN 0x20 /* Enables ARR region */ + +#define CCR6 0xea + +#define CCR7 0xeb + +/* Performance Control Register (5x86 only). */ +#define PCR0 0x20 +#define PCR0_RSTK 0x01 /* Enables return stack */ +#define PCR0_BTB 0x02 /* Enables branch target buffer */ +#define PCR0_LOOP 0x04 /* Enables loop */ +#define PCR0_AIS 0x08 /* Enables all instrcutions stalled to + serialize pipe. */ +#define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */ +#define PCR0_BTBRT 0x40 /* Enables BTB test register. */ +#define PCR0_LSSER 0x80 /* Disable reorder */ + +/* Device Identification Registers */ +#define DIR0 0xfe +#define DIR1 0xff + +/* + * The following four 3-byte registers control the non-cacheable regions. + * These registers must be written as three separate bytes. + * + * NCRx+0: A31-A24 of starting address + * NCRx+1: A23-A16 of starting address + * NCRx+2: A15-A12 of starting address | NCR_SIZE_xx. + * + * The non-cacheable region's starting address must be aligned to the + * size indicated by the NCR_SIZE_xx field. + */ +#define NCR1 0xc4 +#define NCR2 0xc7 +#define NCR3 0xca +#define NCR4 0xcd + +#define NCR_SIZE_0K 0 +#define NCR_SIZE_4K 1 +#define NCR_SIZE_8K 2 +#define NCR_SIZE_16K 3 +#define NCR_SIZE_32K 4 +#define NCR_SIZE_64K 5 +#define NCR_SIZE_128K 6 +#define NCR_SIZE_256K 7 +#define NCR_SIZE_512K 8 +#define NCR_SIZE_1M 9 +#define NCR_SIZE_2M 10 +#define NCR_SIZE_4M 11 +#define NCR_SIZE_8M 12 +#define NCR_SIZE_16M 13 +#define NCR_SIZE_32M 14 +#define NCR_SIZE_4G 15 + +/* + * The address region registers are used to specify the location and + * size for the eight address regions. + * + * ARRx + 0: A31-A24 of start address + * ARRx + 1: A23-A16 of start address + * ARRx + 2: A15-A12 of start address | ARR_SIZE_xx + */ +#define ARR0 0xc4 +#define ARR1 0xc7 +#define ARR2 0xca +#define ARR3 0xcd +#define ARR4 0xd0 +#define ARR5 0xd3 +#define ARR6 0xd6 +#define ARR7 0xd9 + +#define ARR_SIZE_0K 0 +#define ARR_SIZE_4K 1 +#define ARR_SIZE_8K 2 +#define ARR_SIZE_16K 3 +#define ARR_SIZE_32K 4 +#define ARR_SIZE_64K 5 +#define ARR_SIZE_128K 6 +#define ARR_SIZE_256K 7 +#define ARR_SIZE_512K 8 +#define ARR_SIZE_1M 9 +#define ARR_SIZE_2M 10 +#define ARR_SIZE_4M 11 +#define ARR_SIZE_8M 12 +#define ARR_SIZE_16M 13 +#define ARR_SIZE_32M 14 +#define ARR_SIZE_4G 15 + +/* + * The region control registers specify the attributes associated with + * the ARRx addres regions. + */ +#define RCR0 0xdc +#define RCR1 0xdd +#define RCR2 0xde +#define RCR3 0xdf +#define RCR4 0xe0 +#define RCR5 0xe1 +#define RCR6 0xe2 +#define RCR7 0xe3 + +#define RCR_RCD 0x01 /* Disables caching for ARRx (x = 0-6). */ +#define RCR_RCE 0x01 /* Enables caching for ARR7. */ +#define RCR_WWO 0x02 /* Weak write ordering. */ +#define RCR_WL 0x04 /* Weak locking. */ +#define RCR_WG 0x08 /* Write gathering. */ +#define RCR_WT 0x10 /* Write-through. */ +#define RCR_NLB 0x20 /* LBA# pin is not asserted. */ + +/* AMD Write Allocate Top-Of-Memory and Control Register */ +#define AMD_WT_ALLOC_TME 0x40000 /* top-of-memory enable */ +#define AMD_WT_ALLOC_PRE 0x20000 /* programmable range enable */ +#define AMD_WT_ALLOC_FRE 0x10000 /* fixed (A0000-FFFFF) range enable */ + + +#ifndef LOCORE +static __inline u_char +read_cyrix_reg(u_char reg) +{ + outb(0x22, reg); + return inb(0x23); +} + +static __inline void +write_cyrix_reg(u_char reg, u_char data) +{ + outb(0x22, reg); + outb(0x23, data); +} +#endif + +#endif /* !_MACHINE_SPECIALREG_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/spigot.h ./modules/label/machine/spigot.h --- ../sys-altq/modules/label/machine/spigot.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/spigot.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,96 @@ +/* + * Video spigot capture driver. + * + * Copyright (c) 1995, Jim Lowe. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Version 1.2, Aug 30, 1995. + */ + +#ifndef _MACHINE_SPIGOT_H_ +#define _MACHINE_SPIGOT_H_ + +#include + +struct spigot_info { + unsigned long maddr; + unsigned short irq; +}; + +/* + * Get memory address. + */ +#define SPIGOT_GET_INFO _IOR('s', 4, struct spigot_info) +/* + * Set up a user interrupt. + */ +#define SPIGOT_SETINT _IOW('s', 5, int) +/* + * Allow/disallow access to the I/O Page. + */ +#define SPIGOT_IOPL_ON _IO ('s', 6) +#define SPIGOT_IOPL_OFF _IO ('s', 7) + +#ifndef KERNEL +/* + * Defines for spigot library. + */ +unsigned short * spigot_open(char *dev); +void spigot_close(void); +void spigot_set_capture_size(int width, int vtof); +unsigned char spigot_start_xfer(int num_frames); +void spigot_stop_xfer(void); +unsigned char spigot_status(void); + +/* + * Define the status bits. + */ +#define SPIGOT_COLOR 0x01 /* Color present (No color) */ +#define SPIGOT_60HZ 0x02 /* 60 hz input signal (50hz) */ +#define SPIGOT_NO_HORIZONTAL_LOCK 0x04 /* Horizontal lock present */ +#define SPIGOT_HPLL_LOCKED 0x08 /* HPLL locked (HPLL unlocked)*/ +#define SPIGOT_VCR_MODE 0x10 /* VCR mode (TV mode) */ +#define SPIGOT_VSYNC_PRESENT 0x20 /* Vsync present */ + +/* + * spigot_open() returns a data address pointing to the spigot data. + * Each read from this address returns the next word. The ``dev'' passed + * is usually "/dev/spigot". Data is described in the phillips desktop + * video data handbook under the 7191 chip. Formats may be either + * YUV 4:2:2 or YUV 4:1:1. A sample device driver for ``nv'' is included + * with this code. + * + * spigot_close() cleans up and closes the device. + * + * spigot_set_capture_size() will set the capture window size. Width should be + * one of: 80, 160, 240, 320, or 640 for NTSC or + * 96, 192, 288, 384 for PAL. + * vtof is the Vertical top of frame offset and must be between 0 and 15 lines. + * + * spigot_start_xfer() will start a transfer from the 7191 to the data fifo. + * spigot_stop_xfer() will clear the data fifo and abort any transfers. + * + * spigot_status() will return the above status bits. + */ +#endif /* !KERNEL */ + +#endif /* !_MACHINE_SPIGOT_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/stdarg.h ./modules/label/machine/stdarg.h --- ../sys-altq/modules/label/machine/stdarg.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/stdarg.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdarg.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/i386/include/stdarg.h,v 1.9.4.1 1999/08/29 16:06:53 peter Exp $ + */ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +typedef char *va_list; + +#define __va_size(type) \ + (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + +#ifdef __GNUC__ +#define va_start(ap, last) \ + ((ap) = (va_list)__builtin_next_arg(last)) +#else +#define va_start(ap, last) \ + ((ap) = (va_list)&(last) + __va_size(last)) +#endif + +#define va_arg(ap, type) \ + (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) + +#define va_end(ap) + +#endif /* !_STDARG_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/sysarch.h ./modules/label/machine/sysarch.h --- ../sys-altq/modules/label/machine/sysarch.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/sysarch.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/sysarch.h,v 1.10.2.1 1999/08/29 16:06:53 peter Exp $ + */ + +/* + * Architecture specific syscalls (i386) + */ +#ifndef _MACHINE_SYSARCH_H_ +#define _MACHINE_SYSARCH_H_ + +#define I386_GET_LDT 0 +#define I386_SET_LDT 1 + /* I386_IOPL */ +#define I386_GET_IOPERM 3 +#define I386_SET_IOPERM 4 + /* xxxxx */ +#define I386_VM86 6 + +#ifndef KERNEL +#include + +union descriptor; + +__BEGIN_DECLS +int i386_get_ldt __P((int, union descriptor *, int)); +int i386_set_ldt __P((int, union descriptor *, int)); +int i386_get_ioperm __P((unsigned int, unsigned int *, int *)); +int i386_set_ioperm __P((unsigned int, unsigned int, int)); +int i386_vm86 __P((int, void *)); +__END_DECLS +#endif /* !KERNEL */ + +#endif /* !_MACHINE_SYSARCH_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/trap.h ./modules/label/machine/trap.h --- ../sys-altq/modules/label/machine/trap.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/trap.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)trap.h 5.4 (Berkeley) 5/9/91 + * $FreeBSD: src/sys/i386/include/trap.h,v 1.7.4.1 1999/08/29 16:06:54 peter Exp $ + */ + +#ifndef _MACHINE_TRAP_H_ +#define _MACHINE_TRAP_H_ + +/* + * Trap type values + * also known in trap.c for name strings + */ + +#define T_PRIVINFLT 1 /* privileged instruction */ +#define T_BPTFLT 3 /* breakpoint instruction */ +#define T_ARITHTRAP 6 /* arithmetic trap */ +#define T_ASTFLT 7 /* system forced exception */ +#define T_PROTFLT 9 /* protection fault */ +#define T_TRCTRAP 10 /* debug exception (sic) */ +#define T_PAGEFLT 12 /* page fault */ +#define T_ALIGNFLT 14 /* alignment fault */ + +#define T_DIVIDE 18 /* integer divide fault */ +#define T_NMI 19 /* non-maskable trap */ +#define T_OFLOW 20 /* overflow trap */ +#define T_BOUND 21 /* bound instruction fault */ +#define T_DNA 22 /* device not available fault */ +#define T_DOUBLEFLT 23 /* double fault */ +#define T_FPOPFLT 24 /* fp coprocessor operand fetch fault */ +#define T_TSSFLT 25 /* invalid tss fault */ +#define T_SEGNPFLT 26 /* segment not present fault */ +#define T_STKFLT 27 /* stack fault */ +#define T_MCHK 28 /* machine check trap */ +#define T_RESERVED 29 /* reserved (unknown) */ + +/* XXX most of the following codes aren't used, but could be. */ + +/* definitions for */ +#define ILL_RESAD_FAULT T_RESADFLT +#define ILL_PRIVIN_FAULT T_PRIVINFLT +#define ILL_RESOP_FAULT T_RESOPFLT +#define ILL_ALIGN_FAULT T_ALIGNFLT +#define ILL_FPOP_FAULT T_FPOPFLT /* coprocessor operand fault */ + +/* codes for SIGFPE/ARITHTRAP */ +#define FPE_INTOVF_TRAP 0x1 /* integer overflow */ +#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */ +#define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ +#define FPE_FLTOVF_TRAP 0x4 /* floating overflow */ +#define FPE_FLTUND_TRAP 0x5 /* floating underflow */ +#define FPE_FPU_NP_TRAP 0x6 /* floating point unit not present */ +#define FPE_SUBRNG_TRAP 0x7 /* subrange out of bounds */ + +/* codes for SIGBUS */ +#define BUS_PAGE_FAULT T_PAGEFLT /* page fault protection base */ +#define BUS_SEGNP_FAULT T_SEGNPFLT /* segment not present */ +#define BUS_STK_FAULT T_STKFLT /* stack segment */ +#define BUS_SEGM_FAULT T_RESERVED /* segment protection base */ + +/* Trap's coming from user mode */ +#define T_USER 0x100 + +#endif /* !_MACHINE_TRAP_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/tss.h ./modules/label/machine/tss.h --- ../sys-altq/modules/label/machine/tss.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/tss.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/tss.h,v 1.8.4.1 1999/08/29 16:06:55 peter Exp $ + */ + +#ifndef _MACHINE_TSS_H_ +#define _MACHINE_TSS_H_ 1 + +/* + * Intel 386 Context Data Type + */ + +struct i386tss { + int tss_link; /* actually 16 bits: top 16 bits must be zero */ + int tss_esp0; /* kernel stack pointer privilege level 0 */ +#define tss_ksp tss_esp0 + int tss_ss0; /* actually 16 bits: top 16 bits must be zero */ + int tss_esp1; /* kernel stack pointer privilege level 1 */ + int tss_ss1; /* actually 16 bits: top 16 bits must be zero */ + int tss_esp2; /* kernel stack pointer privilege level 2 */ + int tss_ss2; /* actually 16 bits: top 16 bits must be zero */ + int tss_cr3; /* page table directory */ +#define tss_ptd tss_cr3 + int tss_eip; /* program counter */ +#define tss_pc tss_eip + int tss_eflags; /* program status longword */ +#define tss_psl tss_eflags + int tss_eax; + int tss_ecx; + int tss_edx; + int tss_ebx; + int tss_esp; /* user stack pointer */ +#define tss_usp tss_esp + int tss_ebp; /* user frame pointer */ +#define tss_fp tss_ebp + int tss_esi; + int tss_edi; + int tss_es; /* actually 16 bits: top 16 bits must be zero */ + int tss_cs; /* actually 16 bits: top 16 bits must be zero */ + int tss_ss; /* actually 16 bits: top 16 bits must be zero */ + int tss_ds; /* actually 16 bits: top 16 bits must be zero */ + int tss_fs; /* actually 16 bits: top 16 bits must be zero */ + int tss_gs; /* actually 16 bits: top 16 bits must be zero */ + int tss_ldt; /* actually 16 bits: top 16 bits must be zero */ + int tss_ioopt; /* options & io offset bitmap: currently zero */ + /* XXX unimplemented .. i/o permission bitmap */ +}; +#endif /* _MACHINE_TSS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/types.h ./modules/label/machine/types.h --- ../sys-altq/modules/label/machine/types.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/types.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.3 (Berkeley) 1/5/94 + * $FreeBSD: src/sys/i386/include/types.h,v 1.16.2.1 1999/08/29 16:06:55 peter Exp $ + */ + +#ifndef _MACHINE_TYPES_H_ +#define _MACHINE_TYPES_H_ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +typedef struct _physadr { + int r[1]; +} *physadr; + +typedef struct label_t { + int val[6]; +} label_t; +#endif + +typedef unsigned int vm_offset_t; +typedef __int64_t vm_ooffset_t; +typedef unsigned int vm_pindex_t; +typedef unsigned int vm_size_t; + +typedef __int32_t register_t; + + +#ifdef KERNEL +typedef int intfptr_t; +typedef unsigned int uintfptr_t; +#endif + +/* Interrupt mask (spl, xxx_imask, etc) */ +typedef __uint32_t intrmask_t; + +/* Interrupt handler function type. */ +typedef void inthand2_t __P((void *_cookie)); + +#endif /* !_MACHINE_TYPES_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/ultrasound.h ./modules/label/machine/ultrasound.h --- ../sys-altq/modules/label/machine/ultrasound.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/ultrasound.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,121 @@ +#ifndef _ULTRASOUND_H_ +#define _ULTRASOUND_H_ +/* + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* + * ultrasound.h - Macros for programming the Gravis Ultrasound + * These macros are extremely device dependent + * and not portable. + */ + +/* + * Private events for Gravis Ultrasound (GUS) + * + * Format: + * byte 0 - SEQ_PRIVATE (0xfe) + * byte 1 - Synthesizer device number (0-N) + * byte 2 - Command (see below) + * byte 3 - Voice number (0-31) + * bytes 4 and 5 - parameter P1 (unsigned short) + * bytes 6 and 7 - parameter P2 (unsigned short) + * + * Commands: + * Each command affects one voice defined in byte 3. + * Unused parameters (P1 and/or P2 *MUST* be initialized to zero). + * _GUS_NUMVOICES - Sets max. number of concurrent voices (P1=14-31, default 16) + * _GUS_VOICESAMPLE- ************ OBSOLETE ************* + * _GUS_VOICEON - Starts voice (P1=voice mode) + * _GUS_VOICEOFF - Stops voice (no parameters) + * _GUS_VOICEFADE - Stops the voice smoothly. + * _GUS_VOICEMODE - Alters the voice mode, don't start or stop voice (P1=voice mode) + * _GUS_VOICEBALA - Sets voice balance (P1, 0=left, 7=middle and 15=right, default 7) + * _GUS_VOICEFREQ - Sets voice (sample) playback frequency (P1=Hz) + * _GUS_VOICEVOL - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) + * _GUS_VOICEVOL2 - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) + * (Like GUS_VOICEVOL but doesn't change the hw + * volume. It just updates volume in the voice table). + * + * _GUS_RAMPRANGE - Sets limits for volume ramping (P1=low volume, P2=high volume) + * _GUS_RAMPRATE - Sets the speed for volume ramping (P1=scale, P2=rate) + * _GUS_RAMPMODE - Sets the volume ramping mode (P1=ramping mode) + * _GUS_RAMPON - Starts volume ramping (no parameters) + * _GUS_RAMPOFF - Stops volume ramping (no parameters) + * _GUS_VOLUME_SCALE - Changes the volume calculation constants + * for all voices. + */ + +#define _GUS_NUMVOICES 0x00 +#define _GUS_VOICESAMPLE 0x01 /* OBSOLETE */ +#define _GUS_VOICEON 0x02 +#define _GUS_VOICEOFF 0x03 +#define _GUS_VOICEMODE 0x04 +#define _GUS_VOICEBALA 0x05 +#define _GUS_VOICEFREQ 0x06 +#define _GUS_VOICEVOL 0x07 +#define _GUS_RAMPRANGE 0x08 +#define _GUS_RAMPRATE 0x09 +#define _GUS_RAMPMODE 0x0a +#define _GUS_RAMPON 0x0b +#define _GUS_RAMPOFF 0x0c +#define _GUS_VOICEFADE 0x0d +#define _GUS_VOLUME_SCALE 0x0e +#define _GUS_VOICEVOL2 0x0f +#define _GUS_VOICE_POS 0x10 + +/* + * GUS API macros + */ + +#define _GUS_CMD(chn, voice, cmd, p1, p2) \ + {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\ + _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\ + _seqbuf[_seqbufptr+3] = voice;\ + *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\ + *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\ + _SEQ_ADVBUF(8);} + +#define GUS_NUMVOICES(chn, p1) _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0) +#define GUS_VOICESAMPLE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */ +#define GUS_VOICEON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0) +#define GUS_VOICEOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0) +#define GUS_VOICEFADE(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0) +#define GUS_VOICEMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0) +#define GUS_VOICEBALA(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0) +#define GUS_VOICEFREQ(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \ + (p) & 0xffff, ((p) >> 16) & 0xffff) +#define GUS_VOICEVOL(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0) +#define GUS_VOICEVOL2(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0) +#define GUS_RAMPRANGE(chn, voice, low, high) _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high)) +#define GUS_RAMPRATE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2)) +#define GUS_RAMPMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0) +#define GUS_RAMPON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0) +#define GUS_RAMPOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0) +#define GUS_VOLUME_SCALE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2)) +#define GUS_VOICE_POS(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICE_POS, \ + (p) & 0xffff, ((p) >> 16) & 0xffff) + +#endif diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/varargs.h ./modules/label/machine/varargs.h --- ../sys-altq/modules/label/machine/varargs.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/varargs.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)varargs.h 8.2 (Berkeley) 3/22/94 + * $FreeBSD: src/sys/i386/include/varargs.h,v 1.7.4.1 1999/08/29 16:06:56 peter Exp $ + */ + +#ifndef _VARARGS_H_ +#define _VARARGS_H_ + +typedef char *va_list; + +#define __va_size(type) \ + (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + +#ifdef __GNUC__ +#define va_alist __builtin_va_alist +#endif +#if __GNUC__ > 1 +#define va_dcl int va_alist; ... +#else +#define va_dcl int va_alist; +#endif + +#define va_start(ap) \ + ((ap) = (va_list)&va_alist) + +#define va_arg(ap, type) \ + (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) + +#define va_end(ap) + +#endif /* !_VARARGS_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/vm86.h ./modules/label/machine/vm86.h --- ../sys-altq/modules/label/machine/vm86.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/vm86.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,167 @@ +/*- + * Copyright (c) 1997 Jonathan Lemon + * All rights reserved. + * + * Derived from register.h, which is + * Copyright (c) 1996 Michael Smith. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/i386/include/vm86.h,v 1.8.2.2 1999/08/29 16:06:57 peter Exp $ + */ + +#ifndef _MACHINE_VM86_H_ +#define _MACHINE_VM86_H_ 1 + +/* standard register representation */ +typedef union { + u_int r_ex; + struct { + u_short r_x; + u_int :16; + } r_w; + struct { + u_char r_l; + u_char r_h; + u_int :16; + } r_b; +} reg86_t; + +/* layout must match definition of struct trapframe_vm86 in */ + +struct vm86frame { + int kernel_es; + int kernel_ds; + reg86_t edi; + reg86_t esi; + reg86_t ebp; + reg86_t isp; + reg86_t ebx; + reg86_t edx; + reg86_t ecx; + reg86_t eax; + int vmf_trapno; + int vmf_err; + reg86_t eip; + reg86_t cs; + reg86_t eflags; + reg86_t esp; + reg86_t ss; + reg86_t es; + reg86_t ds; + reg86_t fs; + reg86_t gs; +#define vmf_ah eax.r_b.r_h +#define vmf_al eax.r_b.r_l +#define vmf_ax eax.r_w.r_x +#define vmf_eax eax.r_ex +#define vmf_bh ebx.r_b.r_h +#define vmf_bl ebx.r_b.r_l +#define vmf_bx ebx.r_w.r_x +#define vmf_ebx ebx.r_ex +#define vmf_ch ecx.r_b.r_h +#define vmf_cl ecx.r_b.r_l +#define vmf_cx ecx.r_w.r_x +#define vmf_ecx ecx.r_ex +#define vmf_dh edx.r_b.r_h +#define vmf_dl edx.r_b.r_l +#define vmf_dx edx.r_w.r_x +#define vmf_edx edx.r_ex +#define vmf_si esi.r_w.r_x +#define vmf_di edi.r_w.r_x +#define vmf_cs cs.r_w.r_x +#define vmf_ds ds.r_w.r_x +#define vmf_es es.r_w.r_x +#define vmf_ss ss.r_w.r_x +#define vmf_sp esp.r_w.r_x +#define vmf_ip eip.r_w.r_x +#define vmf_flags eflags.r_w.r_x +#define vmf_eflags eflags.r_ex +}; + +#define VM86_PMAPSIZE 3 +#define VMAP_MALLOC 1 /* page was malloced by us */ + +struct vm86context { + int npages; + struct vm86pmap { + int flags; + int pte_num; + vm_offset_t kva; + u_int old_pte; + } pmap[VM86_PMAPSIZE]; +}; + +#define VM_USERCHANGE (PSL_USERCHANGE | PSL_RF) +#define VME_USERCHANGE (VM_USERCHANGE | PSL_VIP | PSL_VIF) + +struct vm86_kernel { + caddr_t vm86_intmap; /* interrupt map */ + u_int vm86_eflags; /* emulated flags */ + int vm86_has_vme; /* VME support */ + int vm86_inited; /* we were initialized */ + int vm86_debug; + caddr_t vm86_sproc; /* address of sproc */ +}; + +struct i386_vm86_args { + int sub_op; /* sub-operation to perform */ + char *sub_args; /* args */ +}; + +#define VM86_INIT 1 +#define VM86_SET_VME 2 +#define VM86_GET_VME 3 +#define VM86_INTCALL 4 + +struct vm86_init_args { + int debug; /* debug flag */ + int cpu_type; /* cpu type to emulate */ + u_char int_map[32]; /* interrupt map */ +}; + +struct vm86_vme_args { + int state; /* status */ +}; + +struct vm86_intcall_args { + int intnum; + struct vm86frame vmf; +}; + +extern int in_vm86call; + +struct proc; +extern int vm86_emulate __P((struct vm86frame *)); +extern int vm86_sysarch __P((struct proc *, char *)); +extern void vm86_trap __P((struct vm86frame *)); +extern int vm86_intcall __P((int, struct vm86frame *)); +extern int vm86_datacall __P((int, struct vm86frame *, struct vm86context *)); +extern void initial_bioscalls __P((u_int *, u_int *)); +extern vm_offset_t vm86_getpage __P((struct vm86context *, int)); +extern vm_offset_t vm86_addpage __P((struct vm86context *, int, vm_offset_t)); +extern int vm86_getptr __P((struct vm86context *, vm_offset_t, + u_short *, u_short *)); + +extern vm_offset_t vm86_getaddr __P((struct vm86context *, u_short, u_short)); + +#endif /* _MACHINE_VM86_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/vmparam.h ./modules/label/machine/vmparam.h --- ../sys-altq/modules/label/machine/vmparam.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/vmparam.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 1994 John S. Dyson + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 + * $FreeBSD: src/sys/i386/include/vmparam.h,v 1.30.2.2 1999/08/29 16:06:58 peter Exp $ + */ + + +#ifndef _MACHINE_VMPARAM_H_ +#define _MACHINE_VMPARAM_H_ 1 + +/* + * Machine dependent constants for 386. + */ + +#define VM_PROT_READ_IS_EXEC /* if you can read -- then you can exec */ + +/* + * Virtual memory related constants, all in bytes + */ +#define MAXTSIZ (128UL*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (128UL*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (512UL*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64UL*1024*1024) /* max stack size */ +#endif +#ifndef SGROWSIZ +#define SGROWSIZ (128UL*1024) /* amount to grow stack */ +#endif + +#define USRTEXT (1*PAGE_SIZE) /* base of user text XXX bogus */ + +/* + * Size of the Shared Memory Pages page table. + */ +#ifndef SHMMAXPGS +#define SHMMAXPGS 1024 /* XXX until we have more kmap space */ +#endif + +/* + * The time for a process to be blocked before being very swappable. + * This is a number of seconds which the system takes as being a non-trivial + * amount of real time. You probably shouldn't change this; + * it is used in subtle ways (fractions and multiples of it are, that is, like + * half of a ``long time'', almost a long time, etc.) + * It is related to human patience and other factors which don't really + * change over time. + */ +#define MAXSLP 20 + + +/* + * Virtual addresses of things. Derived from the page directory and + * page table indexes from pmap.h for precision. + * Because of the page that is both a PD and PT, it looks a little + * messy at times, but hey, we'll do anything to save a page :-) + */ + +#define VM_MAX_KERNEL_ADDRESS VADDR(KPTDI+NKPDE, 0) +#define VM_MIN_KERNEL_ADDRESS VADDR(PTDPTDI, PTDPTDI) + +#define KERNBASE VADDR(KPTDI, 0) + +#define KPT_MAX_ADDRESS VADDR(PTDPTDI, KPTDI+NKPT) +#define KPT_MIN_ADDRESS VADDR(PTDPTDI, KPTDI) + +#define UPT_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI) +#define UPT_MIN_ADDRESS VADDR(PTDPTDI, 0) + +#define VM_MAXUSER_ADDRESS VADDR(UMAXPTDI, UMAXPTEOFF) + +#define USRSTACK VM_MAXUSER_ADDRESS + +#define VM_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI) +#define VM_MIN_ADDRESS ((vm_offset_t)0) + +/* virtual sizes (bytes) for various kernel submaps */ +#ifndef VM_KMEM_SIZE +#define VM_KMEM_SIZE (12 * 1024 * 1024) +#endif + +/* + * How many physical pages per KVA page allocated. + * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * is the total KVA space allocated for kmem_map. + */ +#ifndef VM_KMEM_SIZE_SCALE +#define VM_KMEM_SIZE_SCALE (3) +#endif + +/* + * Ceiling on amount of kmem_map kva space. + */ +#ifndef VM_KMEM_SIZE_MAX +#define VM_KMEM_SIZE_MAX (200 * 1024 * 1024) +#endif + +/* initial pagein size of beginning of executable file */ +#ifndef VM_INITIAL_PAGEIN +#define VM_INITIAL_PAGEIN 16 +#endif + +#endif /* _MACHINE_VMPARAM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/modules/label/machine/wtio.h ./modules/label/machine/wtio.h --- ../sys-altq/modules/label/machine/wtio.h Wed Dec 31 19:00:00 1969 +++ ./modules/label/machine/wtio.h Wed Dec 1 17:28:10 1999 @@ -0,0 +1,30 @@ +#ifndef _MACHINE_WTIO_H +#define _MACHINE_WTIO_H + +/* + * Streamer tape driver for 386bsd and FreeBSD. + * Supports Archive and Wangtek compatible QIC-02/QIC-36 boards. + * + * Copyright (C) 1993 by: + * Sergey Ryzhkov + * Serge Vakulenko + * + * This software is distributed with NO WARRANTIES, not even the implied + * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Authors grant any other persons or organizations permission to use + * or modify this software as long as this message is kept with the software, + * all derivative works or modified versions. + * + * This driver is derived from the old 386bsd Wangtek streamer tape driver, + * made by Robert Baron at CMU, based on Intel sources. + * + * $FreeBSD: src/sys/i386/include/wtio.h,v 1.3.4.1 1999/08/29 16:06:58 peter Exp $ + * + */ + +/* formats for printing flags and error values */ +#define WTDS_BITS "\20\1inuse\2read\3write\4start\5rmark\6wmark\7rew\10excep\11vol\12wo\13ro\14wany\15rany\16wp\17timer\20active" +#define WTER_BITS "\20\1eof\2bnl\3uda\4eom\5wrp\6usl\7cni\11por\12erm\13bpe\14bom\15mbd\16ndt\17ill" + +#endif /* _MACHINE_WTIO_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/net/atmstat.h ./net/atmstat.h --- ../sys-altq/net/atmstat.h Wed Dec 31 19:00:00 1969 +++ ./net/atmstat.h Tue Mar 21 12:19:17 2000 @@ -0,0 +1,65 @@ +/****************************************************/ +/* file: atmstat.h */ +/* created: June 8 1998 */ +/* Keng Lim */ +/* ISI-East */ +/* history: */ +/* June 15 1998 added tx_slot struct -Keng */ +/****************************************************/ + + +#ifndef ENSTAT_H +#define ENSTAT_H + + + +/* is there a better way? */ +/* this actually has the same value as MID_NTX_CH in midwayreg.h */ +#define NUM_TX_SLOTS 8 + + +/* use a struct in case we need to add more stats */ +typedef struct transmit_slot_stats { + int vci_assgn; /* vci assigned to slot */ + long txmbovr; /* transmit-slot queue overflow count */ + long bfree; /* # buffer size on card for this slot */ + long mbsize; /* software q size */ + long txbuf2small; /* pkt drop count when tx slot buf smaller than pkt size */ +} tx_slot; + +struct atm_stat { + char *if_name; + int level; + int reset; + /* stats */ + long vtrash; /* sw copy of counter */ + long otrash; /* sw copy of counter */ + long ttrash; /* # of RBD's with T bit set */ + long mfix; /* # of times we had to call mfix */ + long mfixfail; /* # of times mfix failed */ + long headbyte; /* # of times we used BYTE DMA at front */ + long tailbyte; /* # of times we used BYTE DMA at end */ + long tailflush; /* # of times we had to FLUSH out DMA bytes */ + long txmbovr; /* # of times we dropped due to mbsize */ + long dmaovr; /* tx dma overflow count */ + long txoutspace; /* out of space in xmit buffer */ + long txdtqout; /* out of DTQs */ + long launch; /* total # of launches */ + long lheader; /* # of launches without OB header */ + long ltail; /* # of launches without OB tail */ + long hwpull; /* # of pulls off hardware service list */ + long swadd; /* # of pushes on sw service list */ + long rxqnotus; /* # of times we pull from rx q, but fail */ + long rxqus; /* # of good pulls from rx q */ + long rxoutboth; /* # of times out of mbufs and DRQs */ + long rxdrqout; /* # of times out of DRQs */ + long rxmbufout; /* # of time out of mbufs */ + long natm_drops; /* number of packets dropped */ + tx_slot txslot[NUM_TX_SLOTS]; /* transmit slot specific stats */ +}; + +#endif /* ENSTAT_H */ + + + + diff -urN --exclude=compile --exclude=@ ../sys-altq/net/if_atm.h ./net/if_atm.h --- ../sys-altq/net/if_atm.h Wed Jan 12 15:47:46 2000 +++ ./net/if_atm.h Tue Mar 21 12:19:17 2000 @@ -36,20 +36,15 @@ * net/if_atm.h */ +#ifndef _NET_IFATM_H_ +#define _NET_IFATM_H_ + #if (defined(__FreeBSD__) || defined(__bsdi__)) && defined(KERNEL) #ifndef _KERNEL #define _KERNEL #endif #endif /* freebsd doesn't define _KERNEL */ -#ifndef NO_ATM_PVCEXT -/* - * ATM_PVCEXT enables PVC extention: VP/VC shaping - * and PVC shadow interfaces. - */ -#define ATM_PVCEXT /* enable pvc extention */ -#endif - #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) #define RTALLOC1(A,B) rtalloc1((A),(B)) #elif defined(__FreeBSD__) @@ -59,6 +54,7 @@ /* * pseudo header for packet transmission */ + struct atm_pseudohdr { u_int8_t atm_ph[4]; /* flags+VPI+VCI1(msb)+VCI2(lsb) */ }; @@ -74,15 +70,39 @@ #define ATM_PH_AAL5 0x01 /* use AAL5? (0 == aal0) */ #define ATM_PH_LLCSNAP 0x02 /* use the LLC SNAP encoding (iff aal5) */ -#ifdef ATM_PVCEXT -#define ATM_PH_INERNAL 0x20 /* reserve for kernel internal use */ -#endif #define ATM_PH_DRIVER7 0x40 /* reserve for driver's use */ #define ATM_PH_DRIVER8 0x80 /* reserve for driver's use */ #define ATMMTU 9180 /* ATM MTU size for IP */ /* XXX: could be 9188 with LLC/SNAP according to comer */ +#include + +/* + * ifatmreq and ifatmconf: Used to obtain a list of configured VCCs + * on an atm card. + */ + +struct ifatmreq { + char ifar_name[IFNAMSIZ]; /* if name, ex: en0 */ + u_int16_t ifar_vci; /* VCI */ + u_int8_t ifar_vpi; /* VPI */ + u_int8_t ifar_flags; /* Encaps, AAL, etc */ + int ifar_pcr; /* Peak rate cells/sec */ + int ifar_refcnt; /* Number of connections using VCI */ +}; + +struct ifatmconf { + int ifac_len; /* size of the associated buffer */ + int ifac_cnt; /* Number of entries/pseudo-ifs returned */ + union { + caddr_t ifacu_buf; + struct ifatmreq *ifacu_req; + } ifac_ifacu; +#define ifac_buf ifac_ifacu.ifacu_buf /* buffer address */ +#define ifac_req ifac_ifacu.ifacu_req /* array of structures returned */ +}; + /* user's ioctl hook for raw atm mode */ #define SIOCRAWATM _IOWR('a', 122, int) /* set driver's raw mode */ @@ -95,35 +115,29 @@ #define SIOCATMENA _IOWR('a', 123, struct atm_pseudoioctl) /* enable */ #define SIOCATMDIS _IOWR('a', 124, struct atm_pseudoioctl) /* disable */ -#ifdef ATM_PVCEXT +/* user's ioctl hook for setting the TXSPEED --Milind */ +#define SIOCTXSPEED _IOWR('a', 125, trfdesc)/* set driver's raw mode */ -/* structure to control PVC transmitter */ -struct pvctxreq { - /* first entry must be compatible with struct ifreq */ - char pvc_ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ - struct atm_pseudohdr pvc_aph; /* (flags) + vpi:vci */ - struct atm_pseudohdr pvc_joint; /* for vp shaping: another vc - to share the shaper */ - int pvc_pcr; /* peak cell rate (shaper value) */ -}; - -/* structure to control PVC bridging */ -struct pvcfwdreq { - /* first entry must be compatible with struct ifreq */ - char pvc_ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ - char pvc_ifname2[IFNAMSIZ]; /* if name to be bridged to/from */ - int pvc_op; /* 1:add 0:delete */ -}; +/* a way to create a PVC which takes npcb sharing stuff into account */ +#define SIOCNEWVC _IOWR('a', 126, struct ifatmreq) -/* use ifioctl for now */ -#define SIOCSPVCFWD _IOW('i', 93, struct pvcfwdreq) -#define SIOCGPVCFWD _IOWR('i', 94, struct pvcfwdreq) -#define SIOCSPVCTX _IOWR('i', 95, struct pvctxreq) -#define SIOCGPVCTX _IOWR('i', 96, struct pvctxreq) -#define SIOCSPVCSIF _IOWR('i', 97, struct ifreq) -#define SIOCGPVCSIF _IOWR('i', 98, struct ifreq) +/* user ioctl for retrieving configured VCC info */ +#define SIOCGATMCONF _IOWR('a', 127, struct ifatmconf) -#endif /* ATM_PVCEXT */ +/* and to delete a VC */ +#define SIOCDELVC _IOWR('a', 128, struct ifatmreq) + +#define SIOCATMSTAT _IOWR('a',121, struct atm_stat) /* en dump */ + +/* to be used with SIOENDUMP */ +#define END_SWSL 0x00000040 /* swsl state */ +#define END_DRQ 0x00000020 /* drq state */ +#define END_DTQ 0x00000010 /* dtq state */ +#define END_RX 0x00000008 /* rx state */ +#define END_TX 0x00000004 /* tx state */ +#define END_MREGS 0x00000002 /* registers */ +#define END_STATS 0x00000001 /* dump stats */ +#define END_BITS "\20\7SWSL\6DRQ\5DTQ\4RX\3TX\2MREGS\1STATS" /* * XXX forget all the garbage in if_llc.h and do it the easy way @@ -150,28 +164,4 @@ struct rtentry *)); #endif -#ifdef ATM_PVCEXT -#ifdef _KERNEL -#include -/* - * ATM PVC subinterface: a trick to assign a subinterface - * to a PVC. - * with a pvc subinterface, each PVC looks like an individual - * Point-to-Point interface. - * as opposed to the NBMA model, a pvc subinterface is inherently - * multicast capable (no LANE/MARS required). - */ -struct pvcsif { - /* - * The ifnet struct _must_ be at the head of this structure. - */ - struct ifnet sif_if; /* ifnet structure per pvc */ - struct atm_pseudohdr sif_aph; /* flags + vpi:vci */ - int sif_vci; /* vci no */ - struct ifnet *sif_fwdifp; /* bridging ifp */ - SLIST_ENTRY(pvcsif) sif_links; -}; -struct ifnet *pvcsif_alloc __P((void)); -int pvc_set_fwd __P((char *, char *, int)); -#endif -#endif /* ATM_PVCEXT */ +#endif /* _NET_IFATM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/net/if_atmsubr.c ./net/if_atmsubr.c --- ../sys-altq/net/if_atmsubr.c Wed Jan 12 15:47:46 2000 +++ ./net/if_atmsubr.c Tue Mar 21 12:52:31 2000 @@ -39,16 +39,26 @@ #include "opt_altq.h" #endif -#include "opt_inet.h" -#include "opt_natm.h" +#include "opt_label.h" #include #include +#include +#include #include +#include #include + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) #include -#include +#else +#include +#endif /* FBSD 3.x */ + #include +#include + +#include #include #include @@ -60,6 +70,12 @@ #include #include #include /* XXX: for ETHERTYPE_* */ + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) +#include "opt_inet.h" +#include "opt_natm.h" +#endif + #if defined(INET) || defined(INET6) #include #endif @@ -67,15 +83,38 @@ #include #endif +#ifdef INET6 + +#ifdef IPV6_INRIA_VERSION +#include +#include +#include +#endif /* INRIA */ + +#ifdef __KAME__ +#include +#endif /* __KAME__ */ + +#endif /* INET6 */ + +#include "en.h" +#include "enp.h" +#include +#include + #ifdef ALTQ -#include +# ifdef __KAME__ +# include +# else +# include +# endif #ifdef AFMAP #include #endif #endif -#ifndef ETHERTYPE_IPV6 -#define ETHERTYPE_IPV6 0x86dd +#if defined(LABEL) || defined(LABEL_MODULE) +#include #endif #define senderr(e) { error = (e); goto bad;} @@ -107,13 +146,21 @@ struct atm_pseudohdr atmdst, *ad; register struct mbuf *m = m0; register struct rtentry *rt; + struct mbuf *mcopy = (struct mbuf *)0; struct atmllc *atmllc; - struct atmllc *llc_hdr = NULL; u_int32_t atm_flags; + int own=0; /* pkt destined to self? */ #ifdef ALTQ struct pr_hdr pr_hdr; #endif +#if defined(LABEL) || defined(LABEL_MODULE) + int stacksize = 0; + int queue_type; + LabelTableEntryPtr labelentryptr = NULL; + EthLabel *labelptr, *labelhelp,label; +#endif + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -132,6 +179,13 @@ /* * check route */ +#if defined(LABEL) || defined(LABEL_MODULE) + if (rt0) + if (ifp == ((LabelTableEntryPtr)rt0)->lteForward) { + labelentryptr = ((LabelTableEntryPtr)rt0); + rt0 = NULL; + } +#endif if ((rt = rt0) != NULL) { if ((rt->rt_flags & RTF_UP) == 0) { /* route went down! */ @@ -161,44 +215,41 @@ */ if (dst) { switch (dst->sa_family) { -#if defined(INET) || defined(INET6) #ifdef INET case AF_INET: + if (!atmresolve(rt, m, dst, ifp, &atmdst, &own)) { + m = NULL; + /* XXX: atmresolve already free'd it */ + senderr(EHOSTUNREACH); + /* XXX: put ATMARP stuff here */ + /* XXX: watch who frees m on failure */ + } + if (own) + return (error); + if ((m->m_flags&M_BCAST) && (ifp->if_flags&IFF_SIMPLEX)) + mcopy = m_copy(m, 0, (int)M_COPYALL); + etype = htons(ETHERTYPE_IP); + break; #endif #ifdef INET6 case AF_INET6: -#endif - if (dst->sa_family == AF_INET6) - etype = htons(ETHERTYPE_IPV6); - else - etype = htons(ETHERTYPE_IP); -#ifdef ATM_PVCEXT - if (ifp->if_flags & IFF_POINTOPOINT) { - /* pvc subinterface */ - struct pvcsif *pvcsif = (struct pvcsif *)ifp; - atmdst = pvcsif->sif_aph; - break; - } -#endif - if (!atmresolve(rt, m, dst, &atmdst)) { - m = NULL; + if (!atmresolve(rt, m, dst, ifp, &atmdst, &own)) { + m = NULL; /* XXX: atmresolve already free'd it */ senderr(EHOSTUNREACH); /* XXX: put ATMARP stuff here */ /* XXX: watch who frees m on failure */ } + if (own) + return (error); + /* No M_BCAST for IPv6 */ +# ifndef __KAME__ + m->m_flags &= ~M_NOPROBE; +# endif + etype = htons(ETHERTYPE_IPV6); break; -#endif /* INET || INET6 */ +#endif /* INET6 */ - case AF_UNSPEC: - /* - * XXX: bpfwrite. assuming dst contains 12 bytes - * (atm pseudo header (4) + LLC/SNAP (8)) - */ - bcopy(dst->sa_data, &atmdst, sizeof(atmdst)); - llc_hdr = (struct atmllc *)(dst->sa_data + sizeof(atmdst)); - break; - default: #if defined(__NetBSD__) || defined(__OpenBSD__) printf("%s: can't handle af%d\n", ifp->if_xname, @@ -210,22 +261,32 @@ senderr(EAFNOSUPPORT); } + if (mcopy) { +#if defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 300000) + (void) looutput(ifp, mcopy, dst, rt); +#else + ifp->if_opackets++; + ifp->if_obytes += m->m_pkthdr.len; + if_simloop(ifp, m, dst, 0); +#endif + } + #if defined(ALTQ) && defined(AFMAP) if (ifp->if_altqflags & ALTQF_DRIVER1) { - /* try to map flow to vpi/vci. */ + /* try to map flow to vpi/vci. */ struct flowinfo flow; - struct afm *afm; + struct afm *afm; altq_extractflow(m, &pr_hdr, &flow, FIMB_ALL); - if ((afm = afm_match(ifp, &flow)) != NULL) { - /* matching entry found. overwrite vpi:vci. */ + if ((afm = afm_match(ifp, &flow)) != NULL) { + /* matching entry found. overwrite vpi:vci. */ #if 0 printf("%s%d: atm_output:afmap vci %d -> %d\n", - ifp->if_name, ifp->if_unit, - ATM_PH_VCI(&atmdst), afm->afm_vci); + ifp->if_name, ifp->if_unit, + ATM_PH_VCI(&atmdst), afm->afm_vci); #endif - ATM_PH_VPI(&atmdst) = afm->afm_vpi; - ATM_PH_SETVCI(&atmdst, afm->afm_vci); + ATM_PH_VPI(&atmdst) = afm->afm_vpi; + ATM_PH_SETVCI(&atmdst, afm->afm_vci); afm->afms_packets++; afm->afms_bytes = m->m_pkthdr.len; @@ -233,6 +294,39 @@ } #endif /* ALTQ && AFMAP */ +#if defined(LABEL) || defined(LABEL_MODULE) + if(labelentryptr) { + if(labelentryptr->lteTTL) { + bzero((char *)&label, sizeof(EthLabel)); /* XXX skb */ + SetEthLabel(label,labelentryptr->lteNewLabel); + SetEthTTL(label, labelentryptr->lteTTL); + if(labelentryptr->lteSlabel == 1) + SetEthS(label); + if((label_eth_header_ptr) && (label_stack_size_ptr)){ + (*label_eth_header_ptr)(m, &etype, + labelentryptr); + + if((stacksize = (*label_stack_size_ptr)(&label, + ifp->if_flags)) < 0) { return error; } + } + + /* Now add the SHIM header to the packet */ + M_PREPEND(m, stacksize, M_DONTWAIT); + if(m == 0) + senderr(ENOBUFS); + labelhelp = mtod(m, EthLabel *); + if(label_add_stack_ptr) { + (*label_add_stack_ptr)(&label, labelhelp, ifp->if_flags, stacksize); + } + /* change family in pr_hdr so that we can queue based on label */ + pr_hdr.ph_family = PF_LABEL; + pr_hdr.ph_hdr = (caddr_t *)labelhelp; + } else { + goto bad; + } + } +#endif /*LABEL*/ + /* * must add atm_pseudohdr to data */ @@ -246,14 +340,10 @@ *ad = atmdst; if (atm_flags & ATM_PH_LLCSNAP) { atmllc = (struct atmllc *)(ad + 1); - if (llc_hdr == NULL) { - bcopy(ATMLLC_HDR, atmllc->llchdr, - sizeof(atmllc->llchdr)); - ATM_LLC_SETTYPE(atmllc, etype); + bcopy(ATMLLC_HDR, atmllc->llchdr, + sizeof(atmllc->llchdr)); + ATM_LLC_SETTYPE(atmllc, etype); /* note: already in network order */ - } - else - bcopy(llc_hdr, atmllc, sizeof(struct atmllc)); } } @@ -261,15 +351,19 @@ * Queue message on interface, and start output if interface * not yet active. */ + #ifdef ALTQ if (ALTQ_IS_ON(ifp)) { - s = splimp(); + s = splimp(); error = (*ifp->if_altqenqueue)(ifp, m, &pr_hdr, ALTEQ_NORMAL); splx(s); if (error) { IF_DROP(&ifp->if_snd); } else { + if(labelentryptr){ + labelentryptr->lteStatsOut++; + } ifp->if_obytes += m->m_pkthdr.len; if (m->m_flags & M_MCAST) ifp->if_omcasts++; @@ -279,19 +373,24 @@ #endif /* ALTQ */ s = splimp(); + if (IF_QFULL(&ifp->if_snd)) { IF_DROP(&ifp->if_snd); #ifdef ALTQ_ACCOUNT ALTQ_ACCOUNTING(ifp, m, &pr_hdr, ALTEQ_ACCDROP); -#endif +#endif /* ALTQ_ACCOUNT */ splx(s); senderr(ENOBUFS); } + if(labelentryptr){ + labelentryptr->lteStatsOut++; + } ifp->if_obytes += m->m_pkthdr.len; IF_ENQUEUE(&ifp->if_snd, m); #ifdef ALTQ_ACCOUNT ALTQ_ACCOUNTING(ifp, m, &pr_hdr, ALTEQ_ACCOK); -#endif +#endif /* ALTQ_ACCOUNT */ + if ((ifp->if_flags & IFF_OACTIVE) == 0) (*ifp->if_start)(ifp); splx(s); @@ -318,95 +417,212 @@ u_int16_t etype = ETHERTYPE_IP; /* default */ int s; +#if defined(LABEL) || defined(LABEL_MODULE) + LabelTablePtr labelptr = NULL; + EthLabel label, *labelhelp; + struct sockaddr_in tempdst, *dst = NULL; + LabelTableEntryPtr entry = NULL; + struct mbuf* mcopy; +#endif + if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); return; } + +#if 0 + /* Avoid updating if_lastchange per packet, as in the ALTQ driver */ +#if (defined(__FreeBSD__) && (__FreeBSD_version >= 300000)) + getmicrotime(&ifp->if_lastchange); +#else + ifp->if_lastchange = time; +#endif +#endif /* 0 */ + ifp->if_ibytes += m->m_pkthdr.len; if (rxhand) { #ifdef NATM - struct natmpcb *npcb = rxhand; - s = splimp(); /* in case 2 atm cards @ diff lvls */ - npcb->npcb_inq++; /* count # in queue */ - splx(s); - schednetisr(NETISR_NATM); - inq = &natmintrq; - m->m_pkthdr.rcvif = rxhand; /* XXX: overload */ + struct natmpcb *npcb = rxhand; + s = splimp(); /* in case 2 atm cards @ diff lvls */ + npcb->npcb_inq++; /* count # in queue */ + splx(s); + schednetisr(NETISR_NATM); + inq = &natmintrq; + m->m_pkthdr.rcvif = rxhand; /* XXX: overload */ #else - printf("atm_input: NATM detected but not configured in kernel\n"); - m_freem(m); - return; + printf("atm_input: NATM detected but not configured in kernel\n"); + m_freem(m); + return; #endif } else { - /* - * handle LLC/SNAP header, if present - */ - if (ATM_PH_FLAGS(ah) & ATM_PH_LLCSNAP) { - struct atmllc *alc; - if (m->m_len < sizeof(*alc) && - (m = m_pullup(m, sizeof(*alc))) == 0) - return; /* failed */ - alc = mtod(m, struct atmllc *); - if (bcmp(alc, ATMLLC_HDR, 6)) { -#if defined(__NetBSD__) || defined(__OpenBSD__) - printf("%s: recv'd invalid LLC/SNAP frame [vp=%d,vc=%d]\n", - ifp->if_xname, ATM_PH_VPI(ah), ATM_PH_VCI(ah)); -#elif defined(__FreeBSD__) || defined(__bsdi__) - printf("%s%d: recv'd invalid LLC/SNAP frame [vp=%d,vc=%d]\n", - ifp->if_name, ifp->if_unit, ATM_PH_VPI(ah), ATM_PH_VCI(ah)); -#endif - m_freem(m); - return; - } - etype = ATM_LLC_TYPE(alc); - m_adj(m, sizeof(*alc)); - } - -#ifdef ATM_PVCEXT - /* atm bridging support */ - if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LINK2)) == - (IFF_POINTOPOINT|IFF_LINK2)) { - struct pvcsif *pvcsif = (struct pvcsif *)ifp; - - if (pvcsif->sif_fwdifp != NULL) { - struct sockaddr dst; - - /* set address family to dummy dst addr */ - switch (etype) { - case ETHERTYPE_IP: - dst.sa_family = AF_INET; - break; - case ETHERTYPE_IPV6: - dst.sa_family = AF_INET6; - break; - default: - m_freem(m); - return; - } - atm_output(pvcsif->sif_fwdifp, m, &dst, NULL); - return; - } - } -#endif /* ATM_PVCEXT */ + /* + * handle LLC/SNAP header, if present + */ + if (ATM_PH_FLAGS(ah) & ATM_PH_LLCSNAP) { + struct atmllc *alc; + if (m->m_len < sizeof(*alc) && (m = m_pullup(m, sizeof(*alc))) == 0) + return; /* failed */ + alc = mtod(m, struct atmllc *); + if (bcmp(alc, ATMLLC_HDR, 6)) { + ifp->if_ierrors++; + m_freem(m); + return; + } + etype = ATM_LLC_TYPE(alc); + m_adj(m, sizeof(*alc)); + } - switch (etype) { + switch (etype) { #ifdef INET - case ETHERTYPE_IP: - schednetisr(NETISR_IP); - inq = &ipintrq; - break; + case ETHERTYPE_IP: + schednetisr(NETISR_IP); + inq = &ipintrq; + break; #endif #ifdef INET6 - case ETHERTYPE_IPV6: - schednetisr(NETISR_IPV6); - inq = &ip6intrq; - break; + case ETHERTYPE_IPV6: +#ifdef __KAME__ + schednetisr(NETISR_IPV6); + inq = &ip6intrq; +#else + schednetisr(NETISR_IP); + inq = &ipintrq; +#endif /* __KAME__ */ + break; +#endif /* INET6 */ + +#if defined(LABEL) || defined(LABEL_MODULE) + case ETH_P_UMPLS: /* ntohs value for ETH_P_UMPLS */ + case ETH_P_MMPLS: /* ntohs value for ETH_P_MMPLS */ + if(lt_find_by_label_ptr){ + /* extract label and see if needs to be forwarded or not */ + label = *mtod(m, EthLabel *); + labelptr = (*lt_find_by_label_ptr)(GetEthLabel(label),0); + if(labelptr != NULL) { + switch(labelptr->ltEntry.lteFlags) { + case LTE_POP: + if(GetEthS(label)) { + /* data for me not to be forwarded hence discarding label */ + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + labelptr->ltEntry.lteTTL = GetEthTTL(label); +#ifdef LABEL_DEBUG + printf("Queued Packet \n"); +#endif + schednetisr(NETISR_IP); + inq = &ipintrq; + labelptr = NULL; + break; + } + else { + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + label = *mtod(m, EthLabel *); + labelptr = (*lt_find_by_label_ptr) + (GetEthLabel(label),0); + break; + } + case LTE_SWAP: + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + bzero((char *)&tempdst,sizeof(tempdst)); + tempdst.sin_family = AF_INET; + tempdst.sin_len = sizeof(*dst); + tempdst.sin_addr.s_addr = + labelptr->ltEntry.lteNextHopAddr; + dst = &tempdst; + if(IN_MULTICAST(ntohl( + tempdst.sin_addr.s_addr))) { + m->m_flags |= M_MCAST; + } + +#ifdef LABEL_DEBUG + printf("calling ether out with label %x , addr %x \n", + labelptr->ltEntry.lteNewLabel, + tempdst.sin_addr.s_addr); +#endif + entry = &(labelptr->ltEntry); + while(entry){ + if(GetEthS(label)) { + entry->lteSlabel = 1; + } + entry->lteTTL = GetEthTTL(label)-1; + if(entry->lteTTL <= 0) { + icmp_error(m, 11, 0, 0, 0); + m_free(m); + return; + } else { + mcopy = m_copy(m, 0, M_COPYALL); + (*entry->lteForward->if_output)( + entry->lteForward, mcopy, + (struct sockaddr *)dst, + (struct rtentry *)entry); + entry = entry->lteMCastList; + } + + } + m_freem(m); + return; + case LTE_PUSH: + labelptr->ltEntry.lteTTL = GetEthTTL(label)-1; + tempdst.sin_family = AF_INET; + tempdst.sin_len = sizeof(*dst); + tempdst.sin_addr.s_addr = + labelptr->ltEntry.lteNextHopAddr; + dst = &tempdst; + +#ifdef LABEL_DEBUG + printf("calling ether out with label %u, addr %x \n", + labelptr->ltEntry.lteNewLabel, + tempdst.sin_addr.s_addr); +#endif + entry = &(labelptr->ltEntry); + while(entry){ + mcopy = m_copy(m, 0, M_COPYALL); + (*entry->lteForward->if_output)( + entry->lteForward, mcopy, + (struct sockaddr *)dst, + (struct rtentry *)entry); + entry = entry->lteMCastList; + } + m_freem(m); + return; + default: +#ifdef LABEL_DEBUG + printf(" discarding packet :-> ! %x \n", + labelptr->ltEntry.lteFlags); +#endif + m_freem(m); + return; + } + } + else { +#ifdef LABEL_DEBUG + printf(" discarding packet (labelptr NULL):-> ! \n"); #endif - default: m_freem(m); return; - } + } + } + else /* only when module not loaded */ + { +#ifdef LABEL_DEBUG + printf(" discarding packet :-< ! \n"); +#endif + m_freem(m); + return; + } + break; +#endif + + default: + m_freem(m); + return; + } } s = splimp(); @@ -429,112 +645,35 @@ register struct sockaddr_dl *sdl; ifp->if_type = IFT_ATM; - ifp->if_addrlen = 0; + ifp->if_addrlen = 6; ifp->if_hdrlen = 0; ifp->if_mtu = ATMMTU; +#if defined(INET6) && defined(IPV6_INRIA_VERSION) + ifp->if_ndtype = IFND6_PPP; +#endif ifp->if_output = atm_output; - ifp->if_snd.ifq_maxlen = 50; /* dummy */ #if defined(__NetBSD__) || defined(__OpenBSD__) for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) -#elif defined(__FreeBSD__) && (__FreeBSD__ > 2) +#elif defined(__FreeBSD__) && (__FreeBSD_version >= 300000) for (ifa = ifp->if_addrhead.tqh_first; ifa; ifa = ifa->ifa_link.tqe_next) #elif defined(__FreeBSD__) || defined(__bsdi__) for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) #endif + if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && sdl->sdl_family == AF_LINK) { sdl->sdl_type = IFT_ATM; + /* sdl->sdl_type = IFT_ETHER; */ sdl->sdl_alen = ifp->if_addrlen; + bcopy(((struct en_softc *)ifp->if_softc)->macaddr, + LLADDR(sdl), + ifp->if_addrlen); #ifdef notyet /* if using ATMARP, store hardware address using the next line */ bcopy(ifp->hw_addr, LLADDR(sdl), ifp->if_addrlen); #endif break; } - -} - -#ifdef ATM_PVCEXT - -static int pvc_max_number = 16; /* max number of PVCs */ -static int pvc_number = 0; /* pvc unit number */ - -struct ifnet * -pvcsif_alloc() -{ - struct pvcsif *pvcsif; - - if (pvc_number >= pvc_max_number) - return (NULL); - MALLOC(pvcsif, struct pvcsif *, sizeof(struct pvcsif), - M_DEVBUF, M_WAITOK); - if (pvcsif == NULL) - return (NULL); - bzero(pvcsif, sizeof(struct pvcsif)); - -#ifdef __NetBSD__ - sprintf(pvcsif->sif_if.if_xname, "pvc%d", pvc_number++); -#else - pvcsif->sif_if.if_name = "pvc"; - pvcsif->sif_if.if_unit = pvc_number++; -#endif - return (&pvcsif->sif_if); -} - -/* - * pvc bridging support: - * add or delete brigding between 2 pvc interfaces. - */ -int -pvc_set_fwd(if_name, if_name2, op) - char *if_name, *if_name2; - int op; /* 0:delete 1:add 2:get */ -{ - struct ifnet *ifp, *ifp2; - struct pvcsif *pvcsif, *pvcsif2; - - if (strncmp(if_name, "pvc", 3) != 0 - || (ifp = ifunit(if_name)) == NULL) - return (EINVAL); - pvcsif = (struct pvcsif *)ifp; - - if (op == 2) { - /* get bridging info */ - if ((ifp2 = pvcsif->sif_fwdifp) == NULL) - *if_name2 = '\0'; - else -#ifdef __NetBSD__ - sprintf(if_name2, "%s", ifp2->if_xname); -#else - sprintf(if_name2, "%s%d", - ifp2->if_name, ifp2->if_unit); -#endif - return (0); - } - - if (strncmp(if_name2, "pvc", 3) != 0 - || (ifp2 = ifunit(if_name2)) == NULL) - return (EINVAL); - pvcsif2 = (struct pvcsif *)ifp2; - - if (op) { - /* set up bridging */ - pvcsif->sif_fwdifp = ifp2; - pvcsif2->sif_fwdifp = ifp; - ifp->if_flags |= IFF_LINK2; /* use IFF_LINK2 to show */ - ifp2->if_flags |= IFF_LINK2; /* bridging is enabled */ - } - else { - /* delete bridging */ - if (pvcsif->sif_fwdifp != ifp2 || pvcsif2->sif_fwdifp != ifp) - return (EINVAL); - pvcsif->sif_fwdifp = NULL; - pvcsif2->sif_fwdifp = NULL; - ifp->if_flags &= ~IFF_LINK2; - ifp2->if_flags &= ~IFF_LINK2; - } - return (0); } -#endif /* ATM_PVCEXT */ diff -urN --exclude=compile --exclude=@ ../sys-altq/net/if_ethersubr.c ./net/if_ethersubr.c --- ../sys-altq/net/if_ethersubr.c Wed Jan 12 15:47:46 2000 +++ ./net/if_ethersubr.c Tue Mar 21 12:36:12 2000 @@ -37,6 +37,8 @@ #include "opt_altq.h" #endif +#include "opt_label.h" + #include "opt_atalk.h" #include "opt_inet.h" #include "opt_ipx.h" @@ -114,6 +116,13 @@ #include #endif /* NVLAN > 0 */ +#if defined(LABEL) || defined(LABEL_MODULE) +#include +label_stack_size_t *label_stack_size_ptr = NULL; +label_add_stack_t *label_add_stack_ptr = NULL; +label_eth_header_t *label_eth_header_ptr = NULL; +#endif + static int ether_resolvemulti __P((struct ifnet *, struct sockaddr **, struct sockaddr *)); u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -145,9 +154,23 @@ #ifdef ALTQ struct pr_hdr pr_hdr; #endif +#if defined(LABEL) || defined(LABEL_MODULE) + int stacksize = 0; + int queue_type; + LabelTableEntryPtr labelentryptr = NULL; + EthLabel label, *labelhelp; +#endif + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); +#if defined(LABEL) || defined(LABEL_MODULE) + if (rt0) + if (ifp == ((LabelTableEntryPtr)rt0)->lteForward) { + labelentryptr = ((LabelTableEntryPtr)rt0); + rt0 = NULL; + } +#endif rt = rt0; if (rt) { if ((rt->rt_flags & RTF_UP) == 0) { @@ -357,14 +380,51 @@ senderr(EAFNOSUPPORT); } +#if defined(LABEL) || defined(LABEL_MODULE) + if(labelentryptr) { + if(labelentryptr->lteTTL) { + SetEthLabel(label, labelentryptr->lteNewLabel); + SetEthTTL(label, labelentryptr->lteTTL); + if(labelentryptr->lteSlabel == 1) { + SetEthS(label); + } + if(label_eth_header_ptr && label_stack_size_ptr){ + (*label_eth_header_ptr)(m, &type, labelentryptr); + if((stacksize = (*label_stack_size_ptr) + (&label,ifp->if_flags)) < 0) { + return error; + } + } + } else { + goto bad; + } + } +#endif + /* * Add local net header. If no space in first mbuf, * allocate another. */ +#if defined(LABEL) || defined(LABEL_MODULE) + M_PREPEND(m, sizeof(struct ether_header) + stacksize, M_DONTWAIT); +#else M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); +#endif + if (m == 0) senderr(ENOBUFS); eh = mtod(m, struct ether_header *); +#if defined(LABEL) || defined(LABEL_MODULE) + if(labelentryptr){ + labelhelp = (EthLabel *)(eh+1); + if(label_add_stack_ptr) { + (*label_add_stack_ptr)(&label, labelhelp, ifp->if_flags, stacksize); + } + /* change family in pr_hdr so that we can queue based on label */ + pr_hdr.ph_family = PF_LABEL; + pr_hdr.ph_hdr = (caddr_t *)labelhelp; + } +#endif (void)memcpy(&eh->ether_type, &type, sizeof(eh->ether_type)); (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); @@ -405,15 +465,19 @@ return (0); } #endif + queue_type = ALTEQ_NORMAL; #ifdef ALTQ if (ALTQ_IS_ON(ifp)) { s = splimp(); - error = (*ifp->if_altqenqueue)(ifp, m, &pr_hdr, ALTEQ_NORMAL); + error = (*ifp->if_altqenqueue)(ifp, m, &pr_hdr, queue_type); splx(s); if (error) { IF_DROP(&ifp->if_snd); } else { + if(labelentryptr){ + labelentryptr->lteStatsOut++; + } ifp->if_obytes += len + sizeof (struct ether_header); if (m->m_flags & M_MCAST) ifp->if_omcasts++; @@ -441,6 +505,9 @@ if ((ifp->if_flags & IFF_OACTIVE) == 0) (*ifp->if_start)(ifp); splx(s); + if(labelentryptr){ + labelentryptr->lteStatsOut++; + } ifp->if_obytes += len + sizeof (struct ether_header); if (m->m_flags & M_MCAST) ifp->if_omcasts++; @@ -466,6 +533,16 @@ register struct ifqueue *inq; u_short ether_type; int s; + +#if defined(LABEL) || defined(LABEL_MODULE) + int queue_type,stacksize; + LabelTablePtr labelptr = NULL; + EthLabel label, *labelhelp; + struct sockaddr_in tempdst, *dst = NULL; + LabelTableEntryPtr entry = NULL; + struct mbuf* mcopy; +#endif + #if defined (ISO) || defined (LLC) || defined(NETATALK) register struct llc *l; #endif @@ -509,6 +586,132 @@ inq = &arpintrq; break; #endif + +#if defined(LABEL) || defined(LABEL_MODULE) + case ETH_P_UMPLS: /* ntohs value for ETH_P_UMPLS */ + case ETH_P_MMPLS: /* ntohs value for ETH_P_MMPLS */ + if(lt_find_by_label_ptr){ + /* extract label and see if needs to be forwarded or not */ + label = *mtod(m, EthLabel *); + labelptr = (*lt_find_by_label_ptr)(GetEthLabel(label),0); + if(labelptr != NULL) { + while(labelptr) { + switch(labelptr->ltEntry.lteFlags) { + case LTE_POP: + if(GetEthS(label)) { + /* data for me not to be forwarded hence discarding label */ + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + labelptr->ltEntry.lteTTL = GetEthTTL(label); +#ifdef LABEL_DEBUG + printf("Queued Packet \n"); +#endif + schednetisr(NETISR_IP); + inq = &ipintrq; + labelptr = NULL; + break; + } + else { + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + label = *mtod(m, EthLabel *); + labelptr = (*lt_find_by_label_ptr) + (GetEthLabel(label),0); + break; + } + case LTE_SWAP: + m->m_data += 4; + m->m_len -= 4; + m->m_pkthdr.len -= 4; + bzero((char *)&tempdst,sizeof(tempdst)); + tempdst.sin_family = AF_INET; + tempdst.sin_len = sizeof(*dst); + tempdst.sin_addr.s_addr = + labelptr->ltEntry.lteNextHopAddr; + dst = &tempdst; + if(IN_MULTICAST(ntohl( + tempdst.sin_addr.s_addr))) { + m->m_flags |= M_MCAST; + } + +#ifdef LABEL_DEBUG + printf("calling ether out with label %u, addr %x \n", + labelptr->ltEntry.lteNewLabel, tempdst.sin_addr.s_addr); +#endif + entry = &(labelptr->ltEntry); + while(entry){ + if(GetEthS(label)) { + entry->lteSlabel = 1; + } + entry->lteTTL = GetEthTTL(label)-1; + if(entry->lteTTL <= 0) { + icmp_error(m, 11, 0, 0, 0); + m_free(m); + return; + } else { + mcopy = m_copy(m, 0, M_COPYALL); + (*entry->lteForward->if_output)( + entry->lteForward, mcopy, + (struct sockaddr *)dst, + (struct rtentry *)entry); + entry = entry->lteMCastList; + } + } + m_freem(m); + return; + case LTE_PUSH: + labelptr->ltEntry.lteTTL = GetEthTTL(label)-1; + tempdst.sin_family = AF_INET; + tempdst.sin_len = sizeof(*dst); + tempdst.sin_addr.s_addr = + labelptr->ltEntry.lteNextHopAddr; + dst = &tempdst; + +#ifdef LABEL_DEBUG + printf("calling ether out with label %u, addr %x \n", + labelptr->ltEntry.lteNewLabel, tempdst.sin_addr.s_addr); +#endif + entry = &(labelptr->ltEntry); + while(entry){ + mcopy = m_copy(m, 0, M_COPYALL); + (*entry->lteForward->if_output)( + entry->lteForward, mcopy, + (struct sockaddr *)dst, + (struct rtentry *)labelptr); + entry = entry->lteMCastList; + } + m_freem(m); + return; + default: +#ifdef LABEL_DEBUG + printf(" discarding packet :-> ! %x \n",labelptr->ltEntry.lteFlags); +#endif + m_freem(m); + return; + } + } + } + else { +#ifdef LABEL_DEBUG + printf(" discarding packet (labelptr NULL):-> ! \n"); +#endif + m_freem(m); + return; + } + } + else /* only when module not loaded */ + { +#ifdef LABEL_DEBUG + printf(" discarding packet :-< ! \n"); +#endif + m_freem(m); + return; + } + break; +#endif /* LABEL */ + #ifdef IPX case ETHERTYPE_IPX: schednetisr(NETISR_IPX); diff -urN --exclude=compile --exclude=@ ../sys-altq/net/route.h ./net/route.h --- ../sys-altq/net/route.h Thu Apr 6 14:05:18 2000 +++ ./net/route.h Tue Feb 15 10:40:08 2000 @@ -209,6 +209,12 @@ #define RTM_NEWMADDR 0xf /* mcast group membership being added to if */ #define RTM_DELMADDR 0x10 /* mcast group membership being deleted */ +/* LABEL EXTENTIONS TO ROUTE SOCKET */ +#define LABEL_ADD 0x12 /* Add LABEL */ +#define LABEL_DELETE 0x13 /* Delete LABEL */ +#define LABEL_CHANGE 0x14 /* Change Metrics or flags */ +#define LABEL_GET 0x15 /* Report LABEL TABLE */ + /* * Bitmask values for rtm_inits and rmx_locks. */ diff -urN --exclude=compile --exclude=@ ../sys-altq/net/rtsock.c ./net/rtsock.c --- ../sys-altq/net/rtsock.c Wed Jan 12 15:47:49 2000 +++ ./net/rtsock.c Thu Feb 17 19:51:15 2000 @@ -35,6 +35,8 @@ */ +#include "opt_label.h" + #include #include #include @@ -51,6 +53,10 @@ #include #include +#if defined(LABEL) || defined(LABEL_MODULE) +#include +#endif + MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); static struct sockaddr route_dst = { 2, PF_ROUTE, }; @@ -284,6 +290,12 @@ struct ifnet *ifp = 0; struct ifaddr *ifa = 0; +#if defined(LABEL) || defined(LABEL_MODULE) + LabelTableEntryPtr ltentry; + char *name; + char *buf; +#endif + #define senderr(e) { error = e; goto flush;} if (m == 0 || ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == 0)) @@ -306,6 +318,31 @@ dst = 0; senderr(EPROTONOSUPPORT); } + +#if defined(LABEL) || defined(LABEL_MODULE) + if(rtm->rtm_type > 0x0f) { + if(rtm->rtm_msglen > sizeof(struct rt_msghdr)) { + if(rtm->rtm_type != LABEL_GET) + { + R_Malloc(ltentry, LabelTableEntryPtr, sizeof(LabelTableEntry)); + ltentry = (LabelTableEntryPtr)((char *)(rtm) + + sizeof(struct rt_msghdr)); + name = (char *)((char *)(rtm) + sizeof(struct rt_msghdr) + sizeof(LabelTableEntry)); + name[rtm->rtm_msglen - (sizeof(struct rt_msghdr) + sizeof(LabelTableEntry))] = '\0'; + if(strlen(name)) + ltentry->lteForward = ifunit(name); + if(!ltentry->lteForward) { + if(strlen(name)) { + printf("Routing Error - %s %d \n",name,strlen(name)); + return(1); + } + } + } /* !LABEL_GET */ + } + } + else { +#endif + rtm->rtm_pid = curproc->p_pid; info.rti_addrs = rtm->rtm_addrs; if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { @@ -313,8 +350,9 @@ senderr(EINVAL); } if (dst == 0 || (dst->sa_family >= AF_MAX) - || (gate != 0 && (gate->sa_family >= AF_MAX))) + || (gate != 0 && (gate->sa_family >= AF_MAX))) { senderr(EINVAL); + } if (genmask) { struct radix_node *t; t = rn_addmask((caddr_t)genmask, 0, 1); @@ -323,6 +361,11 @@ else senderr(ENOBUFS); } + +#if defined(LABEL) || defined(LABEL_MODULE) + } +#endif + switch (rtm->rtm_type) { case RTM_ADD: @@ -450,6 +493,33 @@ break; } break; + +#if defined(LABEL) || defined(LABEL_MODULE) + case LABEL_ADD: + if(lt_add_ptr){ + (*lt_add_ptr)(ltentry); + } + return(error); + case LABEL_DELETE: + if(lt_rm_ptr) { + (*lt_rm_ptr)(ltentry); + } + return(error); + + case LABEL_CHANGE: + break; + case LABEL_GET: + buf = ((char*)rtm + sizeof(struct rt_msghdr)); + if(PrintLabelTable_ptr) + { + (*PrintLabelTable_ptr)(buf); + } + rtm->rtm_msglen = 2048; + rtm->rtm_pid = rtm->rtm_pid + 1; + dst = 0; + break; +#endif /* LABEL */ + default: senderr(EOPNOTSUPP); diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/altq.h ./netinet/altq.h --- ../sys-altq/netinet/altq.h Wed Jan 12 15:48:05 2000 +++ ./netinet/altq.h Tue Feb 1 18:25:16 2000 @@ -69,8 +69,14 @@ u_int16_t fi_dport; /* dest port */ u_int16_t fi_sport; /* src port */ u_int32_t fi_gpi; /* generalized port id for ipsec */ +#if defined(LABEL) || defined(LABEL_MODULE) + u_int32_t fi_label; /* label for this flow if any */ + u_int8_t _pad[24]; /* make the size equal to + flowinfo_in6 */ +#else u_int8_t _pad[28]; /* make the size equal to flowinfo_in6 */ +#endif }; #ifdef SIN6_LEN diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/altq_cbq.c ./netinet/altq_cbq.c --- ../sys-altq/netinet/altq_cbq.c Wed Jan 12 15:48:06 2000 +++ ./netinet/altq_cbq.c Tue Feb 15 10:29:31 2000 @@ -36,6 +36,8 @@ #include "opt_inet.h" #endif #endif /* !_NO_OPT_ALTQ_H_ */ + +#include "opt_label.h" #ifdef CBQ /* cbq is enabled by CBQ option in opt_altq.h */ /* #pragma ident "@(#)cbq.c 1.39 98/05/13 SMI" */ @@ -390,6 +392,46 @@ dfp->cbq_filter_handle); } +#if defined(LABEL) || defined(LABEL_MODULE) +static int +cbq_add_label(afp) + struct cbq_add_filter *afp; +{ + char *ifacename; + cbq_state_t *cbqp; + struct rm_class *cl; + + ifacename = afp->cbq_iface.cbq_ifacename; + if ((cbqp = altq_lookup(ifacename, ALTQT_CBQ)) == NULL) + return (EBADF); + + /* Get the pointer to class. */ + if ((cl = clh_to_clp(cbqp, afp->cbq_class_handle)) == NULL) + { + return (EINVAL); + } + + return acc_add_label(&cbqp->cbq_classifier, &afp->cbq_filter, + cl, &afp->cbq_filter_handle); +} + +static int +cbq_delete_label(dfp) + struct cbq_delete_filter *dfp; +{ + char *ifacename; + cbq_state_t *cbqp; + + ifacename = dfp->cbq_iface.cbq_ifacename; + if ((cbqp = altq_lookup(ifacename, ALTQT_CBQ)) == NULL) + return (EBADF); + + return acc_delete_label(&cbqp->cbq_classifier, + dfp->cbq_filter_handle); +} +#endif + + /* * cbq_clear_hierarchy deletes all classes and their filters on the * given interface. @@ -1050,6 +1092,17 @@ error = cbq_add_riometer((struct cbq_riometer *)addr); break; #endif + +#if defined(LABEL) || defined(LABEL_MODULE) + case CBQ_ADD_LABEL: + error = cbq_add_label((struct cbq_add_filter *)addr); + break; + + case CBQ_DEL_LABEL: + error = cbq_delete_label((struct cbq_delete_filter *)addr); + break; +#endif + default: error = EINVAL; diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/altq_cbq.h ./netinet/altq_cbq.h --- ../sys-altq/netinet/altq_cbq.h Wed Jan 12 15:48:06 2000 +++ ./netinet/altq_cbq.h Mon Feb 14 18:01:15 2000 @@ -89,6 +89,10 @@ u_long cbq_filter_handle; }; +#define CBQ_ADD_LABEL _IOWR('Q', 13, struct cbq_add_filter) +#define CBQ_DEL_LABEL _IOW('Q', 14, struct cbq_delete_filter) + + #define CBQ_ADD_CLASS _IOWR('Q', 5, struct cbq_add_class) typedef struct cbq_class_spec { diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/altq_subr.c ./netinet/altq_subr.c --- ../sys-altq/netinet/altq_subr.c Wed Jan 12 15:48:05 2000 +++ ./netinet/altq_subr.c Tue Feb 22 17:56:38 2000 @@ -34,6 +34,8 @@ #endif #endif /* !_NO_OPT_ALTQ_H_ */ +#include "opt_label.h" + #include #include #include @@ -65,6 +67,10 @@ #include #include +#if defined (LABEL) || defined (LABEL_MODULE) +#include +#endif + #ifdef __FreeBSD__ #include "opt_cpu.h" /* for FreeBSD-2.2.8 to get i586_ctr_freq */ #include @@ -308,6 +314,33 @@ } #endif /* INET6 */ +#if defined(LABEL) || defined (LABEL_MODULE) + case PF_LABEL: { + struct flowinfo_in *fin; + struct ip *ip; + EthLabel *label; + + label = (EthLabel *)pr_hdr->ph_hdr; + + fin = (struct flowinfo_in *)flow; + fin->fi_len = sizeof(struct flowinfo_in); + fin->fi_family = AF_LABEL; + + fin->fi_proto = 0; + fin->fi_tos = 0; + + fin->fi_src.s_addr = 0; + fin->fi_dst.s_addr = 0; + + fin->fi_sport = 0; + fin->fi_dport = 0; + fin->fi_gpi = 0; + fin->fi_label = GetEthLabel(*label); /* extract label */ + + return (1); + } +#endif + default: #ifdef ALTQ_DEBUG printf("altq_extractflow: unknown proto family=%d\n", pr_hdr->ph_family); @@ -657,6 +690,90 @@ return (0); } +#if defined(LABEL) || defined(LABEL_MODULE) + +int acc_add_label(classifier, filter, class, phandle) + struct acc_classifier *classifier; + struct flow_filter *filter; + void *class; + u_long *phandle; +{ + struct acc_filter *afp, *prev, *tmp; + int i, s; + + if (filter->ff_flow.fi_family != AF_INET) + { + return (EINVAL); + } + + MALLOC(afp, struct acc_filter *, sizeof(struct acc_filter), + M_DEVBUF, M_WAITOK); + if (afp == NULL) + return (ENOMEM); + bzero(afp, sizeof(struct acc_filter)); + + afp->f_filter = *filter; + afp->f_class = class; + + i = ACC_WILDCARD_INDEX; + if (filter->ff_flow.fi_family == AF_INET) { + struct flow_filter *filter4 = &afp->f_filter; + + i = ACC_GET_HASH_INDEX(filter4->ff_flow.fi_label); + } + + afp->f_handle = get_filt_handle(classifier, i); + + /* update filter bitmask */ + afp->f_fbmask = filt2fibmask(filter); + classifier->acc_fbmask |= afp->f_fbmask; + + /* + * add this filter to the filter list. + * filters are ordered from the highest rule number. + */ + s = splimp(); + prev = NULL; + LIST_FOREACH(tmp, &classifier->acc_filters[i], f_chain) { + if (tmp->f_filter.ff_ruleno > afp->f_filter.ff_ruleno) + prev = tmp; + else + break; + } + if (prev == NULL) + LIST_INSERT_HEAD(&classifier->acc_filters[i], afp, f_chain); + else + LIST_INSERT_AFTER(prev, afp, f_chain); + splx(s); + + *phandle = afp->f_handle; + return (0); +} + +int acc_delete_label(classifier, handle) + struct acc_classifier *classifier; + u_long handle; +{ + struct acc_filter *afp; + int s; + + if ((afp = filth_to_filtp(classifier, handle)) == NULL) + return (EINVAL); + + s = splimp(); + LIST_REMOVE(afp, f_chain); + splx(s); + + FREE(afp, M_DEVBUF); + + /* todo: update filt_bmask */ + + return (0); +} + +#endif + + /* * delete filters referencing to the specified class. * if the all flag is not 0, delete all the filters. @@ -783,6 +900,30 @@ } while (1); } #endif /* INET6 */ + +#if defined(LABEL) || defined (LABEL_MODULE) + else if (flowinfo->fi_family == AF_LABEL) { + struct flowinfo_in *fp = (struct flowinfo_in *)flowinfo; + + /* get the filter hash entry from its label */ + i = ACC_GET_HASH_INDEX(fp->fi_label); + + do { + /* + * go through this loop twice. first for dst + * hash, second for wildcards. + */ + LIST_FOREACH(afp, &classifier->acc_filters[i], + f_chain) + if ( afp->f_filter.ff_flow.fi_label == + fp->fi_label) + /* filter matched */ + return (afp->f_class); + + break; + } while (1); + } +#endif /* no filter matched */ return (NULL); diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/altq_var.h ./netinet/altq_var.h --- ../sys-altq/netinet/altq_var.h Wed Jan 12 15:48:05 2000 +++ ./netinet/altq_var.h Tue Feb 1 18:46:35 2000 @@ -215,6 +215,13 @@ int acc_add_filter __P((struct acc_classifier *, struct flow_filter *, void *, u_long *)); int acc_delete_filter __P((struct acc_classifier *, u_long)); + +#if defined(LABEL) || defined(LABEL_MODULE) +int acc_add_label __P((struct acc_classifier *, struct flow_filter *, + void *, u_long *)); +int acc_delete_label __P((struct acc_classifier *, u_long)); +#endif + int acc_discard_filters __P((struct acc_classifier *, void *, int)); void *acc_classify __P((struct acc_classifier *, struct flowinfo *)); u_int8_t read_dsfield __P((struct pr_hdr *)); diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/bitops.h ./netinet/bitops.h --- ../sys-altq/netinet/bitops.h Wed Dec 31 19:00:00 1969 +++ ./netinet/bitops.h Thu Feb 3 17:02:40 2000 @@ -0,0 +1,145 @@ +#ifndef _I386_BITOPS_H +#define _I386_BITOPS_H + +/* + * Copyright 1992, Linus Torvalds. + */ + +/* + * These have to be done with inline assembly: that way the bit-setting + * is guaranteed to be atomic. All bit operations return 0 if the bit + * was cleared before the operation and != 0 if it was not. + * + * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). + */ + +#ifdef __SMP__ +#define LOCK_PREFIX "lock ; " +#define SMPVOL volatile +#else +#define LOCK_PREFIX "" +#define SMPVOL +#endif + +/* + * Some hacks to defeat gcc over-optimizations.. + */ +struct __dummy { unsigned long a[100]; }; +#define ADDR (*(struct __dummy *) addr) +#define CONST_ADDR (*(const struct __dummy *) addr) + +extern int set_bit(int nr, SMPVOL void * addr); +extern int clear_bit(int nr, SMPVOL void * addr); +extern int change_bit(int nr, SMPVOL void * addr); +extern int test_bit(int nr, const SMPVOL void * addr); +extern unsigned long ffz(unsigned long word); +extern int find_next_zero_bit (void * addr, int size, int offset); +extern int find_first_zero_bit(void * addr, unsigned size); + +extern __inline__ int set_bit(int nr, SMPVOL void * addr) +{ + int oldbit; + + __asm__ __volatile__(LOCK_PREFIX + "btsl %2,%1\n\tsbbl %0,%0" + :"=r" (oldbit),"=m" (ADDR) + :"ir" (nr)); + return oldbit; +} + +extern __inline__ int clear_bit(int nr, SMPVOL void * addr) +{ + int oldbit; + + __asm__ __volatile__(LOCK_PREFIX + "btrl %2,%1\n\tsbbl %0,%0" + :"=r" (oldbit),"=m" (ADDR) + :"ir" (nr)); + return oldbit; +} + +extern __inline__ int change_bit(int nr, SMPVOL void * addr) +{ + int oldbit; + + __asm__ __volatile__(LOCK_PREFIX + "btcl %2,%1\n\tsbbl %0,%0" + :"=r" (oldbit),"=m" (ADDR) + :"ir" (nr)); + return oldbit; +} + +/* + * This routine doesn't need to be atomic. + */ +extern __inline__ int test_bit(int nr, const SMPVOL void * addr) +{ + return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) != 0; +} + +/* + * Find-bit routines.. + */ +extern __inline__ int find_first_zero_bit(void * addr, unsigned size) +{ + int res; + + if (!size) + return 0; + __asm__("cld\n\t" + "movl $-1,%%eax\n\t" + "xorl %%edx,%%edx\n\t" + "repe; scasl\n\t" + "je 1f\n\t" + "xorl -4(%%edi),%%eax\n\t" + "subl $4,%%edi\n\t" + "bsfl %%eax,%%edx\n" + "1:\tsubl %%ebx,%%edi\n\t" + "shll $3,%%edi\n\t" + "addl %%edi,%%edx" + :"=d" (res) + :"c" ((size + 31) >> 5), "D" (addr), "b" (addr) + :"ax", "cx", "di"); + return res; +} + +extern __inline__ int find_next_zero_bit (void * addr, int size, int offset) +{ + unsigned long * p = ((unsigned long *) addr) + (offset >> 5); + int set = 0, bit = offset & 31, res; + + if (bit) { + /* + * Look for zero in first byte + */ + __asm__("bsfl %1,%0\n\t" + "jne 1f\n\t" + "movl $32, %0\n" + "1:" + : "=r" (set) + : "r" (~(*p >> bit))); + if (set < (32 - bit)) + return set + offset; + set = 32 - bit; + p++; + } + /* + * No zero yet, search remaining full bytes for a zero + */ + res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr)); + return (offset + set + res); +} + +/* + * ffz = Find First Zero in word. Undefined if no zero exists, + * so code should check against ~0UL first.. + */ +extern __inline__ unsigned long ffz(unsigned long word) +{ + __asm__("bsfl %1,%0" + :"=r" (word) + :"r" (~word)); + return word; +} + +#endif /* _I386_BITOPS_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/if_atm.c ./netinet/if_atm.c --- ../sys-altq/netinet/if_atm.c Wed Jan 12 15:47:59 2000 +++ ./netinet/if_atm.c Thu Apr 13 11:08:14 2000 @@ -36,18 +36,31 @@ * IP <=> ATM address resolution. */ +#include + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) #include "opt_inet.h" #include "opt_natm.h" +#endif #if defined(INET) || defined(INET6) -#include #include -#include +#include #include #include +#include +#include +#include + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) #include +#else +#include +#endif /* FBSD 3.x */ + #include +#include #include #include @@ -55,15 +68,51 @@ #include #include +#include +#include +#include #include #ifdef NATM #include #endif +#if defined(INET6) && !defined(__KAME__) +#include +#include +#include +#endif /* INET6 */ + +#include "en.h" +#include "enp.h" +#include +#include #define SDL(s) ((struct sockaddr_dl *)s) +#if defined(INET6) && !defined(CLR_ADDR6) +#define CLR_ADDR6(a) \ + { \ + (a).s6_addr32[0] = 0; \ + (a).s6_addr32[1] = 0; \ + (a).s6_addr32[2] = 0; \ + (a).s6_addr32[3] = 0; \ + } +#define COPY_ADDR6(from, to) \ + { \ + (to).s6_addr32[0] = (from).s6_addr32[0]; \ + (to).s6_addr32[1] = (from).s6_addr32[1]; \ + (to).s6_addr32[2] = (from).s6_addr32[2]; \ + (to).s6_addr32[3] = (from).s6_addr32[3]; \ + } +#define SAME_ADDR6(a, b) \ + (((a).s6_addr32[0] == (b).s6_addr32[0]) && \ + ((a).s6_addr32[1] == (b).s6_addr32[1]) && \ + ((a).s6_addr32[2] == (b).s6_addr32[2]) && \ + ((a).s6_addr32[3] == (b).s6_addr32[3])) +/* #define IA_SIN6(ia) IA6_SIN6(ia) */ +#define IA_SIN6(ia) IA6_SIN6((struct in6_ifaddr *)ia) +#endif /* CLR_ADDR6 */ /* * atm_rtrequest: handle ATM rt request (in support of generic code) * inputs: "req" = request code @@ -79,8 +128,12 @@ { register struct sockaddr *gate = rt->rt_gateway; struct atm_pseudoioctl api; + int i; + struct en_softc *sc; + struct ifnet *ifp; #ifdef NATM - struct sockaddr_in *sin; + int chan; + struct sockaddr *sa2; struct natmpcb *npcb = NULL; struct atm_pseudohdr *aph; #endif @@ -118,7 +171,8 @@ } if (gate->sa_family != AF_LINK || gate->sa_len < sizeof(null_sdl)) { - log(LOG_DEBUG, "atm_rtrequest: bad gateway value"); + /* XXX hack: someone adding /128 addr. Use loif */ + rt->rt_ifp = loif; break; } @@ -131,23 +185,85 @@ * let native ATM know we are using this VCI/VPI * (i.e. reserve it) */ - sin = (struct sockaddr_in *) rt_key(rt); - if (sin->sin_family != AF_INET) + sa2 = (struct sockaddr *) rt_key(rt); + if ((sa2->sa_family != AF_INET) && + (sa2->sa_family != AF_INET6)) goto failed; aph = (struct atm_pseudohdr *) LLADDR(SDL(gate)); npcb = npcb_add(NULL, rt->rt_ifp, ATM_PH_VCI(aph), ATM_PH_VPI(aph)); if (npcb == NULL) goto failed; - npcb->npcb_flags |= NPCB_IP; - npcb->ipaddr.s_addr = sin->sin_addr.s_addr; + if ((npcb->npcb_flags & NPCB_IP) == 0) { + npcb->npcb_flags |= NPCB_IP; +#if !defined(INET6) || defined(__KAME__) +#define satosin(sa) ((struct sockaddr_in *)(sa)) +#endif + +#ifdef INET6 + CLR_ADDR6(npcb->ipaddr6); + if (sa2->sa_family == AF_INET) { + npcb->ipaddr6.s6_addr32[2] = htonl(0xffff); +#endif + npcb->ipaddr.s_addr = satosin(sa2)->sin_addr.s_addr; +#ifdef INET6 + } else { + COPY_ADDR6(satosin6(sa2)->sin6_addr, + npcb->ipaddr6); + } +#endif + +#if !defined(INET6) || defined(__KAME__) +#undef satosin +#endif + } /* XXX: move npcb to llinfo when ATM ARP is ready */ rt->rt_llinfo = (caddr_t) npcb; rt->rt_flags |= RTF_LLINFO; -#endif +#endif /* NATM */ + + /* + * When pseudo-i/fs are defined, limit one VC per interface. + * If there is already a different VC on this i/f, bail. + */ + sc=(struct en_softc *)rt->rt_ifp->if_softc; + ifp = rt->rt_ifp; + +#if NENP > 0 + i = ((strlen(ifp->if_name) == 2) ? 0: ifp->if_unit) + + ((strlen(ifp->if_name) > 2) ? 1: 0); + + if ((sc->vctoif[i].vci != 0) && + sc->vctoif[i].vci != ATM_PH_VCI(aph)) { + printf("atm: VC already exists on %s%d, vci: %d->%d\n", + ifp->if_name, ifp->if_unit, + sc->vctoif[i].vci, ATM_PH_VCI(aph)); + goto failed; + } + + /* + * If this VC already exists on a _different_ i/f, bail. + * We rewrite the specified VCI and set it to 0 so the + * ultimate RTM_DELETE call doesn't delete the valid VC. + */ + if (sc->vci2ifp[ATM_PH_VCI(aph)] && + sc->vci2ifp[ATM_PH_VCI(aph)] != ifp) { + printf("atm: VCI %d already exists on %s%d\n", + ATM_PH_VCI(aph), + sc->vci2ifp[ATM_PH_VCI(aph)]->if_name, + sc->vci2ifp[ATM_PH_VCI(aph)]->if_unit); + bzero(LLADDR(SDL(gate)), SDL(gate)->sdl_alen); + goto failed; + } +#endif /* NENP > 0 */ + /* * let the lower level know this circuit is active */ +#ifdef NATM + if (npcb->npcb_refcnt > 1) + break; +#endif bcopy(LLADDR(SDL(gate)), &api.aph, sizeof(api.aph)); api.rxhand = NULL; if (rt->rt_ifp->if_ioctl(rt->rt_ifp, SIOCATMENA, @@ -156,12 +272,43 @@ goto failed; } + /* + * Update the vctoif mapping in the en_softc structure. + * When no pseudo-i/f's are defined, this saves the "last" VC + * created in vctoif[]; ie., IPmc is supported only on the last + * created VC in that case. + * XXX this is done here instead of in en_rxctl + * because there we don't have the ifp. + * Deletion, however, is done there. + */ + i = ((strlen(ifp->if_name) == 2) ? 0: ifp->if_unit) + + ((strlen(ifp->if_name) > 2) ? 1: 0); + sc->vctoif[i].ifp = ifp; + sc->vctoif[i].vci = ATM_PH_VCI(&api.aph); + + if ( (chan = en_find_chan(sc,sc->vctoif[i].vci)) < 0) { + /* assgn it to 0 when all slots used */ +#ifdef DIAGNOSTIC + printf("more than 7 pseudo interfaces\n"); +#endif + chan = 0; + } + sc->txslot[chan].vci_assgn = sc->vctoif[i].vci; + sc->txvc2slot[sc->vctoif[i].vci] = chan; + sc->txchan[chan]++; + bcopy((char *)&api.aph, &sc->vctoif[i].aph, + sizeof (struct atm_pseudohdr) ); + sc->vctoif[i].refcnt = &npcb->npcb_refcnt; + + sc->vci2ifp[sc->vctoif[i].vci] = ifp; + SDL(gate)->sdl_type = rt->rt_ifp->if_type; SDL(gate)->sdl_index = rt->rt_ifp->if_index; break; failed: + printf("RTM_ADD: failed. Deleting the npcb/vci.\n"); #ifdef NATM if (npcb) { npcb_free(npcb, NPCB_DESTROY); @@ -181,16 +328,26 @@ */ if (rt->rt_flags & RTF_LLINFO) { - npcb_free((struct natmpcb *)rt->rt_llinfo, - NPCB_DESTROY); + npcb = (struct natmpcb *) rt->rt_llinfo; + /* + * npcb is deallocated by npcb_free + * only if refcnt <= 1. This is a hack to test here. XXX + */ + if (npcb->npcb_refcnt == 1) { + npcb_free(npcb, NPCB_DESTROY); + npcb = 0; + } else { + npcb_free(npcb, NPCB_DESTROY); + } rt->rt_llinfo = NULL; rt->rt_flags &= ~RTF_LLINFO; } + if (npcb && (npcb->npcb_refcnt >= 1)) + break; #endif /* * tell the lower layer to disable this circuit */ - bcopy(LLADDR(SDL(gate)), &api.aph, sizeof(api.aph)); api.rxhand = NULL; (void)rt->rt_ifp->if_ioctl(rt->rt_ifp, SIOCATMDIS, @@ -206,8 +363,11 @@ * [1] "rt" = the link level route to use (or null if need to look one up) * [2] "m" = mbuf containing the data to be sent * [3] "dst" = sockaddr_in (IP) address of dest. + * [4] "ifp" = the interface pointer on which this pkt is going out. + * This is used for bcast/mcast. * output: - * [4] "desten" = ATM pseudo header which we will fill in VPI/VCI info + * [5] "desten" = ATM pseudo header which we will fill in VPI/VCI info + * [6] "own" = If the pkt is addresses to own interface - looped back. * return: * 0 == resolve FAILED; note that "m" gets m_freem'd in this case * 1 == resolve OK; desten contains result @@ -217,19 +377,37 @@ */ int -atmresolve(rt, m, dst, desten) +atmresolve(rt, m, dst, ifp, desten, own) register struct rtentry *rt; struct mbuf *m; register struct sockaddr *dst; +struct ifnet *ifp; register struct atm_pseudohdr *desten; /* OUT */ +int *own; /* OUT */ { struct sockaddr_dl *sdl; + /* + * For bcast/mcast pkt, get the pseudohdr from softc + */ if (m->m_flags & (M_BCAST|M_MCAST)) { - log(LOG_INFO, "atmresolve: BCAST/MCAST packet detected/dumped"); - goto bad; + struct en_softc *sc = (struct en_softc *) ifp->if_softc; + int i = ((strlen(ifp->if_name) == 2) ? 0: ifp->if_unit) + + ((strlen(ifp->if_name) > 2) ? 1: 0); + + if (sc->vctoif[i].vci != 0) { + bcopy(&sc->vctoif[i].aph, desten, + sizeof(struct atm_pseudohdr)); + return(1); + } else { + log(LOG_INFO, "atmresolve: BCAST/MCAST packet detected" + "/dumped. No VC on %s%d\n", + ifp ? ifp->if_name : "", ifp ? ifp->if_unit : 0); + goto bad; + } + } if (rt == NULL) { @@ -270,8 +448,47 @@ * sdl_alen == 0). dump packet. (fall through to "bad"). */ + /* However, if the pkt is destined to our own address, loop it back + * XXX hack! + */ + if (dst) { + switch (dst->sa_family) { +#ifdef INET + case AF_INET: + if ( ((struct sockaddr_in *)(dst))->sin_addr.s_addr == + (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) { +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) + ifp->if_opackets++; + ifp->if_obytes += m->m_pkthdr.len; + if_simloop(ifp, m, dst, 0); +#else + looutput(ifp, m, dst, rt); +#endif + *own = 1; + return(1); + } +#endif /* INET */ +#ifdef INET6 + case AF_INET6: + if (SAME_ADDR6(((struct sockaddr_in6 *)(dst))->sin6_addr, \ + (IA_SIN6(rt->rt_ifa))->sin6_addr)) { +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) + ifp->if_opackets++; + ifp->if_obytes += m->m_pkthdr.len; + if_simloop(ifp, m, dst, 0); +#else + looutput(ifp, m, dst, rt); +#endif /* FBSD 3.x */ + *own = 1; + return(1); + } +#endif /* INET6 */ + default: + } + } + bad: m_freem(m); return(0); } -#endif /* INET */ +#endif /* INET || INET6 */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/if_atm.h ./netinet/if_atm.h --- ../sys-altq/netinet/if_atm.h Wed Jan 12 15:48:00 2000 +++ ./netinet/if_atm.h Fri Jun 11 03:42:36 1999 @@ -35,12 +35,11 @@ /* * if_atm.h */ - -struct atm_pseudohdr; -struct mbuf; -struct rtentry; -struct sockaddr; +#ifndef _NETINET_IFATM_H_ +#define _NETINET_IFATM_H_ void atm_rtrequest __P((int, struct rtentry *, struct sockaddr *)); int atmresolve __P((struct rtentry *, struct mbuf *, struct sockaddr *, - struct atm_pseudohdr *)); + struct ifnet *, struct atm_pseudohdr *, int *)); + +#endif /* _NETINET_IFATM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/ip_output.c ./netinet/ip_output.c --- ../sys-altq/netinet/ip_output.c Wed Jan 12 15:48:03 2000 +++ ./netinet/ip_output.c Tue Mar 7 09:59:03 2000 @@ -40,6 +40,7 @@ #include "opt_ipdn.h" #include "opt_ipdivert.h" #include "opt_ipfilter.h" +#include "opt_label.h" #include #include @@ -60,6 +61,10 @@ #include #include +#if defined(LABEL) || defined(LABEL_MODULE) +#include +#endif + #ifdef vax #include #endif @@ -107,6 +112,17 @@ static int ip_optcopy __P((struct ip *, struct ip *)); #endif +#if defined(LABEL) || defined(LABEL_MODULE) +lt_add_t *lt_add_ptr = NULL; +lt_rm_t *lt_rm_ptr = NULL; +lt_find_by_label_t *lt_find_by_label_ptr = NULL; +lt_find_by_dest_t *lt_find_by_dest_ptr = NULL; +lt_find_t *lt_find_ptr = NULL; +PrintLabelTable_t *PrintLabelTable_ptr = NULL; +extract_port_t *extract_port_ptr = NULL; +extract_key_t *extract_key_ptr = NULL; +#endif + extern struct protosw inetsw[]; @@ -129,8 +145,15 @@ struct mbuf *m = m0; int hlen = sizeof (struct ip); int len, off, error = 0; +#if defined(LABEL) || defined(LABEL_MODULE) + struct sockaddr_in tempdst, *dst = NULL; + struct in_ifaddr *ia = NULL; + LabelTablePtr labelptr=NULL; + LabelTableKeyPtr key = NULL; +#else struct sockaddr_in *dst; struct in_ifaddr *ia; +#endif int isbroadcast; #ifdef IPFIREWALL_FORWARD int fwd_rewrite_src = 0; @@ -193,6 +216,42 @@ hlen = IP_VHL_HL(ip->ip_vhl) << 2; } +#if defined(LABEL) || defined(LABEL_MODULE) + /* + * If label-switching is enabled + */ + if(extract_key_ptr) + key = (*extract_key_ptr)(ip,hlen); + if((lt_find_ptr) && ((labelptr = (*lt_find_ptr)(key))!=NULL) && (labelptr->ltEntry.lteFlags == LTE_PUSH)){ + free(key,M_DEVBUF); + bzero((char *)&tempdst,sizeof(tempdst)); + tempdst.sin_family = AF_INET; + tempdst.sin_len = sizeof(*dst); + tempdst.sin_addr.s_addr = labelptr->ltEntry.lteNextHopAddr; + labelptr->ltEntry.lteTTL = ip->ip_ttl; + labelptr->ltEntry.lteSlabel = 1; /* set to if last label */ + dst = &tempdst; + /* only some rare beginnings of multicasting and labels */ + if (IN_MULTICAST(ntohl(tempdst.sin_addr.s_addr))) + m->m_flags |= M_MCAST; + ro->ro_rt = NULL; + ifp = labelptr->ltEntry.lteForward; + if (ip->ip_src.s_addr == INADDR_ANY) { + register struct in_ifaddr *ia1; + + for (ia1 = in_ifaddrhead.tqh_first; ia1; + ia1 = ia1->ia_link.tqe_next) + if (ia1->ia_ifp == ifp) { + ip->ip_src = IA_SIN(ia1)->sin_addr; + break; + } + } + goto sendit; + } + else { + labelptr = NULL; + if(key) free(key,M_DEVBUF); +#endif /* LABEL */ dst = (struct sockaddr_in *)&ro->ro_dst; /* * If there is a cached route, @@ -353,6 +412,9 @@ goto sendit; } +#if defined(LABEL) || defined(LABEL_MODULE) + } +#endif #ifndef notdef /* * If source address not specified yet, use address @@ -610,8 +672,32 @@ } else { ip->ip_sum = in_cksum(m, hlen); } + +#if defined(LABEL) || defined(LABEL_MODULE) + if(labelptr) { + LabelTableEntryPtr entry = NULL; + struct mbuf *mbcopy; + entry = &(labelptr->ltEntry); + while(entry) { + mbcopy = m_copy(m, 0, M_COPYALL); + ifp = entry->lteForward; + error = (*ifp->if_output)(ifp, mbcopy, + (struct sockaddr *)dst, (struct rtentry *)entry); + if(entry->lteMCastList) { + entry->lteMCastList->lteTTL = entry->lteTTL; + entry->lteMCastList->lteSlabel = entry->lteSlabel; + } + entry = (entry->lteMCastList); + } + m_freem(m); + } + else + error = (*ifp->if_output)(ifp, m, + (struct sockaddr *)dst, ro->ro_rt); +#else error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, ro->ro_rt); +#endif goto done; } /* diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/jenkinshash.c ./netinet/jenkinshash.c --- ../sys-altq/netinet/jenkinshash.c Wed Dec 31 19:00:00 1969 +++ ./netinet/jenkinshash.c Thu Feb 3 15:53:31 2000 @@ -0,0 +1,417 @@ +/* +-------------------------------------------------------------------- +lookup2.c, by Bob Jenkins, December 1996 +hash(), hash2(), hash3, and mix() are externally useful functions. +Routines to test the hash are included if SELF_TEST is defined. +You can use this free for any purpose. It has no warranty. +-------------------------------------------------------------------- +*/ +/* #define SELF_TEST */ +/* + * Note (Mark): I have adapted this code slightly for my purposes - + * removed references to non-kernel header files, and made the + * interface names a bit less generic. + */ + +#ifdef SELF_TEST +#include +#include +#include +#endif + +#include + +#define jenkinshash( k, length, initval) jenkinshash3( k, length, initval) + +typedef u_int32_t ub4; /* unsigned 4-byte quantities */ +typedef u_int8_t ub1; + +#define hashsize(n) ((ub4)1<<(n)) +#define hashmask(n) (hashsize(n)-1) + +/* +-------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. +For every delta with one or two bit set, and the deltas of all three + high bits or all three low bits, whether the original value of a,b,c + is almost all zero or is uniformly distributed, +* If mix() is run forward or backward, at least 32 bits in a,b,c + have at least 1/4 probability of changing. +* If mix() is run forward, every bit of c will change between 1/3 and + 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) +mix() takes 36 machine instructions, but only 18 cycles on a superscalar + machine (like a Pentium or a Sparc). No faster mixer seems to work, + that's the result of my brute-force search. There were about 2^^68 + hashes to choose from. I only tested about a billion of those. +-------------------------------------------------------------------- +*/ +#define mix(a,b,c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<<8); \ + c -= a; c -= b; c ^= (b>>13); \ + a -= b; a -= c; a ^= (c>>12); \ + b -= c; b -= a; b ^= (a<<16); \ + c -= a; c -= b; c ^= (b>>5); \ + a -= b; a -= c; a ^= (c>>3); \ + b -= c; b -= a; b ^= (a<<10); \ + c -= a; c -= b; c ^= (b>>15); \ +} + +/* same, but slower, works on systems that might have 8 byte ub4's */ +#define mix2(a,b,c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<< 8); \ + c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \ + a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \ + b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \ + a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \ + b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \ +} + +/* +-------------------------------------------------------------------- +jenkinshash1() -- hash a variable-length key into a 32-bit value + k : the key (the unaligned variable-length array of bytes) + len : the length of the key, counting by bytes + level : can be any 4-byte value +Returns a 32-bit value. Every bit of the key affects every bit of +the return value. Every 1-bit and 2-bit delta achieves avalanche. +About 36+6len instructions. + +The best hash table sizes are powers of 2. There is no need to do +mod a prime (mod is sooo slow!). If you need less than 32 bits, +use a bitmask. For example, if you need only 10 bits, do + h = (h & hashmask(10)); +In which case, the hash table should have hashsize(10) elements. + +If you are hashing n strings (ub1 **)k, do it like this: + for (i=0, h=0; i= 12) + { + a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); + b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); + c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); + mix(a,b,c); + k += 12; len -= 12; + } + + /*------------------------------------- handle the last 11 bytes */ + c += length; + switch(len) /* all the case statements fall through */ + { + case 11: c+=((ub4)k[10]<<24); + case 10: c+=((ub4)k[9]<<16); + case 9 : c+=((ub4)k[8]<<8); + /* the first byte of c is reserved for the length */ + case 8 : b+=((ub4)k[7]<<24); + case 7 : b+=((ub4)k[6]<<16); + case 6 : b+=((ub4)k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=((ub4)k[3]<<24); + case 3 : a+=((ub4)k[2]<<16); + case 2 : a+=((ub4)k[1]<<8); + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + mix(a,b,c); + /*-------------------------------------------- report the result */ + return c; +} + + +/* +-------------------------------------------------------------------- + This works on all machines, is identical to hash() on little-endian + machines, and it is much faster than hash(), but it requires + -- that the key be an array of ub4's, and + -- that all your machines have the same endianness, and + -- that the length be the number of ub4's in the key +-------------------------------------------------------------------- +*/ +ub4 jenkinshash2( k, length, initval) +register ub4 *k; /* the key */ +register ub4 length; /* the length of the key */ +register ub4 initval; /* the previous hash, or an arbitrary value */ +{ + register ub4 a,b,c,len; + + /* Set up the internal state */ + len = length; + a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ + c = initval; /* the previous hash value */ + + /*---------------------------------------- handle most of the key */ + while (len >= 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + k += 3; len -= 3; + } + + /*-------------------------------------- handle the last 2 ub4's */ + c += length; + switch(len) /* all the case statements fall through */ + { + /* c is reserved for the length */ + case 2 : b+=k[1]; + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + mix(a,b,c); + /*-------------------------------------------- report the result */ + return c; +} + +/* +-------------------------------------------------------------------- + This is identical to hash() on little-endian machines, and it is much + faster than hash(), but a little slower than hash2(), and it requires + -- that all your machines be little-endian, for example all Intel x86 + chips or all VAXen. It gives wrong results on big-endian machines. +-------------------------------------------------------------------- +*/ + +ub4 jenkinshash3( k, length, initval) +register ub1 *k; /* the key */ +register ub4 length; /* the length of the key */ +register ub4 initval; /* the previous hash, or an arbitrary value */ +{ + register ub4 a,b,c,len; + + /* Set up the internal state */ + len = length; + a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ + c = initval; /* the previous hash value */ + + /*---------------------------------------- handle most of the key */ + if (((ub4)k)&3) + { + while (len >= 12) /* unaligned */ + { + a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); + b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); + c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); + mix(a,b,c); + k += 12; len -= 12; + } + } + else + { + while (len >= 12) /* aligned */ + { + a += *(ub4 *)(k+0); + b += *(ub4 *)(k+4); + c += *(ub4 *)(k+8); + mix(a,b,c); + k += 12; len -= 12; + } + } + + /*------------------------------------- handle the last 11 bytes */ + c += length; + switch(len) /* all the case statements fall through */ + { + case 11: c+=((ub4)k[10]<<24); + case 10: c+=((ub4)k[9]<<16); + case 9 : c+=((ub4)k[8]<<8); + /* the first byte of c is reserved for the length */ + case 8 : b+=((ub4)k[7]<<24); + case 7 : b+=((ub4)k[6]<<16); + case 6 : b+=((ub4)k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=((ub4)k[3]<<24); + case 3 : a+=((ub4)k[2]<<16); + case 2 : a+=((ub4)k[1]<<8); + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + mix(a,b,c); + /*-------------------------------------------- report the result */ + return c; +} + + + +#ifdef SELF_TEST + +/* used for timings */ +static void driver1() +{ + ub4 buf[256]; + ub4 i; + ub4 h=0; + + for (i=0; i<256; ++i) + { + h = jenkinshash(buf,i,h); + } +} + +/* check that every input bit changes every output bit half the time */ +#define HASHSTATE 1 +#define HASHLEN 1 +#define MAXPAIR 80 +#define MAXLEN 70 +static void driver2() +{ + ub1 qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1]; + ub4 c[HASHSTATE], d[HASHSTATE], i, j=0, k, l, m, z; + ub4 e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE]; + ub4 x[HASHSTATE],y[HASHSTATE]; + ub4 hlen; + + printf("No more than %d trials should ever be needed \n",MAXPAIR/2); + for (hlen=0; hlen < MAXLEN; ++hlen) + { + z=0; + for (i=0; i>(8-j)); + c[0] = jenkinshash(a, hlen, m); + b[i] ^= ((k+1)<>(8-j)); + d[0] = jenkinshash(b, hlen, m); + /* check every bit is 1, 0, set, and not set at least once */ + for (l=0; lz) z=k; + if (k==MAXPAIR) + { + printf("Some bit didn't change: "); + printf("%.8lx %.8lx %.8lx %.8lx %.8lx %.8lx ", + e[0],f[0],g[0],h[0],x[0],y[0]); + printf("i %ld j %ld m %ld len %ld\n",i,j,m,hlen); + } + if (z==MAXPAIR) goto done; + } + } + } + done: + if (z < MAXPAIR) + { + printf("Mix success %2ld bytes %2ld initvals ",i,m); + printf("required %ld trials\n",z/2); + } + } + printf("\n"); +} + +/* Check for reading beyond the end of the buffer and alignment problems */ +static void driver3() +{ + ub1 buf[MAXLEN+20], *b; + ub4 len; + ub1 q[] = "This is the time for all good men to come to the aid of their country"; + ub1 qq[] = "xThis is the time for all good men to come to the aid of their country"; + ub1 qqq[] = "xxThis is the time for all good men to come to the aid of their country"; + ub1 qqqq[] = "xxxThis is the time for all good men to come to the aid of their country"; + ub4 h,i,j,ref,x,y; + + printf("Endianness. These should all be the same:\n"); + printf("%.8lx\n", jenkinshash(q, sizeof(q)-1, (ub4)0)); + printf("%.8lx\n", jenkinshash(qq+1, sizeof(q)-1, (ub4)0)); + printf("%.8lx\n", jenkinshash(qqq+2, sizeof(q)-1, (ub4)0)); + printf("%.8lx\n", jenkinshash(qqqq+3, sizeof(q)-1, (ub4)0)); + printf("\n"); + for (h=0, b=buf+1; h<8; ++h, ++b) + { + for (i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define LT_DEBUG 1 + +#define PRIVATE +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +typedef enum {false = FALSE, true = TRUE} boolean; +#endif +typedef enum {false = FALSE, true = TRUE} boolean; + + +/* OK, as defined, each table entry+pointers amounts to 56 bytes (14 words). + * We pre-allocate 1024 entries (and can allocate more in blocks of 1024 each), + * and create two hash tables with 256 slots. We also keep a finger on the + * last two entries accessed (not sure how helpful this is). Total initial + * memory use is 60 bytes. + */ + +#define LT_PREALLOC 1024 +#define LT_HASHSIZE 256 +#define LT_MAXCHAIN 10 + + + +PRIVATE LabelTablePtr lt_finger1, + lt_finger2; + +/* We put all the meta-header information in an allocated region for + * user-level shared memory testing, mostly. It would make it easier + * for setting up multiple tables, if we end up doing that at some point. + */ +typedef struct _ltArea { + LabelTablePtr lt_supply; + LabelTablePtr *lt_base; + LabelTableHeadPtr lt_labelhash; + LabelTableHeadPtr lt_keyhash; + int lt_blockcount; + int lt_entrycount; +#ifdef __SMP__ + lock_t lt_globallock; + bed_t lt_supplybed; + bed_t lt_chainbed; +#endif /* __SMP__ */ +} LtArea, *LtAreaPtr; + +PRIVATE LtAreaPtr lt; + +/* The table locking and memory allocation are currently written in a + * Linux-specific fashion. Notes on porting it: + * 1. I assume all table entry creation/deletion is at task time. + * 2. Table access can be at interrupt time, so the table has to + * be allocated in non-pageable memory. Table storage is allocated + * in 40K blocks, so should work out to an even number of pages. + * 3. The atomic locks and cli/sti are an attempt to prepare for future + * SMP systems. + * 4. Sleep/wakeup routines, task-time only. + * 5. ... + */ + +#ifdef LT_DEBUG +int lt_debug_level = 10; +int lt_check(int); +void DumpLabelTable(LabelTableHeadPtr table, int index, int level, boolean islabel); + +#if defined(__KERNEL__) +/* Seizing up the kernel is probably not too wise */ +/* #define seizure() */ +#define errprint(level, format, args...) printf(format, ## args) +#define getpid() 1 +#else +void seizure(void); +#define errprint(level, format, args...) \ + {if (lt_debug_level >= level) printf(format , ## args);} +#define getpid() 1 +#endif /* __KERNEL__ */ + +#else +#define lt_check(again) +#define seizure() +#define errprint(level, format, args...) +#endif /* LT_DEBUG */ + +#ifdef __SMP__ +PRIVATE lock_t supplylock, chainlock; + +#define LockSupply() SleepyLock(&supplylock, <->lt_supplybed, "supply") +#define UnLockSupply() SleepyUnLock(&supplylock, <->lt_supplybed) + +/* Chain locking theory: There are locks at the head of each slot in the + * first-level hash tables. (There are also lock fields in the second-level + * tables, but let's not use them for now.) In order to add or remove an + * entry, we lock its slot in both the label and destination tables. + * How to avoid deadlock? We always lock the label table first and + * destination table second. The one problem with this is when we are + * redistributing a destination table chain. There we already have the + * destination lock, but could run into deadlock if we tried to get the + * label lock. So instead, we require anyone else doing updates to grab + * two destination locks, on both the pre and current entry. (They grab these + * in numerical order to avoid yet another deadlock possibility.) That way, + * our label hash table update can proceed unimpeded. + */ + +#define LockChain(chainlock, funcname, arg, islabel, no) SleepyLock(&chainlock, <->lt_chainbed, _p(funcname, arg, islabel,no)) +#define UnLockChain(chainlock) SleepyUnLock(&chainlock, <->lt_chainbed) + +static char * +_p(char *funcname, u_int32_t arg, boolean islabel, u_int32_t no) +{ + static char string[BUFSIZ]; + sprintf(string, "%s chain %d %s(%d)", islabel?"label":"dest", no, + funcname, arg); + + return string; +} +#endif /* __SMP__ */ + +#if defined (__FreeBSD__) +#define mallocinit() +#define malloccleanup() +#define bigmalloc(a) malloc((a), M_DEVBUF, 0) +#define smallmalloc(a) kmem_alloc(kernel_map, (a)) +#define bigfree(a,size) free((a),M_DEVBUF) +#define smallfree(a, size) kmem_free(kernel_map, (vm_offset_t)(a), size) +#endif + + +/* Forward Declarations */ +PRIVATE void lt_addblock(void); +PRIVATE LabelTableHeadPtr lt_addhash(void); +PRIVATE LabelTablePtr lt_alloc(void); +PRIVATE void lt_free(LabelTablePtr); +PRIVATE u_int32_t lt_hash(u_int32_t, u_int32_t); +PRIVATE u_int32_t lt_hashkey(LabelTableKeyPtr , LabelTableKeyPtr ); +PRIVATE u_int32_t lt_hashkey2(LabelTableKeyPtr , LabelTableKeyPtr ); +PRIVATE u_int32_t lt_hash2(u_int32_t, u_int32_t); +PRIVATE LabelTablePtr *lt_hashstart(LabelTableHeadPtr, u_int32_t, u_int32_t); +PRIVATE LabelTablePtr * +lt_hashkeystart(LabelTableHeadPtr, LabelTableKeyPtr, LabelTableKeyPtr); +PRIVATE LabelTablePtr lt_find_before_by_label(u_int32_t, u_int32_t); +PRIVATE LabelTablePtr lt_find_before_by_dest(u_int32_t, u_int32_t); +PRIVATE LabelTablePtr lt_find_before_by_key(LabelTableKeyPtr , LabelTableKeyPtr ); +PRIVATE LabelTablePtr lt_find_before_by_ptr(LabelTableKeyPtr , LabelTableKeyPtr , LabelTablePtr ); +PRIVATE int KeyMatch(LabelTableKeyPtr, LabelTableKeyPtr, LabelTableKeyPtr); +PRIVATE void RedistributeTable(LabelTableHeadPtr, u_int32_t, u_int32_t, boolean); +PRIVATE void ChewChain(LabelTableHeadPtr, boolean, int); +PRIVATE void PrintLabelTable(char *); +PRIVATE u_short extract_port(struct ip *, int); +PRIVATE LabelTableKeyPtr extract_key(struct ip *, int); +int CheckTable(LabelTableHead, int, int, boolean); +void lt_dump_table(void); +int CountLabelTable(LabelTableHead table, int index, int level, boolean islabel); + +static LabelTablePtr lt_find_by_key(LabelTableKeyPtr, LabelTableKeyPtr); +static LabelTablePtr lt_add __P((LabelTableEntryPtr entry)); +static int lt_rm __P((LabelTableEntryPtr victim)); +static LabelTablePtr lt_find __P((LabelTableKeyPtr key)); +static LabelTablePtr lt_find_by_label __P((u_int32_t label, u_int32_t CoS)); +static LabelTablePtr lt_find_by_dest __P((u_int32_t dest, u_int32_t CoS)); +static int label_eth_header __P((struct mbuf *skb, u_short *type, + LabelTableEntryPtr label)); +static int true_label_stack_size __P((EthLabelStack label)); +static int label_stack_size __P((EthLabelStack label, unsigned short flags)); +static void label_add_stack __P((EthLabelStack buffer, + EthLabelStack stack, unsigned short flags, int stacksize)); + +PRIVATE void +lt_addblock(void) +{ + int i; + + if (lt->lt_blockcount >= LT_HASHSIZE) /* too much... */ + return; + lt->lt_base[lt->lt_blockcount++] = lt->lt_supply = (LabelTablePtr)bigmalloc(LT_PREALLOC * sizeof(LabelTable)); + if (!lt->lt_supply) { + errprint(1, "lt_addblock: alloc failed\n"); + seizure(); + return; + } + bzero(lt->lt_supply, LT_PREALLOC * sizeof(LabelTable)); + for (i=0; i < LT_PREALLOC-1; ++i) { + ++lt->lt_supply; + lt->lt_supply->ltNextLabel = (lt->lt_supply-1); + } +} + +PRIVATE LabelTableHeadPtr +lt_addhash(void) +{ + LabelTableHeadPtr answer; + + answer = (LabelTableHeadPtr)smallmalloc(LT_HASHSIZE*sizeof(LabelTableHead)); + if (!answer) { + errprint(1, "lt_addhash: alloc failed\n"); + return NULL; + } + bzero(answer, LT_HASHSIZE*sizeof(LabelTableHead)); + return answer; +} + +#include + +void +lt_init(void) +{ +#ifdef SMP_TEST + void bustlocks(int arg); + + signal(SIGUSR1, bustlocks); +#endif /* SMP_TEST */ + lt_add_ptr = lt_add; + lt_rm_ptr = lt_rm; + lt_find_by_label_ptr = lt_find_by_label; + lt_find_by_dest_ptr = lt_find_by_dest; + lt_find_ptr = lt_find; + label_stack_size_ptr = label_stack_size; + true_label_stack_size_ptr = true_label_stack_size; + label_eth_header_ptr = label_eth_header; + label_add_stack_ptr = label_add_stack; + PrintLabelTable_ptr = PrintLabelTable; + extract_port_ptr = extract_port; + extract_key_ptr = extract_key; + mallocinit(); + lt = (LtAreaPtr)smallmalloc(sizeof(LtArea)); + if (!lt) { + errprint(1, "lt_init: alloc failed 1\n"); + seizure(); + return; + } + bzero(lt, sizeof(LtArea)); + lt->lt_base = (LabelTablePtr *)smallmalloc(LT_HASHSIZE * sizeof(LabelTablePtr)); + if (!lt->lt_base) { + errprint(1, "lt_init: alloc failed 2\n"); + seizure(); + return; + } + bzero(lt->lt_base, LT_HASHSIZE * sizeof(LabelTablePtr)); + + lt_addblock(); + lt->lt_labelhash = lt_addhash(); + lt->lt_keyhash = lt_addhash(); +#ifdef SMP_TEST +#endif /* SMP_TEST */ +} + +void +lt_cleanup(void) +{ + int i; + + for (i=0; i < LT_HASHSIZE; ++i) { + if (lt->lt_labelhash[i].lthSecondTable) + smallfree(lt->lt_labelhash[i].lthSecondTable, LT_HASHSIZE * sizeof(LabelTableHead)); + if (lt->lt_keyhash[i].lthSecondTable) + smallfree(lt->lt_keyhash[i].lthSecondTable, LT_HASHSIZE * sizeof(LabelTableHead)); + } + smallfree(lt->lt_labelhash, LT_HASHSIZE * sizeof(LabelTableHead)); + smallfree(lt->lt_keyhash, LT_HASHSIZE * sizeof(LabelTableHead)); + for (i=0; i < lt->lt_blockcount; ++i) + bigfree(lt->lt_base[i], LT_PREALLOC * sizeof(LabelTable)); + smallfree(lt->lt_base, LT_HASHSIZE * sizeof(LabelTablePtr)); + smallfree(lt, sizeof(LtArea)); + lt = NULL; + lt_finger1 = lt_finger2 = NULL; + lt_add_ptr = NULL; + lt_rm_ptr = NULL; + lt_find_by_label_ptr = NULL; + lt_find_by_dest_ptr = NULL; + lt_find_ptr = NULL; + label_stack_size_ptr = NULL; + true_label_stack_size_ptr = NULL; + label_eth_header_ptr = NULL; + label_add_stack_ptr = NULL; + PrintLabelTable_ptr = NULL; + extract_port_ptr = NULL; + extract_key_ptr = NULL; + malloccleanup(); +} + +PRIVATE LabelTablePtr +lt_alloc(void) +{ + LabelTablePtr answer=NULL; + +#ifdef __SMP__ + LockSupply(); +#endif + + if (!lt->lt_supply) + lt_addblock(); + if (lt->lt_supply) { + answer = lt->lt_supply; + lt->lt_supply = lt->lt_supply->ltNextLabel; + } else { + errprint(2, "lt_alloc: alloc failed\n"); + return NULL; + } + +#ifdef __SMP__ + UnLockSupply(); +#endif + bzero(answer, sizeof(LabelTable)); + return answer; +} + +PRIVATE void +lt_free(LabelTablePtr victim) +{ +#ifdef __SMP__ + LockSupply(); +#endif + + victim->ltNextLabel = lt->lt_supply; + lt->lt_supply = victim; + +#ifdef __SMP__ + UnLockSupply(); +#endif +} + +/* Really silly hash function which has endeared itself to me */ +PRIVATE u_int32_t +lt_hash(u_int32_t one, u_int32_t two) +{ + u_int32_t answer=0; + + while (one) { + answer += one; + answer *= 69069; + one >>= 8; + } + while (two) { + answer += two; + answer *= 69069; + two >>= 8; + } + return (answer&(LT_HASHSIZE-1)); +} + +PRIVATE u_int32_t +lt_hashkey(LabelTableKeyPtr key, LabelTableKeyPtr mask) +{ + u_int32_t answer=0; + u_int32_t *intkey = (u_int32_t *)key; + u_int32_t *intmask = (u_int32_t *)mask; + int i; + + for (i=0; i < sizeof(LabelTableKey)/sizeof(u_int32_t); ++i) { + u_int32_t victim; + + if (intmask) { + victim = (intkey[i]&intmask[i]); + } else { + victim = intkey[i]; + } + while (victim) { + answer += victim; + answer *= 69069; + victim >>= 8; + } + } + return (answer&(LT_HASHSIZE-1)); +} + + + +/* Use a better, but slower, hash for the second level */ +PRIVATE u_int32_t +lt_hash2(u_int32_t one, u_int32_t two) +{ + return (jenkinshash2(&one, 1, two)&(LT_HASHSIZE-1)); +} + +PRIVATE u_int32_t +lt_hashkey2(LabelTableKeyPtr key, LabelTableKeyPtr mask) +{ + u_int32_t answer=0; + u_int32_t *intkey = (u_int32_t *)key; + u_int32_t *intmask = (u_int32_t *)mask; + int i; + + if (!intmask) + { + return (jenkinshash2((u_int32_t *)key, + sizeof(LabelTableKey)/sizeof(u_int32_t), 0) + & (LT_HASHSIZE-1)); + } + for (i=0; i < sizeof(LabelTableKey)/sizeof(u_int32_t); ++i) { + u_int32_t victim; + + victim = (intkey[i]&intmask[i]); + answer = jenkinshash2(&victim, 1, answer); + } + return (answer&(LT_HASHSIZE-1)); +} + +PRIVATE LabelTablePtr * +lt_hashstart(LabelTableHeadPtr table, u_int32_t one, u_int32_t two) +{ + u_int32_t hash1 = lt_hash(one, two); + LabelTablePtr answer; + if (table[hash1].lthSecondTable) { + u_int32_t hash2 = lt_hash2(one, two); + return & table[hash1].lthSecondTable[hash2].lthHeader; + } + return & table[hash1].lthHeader; +} + +PRIVATE LabelTablePtr * +lt_hashkeystart(LabelTableHeadPtr table, LabelTableKeyPtr key, + LabelTableKeyPtr mask) +{ + u_int32_t hash1 = lt_hashkey(key, mask); + LabelTablePtr answer; + + if (table[hash1].lthSecondTable) { + u_int32_t hash2 = lt_hashkey2(key, mask); + return & table[hash1].lthSecondTable[hash2].lthHeader; + } + return & table[hash1].lthHeader; +} + +#ifdef LT_DEBUG +/* Keep running tally of last hundred accesses... */ +PRIVATE int hash_tries[100]; +PRIVATE int circular=0; +PRIVATE int *here; +#endif + +/* This is the initial list of bitmasks used for matching. The + * order is significant, of course (first matches preferred). + */ +PRIVATE LabelTableKey ltk_matchmasks[LT_KEYMATCH_MAX] = { + { 0xffffffff, /* destination IP */ + 0xffffffff, /* CoS */ + {0xffffff}, /* destination protocol/port */ + 0xffffffff, /* source IP */ + {0xffffff} /* source protocol/port */ + }, + { 0xffffffff, /* destination IP */ + 0xffffffff, /* CoS */ + {0}, /* IGNORE destination protocol/port */ + 0xffffffff, /* source IP */ + {0} /* IGNORE source protocol/port */ + }, + { 0xffffffff, /* destination IP */ + 0xffffffff, /* CoS */ + {0}, /* IGNORE destination protocol/port */ + 0, /* IGNORE source IP */ + {0} /* IGNORE source protocol/port */ + }, + { 0xffffff00, /* destination IP subnet (24 bit) */ + 0xffffffff, /* CoS */ + {0}, /* IGNORE destination protocol/port */ + 0, /* IGNORE source IP */ + {0} /* IGNORE source protocol/port */ + }, +}; + +PRIVATE int ltk_matchcount=4; + +void +lt_keymatchlist(LabelTableKeyPtr list, int count) +{ + if (count > LT_KEYMATCH_MAX) + count = LT_KEYMATCH_MAX; + bcopy(list, ltk_matchmasks, count*sizeof(LabelTableKey)); + ltk_matchcount = count; +} + +/* Find the entry before the specified one in the hash chain */ +PRIVATE LabelTablePtr +lt_find_before_by_label(u_int32_t label, u_int32_t CoS) +{ + LabelTablePtr answer, next; + + for (answer = NULL, next = *lt_hashstart(lt->lt_labelhash, label, CoS); next; + answer = next, next = next->ltNextLabel) { + if (next->ltEntry.lteLabel == label + && next->ltEntry.lteCoS == CoS) { + return answer; + } + } + return NULL; +} +PRIVATE int +KeyMatch(LabelTableKeyPtr entry, LabelTableKeyPtr key, LabelTableKeyPtr mask) +{ + if (!mask) + return bcmp((void *)entry, (void *)key, sizeof(LabelTableKey)); + else { + u_int32_t *intentry = (u_int32_t *)entry; + u_int32_t *intkey = (u_int32_t *)key; + u_int32_t *intmask = (u_int32_t *)mask; + int i; + + for (i=0; i < sizeof(LabelTableKey)/sizeof(u_int32_t); ++i) { + if (intentry[i] != (intkey[i]&intmask[i])) + return intentry[i] - (intkey[i]&intmask[i]); + } + } + return 0; +} + +PRIVATE LabelTablePtr +lt_find_before_by_key(LabelTableKeyPtr key, LabelTableKeyPtr mask) +{ + LabelTablePtr answer, next; + + for (answer = NULL, next = *lt_hashkeystart(lt->lt_keyhash, key, mask); next; + answer = next, next = next->ltNextKey) { + if (!KeyMatch(&next->ltEntry.lteKey, key, mask)) { + + return answer; + } + } + return NULL; +} + +PRIVATE LabelTablePtr +lt_find_before_by_ptr(LabelTableKeyPtr key, LabelTableKeyPtr mask, LabelTablePtr ptr) +{ + LabelTablePtr answer, next; + + for (answer = NULL, next = *lt_hashkeystart(lt->lt_keyhash, key, mask); next; + answer = next, next = next->ltNextKey) { + if (next == ptr) { + + return answer; + } + } + return NULL; +} + +LabelTablePtr +lt_find_by_label(u_int32_t label, u_int32_t CoS) +{ + LabelTablePtr answer; + +#ifdef LT_DEBUG +here = hash_tries + circular; +++circular; +if (circular >= 100) + circular = 0; +*here = 0; +#endif + /* Small cache (is this useful?) */ + if (lt_finger1 && lt_finger1->ltEntry.lteLabel == label && + lt_finger1->ltEntry.lteCoS == CoS) { +#ifdef LT_DEBUG +*here = -2; +#endif + return lt_finger1; + } + if (lt_finger2 && lt_finger2->ltEntry.lteLabel == label && + lt_finger2->ltEntry.lteCoS == CoS) { +#ifdef LT_DEBUG +*here = -1; +#endif + return lt_finger2; + } + for (answer = *lt_hashstart(lt->lt_labelhash, label, CoS); answer; + answer = answer->ltNextLabel) { +#ifdef LT_DEBUG + *here = *here + 1; +#endif + if (answer->ltEntry.lteLabel == label + && answer->ltEntry.lteCoS == CoS) { + lt_finger2 = lt_finger1; + lt_finger1 = answer; + return answer; + } + } + return NULL; +} + +LabelTablePtr +lt_find_by_dest(u_int32_t dest, u_int32_t CoS) +{ + LabelTableKey key; + + bzero(&key, sizeof(key)); + key.ltkDest = dest; + key.ltkCoS = CoS; + return lt_find(&key); +} + +LabelTablePtr +lt_find_by_key(LabelTableKeyPtr key, LabelTableKeyPtr mask) +{ + LabelTablePtr answer; + if(key) { + +#ifdef LT_DEBUG +here = hash_tries + circular; +++circular; +if (circular >= 100) + circular = 0; +*here = 0; +#endif + for (answer = *lt_hashkeystart(lt->lt_keyhash, key, mask); + answer; answer = answer->ltNextKey) { +#ifdef LT_DEBUG +*here = *here + 1; +#endif + if (!KeyMatch(&answer->ltEntry.lteKey, key, mask)) { + return answer; + } + } + } + return NULL; +} +LabelTablePtr +lt_find(LabelTableKeyPtr key) +{ + LabelTablePtr answer; + int i; + + + if (ltk_matchcount) { + for (i = 0; i < ltk_matchcount; ++i) { + if (answer = lt_find_by_key(key, <k_matchmasks[i])) + return answer; + } + return NULL; + } else { + return lt_find_by_key(key, NULL); + } +} + + +/* Redistributing table entries to the second-level table. We have to + * be very careful here to ensure the table is always in a consistent state. + * We duplicate all the entries before moving them and do some fussy work + * with the pointers. + */ +PRIVATE void +RedistributeTable(LabelTableHeadPtr table, u_int32_t ourhash, u_int32_t otherhash, boolean islabel) +{ + LabelTableHeadPtr second_table; + LabelTablePtr run, last, newentry, *slot; + u_int32_t hash, nexthash, hash2; + +#ifdef LT_DEBUG + errprint(5, "%d: Redistributing %s table %d\n", + getpid(), islabel ? "label" : "key", ourhash); + if (lt_debug_level >= 5) + DumpLabelTable(table, ourhash, 0, islabel); errprint(5, "\n"); +#endif /* LT_DEBUG */ + second_table = lt_addhash(); + if (!second_table) + return; + + if (islabel) { + for (run = table->lthHeader; run; run = run->ltNextLabel) { + /* Lock it and successor in other table */ + hash = lt_hashkey(&run->ltEntry.lteKey, NULL); + if (run->ltNextLabel) + nexthash = lt_hashkey(&run->ltNextLabel->ltEntry.lteKey, NULL); + else + nexthash = hash; +#ifdef __SMP__ + if (hash != otherhash) {/* don't try to double lock! */ + if (hash < nexthash && nexthash != otherhash) { +errprint(5, "%d: lock keyhash %d\n", getpid(), hash); + LockChain(lt->lt_keyhash[hash].lthLock, "RedistributeTable", 0, FALSE, hash); +errprint(5, "%d: lock keyhash %d\n", getpid(), nexthash); + LockChain(lt->lt_keyhash[nexthash].lthLock, "RedistributeTable", 1, FALSE, nexthash); + } else if (hash > nexthash && nexthash != otherhash) { +errprint(5, "%d: lock keyhash %d\n", getpid(), nexthash); + LockChain(lt->lt_keyhash[nexthash].lthLock, "RedistributeTable", 2, FALSE, nexthash); +errprint(5, "%d: lock keyhash %d\n", getpid(), hash); + LockChain(lt->lt_keyhash[hash].lthLock, "RedistributeTable", 3, FALSE, hash); + } else { +errprint(5, "%d: lock keyhash %d\n", getpid(), hash); + LockChain(lt->lt_keyhash[hash].lthLock, "RedistributeTable", 4, FALSE, hash); + } + } else if (nexthash != otherhash) { +errprint(5, "%d: lock keyhash %d\n", getpid(), nexthash); + LockChain(lt->lt_keyhash[nexthash].lthLock, "RedistributeTable", 5, FALSE, nexthash); + } +#endif /* __SMP__ */ + newentry = lt_alloc(); + if (!newentry) { + errprint(1, "RedistributeTable: alloc failed 1!\n"); + seizure(); + } + *newentry = *run; + hash2 = lt_hash2(run->ltEntry.lteLabel, run->ltEntry.lteCoS); +#ifdef LT_DEBUG + if (hash2 >= LT_HASHSIZE) { + errprint(1, "RedistributeTable: hash2 %d!\n", hash2); + seizure(); + } +#endif + newentry->ltNextLabel = second_table[hash2].lthHeader; + second_table[hash2].lthHeader = newentry; + /* Update parent in other table */ + last = lt_find_before_by_ptr(&newentry->ltEntry.lteKey, NULL, run); + if (last) + last->ltNextKey = newentry; + else { /* Must be at head of table */ + slot = lt_hashkeystart(lt->lt_keyhash, &newentry->ltEntry.lteKey, NULL); + if ((*slot)->ltEntry.lteDest != newentry->ltEntry.lteDest) { + errprint(1, "RedistributeTable: huh no %d/%d on dest %d?\n", newentry->ltEntry.lteDest, newentry->ltEntry.lteCoS, hash); + seizure(); + + } + *slot = newentry; + } +#ifdef __SMP__ + if (hash != otherhash) { +errprint(5, "%d: unlock keyhash %d\n", getpid(), hash); + UnLockChain(lt->lt_keyhash[hash].lthLock); + } + if (nexthash != hash && nexthash != otherhash) { +errprint(5, "%d: unlock keyhash %d\n", getpid(), nexthash); + UnLockChain(lt->lt_keyhash[nexthash].lthLock); + } +#endif /* __SMP__ */ + } + } else for (run = table->lthHeader; run; run = run->ltNextKey) { + hash = lt_hash(run->ltEntry.lteLabel, run->ltEntry.lteCoS); +#ifdef __SMP__ + /* Don't lock in other table! */ +errprint(5, "%d: dont't lock labelhash %d\n", getpid(), hash); + /*LockChain(lt->lt_labelhash[hash].lthLock, TRUE, hash);*/ +#endif /* __SMP__ */ + newentry = lt_alloc(); +#ifdef __SMP__ + BlockAll(); /* @@ this needs to be replaced */ +#endif /* __SMP__ */ + if (!newentry) { + errprint(1, "RedistributeTable: alloc failed 2!\n"); + seizure(); + } + *newentry = *run; + hash2 = lt_hashkey2(&run->ltEntry.lteKey, NULL); +#ifdef LT_DEBUG + if (hash2 >= LT_HASHSIZE) { + errprint(1, "RedistributeTable: hashkey2 %d!\n", hash2); + seizure(); + } +#endif + newentry->ltNextKey = second_table[hash2].lthHeader; + second_table[hash2].lthHeader = newentry; + /* Update parent in other table */ + last = lt_find_before_by_label(newentry->ltEntry.lteLabel, newentry->ltEntry.lteCoS); + if (last) + last->ltNextLabel = newentry; + else { /* Must be at head of table */ + slot = lt_hashstart(lt->lt_labelhash, newentry->ltEntry.lteLabel, newentry->ltEntry.lteCoS); + if ((*slot)->ltEntry.lteLabel != newentry->ltEntry.lteLabel) { + errprint(1, "RedistributeTable: huh no %d/%d on label %d?\n", newentry->ltEntry.lteLabel, newentry->ltEntry.lteCoS, hash); + seizure(); + } + *slot = newentry; + } +#ifdef __SMP__ + /*UnLockChain(lt->lt_labelhash[hash].lthLock);*/ + UnBlockAll(); /* @@ tbd */ +#endif /* __SMP__ */ + } + /* Table all set up; now install it */ + table->lthSecondTable = second_table; +#ifdef LT_DEBUG + errprint(5, "%d: Done with %s table %d at %lx\n", + getpid(), islabel ? "label" : "key", ourhash, second_table); + if (lt_debug_level >= 5) + DumpLabelTable(table, ourhash, 0, islabel); errprint(5, "\n"); +#endif +} + +/* Dispose of an old first-level chain. We delay this to make sure we + * don't surprise anyone who was in the midst of using the old chain. + * (This isn't actually possible in current Linux but...) + */ +PRIVATE void +ChewChain(LabelTableHeadPtr table, boolean islabel, int ourhash) +{ + LabelTablePtr run; + + /* New table is safely in place; chew up and spit out old chain */ + while (table->lthHeader) { + run = table->lthHeader; + table->lthHeader = islabel ? run->ltNextLabel : run->ltNextKey; + lt_free(run); + } +} + + +/* lt_add - add a new entry to the tables */ +LabelTablePtr +lt_add(LabelTableEntryPtr entry) +{ + LabelTablePtr answer, *slot; + u_int32_t hash, hash2; + + hash = lt_hash(entry->lteLabel, entry->lteCoS); + hash2 = lt_hashkey(&entry->lteKey, NULL); +#ifdef __SMP__ + /* Lock the chains that will be updated */ + LockChain(lt->lt_labelhash[hash].lthLock, "lt_add", entry->lteLabel, TRUE, hash); + LockChain(lt->lt_keyhash[hash2].lthLock, "lt_add", entry->lteLabel, FALSE, hash2); +#endif /* __SMP__ */ + + errprint(9, "lt_add: adding (%d %d %d) to %d and %d\n", + entry->lteLabel, entry->lteCoS, entry->lteDest, hash, hash2); + + answer = lt_find_by_label(entry->lteLabel, entry->lteCoS); + if(!answer) { + answer = lt_find_by_key(&entry->lteKey, NULL); + if(answer) + { + if( ((answer->ltEntry.lteNewLabel != entry->lteNewLabel) && + (answer->ltEntry.lteFlags == LTE_SWAP)) || + ((entry->lteNewLabel == 0) && + (answer->ltEntry.lteFlags == LTE_POP)) ) + { + answer = NULL; + /* we r sinking 2 lsp's to the same fec (dest addr/port) */ + } + } + if(answer) + if (answer->ltEntry.lteForward == entry->lteForward){/* error */ +#ifdef LT_DEBUG + errprint(1, "lt_add: huh? found %d/%d by dest but not by label %d \n",entry->lteDest, entry->lteCoS, entry->lteLabel); + seizure(); +#endif + } else { + /* Source is multihomed and originator of mcast stream + Change Label to previous entry's label since only + NewLabel is different */ + entry->lteLabel = answer->ltEntry.lteLabel; + printf("label change \n"); + answer = lt_find_by_label(entry->lteLabel, entry->lteCoS); + } + } + + if (answer) + if (answer->ltEntry.lteForward == entry->lteForward){/* interpret as update */ + entry->lteMCastList = answer->ltEntry.lteMCastList; + answer->ltEntry = *entry; +#ifdef __SMP__ + UnLockChain(lt->lt_keyhash[hash2].lthLock); + UnLockChain(lt->lt_labelhash[hash].lthLock); +#endif /* __SMP__ */ + lt_check(1); + return answer; + } else { /* Multiple entries for MCast */ + printf("Multicast \n"); + entry->lteMCastList = answer->ltEntry.lteMCastList; + answer->ltEntry.lteMCastList = entry; + return answer; + } + + +#ifdef LT_DEBUG + answer = lt_find_by_label(entry->lteLabel, entry->lteCoS); + if (answer) { /* shouldn't be... */ + if (answer->ltEntry.lteForward == entry->lteForward){ + errprint(1, "lt_add: whoops one!\n"); + seizure(); + } + } +#endif LT_DEBUG + + entry->lteMCastList = NULL; + answer = lt_alloc(); + if (!answer) { + errprint(5, "lt_add: alloc failed\n"); +#ifdef __SMP__ + UnLockChain(lt->lt_keyhash[hash2].lthLock); + UnLockChain(lt->lt_labelhash[hash].lthLock); +#endif /* __SMP__ */ + return NULL; + } + answer->ltEntry = *entry; + + /* Mark add as in progress */ + answer->ltEntry.lteFlags |= LTE_INPROGRESS; + + /* Check if label table has gotten too big */ + if (++lt->lt_labelhash[hash].lthCount > LT_MAXCHAIN) { + if (!lt->lt_labelhash[hash].lthSecondTable) + RedistributeTable(<->lt_labelhash[hash], hash, hash2, TRUE); + else if (lt->lt_labelhash[hash].lthHeader) + ChewChain(<->lt_labelhash[hash], TRUE, hash); + + } + /* Insert into hash tables */ + slot = lt_hashstart(lt->lt_labelhash, entry->lteLabel, entry->lteCoS); + answer->ltNextLabel = *slot; + *slot = answer; + + /* Check if dest table has gotten too big */ + + if (++lt->lt_keyhash[hash2].lthCount > LT_MAXCHAIN) { + if (!lt->lt_keyhash[hash2].lthSecondTable) + RedistributeTable(<->lt_keyhash[hash2], hash2, hash, FALSE); + else if (lt->lt_keyhash[hash2].lthHeader) + ChewChain(<->lt_keyhash[hash2], FALSE, hash2); + + + } + /* Insert into dest hash tables */ + slot = lt_hashkeystart(lt->lt_keyhash, &entry->lteKey, NULL); + answer->ltNextKey = *slot; + *slot = answer; + + /* Mark add as finished */ + ++lt->lt_entrycount; + answer->ltEntry.lteFlags &= ~LTE_INPROGRESS; + +#ifdef __SMP__ + UnLockChain(lt->lt_keyhash[hash2].lthLock); + UnLockChain(lt->lt_labelhash[hash].lthLock); +#endif /* __SMP__ */ +#ifdef LT_DEBUG + lt_check(1); +#endif /* LT_DEBUG */ + + return answer; +} + +int +lt_rm(LabelTableEntryPtr victim) +{ + u_int32_t hash, hash2, hash3; + LabelTablePtr answer, pre, finger = NULL, *slot; + + /* Lock the chains that will be updated */ + hash = lt_hash(victim->lteLabel, victim->lteCoS); + hash3 = hash2 = lt_hashkey(&victim->lteKey, NULL); +#ifdef __SMP__ + LockChain(lt->lt_labelhash[hash].lthLock, "lt_rm", victim->lteLabel, TRUE, hash); +#endif /* __SMP__ */ + + answer = lt_find_by_label(victim->lteLabel, victim->lteCoS); + if(!answer) { + answer = lt_find_by_key(&victim->lteKey,NULL); + if(answer) { + /* This m/c was source of mcast stream and so label + is different even though key is same since label + eqauls new label */ + victim->lteLabel = answer->ltEntry.lteLabel; + answer = lt_find_by_label(victim->lteLabel, victim->lteCoS); + hash = lt_hash(victim->lteLabel, victim->lteCoS); + hash3 = hash2 = lt_hashkey(&victim->lteKey, NULL); + } + } + if(answer->ltEntry.lteMCastList) { /* Multiple Entries */ + LabelTableEntryPtr entry; + entry = &(answer->ltEntry); + if(entry->lteForward == victim->lteForward) { /* 1st entry */ + answer->ltEntry = *(entry->lteMCastList); + errprint(9, "lt_rm: removed (%d %d %d) from %d and %d\n", + victim->lteLabel, victim->lteCoS, victim->lteDest, hash, hash2); + return 0; + } + else { + while(entry->lteMCastList->lteForward != victim->lteForward) { + printf("searching \n"); + entry = entry->lteMCastList; + } + printf("deleting \n"); + entry->lteMCastList = entry->lteMCastList->lteMCastList; + return 0; + } + } else { + errprint(9, "lt_rm: removing (%d %d %d) from %d and %d\n", + victim->lteLabel, victim->lteCoS, victim->lteDest, hash, hash2); + + pre = lt_find_before_by_label(victim->lteLabel, victim->lteCoS); + if (pre) { + /* Lock pre's key chain as well, in case big munging is going on */ + hash3 = lt_hashkey(&pre->ltEntry.lteKey, NULL); + +#ifdef __SMP__ + if (hash3 > hash2) { + LockChain(lt->lt_keyhash[hash2].lthLock, "lt_rm 1", victim->lteLabel, FALSE, hash2); + LockChain(lt->lt_keyhash[hash3].lthLock, "lt_rm 2", victim->lteLabel, FALSE, hash3); + } else if (hash3 < hash2) { + LockChain(lt->lt_keyhash[hash3].lthLock, "lt_rm 3", victim->lteLabel, FALSE, hash3); + LockChain(lt->lt_keyhash[hash2].lthLock, "lt_rm 4", victim->lteLabel, FALSE, hash2); + } else { + LockChain(lt->lt_keyhash[hash2].lthLock, "lt_rm 5", victim->lteLabel, FALSE, hash2); + } +#endif /* __SMP__ */ + + finger = pre->ltNextLabel; + if(victim->lteDest == 0) { + victim->lteDest = finger->ltEntry.lteDest; + hash2 = lt_hashkey(&victim->lteKey, NULL); + } + /* Mark rm as in progress */ + finger->ltEntry.lteFlags |= LTE_INPROGRESS; + if (finger->ltEntry.lteLabel != victim->lteLabel || + finger->ltEntry.lteCoS != victim->lteCoS) { + errprint(1, "lt_rm: huh got %d/%d instead on label %d?\n", finger->ltEntry.lteLabel, finger->ltEntry.lteCoS, hash); + seizure(); + } + pre->ltNextLabel = finger->ltNextLabel; +#ifdef __SMP__ + /* @@I think we can unconditionally unlock 3 now?? */ + if (hash3 != hash2) { + UnLockChain(lt->lt_keyhash[hash3].lthLock); + } +#endif /* __SMP__ */ + --lt->lt_labelhash[hash].lthCount; + if (((int)lt->lt_labelhash[hash].lthCount) < 0) { + errprint(1, "lt_rm: negative count on label %d\n", hash); + seizure(); + } + } else { /* either not there, or head of chain */ + slot = lt_hashstart(lt->lt_labelhash, victim->lteLabel, victim->lteCoS); + pre = *slot; + if (pre && pre->ltEntry.lteLabel == victim->lteLabel && + pre->ltEntry.lteCoS == victim->lteCoS) { +#ifdef __SMP__ + LockChain(lt->lt_keyhash[hash2].lthLock, "lt_rm 6", victim->lteLabel, FALSE, hash2); +#endif /* __SMP__ */ + finger = pre; + if(victim->lteDest == 0) { + victim->lteDest = finger->ltEntry.lteDest; + hash2 = lt_hashkey(&victim->lteKey, NULL); + } + /* Mark rm as in progress */ + finger->ltEntry.lteFlags |= LTE_INPROGRESS; + *slot = pre->ltNextLabel; + --lt->lt_labelhash[hash].lthCount; + if (((int)lt->lt_labelhash[hash].lthCount) < 0) { + errprint(1, "lt_rm: negative count 2 on label %d\n", hash); + seizure(); + } + } + } + + if (!finger) { +#ifdef __SMP__ + UnLockChain(lt->lt_labelhash[hash].lthLock); +#endif /* __SMP__ */ +#ifdef LT_DEBUG + lt_check(1); +#endif /* LT_DEBUG */ + return -1; + } + + + pre = lt_find_before_by_ptr(&(victim->lteKey), NULL, finger); + + if (pre) { +#ifdef __SMP__ + /* No additional locking required here, since any label + * redistributor will be blocked by the destination lock. + */ +#endif /* __SMP__ */ + if (pre->ltNextKey == finger) { + pre->ltNextKey = finger->ltNextKey; + } else { + errprint(1, "lt_rm: huh got %d/%d instead on dest %d?\n", pre->ltNextKey->ltEntry.lteLabel, pre->ltNextKey->ltEntry.lteCoS, hash2); + seizure(); + } + --lt->lt_keyhash[hash2].lthCount; + if (((int)lt->lt_keyhash[hash2].lthCount) < 0) { + errprint(1, "lt_rm: negative count on dest %d\n", hash2); + seizure(); + } + } else { /* either not there, or head of chain */ + slot = lt_hashkeystart(lt->lt_keyhash, &victim->lteKey, NULL); + if (*slot != finger) { + errprint(1, "lt_rm: huh head has %d/%d instead on dest %d?\n", (*slot)->ltEntry.lteLabel, (*slot)->ltEntry.lteCoS, hash2); + seizure(); + } + *slot = finger->ltNextKey; + --lt->lt_keyhash[hash2].lthCount; + if (((int)lt->lt_keyhash[hash2].lthCount) < 0) { + errprint(1, "lt_rm: negative count 2 on dest %d\n", hash2); + seizure(); + } + } +#ifdef __SMP__ + UnLockChain(lt->lt_keyhash[hash2].lthLock); + UnLockChain(lt->lt_labelhash[hash].lthLock); +#endif /* __SMP__ */ + + if (finger == lt_finger1) + lt_finger1 = NULL; + else if (finger == lt_finger2) + lt_finger2 = NULL; + + /* No need to change the flag, since we're freeing it, but this + * feels more satisfying. + */ + --lt->lt_entrycount; + finger->ltEntry.lteFlags &= ~LTE_INPROGRESS; + lt_free(finger); + + +#ifdef LT_DEBUG2 + lt_check(1); +#endif /* LT_DEBUG */ + + return 0; + } +} + +#ifdef LT_DEBUG +int +CheckTable(LabelTableHead table, int index, int level, boolean islabel) +{ + int i; + LabelTablePtr run = table.lthHeader; + int code=0; + + if (!run && !table.lthSecondTable) + return 0; + + if (table.lthSecondTable) { + for (i = 0; i < LT_HASHSIZE; ++i) + code += CheckTable(table.lthSecondTable[i], i, 1, islabel); + return code; + } + while (run) { + if (islabel) { + if (!level) { + if (lt_hash(run->ltEntry.lteLabel, run->ltEntry.lteCoS) != index) { + errprint(0, "(%d %d %d) bad label hash\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } else { + if (lt_hash2(run->ltEntry.lteLabel, run->ltEntry.lteCoS) != index) { + errprint(0, "(%d %d %d) bad 2nd label hash\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } + if (!lt_find_by_key(&run->ltEntry.lteKey, NULL)) { + if (run->ltEntry.lteFlags<E_INPROGRESS) { + errprint(9, "(%d %d %d) in progress (not in dest)\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + } else { + errprint(0, "(%d %d %d) not in dest table\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } + run = run->ltNextLabel; + } else { + if (!level) { + if (lt_hashkey(&run->ltEntry.lteKey, NULL) != index) { + errprint(0, "(%d %d %d) bad dest hash\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } else { + if (lt_hashkey2(&run->ltEntry.lteKey, NULL) != index) { + errprint(0, "(%d %d %d) bad 2nd dest hash\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } + if (!lt_find_by_label(run->ltEntry.lteLabel, + run->ltEntry.lteCoS)) { + if (run->ltEntry.lteFlags<E_INPROGRESS) { + errprint(5, "(%d %d %d) in progress (not in label)\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + } else { + errprint(0, "(%d %d %d) not in label table\n", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest + ); + --code; + } + } + run = run->ltNextKey; + } + } + return code; +} + +void +DumpLabelTable(LabelTableHeadPtr table, int index, int level, boolean islabel) +{ + int i; + LabelTablePtr run = table->lthHeader; + + if (!run && !table->lthSecondTable) + return; + printf("\n"); + for (i=0; i <= level; ++i) + printf("\t"); + errprint(0, "%3d: ", index); + if (table->lthSecondTable) { + for (i = 0; i < LT_HASHSIZE; ++i) + DumpLabelTable(&table->lthSecondTable[i], i, 1, islabel); + return; + } + while (run) { + errprint(0, "(%d %d %d) ", + run->ltEntry.lteLabel, + run->ltEntry.lteCoS, + run->ltEntry.lteDest); + run = islabel ? run->ltNextLabel : run->ltNextKey; + } +} + +int +CountLabelTable(LabelTableHead table, int index, int level, boolean islabel) +{ + int i; + LabelTablePtr run = table.lthHeader; + int answer=0; + + if (!run && !table.lthSecondTable) + return 0; + if (table.lthSecondTable) { + for (i = 0; i < LT_HASHSIZE; ++i) + answer += CountLabelTable(table.lthSecondTable[i], i, 1, islabel); + if (answer != table.lthCount) + errprint(0, "%s table %d lthCount %d actual %d\n", + islabel ? "label" : "key", + index, + table.lthCount, + answer); + return answer; + } + while (run) { + ++answer; + run = islabel ? run->ltNextLabel : run->ltNextKey; + } + if (!level && answer != table.lthCount) + errprint(0, "%s table %d lthCount %d actual %d\n", + islabel ? "label" : "key", + index, + table.lthCount, + answer); + return answer; +} + +void +lt_dump_table(void) +{ + int i, j, total=0; + + for (i=j=0; i < 100; ++i) { + if (hash_tries[i]) { + ++j; + total += hash_tries[i]; + } + } + if (j) + errprint(0, "Average # of hash tries %6.3f\n", + (double)total/(double)j); + + errprint(0, "\nLabel hash table layout (%d entries):\n", lt->lt_entrycount); + for (i = 0; i < LT_HASHSIZE; ++i) + if (lt->lt_labelhash[i].lthCount) + DumpLabelTable(<->lt_labelhash[i], i, 0, TRUE); + + errprint(0, "\n\nDest hash table layout (%d entries):\n", lt->lt_entrycount); + for (i = 0; i < LT_HASHSIZE; ++i) { + if (lt->lt_keyhash[i].lthCount) + DumpLabelTable(<->lt_keyhash[i], i, 0, FALSE); + } + errprint(0, "\n"); +} + +int +lt_check(int again) +{ + int i, value=0, labelcount=0, keycount=0, beforecount, aftercount; + char stuff[100]; + + beforecount = lt->lt_entrycount; + for (i=0; i < LT_HASHSIZE; ++i) { +#ifdef __SMP__ + LockChain(lt->lt_labelhash[i].lthLock, "lt_check", 0, TRUE, i); +#endif + + + value += CheckTable(lt->lt_labelhash[i], i, 0, TRUE); + labelcount += CountLabelTable(lt->lt_labelhash[i], i, 0, TRUE); +#ifdef __SMP__ + UnLockChain(lt->lt_labelhash[i].lthLock); +#endif + } + for (i=0; i < LT_HASHSIZE; ++i) { +#ifdef __SMP__ + LockChain(lt->lt_keyhash[i].lthLock, "lt_check", 0, FALSE, i); +#endif + value += CheckTable(lt->lt_keyhash[i], i, 0, FALSE); + keycount += CountLabelTable(lt->lt_keyhash[i], i, 0, FALSE); +#ifdef __SMP__ + UnLockChain(lt->lt_keyhash[i].lthLock); +#endif + } + aftercount = lt->lt_entrycount; + if (value) { + errprint(0, "%d: lt_check: %d table problem(s)!\n", getpid(), -value); + errprint(0, "Program %d seized up!\n", getpid()); + /* errprint(0, "Hit return for table dump: "); + gets(stuff); */ + lt_dump_table(); + return value; + } + if (beforecount > aftercount) { + int tmp; + tmp = beforecount; + beforecount = aftercount; + aftercount = tmp; + } + if (labelcount < beforecount || labelcount > aftercount || + keycount < beforecount || keycount > aftercount) { + /* Try once more; maybe stray rm */ + if (again && !lt_check(0)) + return 0; + errprint(0, "%d: lt_check: Warning: labelcount %d keycount %d bounds: %d/%d (current %d)\n", + getpid(), labelcount, keycount, beforecount, aftercount, lt->lt_entrycount); + errprint(0, "Program %d seized up!\n", getpid()); + /*errprint(0, "Hit return for table dump: "); + gets(stuff);*/ + lt_dump_table(); + } + return value; + +} + +void seizure() +{ + BlockAll(); + errprint(0, "Program seized up!\n"); + lt_dump_table(); +} + +/* this function was in eth_label.c before */ + +int label_eth_header(struct mbuf *skb, u_short *type, + LabelTableEntryPtr label) +{ + + if (!label) /* Just produce a standard header */ + return 0; + + /* Allow sufficient space for the label stack */ + + if((skb->m_flags & M_MCAST) || IN_MULTICAST(ntohl(label->lteDest))) + *type = htons(ETH_P_MMPLS); + else + *type = htons(ETH_P_UMPLS); + + return 0; +} + +/* these functions were in label_misc.c */ + + +/* Determine the "raw" size of a label stack */ +int true_label_stack_size(EthLabelStack label) +{ + int answer=sizeof(EthLabel); + return answer; + + if (!label) + return 0; + while (!label->elLab.elS) { + answer += sizeof(EthLabel); + ++label; + } + return answer; +} + +/* Determine the "refined" size of a label stack; works for both shim and mac + * proposals. + */ +int label_stack_size(EthLabelStack label, unsigned short flags) +{ + int answer = (*true_label_stack_size_ptr)(label); + + if (!answer) + return 0; + else + return answer; +} + +/* Copy in the relevant part of a label stack after the Ethernet header */ +void +label_add_stack(EthLabelStack buffer, EthLabelStack stack, unsigned short flags, int stacksize) +{ + bcopy((void *)buffer, (void *)(stack), stacksize); +} + +/* print Lable Table in respone to Label_Get */ +void PrintLabelTable(char *buf) +{ + int i; + LabelTablePtr run = NULL; + char str[80]; + LabelTableEntry *entry = NULL; + + sprintf(buf,"LabelIn Dest Addr Port Source Addr SPort Proto LabelOut Iface Stat_Out\n"); + for(i = 0; i < LT_HASHSIZE; ++i) { + if(lt->lt_keyhash[i].lthCount) { + run = lt->lt_keyhash[i].lthHeader; + } + while(run) { + entry = &(run->ltEntry); + while(entry) { + struct in_addr dest,src; + char protostr[5],destaddr[20],srcaddr[20]; + dest.s_addr = entry->lteDest; + strcpy(destaddr,inet_ntoa(dest)); + src.s_addr = entry->lteSource; + strcpy(srcaddr,inet_ntoa(src)); + strcpy(protostr,"TCP"); + sprintf(str,"%6d %15s %5d %15s %4d %3d %7d %4s%2u %d\n", + entry->lteLabel,(destaddr), + htons(entry->lteDestLtpPort), + inet_ntoa(src), + htons(entry->lteSourceLtpPort), + entry->lteDestLtpProtocol,entry->lteNewLabel, + (entry->lteForward)?entry->lteForward->if_name:"API", + (entry->lteForward)?entry->lteForward->if_unit:0, + entry->lteStatsOut); + strcat(buf,str); + entry = (entry->lteMCastList); + } + run = run->ltNextDest; + } + } + + return; +} + +u_short +extract_port(ips,hlen) +struct ip *ips; +int hlen; +{ + struct tcphdr *tcp; + struct udphdr *udp; + + + if (ips->ip_p == IPPROTO_TCP) { + tcp = (struct tcphdr *) ((char *)ips + hlen); + return (tcp->th_dport); + } + if (ips->ip_p == IPPROTO_UDP) { + udp = (struct udphdr *) ((char *)ips + hlen); + return (udp->uh_dport); + } + return 0; +} + +LabelTableKeyPtr extract_key(ips,hlen) +struct ip *ips; +int hlen; +{ + + struct tcphdr *tcp; + struct udphdr *udp; + LabelTableKeyPtr key = NULL; + + + if(ips->ip_p == IPPROTO_RSVP) return(NULL); + if (ips->ip_p == IPPROTO_TCP) { + key = (LabelTableKeyPtr)bigmalloc(sizeof(LabelTableKey)); + if(!key) return(NULL); + tcp = (struct tcphdr *) ((char *)ips + hlen); + key->ltkDestPort.ltp.ltpProtocol = (u_int8_t)IPPROTO_TCP; + key->ltkSourcePort.ltp.ltpProtocol = (u_int8_t)IPPROTO_TCP; + key->ltkDestPort.ltp.ltpPort = (u_int16_t)(tcp->th_dport); + key->ltkSourcePort.ltp.ltpPort = (u_int16_t)(tcp->th_sport); + key->ltkDestPort.ltp.ltpPad = (u_int8_t)0; + key->ltkSourcePort.ltp.ltpPad = (u_int8_t)0; + key->ltkDest = ips->ip_dst.s_addr; + key->ltkSource = ips->ip_src.s_addr; + key->ltkCoS = 0; + return(key); + } else if (ips->ip_p == IPPROTO_UDP) { + key = (LabelTableKeyPtr)bigmalloc(sizeof(LabelTableKey)); + if(!key) return(NULL); + udp = (struct udphdr *) ((char *)ips + hlen); + key->ltkDestPort.ltp.ltpProtocol = (u_int8_t)IPPROTO_UDP; + key->ltkSourcePort.ltp.ltpProtocol = (u_int8_t)IPPROTO_UDP; + key->ltkDestPort.ltp.ltpPort = (u_int16_t)(udp->uh_dport); + key->ltkSourcePort.ltp.ltpPort = (u_int16_t)(udp->uh_sport); + key->ltkDestPort.ltp.ltpPad = (u_int8_t)0; + key->ltkSourcePort.ltp.ltpPad = (u_int8_t)0; + key->ltkDest = ips->ip_dst.s_addr; + key->ltkSource = ips->ip_src.s_addr; + key->ltkCoS = 0; + return(key); + } else { + key = (LabelTableKeyPtr)bigmalloc(sizeof(LabelTableKey)); + if(!key) return(NULL); + key->ltkDestPort.ltp.ltpProtocol = 0; + key->ltkSourcePort.ltp.ltpProtocol = 0; + key->ltkDestPort.ltp.ltpPort = 0; + key->ltkSourcePort.ltp.ltpPort = 0; + key->ltkDestPort.ltp.ltpPad = (u_int8_t)0; + key->ltkSourcePort.ltp.ltpPad = (u_int8_t)0; + key->ltkDest = ips->ip_dst.s_addr; + key->ltkSource = ips->ip_src.s_addr; + key->ltkCoS = 0; + return(key); + } + + + +} + +#ifdef LABEL_MODULE +/* +MOD_MISC(label); + + +static int +label_load(struct lkm_table *lkmtp, int cmd) +{ + int s = splnet(); + lt_init(); + uprintf("Label support installed \n"); + splx(s); + return 0; +} + +static int +label_unload(struct lkm_table *lkmtp, int cmd) +{ + int s = splnet(); + lt_cleanup(); + uprintf("Label support removed \n"); + splx(s); + return 0; +} + +int +label_mod(struct lkm_table *lkmtp, int cmd, int ver) +{ + MOD_DISPATCH(label,lkmtp, cmd, ver, + label_load, label_unload, lkm_nullcmd); +} + +*/ +static int +label_modevent(module_t mod, int type, void *unused) +{ + int s; + + switch (type) { + case MOD_LOAD: + s = splnet(); + + lt_init(); + uprintf("Label support installed \n"); + splx(s); + return 0; + case MOD_UNLOAD: + s = splnet(); + lt_cleanup(); + uprintf("Label support removed \n"); + splx(s); + return 0; + default: + break; + } + return 0; +} + +static moduledata_t labelmod = { + "label", + label_modevent, + 0 +}; + + +DECLARE_MODULE(label, labelmod, SI_SUB_PSEUDO, SI_ORDER_ANY); +#endif /* LABEL_MODULE */ + + +#endif /* LT_DEBUG */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/label_table.h ./netinet/label_table.h --- ../sys-altq/netinet/label_table.h Wed Dec 31 19:00:00 1969 +++ ./netinet/label_table.h Tue Feb 15 14:35:54 2000 @@ -0,0 +1,208 @@ +/* Nascent label table structures and routines */ + +#ifndef _LABEL_TABLE_H +#define _LABEL_TABLE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef RSVPD +#include +#endif +#include + +/* Here is a fairly primitive label table structure. An entry contains + * label, next hop and ultimate destination addresses and QoS info, and + * some flags to cause label stack popping, pushing, or change top-of-stack. + * + * The table itself is a doubly-indexed hash table, indexed by label/CoS and + * by destination IP/CoS (should include QoS) info. Entries should have + * unique label/CoS values, but multiple entries may have the same + * destination IP/CoS value (e.g. for load balancing). + * + * TODO: 1. Make more generic. + * 2. Improve explicit route support. + * 3. Improve QoS support. + * 4. Improve everything else (:-) + */ + +/* LTForwardInfo should be a pointer to a structure having all the information + * required to send the data on to the next step. The actual means of + * employing this information will be implementation-specific, but we can + * at least make the label table storage routines independent of it. + */ +#if defined (linux) || defined (__FreeBSD__) +typedef struct ifnet *LTForwardInfo; +typedef union _ltPort { + u_int32_t ltpProtocolPort; + struct { + u_int16_t ltpPort; + u_int8_t ltpProtocol; /* UDP, TCP, ... */ + u_int8_t ltpPad; + } ltp; +} LTPort; +#else +/* @@ */ +#endif + +typedef struct _labelTableKey { /* size: 20 bytes */ + /* These fields are used for keys on a best match basis. */ + u_int32_t ltkDest; /* Destination IP address */ + u_int32_t ltkCoS; /* CoS info */ + LTPort ltkDestPort; /* Destination UDP/TCP port */ + u_int32_t ltkSource; /* Source IP address */ + LTPort ltkSourcePort; /* Source UDP/TCP port */ +} LabelTableKey, *LabelTableKeyPtr; + +typedef struct _labelTableEntry { + u_int32_t lteLabel; /* Label (also index) */ + LabelTableKey lteKey; +/* Destructuring defines */ + +#define lteDest lteKey.ltkDest +#define lteDestPort lteKey.ltkDestPort +#define lteDestLtpPort lteKey.ltkDestPort.ltp.ltpPort +#define lteDestLtpProtocol lteKey.ltkDestPort.ltp.ltpProtocol +#define lteDestLtpPad lteKey.ltkDestPort.ltp.ltpPad +#define lteSource lteKey.ltkSource +#define lteSourcePort lteKey.ltkSourcePort +#define lteSourceLtpPort lteKey.ltkSourcePort.ltp.ltpPort +#define lteSourceLtpProtocol lteKey.ltkSourcePort.ltp.ltpProtocol +#define lteSourceLtpPad lteKey.ltkSourcePort.ltp.ltpPad +#define lteCoS lteKey.ltkCoS + + /* @@ TBD explicit route info */ + u_int32_t lteTTL; /* temp. storage of TTL */ + u_int32_t lteNewLabel; /* New (next hop) label */ + u_int32_t lteNextHopAddr; /* Next hop IP address */ + u_int32_t lteFlags; /* Label flags */ + u_int32_t lteQFlags; /* Queue flags (placeholder) */ + u_int32_t lteSlabel; /* Flag for last label */ + u_int32_t lteStatsOut; /* Sent labeled packets */ + LTForwardInfo lteForward; /* Output device */ + struct _labelTableEntry *lteMCastList; /* Output list for multicast (circular?) */ +} LabelTableEntry, *LabelTableEntryPtr; + +/* lteFlags */ +#define LTE_ACTION 0xf /* Action mask */ +#define LTE_SWAP 0x1 /* swap new label for existing */ +#define LTE_POP 0x2 /* pop top of label stack */ +#define LTE_PUSH 0x3 /* push new label onto label stack */ +/* values 4-15 reserved */ + +#define LTE_GENERAL 0xf0 /* General flags */ +#define LTE_MULTICAST 0x10 /* ?? Do we need this */ +#define LTE_INPROGRESS 0x20 /* Debug flag - add in progress */ +/* bits 0x40 and 0x80 reserved */ +/* Other bits available */ + +/* The label table itself is a doubly-threaded hash table */ +typedef struct _labelTable { + LabelTableEntry ltEntry; + struct _labelTable * ltNextLabel; + struct _labelTable * ltNextKey; +#define ltNextDest ltNextKey +} LabelTable, *LabelTablePtr; + +/* We have per-table slot locks to control updating. In the current kernel + * environment, with all table updates occurring at task time, this is not + * strictly necessary, but it is good to have this sketched out now. (Note + * that table access will typically be at interrupt time, but we are careful + * to ensure table updates will never leave the table in an inconsistent + * state.) + * + * Unlike the Linux routing table, we don't do any pullbacks on the hash + * table chains. Table access here is relatively straightforward, so the + * additional complication wouldn't buy us too much. (We do keep a tiny + * cache of the last couple of accessed entries, though.) Instead, we + * make provisions to add a second level of hashing if any of the chains + * gets too long. This should be more than sufficient for the size of + * tables we'd expect to see. + */ + +#include + +typedef struct _labelTableHead { + LabelTablePtr lthHeader; + struct _labelTableHead *lthSecondTable; + u_int32_t lthCount; +#ifdef __SMP__ + lock_t lthLock; +#endif +} LabelTableHead, *LabelTableHeadPtr; + + +/* OK, as defined, each table entry+pointers amounts to 56 bytes (14 words). + * We pre-allocate 1024 entries, and create two hash tables with 256 slots. + * We also keep a finger on the last two entries accessed (not sure how + * helpful this is). Total memory use is 60. + */ + +/* Label tabel routines */ +/* + * lt_init - allocate and initialize label table + * lt_add - add a new entry to table. + * lt_rm - remove an entry + * lt_find - find best-matching entry in table + * lt_find_by_label - look up entry by label/CoS pair + * lt_find_by_dest - look up (first matching) entry by dest/CoS pair + * lt_find_next_dest - find next entry with matching dest/CoS + * lt_cleanup - free up and destroy label table + */ +extern void lt_init(void), + lt_cleanup(void); + +/* lt_keymatchlist - set the "best matching" criteria list. This is an + * array of key headers, where the entries are interpreted as masks. + * The key is and-ed with each mask in turn, with this "reduced" key + * then used to look in the table. + */ +#define LT_KEYMATCH_MAX 32 /* why not... */ +extern void lt_keymatchlist(LabelTableKeyPtr, int); + +#ifdef LT_DEBUG +/* + * lt_dump_table - print out the current label and dest tables + * lt_check - do integrity check over the tables + */ + +extern void lt_dump_table(void); +extern void lt_check(init); +#endif /* LT_DEBUG */ + +typedef LabelTablePtr lt_add_t __P((LabelTableEntryPtr)); +typedef int lt_rm_t __P((LabelTableEntryPtr)); +typedef LabelTablePtr lt_find_by_label_t __P((u_int32_t, u_int32_t)); +typedef LabelTablePtr lt_find_by_dest_t __P((u_int32_t, u_int32_t, u_int32_t)); +typedef LabelTablePtr lt_find_t __P((LabelTableKeyPtr)); +typedef int label_stack_size_t __P((EthLabelStack, unsigned short)); +typedef int true_label_stack_size_t __P((EthLabelStack)); +typedef void label_add_stack_t __P((EthLabelStack, EthLabelStack, unsigned short, int)); +typedef int label_eth_header_t __P((struct mbuf *, u_short *, LabelTablePtr)); +typedef void PrintLabelTable_t __P((char *)); +typedef u_short extract_port_t __P((struct ip *, int)); +typedef LabelTableKeyPtr extract_key_t __P((struct ip *,int)); + +extern lt_add_t *lt_add_ptr; +extern lt_rm_t *lt_rm_ptr; +extern lt_find_by_label_t *lt_find_by_label_ptr; +extern lt_find_by_dest_t *lt_find_by_dest_ptr; +extern lt_find_t *lt_find_ptr; +extern label_stack_size_t *label_stack_size_ptr; +true_label_stack_size_t *true_label_stack_size_ptr; /* needed ??? */ +extern label_add_stack_t *label_add_stack_ptr; +extern label_eth_header_t *label_eth_header_ptr; +extern PrintLabelTable_t *PrintLabelTable_ptr; +extern extract_port_t *extract_port_ptr; +extern extract_key_t *extract_key_ptr; +#endif _LABEL_TABLE_H diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/lock_sleep.c ./netinet/lock_sleep.c --- ../sys-altq/netinet/lock_sleep.c Wed Dec 31 19:00:00 1969 +++ ./netinet/lock_sleep.c Thu Feb 3 15:58:52 2000 @@ -0,0 +1,147 @@ +#include +#include + +#ifdef __SMP__ + +#ifdef SMP_TEST +lock_t *dummy_lock; + +static int numberlocks; +static struct mylocks { + lock_t *lock; + bed_t *bed; +} mylocks[50]; + +void lock_status(lock_t *the_lock); +#endif + + +inline void +SleepyLock(lock_t *the_lock, bed_t *the_bed, char *message) +{ +#ifdef SMP_TEST + int waiting=0, relief=0; +#endif + + BlockAll(); + while (TestAndSetLock(the_lock)) { +#ifdef SMP_TEST +#if LT_DEBUG > 6 + if (!waiting) { + printf("%s: %d: Waiting for %d at %lx\n", + message, getpid(), the_lock->holder, the_lock); + ++relief; + } +#endif + if (waiting == 20) { + printf("%s: %d: Lock holder %d seems to have wandered away!\n", message, getpid(), the_lock->holder); + kill(the_lock->holder, SIGUSR1); + } + ++waiting; +#endif +#ifdef SMP_TEST + if (SleepOn(the_bed, 20) < 0) { + lock_status(the_lock); + ++relief; + } +#else + SleepOn(the_bed, 20); +#endif + } +#ifdef SMP_TEST + mylocks[numberlocks].lock = the_lock; + mylocks[numberlocks].bed = the_bed; + ++numberlocks; +#ifdef SMP_TEST + if (relief) + printf("\t%d: Got it after %d attempts\n", getpid(), waiting); +#endif + the_lock->holder = getpid(); +#endif + UnBlockAll(); +} + +inline void +SleepyTest(lock_t *the_lock, bed_t *the_bed, char *message) +{ +#ifdef SMP_TEST + int waiting=0; +#endif + + BlockAll(); + while (TestLock(the_lock)) { +#ifdef SMP_TEST +#if LT_DEBUG > 6 + if (!waiting) + printf("%s: %d: passively waiting for %lx, (held by %d) sleeping on %lx:\n", + message, getpid(), the_lock, the_lock->holder, the_bed); +#endif + ++waiting; +#endif + SleepOn(the_bed, 20); + } +#ifdef SMP_TEST +#if LT_DEBUG > 6 + if (waiting) + printf("\t%d: Got it after %d attempts\n", getpid(), waiting); +#endif +#endif + UnBlockAll(); +} + +inline void +SleepyUnLock(lock_t *the_lock, bed_t *the_bed) +{ + BlockAll(); + ClearLock(the_lock); + RouseFrom(the_bed); +#ifdef SMP_TEST + --numberlocks; +#endif + UnBlockAll(); +} + +inline int +SleepOn(bed_t *bed, int limit) +{ + int sleep_count; + + (void)TestAndSetLock(bed); + UnBlockAll(); + for (sleep_count = 0; + TestLock(bed) && sleep_count < limit; ++sleep_count) + sleep(1); + BlockAll(); + return sleep_count >= limit ? -1 : 0; +} + + +#ifdef SMP_TEST +void +bustlocks(int arg) +{ + signal(SIGUSR1, bustlocks); + printf("Process %d apologizes for holding onto %d locks\n", getpid(), numberlocks); + while (numberlocks > 0) { + printf("\tBusting lock at %lx\n", mylocks[numberlocks-1].lock); + UnBlockAll(); + SleepyUnLock(mylocks[numberlocks-1].lock, mylocks[numberlocks-1].bed); + } +} + +void +lock_status(lock_t *the_lock) +{ + int i; + + printf("%d: Stuck waiting for %d at %lx\n", + getpid(), the_lock->holder, the_lock); + printf("%d: I already hold these locks: ", getpid()); + for (i = 0; i < numberlocks; ++i) { + printf(" %lx", mylocks[i].lock); + } + printf("\n"); +} +#endif + +#endif /* __SMP__ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/lock_sleep.h ./netinet/lock_sleep.h --- ../sys-altq/netinet/lock_sleep.h Wed Dec 31 19:00:00 1969 +++ ./netinet/lock_sleep.h Thu Feb 3 15:35:03 2000 @@ -0,0 +1,66 @@ +#ifndef _LOCK_SLEEP_H +#define _LOCK_SLEEP_H + +/* Locks */ +#if defined(linux) || defined (__FreeBSD__) + +#include +#include +#define LOCK_BIT 1 +typedef u_int32_t lock_t; +#define TestAndSetLock(a) set_bit(LOCK_BIT, (a)) +#define TestLock(a) test_bit(LOCK_BIT, (a)) +#define ClearLock(a) clear_bit(LOCK_BIT, (a)) + +#if defined(__KERNEL__) +#define BlockAll() cli() +#define UnBlockAll() sti() +#else +lock_t dummy_lock; +#define BlockAll() while (TestAndSetLock(&dummy_lock)) +#define UnBlockAll() (void)ClearLock(&dummy_lock) +#endif /* !__KERNEL__ */ + +#endif /* linux */ + +/* Beds */ +#if defined(linux) || defined(__FreeBSD__) + +#if defined(__KERNEL__) +typedef struct wait_queue *bed_t; +#define SleepOn(bed) interruptible_sleep_on(&bed) +#define RouseFrom(bed) wake_up_interruptible(&bed) +#else +typedef lock_t bed_t; +#define SleepOn(bed) \ + { UnBlockAll(); while (TestLock(bed)) ; BlockAll(); } +#define RouseFrom(bed) ClearLock(bed) +#endif + +#endif + +extern void SleepyLock(lock_t *, bed_t *); +extern void SleepyUnLock(lock_t *, bed_t *); + +#if defined (linux) || defined(__FreeBSD__) +extern __inline__ void +SleepyLock(lock_t *the_lock, bed_t *the_bed) +{ + BlockAll(); + while (TestAndSetLock(the_lock)) { + SleepOn(the_bed); + } + UnBlockAll(); +} + +extern __inline__ void +SleepyUnLock(lock_t *the_lock, bed_t *the_bed) +{ + BlockAll(); + ClearLock(the_lock); + RouseFrom(the_bed); + UnBlockAll(); +} +#endif + +#endif /* _LOCK_SLEEP_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netinet/switch_ether.h ./netinet/switch_ether.h --- ../sys-altq/netinet/switch_ether.h Wed Dec 31 19:00:00 1969 +++ ./netinet/switch_ether.h Thu Feb 3 17:02:14 2000 @@ -0,0 +1,127 @@ +#ifndef _SWITCH_ETHER_H +#define _SWITCH_ETHER_H 1 + +/* switch_ether.h -- structures and macros for dealing with labels in + * Ethernet headers. + * + * We define both the "shim" and "mac" label encodings. + * + * These types are defined: + * + * EthLabel "shim" Ethernet label + * EthMacLabel "mac" Ethernet label + * + * These macros are defined: + * + * GetEthLabel(EthLabel a) - extract "shim" label as integer + * SetEthLabel(EthLabel a, int label) - set "shim" label field + * + * GetEthMacLabel(EthMacLabel a) - extract "mac" label as integer + * SetEthMacLabel(EthMacLabel a, int label) - set "mac" label field + * GetEthMacOUI(EthMacLabel a) - extract "mac" OUI as integer + * SetEthMacOUI(EthMacLabel a, int label) - set "mac" OUI field + * + * The other fields can just be accessed as structure members. + */ + +#include +#include +#include + + +/* Standard types... +#ifndef __BIT_TYPES_DEFINED__ +typedef ushort_t u_int16_t; +typedef ulong_t u_int32_t; +#endif +*/ +/************************************************************************ + * Shim proposal * + ************************************************************************/ +/* "Shim" proposal Ethernet protocol ids (called "ethertype values" in the + * proposal). + */ + +/* IPv4 protocol */ +#define ETH_P_UMPLS 0x8847 /* Unicast MPLS "shim" */ +#define ETH_P_MMPLS 0x8848 /* Multicast MPLS "shim" */ + +/* IPv6 not specified in draft; here are some arbitrary choices: */ +#define ETH_P_V6UMPLS 0x88DD /* Unicast IPv6 MPLS "shim" */ +#define ETH_P_V6MMPLS 0x88DE /* Multicast IPv6 MPLS "shim" */ + +/* "Shim" proposal label stack format */ +/* Because labels are 20 bits, in a little endian bitfield they cannot be + * declared contiguously. So in that case, we just use masks. + */ + +typedef struct _elLab { +#if BYTE_ORDER == LITTLE_ENDIAN + u_int32_t elLabel01:16, /* first 16 bits */ + elS:1, /* bottom of stack */ + elCoS:3, /* class of service */ + elLabel2:4, /* last 4 bits of label */ + elTTL:8; /* time to live */ +#elif BYTE_ORDER == BIG_ENDIAN + u_int32_t elLabel:20, /* actual label */ + elCoS:3, /* class of service */ + elS:1, /* bottom of stack */ + elTTL:8; /* time to live */ +#else +#error "Please fix " +#endif +} ELLab; + +typedef union _ethLabel { + u_int32_t elEntry; /* for when a 32-bit long is more convenient */ + ELLab elLab; +} EthLabel, *EthLabelStack, *EthLabelPtr; + +#if BYTE_ORDER == LITTLE_ENDIAN + +#define __ETH_LABEL_MASK 0x00f0ffff +#define __ETH_TTL_MASK 0xff000000 +#define __ETH_S_MASK 0x00010000 +#define __ETH_COS_MASK 0x000e0000 +#define GetEthLabel(a) (ntohl((a).elEntry&__ETH_LABEL_MASK)>>12) +#define SetEthLabel(a, label) \ + (a).elEntry = (((a).elEntry&~__ETH_LABEL_MASK) | htonl(label<<12)) +#define GetEthTTL(a) (ntohl((a).elEntry&__ETH_TTL_MASK)) +#define SetEthTTL(a, ttl) \ + (a).elEntry = (((a).elEntry&~__ETH_TTL_MASK) | htonl(ttl)) +#define GetEthS(a) ((a).elEntry&__ETH_S_MASK) +#define SetEthS(a) \ + (a).elEntry = ((a).elEntry | __ETH_S_MASK) +#define GetEthCoS (ntohl((a).elEntry&__ETH_COS_MASK)>>9) +#define SetEthCoS(a, cos) \ + (a).elEntry = (((a).elEntry&~__ETH_COS_MASK) | htonl(cos<<9)) + +#elif BYTE_ORDER == BIG_ENDIAN + +#define __ETH_LABEL_MASK 0xfffff000 +#define GetEthLabel(a) ((a).elLab.elLabel) +#define SetEthLabel(a, label) (a).elLab.elLabel = (label) + +#endif + +/* Special label values */ +#define ETHLAB_IP_NULL 0 +#define ETHLAB_ROUTER_ALERT 1 +#define ETHLAB_IPV6_NULL 2 +#define ETHLAB_IMPLICIT_NULL 3 +#define ETHLAB_RESERVED4 4 +#define ETHLAB_RESERVED5 5 +#define ETHLAB_RESERVED6 6 +#define ETHLAB_RESERVED7 7 +#define ETHLAB_RESERVED8 8 +#define ETHLAB_RESERVED9 9 +#define ETHLAB_RESERVED10 10 +#define ETHLAB_RESERVED11 11 +#define ETHLAB_RESERVED12 12 +#define ETHLAB_RESERVED13 13 +#define ETHLAB_RESERVED14 14 +#define ETHLAB_RESERVED15 15 +#define ETHLAB_RESERVED16 16 + + +#endif /* _SWITCH_ETHER_H */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netnatm/natm.c ./netnatm/natm.c --- ../sys-altq/netnatm/natm.c Wed Jan 12 15:48:09 2000 +++ ./netnatm/natm.c Thu Apr 13 08:22:13 2000 @@ -39,409 +39,112 @@ #include #include #include +#include #include +#include #include -#include #include +#include #include #include #include #include #include +#include +#include #include -#include - -static u_long natm5_sendspace = 16*1024; -static u_long natm5_recvspace = 16*1024; - -static u_long natm0_sendspace = 16*1024; -static u_long natm0_recvspace = 16*1024; - -/* - * user requests - */ -#ifdef FREEBSD_USRREQS -/* - * FreeBSD new usrreqs supersedes pr_usrreq. - */ -static int natm_usr_attach __P((struct socket *, int, struct proc *)); -static int natm_usr_detach __P((struct socket *)); -static int natm_usr_connect __P((struct socket *, struct sockaddr *, - struct proc *)); -static int natm_usr_disconnect __P((struct socket *)); -static int natm_usr_shutdown __P((struct socket *)); -static int natm_usr_send __P((struct socket *, int, struct mbuf *, - struct sockaddr *, struct mbuf *, - struct proc *)); -static int natm_usr_peeraddr __P((struct socket *, struct sockaddr **)); -static int natm_usr_control __P((struct socket *, u_long, caddr_t, - struct ifnet *, struct proc *)); -static int natm_usr_abort __P((struct socket *)); -static int natm_usr_bind __P((struct socket *, struct sockaddr *, - struct proc *)); -static int natm_usr_sockaddr __P((struct socket *, struct sockaddr **)); - -static int -natm_usr_attach(struct socket *so, int proto, struct proc *p) -{ - struct natmpcb *npcb; - int error = 0; - int s = SPLSOFTNET(); - - npcb = (struct natmpcb *) so->so_pcb; - - if (npcb) { - error = EISCONN; - goto out; - } - - if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - if (proto == PROTO_NATMAAL5) - error = soreserve(so, natm5_sendspace, natm5_recvspace); - else - error = soreserve(so, natm0_sendspace, natm0_recvspace); - if (error) - goto out; - } - - so->so_pcb = (caddr_t) (npcb = npcb_alloc(M_WAITOK)); - npcb->npcb_socket = so; - out: - splx(s); - return (error); -} - -static int -natm_usr_detach(struct socket *so) -{ - struct natmpcb *npcb; - int error = 0; - int s = SPLSOFTNET(); - - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } - - /* - * we turn on 'drain' *before* we sofree. - */ - npcb_free(npcb, NPCB_DESTROY); /* drain */ - so->so_pcb = NULL; - sofree(so); - out: - splx(s); - return (error); -} - -static int -natm_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) -{ - struct natmpcb *npcb; - struct sockaddr_natm *snatm; - struct atm_pseudoioctl api; - struct ifnet *ifp; - int error = 0; - int s2, s = SPLSOFTNET(); - int proto = so->so_proto->pr_protocol; - - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } - - /* - * validate nam and npcb - */ - - snatm = (struct sockaddr_natm *)nam; - if (snatm->snatm_len != sizeof(*snatm) || - (npcb->npcb_flags & NPCB_FREE) == 0) { - error = EINVAL; - goto out; - } - if (snatm->snatm_family != AF_NATM) { - error = EAFNOSUPPORT; - goto out; - } - - snatm->snatm_if[IFNAMSIZ-1] = '\0'; /* XXX ensure null termination - since ifunit() uses strcmp */ - - /* - * convert interface string to ifp, validate. - */ - - ifp = ifunit(snatm->snatm_if); - if (ifp == NULL || (ifp->if_flags & IFF_RUNNING) == 0) { - error = ENXIO; - goto out; - } - if (ifp->if_output != atm_output) { - error = EAFNOSUPPORT; - goto out; - } - - /* - * register us with the NATM PCB layer - */ - - if (npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi) != npcb) { - error = EADDRINUSE; - goto out; - } - - /* - * enable rx - */ - - ATM_PH_FLAGS(&api.aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0; - ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; - ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); - api.rxhand = npcb; - s2 = splimp(); - if (ifp->if_ioctl == NULL || - ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api) != 0) { - splx(s2); - npcb_free(npcb, NPCB_REMOVE); - error = EIO; - goto out; - } - splx(s2); - - soisconnected(so); - - out: - splx(s); - return (error); -} - -static int -natm_usr_disconnect(struct socket *so) -{ - struct natmpcb *npcb; - struct atm_pseudoioctl api; - struct ifnet *ifp; - int error = 0; - int s2, s = SPLSOFTNET(); - - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } - - if ((npcb->npcb_flags & NPCB_CONNECTED) == 0) { - printf("natm: disconnected check\n"); - error = EIO; - goto out; - } - ifp = npcb->npcb_ifp; +#include "en.h" +#include "enp.h" +#include +#include - /* - * disable rx - */ - - ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5; - ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; - ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); - api.rxhand = npcb; - s2 = splimp(); - if (ifp->if_ioctl != NULL) - ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api); - splx(s2); - - npcb_free(npcb, NPCB_REMOVE); - soisdisconnected(so); - - out: - splx(s); - return (error); -} - -static int -natm_usr_shutdown(struct socket *so) -{ - socantsendmore(so); - return 0; -} - -static int -natm_usr_send(struct socket *so, int flags, struct mbuf *m, - struct sockaddr *nam, struct mbuf *control, struct proc *p) -{ - struct natmpcb *npcb; - struct atm_pseudohdr *aph; - int error = 0; - int s = SPLSOFTNET(); - int proto = so->so_proto->pr_protocol; - - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } - - if (control && control->m_len) { - m_freem(control); - m_freem(m); - error = EINVAL; - goto out; - } - - /* - * send the data. we must put an atm_pseudohdr on first - */ - - M_PREPEND(m, sizeof(*aph), M_WAITOK); - if (m == NULL) { - error = ENOBUFS; - goto out; - } - aph = mtod(m, struct atm_pseudohdr *); - ATM_PH_VPI(aph) = npcb->npcb_vpi; - ATM_PH_SETVCI(aph, npcb->npcb_vci); - ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0; - - error = atm_output(npcb->npcb_ifp, m, NULL, NULL); - - out: - splx(s); - return (error); -} - -static int -natm_usr_peeraddr(struct socket *so, struct sockaddr **nam) -{ - struct natmpcb *npcb; - struct sockaddr_natm *snatm, ssnatm; - int error = 0; - int s = SPLSOFTNET(); - - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } - - snatm = &ssnatm; - bzero(snatm, sizeof(*snatm)); - snatm->snatm_len = sizeof(*snatm); - snatm->snatm_family = AF_NATM; - snprintf(snatm->snatm_if, sizeof(snatm->snatm_if), - "%s%d", npcb->npcb_ifp->if_name, npcb->npcb_ifp->if_unit); - snatm->snatm_vci = npcb->npcb_vci; - snatm->snatm_vpi = npcb->npcb_vpi; - *nam = dup_sockaddr((struct sockaddr *)snatm, 0); - - out: - splx(s); - return (error); -} +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) +#include "opt_natm.h" +#endif -static int -natm_usr_control(struct socket *so, u_long cmd, caddr_t arg, - struct ifnet *ifp, struct proc *p) -{ - struct natmpcb *npcb; - struct atm_rawioctl ario; - int error = 0; - int s = SPLSOFTNET(); +#include - npcb = (struct natmpcb *) so->so_pcb; - if (npcb == NULL) { - error = EINVAL; - goto out; - } +#include - /* - * raw atm ioctl. comes in as a SIOCRAWATM. we convert it to - * SIOCXRAWATM and pass it to the driver. - */ - if (cmd == SIOCRAWATM) { - if (npcb->npcb_ifp == NULL) { - error = ENOTCONN; - goto out; - } - ario.npcb = npcb; - ario.rawvalue = *((int *)arg); - error = npcb->npcb_ifp->if_ioctl(npcb->npcb_ifp, - SIOCXRAWATM, (caddr_t) &ario); - if (!error) { - if (ario.rawvalue) - npcb->npcb_flags |= NPCB_RAW; - else - npcb->npcb_flags &= ~(NPCB_RAW); - } - } - else - error = EOPNOTSUPP; - out: - splx(s); - return (error); -} +u_long natm5_sendspace = 16*1024; +u_long natm5_recvspace = 16*1024; -static int -natm_usr_abort(struct socket *so) -{ - return natm_usr_shutdown(so); -} +u_long natm0_sendspace = 16*1024; +u_long natm0_recvspace = 16*1024; -static int -natm_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) -{ - return EOPNOTSUPP; -} +/* + * Function prototypes + */ +int natmconf __P((struct mbuf *, struct mbuf *)); +int natmnewvc __P((struct mbuf *, struct mbuf *)); +int natmdelvc __P((struct mbuf *, struct mbuf *)); +int natmstat __P((struct mbuf *, struct mbuf*)); -static int -natm_usr_sockaddr(struct socket *so, struct sockaddr **nam) -{ - return EOPNOTSUPP; -} +/* + * user requests + * + * FBSD 3.x now follows only new style of declarations. + * NOTE: If you make any changes to natm_usrreq(), then make sure to + * ALSO MAKE THE SAME CHANGES TO THE INDIVIDUAL USRREQS FOR FreeBSD 3.x + */ -/* xxx - should be const */ -struct pr_usrreqs natm_usrreqs = { - natm_usr_abort, pru_accept_notsupp, natm_usr_attach, natm_usr_bind, - natm_usr_connect, pru_connect2_notsupp, natm_usr_control, - natm_usr_detach, natm_usr_disconnect, pru_listen_notsupp, - natm_usr_peeraddr, pru_rcvd_notsupp, pru_rcvoob_notsupp, - natm_usr_send, pru_sense_null, natm_usr_shutdown, - natm_usr_sockaddr, sosend, soreceive, sopoll -}; +/*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*/ -#else /* !FREEBSD_USRREQS */ +/* Include this section only for NetBSD, OpenBSD, and FreeBSD versions + * prior to v3.0 + */ +#if defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 300000) #if defined(__NetBSD__) || defined(__OpenBSD__) -int natm_usrreq(so, req, m, nam, control, p) -#elif defined(__FreeBSD__) +int +natm_usrreq(so, req, m, nam, control, p) +#elif defined(__FreeBSD__) int natm_usrreq(so, req, m, nam, control) #endif - -struct socket *so; -int req; -struct mbuf *m, *nam, *control; + struct socket *so; + int req; + struct mbuf *m, *nam, *control; #if defined(__NetBSD__) || defined(__OpenBSD__) -struct proc *p; + struct proc *p; #endif - { int error = 0, s, s2; - struct natmpcb *npcb; + struct natmpcb *npcb, *cpcb; struct sockaddr_natm *snatm; struct atm_pseudoioctl api; struct atm_pseudohdr *aph; struct atm_rawioctl ario; + struct atm_txspd_ioctl atxspd; struct ifnet *ifp; int proto = so->so_proto->pr_protocol; + trfdesc old; s = SPLSOFTNET(); + if((u_long)m == SIOCATMSTAT) { + error = natmstat(m, nam); + goto done; + } + + if((u_long)m == SIOCGATMCONF) { + error = natmconf(m, nam); + goto done; + } + + if ((u_long)m == SIOCNEWVC) { + error = natmnewvc(m, nam); + goto done; + } + + if ((u_long)m == SIOCDELVC) { + error = natmdelvc(m, nam); + goto done; + } + npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL && req != PRU_ATTACH) { @@ -451,7 +154,8 @@ switch (req) { - case PRU_ATTACH: /* attach protocol to up */ + + case PRU_ATTACH: /* attach protocol to up */ if (npcb) { error = EISCONN; @@ -459,16 +163,21 @@ } if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - if (proto == PROTO_NATMAAL5) + if (proto == PROTO_NATMAAL5) { + /* printf("natm5_sendspace=%d\n",natm5_sendspace); */ error = soreserve(so, natm5_sendspace, natm5_recvspace); - else + } + else { + /* printf("natm0_sendspace=%d\n",natm0_sendspace); */ error = soreserve(so, natm0_sendspace, natm0_recvspace); + } if (error) break; } so->so_pcb = (caddr_t) (npcb = npcb_alloc(M_WAITOK)); npcb->npcb_socket = so; + npcb->npcb_refcnt++; break; @@ -522,19 +231,50 @@ break; } + if (ifp->if_ioctl == NULL) { + error = EIO; + break; + } + + /* + * Zero the traffic descriptor + */ + npcb->desc.pbw= npcb->desc.abw= npcb->desc.pbw=0; /* * register us with the NATM PCB layer */ - if (npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi) != npcb) { - error = EADDRINUSE; + cpcb = npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi); + if (cpcb == NULL) { + error = EADDRINUSE; + break; + } + if (cpcb != npcb) { + npcb_free(npcb, NPCB_DESTROY); + npcb = cpcb; + so->so_pcb = (caddr_t) npcb; + npcb->npcb_socket = so; + } else { + npcb->npcb_refcnt--; + } + + if (snatm->snatm_vpi == 1) { +#ifdef EN_DEBUG + printf("Leaving connect, it's pvc, so failed VCI=%d \n", + snatm->snatm_vci); +#endif + soisconnected(so); break; } /* * enable rx */ + if (npcb->npcb_refcnt > 1) { + soisconnected(so); + break; + } ATM_PH_FLAGS(&api.aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0; ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; @@ -545,6 +285,7 @@ ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api) != 0) { splx(s2); npcb_free(npcb, NPCB_REMOVE); + printf("NATM EIO ERROR ... ioctl function %p\n", ifp->if_ioctl); error = EIO; break; } @@ -567,16 +308,26 @@ * disable rx */ + /* If the refcnt is more than 1, we keep the VC */ + + if (npcb->npcb_refcnt > 1) { + npcb->npcb_refcnt--; + soisdisconnected(so); + break; + } + ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5; ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; s2 = splimp(); + if (ifp->if_ioctl != NULL) ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api); splx(s2); npcb_free(npcb, NPCB_REMOVE); + soisdisconnected(so); break; @@ -594,9 +345,24 @@ } /* - * send the data. we must put an atm_pseudohdr on first + * send the data without waiting. Driver may drop it! + * we must put an atm_pseudohdr on first + * */ + /* + * Following printfs are for NATM_AAL0 to see if size of message + * is multiple of 48. + * + * */ + + /*if (m->m_flags & M_PKTHDR) { + if ((m->m_pkthdr.len % 48) != 0) + printf("ODD LENGTH %d\n", m->m_pkthdr.len); + } else { + printf("NON PACKET HEADER DETECTED!!!!!!\n"); + }*/ + M_PREPEND(m, sizeof(*aph), M_WAITOK); if (m == NULL) { error = ENOBUFS; @@ -621,10 +387,11 @@ nam->m_len = snatm->snatm_len = sizeof(*snatm); snatm->snatm_family = AF_NATM; #if defined(__NetBSD__) || defined(__OpenBSD__) - bcopy(npcb->npcb_ifp->if_xname, snatm->snatm_if, sizeof(snatm->snatm_if)); + bcopy(npcb->npcb_ifp->if_xname, snatm->snatm_if, + sizeof(snatm->snatm_if)); #elif defined(__FreeBSD__) - snprintf(snatm->snatm_if, sizeof(snatm->snatm_if), - "%s%d", npcb->npcb_ifp->if_name, npcb->npcb_ifp->if_unit); + sprintf(snatm->snatm_if, "%s%d", npcb->npcb_ifp->if_name, + npcb->npcb_ifp->if_unit); #endif snatm->snatm_vci = npcb->npcb_vci; snatm->snatm_vpi = npcb->npcb_vpi; @@ -654,6 +421,37 @@ break; } + /* + * Set TXSPEED ioctl. comes in as a SIOCTXPSEED. we convert it to + * SIOCXTXSPEED and pass it to the driver. Need "vci" in the + * "pcb" */ + if ((u_long)m == SIOCTXSPEED) { + if (error = suser(curproc->p_ucred, &curproc->p_acflag)) { + break; + } + if (npcb->npcb_ifp == NULL) { + printf("natm.c/atm_usrreq(): SIOCTXSPEED, no data\n"); + error = ENOTCONN; + break; + } + bcopy(&(npcb->desc), (trfdesc *)&old,sizeof(trfdesc)); + bcopy((trfdesc *)nam, (trfdesc *)&(npcb->desc), sizeof(trfdesc)); + atxspd.npcb = npcb; + +#ifdef EN_DEBUG + printf("Bfioctl:VCI=%d,pbw=%d,abw=%d,bsz=%d\n", + atxspd.npcb->npcb_vci,((trfdesc *)nam)->pbw, + ((trfdesc *)nam)->abw,((trfdesc *) nam)->bsize); +#endif + error = npcb->npcb_ifp->if_ioctl(npcb->npcb_ifp, + SIOCXTXSPEED, (caddr_t) &atxspd); + if (!error) { + /* Copy old traffic descriptor back !*/ + bcopy( (trfdesc *)&old,&(npcb->desc),sizeof(trfdesc)); + } + break; + } + error = EOPNOTSUPP; break; @@ -685,7 +483,11 @@ return(error); } -#endif /* !FREEBSD_USRREQS */ +#endif /* NetBSD || OpenBSD || FreeBSD < 3.0*/ + + +/*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*/ + /* * natmintr: splsoftnet interrupt @@ -762,6 +564,218 @@ goto next; } + +/* return a bunch of stats */ +int natmstat(struct mbuf *m, struct mbuf *nam) { + struct ifnet *ifp; + struct atm_stat *enstat = (struct atm_stat*)nam; + char *ifname = enstat->if_name; + + int error = 0; + /*ensure NULL termination */ + ifname[IFNAMSIZ-1] = '\0'; + if ((ifp = ifunit(ifname)) == NULL) { + printf("%s is not configured\n", ifname); + return EINVAL; + } + error = ifp->if_ioctl(ifp,(u_long)m,(caddr_t)nam); + return error; +} + +/* + * Retrieve the configured VCC info on an ATM card + * (all its pseudo-interfaces included). + */ +int +natmconf(m, nam) +struct mbuf *m, *nam; +{ + struct ifnet *ifp; + struct ifatmconf *ifac = (struct ifatmconf *) nam; + struct ifatmreq *ifar = ifac->ifac_req; + char *ifname = ifar->ifar_name; + int error = 0; + + if((u_long)m == SIOCGATMCONF) { + ifname[IFNAMSIZ-1] = '\0'; /* ensure NULL termination */ + if ( (ifp=ifunit(ifname)) == 0 ) { + printf("natm.c/atm_usrreq(): SIOCGATMCONF, no data.\n"); + return EINVAL; + } + error = ifp->if_ioctl(ifp, (u_long) m, (caddr_t) nam); + } else { + error = EINVAL; + } + return error; +} + +/* + * Create a new VCC, called directly from a user utility program. + * Takes care of sharing npcbs. When we do away with them, this VC creation + * needs to be reexamined. + */ +int +natmnewvc(m, nam) +struct mbuf *m, *nam; +{ + int error = 0; + struct ifnet *ifp; + struct ifatmreq *ifar = (struct ifatmreq *) nam; + struct atm_pseudoioctl api; + struct atm_pseudohdr *aph = &api.aph; + struct natmpcb *npcb = NULL; + struct en_softc *sc; + int i; + + /* If not super user, tough luck! + */ + if (error = suser(curproc->p_ucred, &curproc->p_acflag)) { + return error; + } + + /* Build the ATM pseudo-header + */ + aph->atm_ph[0] = ifar->ifar_flags; + aph->atm_ph[1] = ifar->ifar_vpi; + ATM_PH_SETVCI(aph,ifar->ifar_vci); + + ifar->ifar_name[IFNAMSIZ-1] = '\0'; /* XXX ensure null termination */ + ifp = ifunit(ifar->ifar_name); + if (ifp == NULL) + return (ENXIO); + + /* + * If there is already a VC on this i/f, bail. + */ + i = ((strlen(ifp->if_name) == 2) ? 0: ifp->if_unit) + + ((strlen(ifp->if_name) > 2) ? 1: 0); + sc=(struct en_softc *)ifp->if_softc; + if ((sc->vctoif[i].vci != 0) && (sc->vctoif[i].vci != ifar->ifar_vci)) + return (EEXIST); + + /* + * let native ATM know we are using this VCI/VPI + * (i.e. reserve it) + */ + npcb = npcb_add(NULL, ifp, ATM_PH_VCI(aph), + ATM_PH_VPI(aph)); + if (npcb == NULL) { + return (EADDRINUSE); + } + if ((npcb->npcb_flags & NPCB_IP) == 0) { + npcb->npcb_flags |= NPCB_IP; + } + + /* + * let the lower level know this circuit is active + */ +#ifdef NATM + if (npcb->npcb_refcnt > 1) { + printf("natmnewvc: VCI: %d exists.\n", ifar->ifar_vci); + return error; + } +#endif /* NATM */ + + api.rxhand = NULL; + if ((error=ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t)&api)) != 0) { + printf("atm: couldn't add VC\n"); + goto failed; + } + + /* + * Update the vctoif mapping in the en_softc structure. + * XXX this is done here instead of in en_rxctl + * because there we don't have the ifp. + * Deletion, however, is done there. + */ + sc->vctoif[i].ifp = ifp; + sc->vctoif[i].vci = ifar->ifar_vci; + bcopy((char *)aph, &sc->vctoif[i].aph, sizeof (struct atm_pseudohdr) ); + sc->vctoif[i].refcnt = &npcb->npcb_refcnt; + + sc->vci2ifp[ifar->ifar_vci] = ifp; + + return error; + +failed: + printf("natmnewvc: failed. Deleting the npcb/vci.\n"); +#ifdef NATM + if (npcb) { + npcb_free(npcb, NPCB_DESTROY); + } +#endif + + return error; +} + +/* + * This is called to delete a VCC created by SIOCNEWVC + */ +int +natmdelvc(m, nam) +struct mbuf *m, *nam; +{ + int error = 0; + struct ifnet *ifp; + struct ifatmreq *ifar = (struct ifatmreq *) nam; + struct atm_pseudoioctl api; + struct atm_pseudohdr *aph = &api.aph; + +#ifdef NATM + struct natmpcb *npcb = NULL; +#endif + + /* If not super user, tough luck! + */ + if (error = suser(curproc->p_ucred, &curproc->p_acflag)) { + return error; + } + + ifar->ifar_name[IFNAMSIZ-1] = '\0'; /* XXX ensure null termination */ + ifp = ifunit(ifar->ifar_name); + if (ifp == NULL) + return (ENXIO); + +#ifdef NATM + + /* + * tell native ATM we are done with this VC + */ + + if ((npcb=npcb_lookup(ifp, ifar->ifar_vci, ifar->ifar_vpi)) == NULL) { + return (EINVAL); + } + + /* + * npcb is deallocated by npcb_free + * only if refcnt <= 1. This is a hack to test here. XXX + */ + if (npcb->npcb_refcnt <= 1) { + npcb_free(npcb, NPCB_DESTROY); + npcb = 0; + } else { + npcb_free(npcb, NPCB_DESTROY); + } + + if (npcb) + return(error); +#endif /* NATM */ + + /* Build the ATM pseudo-header + */ + aph->atm_ph[0] = ifar->ifar_flags; + aph->atm_ph[1] = ifar->ifar_vpi; + ATM_PH_SETVCI(aph,ifar->ifar_vci); + api.rxhand = NULL; + + /* + * tell the lower layer to disable this circuit + */ + error=ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t)&api); + + return error; +} + #if defined(__FreeBSD__) NETISR_SET(NETISR_NATM, natmintr); #endif @@ -808,3 +822,468 @@ return (ENOTDIR); return (ENOPROTOOPT); } + +/******* Rest is FreeBSD 3.x specific *******/ + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) +static int +natm_abort(struct socket *so) +{ + struct natmpcb *npcb = (struct natmpcb *) so->so_pcb; + + if (npcb == NULL) + return EINVAL; + return EOPNOTSUPP; +} + +static int +natm_attach(struct socket *so, int proto, struct proc *p) +{ + struct natmpcb *npcb; + int s, error=0; + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb) { + return EISCONN; + } + + s = SPLSOFTNET(); + + if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { + if (proto == PROTO_NATMAAL5) { + error = soreserve(so, natm5_sendspace, natm5_recvspace); + } else { + error = soreserve(so, natm0_sendspace, natm0_recvspace); + } + if (error) { + splx(s); + return error; + } + } + so->so_pcb = (caddr_t) (npcb = npcb_alloc(M_WAITOK)); + npcb->npcb_socket = so; + npcb->npcb_refcnt++; + + splx(s); + return error; +} + +static int +natm_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +{ + return EOPNOTSUPP; +} + +static int +natm_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +{ + struct natmpcb *npcb, *cpcb; + struct sockaddr_natm *snatm; + struct atm_pseudoioctl api; + int s, s2, error=0; + struct ifnet *ifp; + int proto = so->so_proto->pr_protocol; + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) + return EINVAL; + + /* + * validate nam and npcb + */ + + snatm = (struct sockaddr_natm *) nam; + if (snatm->snatm_len != sizeof(*snatm) || + (npcb->npcb_flags & NPCB_FREE) == 0) { + return EINVAL; + } + if (snatm->snatm_family != AF_NATM) { + return EAFNOSUPPORT; + } + + s = SPLSOFTNET(); + + snatm->snatm_if[IFNAMSIZ-1] = '\0'; /* XXX ensure null termination + since ifunit() uses strcmp */ + + /* + * convert interface string to ifp, validate. + */ + + ifp = ifunit(snatm->snatm_if); + if (ifp == NULL || (ifp->if_flags & IFF_RUNNING) == 0) { + error = ENXIO; + goto done; + } + if (ifp->if_output != atm_output) { + error = EAFNOSUPPORT; + goto done; + } + + if (ifp->if_ioctl == NULL) { + error = EIO; + goto done; + } + + /* + * Zero the traffic descriptor + */ + npcb->desc.pbw= npcb->desc.abw= npcb->desc.pbw=0; + + /* + * register us with the NATM PCB layer + */ + + cpcb = npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi); + if (cpcb == NULL) { + error = EADDRINUSE; + goto done; + } + if (cpcb != npcb) { + npcb_free(npcb, NPCB_DESTROY); + npcb = cpcb; + so->so_pcb = (caddr_t) npcb; + npcb->npcb_socket = so; + } else { + npcb->npcb_refcnt--; + } + + if (snatm->snatm_vpi == 1) { +#ifdef EN_DEBUG + printf("Leaving connect, it's pvc, so failed VCI=%d \n", + snatm->snatm_vci); +#endif + soisconnected(so); + goto done; + } + + /* + * enable rx + */ + if (npcb->npcb_refcnt > 1) { + soisconnected(so); + goto done; + } + + ATM_PH_FLAGS(&api.aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0; + ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; + ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); + api.rxhand = npcb; + s2 = splimp(); + if (ifp->if_ioctl == NULL || + ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api) != 0) { + splx(s2); + npcb_free(npcb, NPCB_REMOVE); + printf("NATM EIO ERROR ... ioctl function %p\n", ifp->if_ioctl); + error = EIO; + goto done; + } + splx(s2); + + soisconnected(so); + +done: + splx(s); + return error; +} + +static int +natm_control(struct socket *so, u_long cmd, caddr_t data, + struct ifnet *ifp, struct proc *p) +{ + struct natmpcb *npcb; + int s, error = 0; + struct atm_rawioctl ario; + struct atm_txspd_ioctl atxspd; + trfdesc old; + + s = SPLSOFTNET(); + + if((u_long)cmd == SIOCATMSTAT) { + error = natmstat((struct mbuf *)cmd, (struct mbuf *)data); + goto done; + } + + if((u_long)cmd == SIOCGATMCONF) { + error = natmconf((struct mbuf *)cmd, (struct mbuf *)data); + goto done; + } + + if ((u_long)cmd == SIOCNEWVC) { + error = natmnewvc((struct mbuf *)cmd, (struct mbuf *)data); + goto done; + } + + if ((u_long)cmd == SIOCDELVC) { + error = natmdelvc((struct mbuf *)cmd, (struct mbuf *)data); + goto done; + } + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) { + error = EINVAL; + goto done; + } + + /* + * raw atm ioctl. comes in as a SIOCRAWATM. we convert it to + * SIOCXRAWATM and pass it to the driver. + */ + if ((u_long)cmd == SIOCRAWATM) { + if (npcb->npcb_ifp == NULL) { + error = ENOTCONN; + goto done; + } + ario.npcb = npcb; + ario.rawvalue = *((int *)data); + error = npcb->npcb_ifp->if_ioctl(npcb->npcb_ifp, + SIOCXRAWATM, (caddr_t) &ario); + if (!error) { + if (ario.rawvalue) + npcb->npcb_flags |= NPCB_RAW; + else + npcb->npcb_flags &= ~(NPCB_RAW); + } + + goto done; + } + + /* + * Set TXSPEED ioctl. comes in as a SIOCTXPSEED. we convert it to + * SIOCXTXSPEED and pass it to the driver. Need "vci" in the + * "pcb" + */ + if ((u_long)cmd == SIOCTXSPEED) { + if (error = suser(curproc->p_ucred, &curproc->p_acflag)) { + goto done; + } + + if (npcb->npcb_ifp == NULL) { + printf("natm.c/atm_usrreq(): SIOCTXSPEED, no data\n"); + error = ENOTCONN; + goto done; + } + bcopy(&(npcb->desc), (trfdesc *)&old,sizeof(trfdesc)); + bcopy((trfdesc *)data,(trfdesc *)&(npcb->desc), sizeof(trfdesc)); + atxspd.npcb = npcb; + +#ifdef EN_DEBUG + printf("Bfioctl:VCI=%d,pbw=%d,abw=%d,bsz=%d\n", + atxspd.npcb->npcb_vci,((trfdesc *)data)->pbw, + ((trfdesc *)data)->abw,((trfdesc *) data)->bsize); +#endif + error = npcb->npcb_ifp->if_ioctl(npcb->npcb_ifp, + SIOCXTXSPEED, (caddr_t) &atxspd); + if (!error) { + /* Copy old traffic descriptor back !*/ + bcopy( (trfdesc *)&old,&(npcb->desc),sizeof(trfdesc)); + } + goto done; + } + + error = EOPNOTSUPP; + +done: + splx(s); + return error; +} + +static int +natm_detach(struct socket *so) +{ + struct natmpcb *npcb; + int s; + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) + return EINVAL; + + s = SPLSOFTNET(); + + npcb_free(npcb, NPCB_DESTROY); /* drain */ + so->so_pcb = NULL; + sofree(so); + + splx(s); + return 0; +} + +static int +natm_disconnect(struct socket *so) +{ + struct natmpcb *npcb; + int s, s2, error = 0; + struct atm_pseudoioctl api; + struct ifnet *ifp; + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) + return EINVAL; + + s = SPLSOFTNET(); + + if ((npcb->npcb_flags & NPCB_CONNECTED) == 0) { + printf("natm: disconnected check\n"); + error = EIO; + goto done; + } + ifp = npcb->npcb_ifp; + + /* + * disable rx + */ + + /* If the refcnt is more than 1, we keep the VC */ + + if (npcb->npcb_refcnt > 1) { + npcb->npcb_refcnt--; + soisdisconnected(so); + goto done; + } + + ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5; + ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; + ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); + api.rxhand = npcb; + s2 = splimp(); + + if (ifp->if_ioctl != NULL) + ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api); + splx(s2); + + npcb_free(npcb, NPCB_REMOVE); + + soisdisconnected(so); + +done: + splx(s); + return error; +} + +static int +natm_peeraddr(struct socket *so, struct sockaddr **nam) +{ + struct natmpcb *npcb; + struct sockaddr_natm *snatm; + int s; + + /* + * Do the malloc first in case it blocks. + */ + MALLOC(snatm, struct sockaddr_natm *, sizeof *snatm, + M_SONAME, M_WAITOK); + bzero((caddr_t)snatm, sizeof(*snatm)); + snatm->snatm_family = AF_NATM; + snatm->snatm_len = sizeof(*snatm); + + s = SPLSOFTNET(); + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) { + splx(s); + free(snatm, M_SONAME); + return EINVAL; + } + +#if defined(__NetBSD__) || defined(__OpenBSD__) + bcopy(npcb->npcb_ifp->if_xname, snatm->snatm_if, + sizeof(snatm->snatm_if)); +#elif defined(__FreeBSD__) + sprintf(snatm->snatm_if, "%s%d", npcb->npcb_ifp->if_name, + npcb->npcb_ifp->if_unit); +#endif + snatm->snatm_vci = npcb->npcb_vci; + snatm->snatm_vpi = npcb->npcb_vpi; + + splx(s); + + *nam = (struct sockaddr *)snatm; + return 0; +} + +static int +natm_send(struct socket *so, int flags, struct mbuf *m, + struct sockaddr *addr, struct mbuf *control, struct proc *p) +{ + struct natmpcb *npcb; + int s, error = 0; + struct atm_pseudohdr *aph; + int proto = so->so_proto->pr_protocol; + + if (control && control->m_len) { + m_freem(control); + m_freem(m); + return EINVAL; + } + + s = SPLSOFTNET(); + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) { + splx(s); + return EINVAL; + } + + /* + * send the data without waiting. Driver may drop it! + * we must put an atm_pseudohdr on first + * + */ + + /* + * Following printfs are for NATM_AAL0 to see if size of message + * is multiple of 48. + */ + + /*if (m->m_flags & M_PKTHDR) { + if ((m->m_pkthdr.len % 48) != 0) + printf("ODD LENGTH %d\n", m->m_pkthdr.len); + } else { + printf("NON PACKET HEADER DETECTED!!!!!!\n"); + }*/ + + M_PREPEND(m, sizeof(*aph), M_WAITOK); + if (m == NULL) { + error = ENOBUFS; + goto done; + } + aph = mtod(m, struct atm_pseudohdr *); + ATM_PH_VPI(aph) = npcb->npcb_vpi; + ATM_PH_SETVCI(aph, npcb->npcb_vci); + ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0; + + error = atm_output(npcb->npcb_ifp, m, NULL, NULL); + +done: + splx(s); + return error; +} + +static int +natm_shutdown(struct socket *so) +{ + struct natmpcb *npcb; + + npcb = (struct natmpcb *) so->so_pcb; + if (npcb == NULL) + return EINVAL; + + socantsendmore(so); + return 0; +} + +static int +natm_sockaddr_unsupp(struct socket *so, struct sockaddr **nam) +{ + return EOPNOTSUPP; +} + +struct pr_usrreqs natm_usrreqs = { + natm_abort, pru_accept_notsupp, natm_attach, natm_bind, natm_connect, + pru_connect2_notsupp, natm_control, natm_detach, natm_disconnect, + pru_listen_notsupp, natm_peeraddr, pru_rcvd_notsupp, + pru_rcvoob_notsupp, natm_send, pru_sense_null, natm_shutdown, + natm_sockaddr_unsupp, sosend, soreceive, sopoll +}; + +#endif /* FreeBSD 3.x */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netnatm/natm.h ./netnatm/natm.h --- ../sys-altq/netnatm/natm.h Wed Jan 12 15:48:09 2000 +++ ./netnatm/natm.h Fri Jun 11 03:43:38 1999 @@ -36,6 +36,8 @@ * natm.h: native mode atm */ +#ifndef _NETNATM_NATM_H_ +#define _NETNATM_NATM_H_ /* * supported protocols @@ -56,6 +58,11 @@ u_int8_t snatm_vpi; /* vpi */ }; +typedef struct traffic_des { + int abw; /* Average bw */ + int pbw; /* Peak bw */ + int bsize; /* Burst sz */ +} trfdesc; #if defined(__FreeBSD__) && defined(KERNEL) @@ -82,10 +89,24 @@ u_int npcb_inq; /* # of our pkts in proto q */ struct socket *npcb_socket; /* backpointer to socket */ struct ifnet *npcb_ifp; /* pointer to hardware */ +#ifdef INET6 + union { + struct { + u_int32_t spare[3]; + struct in_addr addr; + } addr4; + struct in6_addr addr6; + } u_ipaddr; +#define ipaddr u_ipaddr.addr4.addr +#define ipaddr6 u_ipaddr.addr6 +#else /* INET6 */ struct in_addr ipaddr; /* remote IP address, if APCB_IP */ +#endif /* INET6 */ u_int16_t npcb_vci; /* VCI */ u_int8_t npcb_vpi; /* VPI */ u_int8_t npcb_flags; /* flags */ + trfdesc desc; /* Traffic Descriptor */ + u_int16_t npcb_refcnt; /* reference count */ }; /* flags */ @@ -95,6 +116,9 @@ #define NPCB_DRAIN 0x08 /* destory as soon as inq == 0 */ #define NPCB_RAW 0x10 /* in 'raw' mode? */ +/* VPI used for all VCs meant to be rate limited - maher */ +#define RATE_LIMIT_VPI 1 + /* flag arg to npcb_free */ #define NPCB_REMOVE 0 /* remove from global list */ #define NPCB_DESTROY 1 /* destroy and be free */ @@ -113,7 +137,7 @@ /* global data structures */ -extern struct npcblist natm_pcbs; /* global list of pcbs */ +struct npcblist natm_pcbs; /* global list of pcbs */ extern struct ifqueue natmintrq; /* natm packet input queue */ #define NATM_STAT #ifdef NATM_STAT @@ -128,7 +152,18 @@ struct natmpcb *npcb; int rawvalue; }; -#define SIOCXRAWATM _IOWR('a', 125, struct atm_rawioctl) +#define SIOCXRAWATM _IOWR('c', 128, struct atm_rawioctl) + + +/* Adding a ioctl to set the VCI rate -- Milind */ +struct atm_txspd_ioctl { + struct natmpcb *npcb; +}; +#define SIOCXTXSPEED _IOWR('i',129,struct atm_txspd_ioctl) + +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) +extern struct pr_usrreqs natm_usrreqs; +#endif /* external functions */ @@ -136,26 +171,20 @@ struct natmpcb *npcb_alloc __P((int)); void npcb_free __P((struct natmpcb *, int)); struct natmpcb *npcb_add __P((struct natmpcb *, struct ifnet *, int, int)); +struct natmpcb *npcb_lookup __P((struct ifnet *, int, int)); /* natm.c */ #if defined(__NetBSD__) || defined(__OpenBSD__) int natm_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *)); #elif defined(__FreeBSD__) -#if __FreeBSD__ > 2 -/* - * FreeBSD new usrreqs style appeared since 2.2. compatibility to old style - * has gone since 3.0. - */ -#define FREEBSD_USRREQS -extern struct pr_usrreqs natm_usrreqs; -#else /* !( __FreeBSD__ > 2) */ int natm_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *)); -#endif /* !( __FreeBSD__ > 2) */ #endif int natm0_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); int natm5_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); void natmintr __P((void)); #endif + +#endif /* _NETNATM_NATM_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/netnatm/natm_pcb.c ./netnatm/natm_pcb.c --- ../sys-altq/netnatm/natm_pcb.c Wed Jan 12 15:48:09 2000 +++ ./netnatm/natm_pcb.c Fri Dec 10 09:24:53 1999 @@ -39,17 +39,36 @@ #include #include -#include +#include #include +#include +#include +#include +#include #include #include +#include +#include #include +#if (defined(__FreeBSD__) && __FreeBSD_version >= 300000) +#include "opt_inet.h" +#include "opt_ddb.h" +#endif /* FBSD 3.x */ + #include -struct npcblist natm_pcbs; +#if defined(INET6) && !defined(CLR_ADDR6) +#define CLR_ADDR6(a) \ + { \ + (a).s6_addr32[0] = 0; \ + (a).s6_addr32[1] = 0; \ + (a).s6_addr32[2] = 0; \ + (a).s6_addr32[3] = 0; \ + } +#endif /* * npcb_alloc: allocate a npcb [in the free state] @@ -88,13 +107,25 @@ { int s = splimp(); + if (npcb->npcb_refcnt != 0) + npcb->npcb_refcnt--; + + if (npcb->npcb_refcnt > 0) { + splx(s); + return; + } + if ((npcb->npcb_flags & NPCB_FREE) == 0) { - LIST_REMOVE(npcb, pcblist); + /* if this is an npcb for a rate limted VC, it was never added to the + * list - ugly hack. maher + */ + if (npcb->npcb_vpi != RATE_LIMIT_VPI) + LIST_REMOVE(npcb, pcblist); npcb->npcb_flags = NPCB_FREE; } if (op == NPCB_DESTROY) { if (npcb->npcb_inq) { - npcb->npcb_flags = NPCB_DRAIN; /* flag for distruction */ + npcb->npcb_flags = NPCB_DRAIN; /* flag for destruction */ } else { FREE(npcb, M_PCB); /* kill it! */ } @@ -126,8 +157,17 @@ */ for (cpcb = natm_pcbs.lh_first ; cpcb != NULL ; - cpcb = cpcb->pcblist.le_next) { - if (ifp == cpcb->npcb_ifp && vci == cpcb->npcb_vci && vpi == cpcb->npcb_vpi) + cpcb = cpcb->pcblist.le_next) { +#ifdef GROSS + printf("compare: cpcb->vci: %d, vpi: %d ipaddr: %s\n", + cpcb->npcb_vci, cpcb->npcb_vpi, inet_ntoa(cpcb->ipaddr)); +#endif + + /* We assume the vpi is 0, this is to distinguish from the + * RATE_LIMIT_VPI - maher + */ + if (ifp == cpcb->npcb_ifp && vci == cpcb->npcb_vci && + 0 == cpcb->npcb_vpi) break; } @@ -135,7 +175,36 @@ * add & something already there? */ - if (cpcb) { + /* Maher - ugly hack to add rate-limiting to already connected pvc's. + * A vpi == 1, indicates that the vc is a pvc and so a npcb should + * already exist, and make this ok. + */ + if (vpi == RATE_LIMIT_VPI) { + if (cpcb) { + +#ifdef GROSS + printf("npcb_add(): vci: %d is pvc, found a npcb.\n",vci); + printf("npcb_add(): npcb->vci: %d, addr: %s\n", + cpcb->npcb_vci, inet_ntoa(cpcb->ipaddr)); +#endif + splx(s); + npcb->npcb_ifp = ifp; + npcb->ipaddr.s_addr = cpcb->ipaddr.s_addr; + npcb->npcb_vci = vci; + npcb->npcb_vpi = RATE_LIMIT_VPI; + npcb->npcb_flags = NPCB_CONNECTED; + return(npcb); + } else { +#ifdef GROSS + printf("npcb_add(): vci: %d is pvc, did NOT find npcb.\n",vci); +#endif + cpcb = NULL; + goto done; + } + } + + + if (cpcb && (npcb && (cpcb->npcb_socket != 0))) { cpcb = NULL; goto done; /* fail */ } @@ -144,21 +213,32 @@ * need to allocate a pcb? */ - if (npcb == NULL) { - cpcb = npcb_alloc(M_NOWAIT); /* could be called from lower half */ - if (cpcb == NULL) - goto done; /* fail */ - } else { - cpcb = npcb; + if (cpcb == NULL) { + if (npcb == NULL) { + cpcb = npcb_alloc(M_NOWAIT); /* could be called from lower half */ + if (cpcb == NULL) + goto done; /* fail */ + } else { + cpcb = npcb; + } } cpcb->npcb_ifp = ifp; +#ifdef INET6 + CLR_ADDR6(cpcb->ipaddr6); +#else cpcb->ipaddr.s_addr = 0; +#endif /* INET6 */ cpcb->npcb_vci = vci; cpcb->npcb_vpi = vpi; - cpcb->npcb_flags = NPCB_CONNECTED; + cpcb->npcb_flags &= ~NPCB_FREE; + if ((cpcb->npcb_flags & NPCB_CONNECTED) == 0) { + cpcb->npcb_flags |= NPCB_CONNECTED; - LIST_INSERT_HEAD(&natm_pcbs, cpcb, pcblist); + LIST_INSERT_HEAD(&natm_pcbs, cpcb, pcblist); + /*printf("PCB Connected: VCI=%d \n",cpcb->npcb_vci);*/ + } + cpcb->npcb_refcnt++; done: splx(s); @@ -166,7 +246,6 @@ } - #ifdef DDB int npcb_dump __P((void)); @@ -179,13 +258,45 @@ printf("npcb dump:\n"); for (cpcb = natm_pcbs.lh_first ; cpcb != NULL ; cpcb = cpcb->pcblist.le_next) { +#if defined(__NetBSD__) || defined(__OpenBSD__) printf("if=%s, vci=%d, vpi=%d, IP=0x%x, sock=%p, flags=0x%x, inq=%d\n", cpcb->npcb_ifp->if_xname, cpcb->npcb_vci, cpcb->npcb_vpi, cpcb->ipaddr.s_addr, cpcb->npcb_socket, cpcb->npcb_flags, cpcb->npcb_inq); +#elif defined(__FreeBSD__) + printf("if=%s%d, vci=%d, vpi=%d, IP=0x%x, sock=%p, flags=0x%x, inq=%d\n", + cpcb->npcb_ifp->if_name, cpcb->npcb_ifp->if_unit, + cpcb->npcb_vci, cpcb->npcb_vpi, + cpcb->ipaddr.s_addr, cpcb->npcb_socket, + cpcb->npcb_flags, cpcb->npcb_inq); +#endif } printf("done\n"); return(0); } #endif + +/* + * npcb_lookup: Return the matching natmpcb. This is needed when the VC/pcb + * is explicitly created by the user (SIOCNEWVC). In such cases + * no record is kept of the created pcb anywhere else. + */ +struct natmpcb *npcb_lookup(ifp, vci, vpi) +struct ifnet *ifp; +u_int16_t vci; +u_int8_t vpi; +{ + struct natmpcb *cpcb = NULL; + int s = splimp(); + + for (cpcb = natm_pcbs.lh_first ; cpcb != NULL ; + cpcb = cpcb->pcblist.le_next) { + + if (ifp == cpcb->npcb_ifp && vci == cpcb->npcb_vci && + 0 == cpcb->npcb_vpi) + break; + } + splx(s); + return(cpcb); +} diff -urN --exclude=compile --exclude=@ ../sys-altq/netnatm/natm_proto.c ./netnatm/natm_proto.c --- ../sys-altq/netnatm/natm_proto.c Wed Jan 12 15:48:09 2000 +++ ./netnatm/natm_proto.c Tue Jun 15 06:58:08 1999 @@ -39,11 +39,15 @@ #include #include #include +#include #include #include #include +#include #include +#include +#include #include @@ -53,58 +57,67 @@ static void natm_init __P((void)); -static struct protosw natmsw[] = { -{ SOCK_STREAM, &natmdomain, PROTO_NATMAAL5, PR_CONNREQUIRED, - 0, 0, 0, 0, -#ifdef FREEBSD_USRREQS - 0, +#if defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 300000) +#undef NEW_USRREQS #else +#define NEW_USRREQS +#endif + +struct protosw natmsw[] = { +{ SOCK_STREAM, &natmdomain, PROTO_NATMAAL5, PR_CONNREQUIRED |PR_ATOMIC, + 0, 0, 0, 0, +#ifndef NEW_USRREQS natm_usrreq, +#else + 0, #endif 0, 0, 0, 0, +#ifdef NEW_USRREQS + &natm_usrreqs, +#endif #if defined(__NetBSD__) || defined(__OpenBSD__) natm5_sysctl -#elif defined(FREEBSD_USRREQS) - &natm_usrreqs #endif }, { SOCK_DGRAM, &natmdomain, PROTO_NATMAAL5, PR_CONNREQUIRED | PR_ATOMIC, 0, 0, 0, 0, -#ifdef FREEBSD_USRREQS - 0, -#else +#ifndef NEW_USRREQS natm_usrreq, +#else + 0, #endif 0, 0, 0, 0, +#ifdef NEW_USRREQS + &natm_usrreqs, +#endif #if defined(__NetBSD__) || defined(__OpenBSD__) natm5_sysctl -#elif defined(FREEBSD_USRREQS) - &natm_usrreqs #endif }, -{ SOCK_STREAM, &natmdomain, PROTO_NATMAAL0, PR_CONNREQUIRED, +{ SOCK_STREAM, &natmdomain, PROTO_NATMAAL0, PR_CONNREQUIRED | PR_ATOMIC, 0, 0, 0, 0, -#ifdef FREEBSD_USRREQS - 0, -#else +#ifndef NEW_USRREQS natm_usrreq, +#else + 0, #endif 0, 0, 0, 0, +#ifdef NEW_USRREQS + &natm_usrreqs, +#endif #if defined(__NetBSD__) || defined(__OpenBSD__) natm0_sysctl -#elif defined(FREEBSD_USRREQS) - &natm_usrreqs #endif }, }; -static struct domain natmdomain = +struct domain natmdomain = { AF_NATM, "natm", natm_init, 0, 0, natmsw, &natmsw[sizeof(natmsw)/sizeof(natmsw[0])], 0, 0, 0, 0}; struct ifqueue natmintrq; /* natm packet input queue */ -static int natmqmaxlen = IFQ_MAXLEN; /* max # of packets on queue */ +int natmqmaxlen = IFQ_MAXLEN; /* max # of packets on queue */ #ifdef NATM_STAT u_int natm_sodropcnt = 0; /* # mbufs dropped due to full sb */ u_int natm_sodropbytes = 0; /* # of bytes dropped */ diff -urN --exclude=compile --exclude=@ ../sys-altq/pci/if_en_pci.c ./pci/if_en_pci.c --- ../sys-altq/pci/if_en_pci.c Wed Jan 12 15:48:26 2000 +++ ./pci/if_en_pci.c Tue Mar 21 12:20:04 2000 @@ -48,20 +48,37 @@ #if (NEN > 0) && (NPCI > 0) #include +#include #include #include +#ifndef SHUTDOWN_PRE_SYNC +/* + * device shutdown mechanism has been changed since 2.2-ALPHA. + * if SHUTDOWN_PRE_SYNC is defined in "sys/systm.h", use new one. + * otherwise, use old one. + * new: 2.2-ALPHA, 2.2-BETA, 2.2-GAMME, 2.2-RELEASE, 3.0 + * old: 2.1.5, 2.1.6, 2.2-SNAP + * -- kjc + */ +#include +#endif +#include #include #include +#include +#include /* for rdtsc proto for clock.h below */ #include /* for DELAY */ #include +#include +#include "enp.h" /* midwayvar.h refers to NENP */ #include #include -#include -#include +#include +#include /* @@ -69,8 +86,12 @@ */ static void en_pci_attach __P((pcici_t, int)); -static const char *en_pci_probe __P((pcici_t, pcidi_t)); +static char *en_pci_probe __P((pcici_t, pcidi_t)); +#ifdef SHUTDOWN_PRE_SYNC static void en_pci_shutdown __P((int, void *)); +#else +static int en_pci_shutdown __P((struct kern_devconf *, int)); +#endif /* * local structures @@ -83,15 +104,8 @@ /* PCI bus glue */ void *sc_ih; /* interrupt handle */ pci_chipset_tag_t en_pc; /* for PCI calls */ - pcici_t en_confid; /* config id */ -}; -#if !defined(MIDWAY_ENIONLY) -static void eni_get_macaddr __P((struct en_pci_softc *)); -#endif -#if !defined(MIDWAY_ADPONLY) -static void adp_get_macaddr __P((struct en_pci_softc *)); -#endif +}; /* * pointers to softcs (we alloc) @@ -111,7 +125,11 @@ en_pci_probe, en_pci_attach, &en_pci_count, +#ifdef SHUTDOWN_PRE_SYNC NULL, +#else + en_pci_shutdown, +#endif }; DATA_SET (pcidevice_set, endevice); @@ -157,6 +175,10 @@ #define PCI_VENDOR(x) ((x) & 0xFFFF) #define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF) +#if !defined(MIDWAY_ADPONLY) +void get_eni_macaddr(struct en_pci_softc *scp, pcici_t config_id); +#endif + #if !defined(MIDWAY_ENIONLY) static void adp_busreset __P((void *)); @@ -191,7 +213,7 @@ * autoconfig stuff */ -static const char *en_pci_probe(config_id, device_id) +static char *en_pci_probe(config_id, device_id) pcici_t config_id; pcidi_t device_id; @@ -247,10 +269,9 @@ enpcis[unit] = scp; /* lock it in */ en_cd.cd_devs[unit] = sc; /* fake a cfdriver structure */ en_cd.cd_ndevs = NEN; - snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname), "en%d", unit); + sprintf(sc->sc_dev.dv_xname, "en%d", unit); sc->enif.if_unit = unit; sc->enif.if_name = "en"; - scp->en_confid = config_id; /* * figure out if we are an adaptec card or not. @@ -262,11 +283,31 @@ sc->is_adaptec = (PCI_VENDOR(device_id) == PCI_VENDOR_ADP) ? 1 : 0; /* + * Get the IEEE MAC address: We only know about Adaptec cards. + */ + if (sc->is_adaptec) { + u_int8_t lcv; + + for (lcv = 0 ; lcv < sizeof(sc->macaddr) ; lcv++) { + sc->macaddr[lcv] = bus_space_read_1(sc->en_memt, sc->en_base, + MID_ADPMACOFF + lcv); + } + } else { +#if !defined(MIDWAY_ADPONLY) + /* ENI code */ + get_eni_macaddr(scp, config_id); +#endif + } + printf(" address %6D\n", sc->macaddr, ":"); + +#ifdef SHUTDOWN_PRE_SYNC + /* * Add shutdown hook so that DMA is disabled prior to reboot. Not * doing so could allow DMA to corrupt kernel memory during the * reboot before the driver initializes. */ at_shutdown(en_pci_shutdown, scp, SHUTDOWN_POST_SYNC); +#endif if (!pci_map_int(config_id, en_intr, (void *) sc, &net_imask)) { printf("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname); @@ -280,7 +321,6 @@ #if !defined(MIDWAY_ENIONLY) if (sc->is_adaptec) { - adp_get_macaddr(scp); sc->en_busreset = adp_busreset; adp_busreset(sc); } @@ -288,7 +328,6 @@ #if !defined(MIDWAY_ADPONLY) if (!sc->is_adaptec) { - eni_get_macaddr(scp); sc->en_busreset = NULL; pci_conf_write(config_id, EN_TONGA, (TONGA_SWAP_DMA|TONGA_SWAP_WORD)); } @@ -302,6 +341,7 @@ } +#ifdef SHUTDOWN_PRE_SYNC static void en_pci_shutdown( int howto, @@ -312,27 +352,24 @@ en_reset(&psc->esc); DELAY(10); } +#else /* !SHUTDOWN_PRE_SYNC */ +static int +en_pci_shutdown(kdc, force) -#if !defined(MIDWAY_ENIONLY) +struct kern_devconf *kdc; +int force; -#if defined(sparc) || defined(__FreeBSD__) -#define bus_space_read_1(t, h, o) \ - ((void)t, (*(volatile u_int8_t *)((h) + (o)))) -#endif - -static void -adp_get_macaddr(scp) - struct en_pci_softc *scp; { - struct en_softc * sc = (struct en_softc *)scp; - int lcv; - - for (lcv = 0; lcv < sizeof(sc->macaddr); lcv++) - sc->macaddr[lcv] = bus_space_read_1(sc->en_memt, sc->en_base, - MID_ADPMACOFF + lcv); + if (kdc->kdc_unit < NEN) { + struct en_pci_softc *psc = enpcis[kdc->kdc_unit]; + if (psc) /* can it be null? */ + en_reset(&psc->esc); + DELAY(10); + } + dev_detach(kdc); + return(0); } - -#endif /* MIDWAY_ENIONLY */ +#endif /* !SHUTDOWN_PRE_SYNC */ #if !defined(MIDWAY_ADPONLY) @@ -345,16 +382,16 @@ #define EN_PROM_CLK 0x01 #define EN_ESI 64 -static void -eni_get_macaddr(scp) - struct en_pci_softc *scp; +void +get_eni_macaddr(scp, id) +struct en_pci_softc *scp; +pcici_t id; { struct en_softc * sc = (struct en_softc *)scp; - pcici_t id = scp->en_confid; int i, j, address, status; u_int32_t data, t_data; u_int8_t tmp; - + t_data = pci_conf_read(id, EN_TONGA) & 0xffffff00; data = EN_PROM_MAGIC | EN_PROM_DATA | EN_PROM_CLK; @@ -431,7 +468,5 @@ pci_conf_write(id, EN_TONGA, data); pci_conf_write(id, EN_TONGA, t_data); } - -#endif /* !MIDWAY_ADPONLY */ - +#endif /* !defined(MIDWAY_ADPONLY) */ #endif /* NEN > 0 && NPCI > 0 */ diff -urN --exclude=compile --exclude=@ ../sys-altq/pci/midway.c ./pci/midway.c --- ../sys-altq/pci/midway.c Wed Dec 31 19:00:00 1969 +++ ./pci/midway.c Thu Apr 13 12:24:50 2000 @@ -0,0 +1,4488 @@ +/* $NetBSD: midway.c,v 1.25 1997/03/20 21:34:42 chuck Exp $ */ +/* (sync'd to midway.c 1.67) */ + +/* + * + * Copyright (c) 1996 Charles D. Cranor and Washington University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Charles D. Cranor and + * Washington University. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * + * m i d w a y . c e n i 1 5 5 d r i v e r + * + * author: Chuck Cranor + * started: spring, 1996 (written from scratch). + * + * notes from the author: + * Extra special thanks go to Werner Almesberger, EPFL LRC. Werner's + * ENI driver was especially useful in figuring out how this card works. + * I would also like to thank Werner for promptly answering email and being + * generally helpful. + */ + +/* + * Added support for VC rate limiting. Code originally by Milind + * Buddhikot of Washington University, ported to this version of + * the midway driver by Maryann Maher of USC/ISI (maher@isi.edu). + * + */ + +/* + * Added BPF support. SIOCSIFFLAGS no longer returns EINVAL (so that the + * interface promisc flag may be reset). Also added support to associate every + * PVC with its own ifnet (what I call "a pseudo interface"). This is needed + * to support broad/multicast over ATM in a point-to-point connection mode + * and to run RIPv2 in gated. + * + * - Suresh Bhogavilli, USC/Information Sciences Institute (suresh@isi.edu) + */ + +/* HISTORY: 6/14/98: changed two things: */ +/* one VC assigned to one transmit slot */ +/* driver no longer gets packet from ifnet{} if_snd queue */ +/* as fast as it can, but gets packet from allows if_snd */ +/* to grow so that IP can drop packets */ +/* - Keng Lim, USC Information Sciences Institute / */ +/* CMU Information Networking Institute */ +/* 2/20/99: bug fixes for driver's confusion for empty list */ +/* when list is full. - keng@cs.cmu.edu */ +/* 3/31/99: ported to FreeBSD 3.x - suresh@isi.edu */ +/* 4/13/99: bug fix for clearing VC to i/f map when VC is deleted */ +/* 6/3/99: BPF code cleanup. Tx side pkt is shown just before DMA */ +/* 7/2/99: ALTQ v1.2 support added - suresh@isi.edu */ +/* */ + +#if defined(__FreeBSD__) && defined(ALTQ) +#include "opt_altq.h" +#endif + +#include + + +#undef EN_DEBUG +#undef EN_DEBUG_RANGE /* check ranges on en_read/en_write's? */ +#define EN_MBUF_OPT /* try and put more stuff in mbuf? */ +#if defined(DIAGNOSTIC) && !defined(EN_DIAG) +#define EN_DIAG +#endif + +#define RATE_LIM /* set VC rate limiting */ +#define EN_STAT 1 /* yes, define it */ + +#ifndef EN_DMA +#define EN_DMA 1 /* use dma? */ +#endif +#define EN_NOTXDMA 0 /* hook to disable tx dma only */ +#define EN_NORXDMA 0 /* hook to disable rx dma only */ +#define EN_NOWMAYBE 1 /* hook to disable word maybe DMA */ + /* XXX: WMAYBE doesn't work, needs debugging */ +#define EN_DDBHOOK 1 /* compile in ddb functions */ + + +#if defined(MIDWAY_ADPONLY) +#define EN_ENIDMAFIX 0 /* no ENI cards to worry about */ +#else +#define EN_ENIDMAFIX 1 /* avoid byte DMA on the ENI card (see below) */ +#endif + +/* + * note on EN_ENIDMAFIX: the byte aligner on the ENI version of the card + * appears to be broken. it works just fine if there is no load... however + * when the card is loaded the data get corrupted. to see this, one only + * has to use "telnet" over ATM. do the following command in "telnet": + * cat /usr/share/misc/termcap + * "telnet" seems to generate lots of 1023 byte mbufs (which make great + * use of the byte aligner). watch "netstat -s" for checksum errors. + * + * I further tested this by adding a function that compared the transmit + * data on the card's SRAM with the data in the mbuf chain _after_ the + * "transmit DMA complete" interrupt. using the "telnet" test I got data + * mismatches where the byte-aligned data should have been. using ddb + * and en_dumpmem() I verified that the DTQs fed into the card were + * absolutely correct. thus, we are forced to concluded that the ENI + * hardware is buggy. note that the Adaptec version of the card works + * just fine with byte DMA. + * + * bottom line: we set EN_ENIDMAFIX to 1 to avoid byte DMAs on the ENI + * card. + * kjc's fix -added 2/18/99 keng@cs.cmu.edu + */ + +#if defined(DIAGNOSTIC) && !defined(EN_DIAG) +#define EN_DIAG /* link in with master DIAG option */ +#endif +#ifdef EN_STAT +#define EN_COUNT(X) (X)++ +#else +#define EN_COUNT(X) /* nothing */ +#endif + +#ifdef EN_DEBUG +#undef EN_DDBHOOK +#define EN_DDBHOOK 1 +#define STATIC /* nothing */ +#define INLINE /* nothing */ +#else /* EN_DEBUG */ +#define STATIC static +#if __FreeBSD_version >= 300000 +#define INLINE __inline +#else +#define INLINE inline +#endif /* __FreeBSD_version */ +#endif /* EN_DEBUG */ + +#ifdef __FreeBSD__ +#include "en.h" +#include "enp.h" +#endif + +#if NEN > 0 || !defined(__FreeBSD__) + +#include +#include +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) +#include +#endif + +#if defined(__FreeBSD__) && __FreeBSD_version >= 300000 +#include +#else +#include +#endif /* FreeBSD 3.0 */ + +#include +#include +#include + +#include +#include + +#include "bpfilter.h" + +#if NBPFILTER > 0 +#include +#include +#ifdef __FreeBSD__ +#define BPFATTACH(ifp, dlt, hlen) bpfattach((ifp), (dlt), (hlen)) +#define BPF_MTAP(ifp, m) bpf_mtap((ifp), (m)) +#else +#define BPFATTACH(ifp, dlt, hlen) bpfattach(&(ifp)->if_bpf, (ifp), (dlt), (hlen)) +#define BPF_MTAP(ifp, m) bpf_mtap((ifp)->if_bpf, (m)) +#endif +#endif /* NBPFILTER > 0 */ + +#include + +#if defined(__FreeBSD__) && __FreeBSD_version >= 300000 +#include "opt_inet.h" +#include "opt_natm.h" +#include "opt_ddb.h" +#endif /* FBSD 3.x */ + +#if defined(INET) || defined(INET6) +#include +#include /* KAME needs it for SIOCSIFADDR_IN6 */ +#include +#endif + +#if defined(__KAME__) && defined(INET6) +#include /* For in6_ifattach() & IN6_IFT_802 */ +#endif + +#ifdef NATM +#include +#endif + +#ifdef ALTQ +# ifdef __KAME__ +# include +# else +# include +# endif +#ifdef AFMAP +#include +#endif +#endif + +#if !defined(sparc) && !defined(__FreeBSD__) +#include +#endif + +#include + +#if defined(__NetBSD__) || defined(__OpenBSD__) +#include +#include +#if defined(__alpha__) +/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */ +#undef vtophys +#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) +#endif +#elif defined(__FreeBSD__) +#include /* for rdtsc proto for clock.h below */ +#include /* for DELAY */ +#include +#include +#include /* for vtophys proto */ +#include + +#if (__FreeBSD_version >= 300000) +#define FOREACHIFP(ifp) \ + for ((ifp) = ifnet.tqh_first; (ifp); (ifp) = (ifp)->if_link.tqe_next) +#else +#define FOREACHIFP(ifp) \ + for ((ifp) = ifnet; (ifp); (ifp) = (ifp)->if_next) +#endif /* FBSD 3.x */ + +#define IFF_NOTRAILERS 0 + +#endif /* __FreeBSD__ */ + +/* + * params + */ + +#ifdef RATE_LIM +#define MAX_LINE_RATE 352400 /* Line rate */ +#endif + +#ifndef EN_TXHIWAT +#define EN_TXHIWAT (20*1024) /* max 20 KB waiting to be DMAd out */ +#endif + +#ifndef EN_MINDMA +#define EN_MINDMA 32 /* don't DMA anything less than this (bytes) */ +#endif + +#define RX_NONE 0xffff /* recv VC not in use */ + +#define EN_OBHDR ATM_PH_DRIVER7 /* TBD in first mbuf ! */ +#define EN_OBTRL ATM_PH_DRIVER8 /* PDU trailier in last mbuf ! */ + +#define ENOTHER_FREE 0x01 /* free rxslot */ +#define ENOTHER_DRAIN 0x02 /* almost free (drain DRQ dma) */ +#define ENOTHER_RAW 0x04 /* 'raw' access (aka boodi mode) */ +#define ENOTHER_SWSL 0x08 /* in software service list */ + +int en_dma = EN_DMA; /* use DMA (switch off for dbg) */ +static char *en_pif_name[4] = { +"enp", "enq", "enr", "ens" +}; + +/* + * autoconfig attachments + */ + +struct cfdriver en_cd = { + 0, "en", DV_IFNET, +}; + +/* + * local structures + */ + +/* + * params to en_txlaunch() function + */ + +struct en_launch { + u_int32_t tbd1; /* TBD 1 */ + u_int32_t tbd2; /* TBD 2 */ + u_int32_t pdu1; /* PDU 1 (aal5) */ + int nodma; /* don't use DMA */ + int need; /* total space we need (pad out if less data) */ + int mlen; /* length of mbuf (for dtq) */ + struct mbuf *t; /* data */ + u_int32_t aal; /* aal code */ + u_int32_t atm_vci; /* vci */ + u_int8_t atm_flags; /* flags */ +}; + +#ifdef RATE_LIM +/* For en_cps2enispec() and viceversa (milind-maher) */ +static u_int32_t PR[4] = {4,16,128,2048}; /* Prescaler (pg.45-ENImanual)*/ +#endif + + +/* + * dma table (index by # of words) + * + * plan A: use WMAYBE + * plan B: avoid WMAYBE + */ + +struct en_dmatab { + u_int8_t bcode; /* code */ + u_int8_t divshift; /* byte divisor */ +}; + +static struct en_dmatab en_dma_planA[] = { + { 0, 0 }, /* 0 */ { MIDDMA_WORD, 2 }, /* 1 */ + { MIDDMA_2WORD, 3}, /* 2 */ { MIDDMA_4WMAYBE, 2}, /* 3 */ + { MIDDMA_4WORD, 4}, /* 4 */ { MIDDMA_8WMAYBE, 2}, /* 5 */ + { MIDDMA_8WMAYBE, 2}, /* 6 */ { MIDDMA_8WMAYBE, 2}, /* 7 */ + { MIDDMA_8WORD, 5}, /* 8 */ { MIDDMA_16WMAYBE, 2}, /* 9 */ + { MIDDMA_16WMAYBE,2}, /* 10 */ { MIDDMA_16WMAYBE, 2}, /* 11 */ + { MIDDMA_16WMAYBE,2}, /* 12 */ { MIDDMA_16WMAYBE, 2}, /* 13 */ + { MIDDMA_16WMAYBE,2}, /* 14 */ { MIDDMA_16WMAYBE, 2}, /* 15 */ + { MIDDMA_16WORD, 6}, /* 16 */ +}; + +static struct en_dmatab en_dma_planB[] = { + { 0, 0 }, /* 0 */ { MIDDMA_WORD, 2}, /* 1 */ + { MIDDMA_2WORD, 3}, /* 2 */ { MIDDMA_WORD, 2}, /* 3 */ + { MIDDMA_4WORD, 4}, /* 4 */ { MIDDMA_WORD, 2}, /* 5 */ + { MIDDMA_2WORD, 3}, /* 6 */ { MIDDMA_WORD, 2}, /* 7 */ + { MIDDMA_8WORD, 5}, /* 8 */ { MIDDMA_WORD, 2}, /* 9 */ + { MIDDMA_2WORD, 3}, /* 10 */ { MIDDMA_WORD, 2}, /* 11 */ + { MIDDMA_4WORD, 4}, /* 12 */ { MIDDMA_WORD, 2}, /* 13 */ + { MIDDMA_2WORD, 3}, /* 14 */ { MIDDMA_WORD, 2}, /* 15 */ + { MIDDMA_16WORD, 6}, /* 16 */ +}; + +static struct en_dmatab *en_dmaplan = en_dma_planB; + +/* + * prototypes + */ + +STATIC INLINE int en_b2sz __P((int)); + +/* int en_dump __P((int,int)); */ +int en_dump __P((struct ifnet*,struct atm_stat*)); + +int en_find_if_index __P((struct ifnet*)); + +int en_dumpmem __P((int,int,int)); + +STATIC void en_dmaprobe __P((struct en_softc *)); +STATIC int en_dmaprobe_doit __P((struct en_softc *, u_int8_t *, + u_int8_t *, int)); +STATIC int en_dqneed __P((struct en_softc *, caddr_t, u_int, u_int)); +STATIC void en_init __P((struct en_softc *)); +STATIC int en_ioctl __P((struct ifnet *, EN_IOCTL_CMDT, caddr_t)); +#ifdef RATE_LIM +u_int8_t en_cps2enispec __P((trfdesc *)); +int en_enispec2cps __P((u_int8_t)); +#endif +STATIC int en_k2sz __P((int)); +STATIC void en_loadvc __P((struct en_softc *, int)); +STATIC int en_mfix __P((struct en_softc *, struct mbuf **, struct mbuf *)); +STATIC struct mbuf *en_mget __P((struct en_softc *, u_int, u_int *)); +STATIC u_int32_t en_read __P((struct en_softc *, u_int32_t)); +STATIC int en_rxctl __P((struct en_softc *, struct atm_pseudoioctl *, int)); +STATIC void en_txdma __P((struct en_softc *, int)); +STATIC void en_txlaunch __P((struct en_softc *, int, struct en_launch *)); +STATIC void en_service __P((struct en_softc *)); +STATIC void en_start __P((struct ifnet *)); +STATIC INLINE int en_sz2b __P((int)); +STATIC INLINE void en_write __P((struct en_softc *, u_int32_t, u_int32_t)); +STATIC int en_atmconf __P((struct en_softc *, caddr_t)); + +#if defined(ALTQ) && defined(AFMAP) +static int en_flowmap_add __P((struct en_softc *, struct atm_flowmap *)); +static int en_flowmap_delete __P((struct en_softc *, int, int)); +static int en_flowmap_get __P((struct en_softc *, struct atm_flowmap *)); +#endif + +/* + * macros/inline + */ + +/* + * raw read/write macros + */ + +#define EN_READDAT(SC,R) en_read(SC,R) +#define EN_WRITEDAT(SC,R,V) en_write(SC,R,V) + +/* + * cooked read/write macros + */ + +#define EN_READ(SC,R) ntohl(en_read(SC,R)) +#define EN_WRITE(SC,R,V) en_write(SC,R, htonl(V)) + +#define EN_WRAPADD(START,STOP,CUR,VAL) { \ + (CUR) = (CUR) + (VAL); \ + if ((CUR) >= (STOP)) \ + (CUR) = (START) + ((CUR) - (STOP)); \ + } + +#define WORD_IDX(START, X) (((X) - (START)) / sizeof(u_int32_t)) + +/* we store sc->dtq and sc->drq data in the following format... */ +#define EN_DQ_MK(SLOT,LEN) (((SLOT) << 20)|(LEN)|(0x80000)) + /* the 0x80000 ensures we != 0 */ +#define EN_DQ_SLOT(X) ((X) >> 20) +#define EN_DQ_LEN(X) ((X) & 0x3ffff) + +/* format of DTQ/DRQ word 1 differs between ENI and ADP */ +#if defined(MIDWAY_ENIONLY) + +#define MID_MK_TXQ(SC,CNT,CHAN,END,BCODE) \ + EN_WRITE((SC), (SC)->dtq_us, \ + MID_MK_TXQ_ENI((CNT), (CHAN), (END), (BCODE))); + +#define MID_MK_RXQ(SC,CNT,VCI,END,BCODE) \ + EN_WRITE((SC), (SC)->drq_us, \ + MID_MK_RXQ_ENI((CNT), (VCI), (END), (BCODE))); + +#elif defined(MIDWAY_ADPONLY) + +#define MID_MK_TXQ(SC,CNT,CHAN,END,JK) \ + EN_WRITE((SC), (SC)->dtq_us, \ + MID_MK_TXQ_ADP((CNT), (CHAN), (END), (JK))); + +#define MID_MK_RXQ(SC,CNT,VCI,END,JK) \ + EN_WRITE((SC), (SC)->drq_us, \ + MID_MK_RXQ_ADP((CNT), (VCI), (END), (JK))); + +#else + +#define MID_MK_TXQ(SC,CNT,CHAN,END,JK_OR_BCODE) { \ + if ((SC)->is_adaptec) \ + EN_WRITE((SC), (SC)->dtq_us, \ + MID_MK_TXQ_ADP((CNT), (CHAN), (END), (JK_OR_BCODE))); \ + else \ + EN_WRITE((SC), (SC)->dtq_us, \ + MID_MK_TXQ_ENI((CNT), (CHAN), (END), (JK_OR_BCODE))); \ + } + +#define MID_MK_RXQ(SC,CNT,VCI,END,JK_OR_BCODE) { \ + if ((SC)->is_adaptec) \ + EN_WRITE((SC), (SC)->drq_us, \ + MID_MK_RXQ_ADP((CNT), (VCI), (END), (JK_OR_BCODE))); \ + else \ + EN_WRITE((SC), (SC)->drq_us, \ + MID_MK_RXQ_ENI((CNT), (VCI), (END), (JK_OR_BCODE))); \ + } + +#endif + +/* add an item to the DTQ */ +#define EN_DTQADD(SC,CNT,CHAN,JK_OR_BCODE,ADDR,LEN,END) { \ + if (END) \ + (SC)->dtq[MID_DTQ_A2REG((SC)->dtq_us)] = EN_DQ_MK(CHAN,LEN); \ + MID_MK_TXQ(SC,CNT,CHAN,END,JK_OR_BCODE); \ + (SC)->dtq_us += 4; \ + EN_WRITE((SC), (SC)->dtq_us, (ADDR)); \ + EN_WRAPADD(MID_DTQOFF, MID_DTQEND, (SC)->dtq_us, 4); \ + (SC)->dtq_free--; \ + if (END) \ + EN_WRITE((SC), MID_DMA_WRTX, MID_DTQ_A2REG((SC)->dtq_us)); \ +} + +/* DRQ add macro */ +#define EN_DRQADD(SC,CNT,VCI,JK_OR_BCODE,ADDR,LEN,SLOT,END) { \ + if (END) \ + (SC)->drq[MID_DRQ_A2REG((SC)->drq_us)] = EN_DQ_MK(SLOT,LEN); \ + MID_MK_RXQ(SC,CNT,VCI,END,JK_OR_BCODE); \ + (SC)->drq_us += 4; \ + EN_WRITE((SC), (SC)->drq_us, (ADDR)); \ + EN_WRAPADD(MID_DRQOFF, MID_DRQEND, (SC)->drq_us, 4); \ + (SC)->drq_free--; \ + if (END) \ + EN_WRITE((SC), MID_DMA_WRRX, MID_DRQ_A2REG((SC)->drq_us)); \ +} + +/* + * the driver code + * + * the code is arranged in a specific way: + * [1] short/inline functions + * [2] autoconfig stuff + * [3] ioctl stuff + * [4] reset -> init -> trasmit -> intr -> receive functions + * + */ + +/***********************************************************************/ + +/* + * en_read: read a word from the card. this is the only function + * that reads from the card. + */ + +STATIC INLINE u_int32_t en_read(sc, r) + +struct en_softc *sc; +u_int32_t r; + +{ + +#ifdef EN_DEBUG_RANGE + if (r > MID_MAXOFF || (r % 4)) + panic("en_read out of range, r=0x%x\n", r); +#endif + + return(bus_space_read_4(sc->en_memt, sc->en_base, r)); +} + +/* + * en_write: write a word to the card. this is the only function that + * writes to the card. + */ + +STATIC INLINE void en_write(sc, r, v) + +struct en_softc *sc; +u_int32_t r, v; + +{ +#ifdef EN_DEBUG_RANGE + if (r > MID_MAXOFF || (r % 4)) + panic("en_write out of range, r=0x%x\n", r); +#endif + + bus_space_write_4(sc->en_memt, sc->en_base, r, v); +} + +/* + * en_k2sz: convert KBytes to a size parameter (a log2) + */ + +STATIC INLINE int en_k2sz(k) + +int k; + +{ + switch(k) { + case 1: return(0); + case 2: return(1); + case 4: return(2); + case 8: return(3); + case 16: return(4); + case 32: return(5); + case 64: return(6); + case 128: return(7); + default: panic("en_k2sz"); + } + return(0); +} +#define en_log2(X) en_k2sz(X) + + +/* + * en_b2sz: convert a DMA burst code to its byte size + */ + +STATIC INLINE int en_b2sz(b) + +int b; + +{ + switch (b) { + case MIDDMA_WORD: return(1*4); + case MIDDMA_2WMAYBE: + case MIDDMA_2WORD: return(2*4); + case MIDDMA_4WMAYBE: + case MIDDMA_4WORD: return(4*4); + case MIDDMA_8WMAYBE: + case MIDDMA_8WORD: return(8*4); + case MIDDMA_16WMAYBE: + case MIDDMA_16WORD: return(16*4); + default: panic("en_b2sz"); + } + return(0); +} + + +/* + * en_sz2b: convert a burst size (bytes) to DMA burst code + */ + +STATIC INLINE int en_sz2b(sz) + +int sz; + +{ + switch (sz) { + case 1*4: return(MIDDMA_WORD); + case 2*4: return(MIDDMA_2WORD); + case 4*4: return(MIDDMA_4WORD); + case 8*4: return(MIDDMA_8WORD); + case 16*4: return(MIDDMA_16WORD); + default: panic("en_sz2b"); + } + return(0); +} + + +/* + * en_dqneed: calculate number of DTQ/DRQ's needed for a buffer + */ + +STATIC INLINE int en_dqneed(sc, data, len, tx) + +struct en_softc *sc; +caddr_t data; +u_int len, tx; + +{ + int result, needalign, sz; + +#if !defined(MIDWAY_ENIONLY) +#if !defined(MIDWAY_ADPONLY) + if (sc->is_adaptec) +#endif /* !MIDWAY_ADPONLY */ + return(1); /* adaptec can DMA anything in one go */ +#endif + +#if !defined(MIDWAY_ADPONLY) + result = 0; + if (len < EN_MINDMA) { + if (!tx) /* XXX: conservative */ + return(1); /* will copy/DMA_JK */ + } + + if (tx) { /* byte burst? */ + needalign = (((unsigned long) data) % sizeof(u_int32_t)); + if (needalign) { + result++; + sz = min(len, sizeof(u_int32_t) - needalign); + len -= sz; + data += sz; + } + } + + if (sc->alburst && len) { + needalign = (((unsigned long) data) & sc->bestburstmask); + if (needalign) { + result++; /* alburst */ + sz = min(len, sc->bestburstlen - needalign); + len -= sz; + } + } + + if (len >= sc->bestburstlen) { + sz = len / sc->bestburstlen; + sz = sz * sc->bestburstlen; + len -= sz; + result++; /* best shot */ + } + + if (len) { + result++; /* clean up */ + if (tx && (len % sizeof(u_int32_t)) != 0) + result++; /* byte cleanup */ + } + + return(result); +#endif /* !MIDWAY_ADPONLY */ +} + + +/* + * en_mget: get an mbuf chain that can hold totlen bytes and return it + * (for recv) [based on am7990_get from if_le and ieget from if_ie] + * after this call the sum of all the m_len's in the chain will be totlen. + */ + +STATIC INLINE struct mbuf *en_mget(sc, totlen, drqneed) + +struct en_softc *sc; +u_int totlen, *drqneed; + +{ + struct mbuf *m; + struct mbuf *top, **mp; + *drqneed = 0; + + MGETHDR(m, M_DONTWAIT, MT_DATA); + if (m == NULL) + return(NULL); + m->m_pkthdr.rcvif = &sc->enif; + m->m_pkthdr.len = totlen; + m->m_len = MHLEN; + top = NULL; + mp = ⊤ + + /* if (top != NULL) then we've already got 1 mbuf on the chain */ + while (totlen > 0) { + if (top) { + MGET(m, M_DONTWAIT, MT_DATA); + if (!m) { + m_freem(top); + return(NULL); /* out of mbufs */ + } + m->m_len = MLEN; + } + if (top && totlen >= MINCLSIZE) { + MCLGET(m, M_DONTWAIT); + if (m->m_flags & M_EXT) + m->m_len = MCLBYTES; + else { + m_free(m); + m_freem(top); + return(NULL); /* out of mbuf clusters */ + } + } + m->m_len = min(totlen, m->m_len); + totlen -= m->m_len; + *mp = m; + mp = &m->m_next; + + *drqneed += en_dqneed(sc, m->m_data, m->m_len, 0); + + } + return(top); +} + +/***********************************************************************/ + +/* + * autoconfig stuff + */ + +void en_attach(sc) + +struct en_softc *sc; + +{ + struct ifnet *ifp = &sc->enif; + int sz; + u_int32_t reg, lcv, check, ptr, sav, midvloc; + +#if defined(NENP) && NENP > 0 + struct ifnet *ifpp = 0; + int i; +#endif + + /* + * probe card to determine memory size. the stupid ENI card always + * reports to PCI that it needs 4MB of space (2MB regs and 2MB RAM). + * if it has less than 2MB RAM the addresses wrap in the RAM address space. + * (i.e. on a 512KB card addresses 0x3ffffc, 0x37fffc, and 0x2ffffc + * are aliases for 0x27fffc [note that RAM starts at offset 0x200000]). + */ + + if (sc->en_busreset) + sc->en_busreset(sc); + EN_WRITE(sc, MID_RESID, 0x0); /* reset card before touching RAM */ + for (lcv = MID_PROBEOFF; lcv <= MID_MAXOFF ; lcv += MID_PROBSIZE) { + EN_WRITE(sc, lcv, lcv); /* data[address] = address */ + for (check = MID_PROBEOFF ; check < lcv ; check += MID_PROBSIZE) { + reg = EN_READ(sc, check); + if (reg != check) { /* found an alias! */ + goto done_probe; /* and quit */ + } + } + } +done_probe: + lcv -= MID_PROBSIZE; /* take one step back */ + sc->en_obmemsz = (lcv + 4) - MID_RAMOFF; + + /* + * determine the largest DMA burst supported + */ + + en_dmaprobe(sc); + + /* + * "hello world" + */ + + if (sc->en_busreset) + sc->en_busreset(sc); + EN_WRITE(sc, MID_RESID, 0x0); /* reset */ + for (lcv = MID_RAMOFF ; lcv < MID_RAMOFF + sc->en_obmemsz ; lcv += 4) + EN_WRITE(sc, lcv, 0); /* zero memory */ + + reg = EN_READ(sc, MID_RESID); + + printf("%s: ATM midway v%d, board IDs %d.%d, %s%s%s, %dKB on-board RAM\n", + sc->sc_dev.dv_xname, MID_VER(reg), MID_MID(reg), MID_DID(reg), + (MID_IS_SABRE(reg)) ? "sabre controller, " : "", + (MID_IS_SUNI(reg)) ? "SUNI" : "Utopia", + (!MID_IS_SUNI(reg) && MID_IS_UPIPE(reg)) ? " (pipelined)" : "", + (u_int32_t) sc->en_obmemsz / 1024); + + if (sc->is_adaptec) { + if (sc->bestburstlen == 64 && sc->alburst == 0) + printf("%s: passed 64 byte DMA test\n", sc->sc_dev.dv_xname); + else + printf("%s: FAILED DMA TEST: burst=%d, alburst=%d\n", + sc->sc_dev.dv_xname, sc->bestburstlen, sc->alburst); + } else { + printf("%s: maximum DMA burst length = %d bytes%s\n", sc->sc_dev.dv_xname, + sc->bestburstlen, (sc->alburst) ? " (must align)" : ""); + } + +#if 0 /* WMAYBE doesn't work, don't complain about it */ + /* check if en_dmaprobe disabled wmaybe */ + if (en_dmaplan == en_dma_planB) + printf("%s: note: WMAYBE DMA has been disabled\n", sc->sc_dev.dv_xname); +#endif + + /* + * link into network subsystem and prepare card + */ + +#if defined(__NetBSD__) || defined(__OpenBSD__) + bcopy(sc->sc_dev.dv_xname, sc->enif.if_xname, IFNAMSIZ); +#endif + sc->enif.if_softc = sc; + ifp->if_flags = IFF_SIMPLEX|IFF_NOTRAILERS|IFF_BROADCAST|IFF_MULTICAST; + ifp->if_ioctl = en_ioctl; + ifp->if_output = atm_output; + ifp->if_start = en_start; +#ifdef ALTQ + ifp->if_altqflags |= ALTQF_READY; +#endif /* ALTQ */ + + /* + * init softc + */ + +#ifdef RATE_LIM +#ifdef NAIVE_ROUNROBIN + sc->txchan = 0; +#else + for (lcv=0; lcvtxchan[lcv] = 0; /* No vcs assigned to start with!*/ + } +#endif +#endif + + for (lcv = 0 ; lcv < MID_N_VC ; lcv++) { + sc->rxvc2slot[lcv] = RX_NONE; + sc->txspeed[lcv] = 0; /* full */ + sc->txvc2slot[lcv] = 0; /* full speed == slot 0 */ + } + + sz = sc->en_obmemsz - (MID_BUFOFF - MID_RAMOFF); + ptr = sav = MID_BUFOFF; + ptr = roundup(ptr, EN_TXSZ * 1024); /* align */ + sz = sz - (ptr - sav); + if (EN_TXSZ*1024 * EN_NTX > sz) { + printf("%s: EN_NTX/EN_TXSZ too big\n", sc->sc_dev.dv_xname); + return; + } + for (lcv = 0 ; lcv < EN_NTX ; lcv++) { + sc->txslot[lcv].txbuf2small = 0; + sc->txslot[lcv].txmbovr = 0; + sc->txslot[lcv].vci_assgn = -1; + sc->txslot[lcv].mbsize = 0; + + sc->txslot[lcv].start = ptr; + ptr += (EN_TXSZ * 1024); + sz -= (EN_TXSZ * 1024); + sc->txslot[lcv].stop = ptr; + sc->txslot[lcv].nref = 0; + bzero(&sc->txslot[lcv].indma, sizeof(sc->txslot[lcv].indma)); + bzero(&sc->txslot[lcv].q, sizeof(sc->txslot[lcv].q)); +#ifdef EN_DEBUG + printf("%s: tx%d: start 0x%x, stop 0x%x\n", sc->sc_dev.dv_xname, lcv, + sc->txslot[lcv].start, sc->txslot[lcv].stop); +#endif + } + + sav = ptr; + ptr = roundup(ptr, EN_RXSZ * 1024); /* align */ + sz = sz - (ptr - sav); + sc->en_nrx = sz / (EN_RXSZ * 1024); + if (sc->en_nrx <= 0) { + printf("%s: EN_NTX/EN_TXSZ/EN_RXSZ too big\n", sc->sc_dev.dv_xname); + return; + } + + /* + * ensure that there is always one VC slot on the service list free + * so that we can tell the difference between a full and empty list. + * kjc's fix - added 2/18/99 keng@cs.cmu.edu + */ + if (sc->en_nrx >= MID_N_VC) + sc->en_nrx = MID_N_VC - 1; + + for (lcv = 0 ; lcv < sc->en_nrx ; lcv++) { + sc->rxslot[lcv].rxhand = NULL; + sc->rxslot[lcv].oth_flags = ENOTHER_FREE; + bzero(&sc->rxslot[lcv].indma, sizeof(sc->rxslot[lcv].indma)); + bzero(&sc->rxslot[lcv].q, sizeof(sc->rxslot[lcv].q)); + midvloc = sc->rxslot[lcv].start = ptr; + ptr += (EN_RXSZ * 1024); + sz -= (EN_RXSZ * 1024); + sc->rxslot[lcv].stop = ptr; + midvloc = midvloc - MID_RAMOFF; + midvloc = (midvloc & ~((EN_RXSZ*1024) - 1)) >> 2; /* mask, cvt to words */ + midvloc = midvloc >> MIDV_LOCTOPSHFT; /* we only want the top 11 bits */ + midvloc = (midvloc & MIDV_LOCMASK) << MIDV_LOCSHIFT; + sc->rxslot[lcv].mode = midvloc | + (en_k2sz(EN_RXSZ) << MIDV_SZSHIFT) | MIDV_TRASH; + +#ifdef EN_DEBUG + printf("%s: rx%d: start 0x%x, stop 0x%x, mode 0x%x\n", sc->sc_dev.dv_xname, + lcv, sc->rxslot[lcv].start, sc->rxslot[lcv].stop, sc->rxslot[lcv].mode); +#endif + } + +#ifdef EN_STAT + + sc->vtrash = sc->otrash = sc->mfix = sc->txmbovr = sc->dmaovr = 0; + sc->txoutspace = sc->txdtqout = sc->launch = sc->lheader = sc->ltail = 0; + sc->hwpull = sc->swadd = sc->rxqnotus = sc->rxqus = sc->rxoutboth = 0; + sc->rxdrqout = sc->ttrash = sc->rxmbufout = sc->mfixfail = 0; + sc->headbyte = sc->tailbyte = sc->tailflush = 0; +#endif + sc->need_drqs = sc->need_dtqs = 0; + + printf("%s: %d %dKB receive buffers, %d %dKB transmit buffers allocated\n", + sc->sc_dev.dv_xname, sc->en_nrx, EN_RXSZ, EN_NTX, EN_TXSZ); + +#if NBPFILTER > 0 + BPFATTACH(ifp, DLT_ATM_RFC1483, sizeof(struct atmllc)); +#endif + +#ifdef RATE_LIM + /* Init avl_bw to MAX */ + sc->avl_bw = EN_MAX_LINE_RATE; +#endif + + /* + * final commit + */ + + if_attach(ifp); + atm_ifattach(ifp); + + /* + * Allocate a flow map: done for the master interface only. XXX skb + */ +#if defined(ALTQ) && defined(AFMAP) + afm_alloc(ifp); +#endif + + /* + * If we have any pseudo atm interfaces, configure them now + */ +#if defined(NENP) && NENP > 0 + for (i=0; i < NENP; ++i) { + ifpp = (struct ifnet *) malloc(sizeof(*ifpp), M_DEVBUF, + M_NOWAIT); + if (ifpp == NULL) + return; + bzero(ifpp, sizeof(*ifpp)); /* zero */ + + /* + * Initialize the new ifnet structure + */ + ifpp->if_softc = ifp->if_softc; + ifpp->if_name = en_pif_name[sc->enif.if_unit]; + ifpp->if_unit = i; + ifpp->if_flags = IFF_SIMPLEX|IFF_NOTRAILERS|IFF_BROADCAST|IFF_MULTICAST; +#ifdef ALTQ + ifpp->if_altqflags |= ALTQF_READY; +#endif + ifpp->if_ioctl = en_ioctl; + ifpp->if_output = atm_output; + ifpp->if_start = en_start; + +#if NBPFILTER > 0 + BPFATTACH(ifpp, DLT_ATM_RFC1483, sizeof(struct atmllc)); +#endif + if_attach(ifpp); + atm_ifattach(ifpp); +#if defined(__KAME__) && defined(INET6) + /* + * KAME stack is running ND as soon as this fn is called. + * This causes the machine to panic as it is not all the way up. + * in6_ifattach is now done when the interface is config'ed up. + */ + /* in6_ifattach(ifpp, IN6_IFT_802, sc->macaddr, 0); */ +#endif + } +#endif +} + + +/* + * en_dmaprobe: helper function for en_attach. + * + * see how the card handles DMA by running a few DMA tests. we need + * to figure out the largest number of bytes we can DMA in one burst + * ("bestburstlen"), and if the starting address for a burst needs to + * be aligned on any sort of boundary or not ("alburst"). + * + * typical findings: + * sparc1: bestburstlen=4, alburst=0 (ick, broken DMA!) + * sparc2: bestburstlen=64, alburst=1 + * p166: bestburstlen=64, alburst=0 + * + * Added updates from ALTQ driver by Kenjiro Cho. + */ + +#if 1 /* __FreeBSD__ */ +#define NBURSTS 3 /* number of bursts to use for dmaprobe */ +#define BOUNDARY 1024 /* test misaligned dma crossing the bounday. + should be n * 64. at least 64*(NBURSTS+1). + dell P6 w/ EDO DRAM has 1K bounday problem */ +#endif + +STATIC void en_dmaprobe(sc) + +struct en_softc *sc; + +{ +#ifdef NBURSTS + /* be careful. kernel stack is only 8K */ + u_int8_t buffer[BOUNDARY * 2 + 64 * (NBURSTS + 1)]; +#else + u_int32_t srcbuf[64], dstbuf[64]; +#endif + u_int8_t *sp, *dp; + int bestalgn, bestnotalgn, lcv, try, fail; + + sc->alburst = 0; + +#ifdef NBURSTS + /* setup src and dst buf at the end of the boundary */ + sp = (u_int8_t *)roundup((unsigned long)buffer, 64); + while (((unsigned long)sp & (BOUNDARY - 1)) != (BOUNDARY - 64)) + sp += 64; + dp = sp + BOUNDARY; + + /* + * we can't dma across page boundary so that, if buf is at a page + * boundary, move it to the next page. but still either src or dst + * will be at the boundary, which should be ok. + */ + if ((((unsigned long)sp + 64) & PAGE_MASK) == 0) + sp += 64; + if ((((unsigned long)dp + 64) & PAGE_MASK) == 0) + dp += 64; +#else /* !NBURSTS */ + sp = (u_int8_t *) srcbuf; + while ((((unsigned long) sp) % MIDDMA_MAXBURST) != 0) + sp += 4; + dp = (u_int8_t *) dstbuf; + while ((((unsigned long) dp) % MIDDMA_MAXBURST) != 0) + dp += 4; +#endif /* !NBURSTS */ + + bestalgn = bestnotalgn = en_dmaprobe_doit(sc, sp, dp, 0); + + for (lcv = 4 ; lcv < MIDDMA_MAXBURST ; lcv += 4) { + try = en_dmaprobe_doit(sc, sp+lcv, dp+lcv, 0); +#ifdef NBURSTS + if (try < bestnotalgn) { + bestnotalgn = try; + break; + } +#else + if (try < bestnotalgn) + bestnotalgn = try; +#endif + } + + if (bestalgn != bestnotalgn) /* need bursts aligned */ + sc->alburst = 1; + + sc->bestburstlen = bestalgn; + sc->bestburstshift = en_log2(bestalgn); + sc->bestburstmask = sc->bestburstlen - 1; /* must be power of 2 */ + sc->bestburstcode = en_sz2b(bestalgn); + +#if 1 /* __FreeBSD__ */ + /* + * correct pci chipsets should be able to handle misaligned-64-byte DMA. + * but there are too many broken chipsets around. we try to work around + * by finding the best workable dma size, but still some broken machines + * exhibit the problem later. so warn it here. + */ + if (bestalgn != 64 || sc->alburst != 0) { + printf("%s: WARNING: DMA test detects a broken PCI chipset!\n", + sc->sc_dev.dv_xname); + printf(" trying to work around the problem... but if this doesn't\n"); + printf(" work for you, you'd better switch to a newer motherboard.\n"); + return; + } +#endif /* 1 */ + + if (sc->bestburstlen <= 2*sizeof(u_int32_t)) + return; /* won't be using WMAYBE */ + + /* + * adaptec does not have (or need) wmaybe. do not bother testing + * for it. + */ + if (sc->is_adaptec) { + /* XXX, actually don't need a DMA plan: adaptec is smarter than that */ + en_dmaplan = en_dma_planB; + return; + } + + /* + * test that WMAYBE dma works like we think it should + * (i.e. no alignment restrictions on host address other than alburst) + */ + + try = sc->bestburstlen - 4; + fail = 0; + fail += en_dmaprobe_doit(sc, sp, dp, try); + for (lcv = 4 ; lcv < sc->bestburstlen ; lcv += 4) { + fail += en_dmaprobe_doit(sc, sp+lcv, dp+lcv, try); + if (sc->alburst) + try -= 4; + } + if (EN_NOWMAYBE || fail) { + if (fail) + printf("%s: WARNING: WMAYBE DMA test failed %d time(s)\n", + sc->sc_dev.dv_xname, fail); + en_dmaplan = en_dma_planB; /* fall back to plan B */ + } + +} + + +/* + * en_dmaprobe_doit: do actual testing + */ + +int +en_dmaprobe_doit(sc, sp, dp, wmtry) + +struct en_softc *sc; +u_int8_t *sp, *dp; +int wmtry; + +{ + int lcv, retval = 4, cnt, count; + u_int32_t reg, bcode, midvloc; + + /* + * set up a 1k buffer at MID_BUFOFF + */ + + if (sc->en_busreset) + sc->en_busreset(sc); + EN_WRITE(sc, MID_RESID, 0x0); /* reset card before touching RAM */ + + midvloc = ((MID_BUFOFF - MID_RAMOFF) / sizeof(u_int32_t)) >> MIDV_LOCTOPSHFT; + EN_WRITE(sc, MIDX_PLACE(0), MIDX_MKPLACE(en_k2sz(1), midvloc)); + EN_WRITE(sc, MID_VC(0), (midvloc << MIDV_LOCSHIFT) + | (en_k2sz(1) << MIDV_SZSHIFT) | MIDV_TRASH); + EN_WRITE(sc, MID_DST_RP(0), 0); + EN_WRITE(sc, MID_WP_ST_CNT(0), 0); + +#ifdef NBURSTS + for (lcv = 0 ; lcv < 64*NBURSTS; lcv++) /* set up sample data */ +#else + for (lcv = 0 ; lcv < 68 ; lcv++) /* set up sample data */ +#endif + sp[lcv] = lcv+1; + EN_WRITE(sc, MID_MAST_CSR, MID_MCSR_ENDMA); /* enable DMA (only) */ + + sc->drq_chip = MID_DRQ_REG2A(EN_READ(sc, MID_DMA_RDRX)); + sc->dtq_chip = MID_DTQ_REG2A(EN_READ(sc, MID_DMA_RDTX)); + + /* + * try it now . . . DMA it out, then DMA it back in and compare + * + * note: in order to get the dma stuff to reverse directions it wants + * the "end" flag set! since we are not dma'ing valid data we may + * get an ident mismatch interrupt (which we will ignore). + * + * note: we've got two different tests rolled up in the same loop + * if (wmtry) + * then we are doing a wmaybe test and wmtry is a byte count + * else we are doing a burst test + */ + + for (lcv = 8 ; lcv <= MIDDMA_MAXBURST ; lcv = lcv * 2) { + + /* zero SRAM and dest buffer */ + for (cnt = 0 ; cnt < 1024; cnt += 4) + EN_WRITE(sc, MID_BUFOFF+cnt, 0); /* zero memory */ +#ifdef NBURSTS + for (cnt = 0 ; cnt < 64*NBURSTS; cnt++) +#else + for (cnt = 0 ; cnt < 68 ; cnt++) +#endif + dp[cnt] = 0; + + if (wmtry) { + count = (sc->bestburstlen - sizeof(u_int32_t)) / sizeof(u_int32_t); + bcode = en_dmaplan[count].bcode; + count = wmtry >> en_dmaplan[count].divshift; + } else { + bcode = en_sz2b(lcv); + count = 1; + } +#ifdef NBURSTS + /* build lcv-byte-DMA x NBURSTS */ + if (sc->is_adaptec) + EN_WRITE(sc, sc->dtq_chip, MID_MK_TXQ_ADP(lcv*NBURSTS, 0, MID_DMA_END, 0)); + else + EN_WRITE(sc, sc->dtq_chip, MID_MK_TXQ_ENI(count*NBURSTS, 0, MID_DMA_END, bcode)); + EN_WRITE(sc, sc->dtq_chip+4, vtophys(sp)); + EN_WRAPADD(MID_DTQOFF, MID_DTQEND, sc->dtq_chip, 8); + EN_WRITE(sc, MID_DMA_WRTX, MID_DTQ_A2REG(sc->dtq_chip)); + cnt = 1000; + while (EN_READ(sc, MID_DMA_RDTX) != MID_DTQ_A2REG(sc->dtq_chip)) { + DELAY(1); + cnt--; + if (cnt == 0) { + printf("%s: unexpected timeout in tx DMA test\n", sc->sc_dev.dv_xname); +/* + printf(" alignment=0x%x, burst size=%d, dma addr reg=0x%x\n", + (u_long)sp & 63, lcv, EN_READ(sc, MID_DMA_ADDR)); +*/ + return(retval); /* timeout, give up */ + } + } +#else /* !NBURSTS */ + if (sc->is_adaptec) + EN_WRITE(sc, sc->dtq_chip, MID_MK_TXQ_ADP(lcv, 0, MID_DMA_END, 0)); + else + EN_WRITE(sc, sc->dtq_chip, MID_MK_TXQ_ENI(count, 0, MID_DMA_END, bcode)); + EN_WRITE(sc, sc->dtq_chip+4, vtophys(sp)); + EN_WRITE(sc, MID_DMA_WRTX, MID_DTQ_A2REG(sc->dtq_chip+8)); + cnt = 1000; + while (EN_READ(sc, MID_DMA_RDTX) == MID_DTQ_A2REG(sc->dtq_chip)) { + DELAY(1); + cnt--; + if (cnt == 0) { + printf("%s: unexpected timeout in tx DMA test\n", sc->sc_dev.dv_xname); + return(retval); /* timeout, give up */ + } + } + EN_WRAPADD(MID_DTQOFF, MID_DTQEND, sc->dtq_chip, 8); +#endif /* !NBURSTS */ + reg = EN_READ(sc, MID_INTACK); + if ((reg & MID_INT_DMA_TX) != MID_INT_DMA_TX) { + printf("%s: unexpected status in tx DMA test: 0x%x\n", + sc->sc_dev.dv_xname, reg); + return(retval); + } + EN_WRITE(sc, MID_MAST_CSR, MID_MCSR_ENDMA); /* re-enable DMA (only) */ + + /* "return to sender..." address is known ... */ + +#ifdef NBURSTS + /* build lcv-byte-DMA x NBURSTS */ + if (sc->is_adaptec) + EN_WRITE(sc, sc->drq_chip, MID_MK_RXQ_ADP(lcv*NBURSTS, 0, MID_DMA_END, 0)); + else + EN_WRITE(sc, sc->drq_chip, MID_MK_RXQ_ENI(count*NBURSTS, 0, MID_DMA_END, bcode)); + EN_WRITE(sc, sc->drq_chip+4, vtophys(dp)); + EN_WRAPADD(MID_DRQOFF, MID_DRQEND, sc->drq_chip, 8); + EN_WRITE(sc, MID_DMA_WRRX, MID_DRQ_A2REG(sc->drq_chip)); + cnt = 1000; + while (EN_READ(sc, MID_DMA_RDRX) != MID_DRQ_A2REG(sc->drq_chip)) { + DELAY(1); + cnt--; + if (cnt == 0) { + printf("%s: unexpected timeout in rx DMA test\n", sc->sc_dev.dv_xname); + return(retval); /* timeout, give up */ + } + } +#else /* !NBURSTS */ + if (sc->is_adaptec) + EN_WRITE(sc, sc->drq_chip, MID_MK_RXQ_ADP(lcv, 0, MID_DMA_END, 0)); + else + EN_WRITE(sc, sc->drq_chip, MID_MK_RXQ_ENI(count, 0, MID_DMA_END, bcode)); + EN_WRITE(sc, sc->drq_chip+4, vtophys(dp)); + EN_WRITE(sc, MID_DMA_WRRX, MID_DRQ_A2REG(sc->drq_chip+8)); + cnt = 1000; + while (EN_READ(sc, MID_DMA_RDRX) == MID_DRQ_A2REG(sc->drq_chip)) { + DELAY(1); + cnt--; + if (cnt == 0) { + printf("%s: unexpected timeout in rx DMA test\n", sc->sc_dev.dv_xname); + return(retval); /* timeout, give up */ + } + } + EN_WRAPADD(MID_DRQOFF, MID_DRQEND, sc->drq_chip, 8); +#endif /* !NBURSTS */ + reg = EN_READ(sc, MID_INTACK); + if ((reg & MID_INT_DMA_RX) != MID_INT_DMA_RX) { + printf("%s: unexpected status in rx DMA test: 0x%x\n", + sc->sc_dev.dv_xname, reg); + return(retval); + } + EN_WRITE(sc, MID_MAST_CSR, MID_MCSR_ENDMA); /* re-enable DMA (only) */ + + if (wmtry) { + return(bcmp(sp, dp, wmtry)); /* wmtry always exits here, no looping */ + } + +#ifdef NBURSTS + if (bcmp(sp, dp, lcv * NBURSTS)) { +/* printf("DMA test failed! lcv=%d, sp=0x%x, dp=0x%x\n", lcv, sp, dp); */ + return(retval); /* failed, use last value */ + } +#else + if (bcmp(sp, dp, lcv)) + return(retval); /* failed, use last value */ +#endif + + retval = lcv; + + } + return(retval); /* studly 64 byte DMA present! oh baby!! */ +} + +/***********************************************************************/ + +/* + * en_ioctl: handle ioctl requests + * + * NOTE: if you add an ioctl to set txspeed, you should choose a new + * TX channel/slot. Choose the one with the lowest sc->txslot[slot].nref + * value, subtract one from sc->txslot[0].nref, add one to the + * sc->txslot[slot].nref, set sc->txvc2slot[vci] = slot, and then set + * txspeed[vci]. + */ + +STATIC int en_ioctl(ifp, cmd, data) + +struct ifnet *ifp; +EN_IOCTL_CMDT cmd; +caddr_t data; + +{ + struct en_softc *sc = (struct en_softc *) ifp->if_softc; + struct ifaddr *ifa = (struct ifaddr *) data; + struct ifreq *ifr = (struct ifreq *) data; + struct atm_pseudoioctl *api = (struct atm_pseudoioctl *)data; + struct atm_stat *atmstat = (struct atm_stat*) data ; +#ifdef NATM + struct atm_rawioctl *ario = (struct atm_rawioctl *)data; +#ifdef RATE_LIM + struct atm_txspd_ioctl *atxspd; + u_int8_t n_txspd; /*new txspeed*/ + trfdesc desc; + int pcb_vci=-1; + int chan; +#endif + int slot; +#endif + int s, i, error = 0; + + s = splnet(); + + switch (cmd) { + + case SIOCATMENA: /* enable circuit for recv */ + error = en_rxctl(sc, api, 1); + break; + + case SIOCATMDIS: /* disable circuit for recv */ + error = en_rxctl(sc, api, 0); + break; + +#ifdef NATM + case SIOCXRAWATM: + if ((slot = sc->rxvc2slot[ario->npcb->npcb_vci]) == RX_NONE) { + error = EINVAL; + break; + } + if (ario->rawvalue > EN_RXSZ*1024) + ario->rawvalue = EN_RXSZ*1024; + if (ario->rawvalue) { + sc->rxslot[slot].oth_flags |= ENOTHER_RAW; + sc->rxslot[slot].raw_threshold = ario->rawvalue; + } else { + sc->rxslot[slot].oth_flags &= (~ENOTHER_RAW); + sc->rxslot[slot].raw_threshold = 0; + } +#ifdef EN_DEBUG + printf("%s: rxvci%d: turn %s raw (boodi) mode\n", + sc->sc_dev.dv_xname, ario->npcb->npcb_vci, + (ario->rawvalue) ? "on" : "off"); +#endif + break; + +#ifdef RATE_LIM + case SIOCXTXSPEED: + atxspd = (struct atm_txspd_ioctl *)data; + bcopy(&(atxspd->npcb->desc),&desc,sizeof(trfdesc)); + pcb_vci = atxspd->npcb->npcb_vci; + /* Basically, if you are doing rate limit, we will reassign */ + /* a transmit slot to the vci. Otherwise, by default, */ + /* any vc created gets assigned to slot 0 - best effort */ + /* Check on available BW ?! */ +#ifdef EN_DEBUG + printf("en_ioct (pci/midway.c): pbw= %d, available bw= %d\n", + desc.pbw, sc->avl_bw); +#endif + if (desc.pbw >= sc->avl_bw) { + error = ENOSPC; + break; + } + + if (desc.pbw == 0) + n_txspd = 0; + else { + if ( (n_txspd = en_cps2enispec(&desc)) == 0 ) { +#ifdef NAIVE_ROUND_ROBIN + sc->txchan_assgn[pcb_vci]= 0; +#endif + error = EINVAL; + } + } + + if (error != EINVAL) { + if (sc->txspeed[pcb_vci] > 0) { + sc->avl_bw = sc->avl_bw + + en_enispec2cps(sc->txspeed[pcb_vci]) - + en_enispec2cps(n_txspd); + if (sc->avl_bw > EN_MAX_LINE_RATE) + sc->avl_bw = EN_MAX_LINE_RATE; + } + else + sc->avl_bw = sc->avl_bw - en_enispec2cps(n_txspd); + + sc->txspeed[pcb_vci] = n_txspd; + if (sc->txchan_assgn[pcb_vci] == 0) { +#ifdef NAIVE_ROUND_ROBIN + sc->txchan++; + if (sc->txchan > 7) sc->txchan = 1; + sc->txchan_assgn[pcb_vci] = sc->txchan; + + sc->txslot[txchan].vci_assgn = pcb_vci; + sc->txvc2slot[pcb_vci] = txchan; + + printf ("Channel %d assigned to VCI=%d\n", + sc->txchan,pcb_vci); +#else + if ((chan=en_find_chan(sc,pcb_vci)) > 0) { + sc->txchan_assgn[pcb_vci] = chan; + + sc->txslot[chan].vci_assgn = pcb_vci; + sc->txvc2slot[pcb_vci] = chan; + + sc->txchan[chan]++; + printf("Channel %d assigned to VCI=%d\n",chan,pcb_vci); + } + else { + + /* by default, assign everything else to slot 0 */ + sc->txslot[0].vci_assgn = pcb_vci; + sc->txvc2slot[pcb_vci] = 0; + + sc->txchan_assgn[pcb_vci] = 0; + sc->txchan[0]++; + printf("Encountered error in channel selection. \ + VC=%d -->chan 0\n" + ,pcb_vci); + error = EINVAL; + } +#endif + } + } + +#ifdef EN_DEBUG + printf("%s: vci%d: descr: abw=%d, pbw=%d, bsize=%d, setto=%d avl=%d\n", + sc->sc_dev.dv_xname, atxspd->npcb->npcb_vci, + atxspd->npcb->desc.abw, + atxspd->npcb->desc.pbw,atxspd->npcb->desc.bsize, + en_enispec2cps(n_txspd), sc->avl_bw); +#endif + /* + * Update the vctoif mapping table with the new rate limit + */ + if (error != EINVAL) { + for (i=0; i<= NENP; ++i) { + if (sc->vctoif[i].vci == pcb_vci) { + sc->vctoif[i].pcr = desc.pbw; + break; + } + } + } + + break; + +#endif /* NATM */ +#endif /* RATE_LIM */ + + + case SIOCSIFADDR: +#if defined(INET6) && defined(SIOCSIFADDR_IN6) +case SIOCSIFADDR_IN6: +#endif + switch (ifa->ifa_addr->sa_family) { +#ifdef INET + case AF_INET: +#endif +#ifdef INET6 + case AF_INET6: +#endif /* INET6 */ +#if defined(INET) || defined(INET6) + ifp->if_flags |= IFF_UP; +#if defined(__KAME__) && defined(INET6) + in6_ifattach(ifp, IN6_IFT_802, sc->macaddr, 0); +#endif + en_reset(sc); + en_init(sc); + ifa->ifa_rtrequest = atm_rtrequest; /* ??? */ + break; +#endif /* INET || INET6*/ + default: + /* what to do if not INET? */ + printf("atm: unknown addr family: %d\n", + ifa->ifa_addr->sa_family); /* XXX skb */ + + en_reset(sc); + en_init(sc); + break; + } + break; + + case SIOCGIFADDR: + error = EINVAL; + break; + + case SIOCSIFFLAGS: + break; + + case SIOCADDMULTI: + case SIOCDELMULTI: + if (ifr == 0) { +#if (!defined(__FreeBSD__) || __FreeBSD_version < 300000) + error = EAFNOSUPPORT; +#endif + break; + } + switch (ifr->ifr_addr.sa_family) { + +#ifdef INET + case AF_INET: + break; +#endif +#ifdef INET6 + case AF_INET6: + break; +#endif /* INET6 */ + + default: + error = EAFNOSUPPORT; + break; + } + break; + +#if defined(SIOCSIFMTU) /* ??? copied from if_de */ +#if !defined(ifr_mtu) +#define ifr_mtu ifr_metric +#endif + case SIOCSIFMTU: + /* + * Set the interface MTU. + */ +#ifdef notsure + if (ifr->ifr_mtu > ATMMTU) { + error = EINVAL; + break; + } +#endif + ifp->if_mtu = ifr->ifr_mtu; + /* XXXCDC: do we really need to reset on MTU size change? */ + en_reset(sc); + en_init(sc); + break; +#endif /* SIOCSIFMTU */ + + case SIOCGATMCONF: + error = en_atmconf(sc, data); + break; + + case SIOCATMSTAT: + error = en_dump(ifp,atmstat); + break; + +#if defined(ALTQ) && defined(AFMAP) + case AFM_ADDFMAP: + do { + struct afm *afm = afm_top(ifp); + error = en_flowmap_add(sc, (struct atm_flowmap *)data); + if (afm == NULL && error == 0) + ifp->if_altqflags |= ALTQF_DRIVER1; + } while (0); + break; + + case AFM_DELFMAP: + do { + struct atm_flowmap *fmap = (struct atm_flowmap *)data; + error = en_flowmap_delete(sc, fmap->af_vpi, fmap->af_vci); + + if (afm_top(ifp) == NULL) + ifp->if_altqflags &= ~ALTQF_DRIVER1; + } while (0); + break; + + case AFM_CLEANFMAP: + do { + struct afm *afm; + while ((afm = afm_top(ifp)) != NULL) + en_flowmap_delete(sc, afm->afm_vpi, afm->afm_vci); + + ifp->if_altqflags &= ~ALTQF_DRIVER1; + } while (0); + break; + + case AFM_GETFMAP: + error = en_flowmap_get(sc, (struct atm_flowmap *)data); + break; + +#endif /* ALTQ && AFMAP */ + + default: + error = EINVAL; + break; + } + splx(s); + return error; +} + +/* finds vctoif[] index for the ifp passed */ +/* returns index, or -1 if failed */ +int +en_find_if_index(struct ifnet *ifp) +{ + int index; + struct en_softc *sc = (struct en_softc*)ifp->if_softc; + + index = ((strlen(ifp->if_name) == 2) ? 0: ifp->if_unit) + + ((strlen(ifp->if_name) > 2) ? 1: 0); + if ((sc->vctoif[index].ifp) && + (!strcmp(sc->vctoif[index].ifp->if_name, ifp->if_name)) && + (sc->vctoif[index].ifp->if_unit == ifp->if_unit)) + return index; + + return -1; +} + +/* + * en_atmconf: Returns a list of all the VCCs and related info + * configured on an ATM card. + * Arguments: sc - softc strcture controlling the ATM card + * data - a pointer to ifatmconf structure + * Returns: 0 on success, + * error if failed. + */ +STATIC int +en_atmconf(sc, data) +struct en_softc *sc; +caddr_t data; +{ + struct ifatmconf *ifac = (struct ifatmconf *) data; + struct ifatmreq *ifar = (struct ifatmreq *) ifac->ifac_buf; + int space = ifac->ifac_len; + int i, max; + char *cp; + + for (i=0, max=NENP+1, ifac->ifac_cnt=0; + space > sizeof(struct ifatmreq) && i < max; + ++i, space -= sizeof(struct ifatmreq) ) { + + if (sc->vctoif[i].ifp == 0) + continue; + + strncpy(ifar->ifar_name, sc->vctoif[i].ifp->if_name, + sizeof(ifar->ifar_name) - 2); + for (cp = ifar->ifar_name; + cp < ifar->ifar_name + sizeof(ifar->ifar_name) - 2 && *cp; + ++cp) + continue; + *cp++ = '0' + sc->vctoif[i].ifp->if_unit; + *cp = '\0'; + ifar->ifar_vci = sc->vctoif[i].vci; + ifar->ifar_vpi = ATM_PH_VPI(&sc->vctoif[i].aph); + ifar->ifar_flags = ATM_PH_FLAGS (&sc->vctoif[i].aph); + ifar->ifar_refcnt = (sc->vctoif[i].refcnt) ? + *sc->vctoif[i].refcnt : 0; + ifar->ifar_pcr = sc->vctoif[i].pcr; + + ifar = (struct ifatmreq *) ((char *)ifar + + sizeof(struct ifatmreq)); + ifac->ifac_cnt++; + } + + return 0; +} + +#ifdef RATE_LIM +/* en_find_chan(): Finds a tx channel (among Chan 1 to Chan 7) with + * smallest number of VCs assigned. This is obviously subpotimal, + * because if you are a slow connection and you are assigned to a + * channel with lowest VCs, you may be sharing it with a very fast + * connection enqueueing large packets. + * */ +/* history: 6/15/98 */ +/* algorithm revised to the following: */ +/* one vci assigned per transmit slot. */ +/* if the current vci already has a transmit slot assignment, */ +/* use it. */ +/* if all slots already have vci assignment, assign vci to slot 0 */ +/* - also added 2nd argument to function. - Keng */ + +int en_find_chan(struct en_softc *sc,int vci) { + int index; + /* first, let's see if there is an existing assignment */ + for (index = 1; index < EN_NTX; index++) { + if (sc->txslot[index].vci_assgn == vci) + return index; /* already assigned, use it */ + } + /* find a free transmit slot */ + for (index = 1; index < EN_NTX; index++) { + if (sc->txslot[index].vci_assgn == -1) { + /* i.e. its not used */ + return index; + } + } + return 0; /* all slots have vci assigned, so use slot 0 */ +} + +/* previous version +int en_find_chan(sc) +struct en_softc *sc; +{ + int i,j=-1,min=-1; + for (i=1;itxchan[i] ==0) + return(i); + if (sc->txchan[i] < min) { + min = sc->txchan[i]; + j= i; + } + } + return(j); +} +*/ + +/* + * en_cps2enispec: change the cells/sec to (PR |RS)= 8bit number that + * describes rate for eni. Refer pgs. 35 and 45 of ENI MIDWAY manual. + * Returns 0 when an invalid rate is specified. + * + * Note: This function should not be called when d->pbw is '0'. + * That's a special case thecaller should check. With a u_int8_t + * we don't have anything other than '0' to return as error. + */ + +u_int8_t en_cps2enispec(d) + trfdesc *d; +{ + u_int8_t eni_d; + int tmp; + int cnd[4]; + int r[4]; + int min,i,delta[4]; + + if (d->pbw > MAX_LINE_RATE) return(0); + if (d->pbw <=0) return(0); + + for (i=0;i<4;i++) { + r[i] = (int) ((25*1000000) /(d->pbw*PR[i]) -1); + if (r[i] < 0) r[i] = 0; + if (r[i] > 63) r[i]=63; + cnd[i] = (int) ((25*1000000)/((r[i]+1)*PR[i] )); + delta[i] = abs(d->pbw - cnd[i]); + } + + tmp= delta[0]; + min=0; + for (i=1;i<4;i++) { + if (delta[i] < tmp) { + tmp = delta[i]; + min=i; + } + if (delta[i] == tmp) { + tmp = delta[i]; + min=i; + } + } + +#ifdef EN_DEBUG + printf("Unrefined: Requested=%d, Actual Rate= %d pr= %d, res=%d\n", + d->pbw, (int) ((25*1000000)/((PR[min])*(r[min]+1))),PR[min],r[min]); +#endif + + /* Always use smaller rate value and hence bigger rate res*/ + if (r[min] < 63) + r[min] = r[min]+1; + +#ifdef EN_DEBUG + printf("FINAL: Requested=%d, Actual Rate= %d pr= %d, res=%d\n", + d->pbw, (int) ((25*1000000)/((PR[min])*(r[min]+1))),PR[min],r[min]); +#endif + /* min is index of "closest" matching (PR, r) comb */ + eni_d = ((u_int8_t)min << 6) | (u_int8_t)(r[min]); + return(eni_d); +} + +/* + * en_enispec2cps: change the cells/sec to (PR |RS)= 8bit number that + * describes rate for eni. Refer pgs. 35 and 45 of ENI MIDWAY manual. + */ + +int32_t +en_enispec2cps (sp) + u_int8_t sp; +{ + int pr,r; + int32_t cps; + + if (sp == 0) + return 0; + + pr=r=sp; + /* extract prescaler and rate-resolution */ + pr = (pr & 0x00000c0) >> 6; + r = (r & 0x0000003f); + cps = (int32_t) ((25*1000000)/((PR[pr])*(r+1))); + return(cps); +} + +#endif /* RATE_LIM */ + +/* + * en_rxctl: turn on and off VCs for recv. + */ + +STATIC int en_rxctl(sc, pi, on) + +struct en_softc *sc; +struct atm_pseudoioctl *pi; +int on; + +{ + u_int s, vci, flags, slot; + u_int32_t oldmode, newmode; +#if NENP > 0 + int i; +#endif + + vci = ATM_PH_VCI(&pi->aph); + flags = ATM_PH_FLAGS(&pi->aph); + +#ifdef EN_DEBUG + printf("%s: %s vpi=%d, vci=%d, flags=%d\n", sc->sc_dev.dv_xname, + (on) ? "enable" : "disable", ATM_PH_VPI(&pi->aph), vci, flags); +#endif + + if (ATM_PH_VPI(&pi->aph) || vci >= MID_N_VC) + return(EINVAL); + + /* + * turn on VCI! + */ + + if (on) { + if (sc->rxvc2slot[vci] != RX_NONE) + return(EINVAL); + for (slot = 0 ; slot < sc->en_nrx ; slot++) + if (sc->rxslot[slot].oth_flags & ENOTHER_FREE) + break; + if (slot == sc->en_nrx) { + printf("Active slots full: %d\n", slot); + return(ENOSPC); + } + sc->rxvc2slot[vci] = slot; + sc->rxslot[slot].rxhand = NULL; + oldmode = sc->rxslot[slot].mode; + newmode = (flags & ATM_PH_AAL5) ? MIDV_AAL5 : MIDV_NOAAL; + sc->rxslot[slot].mode = MIDV_SETMODE(oldmode, newmode); + sc->rxslot[slot].atm_vci = vci; + sc->rxslot[slot].atm_flags = flags; + sc->rxslot[slot].oth_flags = 0; + sc->rxslot[slot].rxhand = pi->rxhand; + if (sc->rxslot[slot].indma.ifq_head || sc->rxslot[slot].q.ifq_head) + panic("en_rxctl: left over mbufs on enable"); + sc->txspeed[vci] = 0; /* full speed to start */ + + en_loadvc(sc, vci); /* does debug printf for us */ + return(0); + } + + /* + * turn off VCI + */ + + if (sc->rxvc2slot[vci] == RX_NONE) + return(EINVAL); + slot = sc->rxvc2slot[vci]; + if ((sc->rxslot[slot].oth_flags & (ENOTHER_FREE|ENOTHER_DRAIN)) != 0) + return(EINVAL); + s = splimp(); /* block out enintr() */ + oldmode = EN_READ(sc, MID_VC(vci)); + newmode = MIDV_SETMODE(oldmode, MIDV_TRASH) & ~MIDV_INSERVICE; + EN_WRITE(sc, MID_VC(vci), (newmode | (oldmode & MIDV_INSERVICE))); + /* halt in tracks, be careful to preserve inserivce bit */ + DELAY(27); + sc->rxslot[slot].rxhand = NULL; + sc->rxslot[slot].mode = newmode; + +#ifdef RATE_LIM + /* Returning BW!*/ + +#ifdef EN_DEBUG + printf("I AM GOING TO ZONK IT NOW\n"); + printf("Returning BW: vci= %d, enispec= 0x%02x, bw= %dcps\t", + vci, sc->txspeed[vci], en_enispec2cps(sc->txspeed[vci])); +#endif + + if (sc->txspeed[vci] != 0) { /* if not full speed */ + sc->avl_bw = sc->avl_bw + en_enispec2cps(sc->txspeed[vci]); + } + +#ifdef EN_DEBUG + printf("avail bw after return= %dcps\n", sc->avl_bw); +#endif + +#endif /* RATE_LIM */ + + /* if stuff is still going on we are going to have to drain it out */ + if (sc->rxslot[slot].indma.ifq_head || + sc->rxslot[slot].q.ifq_head || + (sc->rxslot[slot].oth_flags & ENOTHER_SWSL) != 0) { + sc->rxslot[slot].oth_flags |= ENOTHER_DRAIN; + } else { + sc->rxslot[slot].oth_flags = ENOTHER_FREE; + sc->rxslot[slot].atm_vci = RX_NONE; + sc->rxvc2slot[vci] = RX_NONE; + } + + /* + * Cleanup the vctoif mapping, and the lladdr info of the interface + * if the pseudo interfaces are defined. + */ +#if NENP > 0 + for (i=0; i <= NENP; ++i) { + if (sc->vctoif[i].vci == vci) { + + /* Clear the VC table entry now */ + + sc->vctoif[i].vci = 0; + sc->vctoif[i].ifp = NULL; + bzero(&sc->vctoif[i].aph, sizeof (struct atm_pseudohdr)); + sc->vctoif[i].refcnt = NULL; + + break; + } + } +#endif + + sc->vci2ifp[vci] = 0; + + splx(s); /* enable enintr() */ +#ifdef EN_DEBUG + printf("%s: rx%d: VCI %d is now %s\n", sc->sc_dev.dv_xname, slot, vci, + (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) ? "draining" : "free"); +#endif + return(0); +} + +/***********************************************************************/ + +/* + * en_reset: reset the board, throw away work in progress. + * must en_init to recover. + */ + +void en_reset(sc) + +struct en_softc *sc; + +{ + struct mbuf *m; + int lcv, slot; + +#ifdef EN_DEBUG + printf("%s: reset\n", sc->sc_dev.dv_xname); +#endif + + if (sc->en_busreset) + sc->en_busreset(sc); + EN_WRITE(sc, MID_RESID, 0x0); /* reset hardware */ + + /* + * recv: dump any mbufs we are dma'ing into, if DRAINing, then a reset + * will free us! + */ + + for (lcv = 0 ; lcv < MID_N_VC ; lcv++) { + if (sc->rxvc2slot[lcv] == RX_NONE) + continue; + slot = sc->rxvc2slot[lcv]; + while (1) { + IF_DEQUEUE(&sc->rxslot[slot].indma, m); + if (m == NULL) + break; /* >>> exit 'while(1)' here <<< */ + m_freem(m); + } + while (1) { + IF_DEQUEUE(&sc->rxslot[slot].q, m); + if (m == NULL) + break; /* >>> exit 'while(1)' here <<< */ + m_freem(m); + } + sc->rxslot[slot].oth_flags &= ~ENOTHER_SWSL; + if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) { + sc->rxslot[slot].oth_flags = ENOTHER_FREE; + sc->rxvc2slot[lcv] = RX_NONE; +#ifdef EN_DEBUG + printf("%s: rx%d: VCI %d is now free\n", sc->sc_dev.dv_xname, slot, lcv); +#endif + } + } + + /* + * xmit: dump everything + */ + + for (lcv = 0 ; lcv < EN_NTX ; lcv++) { + while (1) { + IF_DEQUEUE(&sc->txslot[lcv].indma, m); + if (m == NULL) + break; /* >>> exit 'while(1)' here <<< */ + m_freem(m); + /* Should really update the pseudo-i/f's stats XXX skb */ + IF_DROP(&sc->enif.if_snd); + } + while (1) { + IF_DEQUEUE(&sc->txslot[lcv].q, m); + if (m == NULL) + break; /* >>> exit 'while(1)' here <<< */ + m_freem(m); + /* Should really update the pseudo-i/f's stats XXX skb */ + IF_DROP(&sc->enif.if_snd); + } +#if defined(ALTQ) && 0 /* Why not leave those pkts in there? XXX skb */ + do { + struct ifnet *ifp = &sc->enif; + + if (ALTQ_IS_ON(ifp)) + (void)(*ifp->if_altqdequeue)(ifp, ALTDQ_FLUSH); + } while (0); + +#endif /* ALTQ */ + + sc->txslot[lcv].mbsize = 0; + } + +#ifdef EN_STAT + /* + * let's clear the stats also + */ + sc->vtrash = sc->otrash = sc->mfix = sc->txmbovr = sc->dmaovr = 0; + sc->txoutspace = sc->txdtqout = sc->launch = sc->lheader = sc->ltail = 0; + sc->hwpull = sc->swadd = sc->rxqnotus = sc->rxqus = sc->rxoutboth = 0; + sc->rxdrqout = sc->ttrash = sc->rxmbufout = sc->mfixfail = 0; + sc->headbyte = sc->tailbyte = sc->tailflush = 0; + for (lcv = 0; lcv < EN_NTX; lcv++) { + sc->txslot[lcv].txbuf2small = 0; + sc->txslot[lcv].txmbovr = 0; + sc->txslot[lcv].mbsize = 0; + } +#endif + + return; +} + + +/* + * en_init: init board and sync the card with the data in the softc. + */ + +STATIC void en_init(sc) + +struct en_softc *sc; + +{ + int vc, slot, found = 0; + u_int32_t loc; + struct ifnet *ifp; + + if ((sc->enif.if_flags & IFF_UP) == 0) { + /* + * Check if any pseudo interface is up. + */ +#if defined(NENP) && NENP > 0 + FOREACHIFP(ifp) + { + if (!strcmp(ifp->if_name, en_pif_name[sc->enif.if_unit]) && + (ifp->if_flags & IFF_UP) == IFF_UP) { + found = 1; + break; + } + } + if (!found) { +#endif /* NENP */ + +#ifdef EN_DEBUG + printf("%s: going down\n", sc->sc_dev.dv_xname); +#endif + en_reset(sc); /* to be safe */ + sc->enif.if_flags &= ~IFF_RUNNING; /* disable */ +#if defined(NENP) && NENP > 0 + FOREACHIFP(ifp) { + if (!strcmp(ifp->if_name, en_pif_name[sc->enif.if_unit])) { + ifp->if_flags &= ~IFF_RUNNING; + } + } +#endif + return; +#if defined(NENP) && NENP > 0 + } +#endif /* NENP */ + } + +#ifdef EN_DEBUG + printf("%s: going up\n", sc->sc_dev.dv_xname); +#endif + sc->enif.if_flags |= IFF_RUNNING; /* enable */ + + /* + * Also enable any pseudo interfaces. + */ +#if defined(NENP) && NENP > 0 + FOREACHIFP(ifp) { + if (!strcmp(ifp->if_name, en_pif_name[sc->enif.if_unit])) { + ifp->if_flags |= IFF_RUNNING; + } + } +#endif + + + if (sc->en_busreset) + sc->en_busreset(sc); + EN_WRITE(sc, MID_RESID, 0x0); /* reset */ + + /* + * init obmem data structures: vc tab, dma q's, slist. + * note that we set drq_free/dtq_free to one less than the total number + * of DTQ/DRQs present. we do this because the card uses the condition + * (drq_chip == drq_us) to mean "list is empty"... but if you allow the + * circular list to be completely full then (drq_chip == drq_us) [i.e. + * the drq_us pointer will wrap all the way around]. by restricting + * the number of active requests to (N - 1) we prevent the list from + * becoming completely full. note that the card will sometimes give + * us an interrupt for a DTQ/DRQ we have already processes... this helps + * keep that interrupt from messing us up. - kjc's fix. + * added 2/18/99 keng@cs.cmu.edu + */ + + for (vc = 0 ; vc < MID_N_VC ; vc++) + en_loadvc(sc, vc); + + bzero(&sc->drq, sizeof(sc->drq)); + sc->drq_free = MID_DRQ_N -1; /* kjc's fix */ + sc->drq_chip = MID_DRQ_REG2A(EN_READ(sc, MID_DMA_RDRX)); + EN_WRITE(sc, MID_DMA_WRRX, MID_DRQ_A2REG(sc->drq_chip)); + /* ensure zero queue */ + sc->drq_us = sc->drq_chip; + + bzero(&sc->dtq, sizeof(sc->dtq)); + sc->dtq_free = MID_DTQ_N -1; /* kjc's fix */ + sc->dtq_chip = MID_DTQ_REG2A(EN_READ(sc, MID_DMA_RDTX)); + EN_WRITE(sc, MID_DMA_WRTX, MID_DRQ_A2REG(sc->dtq_chip)); + /* ensure zero queue */ + sc->dtq_us = sc->dtq_chip; + + sc->hwslistp = MID_SL_REG2A(EN_READ(sc, MID_SERV_WRITE)); + sc->swsl_size = sc->swsl_head = sc->swsl_tail = 0; + +#ifdef EN_DEBUG + printf("%s: drq free/chip: %d/0x%x, dtq free/chip: %d/0x%x, hwslist: 0x%x\n", + sc->sc_dev.dv_xname, sc->drq_free, sc->drq_chip, + sc->dtq_free, sc->dtq_chip, sc->hwslistp); +#endif + + for (slot = 0 ; slot < EN_NTX ; slot++) { + sc->txslot[slot].bfree = EN_TXSZ * 1024; + EN_WRITE(sc, MIDX_READPTR(slot), 0); + EN_WRITE(sc, MIDX_DESCSTART(slot), 0); + loc = sc->txslot[slot].cur = sc->txslot[slot].start; + loc = loc - MID_RAMOFF; + loc = (loc & ~((EN_TXSZ*1024) - 1)) >> 2; /* mask, cvt to words */ + loc = loc >> MIDV_LOCTOPSHFT; /* top 11 bits */ + EN_WRITE(sc, MIDX_PLACE(slot), MIDX_MKPLACE(en_k2sz(EN_TXSZ), loc)); +#ifdef EN_DEBUG + printf("%s: tx%d: place 0x%x\n", sc->sc_dev.dv_xname, slot, + EN_READ(sc, MIDX_PLACE(slot))); +#endif + } + + /* + * enable! + */ + + EN_WRITE(sc, MID_INTENA, MID_INT_TX|MID_INT_DMA_OVR|MID_INT_IDENT| + MID_INT_LERR|MID_INT_DMA_ERR|MID_INT_DMA_RX|MID_INT_DMA_TX| + MID_INT_SERVICE| /* >>> MID_INT_SUNI| XXXCDC<<< */ MID_INT_STATS); + EN_WRITE(sc, MID_MAST_CSR, MID_SETIPL(sc->ipl)|MID_MCSR_ENDMA| + MID_MCSR_ENTX|MID_MCSR_ENRX); + +} + + +/* + * en_loadvc: load a vc tab entry from a slot + */ + +STATIC void en_loadvc(sc, vc) + +struct en_softc *sc; +int vc; + +{ + int slot; + u_int32_t reg = EN_READ(sc, MID_VC(vc)); + + reg = MIDV_SETMODE(reg, MIDV_TRASH); + EN_WRITE(sc, MID_VC(vc), reg); + DELAY(27); + + if ((slot = sc->rxvc2slot[vc]) == RX_NONE) + return; + + /* no need to set CRC */ + EN_WRITE(sc, MID_DST_RP(vc), 0); /* read pointer = 0, desc. start = 0 */ + EN_WRITE(sc, MID_WP_ST_CNT(vc), 0); /* write pointer = 0 */ + EN_WRITE(sc, MID_VC(vc), sc->rxslot[slot].mode); /* set mode, size, loc */ + sc->rxslot[slot].cur = sc->rxslot[slot].start; + +#ifdef EN_DEBUG + printf("%s: rx%d: assigned to VCI %d\n", sc->sc_dev.dv_xname, slot, vc); +#endif +} + + +/* + * en_start: start transmitting the next packet that needs to go out + * if there is one. note that atm_output() has already splimp()'d us. + */ + +STATIC void en_start(ifp) + +struct ifnet *ifp; + +{ + struct en_softc *sc = (struct en_softc *) ifp->if_softc; + struct ifqueue *ifq = &ifp->if_snd; /* if INPUT QUEUE */ + struct mbuf *m, *lastm, *prev; + struct atm_pseudohdr *ap, *new_ap; + int txchan, mlen, got, need, toadd, cellcnt, first; + u_int32_t atm_vpi, atm_vci, atm_flags, *dat, aal; + u_int8_t *cp; + int index; + + if ((ifp->if_flags & IFF_RUNNING) == 0) + return; + + /* + * remove everything from interface queue since we handle all queueing + * locally ... + */ + /* history: 6/16/98 - change it so that it removes only when */ + /* mbsize > EN_TXHIWAT */ + + + index = en_find_if_index(ifp); + if (index != -1) { + atm_vci = sc->vctoif[index].vci; + txchan = sc->txvc2slot[atm_vci]; + } + else + panic("failed to find channel assignment!"); + + while (sc->txslot[txchan].mbsize < EN_TXHIWAT) { + +#ifdef ALTQ + if (ALTQ_IS_ON(ifp)) { + struct mbuf *tmp; + /* + * The following code looks as if multiple VC's are allowed to share + * the same i/f - not with our code. XXX skb + */ + m = (*ifp->if_altqdequeue)(ifp, ALTDQ_PEEK); + if (m != NULL) { +#if 0 + ap = mtod(m, struct atm_pseudohdr *); + atm_vci = ATM_PH_VCI(ap); + txchan = sc->txvc2slot[atm_vci]; + if (sc->txslot[txchan].mbsize > 20*1024) { + EN_COUNT(sc->txmbovr); /* this isn't a right stat counter */ + return; + } +#endif /* 0 */ + tmp = (*ifp->if_altqdequeue)(ifp, ALTDQ_DEQUEUE); + if (tmp != m) + panic("en_start: different mbuf dequeued!"); + } + } + else +#endif /* ALTQ */ + + IF_DEQUEUE(ifq, m); + + if (m == NULL) + return; /* EMPTY: >>> exit here <<< */ + + /* + * calculate size of packet (in bytes) + * also, if we are not doing transmit DMA we eliminate all stupid + * (non-word) alignments here using en_mfix(). calls to en_mfix() + * seem to be due to tcp retransmits for the most part. + * + * after this loop mlen total length of mbuf chain (including atm_ph), + * and lastm is a pointer to the last mbuf on the chain. + */ + + lastm = m; + mlen = 0; + prev = NULL; + while (1) { + /* no DMA? */ + /* kjc's fix - added 2/18/99 keng@cs.cmu.edu */ + if ((!sc->is_adaptec && EN_ENIDMAFIX) || + (EN_NOTXDMA || !en_dma)) { + if ( (mtod(lastm, unsigned long) % sizeof(u_int32_t)) != 0 || + ((lastm->m_len % sizeof(u_int32_t)) != 0 && lastm->m_next)) { + first = (lastm == m); + if (en_mfix(sc, &lastm, prev) == 0) { /* failed? */ + m_freem(m); + m = NULL; + ifp->if_oerrors++; + break; + } + if (first) + m = lastm; /* update */ + } + prev = lastm; + } + mlen += lastm->m_len; + if (lastm->m_next == NULL) + break; + lastm = lastm->m_next; + } + + if (m == NULL) /* happens only if mfix fails */ + continue; + + ap = mtod(m, struct atm_pseudohdr *); + + atm_vpi = ATM_PH_VPI(ap); + atm_vci = ATM_PH_VCI(ap); + atm_flags = ATM_PH_FLAGS(ap) & ~(EN_OBHDR|EN_OBTRL); + aal = ((atm_flags & ATM_PH_AAL5) != 0) + ? MID_TBD_AAL5 : MID_TBD_NOAAL5; + + /* + * check that vpi/vci is one we can use + */ + + if (atm_vpi || atm_vci > MID_N_VC) { + printf("%s: output vpi=%d, vci=%d out of card range, dropping...\n", + sc->sc_dev.dv_xname, atm_vpi, atm_vci); + m_freem(m); + ifp->if_oerrors++; + continue; + } + + /* + * computing how much padding we need on the end of the mbuf, then + * see if we can put the TBD at the front of the mbuf where the + * link header goes (well behaved protocols will reserve room for us). + * last, check if room for PDU tail. + * + * got = number of bytes of data we have + * cellcnt = number of cells in this mbuf + * need = number of bytes of data + padding we need (excludes TBD) + * toadd = number of bytes of data we need to add to end of mbuf, + * [including AAL5 PDU, if AAL5] + */ + + got = mlen - sizeof(struct atm_pseudohdr *); + toadd = (aal == MID_TBD_AAL5) ? MID_PDU_SIZE : 0; /* PDU */ + cellcnt = (got + toadd + (MID_ATMDATASZ - 1)) / MID_ATMDATASZ; + need = cellcnt * MID_ATMDATASZ; + toadd = need - got; /* recompute, including zero padding */ + +#ifdef EN_DEBUG + printf("%s: txvci%d: mlen=%d, got=%d, need=%d, toadd=%d, cell#=%d\n", + sc->sc_dev.dv_xname, atm_vci, mlen, got, need, toadd, cellcnt); + printf(" leading_space=%d, trailing_space=%d\n", + M_LEADINGSPACE(m), M_TRAILINGSPACE(lastm)); +#endif + +#ifdef EN_MBUF_OPT + + /* + * note: external storage (M_EXT) can be shared between mbufs + * to avoid copying (see m_copym()). this means that the same + * data buffer could be shared by several mbufs, and thus it isn't + * a good idea to try and write TBDs or PDUs to M_EXT data areas. + */ + + if (M_LEADINGSPACE(m) >= MID_TBD_SIZE && (m->m_flags & M_EXT) == 0) { + m->m_data -= MID_TBD_SIZE; + m->m_len += MID_TBD_SIZE; + mlen += MID_TBD_SIZE; + new_ap = mtod(m, struct atm_pseudohdr *); + *new_ap = *ap; /* move it back */ + ap = new_ap; + dat = ((u_int32_t *) ap) + 1; + /* make sure the TBD is in proper byte order */ + *dat++ = htonl(MID_TBD_MK1(aal, sc->txspeed[atm_vci], cellcnt)); + *dat = htonl(MID_TBD_MK2(atm_vci, 0, 0)); + atm_flags |= EN_OBHDR; + } + + if (toadd && (lastm->m_flags & M_EXT) == 0 && + M_TRAILINGSPACE(lastm) >= toadd) { + cp = mtod(lastm, u_int8_t *) + lastm->m_len; + lastm->m_len += toadd; + mlen += toadd; + if (aal == MID_TBD_AAL5) { + bzero(cp, toadd - MID_PDU_SIZE); + dat = (u_int32_t *)(cp + toadd - MID_PDU_SIZE); + /* make sure the PDU is in proper byte order */ + *dat = htonl(MID_PDU_MK1(0, 0, got)); + } else { + bzero(cp, toadd); + } + atm_flags |= EN_OBTRL; + } + ATM_PH_FLAGS(ap) = atm_flags; /* update EN_OBHDR/EN_OBTRL bits */ +#endif /* EN_MBUF_OPT */ + + /* + * get assigned channel (will be zero unless txspeed[atm_vci] is set) + */ + /* done above */ + /* txchan = sc->txvc2slot[atm_vci]; */ + + /* + * Now that the pkts are dequeued only when there is room in txchan, + * does the following accounting really make any sense? XXX skb + */ + if (sc->txslot[txchan].mbsize > EN_TXHIWAT) { +#ifdef ALTQ_ACCOUNT + /* + * special process for altq drop accounting. + * re-extract flow and do drop-accounting here. + */ + struct pr_hdr pr_hdr; + int size; + + pr_hdr.ph_family = AF_INET; /* XXX */ + if (ifp->if_altqflags & ALTQF_ACCOUNTING) { + size = sizeof(struct atm_pseudohdr); + if (atm_flags & ATM_PH_LLCSNAP) + size += 8; /* sizeof snap == 8 */ + if (atm_flags & EN_OBHDR) + size += MID_TBD_SIZE; + if (m->m_len >= size + 20) + /* ip header in the first mbuf */ + pr_hdr.ph_hdr = mtod(m, caddr_t) + size; + else if (m->m_len == size && m->m_next->m_len >= 20) + /* ip header is in the second mbuf */ + pr_hdr.ph_hdr = mtod(m->m_next, caddr_t); + else + /* give up otherwise */ + pr_hdr.ph_hdr = NULL; + } + else + pr_hdr.ph_hdr = NULL; + ALTQ_ACCOUNTING(ifp, m, &pr_hdr, ALTEQ_ACCDROP); +#endif + EN_COUNT(sc->txmbovr); + EN_COUNT(sc->txslot[txchan].txmbovr); + + m_freem(m); + IF_DROP(&ifp->if_snd); +#ifdef EN_DEBUG + printf("%s: tx%d: buffer space shortage\n", sc->sc_dev.dv_xname, + txchan); +#endif + continue; + } + + sc->txslot[txchan].mbsize += mlen; + +#ifdef EN_DEBUG + printf("%s: tx%d: VPI=%d, VCI=%d, FLAGS=0x%x, speed=0x%x\n", + sc->sc_dev.dv_xname, txchan, atm_vpi, atm_vci, atm_flags, + sc->txspeed[atm_vci]); + printf(" adjusted mlen=%d, mbsize=%d\n", mlen, + sc->txslot[txchan].mbsize); +#endif + + IF_ENQUEUE(&sc->txslot[txchan].q, m); + en_txdma(sc, txchan); + + } + /*NOTREACHED*/ +} + + +/* + * en_mfix: fix a stupid mbuf + */ + +#ifndef __FreeBSD__ + +STATIC int en_mfix(sc, mm, prev) + +struct en_softc *sc; +struct mbuf **mm, *prev; + +{ + struct mbuf *m, *new; + u_char *d, *cp; + int off; + struct mbuf *nxt; + + m = *mm; + + EN_COUNT(sc->mfix); /* count # of calls */ +#ifdef EN_DEBUG + printf("%s: mfix mbuf m_data=%p, m_len=%d\n", sc->sc_dev.dv_xname, + m->m_data, m->m_len); +#endif + + d = mtod(m, u_char *); + off = ((unsigned long) d) % sizeof(u_int32_t); + + if (off) { + if ((m->m_flags & M_EXT) == 0) { + bcopy(d, d - off, m->m_len); /* ALIGN! (with costly data copy...) */ + d -= off; + m->m_data = (caddr_t)d; + } else { + /* can't write to an M_EXT mbuf since it may be shared */ + MGET(new, M_DONTWAIT, MT_DATA); + if (!new) { + EN_COUNT(sc->mfixfail); + return(0); + } + MCLGET(new, M_DONTWAIT); + if ((new->m_flags & M_EXT) == 0) { + m_free(new); + EN_COUNT(sc->mfixfail); + return(0); + } + bcopy(d, new->m_data, m->m_len); /* ALIGN! (with costly data copy...) */ + new->m_len = m->m_len; + new->m_next = m->m_next; + if (prev) + prev->m_next = new; + m_free(m); + *mm = m = new; /* note: 'd' now invalid */ + } + } + + off = m->m_len % sizeof(u_int32_t); + if (off == 0) + return(1); + + d = mtod(m, u_char *) + m->m_len; + off = sizeof(u_int32_t) - off; + + nxt = m->m_next; + while (off--) { + for ( ; nxt != NULL && nxt->m_len == 0 ; nxt = nxt->m_next) + /*null*/; + if (nxt == NULL) { /* out of data, zero fill */ + *d++ = 0; + continue; /* next "off" */ + } + cp = mtod(nxt, u_char *); + *d++ = *cp++; + m->m_len++; + nxt->m_len--; + nxt->m_data = (caddr_t)cp; + } + return(1); +} + +#else /* __FreeBSD__ */ + +STATIC int en_makeexclusive(struct en_softc *, struct mbuf **, struct mbuf *); + +STATIC int en_makeexclusive(sc, mm, prev) + struct en_softc *sc; + struct mbuf **mm, *prev; +{ + struct mbuf *m, *new; + + m = *mm; + + if (m->m_flags & M_EXT) { + if (m->m_ext.ext_free) { + /* external buffer isn't an ordinary mbuf cluster! */ + printf("%s: mfix: special buffer! can't make a copy!\n", + sc->sc_dev.dv_xname); + return (0); + } + + if (mclrefcnt[mtocl(m->m_ext.ext_buf)] > 1) { + /* make a real copy of the M_EXT mbuf since it is shared */ + MGET(new, M_DONTWAIT, MT_DATA); + if (!new) { + EN_COUNT(sc->mfixfail); + return(0); + } + if (m->m_flags & M_PKTHDR) + M_COPY_PKTHDR(new, m); + MCLGET(new, M_DONTWAIT); + if ((new->m_flags & M_EXT) == 0) { + m_free(new); + EN_COUNT(sc->mfixfail); + return(0); + } + bcopy(m->m_data, new->m_data, m->m_len); + new->m_len = m->m_len; + new->m_next = m->m_next; + if (prev) + prev->m_next = new; + m_free(m); + *mm = new; + } + else { + /* the buffer is not shared, align the data offset using + this buffer. */ + u_char *d = mtod(m, u_char *); + int off = ((u_long)d) % sizeof(u_int32_t); + + if (off > 0) { + bcopy(d, d - off, m->m_len); + m->m_data = (caddr_t)d - off; + } + } + } + return (1); +} + +STATIC int en_mfix(sc, mm, prev) + +struct en_softc *sc; +struct mbuf **mm, *prev; + +{ + struct mbuf *m; + u_char *d, *cp; + int off; + struct mbuf *nxt; + + m = *mm; + + EN_COUNT(sc->mfix); /* count # of calls */ +#ifdef EN_DEBUG + printf("%s: mfix mbuf m_data=0x%x, m_len=%d\n", sc->sc_dev.dv_xname, + m->m_data, m->m_len); +#endif + + d = mtod(m, u_char *); + off = ((unsigned long) d) % sizeof(u_int32_t); + + if (off) { + if ((m->m_flags & M_EXT) == 0) { + bcopy(d, d - off, m->m_len); /* ALIGN! (with costly data copy...) */ + d -= off; + m->m_data = (caddr_t)d; + } else { + /* can't write to an M_EXT mbuf since it may be shared */ + if (en_makeexclusive(sc, &m, prev) == 0) + return (0); + *mm = m; /* note: 'd' now invalid */ + } + } + + off = m->m_len % sizeof(u_int32_t); + if (off == 0) + return(1); + + if (m->m_flags & M_EXT) { + /* can't write to an M_EXT mbuf since it may be shared */ + if (en_makeexclusive(sc, &m, prev) == 0) + return (0); + *mm = m; /* note: 'd' now invalid */ + } + + d = mtod(m, u_char *) + m->m_len; + off = sizeof(u_int32_t) - off; + + nxt = m->m_next; + while (off--) { + if (nxt != NULL && nxt->m_len == 0) { + /* remove an empty mbuf. this avoids odd byte padding to an empty + last mbuf. */ + m->m_next = nxt = m_free(nxt); + } + if (nxt == NULL) { /* out of data, zero fill */ + *d++ = 0; + continue; /* next "off" */ + } + cp = mtod(nxt, u_char *); + *d++ = *cp++; + m->m_len++; + nxt->m_len--; + nxt->m_data = (caddr_t)cp; + } + if (nxt != NULL && nxt->m_len == 0) + m->m_next = m_free(nxt); + return(1); +} + +#endif /* __FreeBSD__ */ + +/* + * en_txdma: start trasmit DMA, if possible + */ + +STATIC void en_txdma(sc, chan) + +struct en_softc *sc; +int chan; + +{ + struct mbuf *tmp; + struct atm_pseudohdr *ap; + struct en_launch launch; + int datalen = 0, dtqneed, len, ncells; + u_int8_t *cp; + struct ifnet *ifp = &sc->enif; + +#ifdef EN_DEBUG + printf("%s: tx%d: starting...\n", sc->sc_dev.dv_xname, chan); +#endif + + /* + * note: now that txlaunch handles non-word aligned/sized requests + * the only time you can safely set launch.nodma is if you've en_mfix()'d + * the mbuf chain. this happens only if EN_NOTXDMA || !en_dma. + */ + + launch.nodma = (EN_NOTXDMA || !en_dma); + +again: + + /* + * get an mbuf waiting for DMA + */ + + launch.t = sc->txslot[chan].q.ifq_head; /* peek at head of queue */ + + if (launch.t == NULL) { +#ifdef EN_DEBUG + printf("%s: tx%d: ...done!\n", sc->sc_dev.dv_xname, chan); +#endif + return; /* >>> exit here if no data waiting for DMA <<< */ + } + + /* + * get flags, vci + * + * note: launch.need = # bytes we need to get on the card + * dtqneed = # of DTQs we need for this packet + * launch.mlen = # of bytes in in mbuf chain (<= launch.need) + */ + + ap = mtod(launch.t, struct atm_pseudohdr *); + launch.atm_vci = ATM_PH_VCI(ap); + launch.atm_flags = ATM_PH_FLAGS(ap); + launch.aal = ((launch.atm_flags & ATM_PH_AAL5) != 0) ? + MID_TBD_AAL5 : MID_TBD_NOAAL5; + + /* + * XXX: have to recompute the length again, even though we already did + * it in en_start(). might as well compute dtqneed here as well, so + * this isn't that bad. + */ + + if ((launch.atm_flags & EN_OBHDR) == 0) { + dtqneed = 1; /* header still needs to be added */ + launch.need = MID_TBD_SIZE; /* not includeded with mbuf */ + } else { + dtqneed = 0; /* header on-board, dma with mbuf */ + launch.need = 0; + } + + launch.mlen = 0; + for (tmp = launch.t ; tmp != NULL ; tmp = tmp->m_next) { + len = tmp->m_len; + launch.mlen += len; + cp = mtod(tmp, u_int8_t *); + if (tmp == launch.t) { + len -= sizeof(struct atm_pseudohdr); /* don't count this! */ + cp += sizeof(struct atm_pseudohdr); + } + launch.need += len; + if (len == 0) + continue; /* atm_pseudohdr alone in first mbuf */ + + dtqneed += en_dqneed(sc, (caddr_t) cp, len, 1); + } + + if ((launch.need % sizeof(u_int32_t)) != 0) + dtqneed++; /* need DTQ to FLUSH internal buffer */ + + if ((launch.atm_flags & EN_OBTRL) == 0) { + if (launch.aal == MID_TBD_AAL5) { + datalen = launch.need - MID_TBD_SIZE; + launch.need += MID_PDU_SIZE; /* AAL5: need PDU tail */ + } + dtqneed++; /* need to work on the end a bit */ + } + + /* + * finish calculation of launch.need (need to figure out how much padding + * we will need). launch.need includes MID_TBD_SIZE, but we need to + * remove that to so we can round off properly. we have to add + * MID_TBD_SIZE back in after calculating ncells. + */ + + launch.need = roundup(launch.need - MID_TBD_SIZE, MID_ATMDATASZ); + ncells = launch.need / MID_ATMDATASZ; + launch.need += MID_TBD_SIZE; + + if (launch.need > EN_TXSZ * 1024) { + printf("%s: tx%d: packet larger than xmit buffer (%d > %d)\n", + sc->sc_dev.dv_xname, chan, launch.need, EN_TXSZ * 1024); + goto dequeue_drop; + } + + /* + * note: don't use the entire buffer space. if WRTX becomes equal + * to RDTX, the transmitter stops assuming the buffer is empty! --kjc + */ + if (launch.need >= sc->txslot[chan].bfree) { + EN_COUNT(sc->txoutspace); +#ifdef EN_DEBUG + printf("%s: tx%d: out of transmit space\n", sc->sc_dev.dv_xname, chan); +#endif + return; /* >>> exit here if out of obmem buffer space <<< */ + } + + /* + * ensure we have enough dtqs to go, if not, wait for more. + */ + + if (launch.nodma) { + dtqneed = 1; + } + if (dtqneed > sc->dtq_free) { + sc->need_dtqs = 1; + EN_COUNT(sc->txdtqout); +#ifdef EN_DEBUG + printf("%s: tx%d: out of transmit DTQs\n", sc->sc_dev.dv_xname, chan); +#endif + return; /* >>> exit here if out of dtqs <<< */ + } + + /* + * it is a go, commit! dequeue mbuf start working on the xfer. + */ + + IF_DEQUEUE(&sc->txslot[chan].q, tmp); + +#ifdef EN_DIAG + if (launch.t != tmp) + panic("en dequeue"); +#endif /* EN_DIAG */ + + /* + * launch! + */ + + EN_COUNT(sc->launch); + +#if defined(NENP) && NENP > 0 + /* Determine the outgoing ifnet */ + if (sc->vci2ifp[launch.atm_vci]) + ifp = sc->vci2ifp[launch.atm_vci]; + + /* + * If no match, use the default ifp in softc (ifp already set) + */ +#endif /* NENP > 0 */ + + ifp->if_opackets++; + + if ((launch.atm_flags & EN_OBHDR) == 0) { + EN_COUNT(sc->lheader); + /* store tbd1/tbd2 in host byte order */ + launch.tbd1 = MID_TBD_MK1(launch.aal, sc->txspeed[launch.atm_vci], ncells); + launch.tbd2 = MID_TBD_MK2(launch.atm_vci, 0, 0); + } + if ((launch.atm_flags & EN_OBTRL) == 0 && launch.aal == MID_TBD_AAL5) { + EN_COUNT(sc->ltail); + launch.pdu1 = MID_PDU_MK1(0, 0, datalen); /* host byte order */ + } + + en_txlaunch(sc, chan, &launch); + +#if NBPFILTER > 0 + /* + * If bpf is listening, let it see this packet. + * "Remove" the atm_pseudohdr and the TBD header (if any) + * before passing on & "replace" it after. + */ + if (ifp->if_bpf) { + int len = sizeof (struct atm_pseudohdr); + if (launch.atm_flags & EN_OBHDR) + len += MID_TBD_SIZE; + + launch.t->m_len -= len; + launch.t->m_data += len; + BPF_MTAP(ifp, launch.t); + launch.t->m_len += len; + launch.t->m_data -= len; + } +#endif /* NBPFILTER > 0 */ + + /* + * do some housekeeping and get the next packet + */ + + sc->txslot[chan].bfree -= launch.need; + IF_ENQUEUE(&sc->txslot[chan].indma, launch.t); + goto again; + + /* + * END of txdma loop! + */ + + /* + * error handles + */ + +dequeue_drop: + IF_DEQUEUE(&sc->txslot[chan].q, tmp); + + if (launch.t != tmp) + panic("en dequeue drop"); + m_freem(launch.t); + sc->txslot[chan].txbuf2small += 1; + sc->txslot[chan].mbsize -= launch.mlen; + goto again; +} + + +/* + * en_txlaunch: launch an mbuf into the dma pool! + */ + +STATIC void en_txlaunch(sc, chan, l) + +struct en_softc *sc; +int chan; +struct en_launch *l; + +{ + struct mbuf *tmp; + u_int32_t cur = sc->txslot[chan].cur, + start = sc->txslot[chan].start, + stop = sc->txslot[chan].stop, + dma, *data, *datastop, count, bcode; + int pad, addtail, need, len, needalign, cnt, end, mx; + + + /* + * vars: + * need = # bytes card still needs (decr. to zero) + * len = # of bytes left in current mbuf + * cur = our current pointer + * dma = last place we programmed into the DMA + * data = pointer into data area of mbuf that needs to go next + * cnt = # of bytes to transfer in this DTQ + * bcode/count = DMA burst code, and chip's version of cnt + * + * a single buffer can require up to 5 DTQs depending on its size + * and alignment requirements. the 5 possible requests are: + * [1] 1, 2, or 3 byte DMA to align src data pointer to word boundary + * [2] alburst DMA to align src data pointer to bestburstlen + * [3] 1 or more bestburstlen DMAs + * [4] clean up burst (to last word boundary) + * [5] 1, 2, or 3 byte final clean up DMA + */ + + need = l->need; + dma = cur; + addtail = (l->atm_flags & EN_OBTRL) == 0; /* add a tail? */ + +#ifdef EN_DIAG + if ((need - MID_TBD_SIZE) % MID_ATMDATASZ) + printf("%s: tx%d: bogus trasmit needs (%d)\n", sc->sc_dev.dv_xname, chan, + need); +#endif +#ifdef EN_DEBUG + printf("%s: tx%d: launch mbuf %p! cur=0x%x[%d], need=%d, addtail=%d\n", + sc->sc_dev.dv_xname, chan, l->t, cur, (cur-start)/4, need, addtail); + count = EN_READ(sc, MIDX_PLACE(chan)); + printf(" HW: base_address=0x%x, size=%d, read=%d, descstart=%d\n", + MIDX_BASE(count), MIDX_SZ(count), EN_READ(sc, MIDX_READPTR(chan)), + EN_READ(sc, MIDX_DESCSTART(chan))); +#endif + + /* + * do we need to insert the TBD by hand? + * note that tbd1/tbd2/pdu1 are in host byte order. + */ + + if ((l->atm_flags & EN_OBHDR) == 0) { +#ifdef EN_DEBUG + printf("%s: tx%d: insert header 0x%x 0x%x\n", sc->sc_dev.dv_xname, + chan, l->tbd1, l->tbd2); +#endif + EN_WRITE(sc, cur, l->tbd1); + EN_WRAPADD(start, stop, cur, 4); + EN_WRITE(sc, cur, l->tbd2); + EN_WRAPADD(start, stop, cur, 4); + need -= 8; + } + + /* + * now do the mbufs... + */ + + for (tmp = l->t ; tmp != NULL ; tmp = tmp->m_next) { + + /* get pointer to data and length */ + data = mtod(tmp, u_int32_t *); + len = tmp->m_len; + if (tmp == l->t) { + data += sizeof(struct atm_pseudohdr)/sizeof(u_int32_t); + len -= sizeof(struct atm_pseudohdr); + } + + /* now, determine if we should copy it */ + if (l->nodma || (len < EN_MINDMA && + (len % 4) == 0 && ((unsigned long) data % 4) == 0 && (cur % 4) == 0)) { + + /* + * roundup len: the only time this will change the value of len + * is when l->nodma is true, tmp is the last mbuf, and there is + * a non-word number of bytes to transmit. in this case it is + * safe to round up because we've en_mfix'd the mbuf (so the first + * byte is word aligned there must be enough free bytes at the end + * to round off to the next word boundary)... + */ + len = roundup(len, sizeof(u_int32_t)); + datastop = data + (len / sizeof(u_int32_t)); + /* copy loop: preserve byte order!!! use WRITEDAT */ + while (data != datastop) { + EN_WRITEDAT(sc, cur, *data); + data++; + EN_WRAPADD(start, stop, cur, 4); + } + need -= len; +#ifdef EN_DEBUG + printf("%s: tx%d: copied %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, len, need, cur); +#endif + continue; /* continue on to next mbuf */ + } + + /* going to do DMA, first make sure the dtq is in sync. */ + if (dma != cur) { + EN_DTQADD(sc, WORD_IDX(start,cur), chan, MIDDMA_JK, 0, 0, 0); +#ifdef EN_DEBUG + printf("%s: tx%d: dtq_sync: advance pointer to %d\n", + sc->sc_dev.dv_xname, chan, cur); +#endif + } + + /* + * if this is the last buffer, and it looks like we are going to need to + * flush the internal buffer, can we extend the length of this mbuf to + * avoid the FLUSH? + */ + + if (tmp->m_next == NULL) { + cnt = (need - len) % sizeof(u_int32_t); + if (cnt && M_TRAILINGSPACE(tmp) >= cnt) + len += cnt; /* pad for FLUSH */ + } + +#if !defined(MIDWAY_ENIONLY) + + /* + * the adaptec DMA engine is smart and handles everything for us. + */ + + if (sc->is_adaptec) { + /* need to DMA "len" bytes out to card */ + need -= len; + EN_WRAPADD(start, stop, cur, len); +#ifdef EN_DEBUG + printf("%s: tx%d: adp_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, len, need, cur); +#endif + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, len, chan, 0, vtophys(data), l->mlen, end); + if (end) + goto done; + dma = cur; /* update dma pointer */ + continue; + } +#endif /* !MIDWAY_ENIONLY */ + +#if !defined(MIDWAY_ADPONLY) + + /* + * the ENI DMA engine is not so smart and need more help from us + */ + + /* do we need to do a DMA op to align to word boundary? */ + needalign = (unsigned long) data % sizeof(u_int32_t); + if (needalign) { + EN_COUNT(sc->headbyte); + cnt = sizeof(u_int32_t) - needalign; + if (cnt == 2 && len >= cnt) { + count = 1; + bcode = MIDDMA_2BYTE; + } else { + cnt = min(cnt, len); /* prevent overflow */ + count = cnt; + bcode = MIDDMA_BYTE; + } + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: tx%d: small al_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, cnt, need, cur); +#endif + len -= cnt; + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, count, chan, bcode, vtophys(data), l->mlen, end); + if (end) + goto done; + data = (u_int32_t *) ((u_char *)data + cnt); + } + + /* do we need to do a DMA op to align? */ + if (sc->alburst && + (needalign = (((unsigned long) data) & sc->bestburstmask)) != 0 + && len >= sizeof(u_int32_t)) { + cnt = sc->bestburstlen - needalign; + mx = len & ~(sizeof(u_int32_t)-1); /* don't go past end */ + if (cnt > mx) { + cnt = mx; + count = cnt / sizeof(u_int32_t); + bcode = MIDDMA_WORD; + } else { + count = cnt / sizeof(u_int32_t); + bcode = en_dmaplan[count].bcode; + count = cnt >> en_dmaplan[count].divshift; + } + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: tx%d: al_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, cnt, need, cur); +#endif + len -= cnt; + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, count, chan, bcode, vtophys(data), l->mlen, end); + if (end) + goto done; + data = (u_int32_t *) ((u_char *)data + cnt); + } + + /* do we need to do a max-sized burst? */ + if (len >= sc->bestburstlen) { + count = len >> sc->bestburstshift; + cnt = count << sc->bestburstshift; + bcode = sc->bestburstcode; + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: tx%d: best_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, cnt, need, cur); +#endif + len -= cnt; + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, count, chan, bcode, vtophys(data), l->mlen, end); + if (end) + goto done; + data = (u_int32_t *) ((u_char *)data + cnt); + } + + /* do we need to do a cleanup burst? */ + cnt = len & ~(sizeof(u_int32_t)-1); + if (cnt) { + count = cnt / sizeof(u_int32_t); + bcode = en_dmaplan[count].bcode; + count = cnt >> en_dmaplan[count].divshift; + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: tx%d: cleanup_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, cnt, need, cur); +#endif + len -= cnt; + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, count, chan, bcode, vtophys(data), l->mlen, end); + if (end) + goto done; + data = (u_int32_t *) ((u_char *)data + cnt); + } + + /* any word fragments left? */ + if (len) { + EN_COUNT(sc->tailbyte); + if (len == 2) { + count = 1; + bcode = MIDDMA_2BYTE; /* use 2byte mode */ + } else { + count = len; + bcode = MIDDMA_BYTE; /* use 1 byte mode */ + } + need -= len; + EN_WRAPADD(start, stop, cur, len); +#ifdef EN_DEBUG + printf("%s: tx%d: byte cleanup_dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, len, need, cur); +#endif + end = (need == 0) ? MID_DMA_END : 0; + EN_DTQADD(sc, count, chan, bcode, vtophys(data), l->mlen, end); + if (end) + goto done; + } + + dma = cur; /* update dma pointer */ +#endif /* !MIDWAY_ADPONLY */ + + } /* next mbuf, please */ + + /* + * all mbuf data has been copied out to the obmem (or set up to be DMAd). + * if the trailer or padding needs to be put in, do it now. + * + * NOTE: experimental results reveal the following fact: + * if you DMA "X" bytes to the card, where X is not a multiple of 4, + * then the card will internally buffer the last (X % 4) bytes (in + * hopes of getting (4 - (X % 4)) more bytes to make a complete word). + * it is imporant to make sure we don't leave any important data in + * this internal buffer because it is discarded on the last (end) DTQ. + * one way to do this is to DMA in (4 - (X % 4)) more bytes to flush + * the darn thing out. + */ + + if (addtail) { + + pad = need % sizeof(u_int32_t); + if (pad) { + /* + * FLUSH internal data buffer. pad out with random data from the front + * of the mbuf chain... + */ + bcode = (sc->is_adaptec) ? 0 : MIDDMA_BYTE; + EN_COUNT(sc->tailflush); + EN_WRAPADD(start, stop, cur, pad); + EN_DTQADD(sc, pad, chan, bcode, vtophys(l->t->m_data), 0, 0); + need -= pad; +#ifdef EN_DEBUG + printf("%s: tx%d: pad/FLUSH dma %d bytes (%d left, cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, pad, need, cur); +#endif + } + + /* copy data */ + pad = need / sizeof(u_int32_t); /* round *down* */ + if (l->aal == MID_TBD_AAL5) + pad -= 2; +#ifdef EN_DEBUG + printf("%s: tx%d: padding %d bytes (cur now 0x%x)\n", + sc->sc_dev.dv_xname, chan, pad * sizeof(u_int32_t), cur); +#endif + while (pad--) { + EN_WRITEDAT(sc, cur, 0); /* no byte order issues with zero */ + EN_WRAPADD(start, stop, cur, 4); + } + if (l->aal == MID_TBD_AAL5) { + EN_WRITE(sc, cur, l->pdu1); /* in host byte order */ + EN_WRAPADD(start, stop, cur, 8); + } + } + + if (addtail || dma != cur) { + /* write final descritor */ + EN_DTQADD(sc, WORD_IDX(start,cur), chan, MIDDMA_JK, 0, + l->mlen, MID_DMA_END); + /* dma = cur; */ /* not necessary since we are done */ + } + +done: + /* update current pointer */ + sc->txslot[chan].cur = cur; +#ifdef EN_DEBUG + printf("%s: tx%d: DONE! cur now = 0x%x\n", + sc->sc_dev.dv_xname, chan, cur); +#endif + + return; +} + + +/* + * interrupt handler + */ + +EN_INTR_TYPE en_intr(arg) + +void *arg; + +{ + int index; + int txchan; + u_int16_t atm_vci; + struct en_softc *sc = (struct en_softc *) arg; + struct mbuf *m; + struct atm_pseudohdr ah; + struct ifnet *ifp = 0; + u_int32_t reg, kick, val, mask, chip, vci, slot, dtq, drq; + int lcv, idx, need_softserv = 0; + + reg = EN_READ(sc, MID_INTACK); + + if ((reg & MID_INT_ANY) == 0) + EN_INTR_RET(0); /* not us */ + +#ifdef EN_DEBUG + printf("%s: interrupt=0x%b\n", sc->sc_dev.dv_xname, reg, MID_INTBITS); +#endif + + /* + * unexpected errors that need a reset + */ + + if ((reg & (MID_INT_IDENT|MID_INT_LERR|MID_INT_DMA_ERR|MID_INT_SUNI)) != 0) { + printf("%s: unexpected interrupt=0x%b, resetting card\n", + sc->sc_dev.dv_xname, reg, MID_INTBITS); +#ifdef EN_DEBUG +#ifdef DDB + Debugger(); +#endif /* DDB */ + sc->enif.if_flags &= ~IFF_RUNNING; /* FREEZE! */ +#if defined(NENP) && NENP > 0 + FOREACHIFP(ifp) { + if (!strcmp(ifp->if_name, en_pif_name[sc->enif.if_unit])) { + ifp->if_flags &= ~IFF_RUNNING; + } + } +#endif /* NENP */ + +#else + en_reset(sc); + en_init(sc); +#endif + EN_INTR_RET(1); /* for us */ + } + + /******************* + * xmit interrupts * + ******************/ + + kick = 0; /* bitmask of channels to kick */ + if (reg & MID_INT_TX) { /* TX done! */ + + /* + * check for tx complete, if detected then this means that some space + * has come free on the card. we must account for it and arrange to + * kick the channel to life (in case it is stalled waiting on the card). + */ + for (mask = 1, lcv = 0 ; lcv < EN_NTX ; lcv++, mask = mask * 2) { + if (reg & MID_TXCHAN(lcv)) { + kick = kick | mask; /* want to kick later */ + val = EN_READ(sc, MIDX_READPTR(lcv)); /* current read pointer */ + val = (val * sizeof(u_int32_t)) + sc->txslot[lcv].start; + /* convert to offset */ + if (val > sc->txslot[lcv].cur) + sc->txslot[lcv].bfree = val - sc->txslot[lcv].cur; + else + sc->txslot[lcv].bfree = (val + (EN_TXSZ*1024)) - sc->txslot[lcv].cur; +#ifdef EN_DEBUG + printf("%s: tx%d: trasmit done. %d bytes now free in buffer\n", + sc->sc_dev.dv_xname, lcv, sc->txslot[lcv].bfree); +#endif + } + } + } + + if (reg & MID_INT_DMA_TX) { /* TX DMA done! */ + + /* + * check for TX DMA complete, if detected then this means that some DTQs + * are now free. it also means some indma mbufs can be freed. + * if we needed DTQs, kick all channels. + */ + val = EN_READ(sc, MID_DMA_RDTX); /* chip's current location */ + idx = MID_DTQ_A2REG(sc->dtq_chip);/* where we last saw chip */ + if (sc->need_dtqs) { + kick = MID_NTX_CH - 1; /* assume power of 2, kick all! */ + sc->need_dtqs = 0; /* recalculated in "kick" loop below */ +#ifdef EN_DEBUG + printf("%s: cleared need DTQ condition\n", sc->sc_dev.dv_xname); +#endif + } + while (idx != val) { + sc->dtq_free++; + if ((dtq = sc->dtq[idx]) != 0) { + sc->dtq[idx] = 0; /* don't forget to zero it out when done */ + slot = EN_DQ_SLOT(dtq); + + IF_DEQUEUE(&sc->txslot[slot].indma, m); + + if (!m) panic("enintr: dtqsync"); + sc->txslot[slot].mbsize -= EN_DQ_LEN(dtq); + /* printf("mbsize is now %u\n",sc->txslot[slot].mbsize); */ + /* if there's stuff in the send q, let's get it */ + /* which send q though? */ + atm_vci = sc->txslot[slot].vci_assgn; + for (index = 0; index <= NENP; index++) { + if (sc->vctoif[index].vci == atm_vci) { + break; + } + } + +#ifdef EN_DEBUG + printf("%s: tx%d: free %d dma bytes, mbsize now %d\n", + sc->sc_dev.dv_xname, slot, EN_DQ_LEN(dtq), + sc->txslot[slot].mbsize); +#endif + m_freem(m); + } + EN_WRAPADD(0, MID_DTQ_N, idx, 1); + } ; + sc->dtq_chip = MID_DTQ_REG2A(val); /* sync softc */ + } + + + /* + * kick xmit channels as needed + */ + + if (kick) { +#ifdef EN_DEBUG + printf("%s: tx kick mask = 0x%x\n", sc->sc_dev.dv_xname, kick); +#endif + for (mask = 1, lcv = 0 ; lcv < EN_NTX ; lcv++, mask = mask * 2) { + if ((kick & mask) && sc->txslot[lcv].q.ifq_head) { + en_txdma(sc, lcv); /* kick it! */ + } + } /* for each slot */ + } /* if kick */ + + /* + * It is possible at this stage that we can dequeue + * in particular, if channels were kicked to do + * en_txdma() + */ + + /******************* + * recv interrupts * + ******************/ + + /* + * check for RX DMA complete, and pass the data "upstairs" + */ + + if (reg & MID_INT_DMA_RX) { + val = EN_READ(sc, MID_DMA_RDRX); /* chip's current location */ + idx = MID_DRQ_A2REG(sc->drq_chip);/* where we last saw chip */ + while (idx != val) { + sc->drq_free++; + if ((drq = sc->drq[idx]) != 0) { + sc->drq[idx] = 0; /* don't forget to zero it out when done */ + slot = EN_DQ_SLOT(drq); + if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */ + m = NULL; + } else { + IF_DEQUEUE(&sc->rxslot[slot].indma, m); + if (!m) { + printf("%s: lost mbuf in slot %d!\n", sc->sc_dev.dv_xname, slot); + panic("enintr: drqsync"); + } + } + /* do something with this mbuf */ + if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) { /* drain? */ + if (m) + m_freem(m); + vci = sc->rxslot[slot].atm_vci; + if (sc->rxslot[slot].indma.ifq_head == NULL && + sc->rxslot[slot].q.ifq_head == NULL && + (EN_READ(sc, MID_VC(vci)) & MIDV_INSERVICE) == 0 && + (sc->rxslot[slot].oth_flags & ENOTHER_SWSL) == 0) { + sc->rxslot[slot].oth_flags = ENOTHER_FREE; /* done drain */ + sc->rxslot[slot].atm_vci = RX_NONE; + sc->rxvc2slot[vci] = RX_NONE; +#ifdef EN_DEBUG + printf("%s: rx%d: VCI %d now free\n", sc->sc_dev.dv_xname, + slot, vci); +#endif + } + } else if (m != NULL) { + ATM_PH_FLAGS(&ah) = sc->rxslot[slot].atm_flags; + ATM_PH_VPI(&ah) = 0; + ATM_PH_SETVCI(&ah, sc->rxslot[slot].atm_vci); +#ifdef EN_DEBUG + printf("%s: rx%d: rxvci%d: atm_input, mbuf %p, len %d, hand %p\n", + sc->sc_dev.dv_xname, slot, sc->rxslot[slot].atm_vci, m, + EN_DQ_LEN(drq), sc->rxslot[slot].rxhand); +#endif + /* Determine the incoming interface */ +#if NENP > 0 + ifp = (sc->vci2ifp[sc->rxslot[slot].atm_vci]) ? + sc->vci2ifp[sc->rxslot[slot].atm_vci] : &sc->enif; +#else + ifp= &sc->enif; +#endif /* NENP > 0 */ + + ifp->if_ipackets++; + + /* set the rcvif of the mbuf point to ifp */ + if ((m->m_flags & M_PKTHDR) == M_PKTHDR) { + m->m_pkthdr.rcvif = ifp; + } + +#if NBPFILTER > 0 + if (ifp->if_bpf) + BPF_MTAP(ifp, m); +#endif + + atm_input(ifp, &ah, m, sc->rxslot[slot].rxhand); + } + + } + EN_WRAPADD(0, MID_DRQ_N, idx, 1); + }; + sc->drq_chip = MID_DRQ_REG2A(val); /* sync softc */ + + if (sc->need_drqs) { /* true if we had a DRQ shortage */ + need_softserv = 1; + sc->need_drqs = 0; +#ifdef EN_DEBUG + printf("%s: cleared need DRQ condition\n", sc->sc_dev.dv_xname); +#endif + } + } + + /* + * handle service interrupts + */ + + if (reg & MID_INT_SERVICE) { + chip = MID_SL_REG2A(EN_READ(sc, MID_SERV_WRITE)); + + while (sc->hwslistp != chip) { + + /* fetch and remove it from hardware service list */ + vci = EN_READ(sc, sc->hwslistp); + EN_WRAPADD(MID_SLOFF, MID_SLEND, sc->hwslistp, 4);/* advance hw ptr */ + slot = sc->rxvc2slot[vci]; + if (slot == RX_NONE) { +#ifdef EN_DEBUG + printf("%s: unexpected rx interrupt on VCI %d\n", + sc->sc_dev.dv_xname, vci); +#endif + EN_WRITE(sc, MID_VC(vci), MIDV_TRASH); /* rx off, damn it! */ + continue; /* next */ + } + EN_WRITE(sc, MID_VC(vci), sc->rxslot[slot].mode); /* remove from hwsl */ + EN_COUNT(sc->hwpull); + +#ifdef EN_DEBUG + printf("%s: pulled VCI %d off hwslist\n", sc->sc_dev.dv_xname, vci); +#endif + + /* add it to the software service list (if needed) */ + if ((sc->rxslot[slot].oth_flags & ENOTHER_SWSL) == 0) { + EN_COUNT(sc->swadd); + need_softserv = 1; + sc->rxslot[slot].oth_flags |= ENOTHER_SWSL; + sc->swslist[sc->swsl_tail] = slot; + EN_WRAPADD(0, MID_SL_N, sc->swsl_tail, 1); + sc->swsl_size++; +#ifdef EN_DEBUG + printf("%s: added VCI %d to swslist\n", sc->sc_dev.dv_xname, vci); +#endif + } + } ; + } + + /* + * now service (function too big to include here) + */ + + if (need_softserv) + en_service(sc); + + + /* + * keep our stats + */ + + if (reg & MID_INT_DMA_OVR) { + EN_COUNT(sc->dmaovr); +#ifdef EN_DEBUG + printf("%s: MID_INT_DMA_OVR\n", sc->sc_dev.dv_xname); +#endif + } + reg = EN_READ(sc, MID_STAT); +#ifdef EN_STAT + sc->otrash += MID_OTRASH(reg); + sc->vtrash += MID_VTRASH(reg); +#endif + + /* + * kjc's driver starts i/fs in a round robin fashion, which is more fair. + * Do something similar. Also should this be done only when kick'ed? + * XXX skb + */ +#if defined(NENP) && NENP > 0 + ifp = 0; + txchan = 0; + for (lcv = 0; lcv <= NENP; lcv++) { + ifp = sc->vctoif[lcv].ifp; + if (ifp != NULL) { + txchan = sc->txvc2slot[sc->vctoif[lcv].vci]; +#ifdef ALTQ + if (ALTQ_IS_ON(ifp)) { + if ( (sc->txslot[txchan].mbsize < EN_TXHIWAT) && + (*ifp->if_altqdequeue)(ifp, ALTDQ_PEEK) != NULL ) + en_start(ifp); + } else { +#endif /* ALTQ */ + if ((sc->vctoif[lcv].ifp->if_snd.ifq_head != NULL) && + (sc->txslot[txchan].mbsize < EN_TXHIWAT)) + en_start(ifp); +#ifdef ALTQ + } +#endif /* ALTQ */ + } + } +#endif /* NENP */ + + EN_INTR_RET(1); /* for us */ + +} + + +/* + * en_service: handle a service interrupt + * + * Q: why do we need a software service list? + * + * A: if we remove a VCI from the hardware list and we find that we are + * out of DRQs we must defer processing until some DRQs become free. + * so we must remember to look at this RX VCI/slot later, but we can't + * put it back on the hardware service list (since that isn't allowed). + * so we instead save it on the software service list. it would be nice + * if we could peek at the VCI on top of the hwservice list without removing + * it, however this leads to a race condition: if we peek at it and + * decide we are done with it new data could come in before we have a + * chance to remove it from the hwslist. by the time we get it out of + * the list the interrupt for the new data will be lost. oops! + * + */ + +STATIC void en_service(sc) + +struct en_softc *sc; + +{ + struct mbuf *m, *tmp; + u_int32_t cur, dstart, rbd, pdu, *sav, dma, bcode, count, *data, *datastop; + u_int32_t start, stop, cnt, needalign; + int slot, raw, aal5, llc, vci, fill, mlen, tlen, drqneed, need, needfill, end; + + aal5 = 0; /* Silence gcc */ +next_vci: + if (sc->swsl_size == 0) { +#ifdef EN_DEBUG + printf("%s: en_service done\n", sc->sc_dev.dv_xname); +#endif + return; /* >>> exit here if swsl now empty <<< */ + } + + /* + * get slot/vci to service + */ + + slot = sc->swslist[sc->swsl_head]; + vci = sc->rxslot[slot].atm_vci; +#ifdef EN_DIAG + if (sc->rxvc2slot[vci] != slot) panic("en_service rx slot/vci sync"); +#endif + + /* + * determine our mode and if we've got any work to do + */ + + raw = sc->rxslot[slot].oth_flags & ENOTHER_RAW; + start= sc->rxslot[slot].start; + stop= sc->rxslot[slot].stop; + cur = sc->rxslot[slot].cur; + +#ifdef EN_DEBUG + printf("%s: rx%d: service vci=%d raw=%d start/stop/cur=0x%x 0x%x 0x%x\n", + sc->sc_dev.dv_xname, slot, vci, raw, start, stop, cur); +#endif + +same_vci: + dstart = MIDV_DSTART(EN_READ(sc, MID_DST_RP(vci))); + dstart = (dstart * sizeof(u_int32_t)) + start; + + /* check to see if there is any data at all */ + if (dstart == cur) { +defer: /* defer processing */ + EN_WRAPADD(0, MID_SL_N, sc->swsl_head, 1); + sc->rxslot[slot].oth_flags &= ~ENOTHER_SWSL; + sc->swsl_size--; + /* >>> remove from swslist <<< */ +#ifdef EN_DEBUG + printf("%s: rx%d: remove vci %d from swslist\n", + sc->sc_dev.dv_xname, slot, vci); +#endif + goto next_vci; + } + + /* + * figure out how many bytes we need + * [mlen = # bytes to go in mbufs, fill = # bytes to dump (MIDDMA_JK)] + */ + + if (raw) { + + /* raw mode (aka boodi mode) */ + fill = 0; + if (dstart > cur) + mlen = dstart - cur; + else + mlen = (dstart + (EN_RXSZ*1024)) - cur; + + if (mlen < sc->rxslot[slot].raw_threshold) + goto defer; /* too little data to deal with */ + + } else { + + /* normal mode */ + aal5 = (sc->rxslot[slot].atm_flags & ATM_PH_AAL5); + llc = (aal5 && (sc->rxslot[slot].atm_flags & ATM_PH_LLCSNAP)) ? 1 : 0; + rbd = EN_READ(sc, cur); + if (MID_RBD_ID(rbd) != MID_RBD_STDID) + panic("en_service: id mismatch\n"); + + if (rbd & MID_RBD_T) { + mlen = 0; /* we've got trash */ + fill = MID_RBD_SIZE; + EN_COUNT(sc->ttrash); + } else if (!aal5) { + mlen = MID_RBD_SIZE + MID_CHDR_SIZE + MID_ATMDATASZ; /* 1 cell (ick!) */ + fill = 0; + } else { + tlen = (MID_RBD_CNT(rbd) * MID_ATMDATASZ) + MID_RBD_SIZE; + pdu = cur + tlen - MID_PDU_SIZE; + if (pdu >= stop) + pdu -= (EN_RXSZ*1024); + pdu = EN_READ(sc, pdu); /* get PDU in correct byte order */ + fill = tlen - MID_RBD_SIZE - MID_PDU_LEN(pdu); + if (fill < 0 || (rbd & MID_RBD_CRCERR) != 0) { +#ifdef EN_DEBUG + printf("%s: invalid AAL5 PDU length or CRC detected, dropping frame from vci 0x%x\n", + sc->sc_dev.dv_xname, vci); + printf("%s: got %d cells (%d bytes), AAL5 len is %d bytes (pdu=0x%x)\n", + sc->sc_dev.dv_xname, MID_RBD_CNT(rbd), tlen - MID_RBD_SIZE, + MID_PDU_LEN(pdu), pdu); +#endif /* EN_DEBUG */ + + /* Update some stats: we use if_ierrors */ +#if defined(NENP) && NENP > 0 + if (sc->vci2ifp[vci]) + sc->vci2ifp[vci]->if_ierrors++; + else +#endif + sc->enif.if_ierrors++; + fill = tlen; + } + mlen = tlen - fill; + } + + } + + /* + * now allocate mbufs for mlen bytes of data, if out of mbufs, trash all + * + * notes: + * 1. it is possible that we've already allocated an mbuf for this pkt + * but ran out of DRQs, in which case we saved the allocated mbuf on + * "q". + * 2. if we save an mbuf in "q" we store the "cur" (pointer) in the front + * of the mbuf as an identity (that we can check later), and we also + * store drqneed (so we don't have to recompute it). + * 3. after this block of code, if m is still NULL then we ran out of mbufs + */ + + m = sc->rxslot[slot].q.ifq_head; + drqneed = 1; + if (m) { + sav = mtod(m, u_int32_t *); + if (sav[0] != cur) { +#ifdef EN_DEBUG + printf("%s: rx%d: q'ed mbuf %p not ours\n", + sc->sc_dev.dv_xname, slot, m); +#endif + m = NULL; /* wasn't ours */ + EN_COUNT(sc->rxqnotus); + } else { + EN_COUNT(sc->rxqus); + IF_DEQUEUE(&sc->rxslot[slot].q, m); + drqneed = sav[1]; +#ifdef EN_DEBUG + printf("%s: rx%d: recovered q'ed mbuf %p (drqneed=%d)\n", + sc->sc_dev.dv_xname, slot, m, drqneed); +#endif + } + } + + if (mlen != 0 && m == NULL) { + m = en_mget(sc, mlen, &drqneed); /* allocate! */ + if (m == NULL) { + fill += mlen; + mlen = 0; + EN_COUNT(sc->rxmbufout); +#ifdef EN_DEBUG + printf("%s: rx%d: out of mbufs\n", sc->sc_dev.dv_xname, slot); +#endif + } +#ifdef EN_DEBUG + printf("%s: rx%d: allocate mbuf %p, mlen=%d, drqneed=%d\n", + sc->sc_dev.dv_xname, slot, m, mlen, drqneed); +#endif + } + +#ifdef EN_DEBUG + printf("%s: rx%d: VCI %d, mbuf_chain %p, mlen %d, fill %d\n", + sc->sc_dev.dv_xname, slot, vci, m, mlen, fill); +#endif + + /* + * now check to see if we've got the DRQs needed. if we are out of + * DRQs we must quit (saving our mbuf, if we've got one). + */ + + needfill = (fill) ? 1 : 0; + if (drqneed + needfill > sc->drq_free) { + sc->need_drqs = 1; /* flag condition */ + if (m == NULL) { + EN_COUNT(sc->rxoutboth); +#ifdef EN_DEBUG + printf("%s: rx%d: out of DRQs *and* mbufs!\n", sc->sc_dev.dv_xname, slot); +#endif + return; /* >>> exit here if out of both mbufs and DRQs <<< */ + } + sav = mtod(m, u_int32_t *); + sav[0] = cur; + sav[1] = drqneed; + IF_ENQUEUE(&sc->rxslot[slot].q, m); + EN_COUNT(sc->rxdrqout); +#ifdef EN_DEBUG + printf("%s: rx%d: out of DRQs\n", sc->sc_dev.dv_xname, slot); +#endif + return; /* >>> exit here if out of DRQs <<< */ + } + + /* + * at this point all resources have been allocated and we are commited + * to servicing this slot. + * + * dma = last location we told chip about + * cur = current location + * mlen = space in the mbuf we want + * need = bytes to xfer in (decrs to zero) + * fill = how much fill we need + * tlen = how much data to transfer to this mbuf + * cnt/bcode/count = + * + * 'needfill' not used after this point + */ + + dma = cur; /* dma = last location we told chip about */ + need = roundup(mlen, sizeof(u_int32_t)); + fill = fill - (need - mlen); /* note: may invalidate 'needfill' */ + + for (tmp = m ; tmp != NULL && need > 0 ; tmp = tmp->m_next) { + tlen = roundup(tmp->m_len, sizeof(u_int32_t)); /* m_len set by en_mget */ + data = mtod(tmp, u_int32_t *); + +#ifdef EN_DEBUG + printf("%s: rx%d: load mbuf %p, m_len=%d, m_data=%p, tlen=%d\n", + sc->sc_dev.dv_xname, slot, tmp, tmp->m_len, tmp->m_data, tlen); +#endif + + /* copy data */ + if (EN_NORXDMA || !en_dma || tlen < EN_MINDMA) { + datastop = (u_int32_t *)((u_char *) data + tlen); + /* copy loop: preserve byte order!!! use READDAT */ + while (data != datastop) { + *data = EN_READDAT(sc, cur); + data++; + EN_WRAPADD(start, stop, cur, 4); + } + need -= tlen; +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: copied %d bytes (%d left)\n", + sc->sc_dev.dv_xname, slot, vci, tlen, need); +#endif + continue; + } + + /* DMA data (check to see if we need to sync DRQ first) */ + if (dma != cur) { + EN_DRQADD(sc, WORD_IDX(start,cur), vci, MIDDMA_JK, 0, 0, 0, 0); +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: drq_sync: advance pointer to %d\n", + sc->sc_dev.dv_xname, slot, vci, cur); +#endif + } + +#if !defined(MIDWAY_ENIONLY) + + /* + * the adaptec DMA engine is smart and handles everything for us. + */ + + if (sc->is_adaptec) { + need -= tlen; + EN_WRAPADD(start, stop, cur, tlen); +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: adp_dma %d bytes (%d left)\n", + sc->sc_dev.dv_xname, slot, vci, tlen, need); +#endif + end = (need == 0 && !fill) ? MID_DMA_END : 0; + EN_DRQADD(sc, tlen, vci, 0, vtophys(data), mlen, slot, end); + if (end) + goto done; + dma = cur; /* update dma pointer */ + continue; + } +#endif /* !MIDWAY_ENIONLY */ + + +#if !defined(MIDWAY_ADPONLY) + + /* + * the ENI DMA engine is not so smart and need more help from us + */ + + /* do we need to do a DMA op to align? */ + if (sc->alburst && + (needalign = (((unsigned long) data) & sc->bestburstmask)) != 0) { + cnt = sc->bestburstlen - needalign; + if (cnt > tlen) { + cnt = tlen; + count = cnt / sizeof(u_int32_t); + bcode = MIDDMA_WORD; + } else { + count = cnt / sizeof(u_int32_t); + bcode = en_dmaplan[count].bcode; + count = cnt >> en_dmaplan[count].divshift; + } + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: al_dma %d bytes (%d left)\n", + sc->sc_dev.dv_xname, slot, vci, cnt, need); +#endif + tlen -= cnt; + end = (need == 0 && !fill) ? MID_DMA_END : 0; + EN_DRQADD(sc, count, vci, bcode, vtophys(data), mlen, slot, end); + if (end) + goto done; + data = (u_int32_t *)((u_char *) data + cnt); + } + + /* do we need a max-sized burst? */ + if (tlen >= sc->bestburstlen) { + count = tlen >> sc->bestburstshift; + cnt = count << sc->bestburstshift; + bcode = sc->bestburstcode; + need -= cnt; + EN_WRAPADD(start, stop, cur, cnt); +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: best_dma %d bytes (%d left)\n", + sc->sc_dev.dv_xname, slot, vci, cnt, need); +#endif + tlen -= cnt; + end = (need == 0 && !fill) ? MID_DMA_END : 0; + EN_DRQADD(sc, count, vci, bcode, vtophys(data), mlen, slot, end); + if (end) + goto done; + data = (u_int32_t *)((u_char *) data + cnt); + } + + /* do we need to do a cleanup burst? */ + if (tlen) { + count = tlen / sizeof(u_int32_t); + bcode = en_dmaplan[count].bcode; + count = tlen >> en_dmaplan[count].divshift; + need -= tlen; + EN_WRAPADD(start, stop, cur, tlen); +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: cleanup_dma %d bytes (%d left)\n", + sc->sc_dev.dv_xname, slot, vci, tlen, need); +#endif + end = (need == 0 && !fill) ? MID_DMA_END : 0; + EN_DRQADD(sc, count, vci, bcode, vtophys(data), mlen, slot, end); + if (end) + goto done; + } + + dma = cur; /* update dma pointer */ + +#endif /* !MIDWAY_ADPONLY */ + + } + + /* skip the end */ + if (fill || dma != cur) { +#ifdef EN_DEBUG + if (fill) + printf("%s: rx%d: vci%d: skipping %d bytes of fill\n", + sc->sc_dev.dv_xname, slot, vci, fill); + else + printf("%s: rx%d: vci%d: syncing chip from 0x%x to 0x%x [cur]\n", + sc->sc_dev.dv_xname, slot, vci, dma, cur); +#endif + EN_WRAPADD(start, stop, cur, fill); + EN_DRQADD(sc, WORD_IDX(start,cur), vci, MIDDMA_JK, 0, mlen, + slot, MID_DMA_END); + /* dma = cur; */ /* not necessary since we are done */ + } + + /* + * done, remove stuff we don't want to pass up: + * raw mode (boodi mode): pass everything up for later processing + * aal5: remove RBD + * aal0: remove RBD + cell header + */ + +done: + if (m) { + if (!raw) { + cnt = MID_RBD_SIZE; + if (!aal5) cnt += MID_CHDR_SIZE; + m->m_len -= cnt; /* chop! */ + m->m_pkthdr.len -= cnt; + m->m_data += cnt; + } + IF_ENQUEUE(&sc->rxslot[slot].indma, m); + } + sc->rxslot[slot].cur = cur; /* update master copy of 'cur' */ + +#ifdef EN_DEBUG + printf("%s: rx%d: vci%d: DONE! cur now =0x%x\n", + sc->sc_dev.dv_xname, slot, vci, cur); +#endif + + goto same_vci; /* get next packet in this slot */ +} + +/* KENG >> */ +/* #ifdef EN_DDBHOOK commented out */ +/* KENG << */ + +/* + * functions we can call from ddb + */ + +/* + * en_dump: dump the state + */ + +/* the following are defined elsewhere so that a user level program can access it */ + +#if 0 + +#define END_SWSL 0x00000040 /* swsl state */ +#define END_DRQ 0x00000020 /* drq state */ +#define END_DTQ 0x00000010 /* dtq state */ +#define END_RX 0x00000008 /* rx state */ +#define END_TX 0x00000004 /* tx state */ +#define END_MREGS 0x00000002 /* registers */ +#define END_STATS 0x00000001 /* dump stats */ +#define END_BITS "\20\7SWSL\6DRQ\5DTQ\4RX\3TX\2MREGS\1STATS" + +#endif /* 0 */ + +/* KENG >> */ +/* int en_dump(unit, level) */ +/* int unit, level; */ + +int en_dump(struct ifnet* ifp ,struct atm_stat *atmstat) +/* KENG << */ +{ + struct en_softc *sc; + /* int lcv, cnt, slot; */ + int cnt, slot, level; + u_int32_t ptr, reg; + + level = atmstat->level; + /* KENG >> */ + + /* + for (lcv = 0 ; lcv < en_cd.cd_ndevs ; lcv++) { + sc = (struct en_softc *) en_cd.cd_devs[lcv]; + if (sc == NULL) continue; + if (unit != -1 && unit != lcv) + continue; + */ + + /* get sc */ + sc = (struct en_softc*)ifp->if_softc; + + + + if (atmstat->reset == 1) { + for (slot = 0; slot < EN_NTX; slot++) { + sc->txslot[slot].txmbovr = 0; + sc->txslot[slot].txbuf2small = 0; + } + sc->vtrash = sc->otrash = sc->mfix = sc->txmbovr = sc->dmaovr = 0; + sc->txoutspace = sc->txdtqout = sc->launch = sc->lheader = sc->ltail = 0; + sc->hwpull = sc->swadd = sc->rxqnotus = sc->rxqus = sc->rxoutboth = 0; + sc->rxdrqout = sc->ttrash = sc->rxmbufout = sc->mfixfail = 0; + sc->headbyte = sc->tailbyte = sc->tailflush = 0; + } + + + /* KENG << */ +#ifdef EN_DEBUG + printf("dumping device %s at level 0x%b\n", sc->sc_dev.dv_xname, level, + END_BITS); +#endif + if (sc->dtq_us == 0) { + printf("\n"); + } + + if (level & END_STATS) { + /* KENG >> */ + atmstat->mfix = sc->mfix; + atmstat->mfixfail = sc->mfixfail; + atmstat->headbyte = sc->headbyte; + atmstat->tailbyte = sc->tailbyte; + atmstat->tailflush = sc->tailflush; + atmstat->dmaovr = sc->dmaovr; + atmstat->txoutspace = sc->txoutspace; + atmstat->txdtqout = sc->txdtqout; + atmstat->launch = sc->launch; + atmstat->lheader = sc->lheader; + atmstat->ltail = sc->ltail; + atmstat->hwpull = sc->hwpull; + atmstat->swadd = sc->swadd; + atmstat->rxqnotus = sc->rxqnotus; + atmstat->rxqus = sc->rxqus; + atmstat->rxoutboth = sc->rxoutboth; + atmstat->rxdrqout = sc->rxdrqout; + atmstat->txmbovr = sc->txmbovr; + atmstat->vtrash = sc->vtrash; + atmstat->otrash = sc->otrash; + atmstat->ttrash = sc->ttrash; + atmstat->rxmbufout = sc->rxmbufout; + atmstat->natm_drops = natmintrq.ifq_drops; + + for (slot = 0; slot < EN_NTX; slot++) { + atmstat->txslot[slot].txbuf2small = sc->txslot[slot].txbuf2small; + atmstat->txslot[slot].txmbovr = sc->txslot[slot].txmbovr; + atmstat->txslot[slot].vci_assgn = sc->txslot[slot].vci_assgn; + atmstat->txslot[slot].bfree = sc->txslot[slot].bfree; + atmstat->txslot[slot].mbsize = sc->txslot[slot].mbsize; + } + + /* + printf(" en_stats:\n"); + printf(" %d mfix (%d failed); %d/%d head/tail byte DMAs, %d flushes\n", + sc->mfix, sc->mfixfail, sc->headbyte, sc->tailbyte, sc->tailflush); + printf(" %d rx dma overflow interrupts\n", sc->dmaovr); + printf(" %d times we ran out of TX space and stalled\n", + sc->txoutspace); + printf(" %d times we ran out of DTQs\n", sc->txdtqout); + printf(" %d times we launched a packet\n", sc->launch); + printf(" %d times we launched without on-board header\n", sc->lheader); + printf(" %d times we launched without on-board tail\n", sc->ltail); + printf(" %d times we pulled the hw service list\n", sc->hwpull); + printf(" %d times we pushed a vci on the sw service list\n", + sc->swadd); + printf(" %d times RX pulled an mbuf from Q that wasn't ours\n", + sc->rxqnotus); + printf(" %d times RX pulled a good mbuf from Q\n", sc->rxqus); + printf(" %d times we ran out of mbufs *and* DRQs\n", sc->rxoutboth); + printf(" %d times we ran out of DRQs\n", sc->rxdrqout); + + printf(" %d trasmit packets dropped due to mbsize\n", sc->txmbovr); + printf(" %d cells trashed due to turned off rxvc\n", sc->vtrash); + printf(" %d cells trashed due to totally full buffer\n", sc->otrash); + printf(" %d cells trashed due almost full buffer\n", sc->ttrash); + printf(" %d rx mbuf allocation failures\n", sc->rxmbufout); + */ + /* KENG << */ +#ifdef NATM + /* printf(" %d drops at natmintrq\n", natmintrq.ifq_drops); */ +#ifdef NATM_STAT + /* + printf(" natmintr so_rcv: ok/drop cnt: %d/%d, ok/drop bytes: %d/%d\n", + natm_sookcnt, natm_sodropcnt, natm_sookbytes, natm_sodropbytes); + */ +#endif +#endif + } + + if (level & END_MREGS) { + printf("mregs:\n"); + printf("resid = 0x%x\n", (u_int32_t) EN_READ(sc, MID_RESID)); + printf("interrupt status = 0x%b\n", + (u_int32_t) EN_READ(sc, MID_INTSTAT), MID_INTBITS); + printf("interrupt enable = 0x%b\n", + (u_int32_t) EN_READ(sc, MID_INTENA), MID_INTBITS); + printf("mcsr = 0x%b\n", + (u_int32_t) EN_READ(sc, MID_MAST_CSR), MID_MCSRBITS); + printf("serv_write = [chip=%ld] [us=%d]\n", EN_READ(sc, MID_SERV_WRITE), + MID_SL_A2REG(sc->hwslistp)); + printf("dma addr = 0x%x\n", (u_int32_t) EN_READ(sc, MID_DMA_ADDR)); + printf("DRQ: chip[rd=0x%x,wr=0x%x], sc[chip=0x%x,us=0x%x]\n", + (u_int32_t) MID_DRQ_REG2A(EN_READ(sc, MID_DMA_RDRX)), + (u_int32_t) MID_DRQ_REG2A(EN_READ(sc, MID_DMA_WRRX)), + sc->drq_chip, sc->drq_us); + printf("DTQ: chip[rd=0x%x,wr=0x%x], sc[chip=0x%x,us=0x%x]\n", + (u_int32_t) MID_DTQ_REG2A(EN_READ(sc, MID_DMA_RDTX)), + (u_int32_t) MID_DTQ_REG2A(EN_READ(sc, MID_DMA_WRTX)), + sc->dtq_chip, sc->dtq_us); + + printf(" unusal txspeeds: "); + for (cnt = 0 ; cnt < MID_N_VC ; cnt++) + if (sc->txspeed[cnt]) + printf(" vci%d=0x%x", cnt, sc->txspeed[cnt]); + printf("\n"); + + printf(" rxvc slot mappings: "); + for (cnt = 0 ; cnt < MID_N_VC ; cnt++) + if (sc->rxvc2slot[cnt] != RX_NONE) + printf(" %d->%d", cnt, sc->rxvc2slot[cnt]); + printf("\n"); + + } + + if (level & END_TX) { + printf("tx:\n"); + for (slot = 0 ; slot < EN_NTX; slot++) { + printf("tx%d: start/stop/cur=0x%x/0x%x/0x%x [%d] ", slot, + sc->txslot[slot].start, sc->txslot[slot].stop, sc->txslot[slot].cur, + (sc->txslot[slot].cur - sc->txslot[slot].start)/4); + printf("mbsize=%d, bfree=%d\n", sc->txslot[slot].mbsize, + sc->txslot[slot].bfree); + printf("txhw: base_address=0x%x, size=%d, read=%d, descstart=%d\n", + (u_int32_t) MIDX_BASE(EN_READ(sc, MIDX_PLACE(slot))), + (u_int32_t) MIDX_SZ(EN_READ(sc, MIDX_PLACE(slot))), + (u_int32_t) EN_READ(sc, MIDX_READPTR(slot)), + (u_int32_t) EN_READ(sc, MIDX_DESCSTART(slot))); + } + } + + if (level & END_RX) { + printf(" recv slots:\n"); + for (slot = 0 ; slot < sc->en_nrx; slot++) { + printf("rx%d: vci=%d: start/stop/cur=0x%x/0x%x/0x%x ", slot, + sc->rxslot[slot].atm_vci, sc->rxslot[slot].start, + sc->rxslot[slot].stop, sc->rxslot[slot].cur); + printf("mode=0x%x, atm_flags=0x%x, oth_flags=0x%x\n", + sc->rxslot[slot].mode, sc->rxslot[slot].atm_flags, + sc->rxslot[slot].oth_flags); + printf("RXHW: mode=0x%x, DST_RP=0x%x, WP_ST_CNT=0x%x\n", + (u_int32_t) EN_READ(sc, MID_VC(sc->rxslot[slot].atm_vci)), + (u_int32_t) EN_READ(sc, MID_DST_RP(sc->rxslot[slot].atm_vci)), + (u_int32_t) EN_READ(sc, MID_WP_ST_CNT(sc->rxslot[slot].atm_vci))); + } + } + + if (level & END_DTQ) { + printf(" dtq [need_dtqs=%d,dtq_free=%d]:\n", + sc->need_dtqs, sc->dtq_free); + ptr = sc->dtq_chip; + while (ptr != sc->dtq_us) { + reg = EN_READ(sc, ptr); + printf("\t0x%x=[cnt=%d, chan=%d, end=%d, type=%d @ 0x%x]\n", + sc->dtq[MID_DTQ_A2REG(ptr)], MID_DMA_CNT(reg), MID_DMA_TXCHAN(reg), + (reg & MID_DMA_END) != 0, MID_DMA_TYPE(reg), + (u_int32_t) EN_READ(sc, ptr+4)); + EN_WRAPADD(MID_DTQOFF, MID_DTQEND, ptr, 8); + } + } + + if (level & END_DRQ) { + printf(" drq [need_drqs=%d,drq_free=%d]:\n", + sc->need_drqs, sc->drq_free); + ptr = sc->drq_chip; + while (ptr != sc->drq_us) { + reg = EN_READ(sc, ptr); + printf("\t0x%x=[cnt=%d, chan=%d, end=%d, type=%d @ 0x%x]\n", + sc->drq[MID_DRQ_A2REG(ptr)], MID_DMA_CNT(reg), MID_DMA_RXVCI(reg), + (reg & MID_DMA_END) != 0, MID_DMA_TYPE(reg), + (u_int32_t) EN_READ(sc, ptr+4)); + EN_WRAPADD(MID_DRQOFF, MID_DRQEND, ptr, 8); + } + } + + if (level & END_SWSL) { + printf(" swslist [size=%d]: ", sc->swsl_size); + for (cnt = sc->swsl_head ; cnt != sc->swsl_tail ; + cnt = (cnt + 1) % MID_SL_N) + printf("0x%x ", sc->swslist[cnt]); + printf("\n"); + } + + /* } */ /* KENG */ + return(0); +} + +/* + * en_dumpmem: dump the memory + */ + +int en_dumpmem(unit, addr, len) + +int unit, addr, len; + +{ + struct en_softc *sc; + u_int32_t reg; + + if (unit < 0 || unit > en_cd.cd_ndevs || + (sc = (struct en_softc *) en_cd.cd_devs[unit]) == NULL) { + printf("invalid unit number: %d\n", unit); + return(0); + } + addr = addr & ~3; + if (addr < MID_RAMOFF || addr + len*4 > MID_MAXOFF || len <= 0) { + printf("invalid addr/len number: %d, %d\n", addr, len); + return(0); + } + printf("dumping %d words starting at offset 0x%x\n", len, addr); + while (len--) { + reg = EN_READ(sc, addr); + printf("mem[0x%x] = 0x%x\n", addr, reg); + addr += 4; + } + return(0); +} +/* KENG >> */ +/* #endif matches EN_DDBHOOK COMMENT OUT */ +/* KENG << */ + +#if defined(ALTQ) && defined(AFMAP) + +static int en_flowmap_add(sc, fmap) + struct en_softc *sc; + struct atm_flowmap *fmap; +{ + struct afm *afm; + struct atm_pseudoioctl api; + int error = 0; + + afm = afm_lookup(&sc->enif, fmap->af_vpi, fmap->af_vci); + if (afm) + /* already in use */ + return (EEXIST); + + if ((error = afm_add(&sc->enif, fmap))) + return error; + + /* enable rx */ + ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5 | ATM_PH_LLCSNAP; + ATM_PH_VPI(&api.aph) = fmap->af_vpi; + ATM_PH_SETVCI(&api.aph, fmap->af_vci); + api.rxhand = NULL; + error = en_rxctl(sc, &api, 1); + if (error != 0) + error = en_txctl(sc, fmap->af_vci, 0, fmap->af_pcr); + if (error) + (void)en_flowmap_delete(sc, fmap->af_vpi, fmap->af_vci); + + return error; +} + +static int en_flowmap_delete(sc, vpi, vci) + struct en_softc *sc; + int vpi, vci; +{ + struct afm *afm; + struct atm_pseudoioctl api; + int error = 0; + + afm = afm_lookup(&sc->enif, vpi, vci); + if (afm == NULL) + return (ENOENT); + + afm_remove(afm); + + /* disable rx */ + ATM_PH_FLAGS(&api.aph) = 0; + ATM_PH_VPI(&api.aph) = vpi; + ATM_PH_SETVCI(&api.aph, vci); + api.rxhand = NULL; + error = en_rxctl(sc, &api, 0); + + return error; +} + +static int en_flowmap_get(sc, fmap) + struct en_softc *sc; + struct atm_flowmap *fmap; +{ + struct afm *afm; + int error = 0; + + afm = afm_lookup(&sc->enif, fmap->af_vpi, fmap->af_vci); + if (afm == NULL) + return (ENOENT); + + bcopy(&afm->afm_flowinfo, &fmap->af_flowinfo, sizeof(struct flowinfo)); + + /* get pcr value */ + if (sc->txspeed[fmap->af_vci] != 0) + fmap->af_pcr = en_txspeed2pcr(sc->txspeed[fmap->af_vci]); + else + fmap->af_pcr = 0; + + /* get stats */ + fmap->afs_packets = afm->afms_packets; + fmap->afs_bytes = afm->afms_bytes; + + return error; +} + +#endif /* ALTQ && AFMAP */ + +#endif /* NEN > 0 || !defined(__FreeBSD__) */ diff -urN --exclude=compile --exclude=@ ../sys-altq/pci/midwayreg.h ./pci/midwayreg.h --- ../sys-altq/pci/midwayreg.h Wed Dec 31 19:00:00 1969 +++ ./pci/midwayreg.h Tue Mar 21 12:20:04 2000 @@ -0,0 +1,308 @@ +/* $NetBSD: midwayreg.h,v 1.6 1997/03/20 21:34:47 chuck Exp $ */ + +/* + * m i d w a y r e g . h + * + * this file contains the description of the ENI ATM midway chip + * data structures. see midway.c for more details. + * + */ + +#if defined(sparc) || defined(__FreeBSD__) +/* XXX: gross. netbsd/sparc doesn't have machine/bus.h yet. */ +typedef void * bus_space_tag_t; +typedef u_int32_t pci_chipset_tag_t; +typedef caddr_t bus_space_handle_t; +typedef u_int32_t bus_size_t; +typedef caddr_t bus_addr_t; + +#define bus_space_read_4(t, h, o) ((void) t, \ + (*(volatile u_int32_t *)((h) + (o)))) +#define bus_space_write_4(t, h, o, v) \ + ((void) t, ((void)(*(volatile u_int32_t *)((h) + (o)) = (v)))) +#define bus_space_read_1(t, h, o) ((void) t, \ + (*(volatile u_int8_t *)((h) + (o)))) + +#if defined(sparc) +#define vtophys(x) ((u_int32_t)(x)) /* sun4c dvma */ +#endif + +#endif + + +#define MID_SZTOB(X) ((X) * 256 * 4) /* size to bytes */ +#define MID_BTOSZ(X) ((X) / 256 / 4) /* bytes to "size" */ + +#define MID_N_VC 1024 /* # of VCs we can use */ +#define MID_NTX_CH 8 /* 8 transmit channels (shared) */ +#define MID_ATMDATASZ 48 /* need data in 48 byte blocks */ + +/* + * card data structures, top down + * + * in order to have a portable driver, the netbsd guys will not let us + * use structs. we have a bus_space_handle_t which is the en_base address. + * everything else is an offset from that base. all card data must be + * accessed with bus_space_read_4()/bus_space_write_4(): + * + * rv = bus_space_read_4(sc->en_memt, sc->en_base, BYTE_OFFSET); + * bus_space_write_4(sc->en_memt, sc->en_base, BYTE_OFFSET, VALUE); + * + * en_card: the whole card (prom + phy + midway + obmem) + * obmem contains: vci tab + dma queues (rx & tx) + service list + bufs + */ + +/* byte offsets from en_base of various items */ +#define MID_PHYOFF 0x030000 /* PHY offset */ +#define MID_MIDOFF 0x040000 /* midway regs offset */ +#define MID_RAMOFF 0x200000 /* RAM offset */ +#define MID_DRQOFF 0x204000 /* DRQ offset */ +#define MID_DRQEND MID_DTQOFF /* DRQ end */ +#define MID_DTQOFF 0x205000 /* DTQ offset */ +#define MID_DTQEND MID_SLOFF /* DTQ end */ +#define MID_SLOFF 0x206000 /* service list */ +#define MID_SLEND MID_BUFOFF /* service list end */ +#define MID_BUFOFF 0x207000 /* buffer area */ +#define MID_PROBEOFF 0x21fffc /* start probe here */ +#define MID_PROBSIZE 0x020000 /* 128 KB */ +#define MID_MAXOFF 0x3ffffc /* max offset */ + +/* + * prom & phy: not defined here, except + */ + +#define MID_ADPMACOFF 0xffc0 /* mac address offset (adaptec only) */ + +/* + * midway regs (byte offsets from en_base) + */ + +#define MID_RESID 0x40000 /* write=reset reg, read=ID reg */ + +#define MID_VER(X) (((X) & 0xf0000000) >> 28) /* midway version # */ +#define MID_MID(X) (((X) & 0x700) >> 8) /* motherboard ID */ +#define MID_IS_SABRE(X) ((X) & 0x80) /* sabre controller? */ +#define MID_IS_SUNI(X) ((X) & 0x40) /* SUNI? vs utopia */ +#define MID_IS_UPIPE(X) ((X) & 0x20) /* utopia pipeline? */ +#define MID_DID(X) ((X) & 0x1f) /* daughterboard ID */ + +#define MID_INTACK 0x40004 /* interrupt ACK */ +#define MID_INTSTAT 0x40008 /* interrupt status */ +#define MID_INTENA 0x4000c /* interrupt enable */ + +#define MID_TXCHAN(N) (1 << ((N) + 9)) /* ack/status/enable xmit channel bit*/ +#define MID_INT_TX 0x1fe00 /* mask for any xmit interrupt */ +#define MID_INT_DMA_OVR 0x00100 /* DMA overflow interrupt */ +#define MID_INT_IDENT 0x00080 /* ident match error interrupt */ +#define MID_INT_LERR 0x00040 /* LERR interrupt (sbus?) */ +#define MID_INT_DMA_ERR 0x00020 /* DMA error interrupt */ +#define MID_INT_DMA_RX 0x00010 /* DMA recv interrupt */ +#define MID_INT_DMA_TX 0x00008 /* DMA xmit interrupt */ +#define MID_INT_SERVICE 0x00004 /* service list interrupt */ +#define MID_INT_SUNI 0x00002 /* SUNI interrupt */ +#define MID_INT_STATS 0x00001 /* stats overflow interrupt */ + +#define MID_INT_ANY 0x1ffff /* any interrupt? */ + +#define MID_INTBITS "\20\21T7\20T6\17T5\16T4\15T3\14T2\13T1\12T0\11DMAOVR\10ID\7LERR\6DMAERR\5RXDMA\4TXDMA\3SERV\2SUNI\1STAT" + +#define MID_MAST_CSR 0x40010 /* master CSR */ + +#define MID_IPL(X) (((X) & 0x1c0) >> 6) /* IPL */ +#define MID_SETIPL(I) ((I) << 6) +#define MID_MCSR_TXLOCK 0x20 /* lock on xmit overflow mode */ +/* NOTE: next 5 bits: write 1 means enable, write 0 means no change */ +#define MID_MCSR_ENDMA 0x10 /* DMA enable */ +#define MID_MCSR_ENTX 0x08 /* TX enable */ +#define MID_MCSR_ENRX 0x04 /* RX enable */ +#define MID_MCSR_W1MS 0x02 /* wait 1 msec */ +#define MID_MCSR_W500US 0x01 /* wait 500 usec */ + +#define MID_MCSRBITS "\20\6LCK\5DMAON\4TXON\3RXON\2W1MS\1W500US" + +#define MID_STAT 0x40014 /* stat register, clear on read */ + +#define MID_VTRASH(X) (((X) >> 16) & 0xffff) + /* # cells trashed due to VCI's mode */ +#define MID_OTRASH(X) ((X) & 0xffff) /* # cells trashed due to overflow */ + +#define MID_SERV_WRITE 0x40018 /* 10 bit service write pointer (r/o) */ +#define MID_DMA_ADDR 0x4001c /* VA of DMA (r/o) */ + + /* DMA queue pointers (bits 0 to 8) */ +#define MID_DMA_WRRX 0x40020 /* write ptr. for DMA recv queue */ + /* (for adaptor -> host xfers) */ +#define MID_DMA_RDRX 0x40024 /* read ptr for DMA recv queue (r/o) */ + /* (i.e. current adaptor->host xfer) */ +#define MID_DMA_WRTX 0x40028 /* write ptr for DMA xmit queue */ + /* (for host -> adaptor xfers) */ +#define MID_DMA_RDTX 0x4002c /* read ptr for DMA xmit queue (r/o) */ + /* (i.e. current host->adaptor xfer) */ + + /* xmit channel regs (1 per channel, MID_NTX_CH max channels) */ + +#define MIDX_PLACE(N) (0x40040+((N)*0x10)) /* xmit place */ + +#define MIDX_MKPLACE(SZ,LOC) ( ((SZ) << 11) | (LOC) ) +#define MIDX_LOC(X) ((X) & 0x7ff) /* location in obmem */ +#define MIDX_SZ(X) ((X) >> 11) /* (size of block / 256) in int32_t's*/ +#define MIDX_BASE(X) \ + (((MIDX_LOC(X) << MIDV_LOCTOPSHFT) * sizeof(u_int32_t)) + MID_RAMOFF) + + /* the following two regs are word offsets in the block */ +#define MIDX_READPTR(N) (0x40044+((N)*0x10)) /* xmit read pointer (r/o) */ +#define MIDX_DESCSTART(N) (0x40048+((N)*0x10)) /* seg currently in DMA (r/o) */ + + +/* + * obmem items + */ + +/* + * vci table in obmem (offset from MID_VCTOFF) + */ + +#define MID_VC(N) (MID_RAMOFF+((N)*0x10)) + +#define MIDV_TRASH 0x00000000 /* ignore VC */ +#define MIDV_AAL5 0x80000000 /* do AAL5 on it */ +#define MIDV_NOAAL 0x40000000 /* do per-cell stuff on it */ +#define MIDV_MASK 0xc0000000 /* mode mask */ +#define MIDV_SETMODE(VC,M) (((VC) & ~(MIDV_MASK)) | (M)) /* new mode */ +#define MIDV_PTI 0x20000000 /* save PTI cells? */ +#define MIDV_LOCTOPSHFT 8 /* shift to get top 11 bits of 19 */ +#define MIDV_LOCSHIFT 18 +#define MIDV_LOCMASK 0x7ff +#define MIDV_LOC(X) (((X) >> MIDV_LOCSHIFT) & MIDV_LOCMASK) + /* 11 most sig bits of addr */ +#define MIDV_SZSHIFT 15 +#define MIDV_SZ(X) (((X) >> MIDV_SZSHIFT) & 7) + /* size encoded the usual way */ +#define MIDV_INSERVICE 0x1 /* in service list */ + +#define MID_DST_RP(N) (MID_VC(N)|0x4) + +#define MIDV_DSTART_SHIFT 16 /* shift */ +#define MIDV_DSTART(X) (((X) >> MIDV_DSTART_SHIFT) & 0x7fff) +#define MIDV_READP_MASK 0x7fff /* valid bits, (shift = 0) */ + +#define MID_WP_ST_CNT(N) (MID_VC(N)|0x8) /* write pointer/state/count */ + +#define MIDV_WRITEP_MASK 0x7fff0000 /* mask for write ptr. */ +#define MIDV_WRITEP_SHIFT 16 +#define MIDV_ST_IDLE 0x0000 +#define MIDV_ST_TRASH 0xc000 +#define MIDV_ST_REASS 0x4000 +#define MIDV_CCOUNT 0x7ff /* cell count */ + +#define MID_CRC(N) (MID_VC(N)|0xc) /* CRC */ + +/* + * dma recv q. + */ + +#define MID_DMA_END (1 << 5) /* for both tx and rx */ +#define MID_DMA_CNT(X) (((X) >> 16) & 0xffff) +#define MID_DMA_TXCHAN(X) (((X) >> 6) & 0x7) +#define MID_DMA_RXVCI(X) (((X) >> 6) & 0x3ff) +#define MID_DMA_TYPE(X) ((X) & 0xf) + +#define MID_DRQ_N 512 /* # of descriptors */ +#define MID_DRQ_A2REG(N) (((N) - MID_DRQOFF) >> 3) + /* convert byte offset to reg value */ +#define MID_DRQ_REG2A(N) (((N) << 3) + MID_DRQOFF) /* and back */ + +/* note: format of word 1 of RXQ is different beween ENI and ADP cards */ +#define MID_MK_RXQ_ENI(CNT,VC,END,TYPE) \ + ( ((CNT) << 16)|((VC) << 6)|(END)|(TYPE) ) + +#define MID_MK_RXQ_ADP(CNT,VC,END,JK) \ + ( ((CNT) << 12)|((VC) << 2)|((END) >> 4)|(((JK) != 0) ? 1 : 0)) +/* + * dma xmit q. + */ + +#define MID_DTQ_N 512 /* # of descriptors */ +#define MID_DTQ_A2REG(N) (((N) - MID_DTQOFF) >> 3) + /* convert byte offset to reg value */ +#define MID_DTQ_REG2A(N) (((N) << 3) + MID_DTQOFF) /* and back */ + + +/* note: format of word 1 of TXQ is different beween ENI and ADP cards */ +#define MID_MK_TXQ_ENI(CNT,CHN,END,TYPE) \ + ( ((CNT) << 16)|((CHN) << 6)|(END)|(TYPE) ) + +#define MID_MK_TXQ_ADP(CNT,CHN,END,JK) \ + ( ((CNT) << 12)|((CHN) << 2)|((END) >> 4)|(((JK) != 0) ? 1 : 0) ) + +/* + * dma types + */ + +#define MIDDMA_JK 0x3 /* just kidding */ +#define MIDDMA_BYTE 0x1 /* byte */ +#define MIDDMA_2BYTE 0x2 /* 2 bytes */ +#define MIDDMA_WORD 0x0 /* word */ +#define MIDDMA_2WORD 0x7 /* 2 words */ +#define MIDDMA_4WORD 0x4 /* 4 words */ +#define MIDDMA_8WORD 0x5 /* 8 words */ +#define MIDDMA_16WORD 0x6 /* 16 words!!! */ +#define MIDDMA_2WMAYBE 0xf /* 2 words, maybe */ +#define MIDDMA_4WMAYBE 0xc /* 4 words, maybe */ +#define MIDDMA_8WMAYBE 0xd /* 8 words, maybe */ +#define MIDDMA_16WMAYBE 0xe /* 16 words, maybe */ + +#define MIDDMA_MAYBE 0xc /* mask to detect WMAYBE dma code */ +#define MIDDMA_MAXBURST (16 * sizeof(u_int32_t)) /* largest burst */ + +/* + * service list + */ + +#define MID_SL_N 1024 /* max # entries on slist */ +#define MID_SL_A2REG(N) (((N) - MID_SLOFF) >> 2) + /* convert byte offset to reg value */ +#define MID_SL_REG2A(N) (((N) << 2) + MID_SLOFF) /* and back */ + +/* + * data in the buffer area of obmem + */ + +/* + * recv buffer desc. (1 u_int32_t at start of buffer) + */ + +#define MID_RBD_SIZE 4 /* RBD size */ +#define MID_CHDR_SIZE 4 /* on aal0, cell header size */ +#define MID_RBD_ID(X) ((X) & 0xfe000000) /* get ID */ +#define MID_RBD_STDID 0x36000000 /* standard ID */ +#define MID_RBD_CLP 0x01000000 /* CLP: cell loss priority */ +#define MID_RBD_CE 0x00010000 /* CE: congestion experienced */ +#define MID_RBD_T 0x00001000 /* T: trashed due to overflow */ +#define MID_RBD_CRCERR 0x00000800 /* CRC error */ +#define MID_RBD_CNT(X) ((X) & 0x7ff) /* cell count */ + +/* + * xmit buffer desc. (2 u_int32_t's at start of buffer) + * (note we treat the PR & RATE as a single u_int8_t) + */ + +#define MID_TBD_SIZE 8 +#define MID_TBD_MK1(AAL,PR_RATE,CNT) \ + (MID_TBD_STDID|(AAL)|((PR_RATE) << 19)|(CNT)) +#define MID_TBD_STDID 0xb0000000 /* standard ID */ +#define MID_TBD_AAL5 0x08000000 /* AAL 5 */ +#define MID_TBD_NOAAL5 0x00000000 /* not AAL 5 */ + +#define MID_TBD_MK2(VCI,PTI,CLP) \ + (((VCI) << 4)|((PTI) << 1)|(CLP)) + +/* + * aal5 pdu tail, last 2 words of last cell of AAL5 frame + * (word 2 is CRC .. handled by hw) + */ + +#define MID_PDU_SIZE 8 +#define MID_PDU_MK1(UU,CPI,LEN) \ + (((UU) << 24)|((CPI) << 16)|(LEN)) +#define MID_PDU_LEN(X) ((X) & 0xffff) diff -urN --exclude=compile --exclude=@ ../sys-altq/pci/midwayvar.h ./pci/midwayvar.h --- ../sys-altq/pci/midwayvar.h Wed Dec 31 19:00:00 1969 +++ ./pci/midwayvar.h Tue Mar 21 12:20:04 2000 @@ -0,0 +1,254 @@ +/* $NetBSD: midwayvar.h,v 1.8 1996/10/21 22:34:33 thorpej Exp $ */ + +/* + * + * Copyright (c) 1996 Charles D. Cranor and Washington University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Charles D. Cranor and + * Washington University. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * m i d w a y v a r . h + * + * we define the en_softc here so that bus specific modules can allocate + * it as the first item in their softc. note that BSD-required + * "struct device" is in the mid_softc! + * + * author: Chuck Cranor + */ + +#ifndef _MIDWAYVAR_H_ +#define _MIDWAYVAR_H_ + +/* + * params needed to determine softc size + */ + +#ifndef EN_NTX +#define EN_NTX 8 /* number of tx bufs to use */ +#endif +#ifndef EN_TXSZ +#define EN_TXSZ 32 /* trasmit buf size in KB */ +#endif +#ifndef EN_RXSZ +#define EN_RXSZ 32 /* recv buf size in KB */ +#endif +#define EN_MAXNRX ((2048-(EN_NTX*EN_TXSZ))/EN_RXSZ) + /* largest possible NRX (depends on RAM size) */ + +#define EN_MAX_LINE_RATE 365500 /* (155e6/8)*(48/53)*(1/48) cps)*/ + + +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) +#define EN_INTR_TYPE int +#define EN_INTR_RET(X) return(X) +#if defined(__NetBSD__) || defined(__OpenBSD__) +#define EN_IOCTL_CMDT u_long +#elif defined(__bsdi__) +#define EN_IOCTL_CMDT int +#endif + +#elif defined(__FreeBSD__) + +#define EN_INTR_TYPE void +#define EN_INTR_RET(X) return +#if __FreeBSD_version >= 300000 +#define EN_IOCTL_CMDT u_long +#else +#define EN_IOCTL_CMDT int +#endif /* FBSD 3.x */ + +struct device { + char dv_xname[IFNAMSIZ]; +}; + +#define DV_IFNET 1 + +struct cfdriver { + int zero; + char *name; + int one; + int cd_ndevs; + void *cd_devs[NEN]; +}; + +#endif + + +/* + * softc + */ + +struct en_softc { + /* bsd glue */ + struct device sc_dev; /* system device */ + struct ifnet enif; /* network ifnet handle */ + + /* bus glue */ + bus_space_tag_t en_memt; /* for EN_READ/EN_WRITE */ + bus_space_handle_t en_base; /* base of en card */ + bus_size_t en_obmemsz; /* size of en card (bytes) */ + void (*en_busreset) __P((void *)); + /* bus specific reset function */ + + u_int8_t macaddr[6]; /* IEEE MAC address */ + + /* serv list */ + u_int32_t hwslistp; /* hw pointer to service list (byte offset) */ + u_int16_t swslist[MID_SL_N]; /* software service list (see en_service()) */ + u_int16_t swsl_head, /* ends of swslist (index into swslist) */ + swsl_tail; + u_int32_t swsl_size; /* # of items in swsl */ + + /* xmit avl bw */ + + int32_t avl_bw; /* Available XMIT BW */ + /* xmit dma */ + u_int32_t dtq[MID_DTQ_N]; /* sw copy of dma q (see ENIDQ macros) */ + u_int32_t dtq_free; /* # of dtq's free */ + u_int32_t dtq_us; /* software copy of our ptr (byte offset) */ + u_int32_t dtq_chip; /* chip's pointer (byte offset) */ + u_int32_t need_dtqs; /* true if we ran out of DTQs */ + + /* recv dma */ + u_int32_t drq[MID_DRQ_N]; /* sw copy of dma q (see ENIDQ macros) */ + u_int32_t drq_free; /* # of drq's free */ + u_int32_t drq_us; /* software copy of our ptr (byte offset) */ + u_int32_t drq_chip; /* chip's pointer (byte offset) */ + u_int32_t need_drqs; /* true if we ran out of DRQs */ + + /* xmit buf ctrl. (per channel) */ + struct { + u_int32_t txbuf2small; /* pkt drop count when pkt size > tx slot buf on card */ + u_int32_t mbsize; /* # mbuf bytes we are using (max=TXHIWAT) */ + u_int32_t bfree; /* # free bytes in buffer (not dma or xmit) */ + u_int32_t start, stop; /* ends of buffer area (byte offset) */ + u_int32_t cur; /* next free area (byte offset) */ + u_int32_t nref; /* # of VCs using this channel */ + struct ifqueue indma; /* mbufs being dma'd now */ + struct ifqueue q; /* mbufs waiting for dma now */ + u_int32_t vci_assgn; /* specific vci assigned to transmit slot */ + u_int32_t txmbovr; /* number of times packet dropped due to mbsize */ + } txslot[MID_NTX_CH]; + + struct ifqueue *txslot_q_ptr; /* ptr to current tx slot q assigned */ + + /* xmit channel assignment for a vci: */ + int8_t txchan_assgn[MID_N_VC]; + + /* Alloc channels from 1-7 in round robin fashion. 0 is always BestEffort */ + /* Keeps track of channel last allocated to a VCI Naive roundrobin + * can result in multiple VC getting assigned to the same channel + * even if some channels may be idle. The other scheme tries to + * avoid this. + * */ +#ifdef NAIVE_ROUNDROBIN + int8_t txchan; +#else + int8_t txchan[EN_NTX]; +#endif + + /* xmit vc ctrl. (per vc) */ + u_int8_t txspeed[MID_N_VC]; /* speed of tx on a VC */ + u_int8_t txvc2slot[MID_N_VC]; /* XXX: map VC to slot */ + + /* recv vc ctrl. (per vc). maps VC number to recv slot */ + u_int16_t rxvc2slot[MID_N_VC]; + int en_nrx; /* # of active rx slots */ + + /* recv buf ctrl. (per recv slot) */ + struct { + void *rxhand; /* recv. handle if doing direct delivery */ + u_int32_t mode; /* saved copy of mode info */ + u_int32_t start, stop; /* ends of my buffer area */ + u_int32_t cur; /* where I am at */ + u_int16_t atm_vci; /* backpointer to VCI */ + u_int8_t atm_flags; /* copy of atm_flags from atm_ph */ + u_int8_t oth_flags; /* other flags */ + u_int32_t raw_threshold; /* for raw mode */ + struct ifqueue indma; /* mbufs being dma'd now */ + struct ifqueue q; /* mbufs waiting for dma now */ + } rxslot[EN_MAXNRX]; /* recv info */ + + /* stats */ + u_int32_t vtrash; /* sw copy of counter */ + u_int32_t otrash; /* sw copy of counter */ + u_int32_t ttrash; /* # of RBD's with T bit set */ + u_int32_t mfix; /* # of times we had to call mfix */ + u_int32_t mfixfail; /* # of times mfix failed */ + u_int32_t headbyte; /* # of times we used BYTE DMA at front */ + u_int32_t tailbyte; /* # of times we used BYTE DMA at end */ + u_int32_t tailflush; /* # of times we had to FLUSH out DMA bytes */ + u_int32_t txmbovr; /* # of times we dropped due to mbsize */ + u_int32_t dmaovr; /* tx dma overflow count */ + u_int32_t txoutspace; /* out of space in xmit buffer */ + u_int32_t txdtqout; /* out of DTQs */ + u_int32_t launch; /* total # of launches */ + u_int32_t lheader; /* # of launches without OB header */ + u_int32_t ltail; /* # of launches without OB tail */ + u_int32_t hwpull; /* # of pulls off hardware service list */ + u_int32_t swadd; /* # of pushes on sw service list */ + u_int32_t rxqnotus; /* # of times we pull from rx q, but fail */ + u_int32_t rxqus; /* # of good pulls from rx q */ + u_int32_t rxoutboth; /* # of times out of mbufs and DRQs */ + u_int32_t rxdrqout; /* # of times out of DRQs */ + u_int32_t rxmbufout; /* # of time out of mbufs */ + + /* random stuff */ + u_int32_t ipl; /* sbus interrupt lvl (1 on pci?) */ + u_int8_t bestburstcode; /* code of best burst we can use */ + u_int8_t bestburstlen; /* length of best burst (bytes) */ + u_int8_t bestburstshift; /* (x >> shift) == (x / bestburstlen) */ + u_int8_t bestburstmask; /* bits to check if not multiple of burst */ + u_int8_t alburst; /* align dma bursts? */ + u_int8_t is_adaptec; /* adaptec version of midway? */ + + /* a mapping from incoming vci to ifnet */ + struct { + struct ifnet *ifp; + u_int16_t vci; + u_int16_t *refcnt; /* No. of entities using this VCC */ + int pcr; /* peak rate in cells/sec */ + struct atm_pseudohdr aph; + } vctoif[NENP+1]; /* NENP pseudo if's and the original ifnet */ + + /* This is a much quicker place to find the ifp for a vci */ + struct ifnet *vci2ifp[MID_N_VC]; +}; + +/* + * exported functions + */ + +void en_attach __P((struct en_softc *)); +EN_INTR_TYPE en_intr __P((void *)); +void en_reset __P((struct en_softc *)); +/* this is used in /sys/netinet/if_atm.c */ +int en_find_chan __P((struct en_softc *, int)); + +#endif /* _MIDWAYVAR_H_ */ diff -urN --exclude=compile --exclude=@ ../sys-altq/sys/mount.h ./sys/mount.h --- ../sys-altq/sys/mount.h Wed Jan 12 15:48:37 2000 +++ ./sys/mount.h Fri Feb 4 16:33:42 2000 @@ -373,7 +373,7 @@ #include -#define AF_MAX 31 /* XXX */ +#define AF_MAX 32 /* XXX */ /* * Network address lookup element diff -urN --exclude=compile --exclude=@ ../sys-altq/sys/socket.h ./sys/socket.h --- ../sys-altq/sys/socket.h Wed Jan 12 15:48:39 2000 +++ ./sys/socket.h Wed Feb 2 12:44:48 2000 @@ -128,8 +128,9 @@ #define AF_INET6 28 /* IPv6 */ #define AF_NATM 29 /* native ATM access */ #define AF_ATM 30 /* ATM */ +#define AF_LABEL 31 -#define AF_MAX 31 +#define AF_MAX 32 /* * Structure used by kernel to store most @@ -187,6 +188,7 @@ #define PF_INET6 AF_INET6 #define PF_NATM AF_NATM #define PF_ATM AF_ATM +#define PF_LABEL AF_LABEL #define PF_MAX AF_MAX