--- //depot/vendor/freebsd/src/sys/alpha/alpha/pmap.c 2004/04/26 10:50:53 +++ //depot/user/jhb/acpipci/alpha/alpha/pmap.c 2004/04/16 11:09:59 @@ -148,7 +148,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.146 2004/04/26 17:49:05 gallatin Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.143 2004/04/11 05:08:26 alc Exp $"); #include #include @@ -1074,7 +1074,7 @@ */ VM_OBJECT_LOCK(pmap->pm_pteobj); lev1pg = vm_page_grab(pmap->pm_pteobj, NUSERLEV3MAPS + NUSERLEV2MAPS, - VM_ALLOC_NORMAL | VM_ALLOC_RETRY | VM_ALLOC_WIRED | VM_ALLOC_ZERO); + VM_ALLOC_NORMAL | VM_ALLOC_RETRY | VM_ALLOC_WIRED); vm_page_lock_queues(); vm_page_flag_clear(lev1pg, PG_BUSY); @@ -1083,7 +1083,10 @@ VM_OBJECT_UNLOCK(pmap->pm_pteobj); pmap->pm_lev1 = (pt_entry_t*) ALPHA_PHYS_TO_K0SEG(VM_PAGE_TO_PHYS(lev1pg)); + if ((lev1pg->flags & PG_ZERO) == 0) + bzero(pmap->pm_lev1, PAGE_SIZE); + /* install self-referential address mapping entry (not PG_ASM) */ pmap->pm_lev1[PTLEV1I] = pmap_phys_to_pte(VM_PAGE_TO_PHYS(lev1pg)) | PG_V | PG_KRE | PG_KWE; @@ -1191,6 +1194,8 @@ VM_OBJECT_LOCK(pmap->pm_pteobj); m = vm_page_grab(pmap->pm_pteobj, ptepindex, VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY); + if ((m->flags & PG_ZERO) == 0) + pmap_zero_page(m); KASSERT(m->queue == PQ_NONE, ("_pmap_allocpte: %p->queue != PQ_NONE", m)); @@ -1237,6 +1242,7 @@ vm_page_lock_queues(); m->valid = VM_PAGE_BITS_ALL; + vm_page_flag_clear(m, PG_ZERO); vm_page_wakeup(m); vm_page_unlock_queues(); if (!is_object_locked) @@ -1900,8 +1906,7 @@ * raise IPL while manipulating pv_table since pmap_enter can be * called at interrupt time. */ - if (pmap_initialized && - (m->flags & (PG_FICTITIOUS|PG_UNMANAGED)) == 0) { + if (pmap_initialized && (m->flags & PG_FICTITIOUS) == 0) { pmap_insert_entry(pmap, va, mpte, m); managed |= PG_MANAGED; } @@ -1961,7 +1966,7 @@ pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_page_t mpte) { register pt_entry_t *pte; - int managed; + /* * In the case that a page table page is not @@ -2026,11 +2031,7 @@ * raise IPL while manipulating pv_table since pmap_enter can be * called at interrupt time. */ - managed = 0; - if ((m->flags & (PG_FICTITIOUS|PG_UNMANAGED)) == 0) { - pmap_insert_entry(pmap, va, mpte, m); - managed = PG_MANAGED | PG_FOR | PG_FOW | PG_FOE; - } + pmap_insert_entry(pmap, va, mpte, m); /* * Increment counters @@ -2040,7 +2041,7 @@ /* * Now validate mapping with RO protection */ - *pte = pmap_phys_to_pte(VM_PAGE_TO_PHYS(m)) | PG_V | PG_KRE | PG_URE | managed; + *pte = pmap_phys_to_pte(VM_PAGE_TO_PHYS(m)) | PG_V | PG_KRE | PG_URE | PG_MANAGED | PG_FOR | PG_FOE | PG_FOW; alpha_pal_imb(); /* XXX overkill? */ return mpte; --- //depot/vendor/freebsd/src/sys/alpha/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/alpha/include/float.h 2004/04/16 11:09:59 @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/alpha/include/float.h,v 1.6 2004/04/25 02:36:28 das Exp $ */ +/* $FreeBSD: src/sys/alpha/include/float.h,v 1.5 2004/04/05 21:00:50 imp Exp $ */ /* From: NetBSD: float.h,v 1.6 1997/07/17 21:36:03 thorpej Exp */ /* @@ -41,10 +41,8 @@ #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS __flt_rounds() -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD 0 /* no promotions */ #define DECIMAL_DIG 17 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/amd64/acpica/acpi_machdep.c 2004/04/20 19:15:50 +++ //depot/user/jhb/acpipci/amd64/acpica/acpi_machdep.c 2004/01/07 11:51:02 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_machdep.c,v 1.13 2004/04/21 02:10:58 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_machdep.c,v 1.12 2003/09/22 22:12:46 peter Exp $"); #include #include @@ -40,7 +40,8 @@ { struct acpi_softc *sc; - sc = device_get_softc(dev); + if ((sc = device_get_softc(dev)) == NULL) + return (ENXIO); acpi_install_wakeup_handler(sc); --- //depot/vendor/freebsd/src/sys/amd64/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/amd64/include/float.h 2004/04/16 11:09:59 @@ -27,20 +27,16 @@ * SUCH DAMAGE. * * from: @(#)float.h 7.1 (Berkeley) 5/8/90 - * $FreeBSD: src/sys/amd64/include/float.h,v 1.12 2004/04/25 02:36:28 das Exp $ + * $FreeBSD: src/sys/amd64/include/float.h,v 1.11 2004/04/05 21:25:51 imp Exp $ */ #ifndef _MACHINE_FLOAT_H_ #define _MACHINE_FLOAT_H_ 1 -#include - #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS 1 /* FP addition rounds to nearest */ -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD (-1) /* i387 semantics are...interesting */ #define DECIMAL_DIG 21 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/boot/i386/boot0/Makefile 2004/04/27 12:11:49 +++ //depot/user/jhb/acpipci/boot/i386/boot0/Makefile 2004/02/18 13:44:48 @@ -1,10 +1,11 @@ -# $FreeBSD: src/sys/boot/i386/boot0/Makefile,v 1.26 2004/04/27 19:07:35 phk Exp $ +# $FreeBSD: src/sys/boot/i386/boot0/Makefile,v 1.23 2004/02/09 14:11:56 ru Exp $ -PROG= ${BOOT} +PROG= ${BOOT}.out INTERNALPROG= FILES= ${BOOT} NOMAN= SRCS= ${BOOT}.s +CLEANFILES= ${BOOT} BOOT?= boot0 @@ -33,12 +34,9 @@ --defsym TICKS=${BOOT_BOOT0_TICKS} \ --defsym COMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED} -LDFLAGS=-N -e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-S,--oformat,binary +LDFLAGS=-N -e start -Ttext ${BOOT_BOOT0_ORG} + +${BOOT}: ${BOOT}.out + objcopy -S -O binary ${BOOT}.out ${.TARGET} .include - -boot0.s: boot0_512.s - cpp -USIO < ${.CURDIR}/boot0_512.s > boot0.s - -boot0sio.s: ${.CURDIR}/../boot0/boot0_512.s - cpp -DSIO < ${.CURDIR}/../boot0/boot0_512.s > boot0sio.s --- //depot/vendor/freebsd/src/sys/boot/i386/boot0/boot0ext.s 2004/04/20 06:36:13 +++ //depot/user/jhb/acpipci/boot/i386/boot0/boot0ext.s 2004/04/19 12:56:56 @@ -13,7 +13,7 @@ # purpose. # -# $FreeBSD: src/sys/boot/i386/boot0/boot0ext.s,v 1.5 2004/04/20 13:34:18 obrien Exp $ +# $FreeBSD: src/sys/boot/i386/boot0/boot0ext.s,v 1.2 2004/04/19 19:31:48 obrien Exp $ # A 1024-byte boot manager. @@ -72,9 +72,9 @@ movw %ax,%ds # data movw %ax,%ss # Set up movw $LOAD,%sp # stack -# +# # End signature code -# +# # # Set address for variable space beyond code, and clear it. # Notice that this is also used to point to the values embedded in the block, @@ -98,7 +98,7 @@ boot.2: # # Reload all of boot0 (including the extra sectors) into memory at the -# relocation address. +# relocation address. # push %dx # Save drive number movw $start,%bx # Origin we were linked for @@ -130,7 +130,7 @@ # Loop around on the partition table, printing values until we # pass a 256 byte boundary. The end of loop test is at main.5. # -main.3: movb %ch,-0x4(%bx) # Zero active flag (ch == 0) +main.3: movb %ch,-0x4(%bx) # Zero active flag (ch == 0) btw %dx,_FLAGS(%bp) # Entry enabled? jnc main.5 # No # @@ -157,16 +157,16 @@ # pointing at its first element which points to a "?". # addw $TBL1SZ,%di # Adjust -main.4: movb (%di),%cl # Partition +main.4: movb (%di),%cl # Partition addw %cx,%di # description callw putx # Display it -main.5: incw %dx # Next item +main.5: incw %dx # Next item addb $0x10,%bl # Next entry jnc main.3 # Till done # # Passed a 256 byte boundary.. # table is finished. -# Add one to the drive number and check it is valid, +# Add one to the drive number and check it is valid, # popw %ax # Drive number subb $0x80-0x1,%al # Does next @@ -188,7 +188,7 @@ # This also is part of the printed drive string so add 0x80 to indicate # end of string. # -main.6: addb $'0'|0x80,%al # Save next +main.6: addb $'0'|0x80,%al # Save next movb %al,_NXTDRV(%bp) # drive number movw $drive,%di # Display callw putx # item @@ -196,7 +196,7 @@ # Now that we've printed the drive (if we needed to), display a prompt. # Get ready for the input by noting the time. # -main.7: movw $prompt,%si # Display +main.7: movw $prompt,%si # Display callw putstr # prompt movb _OPT(%bp),%dl # Display decw %si # default @@ -205,11 +205,11 @@ int $0x1a # system time movw %dx,%di # Ticks when addw _TICKS(%bp),%di # timeout -# +# # Busy loop, looking for keystrokes but # keeping one eye on the time. # -main.8: movb $0x1,%ah # BIOS: Check +main.8: movb $0x1,%ah # BIOS: Check int $0x16 # for keypress jnz main.11 # Have one xorb %ah,%ah # BIOS: Get @@ -219,12 +219,12 @@ # # If timed out or defaulting, come here. # -main.9: movb _OPT(%bp),%al # Load default +main.9: movb _OPT(%bp),%al # Load default jmp main.12 # Join common code # # User's last try was bad, beep in displeasure. # Since nothing was printed, just continue on as if the user -# hadn't done anything. This gives the effect of the user getting a beep +# hadn't done anything. This gives the effect of the user getting a beep # for all bad keystrokes but no action until either the timeout # occurs or the user hits a good key. # @@ -293,7 +293,7 @@ jne main.15 # If not F5/#5 movb _NXTDRV(%bp),%dl # Next drive subb $'0',%dl # number -# +# # load selected bootsector to the LOAD location in RAM. # If it fails to read or isn't marked bootable, treat it # as a bad selection. @@ -311,7 +311,7 @@ # Display routines # -putkey: movb $'F',%al # Display +putkey: movb $'F',%al # Display callw putchr # 'F' movb $'1',%al # Prepare addb %dl,%al # digit @@ -330,14 +330,14 @@ putn: movw $crlf,%si # To next line -putstr: lodsb # Get byte +putstr: lodsb # Get byte testb $0x80,%al # End of string? jnz putstr.2 # Yes putstr.1: callw putchr # Display char jmp putstr # Continue putstr.2: andb $~0x80,%al # Clear MSB -putchr: pushw %bx # Save +putchr: pushw %bx # Save movw $0x7,%bx # Page:attribute movb $0xe,%ah # BIOS: Display int $0x10 # character @@ -360,7 +360,7 @@ # to use the EDD stuff with the LBA offset instead of CHS. However, # use CHS if at all possible. -intx13: movb 0x1(%si),%dh # Load head +intx13: movb 0x1(%si),%dh # Load head movw 0x2(%si),%cx # Load cylinder:sector pushw %si # Save movw %sp,%di # Save @@ -405,25 +405,25 @@ .org PRT_OFF-0xe,0x90 # # These values are sometimes changed before writing back to the drive -# Be especially careful that nxtdrv: must come after drive:, as it +# Be especially careful that nxtdrv: must come after drive:, as it # is part of the same string. # # Note that the 'drive' string variable is used as the second signature # check in boot0cfg(8). # version_minor: .byte 0x1 # minor version -version_major: .byte 0x1 # major version +version_major: .byte 0x1 # major version drive: .ascii "Drive " -nxtdrv: .byte 0x0 # Next drive number +nxtdrv: .byte 0x0 # Next drive number opt: .byte 0x0 # Option -setdrv: .byte 0x80 # Drive to force +setdrv: .byte 0x80 # Drive to force flags: .byte FLAGS # Flags ticks: .word TICKS # Delay # # here is the 64 byte partition table that fdisk would fiddle with. # -partbl: .fill 0x40,0x1,0x0 # Partition table +partbl: .fill 0x40,0x1,0x0 # Partition table .word MAGIC # Magic number # @@ -433,7 +433,7 @@ # Menu strings item: .ascii " "; .byte ' '|0x80 -prompt: .ascii "\nDefault:"; .byte ' '|0x80 +prompt: .ascii "\nDefault:"; .byte ' '|0x80 crlf: .ascii "\r"; .byte '\n'|0x80 # Partition type tables @@ -470,13 +470,13 @@ .byte os_openbsd-. # OpenBSD .byte os_netbsd-. # NetBSD # -# And here are the strings themselves. 0x80 or'd into a byte indicates +# And here are the strings themselves. 0x80 or'd into a byte indicates # the end of the string. (not so great for Russians but...) # os_misc: .ascii "Unknow"; .byte 'n'|0x80 -os_dos: .ascii "DO"; .byte 'S'|0x80 +os_dos: .ascii "DO"; .byte 'S'|0x80 os_nt: .ascii "Windows NT/X"; .byte 'P'|0x80 -os_windows: .ascii "Window"; .byte 's'|0x80 +os_windows: .ascii "Window"; .byte 's'|0x80 os_unix: .ascii "UNI"; .byte 'X'|0x80 os_linux: .ascii "Linu"; .byte 'x'|0x80 os_freebsd: .ascii "FreeBS"; .byte 'D'|0x80 --- //depot/vendor/freebsd/src/sys/boot/i386/btx/btx/Makefile 2004/04/27 12:45:23 +++ //depot/user/jhb/acpipci/boot/i386/btx/btx/Makefile 2004/02/18 13:44:48 @@ -1,9 +1,10 @@ -# $FreeBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.18 2004/04/27 19:45:15 ru Exp $ +# $FreeBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.15 2004/02/11 08:42:37 ru Exp $ -PROG= btx +PROG= btx.out INTERNALPROG= NOMAN= SRCS= btx.S +CLEANFILES= btx .if defined(PAGING) CFLAGS+=-DPAGING @@ -28,6 +29,11 @@ ORG= 0x9000 -LDFLAGS=-N -e start -Ttext ${ORG} -Wl,-S,--oformat,binary +all: btx + +LDFLAGS=-N -e start -Ttext ${ORG} + +btx: btx.out + objcopy -S -O binary btx.out ${.TARGET} .include --- //depot/vendor/freebsd/src/sys/boot/i386/btx/btxldr/Makefile 2004/04/27 12:45:23 +++ //depot/user/jhb/acpipci/boot/i386/btx/btxldr/Makefile 2004/02/18 13:44:48 @@ -1,9 +1,10 @@ -# $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.17 2004/04/27 19:45:16 ru Exp $ +# $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.14 2004/02/11 08:42:37 ru Exp $ -PROG= btxldr +PROG= btxldr.out INTERNALPROG= NOMAN= SRCS= btxldr.S +CLEANFILES= btxldr CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} @@ -11,6 +12,11 @@ CFLAGS+=-DBTXLDR_VERBOSE .endif -LDFLAGS=-N -e start -Ttext ${LOADER_ADDRESS} -Wl,-S,--oformat,binary +all: btxldr + +LDFLAGS=-N -e start -Ttext ${LOADER_ADDRESS} + +btxldr: btxldr.out + objcopy -S -O binary btxldr.out ${.TARGET} .include --- //depot/vendor/freebsd/src/sys/boot/i386/cdboot/Makefile 2004/04/27 12:45:23 +++ //depot/user/jhb/acpipci/boot/i386/cdboot/Makefile 2004/02/18 13:44:48 @@ -1,14 +1,18 @@ -# $FreeBSD: src/sys/boot/i386/cdboot/Makefile,v 1.11 2004/04/27 19:45:16 ru Exp $ +# $FreeBSD: src/sys/boot/i386/cdboot/Makefile,v 1.8 2004/02/09 14:11:57 ru Exp $ -PROG= ${BOOT} +PROG= ${BOOT}.out INTERNALPROG= FILES= ${BOOT} NOMAN= SRCS= ${BOOT}.s +CLEANFILES= ${BOOT} BOOT= cdboot ORG= 0x7c00 -LDFLAGS=-N -e start -Ttext ${ORG} -Wl,-S,--oformat,binary +${BOOT}: ${BOOT}.out + objcopy -S -O binary ${BOOT}.out ${.TARGET} + +LDFLAGS=-N -e start -Ttext ${ORG} .include --- //depot/vendor/freebsd/src/sys/boot/i386/mbr/Makefile 2004/04/27 12:45:23 +++ //depot/user/jhb/acpipci/boot/i386/mbr/Makefile 2004/02/18 13:44:48 @@ -1,14 +1,18 @@ -# $FreeBSD: src/sys/boot/i386/mbr/Makefile,v 1.12 2004/04/27 19:45:16 ru Exp $ +# $FreeBSD: src/sys/boot/i386/mbr/Makefile,v 1.9 2004/02/09 14:11:57 ru Exp $ -PROG= ${BOOT} +PROG= ${BOOT}.out INTERNALPROG= FILES= ${BOOT} NOMAN= SRCS= ${BOOT}.s +CLEANFILES= ${BOOT} BOOT= mbr ORG= 0x600 -LDFLAGS=-N -e start -Ttext ${ORG} -Wl,-S,--oformat,binary +${BOOT}: ${BOOT}.out + objcopy -S -O binary ${BOOT}.out ${.TARGET} + +LDFLAGS=-N -e start -Ttext ${ORG} .include --- //depot/vendor/freebsd/src/sys/boot/i386/pxeldr/Makefile 2004/04/27 12:45:23 +++ //depot/user/jhb/acpipci/boot/i386/pxeldr/Makefile 2004/02/18 13:44:48 @@ -1,9 +1,9 @@ -# $FreeBSD: src/sys/boot/i386/pxeldr/Makefile,v 1.16 2004/04/27 19:45:16 ru Exp $ +# $FreeBSD: src/sys/boot/i386/pxeldr/Makefile,v 1.13 2004/02/11 08:42:38 ru Exp $ # Pick up ../Makefile.inc early. .include -PROG= ${LDR} +PROG= ${LDR}.out INTERNALPROG= FILES= ${BOOT} MAN= ${BOOT}.8 @@ -32,7 +32,12 @@ dd if=${.TARGET}.tmp of=${.TARGET} obs=2k conv=osync rm ${.TARGET}.tmp -LDFLAGS+= -N -e start -Ttext ${ORG} -Wl,-S,--oformat,binary +CLEANFILES+= ${LDR} + +${LDR}: ${LDR}.out + objcopy -S -O binary ${LDR}.out ${.TARGET} + +LDFLAGS+= -N -e start -Ttext ${ORG} CLEANFILES+= ${LOADER} --- //depot/vendor/freebsd/src/sys/compat/freebsd32/freebsd32_misc.c 2004/04/23 21:35:30 +++ //depot/user/jhb/acpipci/compat/freebsd32/freebsd32_misc.c 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.22 2004/04/24 04:31:59 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.21 2004/04/14 23:17:37 peter Exp $"); #include "opt_compat.h" @@ -120,7 +120,6 @@ return (error); } -#ifdef COMPAT_FREEBSD4 static void copy_statfs(struct statfs *in, struct statfs32 *out) { @@ -147,9 +146,7 @@ bcopy(in->f_mntfromname, out->f_mntfromname, min(MNAMELEN, FREEBSD4_MNAMELEN)); } -#endif -#ifdef COMPAT_FREEBSD4 int freebsd4_freebsd32_getfsstat(struct thread *td, struct freebsd4_freebsd32_getfsstat_args *uap) { @@ -182,7 +179,6 @@ } return (error); } -#endif struct sigaltstack32 { u_int32_t ss_sp; @@ -873,7 +869,6 @@ return (error); } -#ifdef COMPAT_FREEBSD4 int freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_args *uap) { @@ -900,9 +895,7 @@ } return (error); } -#endif -#ifdef COMPAT_FREEBSD4 int freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_args *uap) { @@ -929,9 +922,7 @@ } return (error); } -#endif -#ifdef COMPAT_FREEBSD4 int freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatfs_args *uap) { @@ -958,7 +949,6 @@ } return (error); } -#endif int freebsd32_semsys(struct thread *td, struct freebsd32_semsys_args *uap) --- //depot/vendor/freebsd/src/sys/compat/ndis/kern_ndis.c 2004/04/22 00:10:50 +++ //depot/user/jhb/acpipci/compat/ndis/kern_ndis.c 2004/04/16 11:09:59 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.53 2004/04/22 07:08:39 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.52 2004/04/16 00:04:28 wpaul Exp $"); #include #include @@ -99,7 +99,6 @@ int np_state; }; -static void ndis_return(void *); static int ndis_create_kthreads(void); static void ndis_destroy_kthreads(void); static void ndis_stop_thread(int); @@ -725,38 +724,17 @@ return(0); } -static void -ndis_return(arg) +void +ndis_return_packet(buf, arg) + void *buf; /* not used */ void *arg; { struct ndis_softc *sc; - __stdcall ndis_return_handler returnfunc; ndis_handle adapter; ndis_packet *p; + __stdcall ndis_return_handler returnfunc; uint8_t irql; - p = arg; - sc = p->np_softc; - adapter = sc->ndis_block.nmb_miniportadapterctx; - - if (adapter == NULL) - return; - - returnfunc = sc->ndis_chars.nmc_return_packet_func; - irql = FASTCALL1(hal_raise_irql, DISPATCH_LEVEL); - returnfunc(adapter, p); - FASTCALL1(hal_lower_irql, irql); - - return; -} - -void -ndis_return_packet(buf, arg) - void *buf; /* not used */ - void *arg; -{ - ndis_packet *p; - if (arg == NULL) return; @@ -769,7 +747,14 @@ if (p->np_refcnt) return; - ndis_sched(ndis_return, p, NDIS_SWI); + sc = p->np_softc; + returnfunc = sc->ndis_chars.nmc_return_packet_func; + adapter = sc->ndis_block.nmb_miniportadapterctx; + if (adapter != NULL) { + irql = FASTCALL1(hal_raise_irql, DISPATCH_LEVEL); + returnfunc(adapter, p); + FASTCALL1(hal_lower_irql, irql); + } return; } --- //depot/vendor/freebsd/src/sys/compat/ndis/ntoskrnl_var.h 2004/04/19 19:31:15 +++ //depot/user/jhb/acpipci/compat/ndis/ntoskrnl_var.h 2004/04/16 11:09:59 @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.15 2004/04/20 02:27:38 wpaul Exp $ + * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.14 2004/04/16 00:04:28 wpaul Exp $ */ #ifndef _NTOSKRNL_VAR_H_ @@ -204,7 +204,7 @@ ((td)->td_proc->p_flag & P_KTHREAD == FALSE) #define AT_DISPATCH_LEVEL(td) \ - ((td)->td_base_pri == PI_REALTIME) + ((td)->td_priority == PI_REALTIME) #define AT_DIRQL_LEVEL(td) \ ((td)->td_priority <= PI_NET) --- //depot/vendor/freebsd/src/sys/compat/ndis/subr_hal.c 2004/04/19 15:40:42 +++ //depot/user/jhb/acpipci/compat/ndis/subr_hal.c 2004/04/16 11:09:59 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_hal.c,v 1.12 2004/04/19 22:39:04 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_hal.c,v 1.11 2004/04/16 00:04:28 wpaul Exp $"); #include #include @@ -313,13 +313,9 @@ if (irql < hal_irql()) panic("IRQL_NOT_LESS_THAN"); - if (hal_irql() == DISPATCH_LEVEL) - return(DISPATCH_LEVEL); - mtx_lock_spin(&sched_lock); - oldirql = curthread->td_base_pri; + oldirql = curthread->td_priority; sched_prio(curthread, PI_REALTIME); - curthread->td_base_pri = PI_REALTIME; mtx_unlock_spin(&sched_lock); return(oldirql); @@ -332,14 +328,10 @@ __asm__ __volatile__ ("" : "=c" (oldirql)); - if (oldirql == DISPATCH_LEVEL) - return; - if (hal_irql() != DISPATCH_LEVEL) panic("IRQL_NOT_GREATER_THAN"); mtx_lock_spin(&sched_lock); - curthread->td_base_pri = oldirql; sched_prio(curthread, oldirql); mtx_unlock_spin(&sched_lock); --- //depot/vendor/freebsd/src/sys/conf/NOTES 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/conf/NOTES 2004/04/19 12:55:20 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1222 2004/04/27 16:38:12 emax Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1215 2004/04/19 03:33:54 njl Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -27,7 +27,7 @@ # order. All device and option lines must be described by a comment that # doesn't just expand the device or option name. Use only a concise # comment on the same line if possible. Very detailed descriptions of -# devices and subsystems belong in man pages. +# devices and subsystems belong in manpages. # # A space followed by a tab separates 'options' from an option name. Two # spaces followed by a tab separate 'device' from a device name. Comments @@ -189,7 +189,7 @@ options WITNESS_SKIPSPIN # MUTEX_PROFILING - Profiling mutual exclusion locks (mutexes). See -# MUTEX_PROFILING(9) for details. +# the MUTEX_PROFILING(9) manual page for details. options MUTEX_PROFILING @@ -410,15 +410,6 @@ options NETGRAPH #netgraph(4) system options NETGRAPH_ASYNC options NETGRAPH_ATMLLC -options NETGRAPH_ATM_ATMPIF -options NETGRAPH_BLUETOOTH # ng_bluetooth(4) -options NETGRAPH_BLUETOOTH_BT3C # ng_bt3c(4) -options NETGRAPH_BLUETOOTH_H4 # ng_h4(4) -options NETGRAPH_BLUETOOTH_HCI # ng_hci(4) -options NETGRAPH_BLUETOOTH_L2CAP # ng_l2cap(4) -options NETGRAPH_BLUETOOTH_SOCKET # ng_btsocket(4) -options NETGRAPH_BLUETOOTH_UBT # ng_ubt(4) -options NETGRAPH_BLUETOOTH_UBTBCMFW # ubtbcmfw(4) options NETGRAPH_BPF options NETGRAPH_BRIDGE options NETGRAPH_CISCO @@ -443,11 +434,11 @@ options NETGRAPH_RFC1490 options NETGRAPH_SOCKET options NETGRAPH_SPLIT -options NETGRAPH_SPPP options NETGRAPH_TEE options NETGRAPH_TTY options NETGRAPH_UI options NETGRAPH_VJC +options NETGRAPH_ATM_ATMPIF # NgATM - Netgraph ATM options NGATM_ATM @@ -579,8 +570,8 @@ # from traceroute and similar tools. # # PFIL_HOOKS enables an abtraction layer which is meant to be used in -# network code where filtering is required. See pfil(9). This option is -# required by the IPFILTER option and the PF device. +# network code where filtering is required. See the pfil(9) man page. +# This option is required by the IPFILTER option and the PF device. # # TCPDEBUG enables code which keeps traces of the TCP state machine # for sockets with the SO_DEBUG option set, which can then be examined @@ -606,7 +597,8 @@ # The MBUF_STRESS_TEST option enables options which create # various random failures / extreme cases related to mbuf -# functions. See mbuf(9) for a list of available test cases. +# functions. See the mbuf(9) manpage for a list of available +# test cases. options MBUF_STRESS_TEST # RANDOM_IP_ID causes the ID field in IP packets to be randomized @@ -626,18 +618,10 @@ # options TCP_DROP_SYNFIN #drop TCP packets with SYN+FIN -# TCP_SIGNATURE adds support for RFC 2385 (TCP-MD5) digests. These are -# carried in TCP option 19. This option is commonly used to protect -# TCP sessions (e.g. BGP) where IPSEC is not available nor desirable. -# This is enabled on a per-socket basis using the TCP_MD5SIG socket option. -# This requires the use of 'device crypto', 'options FAST_IPSEC', and -# 'device cryptodev' as it depends on the non-KAME IPSEC SADB code. -#options TCP_SIGNATURE #include support for RFC 2385 - -# DUMMYNET enables the "dummynet" bandwidth limiter. You need IPFIREWALL -# as well. See dummynet(4) and ipfw(8) for more info. When you run -# DUMMYNET it is advisable to also have "options HZ=1000" to achieve a -# smoother scheduling of the traffic. +# DUMMYNET enables the "dummynet" bandwidth limiter. You need +# IPFIREWALL as well. See the dummynet(4) and ipfw(8) manpages for more info. +# When you run DUMMYNET it is advisable to also have "options HZ=1000" +# to achieve a smoother scheduling of the traffic. # # BRIDGE enables bridging between ethernet cards -- see bridge(4). # You can use IPFIREWALL and DUMMYNET together with bridging. @@ -1280,14 +1264,15 @@ # Aic7xxx driver debugging options. See sys/dev/aic7xxx/aic7xxx.h options AHC_DEBUG_OPTS -# Print register bitfields in debug output. Adds ~128k to driver -# See ahc(4). +# Print register bitfields in debug output. Adds ~128k to driver. +# See the ahc(4) manpage options AHC_REG_PRETTY_PRINT # Compile in aic79xx debugging code. options AHD_DEBUG -# Aic79xx driver debugging options. Adds ~215k to driver. See ahd(4). +# Aic79xx driver debugging options. Adds ~215k to driver. +# See the ahd(4) manpage options AHD_DEBUG_OPTS=0xFFFFFFFF # Print human-readable register definitions when debugging @@ -1771,7 +1756,8 @@ # # This has support for a large number of new audio cards, based on # CS423x, OPTi931, Yamaha OPL-SAx, and also for SB16, GusPnP. -# For more information about this driver and supported cards, see pcm(4). +# For more information about this driver and supported cards, +# see the pcm.4 man page. # # The flags of the device tells the device a bit more info about the # device that normally is obtained through the PnP interface. @@ -2415,6 +2401,8 @@ # items in loops, etc. # Yet more undocumented options for linting. +# Broken: +##options ASR_MEASURE_PERFORMANCE # BKTR_ALLOC_PAGES has no effect except to cause warnings, and # BROOKTREE_ALLOC_PAGES hasn't actually been superseded by it, since the # driver still mostly spells this option BROOKTREE_ALLOC_PAGES. --- //depot/vendor/freebsd/src/sys/conf/files 2004/04/24 15:05:31 +++ //depot/user/jhb/acpipci/conf/files 2004/04/16 11:09:59 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.890 2004/04/24 22:03:02 rik Exp $ +# $FreeBSD: src/sys/conf/files,v 1.886 2004/04/14 18:13:16 njl Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -450,6 +450,7 @@ dev/hfa/fore_if.c optional hfa dev/hfa/fore_init.c optional hfa dev/hfa/fore_intr.c optional hfa +#dev/hfa/fore_load.c optional hfa nowerror dev/hfa/fore_output.c optional hfa dev/hfa/fore_receive.c optional hfa dev/hfa/fore_stats.c optional hfa @@ -1353,27 +1354,6 @@ contrib/ngatm/netnatm/sig/sig_uni.c optional ngatm_uni contrib/ngatm/netnatm/sig/sig_unimsgcpy.c optional ngatm_uni contrib/ngatm/netnatm/sig/sig_verify.c optional ngatm_uni -netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth -netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c optional netgraph_bluetooth_bt3c -netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4 -netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt -netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c optional netgraph_bluetooth_ubtbcmfw -netgraph/bluetooth/hci/ng_hci_cmds.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_evnt.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_main.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_misc.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_ulpi.c optional netgraph_bluetooth_hci -netgraph/bluetooth/l2cap/ng_l2cap_cmds.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_evnt.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_llpi.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_main.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_misc.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/socket/ng_btsocket.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_hci_raw.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_l2cap.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_rfcomm.c optional netgraph_bluetooth_socket netgraph/ng_UI.c optional netgraph_UI netgraph/ng_async.c optional netgraph_async netgraph/ng_atmllc.c optional netgraph_atmllc @@ -1407,7 +1387,6 @@ netgraph/ng_rfc1490.c optional netgraph_rfc1490 netgraph/ng_socket.c optional netgraph_socket netgraph/ng_split.c optional netgraph_split -netgraph/ng_sppp.c optional netgraph_sppp netgraph/ng_tee.c optional netgraph_tee netgraph/ng_tty.c optional netgraph_tty netgraph/ng_vjc.c optional netgraph_vjc --- //depot/vendor/freebsd/src/sys/conf/files.amd64 2004/04/23 07:46:53 +++ //depot/user/jhb/acpipci/conf/files.amd64 2004/03/26 08:52:16 @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.amd64,v 1.31 2004/04/23 14:41:23 tjr Exp $ +# $FreeBSD: src/sys/conf/files.amd64,v 1.30 2004/03/20 19:36:29 alc Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -90,9 +90,6 @@ crypto/des/des_enc.c optional ipsec ipsec_esp crypto/blowfish/bf_enc.c optional crypto crypto/des/des_enc.c optional crypto -crypto/des/des_ecb.c optional netsmbcrypto -crypto/des/des_enc.c optional netsmbcrypto -crypto/des/des_setkey.c optional netsmbcrypto dev/fb/fb.c optional fb dev/fb/fb.c optional vga dev/fb/splash.c optional splash --- //depot/vendor/freebsd/src/sys/conf/files.i386 2004/04/22 14:30:37 +++ //depot/user/jhb/acpipci/conf/files.i386 2004/04/27 13:00:22 @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.i386,v 1.485 2004/04/22 21:29:01 philip Exp $ +# $FreeBSD: src/sys/conf/files.i386,v 1.484 2004/04/10 19:43:15 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -179,7 +179,6 @@ libkern/ffsl.c standard libkern/flsl.c standard i386/acpica/OsdEnvironment.c optional acpi -i386/acpica/acpi_asus.c optional acpi_asus acpi i386/acpica/acpi_machdep.c optional acpi i386/acpica/acpi_toshiba.c optional acpi_toshiba acpi i386/acpica/acpi_wakeup.c optional acpi @@ -268,6 +267,7 @@ i386/isa/atpic_vector.s standard i386/isa/clock.c standard i386/isa/cy.c count cy +i386/isa/elcr.c standard i386/isa/elink.c optional ep i386/isa/elink.c optional ie i386/isa/if_el.c count el --- //depot/vendor/freebsd/src/sys/conf/kern.pre.mk 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/conf/kern.pre.mk 2004/04/01 11:35:50 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.52 2004/04/27 16:38:13 emax Exp $ +# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.50 2004/03/29 01:15:39 kensmith Exp $ # Part of a unified Makefile for building kernels. This part contains all # of the definitions that need to be before %BEFORE_DEPEND. --- //depot/vendor/freebsd/src/sys/conf/options 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/conf/options 2004/04/19 12:55:20 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options,v 1.445 2004/04/27 16:38:13 emax Exp $ +# $FreeBSD: src/sys/conf/options,v 1.441 2004/04/19 03:33:55 njl Exp $ # # On the handling of kernel options # @@ -351,15 +351,6 @@ NETGRAPH NETGRAPH_ASYNC opt_netgraph.h NETGRAPH_ATMLLC opt_netgraph.h -NETGRAPH_ATM_ATMPIF opt_netgraph.h -NETGRAPH_BLUETOOTH opt_netgraph.h -NETGRAPH_BLUETOOTH_BT3C opt_netgraph.h -NETGRAPH_BLUETOOTH_H4 opt_netgraph.h -NETGRAPH_BLUETOOTH_HCI opt_netgraph.h -NETGRAPH_BLUETOOTH_L2CAP opt_netgraph.h -NETGRAPH_BLUETOOTH_SOCKET opt_netgraph.h -NETGRAPH_BLUETOOTH_UBT opt_netgraph.h -NETGRAPH_BLUETOOTH_UBTBCMFW opt_netgraph.h NETGRAPH_BPF opt_netgraph.h NETGRAPH_BRIDGE opt_netgraph.h NETGRAPH_CISCO opt_netgraph.h @@ -384,11 +375,11 @@ NETGRAPH_RFC1490 opt_netgraph.h NETGRAPH_SOCKET opt_netgraph.h NETGRAPH_SPLIT opt_netgraph.h -NETGRAPH_SPPP opt_netgraph.h NETGRAPH_TEE opt_netgraph.h NETGRAPH_TTY opt_netgraph.h NETGRAPH_UI opt_netgraph.h NETGRAPH_VJC opt_netgraph.h +NETGRAPH_ATM_ATMPIF opt_netgraph.h # NgATM options NGATM_ATM opt_netgraph.h @@ -422,6 +413,9 @@ DPT_LOST_IRQ opt_dpt.h DPT_RESET_HBA opt_dpt.h +# Adaptec ASR and DPT V/VI controller options +ASR_MEASURE_PERFORMANCE opt_asr.h + # Misc debug flags. Most of these should probably be replaced with # 'DEBUG', and then let people recompile just the interesting modules # with 'make CC="cc -DDEBUG"'. --- //depot/vendor/freebsd/src/sys/dev/acpica/Osd/OsdTable.c 2004/04/20 10:15:59 +++ //depot/user/jhb/acpipci/dev/acpica/Osd/OsdTable.c 2004/02/18 13:44:48 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/Osd/OsdTable.c,v 1.7 2004/04/20 17:13:08 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/Osd/OsdTable.c,v 1.6 2004/02/14 03:17:30 njl Exp $ */ /* @@ -66,17 +66,30 @@ caddr_t acpi_dsdt, p; if (ExistingTable == NULL || NewTable == NULL) + { return(AE_BAD_PARAMETER); + } + + (*NewTable) = NULL; - *NewTable = NULL; if (strncmp(ExistingTable->Signature, "DSDT", 4) != 0) + { return(AE_OK); + } + if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) == NULL) + { return(AE_OK); + } + if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) == NULL) + { return(AE_OK); + } + + (*NewTable) = *(void **)p; - *NewTable = *(void **)p; printf("ACPI: DSDT was overridden.\n"); - return (AE_OK); + + return(AE_OK); } --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi.c 2004/04/26 01:50:39 +++ //depot/user/jhb/acpipci/dev/acpica/acpi.c 2004/04/16 11:16:25 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.143 2004/04/26 08:49:11 takawata Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.139 2004/04/16 16:27:37 njl Exp $ */ #include "opt_acpi.h" @@ -1159,7 +1159,7 @@ static void acpi_shutdown_final(void *arg, int howto) { - ACPI_STATUS status; + ACPI_ASSERTLOCK; /* @@ -1168,12 +1168,6 @@ * not power off the system correctly if called from an AP. */ if ((howto & RB_POWEROFF) != 0) { - status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); - if (ACPI_FAILURE(status)) { - printf("AcpiEnterSleepStatePrep failed - %s\n", - AcpiFormatException(status)); - return; - } printf("Powering system off using ACPI\n"); smp_rendezvous(NULL, acpi_shutdown_poweroff, NULL, NULL); } else { @@ -1182,10 +1176,6 @@ } } -/* - * Since this function may be called with locks held or in an unknown - * context, it cannot allocate memory, acquire locks, sleep, etc. - */ static void acpi_shutdown_poweroff(void *arg) { @@ -1197,6 +1187,12 @@ if (PCPU_GET(cpuid) != 0) return; + status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); + if (ACPI_FAILURE(status)) { + printf("AcpiEnterSleepStatePrep failed - %s\n", + AcpiFormatException(status)); + return; + } ACPI_DISABLE_IRQS(); status = AcpiEnterSleepState(ACPI_STATE_S5); if (ACPI_FAILURE(status)) { @@ -1376,21 +1372,6 @@ } } -/* Find the difference between two PM tick counts. */ -uint32_t -acpi_TimerDelta(uint32_t end, uint32_t start) -{ - uint32_t delta; - - if (end >= start) - delta = end - start; - else if (AcpiGbl_FADT->TmrValExt == 0) - delta = ((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF; - else - delta = ((0xFFFFFFFF - start) + end + 1); - return (delta); -} - /* * Allocate a buffer with a preset data size. */ --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_acad.c 2004/04/20 06:12:53 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_acad.c 2004/04/16 11:09:59 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi_acad.c,v 1.23 2004/04/20 13:09:17 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi_acad.c,v 1.22 2004/04/09 18:14:32 njl Exp $ */ #include "opt_acpi.h" @@ -137,8 +137,9 @@ static int acpi_acad_probe(device_t dev) { - if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("acad") && + if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && acpi_MatchHid(dev, "ACPI0003")) { + device_set_desc(dev, "AC Adapter"); return (0); } --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_cpu.c 2004/04/20 17:40:00 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_cpu.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_cpu.c,v 1.34 2004/04/21 00:36:15 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_cpu.c,v 1.33 2004/04/09 18:14:32 njl Exp $"); #include "opt_acpi.h" #include @@ -42,9 +42,6 @@ #include #include #include -#ifdef __ia64__ -#include -#endif #include #include "acpi.h" @@ -132,6 +129,7 @@ static uint32_t cpu_non_c3; /* Index of lowest non-C3 state. */ static struct acpi_cx_stats cpu_cx_stats[MAX_CX_STATES]; static int cpu_idle_busy; /* Count of CPUs in acpi_cpu_idle. */ +static void (*cpu_idle_halt)(void); /* Previous CPU idle hook. */ /* Values for sysctl. */ static uint32_t cpu_throttle_state; @@ -159,7 +157,7 @@ static void acpi_cpu_startup_cx(void); static void acpi_cpu_throttle_set(uint32_t speed); static void acpi_cpu_idle(void); -static void acpi_cpu_c1(void); +static void acpi_pm_ticksub(uint32_t *end, const uint32_t *start); static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context); static int acpi_cpu_quirks(struct acpi_cpu_softc *sc); static int acpi_cpu_throttle_sysctl(SYSCTL_HANDLER_ARGS); @@ -207,7 +205,7 @@ ACPI_OBJECT pobj; ACPI_BUFFER buf; ACPI_STATUS status; - int thr_ret, cx_ret, cpu_id; + int cx_ret, cpu_id, thr_ret; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -723,6 +721,7 @@ /* Take over idling from cpu_idle_default(). */ cpu_cx_next = cpu_cx_lowest; + cpu_idle_halt = cpu_idle_hook; cpu_idle_hook = acpi_cpu_idle; } @@ -794,7 +793,7 @@ */ sc = cpu_softc[PCPU_GET(cpuid)]; if (sc == NULL) { - acpi_cpu_c1(); + cpu_idle_halt(); return; } @@ -823,7 +822,7 @@ /* NOTREACHED */ case ACPI_STATE_C1: /* Execute HLT (or equivalent) and wait for an interrupt. */ - acpi_cpu_c1(); + cpu_idle_halt(); /* * We can't calculate the time spent in C1 since the place we @@ -874,7 +873,7 @@ } /* Find the actual time asleep in microseconds, minus overhead. */ - end_time = acpi_TimerDelta(end_time, start_time); + acpi_pm_ticksub(&end_time, &start_time); asleep = PM_USEC(end_time) - cx_next->trans_lat; /* Record statistics */ @@ -903,15 +902,16 @@ atomic_subtract_int(&cpu_idle_busy, 1); } -/* Put the CPU in C1 in a machine-dependant way. */ +/* Find the difference between two PM tick counts. */ static void -acpi_cpu_c1() +acpi_pm_ticksub(uint32_t *end, const uint32_t *start) { -#ifdef __ia64__ - ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0); -#else - __asm __volatile("sti; hlt"); -#endif + if (*end >= *start) + *end = *end - *start; + else if (AcpiGbl_FADT->TmrValExt == 0) + *end = (((0x00FFFFFF - *start) + *end + 1) & 0x00FFFFFF); + else + *end = ((0xFFFFFFFF - *start) + *end + 1); } /* --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_pci.c 2004/04/25 19:15:34 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_pci.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.14 2004/04/26 02:11:38 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.13 2004/04/14 17:46:21 njl Exp $"); #include "opt_bus.h" @@ -207,7 +207,7 @@ acpi_state, device_get_nameunit(child), AcpiFormatException(status)); } - if (old_state > state) + if (state > old_state) return (pci_set_powerstate_method(dev, child, state)); else return (0); --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_pci_link.c 2004/04/13 20:35:18 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_pci_link.c 2004/04/16 11:09:59 @@ -48,7 +48,6 @@ TAILQ_ENTRY(acpi_pci_link_entry) links; ACPI_HANDLE handle; UINT8 current_irq; - UINT8 initial_irq; ACPI_RESOURCE possible_resources; UINT8 number_of_interrupts; UINT8 interrupts[MAX_POSSIBLE_INTERRUPTS]; @@ -73,6 +72,9 @@ static int irq_penalty[MAX_ACPI_INTERRUPTS]; +static int acpi_pci_link_is_valid_irq(struct acpi_pci_link_entry *link, + UINT8 irq); + #define ACPI_STA_PRESENT 0x00000001 #define ACPI_STA_ENABLE 0x00000002 #define ACPI_STA_SHOWINUI 0x00000004 @@ -382,7 +384,12 @@ acpi_name(handle), AcpiFormatException(error))); } - link->initial_irq = link->current_irq; + if (!acpi_pci_link_is_valid_irq(link, link->current_irq)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "initial IRQ %u is invalid for link %s\n", + link->current_irq, acpi_name(handle))); + link->current_irq = 0; + } error = AcpiGetPossibleResources(handle, &buf); if (ACPI_FAILURE(error)) { @@ -525,11 +532,6 @@ if (link->interrupts[i] == irq) return (1); } - - /* allow initial IRQ as valid one. */ - if (link->initial_irq == irq) - return (1); - return (0); } --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_timer.c 2004/04/24 09:25:48 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_timer.c 2004/04/16 11:09:59 @@ -24,14 +24,18 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi_timer.c,v 1.32 2004/04/24 16:25:00 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi_timer.c,v 1.28 2004/04/09 18:14:32 njl Exp $ */ #include "opt_acpi.h" #include #include #include #include +#if __FreeBSD_version >= 500000 #include +#else +#include +#endif #include #include @@ -51,23 +55,21 @@ #define _COMPONENT ACPI_TIMER ACPI_MODULE_NAME("TIMER") -static device_t acpi_timer_dev; -static struct resource *acpi_timer_reg; -static bus_space_handle_t acpi_timer_bsh; -static bus_space_tag_t acpi_timer_bst; +static device_t acpi_timer_dev; +struct resource *acpi_timer_reg; static u_int acpi_timer_frequency = 14318182 / 4; static void acpi_timer_identify(driver_t *driver, device_t parent); static int acpi_timer_probe(device_t dev); static int acpi_timer_attach(device_t dev); -static u_int acpi_timer_get_timecount(struct timecounter *tc); -static u_int acpi_timer_get_timecount_safe(struct timecounter *tc); +static unsigned acpi_timer_get_timecount(struct timecounter *tc); +static unsigned acpi_timer_get_timecount_safe(struct timecounter *tc); static int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS); -static void acpi_timer_boot_test(void); +static void acpi_timer_test(void); -static u_int acpi_timer_read(void); -static int acpi_timer_test(void); +static uint32_t read_counter(void); +static int test_counter(void); static device_method_t acpi_timer_methods[] = { DEVMETHOD(device_identify, acpi_timer_identify), @@ -88,19 +90,63 @@ MODULE_DEPEND(acpi_timer, acpi, 1, 1, 1); static struct timecounter acpi_timer_timecounter = { - acpi_timer_get_timecount_safe, /* get_timecount function */ - 0, /* no poll_pps */ - 0, /* no default counter_mask */ - 0, /* no default frequency */ - "ACPI", /* name */ - 1000 /* quality */ + acpi_timer_get_timecount_safe, + 0, + 0xffffff, + 0, + "ACPI", + 1000 }; -static u_int -acpi_timer_read() +static uint32_t +read_counter() +{ + bus_space_handle_t bsh; + bus_space_tag_t bst; + u_int32_t tv; + + bsh = rman_get_bushandle(acpi_timer_reg); + bst = rman_get_bustag(acpi_timer_reg); + tv = bus_space_read_4(bst, bsh, 0); + bus_space_barrier(bst, bsh, 0, 4, BUS_SPACE_BARRIER_READ); + + return (tv); +} + +#define N 2000 +static int +test_counter() { - return (bus_space_read_4(acpi_timer_bst, acpi_timer_bsh, 0)); + u_int last, this; + int min, max, n, delta; + + min = 10000000; + max = 0; + last = read_counter(); + for (n = 0; n < N; n++) { + this = read_counter(); + delta = (this - last) & 0xffffff; + if (delta > max) + max = delta; + else if (delta < min) + min = delta; + last = this; + } + if (max - min > 2) + n = 0; + else if (min < 0 || max == 0) + n = 0; + else + n = 1; + if (bootverbose) { + printf("ACPI timer looks %s min = %d, max = %d, width = %d\n", + n ? "GOOD" : "BAD ", + min, max, max - min); + } + + return (n); } +#undef N /* * Locate the ACPI timer using the FADT, set up and allocate the I/O resources @@ -118,7 +164,7 @@ if (acpi_disabled("timer") || AcpiGbl_FADT == NULL) return_VOID; - + if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) { device_printf(parent, "could not add acpi_timer0\n"); return_VOID; @@ -137,24 +183,13 @@ rtype == SYS_RES_IOPORT ? "port" : "mem", rstart); return_VOID; } - acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); - acpi_timer_bst = rman_get_bustag(acpi_timer_reg); - if (AcpiGbl_FADT->TmrValExt != 0) - acpi_timer_timecounter.tc_counter_mask = 0xffffffff; - else - acpi_timer_timecounter.tc_counter_mask = 0x00ffffff; - acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; if (testenv("debug.acpi.timer_test")) - acpi_timer_boot_test(); + acpi_timer_test(); - /* - * If all tests of the counter succeed, use the ACPI-fast method. If - * at least one failed, default to using the safe routine, which reads - * the timer multiple times to get a consistent value before returning. - */ + acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; j = 0; - for (i = 0; i < 10; i++) - j += acpi_timer_test(); + for(i = 0; i < 10; i++) + j += test_counter(); if (j == 10) { acpi_timer_timecounter.tc_name = "ACPI-fast"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; @@ -189,31 +224,28 @@ /* * Fetch current time value from reliable hardware. */ -static u_int +static unsigned acpi_timer_get_timecount(struct timecounter *tc) { - return (acpi_timer_read()); + return (read_counter()); } /* * Fetch current time value from hardware that may not correctly - * latch the counter. We need to read until we have three monotonic - * samples and then use the middle one, otherwise we are not protected - * against the fact that the bits can be wrong in two directions. If - * we only cared about monosity, two reads would be enough. + * latch the counter. */ -static u_int +static unsigned acpi_timer_get_timecount_safe(struct timecounter *tc) { - u_int u1, u2, u3; + unsigned u1, u2, u3; - u2 = acpi_timer_read(); - u3 = acpi_timer_read(); + u2 = read_counter(); + u3 = read_counter(); do { u1 = u2; u2 = u3; - u3 = acpi_timer_read(); - } while (u1 > u2 || u2 > u3); + u3 = read_counter(); + } while (u1 > u2 || u2 > u3 || u3 - u1 > 15); return (u2); } @@ -243,13 +275,48 @@ 0, sizeof(u_int), acpi_timer_sysctl_freq, "I", ""); /* + * Test harness for verifying ACPI timer behaviour. + * Boot with debug.acpi.timer_test set to invoke this. + */ +static void +acpi_timer_test(void) +{ + u_int32_t u1, u2, u3; + + u1 = read_counter(); + u2 = read_counter(); + u3 = read_counter(); + + device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n"); + for (;;) { + /* + * The failure case is where u3 > u1, but u2 does not fall between + * the two, ie. it contains garbage. + */ + if (u3 > u1) { + if (u2 < u1 || u2 > u3) + device_printf(acpi_timer_dev, + "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n", + u1, u2, u3); + } + u1 = u2; + u2 = u3; + u3 = read_counter(); + } +} + +/* + * Chipset workaround driver hung off PCI. + * * Some ACPI timers are known or believed to suffer from implementation - * problems which can lead to erroneous values being read. This function - * tests for consistent results from the timer and returns 1 if it believes - * the timer is consistent, otherwise it returns 0. + * problems which can lead to erroneous values being read from the timer. + * + * Since we can't trust unknown chipsets, we default to a timer-read + * routine which compensates for the most common problem (as detailed + * in the excerpt from the Intel PIIX4 datasheet below). * - * It appears the cause is that the counter is not latched to the PCI bus - * clock when read: + * When we detect a known-functional chipset, we disable the workaround + * to improve speed. * * ] 20. ACPI Timer Errata * ] @@ -265,75 +332,59 @@ * ] Workaround: Read the register twice and compare. * ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed * ] in the PIIX4M. + * + * The counter is in other words not latched to the PCI bus clock when + * read. Notice the workaround isn't: We need to read until we have + * three monotonic samples and then use the middle one, otherwise we are + * not protected against the fact that the bits can be wrong in two + * directions. If we only cared about monosity two reads would be enough. */ -#define N 2000 -static int -acpi_timer_test() -{ - uint32_t last, this; - int min, max, n, delta; - register_t s; - min = 10000000; - max = 0; +#if 0 +static int acpi_timer_pci_probe(device_t dev); - /* Test the timer with interrupts disabled to get accurate results. */ - s = intr_disable(); - last = acpi_timer_read(); - for (n = 0; n < N; n++) { - this = acpi_timer_read(); - delta = acpi_TimerDelta(this, last); - if (delta > max) - max = delta; - else if (delta < min) - min = delta; - last = this; - } - intr_restore(s); +static device_method_t acpi_timer_pci_methods[] = { + DEVMETHOD(device_probe, acpi_timer_pci_probe), + {0, 0} +}; - if (max - min > 2) - n = 0; - else if (min < 0 || max == 0) - n = 0; - else - n = 1; - if (bootverbose) { - printf("ACPI timer looks %s min = %d, max = %d, width = %d\n", - n ? "GOOD" : "BAD ", - min, max, max - min); - } +static driver_t acpi_timer_pci_driver = { + "acpi_timer_pci", + acpi_timer_pci_methods, + 0, +}; - return (n); -} -#undef N +devclass_t acpi_timer_pci_devclass; +DRIVER_MODULE(acpi_timer_pci, pci, acpi_timer_pci_driver, + acpi_timer_pci_devclass, 0, 0); /* - * Test harness for verifying ACPI timer behaviour. - * Boot with debug.acpi.timer_test set to invoke this. + * Look at PCI devices going past; if we detect one we know contains + * a functional ACPI timer device, enable the faster timecounter read + * routine. */ -static void -acpi_timer_boot_test(void) +static int +acpi_timer_pci_probe(device_t dev) { - uint32_t u1, u2, u3; + int vendor, device, revid; + + vendor = pci_get_vendor(dev); + device = pci_get_device(dev); + revid = pci_get_revid(dev); + + /* Detect the PIIX4M and i440MX, respectively */ + if ((vendor == 0x8086 && device == 0x7113 && revid >= 0x03) || + (vendor == 0x8086 && device == 0x719b)) { - u1 = acpi_timer_read(); - u2 = acpi_timer_read(); - u3 = acpi_timer_read(); - - device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n"); - for (;;) { - /* - * The failure case is where u3 > u1, but u2 does not fall between - * the two, ie. it contains garbage. - */ - if (u3 > u1) { - if (u2 < u1 || u2 > u3) - device_printf(acpi_timer_dev, - "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n", - u1, u2, u3); + acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; + acpi_timer_timecounter.tc_name = "ACPI-fast"; + if (bootverbose) { + device_printf(acpi_timer_dev,"functional ACPI timer detected, " + "enabling fast timecount interface\n"); } - u1 = u2; - u2 = u3; - u3 = acpi_timer_read(); } + + /* We never match anything */ + return (ENXIO); } +#endif --- //depot/vendor/freebsd/src/sys/dev/acpica/acpivar.h 2004/04/22 14:30:37 +++ //depot/user/jhb/acpipci/dev/acpica/acpivar.h 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.63 2004/04/22 21:29:01 philip Exp $ + * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.61 2004/04/14 03:39:08 njl Exp $ */ #include "bus_if.h" @@ -124,7 +124,6 @@ #define ACPI_PROCESSOR 0x00800000 #define ACPI_THERMAL 0x01000000 #define ACPI_TIMER 0x02000000 -#define ACPI_ASUS 0x04000000 /* * Constants for different interrupt models used with acpi_SetIntrModel(). @@ -234,7 +233,6 @@ extern BOOLEAN acpi_MatchHid(device_t dev, char *hid); extern ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result); -extern uint32_t acpi_TimerDelta(uint32_t end, uint32_t start); extern ACPI_BUFFER *acpi_AllocBuffer(int size); extern ACPI_STATUS acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp, UINT32 *number); --- //depot/vendor/freebsd/src/sys/dev/asr/asr.c 2004/04/21 19:25:31 +++ //depot/user/jhb/acpipci/dev/asr/asr.c 2004/03/26 08:52:16 @@ -105,7 +105,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/asr/asr.c,v 1.47 2004/04/22 02:22:18 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/asr/asr.c,v 1.40 2004/03/17 17:50:26 njl Exp $"); #define ASR_VERSION 1 #define ASR_REVISION '0' @@ -118,7 +118,7 @@ * Debug macros to reduce the unsightly ifdefs */ #if (defined(DEBUG_ASR) || defined(DEBUG_ASR_USR_CMD) || defined(DEBUG_ASR_CMD)) -#define debug_asr_message(message) \ +# define debug_asr_message(message) \ { \ u_int32_t * pointer = (u_int32_t *)message; \ u_int32_t length = I2O_MESSAGE_FRAME_getMessageSize(message);\ @@ -135,20 +135,20 @@ #if (defined(DEBUG_ASR)) /* Breaks on none STDC based compilers :-( */ -#define debug_asr_printf(fmt,args...) printf(fmt, ##args) -#define debug_asr_dump_message(message) debug_asr_message(message) -#define debug_asr_print_path(ccb) xpt_print_path(ccb->ccb_h.path); +# define debug_asr_printf(fmt,args...) printf(fmt, ##args) +# define debug_asr_dump_message(message) debug_asr_message(message) +# define debug_asr_print_path(ccb) xpt_print_path(ccb->ccb_h.path); /* None fatal version of the ASSERT macro */ -#if (defined(__STDC__)) -#define ASSERT(phrase) if(!(phrase))printf(#phrase " at line %d file %s\n",__LINE__,__FILE__) -#else -#define ASSERT(phrase) if(!(phrase))printf("phrase" " at line %d file %s\n",__LINE__,__FILE__) -#endif +# if (defined(__STDC__)) +# define ASSERT(phrase) if(!(phrase))printf(#phrase " at line %d file %s\n",__LINE__,__FILE__) +# else +# define ASSERT(phrase) if(!(phrase))printf("phrase" " at line %d file %s\n",__LINE__,__FILE__) +# endif #else /* DEBUG_ASR */ -#define debug_asr_printf(fmt,args...) -#define debug_asr_dump_message(message) -#define debug_asr_print_path(ccb) -#define ASSERT(x) +# define debug_asr_printf(fmt,args...) +# define debug_asr_dump_message(message) +# define debug_asr_print_path(ccb) +# define ASSERT(x) #endif /* DEBUG_ASR */ /* @@ -158,8 +158,8 @@ * 2 - add in outgoing message frames. */ #if (defined(DEBUG_ASR_CMD)) -#define debug_asr_cmd_printf(fmt,args...) printf(fmt,##args) -#define debug_asr_dump_ccb(ccb) \ +# define debug_asr_cmd_printf(fmt,args...) printf(fmt,##args) +# define debug_asr_dump_ccb(ccb) \ { \ u_int8_t * cp = (unsigned char *)&(ccb->csio.cdb_io); \ int len = ccb->csio.cdb_len; \ @@ -169,32 +169,32 @@ --len; \ } \ } -#if (DEBUG_ASR_CMD > 0) -#define debug_asr_cmd1_printf debug_asr_cmd_printf -#else -#define debug_asr_cmd1_printf(fmt,args...) -#endif -#if (DEBUG_ASR_CMD > 1) -#define debug_asr_cmd2_printf debug_asr_cmd_printf -#define debug_asr_cmd2_dump_message(message) debug_asr_message(message) -#else -#define debug_asr_cmd2_printf(fmt,args...) -#define debug_asr_cmd2_dump_message(message) -#endif +# if (DEBUG_ASR_CMD > 0) +# define debug_asr_cmd1_printf debug_asr_cmd_printf +# else +# define debug_asr_cmd1_printf(fmt,args...) +# endif +# if (DEBUG_ASR_CMD > 1) +# define debug_asr_cmd2_printf debug_asr_cmd_printf +# define debug_asr_cmd2_dump_message(message) debug_asr_message(message) +# else +# define debug_asr_cmd2_printf(fmt,args...) +# define debug_asr_cmd2_dump_message(message) +# endif #else /* DEBUG_ASR_CMD */ -#define debug_asr_cmd_printf(fmt,args...) -#define debug_asr_cmd_dump_ccb(ccb) -#define debug_asr_cmd1_printf(fmt,args...) -#define debug_asr_cmd2_printf(fmt,args...) -#define debug_asr_cmd2_dump_message(message) +# define debug_asr_cmd_printf(fmt,args...) +# define debug_asr_cmd_dump_ccb(ccb) +# define debug_asr_cmd1_printf(fmt,args...) +# define debug_asr_cmd2_printf(fmt,args...) +# define debug_asr_cmd2_dump_message(message) #endif /* DEBUG_ASR_CMD */ #if (defined(DEBUG_ASR_USR_CMD)) -#define debug_usr_cmd_printf(fmt,args...) printf(fmt,##args) -#define debug_usr_cmd_dump_message(message) debug_usr_message(message) +# define debug_usr_cmd_printf(fmt,args...) printf(fmt,##args) +# define debug_usr_cmd_dump_message(message) debug_usr_message(message) #else /* DEBUG_ASR_USR_CMD */ -#define debug_usr_cmd_printf(fmt,args...) -#define debug_usr_cmd_dump_message(message) +# define debug_usr_cmd_printf(fmt,args...) +# define debug_usr_cmd_dump_message(message) #endif /* DEBUG_ASR_USR_CMD */ #define dsDescription_size 46 /* Snug as a bug in a rug */ @@ -251,10 +251,10 @@ #define INLINE #if (defined(DEBUG_ASR) && (DEBUG_ASR > 0)) -#undef STATIC -#define STATIC -#undef INLINE -#define INLINE +# undef STATIC +# define STATIC +# undef INLINE +# define INLINE #endif #define IN #define OUT @@ -267,6 +267,7 @@ #include "dev/asr/i2obscsi.h" #include "dev/asr/i2odpt.h" #include "dev/asr/i2oadptr.h" +#include "opt_asr.h" #include "dev/asr/sys_info.h" @@ -294,7 +295,7 @@ U8 Address[0x30]; volatile U32 Status; volatile U32 Mask; -#define Mask_InterruptsDisabled 0x08 +# define Mask_InterruptsDisabled 0x08 U32 x[2]; volatile U32 ToFIFO; /* In Bound FIFO */ volatile U32 FromFIFO; /* Out Bound FIFO */ @@ -338,29 +339,31 @@ LIST_HEAD(,ccb_hdr) ha_ccb; /* ccbs in use */ struct cam_path * ha_path[MAX_CHANNEL+1]; struct cam_sim * ha_sim[MAX_CHANNEL+1]; +#if __FreeBSD_version >= 400000 struct resource * ha_mem_res; struct resource * ha_mes_res; struct resource * ha_irq_res; void * ha_intr; +#endif PI2O_LCT ha_LCT; /* Complete list of devices */ -#define le_type IdentityTag[0] -#define I2O_BSA 0x20 -#define I2O_FCA 0x40 -#define I2O_SCSI 0x00 -#define I2O_PORT 0x80 -#define I2O_UNKNOWN 0x7F -#define le_bus IdentityTag[1] -#define le_target IdentityTag[2] -#define le_lun IdentityTag[3] +# define le_type IdentityTag[0] +# define I2O_BSA 0x20 +# define I2O_FCA 0x40 +# define I2O_SCSI 0x00 +# define I2O_PORT 0x80 +# define I2O_UNKNOWN 0x7F +# define le_bus IdentityTag[1] +# define le_target IdentityTag[2] +# define le_lun IdentityTag[3] target2lun_t * ha_targets[MAX_CHANNEL+1]; PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME ha_Msgs; u_long ha_Msgs_Phys; u_int8_t ha_in_reset; -#define HA_OPERATIONAL 0 -#define HA_IN_RESET 1 -#define HA_OFF_LINE 2 -#define HA_OFF_LINE_RECOVERY 3 +# define HA_OPERATIONAL 0 +# define HA_IN_RESET 1 +# define HA_OFF_LINE 2 +# define HA_OFF_LINE_RECOVERY 3 /* Configuration information */ /* The target id maximums we take */ u_int8_t ha_MaxBus; /* Maximum bus */ @@ -375,6 +378,43 @@ /* Links into other parents and HBAs */ struct Asr_softc * ha_next; /* HBA list */ + +#ifdef ASR_MEASURE_PERFORMANCE +#define MAX_TIMEQ_SIZE 256 /* assumes MAX 256 scsi commands sent */ + asr_perf_t ha_performance; + u_int32_t ha_submitted_ccbs_count; + + /* Queueing macros for a circular queue */ +#define TIMEQ_FREE_LIST_EMPTY(head, tail) (-1 == (head) && -1 == (tail)) +#define TIMEQ_FREE_LIST_FULL(head, tail) ((((tail) + 1) % MAX_TIMEQ_SIZE) == (head)) +#define ENQ_TIMEQ_FREE_LIST(item, Q, head, tail) \ + if (!TIMEQ_FREE_LIST_FULL((head), (tail))) { \ + if TIMEQ_FREE_LIST_EMPTY((head),(tail)) { \ + (head) = (tail) = 0; \ + } \ + else (tail) = ((tail) + 1) % MAX_TIMEQ_SIZE; \ + Q[(tail)] = (item); \ + } \ + else { \ + debug_asr_printf("asr: Enqueueing when TimeQ Free List is full... This should not happen!\n"); \ + } +#define DEQ_TIMEQ_FREE_LIST(item, Q, head, tail) \ + if (!TIMEQ_FREE_LIST_EMPTY((head), (tail))) { \ + item = Q[(head)]; \ + if ((head) == (tail)) { (head) = (tail) = -1; } \ + else (head) = ((head) + 1) % MAX_TIMEQ_SIZE; \ + } \ + else { \ + (item) = -1; \ + debug_asr_printf("asr: Dequeueing when TimeQ Free List is empty... This should not happen!\n"); \ + } + + /* Circular queue of time stamps */ + struct timeval ha_timeQ[MAX_TIMEQ_SIZE]; + u_int32_t ha_timeQFreeList[MAX_TIMEQ_SIZE]; + int ha_timeQFreeHead; + int ha_timeQFreeTail; +#endif } Asr_softc_t; STATIC Asr_softc_t * Asr_softc; @@ -384,6 +424,7 @@ */ /* Externally callable routines */ +#if __FreeBSD_version >= 400000 #define PROBE_ARGS IN device_t tag #define PROBE_RET int #define PROBE_SET() u_int32_t id = (pci_get_device(tag)<<16)|pci_get_vendor(tag) @@ -392,6 +433,16 @@ #define ATTACH_RET int #define ATTACH_SET() int unit = device_get_unit(tag) #define ATTACH_RETURN(retval) return(retval) +#else +#define PROBE_ARGS IN pcici_t tag, IN pcidi_t id +#define PROBE_RET const char * +#define PROBE_SET() +#define PROBE_RETURN(retval) return(retval) +#define ATTACH_ARGS IN pcici_t tag, IN int unit +#define ATTACH_RET void +#define ATTACH_SET() +#define ATTACH_RETURN(retval) return +#endif /* I2O HDM interface */ STATIC PROBE_RET asr_probe(PROBE_ARGS); STATIC ATTACH_RET asr_attach(ATTACH_ARGS); @@ -440,6 +491,7 @@ * Here is the auto-probe structure used to nest our tests appropriately * during the startup phase of the operating system. */ +#if __FreeBSD_version >= 400000 STATIC device_method_t asr_methods[] = { DEVMETHOD(device_probe, asr_probe), DEVMETHOD(device_attach, asr_attach), @@ -487,7 +539,38 @@ STATIC devclass_t mode0_devclass; DRIVER_MODULE(mode0, pci, mode0_driver, mode0_devclass, 0, 0); +#else +STATIC u_long asr_pcicount = 0; +STATIC struct pci_device asr_pcidev = { + "asr", + asr_probe, + asr_attach, + &asr_pcicount, + NULL +}; +DATA_SET (asr_pciset, asr_pcidev); +STATIC u_long domino_pcicount = 0; +STATIC struct pci_device domino_pcidev = { + "domino", + domino_probe, + domino_attach, + &domino_pcicount, + NULL +}; +DATA_SET (domino_pciset, domino_pcidev); + +STATIC u_long mode0_pcicount = 0; +STATIC struct pci_device mode0_pcidev = { + "mode0", + mode0_probe, + mode0_attach, + &mode0_pcicount, + NULL +}; +DATA_SET (mode0_pciset, mode0_pcidev); +#endif + /* * devsw for asr hba driver * @@ -504,6 +587,11 @@ .d_maj = CDEV_MAJOR, }; +#ifdef ASR_MEASURE_PERFORMANCE +STATIC u_int32_t asr_time_delta(IN struct timeval start, + IN struct timeval end); +#endif + /* I2O support routines */ #define defAlignLong(STRUCT,NAME) char NAME[sizeof(STRUCT)] #define getAlignLong(STRUCT,NAME) ((STRUCT *)(NAME)) @@ -668,7 +756,7 @@ while (*((U8 * volatile)&(buffer->SyncByte)) == 0) { if (--Delay == 0) { - buffer = NULL; + buffer = (PI2O_EXEC_STATUS_GET_REPLY)NULL; break; } DELAY (1000); @@ -679,7 +767,7 @@ virt->Mask = Old; return (buffer); } - return (NULL); + return ((PI2O_EXEC_STATUS_GET_REPLY)NULL); } /* ASR_getStatus */ /* @@ -754,6 +842,12 @@ if (id == 0x19648086) { PROBE_RETURN ("Adaptec Mode0 PM2865/2400A/3200S/3400S"); } +#if 0 /* this would match any generic i960 -- mjs */ + /* This is an i960RP (typically also on Motherboards) */ + if (id == 0x19608086) { + PROBE_RETURN ("Adaptec Mode0 PM2554/PM1554/PM2654"); + } +#endif PROBE_RETURN (NULL); } /* mode0_probe */ @@ -770,7 +864,7 @@ OUT union asr_ccb * new_ccb; if ((new_ccb = (union asr_ccb *)malloc(sizeof(*new_ccb), - M_DEVBUF, M_WAITOK | M_ZERO)) != NULL) { + M_DEVBUF, M_WAITOK | M_ZERO)) != (union asr_ccb *)NULL) { new_ccb->ccb_h.pinfo.priority = 1; new_ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX; new_ccb->ccb_h.spriv_ptr0 = sc; @@ -857,7 +951,7 @@ union asr_ccb * ccb; OUT int status; - if ((ccb = asr_alloc_ccb (sc)) == NULL) { + if ((ccb = asr_alloc_ccb (sc)) == (union asr_ccb *)NULL) { return (CAM_REQUEUE_REQ); } @@ -922,6 +1016,21 @@ struct ccb_hdr * ccb; int s; +#if 0 /* Currently handled by callers, unnecessary paranoia currently */ + /* Left in for historical perspective. */ + defAlignLong(I2O_EXEC_LCT_NOTIFY_MESSAGE,Message); + PI2O_EXEC_LCT_NOTIFY_MESSAGE Message_Ptr; + + /* Send a blind LCT command to wait for the enableSys to complete */ + Message_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE)ASR_fillMessage(Message, + sizeof(I2O_EXEC_LCT_NOTIFY_MESSAGE) - sizeof(I2O_SG_ELEMENT)); + I2O_MESSAGE_FRAME_setFunction(&(Message_Ptr->StdMessageFrame), + I2O_EXEC_LCT_NOTIFY); + I2O_EXEC_LCT_NOTIFY_MESSAGE_setClassIdentifier(Message_Ptr, + I2O_CLASS_MATCH_ANYCLASS); + (void)ASR_queue_c(sc, (PI2O_MESSAGE_FRAME)Message_Ptr); +#endif + s = splcam(); /* * We do not need to inform the CAM layer that we had a bus @@ -933,7 +1042,7 @@ * xpt_async (AC_BUS_RESET, sc->ha_path[bus], NULL); * } */ - while ((ccb = LIST_FIRST(&(sc->ha_ccb))) != NULL) { + while ((ccb = LIST_FIRST(&(sc->ha_ccb))) != (struct ccb_hdr *)NULL) { ASR_ccbRemove (sc, (union asr_ccb *)ccb); ccb->status &= ~CAM_STATUS_MASK; @@ -986,8 +1095,8 @@ ASR_getBlinkLedCode ( IN Asr_softc_t * sc) { - if ((sc != NULL) - && (sc->ha_blinkLED != NULL) + if ((sc != (Asr_softc_t *)NULL) + && (sc->ha_blinkLED != (u_int8_t *)NULL) && (sc->ha_blinkLED[1] == 0xBC)) { return (sc->ha_blinkLED[0]); } @@ -1023,13 +1132,13 @@ * sc must be valid before it gets here, so that check could be * dropped if speed a critical issue. */ - if ((sc == NULL) + if ((sc == (Asr_softc_t *)NULL) || (bus > MAX_CHANNEL) || (target > sc->ha_MaxId) || (lun > sc->ha_MaxLun)) { debug_asr_printf("(%lx,%d,%d,%d) target out of range\n", (u_long)sc, bus, target, lun); - return (NULL); + return ((tid_t *)NULL); } /* * See if there is an associated bus list. @@ -1038,9 +1147,9 @@ * BUS_CHUNK must be a power of two. This is to reduce * fragmentation effects on the allocations. */ -#define BUS_CHUNK 8 +# define BUS_CHUNK 8 new_size = ((target + BUS_CHUNK - 1) & ~(BUS_CHUNK - 1)); - if ((bus_ptr = sc->ha_targets[bus]) == NULL) { + if ((bus_ptr = sc->ha_targets[bus]) == (target2lun_t *)NULL) { /* * Allocate a new structure? * Since one element in structure, the +1 @@ -1050,9 +1159,9 @@ || ((sc->ha_targets[bus] = bus_ptr = (target2lun_t *)malloc ( sizeof(*bus_ptr) + (sizeof(bus_ptr->LUN) * new_size), M_TEMP, M_WAITOK | M_ZERO)) - == NULL)) { + == (target2lun_t *)NULL)) { debug_asr_printf("failed to allocate bus list\n"); - return (NULL); + return ((tid_t *)NULL); } bus_ptr->size = new_size + 1; } else if (bus_ptr->size <= new_size) { @@ -1066,9 +1175,10 @@ if ((new_entry == FALSE) || ((new_bus_ptr = (target2lun_t *)malloc ( sizeof(*bus_ptr) + (sizeof(bus_ptr->LUN) * new_size), - M_TEMP, M_WAITOK | M_ZERO)) == NULL)) { + M_TEMP, M_WAITOK | M_ZERO)) + == (target2lun_t *)NULL)) { debug_asr_printf("failed to reallocate bus list\n"); - return (NULL); + return ((tid_t *)NULL); } /* * Copy the whole thing, safer, simpler coding @@ -1088,11 +1198,11 @@ * TARGET_CHUNK must be a power of two. This is to reduce * fragmentation effects on the allocations. */ -#define TARGET_CHUNK 8 +# define TARGET_CHUNK 8 if ((new_size = lun) != 0) { new_size = ((lun + TARGET_CHUNK - 1) & ~(TARGET_CHUNK - 1)); } - if ((target_ptr = bus_ptr->LUN[target]) == NULL) { + if ((target_ptr = bus_ptr->LUN[target]) == (lun2tid_t *)NULL) { /* * Allocate a new structure? * Since one element in structure, the +1 @@ -1101,9 +1211,10 @@ if ((new_entry == FALSE) || ((bus_ptr->LUN[target] = target_ptr = (lun2tid_t *)malloc ( sizeof(*target_ptr) + (sizeof(target_ptr->TID) * new_size), - M_TEMP, M_WAITOK | M_ZERO)) == NULL)) { + M_TEMP, M_WAITOK | M_ZERO)) + == (lun2tid_t *)NULL)) { debug_asr_printf("failed to allocate target list\n"); - return (NULL); + return ((tid_t *)NULL); } target_ptr->size = new_size + 1; } else if (target_ptr->size <= new_size) { @@ -1117,9 +1228,10 @@ if ((new_entry == FALSE) || ((new_target_ptr = (lun2tid_t *)malloc ( sizeof(*target_ptr) + (sizeof(target_ptr->TID) * new_size), - M_TEMP, M_WAITOK | M_ZERO)) == NULL)) { + M_TEMP, M_WAITOK | M_ZERO)) + == (lun2tid_t *)NULL)) { debug_asr_printf("failed to reallocate target list\n"); - return (NULL); + return ((tid_t *)NULL); } /* * Copy the whole thing, safer, simpler coding @@ -1158,7 +1270,8 @@ OUT tid_t retval; s = splcam(); - if (((tid_ptr = ASR_getTidAddress(sc, bus, target, lun, FALSE)) == NULL) + if (((tid_ptr = ASR_getTidAddress (sc, bus, target, lun, FALSE)) + == (tid_t *)NULL) /* (tid_t)0 or (tid_t)-1 indicate no TID */ || (*tid_ptr == (tid_t)0)) { splx(s); @@ -1193,7 +1306,7 @@ } s = splcam(); if ((tid_ptr = ASR_getTidAddress (sc, bus, target, lun, TRUE)) - == NULL) { + == (tid_t *)NULL) { splx(s); return ((tid_t)-1); } @@ -1384,8 +1497,21 @@ * good thing. In a production system, however, one may wish * to instead take the card off-line ... */ - /* Wait Forever */ - while (ASR_resetIOP (sc->ha_Virt, sc->ha_Fvirt) == 0); +# if 0 && (defined(HA_OFF_LINE)) + /* + * Take adapter off-line. + */ + printf ("asr%d: Taking adapter off-line\n", + sc->ha_path[0] + ? cam_sim_unit(xpt_path_sim(sc->ha_path[0])) + : 0); + sc->ha_in_reset = HA_OFF_LINE; + splx (s); + return (ENXIO); +# else + /* Wait Forever */ + while (ASR_resetIOP (sc->ha_Virt, sc->ha_Fvirt) == 0); +# endif } retVal = ASR_init (sc); splx (s); @@ -1483,6 +1609,32 @@ I2O_MESSAGE_FRAME_getInitiatorContext64(Message); if ((MessageOffset = ASR_getMessage(sc->ha_Virt)) != EMPTY_QUEUE) { +#ifdef ASR_MEASURE_PERFORMANCE + int startTimeIndex; + + if (ccb) { + ++sc->ha_performance.command_count[ + (int) ccb->csio.cdb_io.cdb_bytes[0]]; + DEQ_TIMEQ_FREE_LIST(startTimeIndex, + sc->ha_timeQFreeList, + sc->ha_timeQFreeHead, + sc->ha_timeQFreeTail); + if (-1 != startTimeIndex) { + microtime(&(sc->ha_timeQ[startTimeIndex])); + } + /* Time stamp the command before we send it out */ + ((PRIVATE_SCSI_SCB_EXECUTE_MESSAGE *) Message)-> + PrivateMessageFrame.TransactionContext + = (I2O_TRANSACTION_CONTEXT) startTimeIndex; + + ++sc->ha_submitted_ccbs_count; + if (sc->ha_performance.max_submit_count + < sc->ha_submitted_ccbs_count) { + sc->ha_performance.max_submit_count + = sc->ha_submitted_ccbs_count; + } + } +#endif bcopy (Message, sc->ha_Fvirt + MessageOffset, I2O_MESSAGE_FRAME_getMessageSize(Message) << 2); if (ccb) { @@ -1585,7 +1737,7 @@ && (Buffer_Ptr->Header.ResultCount)) { return ((void *)(Buffer_Ptr->Info)); } - return (NULL); + return ((void *)NULL); } /* ASR_getParams */ /* @@ -1609,7 +1761,8 @@ MessageSizeInBytes = sizeof(I2O_EXEC_LCT_NOTIFY_MESSAGE) - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT); if ((Message_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE)malloc ( - MessageSizeInBytes, M_TEMP, M_WAITOK)) == NULL) { + MessageSizeInBytes, M_TEMP, M_WAITOK)) + == (PI2O_EXEC_LCT_NOTIFY_MESSAGE)NULL) { return (ENOMEM); } (void)ASR_fillMessage((char *)Message_Ptr, MessageSizeInBytes); @@ -1652,7 +1805,8 @@ free (Message_Ptr, M_TEMP); return (EINVAL); } - if ((sc->ha_LCT = (PI2O_LCT)malloc (len, M_TEMP, M_WAITOK)) == NULL) { + if ((sc->ha_LCT = (PI2O_LCT)malloc (len, M_TEMP, M_WAITOK)) + == (PI2O_LCT)NULL) { free (Message_Ptr, M_TEMP); return (ENOMEM); } @@ -1720,10 +1874,10 @@ PI2O_EXEC_LCT_NOTIFY_MESSAGE NewMessage_Ptr; if ((NewMessage_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE) - malloc(MessageSizeInBytes, M_TEMP, M_WAITOK)) - == NULL) { + malloc (MessageSizeInBytes, M_TEMP, M_WAITOK)) + == (PI2O_EXEC_LCT_NOTIFY_MESSAGE)NULL) { free (sc->ha_LCT, M_TEMP); - sc->ha_LCT = NULL; + sc->ha_LCT = (PI2O_LCT)NULL; free (Message_Ptr, M_TEMP); return (ENOMEM); } @@ -1790,7 +1944,8 @@ ASR_getParams(sc, I2O_LCT_ENTRY_getLocalTID(Entry), I2O_HBA_SCSI_CONTROLLER_INFO_GROUP_NO, - Buffer, sizeof(struct ControllerInfo))) == NULL) { + Buffer, sizeof(struct ControllerInfo))) + == (PI2O_HBA_SCSI_CONTROLLER_INFO_SCALAR)NULL) { continue; } Entry->le_target @@ -1817,7 +1972,8 @@ ASR_getParams(sc, I2O_LCT_ENTRY_getLocalTID(Entry), I2O_DPT_DEVICE_INFO_GROUP_NO, - Buffer, sizeof(struct DeviceInfo))) == NULL) { + Buffer, sizeof(struct DeviceInfo))) + == (PI2O_DPT_DEVICE_INFO_SCALAR)NULL) { continue; } Entry->le_type @@ -1889,7 +2045,7 @@ } } if (TID == (tid_t)0) { - return (NULL); + return ((PI2O_MESSAGE_FRAME)NULL); } I2O_MESSAGE_FRAME_setTargetAddress(Message_Ptr, TID); PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setTID( @@ -2048,7 +2204,7 @@ /* * Populate the outbound table. */ - if (sc->ha_Msgs == NULL) { + if (sc->ha_Msgs == (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { /* Allocate the reply frames */ size = sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME) @@ -2060,14 +2216,15 @@ */ if ((sc->ha_Msgs = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME) contigmalloc (size, M_DEVBUF, M_WAITOK, 0ul, - 0xFFFFFFFFul, (u_long)sizeof(U32), 0ul)) != NULL) { + 0xFFFFFFFFul, (u_long)sizeof(U32), 0ul)) + != (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { (void)bzero ((char *)sc->ha_Msgs, size); sc->ha_Msgs_Phys = KVTOPHYS(sc->ha_Msgs); } } /* Initialize the outbound FIFO */ - if (sc->ha_Msgs != NULL) + if (sc->ha_Msgs != (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) for (size = sc->ha_Msgs_Count, addr = sc->ha_Msgs_Phys; size; --size) { sc->ha_Virt->FromFIFO = addr; @@ -2092,7 +2249,8 @@ int retVal; if ((SystemTable = (PI2O_SET_SYSTAB_HEADER)malloc ( - sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO)) == NULL) { + sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO)) + == (PI2O_SET_SYSTAB_HEADER)NULL) { return (ENOMEM); } for (ha = Asr_softc; ha; ha = ha->ha_next) { @@ -2101,7 +2259,7 @@ if ((Message_Ptr = (PI2O_EXEC_SYS_TAB_SET_MESSAGE)malloc ( sizeof(I2O_EXEC_SYS_TAB_SET_MESSAGE) - sizeof(I2O_SG_ELEMENT) + ((3+SystemTable->NumberEntries) * sizeof(I2O_SGE_SIMPLE_ELEMENT)), - M_TEMP, M_WAITOK)) == NULL) { + M_TEMP, M_WAITOK)) == (PI2O_EXEC_SYS_TAB_SET_MESSAGE)NULL) { free (SystemTable, M_TEMP); return (ENOMEM); } @@ -2249,8 +2407,8 @@ * as the OS normally would flush all outstanding commands before * issuing a shutdown or an adapter reset). */ - if ((sc != NULL) - && (LIST_FIRST(&(sc->ha_ccb)) != NULL) + if ((sc != (Asr_softc_t *)NULL) + && (LIST_FIRST(&(sc->ha_ccb)) != (struct ccb_hdr *)NULL) && ((TID = ASR_getTid (sc, bus, target, lun)) != (tid_t)-1) && (TID != (tid_t)0)) { defAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE,Message); @@ -2337,12 +2495,17 @@ */ STATIC int asr_pci_map_mem ( +#if __FreeBSD_version >= 400000 IN device_t tag, +#else + IN pcici_t tag, +#endif IN Asr_softc_t * sc) { int rid; u_int32_t p, l, s; +#if __FreeBSD_version >= 400000 /* * I2O specification says we must find first *memory* mapped BAR */ @@ -2386,11 +2549,11 @@ p &= ~15; sc->ha_mem_res = bus_alloc_resource(tag, SYS_RES_MEMORY, &rid, p, p + l, l, RF_ACTIVE); - if (sc->ha_mem_res == NULL) { + if (sc->ha_mem_res == (struct resource *)NULL) { return (0); } sc->ha_Base = (void *)rman_get_start(sc->ha_mem_res); - if (sc->ha_Base == NULL) { + if (sc->ha_Base == (void *)NULL) { return (0); } sc->ha_Virt = (i2oRegs_t *) rman_get_virtual(sc->ha_mem_res); @@ -2408,16 +2571,172 @@ p &= ~15; sc->ha_mes_res = bus_alloc_resource(tag, SYS_RES_MEMORY, &rid, p, p + l, l, RF_ACTIVE); - if (sc->ha_mes_res == NULL) { + if (sc->ha_mes_res == (struct resource *)NULL) { return (0); } - if ((void *)rman_get_start(sc->ha_mes_res) == NULL) { + if ((void *)rman_get_start(sc->ha_mes_res) == (void *)NULL) { return (0); } sc->ha_Fvirt = (U8 *) rman_get_virtual(sc->ha_mes_res); } else { sc->ha_Fvirt = (U8 *)(sc->ha_Virt); } +#else + vm_size_t psize, poffs; + + /* + * I2O specification says we must find first *memory* mapped BAR + */ + for (rid = PCI_MAP_REG_START; + rid < (PCI_MAP_REG_START + 4 * sizeof(u_int32_t)); + rid += sizeof(u_int32_t)) { + p = pci_conf_read (tag, rid); + if ((p & 1) == 0) { + break; + } + } + if (rid >= (PCI_MAP_REG_START + 4 * sizeof(u_int32_t))) { + rid = PCI_MAP_REG_START; + } + /* + ** save old mapping, get size and type of memory + ** + ** type is in the lowest four bits. + ** If device requires 2^n bytes, the next + ** n-4 bits are read as 0. + */ + + sc->ha_Base = (void *)((p = pci_conf_read (tag, rid)) + & PCI_MAP_MEMORY_ADDRESS_MASK); + pci_conf_write (tag, rid, 0xfffffffful); + l = pci_conf_read (tag, rid); + pci_conf_write (tag, rid, p); + + /* + ** check the type + */ + + if (!((l & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_32BIT_1M + && ((u_long)sc->ha_Base & ~0xfffff) == 0) + && ((l & PCI_MAP_MEMORY_TYPE_MASK) != PCI_MAP_MEMORY_TYPE_32BIT)) { + debug_asr_printf ( + "asr_pci_map_mem failed: bad memory type=0x%x\n", + (unsigned) l); + return (0); + }; + + /* + ** get the size. + */ + + psize = -(l & PCI_MAP_MEMORY_ADDRESS_MASK); + if (psize > MAX_MAP) { + psize = MAX_MAP; + } + /* + * The 2005S Zero Channel RAID solution is not a perfect PCI + * citizen. It asks for 4MB on BAR0, and 0MB on BAR1, once + * enabled it rewrites the size of BAR0 to 2MB, sets BAR1 to + * BAR0+2MB and sets it's size to 2MB. The IOP registers are + * accessible via BAR0, the messaging registers are accessible + * via BAR1. If the subdevice code is 50 to 59 decimal. + */ + s = pci_read_config(tag, PCIR_DEVVENDOR, sizeof(s)); + if (s != 0xA5111044) { + s = pci_conf_read (tag, PCIR_SUBVEND_0) + if ((((ADPTDOMINATOR_SUB_ID_START ^ s) & 0xF000FFFF) == 0) + && (ADPTDOMINATOR_SUB_ID_START <= s) + && (s <= ADPTDOMINATOR_SUB_ID_END)) { + psize = MAX_MAP; + } + } + + if ((sc->ha_Base == (void *)NULL) + || (sc->ha_Base == (void *)PCI_MAP_MEMORY_ADDRESS_MASK)) { + debug_asr_printf ("asr_pci_map_mem: not configured by bios.\n"); + return (0); + }; + + /* + ** Truncate sc->ha_Base to page boundary. + ** (Or does pmap_mapdev the job?) + */ + + poffs = (u_long)sc->ha_Base - trunc_page ((u_long)sc->ha_Base); + sc->ha_Virt = (i2oRegs_t *)pmap_mapdev ((u_long)sc->ha_Base - poffs, + psize + poffs); + + if (sc->ha_Virt == (i2oRegs_t *)NULL) { + return (0); + } + + sc->ha_Virt = (i2oRegs_t *)((u_long)sc->ha_Virt + poffs); + if (s == 0xA5111044) { + if ((rid += sizeof(u_int32_t)) + >= (PCI_MAP_REG_START + 4 * sizeof(u_int32_t))) { + return (0); + } + + /* + ** save old mapping, get size and type of memory + ** + ** type is in the lowest four bits. + ** If device requires 2^n bytes, the next + ** n-4 bits are read as 0. + */ + + if ((((p = pci_conf_read (tag, rid)) + & PCI_MAP_MEMORY_ADDRESS_MASK) == 0L) + || ((p & PCI_MAP_MEMORY_ADDRESS_MASK) + == PCI_MAP_MEMORY_ADDRESS_MASK)) { + debug_asr_printf ("asr_pci_map_mem: not configured by bios.\n"); + } + pci_conf_write (tag, rid, 0xfffffffful); + l = pci_conf_read (tag, rid); + pci_conf_write (tag, rid, p); + p &= PCI_MAP_MEMORY_TYPE_MASK; + + /* + ** check the type + */ + + if (!((l & PCI_MAP_MEMORY_TYPE_MASK) + == PCI_MAP_MEMORY_TYPE_32BIT_1M + && (p & ~0xfffff) == 0) + && ((l & PCI_MAP_MEMORY_TYPE_MASK) + != PCI_MAP_MEMORY_TYPE_32BIT)) { + debug_asr_printf ( + "asr_pci_map_mem failed: bad memory type=0x%x\n", + (unsigned) l); + return (0); + }; + + /* + ** get the size. + */ + + psize = -(l & PCI_MAP_MEMORY_ADDRESS_MASK); + if (psize > MAX_MAP) { + psize = MAX_MAP; + } + + /* + ** Truncate p to page boundary. + ** (Or does pmap_mapdev the job?) + */ + + poffs = p - trunc_page (p); + sc->ha_Fvirt = (U8 *)pmap_mapdev (p - poffs, psize + poffs); + + if (sc->ha_Fvirt == (U8 *)NULL) { + return (0); + } + + sc->ha_Fvirt = (U8 *)((u_long)sc->ha_Fvirt + poffs); + } else { + sc->ha_Fvirt = (U8 *)(sc->ha_Virt); + } +#endif return (1); } /* asr_pci_map_mem */ @@ -2427,14 +2746,19 @@ */ STATIC int asr_pci_map_int ( +#if __FreeBSD_version >= 400000 IN device_t tag, +#else + IN pcici_t tag, +#endif IN Asr_softc_t * sc) { +#if __FreeBSD_version >= 400000 int rid = 0; sc->ha_irq_res = bus_alloc_resource_any(tag, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); - if (sc->ha_irq_res == NULL) { + if (sc->ha_irq_res == (struct resource *)NULL) { return (0); } if (bus_setup_intr(tag, sc->ha_irq_res, INTR_TYPE_CAM | INTR_ENTROPY, @@ -2442,6 +2766,13 @@ return (0); } sc->ha_irq = pci_read_config(tag, PCIR_INTLINE, sizeof(char)); +#else + if (!pci_map_int(tag, (pci_inthand_t *)asr_intr, + (void *)sc, &cam_imask)) { + return (0); + } + sc->ha_irq = pci_conf_read(tag, PCIR_INTLINE); +#endif return (1); } /* asr_pci_map_int */ @@ -2455,10 +2786,12 @@ struct scsi_inquiry_data * iq; ATTACH_SET(); - if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) { + if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO)) == + (Asr_softc_t *)NULL) + { ATTACH_RETURN(ENOMEM); } - if (Asr_softc == NULL) { + if (Asr_softc == (Asr_softc_t *)NULL) { /* * Fixup the OS revision as saved in the dptsig for the * engine (dptioctl.h) to pick up. @@ -2470,6 +2803,18 @@ * Initialize the software structure */ LIST_INIT(&(sc->ha_ccb)); +# ifdef ASR_MEASURE_PERFORMANCE + { + u_int32_t i; + + /* initialize free list for timeQ */ + sc->ha_timeQFreeHead = 0; + sc->ha_timeQFreeTail = MAX_TIMEQ_SIZE - 1; + for (i = 0; i < MAX_TIMEQ_SIZE; i++) { + sc->ha_timeQFreeList[i] = i; + } + } +# endif /* Link us into the HA list */ { Asr_softc_t **ha; @@ -2489,6 +2834,7 @@ ATTACH_RETURN(ENXIO); } /* Enable if not formerly enabled */ +#if __FreeBSD_version >= 400000 pci_write_config (tag, PCIR_COMMAND, pci_read_config (tag, PCIR_COMMAND, sizeof(char)) | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN, sizeof(char)); @@ -2503,10 +2849,28 @@ sc->ha_pciDeviceNum = (dinfo->cfg.slot << 3) | dinfo->cfg.func; } +#else + pci_conf_write (tag, PCIR_COMMAND, + pci_conf_read (tag, PCIR_COMMAND) + | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); + /* Knowledge is power, responsibility is direct */ + switch (pci_mechanism) { + + case 1: + sc->ha_pciBusNum = tag.cfg1 >> 16; + sc->ha_pciDeviceNum = tag.cfg1 >> 8; + + case 2: + sc->ha_pciBusNum = tag.cfg2.forward; + sc->ha_pciDeviceNum = ((tag.cfg2.enable >> 1) & 7) + | (tag.cfg2.port >> 5); + } +#endif /* Check if the device is there? */ if ((ASR_resetIOP(sc->ha_Virt, sc->ha_Fvirt) == 0) || ((status = (PI2O_EXEC_STATUS_GET_REPLY)malloc ( - sizeof(I2O_EXEC_STATUS_GET_REPLY), M_TEMP, M_WAITOK)) == NULL) + sizeof(I2O_EXEC_STATUS_GET_REPLY), M_TEMP, M_WAITOK)) + == (PI2O_EXEC_STATUS_GET_REPLY)NULL) || (ASR_getStatus(sc->ha_Virt, sc->ha_Fvirt, status) == NULL)) { printf ("asr%d: could not initialize hardware\n", unit); ATTACH_RETURN(ENODEV); /* Get next, maybe better luck */ @@ -2519,7 +2883,7 @@ sc->ha_SystemTable.InboundMessageFrameSize = status->InboundMFrameSize; sc->ha_SystemTable.MessengerInfo.InboundMessagePortAddressLow - = (U32)(sc->ha_Base) + (U32)offsetof(i2oRegs_t, ToFIFO); + = (U32)(sc->ha_Base) + (U32)(&(((i2oRegs_t *)NULL)->ToFIFO)); if (!asr_pci_map_int(tag, (void *)sc)) { printf ("asr%d: could not map interrupt\n", unit); @@ -2567,12 +2931,13 @@ }; defAlignLong (struct BufferInfo, Buffer); PI2O_DPT_EXEC_IOP_BUFFERS_SCALAR Info; -#define FW_DEBUG_BLED_OFFSET 8 +# define FW_DEBUG_BLED_OFFSET 8 if ((Info = (PI2O_DPT_EXEC_IOP_BUFFERS_SCALAR) ASR_getParams(sc, 0, I2O_DPT_EXEC_IOP_BUFFERS_GROUP_NO, - Buffer, sizeof(struct BufferInfo))) != NULL) { + Buffer, sizeof(struct BufferInfo))) + != (PI2O_DPT_EXEC_IOP_BUFFERS_SCALAR)NULL) { sc->ha_blinkLED = sc->ha_Fvirt + I2O_DPT_EXEC_IOP_BUFFERS_SCALAR_getSerialOutputOffset(Info) + FW_DEBUG_BLED_OFFSET; @@ -2624,7 +2989,7 @@ if ((iq = (struct scsi_inquiry_data *)malloc ( sizeof(struct scsi_inquiry_data), M_TEMP, M_WAITOK | M_ZERO)) - != NULL) { + != (struct scsi_inquiry_data *)NULL) { defAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE,Message); PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE Message_Ptr; int posted = 0; @@ -2711,7 +3076,7 @@ int bus; union asr_ccb * ccb; - if ((ccb = asr_alloc_ccb (sc)) == NULL) { + if ((ccb = asr_alloc_ccb (sc)) == (union asr_ccb *)NULL) { printf ("asr%d: CAM could not be notified of asynchronous callback parameters\n", unit); ATTACH_RETURN(ENOMEM); } @@ -2833,7 +3198,7 @@ debug_asr_cmd_dump_ccb(ccb); if ((Message_Ptr = ASR_init_message ((union asr_ccb *)ccb, - (PI2O_MESSAGE_FRAME)Message)) != NULL) { + (PI2O_MESSAGE_FRAME)Message)) != (PI2O_MESSAGE_FRAME)NULL) { debug_asr_cmd2_printf ("TID=%x:\n", PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_getTID( (PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)Message_Ptr)); @@ -2841,6 +3206,9 @@ debug_asr_cmd1_printf (" q"); if (ASR_queue (sc, Message_Ptr) == EMPTY_QUEUE) { +#ifdef ASR_MEASURE_PERFORMANCE + ++sc->ha_performance.command_too_busy; +#endif ccb->ccb_h.status &= ~CAM_STATUS_MASK; ccb->ccb_h.status |= CAM_REQUEUE_REQ; debug_asr_cmd_printf (" E\n"); @@ -2867,9 +3235,9 @@ xpt_done(ccb); break; -#if (defined(REPORT_LUNS)) +# if (defined(REPORT_LUNS)) case REPORT_LUNS: -#endif +# endif case XPT_ABORT: /* Abort the specified CCB */ /* XXX Implement */ ccb->ccb_h.status = CAM_REQ_INVALID; @@ -2981,6 +3349,61 @@ } } /* asr_action */ +#ifdef ASR_MEASURE_PERFORMANCE +#define WRITE_OP 1 +#define READ_OP 2 +#define min_submitR sc->ha_performance.read_by_size_min_time[index] +#define max_submitR sc->ha_performance.read_by_size_max_time[index] +#define min_submitW sc->ha_performance.write_by_size_min_time[index] +#define max_submitW sc->ha_performance.write_by_size_max_time[index] + +STATIC INLINE void +asr_IObySize( + IN Asr_softc_t * sc, + IN u_int32_t submitted_time, + IN int op, + IN int index) +{ + struct timeval submitted_timeval; + + submitted_timeval.tv_sec = 0; + submitted_timeval.tv_usec = submitted_time; + + if ( op == READ_OP ) { + ++sc->ha_performance.read_by_size_count[index]; + + if ( submitted_time != 0xffffffff ) { + timevaladd( + &(sc->ha_performance.read_by_size_total_time[index]), + &submitted_timeval); + if ( (min_submitR == 0) + || (submitted_time < min_submitR) ) { + min_submitR = submitted_time; + } + + if ( submitted_time > max_submitR ) { + max_submitR = submitted_time; + } + } + } else { + ++sc->ha_performance.write_by_size_count[index]; + if ( submitted_time != 0xffffffff ) { + timevaladd( + &(sc->ha_performance.write_by_size_total_time[index]), + &submitted_timeval); + if ( (submitted_time < min_submitW) + || (min_submitW == 0) ) { + min_submitW = submitted_time; + } + + if ( submitted_time > max_submitW ) { + max_submitW = submitted_time; + } + } + } +} /* asr_IObySize */ +#endif + /* * Handle processing of current CCB as pointed to by the Status. */ @@ -2990,6 +3413,13 @@ { OUT int processed; +#ifdef ASR_MEASURE_PERFORMANCE + struct timeval junk; + + microtime(&junk); + sc->ha_performance.intr_started = junk; +#endif + for (processed = 0; sc->ha_Virt->Status & Mask_InterruptsDisabled; processed = 1) { @@ -3049,11 +3479,11 @@ */ Message_Ptr = (PI2O_UTIL_NOP_MESSAGE)ASR_fillMessage( Message, sizeof(I2O_UTIL_NOP_MESSAGE)); -#if (I2O_UTIL_NOP != 0) +# if (I2O_UTIL_NOP != 0) I2O_MESSAGE_FRAME_setFunction ( &(Message_Ptr->StdMessageFrame), I2O_UTIL_NOP); -#endif +# endif /* * Copy the packet out to the Original Message */ @@ -3071,7 +3501,7 @@ * and a generic handler for immunity against odd error * returns from the adapter. */ - if (ccb == NULL) { + if (ccb == (union asr_ccb *)NULL) { /* * Return Reply so that it can be used for the * next command @@ -3142,6 +3572,154 @@ Reply); } +#ifdef ASR_MEASURE_PERFORMANCE + { + struct timeval endTime; + u_int32_t submitted_time; + u_int32_t size; + int op_type; + int startTimeIndex; + + --sc->ha_submitted_ccbs_count; + startTimeIndex + = (int)Reply->StdReplyFrame.TransactionContext; + if (-1 != startTimeIndex) { + /* Compute the time spent in device/adapter */ + microtime(&endTime); + submitted_time = asr_time_delta(sc->ha_timeQ[ + startTimeIndex], endTime); + /* put the startTimeIndex back on free list */ + ENQ_TIMEQ_FREE_LIST(startTimeIndex, + sc->ha_timeQFreeList, + sc->ha_timeQFreeHead, + sc->ha_timeQFreeTail); + } else { + submitted_time = 0xffffffff; + } + +#define maxctime sc->ha_performance.max_command_time[ccb->csio.cdb_io.cdb_bytes[0]] +#define minctime sc->ha_performance.min_command_time[ccb->csio.cdb_io.cdb_bytes[0]] + if (submitted_time != 0xffffffff) { + if ( maxctime < submitted_time ) { + maxctime = submitted_time; + } + if ( (minctime == 0) + || (minctime > submitted_time) ) { + minctime = submitted_time; + } + + if ( sc->ha_performance.max_submit_time + < submitted_time ) { + sc->ha_performance.max_submit_time + = submitted_time; + } + if ( sc->ha_performance.min_submit_time == 0 + || sc->ha_performance.min_submit_time + > submitted_time) { + sc->ha_performance.min_submit_time + = submitted_time; + } + + switch ( ccb->csio.cdb_io.cdb_bytes[0] ) { + + case 0xa8: /* 12-byte READ */ + /* FALLTHRU */ + case 0x08: /* 6-byte READ */ + /* FALLTHRU */ + case 0x28: /* 10-byte READ */ + op_type = READ_OP; + break; + + case 0x0a: /* 6-byte WRITE */ + /* FALLTHRU */ + case 0xaa: /* 12-byte WRITE */ + /* FALLTHRU */ + case 0x2a: /* 10-byte WRITE */ + op_type = WRITE_OP; + break; + + default: + op_type = 0; + break; + } + + if ( op_type != 0 ) { + struct scsi_rw_big * cmd; + + cmd = (struct scsi_rw_big *) + &(ccb->csio.cdb_io); + + size = (((u_int32_t) cmd->length2 << 8) + | ((u_int32_t) cmd->length1)) << 9; + + switch ( size ) { + + case 512: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_512); + break; + + case 1024: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_1K); + break; + + case 2048: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_2K); + break; + + case 4096: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_4K); + break; + + case 8192: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_8K); + break; + + case 16384: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_16K); + break; + + case 32768: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_32K); + break; + + case 65536: + asr_IObySize(sc, + submitted_time, op_type, + SIZE_64K); + break; + + default: + if ( size > (1 << 16) ) { + asr_IObySize(sc, + submitted_time, + op_type, + SIZE_BIGGER); + } else { + asr_IObySize(sc, + submitted_time, + op_type, + SIZE_OTHER); + } + break; + } + } + } + } +#endif /* Sense data in reply packet */ if (ccb->ccb_h.status & CAM_AUTOSNS_VALID) { u_int16_t size = I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME_getAutoSenseTransferCount(Reply); @@ -3174,6 +3752,25 @@ wakeup (ccb); } } +#ifdef ASR_MEASURE_PERFORMANCE + { + u_int32_t result; + + microtime(&junk); + result = asr_time_delta(sc->ha_performance.intr_started, junk); + + if (result != 0xffffffff) { + if ( sc->ha_performance.max_intr_time < result ) { + sc->ha_performance.max_intr_time = result; + } + + if ( (sc->ha_performance.min_intr_time == 0) + || (sc->ha_performance.min_intr_time > result) ) { + sc->ha_performance.min_intr_time = result; + } + } + } +#endif return (processed); } /* asr_intr */ @@ -3213,7 +3810,7 @@ STATIC u_int8_t ASR_ctlr_held; #if (!defined(UNREFERENCED_PARAMETER)) -#define UNREFERENCED_PARAMETER(x) (void)(x) +# define UNREFERENCED_PARAMETER(x) (void)(x) #endif STATIC int @@ -3228,7 +3825,7 @@ UNREFERENCED_PARAMETER(flags); UNREFERENCED_PARAMETER(ifmt); - if (ASR_get_sc (dev) == NULL) { + if (ASR_get_sc (dev) == (Asr_softc_t *)NULL) { return (ENODEV); } s = splcam (); @@ -3301,7 +3898,8 @@ } /* Copy in the message into a local allocation */ if ((Message_Ptr = (PI2O_MESSAGE_FRAME)malloc ( - sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) == NULL) { + sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) + == (PI2O_MESSAGE_FRAME)NULL) { debug_usr_cmd_printf ( "Failed to acquire I2O_MESSAGE_FRAME memory\n"); return (ENOMEM); @@ -3336,7 +3934,8 @@ case I2O_EXEC_STATUS_GET: { I2O_EXEC_STATUS_GET_REPLY status; - if (ASR_getStatus(sc->ha_Virt, sc->ha_Fvirt, &status) == NULL) { + if (ASR_getStatus (sc->ha_Virt, sc->ha_Fvirt, &status) + == (PI2O_EXEC_STATUS_GET_REPLY)NULL) { debug_usr_cmd_printf ("getStatus failed\n"); return (ENXIO); } @@ -3366,7 +3965,7 @@ } if ((Message_Ptr = (PI2O_MESSAGE_FRAME)malloc (MessageSizeInBytes, - M_TEMP, M_WAITOK)) == NULL) { + M_TEMP, M_WAITOK)) == (PI2O_MESSAGE_FRAME)NULL) { debug_usr_cmd_printf ("Failed to acquire frame[%d] memory\n", MessageSizeInBytes); return (ENOMEM); @@ -3382,7 +3981,8 @@ /* Check the size of the reply frame, and start constructing */ if ((Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)malloc ( - sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) == NULL) { + sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) + == (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { free (Message_Ptr, M_TEMP); debug_usr_cmd_printf ( "Failed to acquire I2O_MESSAGE_FRAME memory\n"); @@ -3410,8 +4010,9 @@ if ((Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)malloc ( ((ReplySizeInBytes > sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)) - ? ReplySizeInBytes : sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)), - M_TEMP, M_WAITOK)) == NULL) { + ? ReplySizeInBytes + : sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)), + M_TEMP, M_WAITOK)) == (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { free (Message_Ptr, M_TEMP); debug_usr_cmd_printf ("Failed to acquire frame[%d] memory\n", ReplySizeInBytes); @@ -3480,7 +4081,8 @@ if ((elm = (struct ioctlSgList_S *)malloc ( sizeof(*elm) - sizeof(elm->KernelSpace) + len, - M_TEMP, M_WAITOK)) == NULL) { + M_TEMP, M_WAITOK)) + == (struct ioctlSgList_S *)NULL) { debug_usr_cmd_printf ( "Failed to allocate SG[%d]\n", len); error = ENOMEM; @@ -3568,7 +4170,8 @@ if ((NewMessage_Ptr = (PI2O_MESSAGE_FRAME) malloc (MessageSizeInBytes, - M_TEMP, M_WAITOK)) == NULL) { + M_TEMP, M_WAITOK)) + == (PI2O_MESSAGE_FRAME)NULL) { debug_usr_cmd_printf ( "Failed to acquire frame[%d] memory\n", MessageSizeInBytes); @@ -3596,7 +4199,8 @@ ++sg; } if (error) { - while ((elm = SLIST_FIRST(&sgList)) != NULL) { + while ((elm = SLIST_FIRST(&sgList)) + != (struct ioctlSgList_S *)NULL) { SLIST_REMOVE_HEAD(&sgList, link); free (elm, M_TEMP); } @@ -3610,9 +4214,10 @@ debug_usr_cmd_dump_message(Message_Ptr); /* Send the command */ - if ((ccb = asr_alloc_ccb (sc)) == NULL) { + if ((ccb = asr_alloc_ccb (sc)) == (union asr_ccb *)NULL) { /* Free up in-kernel buffers */ - while ((elm = SLIST_FIRST(&sgList)) != NULL) { + while ((elm = SLIST_FIRST(&sgList)) + != (struct ioctlSgList_S *)NULL) { SLIST_REMOVE_HEAD(&sgList, link); free (elm, M_TEMP); } @@ -3648,7 +4253,8 @@ } splx(s); /* Free up in-kernel buffers */ - while ((elm = SLIST_FIRST(&sgList)) != NULL) { + while ((elm = SLIST_FIRST(&sgList)) + != (struct ioctlSgList_S *)NULL) { SLIST_REMOVE_HEAD(&sgList, link); free (elm, M_TEMP); } @@ -3691,7 +4297,7 @@ } /* Free up in-kernel buffers */ - while ((elm = SLIST_FIRST(&sgList)) != NULL) { + while ((elm = SLIST_FIRST(&sgList)) != (struct ioctlSgList_S *)NULL) { /* Copy out as necessary */ if ((error == 0) /* DIR bit considered `valid', error due to ignorance works */ @@ -3744,13 +4350,13 @@ UNREFERENCED_PARAMETER(flag); UNREFERENCED_PARAMETER(td); - if (sc != NULL) + if (sc != (Asr_softc_t *)NULL) switch(cmd) { case DPT_SIGNATURE: -#if (dsDescription_size != 50) +# if (dsDescription_size != 50) case DPT_SIGNATURE + ((50 - dsDescription_size) << 16): -#endif +# endif if (cmd & 0xFFFF0000) { (void)bcopy ((caddr_t)(&ASR_sig), data, sizeof(dpt_sig_S)); @@ -3807,7 +4413,7 @@ sysInfo_S Info; char * cp; /* Kernel Specific ptok `hack' */ -#define ptok(a) ((char *)(uintptr_t)(a) + KERNBASE) +# define ptok(a) ((char *)(uintptr_t)(a) + KERNBASE) bzero (&Info, sizeof(Info)); @@ -3906,6 +4512,61 @@ Info.extendedMemSize = j; Info.flags |= SI_MemorySizeValid; +# if (defined(THIS_IS_BROKEN)) + /* If There Is 1 or 2 Drives Found, Set Up Drive Parameters */ + if (Info.numDrives > 0) { + /* + * Get The Pointer From Int 41 For The First + * Drive Parameters + */ + j = ((unsigned)(*((unsigned short *)ptok(0x104+2))) << 4) + + (unsigned)(*((unsigned short *)ptok(0x104+0))); + /* + * It appears that SmartROM's Int41/Int46 pointers + * use memory that gets stepped on by the kernel + * loading. We no longer have access to this + * geometry information but try anyways (!?) + */ + Info.drives[0].cylinders = *((unsigned char *)ptok(j)); + ++j; + Info.drives[0].cylinders += ((int)*((unsigned char *) + ptok(j))) << 8; + ++j; + Info.drives[0].heads = *((unsigned char *)ptok(j)); + j += 12; + Info.drives[0].sectors = *((unsigned char *)ptok(j)); + Info.flags |= SI_DriveParamsValid; + if ((Info.drives[0].cylinders == 0) + || (Info.drives[0].heads == 0) + || (Info.drives[0].sectors == 0)) { + Info.flags &= ~SI_DriveParamsValid; + } + if (Info.numDrives > 1) { + /* + * Get The Pointer From Int 46 For The + * Second Drive Parameters + */ + j = ((unsigned)(*((unsigned short *)ptok(0x118+2))) << 4) + + (unsigned)(*((unsigned short *)ptok(0x118+0))); + Info.drives[1].cylinders = *((unsigned char *) + ptok(j)); + ++j; + Info.drives[1].cylinders += ((int) + *((unsigned char *)ptok(j))) << 8; + ++j; + Info.drives[1].heads = *((unsigned char *) + ptok(j)); + j += 12; + Info.drives[1].sectors = *((unsigned char *) + ptok(j)); + if ((Info.drives[1].cylinders == 0) + || (Info.drives[1].heads == 0) + || (Info.drives[1].sectors == 0)) { + Info.flags &= ~SI_DriveParamsValid; + } + } + } +# endif /* Copy Out The Info Structure To The User */ if (cmd & 0xFFFF0000) { bcopy (&Info, data, sizeof(Info)); @@ -3927,6 +4588,14 @@ } break; + /* Get performance metrics */ +#ifdef ASR_MEASURE_PERFORMANCE + case DPT_PERF_INFO: + bcopy((caddr_t) &(sc->ha_performance), data, + sizeof(sc->ha_performance)); + return (0); +#endif + /* Send an I2O command */ case I2OUSRCMD: return (ASR_queue_i (sc, *((PI2O_MESSAGE_FRAME *)data))); @@ -3941,3 +4610,37 @@ } return (EINVAL); } /* asr_ioctl */ + +#ifdef ASR_MEASURE_PERFORMANCE +/* + * This function subtracts one timeval structure from another, + * Returning the result in usec. + * It assumes that less than 4 billion usecs passed form start to end. + * If times are sensless, 0xffffffff is returned. + */ + +STATIC u_int32_t +asr_time_delta( + IN struct timeval start, + IN struct timeval end) +{ + OUT u_int32_t result; + + if (start.tv_sec > end.tv_sec) { + result = 0xffffffff; + } + else { + if (start.tv_sec == end.tv_sec) { + if (start.tv_usec > end.tv_usec) { + result = 0xffffffff; + } else { + return (end.tv_usec - start.tv_usec); + } + } else { + return (end.tv_sec - start.tv_sec) * 1000000 + + end.tv_usec + (1000000 - start.tv_usec); + } + } + return(result); +} /* asr_time_delta */ +#endif --- //depot/vendor/freebsd/src/sys/dev/ata/ata-chipset.c 2004/04/24 08:55:39 +++ //depot/user/jhb/acpipci/dev/ata/ata-chipset.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.70 2004/04/24 15:54:20 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.68 2004/04/13 09:44:20 sos Exp $"); #include "opt_ata.h" #include @@ -2350,15 +2350,15 @@ break; case SIS66: case SIS100OLD: - pci_write_config(dev, 0x52, pci_read_config(dev, 0x52, 1) & ~0x04, 1); + pci_write_config(dev, 0x52, pci_read_config(dev, 0x52, 1) | 0x04, 1); break; case SIS100NEW: case SIS133OLD: - pci_write_config(dev, 0x49, pci_read_config(dev, 0x49, 1) & ~0x01, 1); + pci_write_config(dev, 0x49, pci_read_config(dev, 0x49, 1) | 0x01, 1); break; case SIS133NEW: - pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 2) | 0x0008, 2); - pci_write_config(dev, 0x52, pci_read_config(dev, 0x52, 2) | 0x0008, 2); + pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 2) & 0xfff7, 2); + pci_write_config(dev, 0x52, pci_read_config(dev, 0x52, 2) & 0xfff7, 2); break; case SISSATA: pci_write_config(dev, 0x04, pci_read_config(dev, 0x04, 2) & ~0x0400, 2); @@ -2662,7 +2662,7 @@ struct ata_pci_controller *ctlr = device_get_softc(dev); int rid = ATA_IRQ_RID; - if (!ata_legacy(dev)) { + if (!ATA_MASTERDEV(dev)) { if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE))) { device_printf(dev, "unable to map interrupt\n"); --- //depot/vendor/freebsd/src/sys/dev/ata/ata-lowlevel.c 2004/04/27 08:56:02 +++ //depot/user/jhb/acpipci/dev/ata/ata-lowlevel.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.34 2004/04/27 15:52:08 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.33 2004/04/19 18:29:43 sos Exp $"); #include "opt_ata.h" #include @@ -635,17 +635,17 @@ } } if (mask == 0x01) /* wait for master only */ - if (!(stat0 & ATA_S_BUSY) || (stat0 == 0xff && timeout > 5)) + if (!(stat0 & ATA_S_BUSY) || (stat0 == 0xff && timeout > 20)) break; if (mask == 0x02) /* wait for slave only */ - if (!(stat1 & ATA_S_BUSY) || (stat1 == 0xff && timeout > 5)) + if (!(stat1 & ATA_S_BUSY) || (stat1 == 0xff && timeout > 20)) break; if (mask == 0x03) { /* wait for both master & slave */ if (!(stat0 & ATA_S_BUSY) && !(stat1 & ATA_S_BUSY)) break; - if (stat0 == 0xff && timeout > 5) + if (stat0 == 0xff && timeout > 20) mask &= ~0x01; - if (stat1 == 0xff && timeout > 5) + if (stat1 == 0xff && timeout > 20) mask &= ~0x02; } DELAY(100000); --- //depot/vendor/freebsd/src/sys/dev/ata/ata-pci.c 2004/04/27 05:55:39 +++ //depot/user/jhb/acpipci/dev/ata/ata-pci.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.82 2004/04/27 12:54:59 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.78 2004/04/13 09:44:20 sos Exp $"); #include "opt_ata.h" #include @@ -62,15 +62,6 @@ static void ata_pci_dmainit(struct ata_channel *); static void ata_pci_locknoop(struct ata_channel *, int); -int -ata_legacy(device_t dev) -{ - return ((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV) && - ((pci_read_config(dev, PCIR_PROGIF, 1) & - (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) != - (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))); -} - static int ata_pci_probe(device_t dev) { @@ -167,7 +158,7 @@ int unit; /* do chipset specific setups only needed once */ - if (ata_legacy(dev) || pci_read_config(dev, 0x18, 4) & IOMASK) + if (ATA_MASTERDEV(dev) || pci_read_config(dev, 0x18, 4) & IOMASK) ctlr->channels = 2; else ctlr->channels = 1; @@ -194,7 +185,7 @@ /* attach all channels on this controller */ for (unit = 0; unit < ctlr->channels; unit++) - device_add_child(dev, "ata", (pci_get_progif(dev) & 0x85) == 0x80 ? + device_add_child(dev, "ata", ATA_MASTERDEV(dev) ? unit : devclass_find_free_unit(ata_devclass, 2)); return bus_generic_attach(dev); @@ -236,7 +227,7 @@ retval += bus_print_child_header(dev, child); retval += printf(": at 0x%lx", rman_get_start(ch->r_io[ATA_IDX_ADDR].res)); - if (ata_legacy(dev)) + if (ATA_MASTERDEV(dev)) retval += printf(" irq %d", 14 + ch->unit); retval += bus_print_child_footer(dev, child); @@ -256,7 +247,7 @@ if (type == SYS_RES_IOPORT) { switch (*rid) { case ATA_IOADDR_RID: - if (ata_legacy(dev)) { + if (ATA_MASTERDEV(dev)) { start = (unit ? ATA_SECONDARY : ATA_PRIMARY); count = ATA_IOSIZE; end = start + count - 1; @@ -268,9 +259,9 @@ break; case ATA_ALTADDR_RID: - if (ata_legacy(dev)) { - start = (unit ? ATA_SECONDARY : ATA_PRIMARY) + ATA_ALTOFFSET; - count = ATA_ALTIOSIZE; + if (ATA_MASTERDEV(dev)) { + start = (unit ? ATA_SECONDARY : ATA_PRIMARY) + ATA_ALTOFFSET-2; + count = 4; end = start + count - 1; } myrid = 0x14 + 8 * unit; @@ -283,7 +274,7 @@ } if (type == SYS_RES_IRQ && *rid == ATA_IRQ_RID) { - if (ata_legacy(dev)) { + if (ATA_MASTERDEV(dev)) { #ifdef __alpha__ return alpha_platform_alloc_ide_intr(unit); #else @@ -325,7 +316,7 @@ if (rid != ATA_IRQ_RID) return ENOENT; - if (ata_legacy(dev)) { + if (ATA_MASTERDEV(dev)) { #ifdef __alpha__ return alpha_platform_release_ide_intr(unit, r); #else @@ -344,7 +335,7 @@ int flags, driver_intr_t *function, void *argument, void **cookiep) { - if (ata_legacy(dev)) { + if (ATA_MASTERDEV(dev)) { #ifdef __alpha__ return alpha_platform_setup_ide_intr(child, irq, function, argument, cookiep); @@ -368,7 +359,7 @@ ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { - if (ata_legacy(dev)) { + if (ATA_MASTERDEV(dev)) { #ifdef __alpha__ return alpha_platform_teardown_ide_intr(child, irq, cookie); #else @@ -411,7 +402,7 @@ ch->r_io[i].offset = i; } ch->r_io[ATA_ALTSTAT].res = altio; - ch->r_io[ATA_ALTSTAT].offset = ata_legacy(device_get_parent(dev)) ? 0 : 2; + ch->r_io[ATA_ALTSTAT].offset = 2; ch->r_io[ATA_IDX_ADDR].res = io; if (ctlr->r_res1) { --- //depot/vendor/freebsd/src/sys/dev/ata/ata-pci.h 2004/04/21 13:05:49 +++ //depot/user/jhb/acpipci/dev/ata/ata-pci.h 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ * (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/dev/ata/ata-pci.h,v 1.30 2004/04/21 20:03:26 sos Exp $ + * $FreeBSD: src/sys/dev/ata/ata-pci.h,v 1.29 2004/04/13 09:44:20 sos Exp $ */ /* structure holding chipset config info */ @@ -63,6 +63,9 @@ void *driver; }; +#define ATA_MASTERDEV(dev) ((pci_get_progif(dev) & 0x80) && \ + (pci_get_progif(dev) & 0x05) != 0x05) + /* defines for known chipset PCI id's */ #define ATA_ACARD_ID 0x1191 #define ATA_ATP850 0x00021191 @@ -292,8 +295,6 @@ #define VIABUG 0x10 /* global prototypes */ -int ata_legacy(device_t); - void ata_dmainit(struct ata_channel *); int ata_dmastart(struct ata_channel *, caddr_t, int32_t, int); int ata_dmastop(struct ata_channel *); --- //depot/vendor/freebsd/src/sys/dev/ciss/ciss.c 2004/04/26 12:30:42 +++ //depot/user/jhb/acpipci/dev/ciss/ciss.c 2004/04/19 12:55:20 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ciss/ciss.c,v 1.45 2004/04/26 19:28:08 ps Exp $ + * $FreeBSD: src/sys/dev/ciss/ciss.c,v 1.44 2004/04/19 17:16:06 ps Exp $ */ /* @@ -1411,9 +1411,7 @@ struct ciss_request *cr; struct ciss_command *cc; struct ciss_bmic_cdb *cbc; - int error, ldrive; - - ldrive = CISS_LUN_TO_TARGET(ld->cl_address.logical.lun); + int error; debug(0, "bringing logical drive %d back online %ssynchronously", ldrive, async ? "a" : ""); @@ -1427,7 +1425,7 @@ cc = CISS_FIND_COMMAND(cr); cc->header.address = *ld->cl_controller; /* target controller */ cbc = (struct ciss_bmic_cdb *)&(cc->cdb.cdb[0]); - cbc->log_drive = ldrive; + cbc->log_drive = CISS_LUN_TO_TARGET(ld->cl_address.logical.lun); /* * Dispatch the request asynchronously if we can't sleep waiting @@ -3570,7 +3568,7 @@ static void ciss_print_adapter(struct ciss_softc *sc) { - int i, j; + int i; ciss_printf(sc, "ADAPTER:\n"); for (i = 0; i < CISSQ_COUNT; i++) { @@ -3581,14 +3579,14 @@ sc->ciss_qstat[i].q_max); } ciss_printf(sc, "max_requests %d\n", sc->ciss_max_requests); + ciss_printf(sc, "notify_head/tail %d/%d\n", + sc->ciss_notify_head, sc->ciss_notify_tail); ciss_printf(sc, "flags %b\n", sc->ciss_flags, "\20\1notify_ok\2control_open\3aborting\4running\21fake_synch\22bmic_abort\n"); - for (i = 0; i < sc->ciss_max_bus_number; i++) { - for (j = 0; j < CISS_MAX_LOGICAL; j++) { - ciss_printf(sc, "LOGICAL DRIVE %d: ", i); - ciss_print_ldrive(sc, &sc->ciss_logical[i][j]); - } + for (i = 0; i < CISS_MAX_LOGICAL; i++) { + ciss_printf(sc, "LOGICAL DRIVE %d: ", i); + ciss_print_ldrive(sc, sc->ciss_logical + i); } for (i = 1; i < sc->ciss_max_requests; i++) --- //depot/vendor/freebsd/src/sys/dev/ciss/cissreg.h 2004/04/21 23:25:26 +++ //depot/user/jhb/acpipci/dev/ciss/cissreg.h 2004/04/19 12:55:20 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ciss/cissreg.h,v 1.8 2004/04/22 06:23:47 ps Exp $ + * $FreeBSD: src/sys/dev/ciss/cissreg.h,v 1.7 2004/04/16 23:00:01 ps Exp $ */ /* @@ -622,9 +622,6 @@ char connector[2]; u_int8_t res5; u_int8_t bay; - u_int16_t rpm; - u_int8_t drive_type; - u_int8_t res6[393]; } __packed; /* CISS_BMIC_BLINK_PDRIVE */ --- //depot/vendor/freebsd/src/sys/dev/gem/if_gem.c 2004/04/23 12:45:31 +++ //depot/user/jhb/acpipci/dev/gem/if_gem.c 2004/03/26 08:52:16 @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/gem/if_gem.c,v 1.22 2004/04/23 19:43:35 tmm Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/gem/if_gem.c,v 1.21 2004/03/20 20:12:12 mdodd Exp $"); /* * Driver for Sun GEM ethernet controllers. @@ -237,11 +237,11 @@ /* Get RX FIFO size */ sc->sc_rxfifosize = 64 * bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_RX_FIFO_SIZE); + printf(", %uKB RX fifo", sc->sc_rxfifosize / 1024); /* Get TX FIFO size */ v = bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_FIFO_SIZE); - device_printf(sc->sc_dev, "%ukB RX FIFO, %ukB TX FIFO\n", - sc->sc_rxfifosize / 1024, v / 16); + printf(", %uKB TX fifo\n", v / 16); /* Initialize ifnet structure. */ ifp->if_softc = sc; --- //depot/vendor/freebsd/src/sys/dev/if_ndis/if_ndis.c 2004/04/23 10:15:32 +++ //depot/user/jhb/acpipci/dev/if_ndis/if_ndis.c 2004/04/16 11:09:59 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v 1.57 2004/04/23 17:15:14 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v 1.53 2004/04/14 07:48:03 wpaul Exp $"); #include "opt_bdg.h" @@ -87,10 +87,14 @@ int ndis_resume (device_t); void ndis_shutdown (device_t); +static void ndis_serial_input (void *); + static __stdcall void ndis_txeof (ndis_handle, ndis_packet *, ndis_status); static __stdcall void ndis_rxeof (ndis_handle, ndis_packet **, uint32_t); +static __stdcall void ndis_rxeof_serial (ndis_handle, + ndis_packet **, uint32_t); static __stdcall void ndis_linksts (ndis_handle, ndis_status, void *, uint32_t); static __stdcall void ndis_linksts_done (ndis_handle); @@ -378,7 +382,7 @@ * init routine may trigger an interrupt. */ - error = bus_setup_intr(dev, sc->ndis_irq, INTR_TYPE_NET | INTR_MPSAFE, + error = bus_setup_intr(dev, sc->ndis_irq, INTR_TYPE_NET, ndis_intr, sc, &sc->ndis_intrhand); if (error) { @@ -417,6 +421,14 @@ } /* + * Check to see if this driver is deserialized or + * not. If not, we need to do use a special serialized + * receive handler. + */ + if (!(sc->ndis_block.nmb_flags & NDIS_ATTRIBUTE_DESERIALIZE)) + sc->ndis_block.nmb_pktind_func = ndis_rxeof_serial; + + /* * Get station address from the driver. */ len = sizeof(eaddr); @@ -687,9 +699,9 @@ struct ifnet *ifp; sc = device_get_softc(dev); - KASSERT(mtx_initialized(&sc->ndis_mtx), + KASSERT(mtx_initialized(sc->ndis_mtx), ("ndis mutex not initialized")); - KASSERT(mtx_initialized(&sc->ndis_intrmtx), + KASSERT(mtx_initialized(sc->ndis_intrmtx), ("ndis interrupt mutex not initialized")); NDIS_LOCK(sc); ifp = &sc->arpcom.ac_if; @@ -866,6 +878,108 @@ return; } +static void +ndis_serial_input(arg) + void *arg; +{ + struct mbuf *m; + struct ifnet *ifp; + + m = arg; + ifp = m->m_pkthdr.rcvif; + (*ifp->if_input)(ifp, m); + + return; +} + +/* + * Special receive handler for serialized miniports. To really serialize + * things, we have to make sure not to try and return packets to the driver + * until after this routine returns. The best way to do that is put the + * call to (*ifp->if_input)() on the ndis swi work queue. In theory, + * we could also copy the packet. I'm not sure which is faster. + */ + +__stdcall static void +ndis_rxeof_serial(adapter, packets, pktcnt) + ndis_handle adapter; + ndis_packet **packets; + uint32_t pktcnt; +{ + struct ndis_softc *sc; + ndis_miniport_block *block; + ndis_packet *p; + uint32_t s; + ndis_tcpip_csum *csum; + struct ifnet *ifp; + struct mbuf *m0, *m; + int i; + + block = (ndis_miniport_block *)adapter; + sc = (struct ndis_softc *)(block->nmb_ifp); + ifp = block->nmb_ifp; + + for (i = 0; i < pktcnt; i++) { + p = packets[i]; + /* Stash the softc here so ptom can use it. */ + p->np_softc = sc; + if (ndis_ptom(&m0, p)) { + device_printf (sc->ndis_dev, "ptom failed\n"); + if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS) + ndis_return_packet(sc, p); + } else { + if (p->np_oob.npo_status == NDIS_STATUS_RESOURCES) { + m = m_dup(m0, M_DONTWAIT); + /* + * NOTE: we want to destroy the mbuf here, but + * we don't actually want to return it to the + * driver via the return packet handler. By + * bumping np_refcnt, we can prevent the + * ndis_return_packet() routine from actually + * doing anything. + */ + p->np_refcnt++; + m_freem(m0); + if (m == NULL) + ifp->if_ierrors++; + else + m0 = m; + } else + p->np_oob.npo_status = NDIS_STATUS_PENDING; + m0->m_pkthdr.rcvif = ifp; + + /* Deal with checksum offload. */ + + if (ifp->if_capenable & IFCAP_RXCSUM && + p->np_ext.npe_info[ndis_tcpipcsum_info] != NULL) { + s = (uintptr_t) + p->np_ext.npe_info[ndis_tcpipcsum_info]; + csum = (ndis_tcpip_csum *)&s; + if (csum->u.ntc_rxflags & + NDIS_RXCSUM_IP_PASSED) + m0->m_pkthdr.csum_flags |= + CSUM_IP_CHECKED|CSUM_IP_VALID; + if (csum->u.ntc_rxflags & + (NDIS_RXCSUM_TCP_PASSED | + NDIS_RXCSUM_UDP_PASSED)) { + m0->m_pkthdr.csum_flags |= + CSUM_DATA_VALID|CSUM_PSEUDO_HDR; + m0->m_pkthdr.csum_data = 0xFFFF; + } + } + + if (ndis_sched(ndis_serial_input, m0, NDIS_SWI)) { + p->np_refcnt++; + m_freem(m0); + ifp->if_ierrors++; + p->np_oob.npo_status = NDIS_STATUS_SUCCESS; + } else + ifp->if_ipackets++; + } + } + + return; +} /* * A frame was downloaded to the chip. It's safe for us to clean up * the list buffers. @@ -1032,8 +1146,6 @@ ndis_media_state linkstate; int error, len; - mtx_unlock(&Giant); - sc = xsc; hangfunc = sc->ndis_chars.nmc_checkhang_func; @@ -1068,8 +1180,6 @@ NDIS_UNLOCK(sc); - mtx_lock(&Giant); - return; } --- //depot/vendor/freebsd/src/sys/dev/led/led.c 2004/04/27 06:10:41 +++ //depot/user/jhb/acpipci/dev/led/led.c 2004/03/10 13:15:05 @@ -9,7 +9,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/led/led.c,v 1.9 2004/04/27 13:09:21 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/led/led.c,v 1.8 2004/02/21 21:10:43 phk Exp $"); #include #include @@ -52,14 +52,10 @@ sc->count--; continue; } - if (*sc->ptr == '.') { - sc->ptr = NULL; - continue; - } else if (*sc->ptr >= 'a' && *sc->ptr <= 'j') { + if (*sc->ptr >= 'a' && *sc->ptr <= 'j') sc->func(sc->private, 0); - } else if (*sc->ptr >= 'A' && *sc->ptr <= 'J') { + else if (*sc->ptr >= 'A' && *sc->ptr <= 'J') sc->func(sc->private, 1); - } sc->count = *sc->ptr & 0xf; sc->ptr++; if (*sc->ptr == '\0') @@ -157,10 +153,11 @@ */ case 's': for(s++; *s; s++) { - if ((*s >= 'a' && *s <= 'j') || - (*s >= 'A' && *s <= 'J') || - *s == '.') - sbuf_bcat(sb, s, 1); + if ((*s & 0x0f) > 10) + continue; + if ((*s & 0xf0) < ' ') + continue; + sbuf_bcat(sb, s, 1); } break; /* @@ -252,7 +249,6 @@ sbuf_delete(sb); mtx_lock(&led_mtx); LIST_INSERT_HEAD(&led_list, sc, list); - sc->func(sc->private, 0); mtx_unlock(&led_mtx); return (sc->dev); } --- //depot/vendor/freebsd/src/sys/dev/pccbb/pccbb.c 2004/04/22 22:25:25 +++ //depot/user/jhb/acpipci/dev/pccbb/pccbb.c 2004/04/16 11:09:59 @@ -73,7 +73,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.109 2004/04/23 05:25:13 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.108 2004/04/13 14:39:26 imp Exp $"); #include #include @@ -683,12 +683,9 @@ static int cbb_attach(device_t brdev) { - static int curr_bus_number = 1; /* XXX EVILE BAD (see below) */ struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev); - int rid, bus, pribus; - device_t parent; + int rid; - parent = device_get_parent(brdev); mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF); cv_init(&sc->cv, "cbb cv"); sc->chipset = cbb_chipset(pci_get_devid(brdev), NULL); @@ -762,32 +759,6 @@ sc->exca.chipset = EXCA_CARDBUS; cbb_chipinit(sc); - /* - * This is a gross hack. We should be scanning the entire pci - * tree, assigning bus numbers in a way such that we (1) can - * reserve 1 extra bus just in case and (2) all sub busses - * are in an appropriate range. - */ - bus = pci_read_config(brdev, PCIR_SECBUS_2, 1); - pribus = pcib_get_bus(parent); - DEVPRINTF((brdev, "Secondary bus is %d\n", bus)); - if (bus == 0) { - if (curr_bus_number < pribus) - curr_bus_number = pribus + 1; - if (pci_read_config(brdev, PCIR_PRIBUS_2, 1) != pribus) { - DEVPRINTF((brdev, "Setting primary bus to %d\n", pribus)); - pci_write_config(brdev, PCIR_PRIBUS_2, pribus, 1); - } - bus = curr_bus_number; - DEVPRINTF((brdev, "Secondary bus set to %d subbus %d\n", bus, - bus + 1)); - sc->secbus = bus; - sc->subbus = bus + 1; - pci_write_config(brdev, PCIR_SECBUS_2, bus, 1); - pci_write_config(brdev, PCIR_SUBBUS_2, bus + 1, 1); - curr_bus_number += 2; - } - /* attach children */ sc->cbdev = device_add_child(brdev, "cardbus", -1); if (sc->cbdev == NULL) --- //depot/vendor/freebsd/src/sys/dev/pci/pci.c 2004/04/25 19:15:34 +++ //depot/user/jhb/acpipci/dev/pci/pci.c 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ * (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/dev/pci/pci.c,v 1.249 2004/04/26 02:11:38 imp Exp $ + * $FreeBSD: src/sys/dev/pci/pci.c,v 1.245 2004/04/16 15:01:54 imp Exp $ * */ @@ -495,7 +495,7 @@ /* * Dx -> Dx is a nop always. */ - if (pci_get_powerstate(child) == state) + if (pci_get_powerstate(dev) == state) return (0); if (cfg->pp.pp_cap != 0) { @@ -824,15 +824,6 @@ */ if (base == 0) return 1; - -#ifdef __sparc64__ - /* Sun EBus bridges contain the ranges for the devices beyond them */ - if ((pci_get_class(dev) == PCIC_BRIDGE) && - (pci_get_vendor(dev) == 0x108e) && - (pci_get_device(dev) == 0x1000 || pci_get_device(dev) == 0x1100)) - return 1; -#endif - start = base; end = base + (1 << ln2size) - 1; count = 1 << ln2size; @@ -846,70 +837,7 @@ return ((ln2range == 64) ? 2 : 1); } -static int -pci_is_ata_legacy(device_t dev) -{ - /* - * ATA PCI in compatibility mode are hard wired to certain - * compatibility addresses. Such entries does not contain - * valid resources as they are at fixed positions to be - * compatible with old ISA requirements. - */ - if ((pci_get_class(dev) == PCIC_STORAGE) && - (pci_get_subclass(dev) == PCIS_STORAGE_IDE) && - (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) && - !(pci_get_progif(dev) & - (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))) - return 1; - return 0; -} - -/* - * The ATA PCI spec specifies that in legacy mode, the device shall - * decode the resources listed below. The ata driver allocates - * resources in this order, and many atapci devices actually have - * values similar to these in the actual underlying bars. Part of the - * problem is that the floppy controller and ata overlap for 1 byte, - * which makes it difficult to properly allocate things. - * - * My reading of the pci spec is such that this appears to be the only - * allowed exception to the rule that devices only decode the addresses - * presented in their BARs. We also ensure that the bits that take - * the device out of legacy mode are set to 0 before making this - * reservation. - */ static void -pci_add_ata_legacy_maps(device_t pcib, device_t bus, device_t dev, int b, - int s, int f, struct resource_list *rl) -{ - int rid; - int type; - - type = SYS_RES_IOPORT; - if ((pci_get_progif(dev) & PCIP_STORAGE_IDE_MODEPRIM) == 0) { - rid = PCIR_BAR(0); - resource_list_add(rl, type, rid, 0x1f0, 0x1f7, 8); - resource_list_alloc(rl, bus, dev, type, &rid, 0x1f0, 0x1f7, 8, - 0); - rid = PCIR_BAR(1); - resource_list_add(rl, type, rid, 0x3f6, 0x3f6, 1); - resource_list_alloc(rl, bus, dev, type, &rid, 0x3f6, 0x3f6, 1, - 0); - } - if ((pci_get_progif(dev) & PCIP_STORAGE_IDE_MODESEC) == 0) { - rid = PCIR_BAR(2); - resource_list_add(rl, type, rid, 0x170, 0x177, 8); - resource_list_alloc(rl, bus, dev, type, &rid, 0x170, 0x177, 8, - 0); - rid = PCIR_BAR(3); - resource_list_add(rl, type, rid, 0x376, 0x376, 1); - resource_list_alloc(rl, bus, dev, type, &rid, 0x376, 0x376, 1, - 0); - } - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(4), rl); -} - -static void pci_add_resources(device_t pcib, device_t bus, device_t dev) { struct pci_devinfo *dinfo = device_get_ivars(dev); @@ -921,13 +849,8 @@ b = cfg->bus; s = cfg->slot; f = cfg->func; - - if (pci_is_ata_legacy(dev)) - pci_add_ata_legacy_maps(pcib, bus, dev, b, s, f, rl); - else - for (i = 0; i < cfg->nummaps;) - i += pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(i), - rl); + for (i = 0; i < cfg->nummaps;) + i += pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(i), rl); for (q = &pci_quirks[0]; q->devid; q++) { if (q->devid == ((cfg->device << 16) | cfg->vendor) @@ -1536,43 +1459,49 @@ /* * Weed out the bogons, and figure out how large the BAR/map - * is. Bars that read back 0 here are bogus and unimplemented. - * Note: atapci in legacy mode are special and handled elsewhere - * in the code. If you have a atapci device in legacy mode and - * it fails here, that other code is broken. + * is. Note: some devices have been found that are '0' after + * a write of 0xffffffff. We view these as 'special' and + * allow drivers to allocate whatever they want with them. So + * far, these BARs have only appeared in certain south bridges + * and ata controllers made by VIA, nVidia and AMD. */ res = NULL; map = pci_read_config(child, *rid, 4); pci_write_config(child, *rid, 0xffffffff, 4); testval = pci_read_config(child, *rid, 4); - if (testval == 0) - return (NULL); - if (pci_maptype(testval) & PCI_MAPMEM) { - if (type != SYS_RES_MEMORY) { - device_printf(child, - "failed: rid %#x is memory, requested %d\n", - *rid, type); - goto out; + if (testval != 0) { + if (pci_maptype(testval) & PCI_MAPMEM) { + if (type != SYS_RES_MEMORY) { + device_printf(child, + "failed: rid %#x is memory, requested %d\n", + *rid, type); + goto out; + } + } else { + if (type != SYS_RES_IOPORT) { + device_printf(child, + "failed: rid %#x is ioport, requested %d\n", + *rid, type); + goto out; + } } - } else { - if (type != SYS_RES_IOPORT) { + /* + * For real BARs, we need to override the size that + * the driver requests, because that's what the BAR + * actually uses and we would otherwise have a + * situation where we might allocate the excess to + * another driver, which won't work. + */ + mapsize = pci_mapsize(testval); + count = 1 << mapsize; + if (RF_ALIGNMENT(flags) < mapsize) + flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); + } + else { + if (bootverbose) device_printf(child, - "failed: rid %#x is ioport, requested %d\n", - *rid, type); - goto out; - } + "ZERO BAR: resource checks suppressed.\n"); } - /* - * For real BARs, we need to override the size that - * the driver requests, because that's what the BAR - * actually uses and we would otherwise have a - * situation where we might allocate the excess to - * another driver, which won't work. - */ - mapsize = pci_mapsize(testval); - count = 1 << mapsize; - if (RF_ALIGNMENT(flags) < mapsize) - flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); /* * Allocate enough resource, and then write back the --- //depot/vendor/freebsd/src/sys/dev/puc/pucdata.c 2004/04/24 06:05:30 +++ //depot/user/jhb/acpipci/dev/puc/pucdata.c 2004/04/19 12:55:20 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.44 2004/04/24 13:04:00 sobomax Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.43 2004/04/18 14:37:27 bde Exp $"); /* * PCI "universal" communications card driver configuration data (used to @@ -1063,51 +1063,6 @@ }, }, - { "IC Book Labs Gunboat x2 Low Profile", - { 0xb00c, 0x0a1c, 0, 0 }, - { 0xffff, 0xffff, 0, 0 }, - { - { PUC_PORT_TYPE_COM, 0x10, 0x00, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x08, COM_FREQ }, - }, - }, - - { "IC Book Labs Gunboat x4 Lite", - { 0xb00c, 0x021c, 0, 0 }, - { 0xffff, 0xffff, 0, 0 }, - { - { PUC_PORT_TYPE_COM, 0x10, 0x00, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x08, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x10, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x18, COM_FREQ }, - }, - PUC_ILR_TYPE_DIGI, { 0x07 }, - }, - - { "IC Book Labs Gunboat x4 Pro", - { 0xb00c, 0x031c, 0, 0 }, - { 0xffff, 0xffff, 0, 0 }, - { - { PUC_PORT_TYPE_COM, 0x10, 0x00, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x08, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x10, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x18, COM_FREQ }, - }, - PUC_ILR_TYPE_DIGI, { 0x07 }, - }, - - { "IC Book Labs Gunboat x4 Low Profile", - { 0xb00c, 0x0b1c, 0, 0 }, - { 0xffff, 0xffff, 0, 0 }, - { - { PUC_PORT_TYPE_COM, 0x10, 0x00, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x08, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x10, COM_FREQ }, - { PUC_PORT_TYPE_COM, 0x10, 0x18, COM_FREQ }, - }, - PUC_ILR_TYPE_DIGI, { 0x07 }, - }, - { "IC Book Labs Ironclad x8 Lite", { 0xb00c, 0x041c, 0, 0 }, { 0xffff, 0xffff, 0, 0 }, --- //depot/vendor/freebsd/src/sys/dev/sio/sio.c 2004/04/07 15:00:57 +++ //depot/user/jhb/acpipci/dev/sio/sio.c 2004/04/16 11:09:59 @@ -1155,6 +1155,9 @@ rid = 0; com->irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); + if (com->irqres == NULL) + com->irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | RF_SHAREABLE); if (com->irqres) { ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres, INTR_TYPE_TTY | INTR_FAST, --- //depot/vendor/freebsd/src/sys/dev/sound/pci/cmi.c 2004/04/20 21:25:29 +++ //depot/user/jhb/acpipci/dev/sound/pci/cmi.c 2004/04/16 11:09:59 @@ -51,7 +51,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/cmi.c,v 1.28 2004/04/21 04:23:51 green Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/cmi.c,v 1.27 2004/04/14 14:57:49 green Exp $"); /* Supported chip ID's */ #define CMI8338A_PCI_ID 0x010013f6 @@ -863,7 +863,7 @@ sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid, RF_ACTIVE | RF_SHAREABLE); if (!sc->irq || - snd_setup_intr(dev, sc->irq, INTR_MPSAFE, cmi_intr, sc, &sc->ih)) { + snd_setup_intr(dev, sc->irq, 0, cmi_intr, sc, &sc->ih)) { device_printf(dev, "cmi_attach: Unable to map interrupt\n"); goto bad; } --- //depot/vendor/freebsd/src/sys/dev/uart/uart_dev_sab82532.c 2004/04/24 21:35:41 +++ //depot/user/jhb/acpipci/dev/uart/uart_dev_sab82532.c 2003/10/23 14:00:40 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/uart/uart_dev_sab82532.c,v 1.6 2004/04/25 04:30:40 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/uart/uart_dev_sab82532.c,v 1.5 2003/09/26 05:14:56 marcel Exp $"); #include #include @@ -252,7 +252,7 @@ sab82532_param(bas, baudrate, databits, stopbits, parity); /* Clear interrupts. */ - uart_setreg(bas, SAB_IMR0, (unsigned char)~SAB_IMR0_TCD); + uart_setreg(bas, SAB_IMR0, 0xff); uart_setreg(bas, SAB_IMR1, 0xff); uart_barrier(bas); uart_getreg(bas, SAB_ISR0); --- //depot/vendor/freebsd/src/sys/dev/usb/if_axe.c 2004/04/25 04:25:29 +++ //depot/user/jhb/acpipci/dev/usb/if_axe.c 2004/03/26 08:52:16 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/usb/if_axe.c,v 1.12 2004/04/25 11:21:30 sanpei Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/if_axe.c,v 1.11 2004/03/14 07:12:23 mdodd Exp $"); /* * ASIX Electronics AX88172 USB 2.0 ethernet driver. Used in the @@ -108,7 +108,6 @@ { USB_VENDOR_ASIX, USB_PRODUCT_ASIX_AX88172 }, { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DUBE100 }, { USB_VENDOR_LINKSYS2, USB_PRODUCT_LINKSYS_USB200M }, - { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUAU2KTX }, { USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA120 }, { 0, 0 } }; --- //depot/vendor/freebsd/src/sys/dev/usb/usbdevs 2004/04/27 06:55:36 +++ //depot/user/jhb/acpipci/dev/usb/usbdevs 2004/04/16 11:09:59 @@ -1,4 +1,4 @@ -$FreeBSD: src/sys/dev/usb/usbdevs,v 1.172 2004/04/27 13:55:26 sanpei Exp $ +$FreeBSD: src/sys/dev/usb/usbdevs,v 1.170 2004/04/16 05:24:45 obrien Exp $ /* * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -374,7 +374,6 @@ vendor DLINK 0x2001 D-Link vendor VIDZMEDIA 0x3275 VidzMedia Pte Ltd vendor DAISY 0x3579 Daisy Technology -vendor DELL 0x413c Dell vendor INTEL 0x8086 Intel vendor HP2 0xf003 Hewlett Packard @@ -592,9 +591,6 @@ /* Dallas Semiconductor products */ product DALLAS J6502 0x4201 J-6502 speakers -/* Dell products */ -product DELL BC02 0x8000 Dell BC02 Bluetooth USB Adapter - /* Diamond products */ product DIAMOND RIO500USB 0x0001 Rio 500 USB @@ -930,7 +926,6 @@ product MELCO LUA2TX5 0x0009 LUA2-TX Ethernet product MELCO LUAKTX 0x0012 LUA-KTX Ethernet product MELCO DUBPXXG 0x001c USB-IDE Bridge: DUB-PxxG -product MELCO LUAU2KTX 0x003d LUA-U2-KTX Ethernet /* Metricom products */ product METRICOM RICOCHET_GS 0x0001 Ricochet GS --- //depot/vendor/freebsd/src/sys/dev/usb/usbdevs.h 2004/04/27 07:00:57 +++ //depot/user/jhb/acpipci/dev/usb/usbdevs.h 2004/04/16 11:09:59 @@ -1,10 +1,10 @@ -/* $FreeBSD: src/sys/dev/usb/usbdevs.h,v 1.179 2004/04/27 13:56:39 sanpei Exp $ */ +/* $FreeBSD: src/sys/dev/usb/usbdevs.h,v 1.177 2004/04/16 05:24:45 obrien Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * FreeBSD: src/sys/dev/usb/usbdevs,v 1.172 2004/04/27 13:55:26 sanpei Exp + * FreeBSD: src/sys/dev/usb/usbdevs,v 1.169 2004/03/18 01:02:46 sobomax Exp */ /* @@ -381,7 +381,6 @@ #define USB_VENDOR_DLINK 0x2001 /* D-Link */ #define USB_VENDOR_VIDZMEDIA 0x3275 /* VidzMedia Pte Ltd */ #define USB_VENDOR_DAISY 0x3579 /* Daisy Technology */ -#define USB_VENDOR_DELL 0x413c /* Dell */ #define USB_VENDOR_INTEL 0x8086 /* Intel */ #define USB_VENDOR_HP2 0xf003 /* Hewlett Packard */ @@ -599,9 +598,6 @@ /* Dallas Semiconductor products */ #define USB_PRODUCT_DALLAS_J6502 0x4201 /* J-6502 speakers */ -/* Dell products */ -#define USB_PRODUCT_DELL_BC02 0x8000 /* Dell BC02 Bluetooth USB Adapter */ - /* Diamond products */ #define USB_PRODUCT_DIAMOND_RIO500USB 0x0001 /* Rio 500 USB */ @@ -937,7 +933,6 @@ #define USB_PRODUCT_MELCO_LUA2TX5 0x0009 /* LUA2-TX Ethernet */ #define USB_PRODUCT_MELCO_LUAKTX 0x0012 /* LUA-KTX Ethernet */ #define USB_PRODUCT_MELCO_DUBPXXG 0x001c /* USB-IDE Bridge: DUB-PxxG */ -#define USB_PRODUCT_MELCO_LUAU2KTX 0x003d /* LUA-U2-KTX Ethernet */ /* Metricom products */ #define USB_PRODUCT_METRICOM_RICOCHET_GS 0x0001 /* Ricochet GS */ --- //depot/vendor/freebsd/src/sys/dev/usb/usbdevs_data.h 2004/04/27 07:00:57 +++ //depot/user/jhb/acpipci/dev/usb/usbdevs_data.h 2004/04/16 11:09:59 @@ -1,10 +1,10 @@ -/* $FreeBSD: src/sys/dev/usb/usbdevs_data.h,v 1.179 2004/04/27 13:56:39 sanpei Exp $ */ +/* $FreeBSD: src/sys/dev/usb/usbdevs_data.h,v 1.177 2004/04/16 05:24:45 obrien Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * FreeBSD: src/sys/dev/usb/usbdevs,v 1.172 2004/04/27 13:55:26 sanpei Exp + * FreeBSD: src/sys/dev/usb/usbdevs,v 1.169 2004/03/18 01:02:46 sobomax Exp */ /* @@ -772,12 +772,6 @@ "J-6502 speakers", }, { - USB_VENDOR_DELL, USB_PRODUCT_DELL_BC02, - 0, - "Dell", - "Dell BC02 Bluetooth USB Adapter", - }, - { USB_VENDOR_DIAMOND, USB_PRODUCT_DIAMOND_RIO500USB, 0, "Diamond", @@ -2044,12 +2038,6 @@ "USB-IDE Bridge: DUB-PxxG", }, { - USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUAU2KTX, - 0, - "Melco", - "LUA-U2-KTX Ethernet", - }, - { USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS, 0, "Metricom", @@ -5224,12 +5212,6 @@ NULL, }, { - USB_VENDOR_DELL, 0, - USB_KNOWNDEV_NOPROD, - "Dell", - NULL, - }, - { USB_VENDOR_INTEL, 0, USB_KNOWNDEV_NOPROD, "Intel", --- //depot/vendor/freebsd/src/sys/dev/vinum/vinumio.c 2004/04/24 16:45:19 +++ //depot/user/jhb/acpipci/dev/vinum/vinumio.c 2004/03/26 08:52:16 @@ -34,7 +34,7 @@ * advised of the possibility of such damage. * * $Id: vinumio.c,v 1.39 2003/05/23 00:59:53 grog Exp grog $ - * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.98 2004/04/24 23:41:21 le Exp $ + * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.97 2004/03/11 14:11:08 le Exp $ */ #include @@ -878,7 +878,6 @@ drive->flags |= VF_CONFIGURED; /* this drive's configuration is complete */ } - Free(config_line); Free(config_text); Free(drivelist); vinum_conf.flags &= ~VF_READING_CONFIG; /* no longer reading from disk */ --- //depot/vendor/freebsd/src/sys/geom/concat/g_concat.c 2004/04/20 10:11:15 +++ //depot/user/jhb/acpipci/geom/concat/g_concat.c 2004/03/10 13:15:05 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/geom/concat/g_concat.c,v 1.7 2004/04/20 17:07:55 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/geom/concat/g_concat.c,v 1.6 2004/03/09 11:18:53 pjd Exp $"); #include #include @@ -750,28 +750,28 @@ g_concat_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) { - struct g_concat_softc *sc; + struct g_concat_softc *sc; - sc = gp->softc; - if (sc == NULL) - return; - if (pp == NULL && cp == NULL) { - sbuf_printf(sb, "%s%zu\n", indent, sc->sc_id); + sc = gp->softc; + if (sc == NULL) + return; + if (gp != NULL) { + sbuf_printf(sb, "%s%zu\n", indent, sc->sc_id); switch (sc->sc_type) { case G_CONCAT_TYPE_AUTOMATIC: - sbuf_printf(sb, "%s%s\n", indent, + sbuf_printf(sb, "%s%s\n", indent, "automatic"); break; case G_CONCAT_TYPE_MANUAL: - sbuf_printf(sb, "%s%s\n", indent, + sbuf_printf(sb, "%s%s\n", indent, "manual"); break; default: - sbuf_printf(sb, "%s%s\n", indent, + sbuf_printf(sb, "%s%s\n", indent, "unknown"); break; } - } + } } DECLARE_GEOM_CLASS(g_concat_class, g_concat); --- //depot/vendor/freebsd/src/sys/i386/acpica/acpi_machdep.c 2004/04/20 19:11:56 +++ //depot/user/jhb/acpipci/i386/acpica/acpi_machdep.c 2004/03/10 13:15:05 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/acpica/acpi_machdep.c,v 1.18 2004/04/21 02:10:58 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/acpica/acpi_machdep.c,v 1.17 2004/02/21 21:10:49 phk Exp $"); #include #include @@ -223,7 +223,8 @@ struct apm_info info; apm_info_old_t aiop; - acpi_sc = device_get_softc(acpi_dev); + if ((acpi_sc = device_get_softc(acpi_dev)) == NULL) + return (ENXIO); switch (cmd) { case APMIO_SUSPEND: @@ -316,7 +317,8 @@ struct acpi_softc *sc; acpi_dev = dev; - sc = device_get_softc(acpi_dev); + if ((sc = device_get_softc(acpi_dev)) == NULL) + return (ENXIO); /* * XXX: Prevent the PnP BIOS code from interfering with --- //depot/vendor/freebsd/src/sys/i386/conf/GENERIC 2004/04/26 15:56:34 +++ //depot/user/jhb/acpipci/i386/conf/GENERIC 2004/04/16 11:09:59 @@ -16,7 +16,7 @@ # If you are in doubt as to the purpose or necessity of a line, check first # in NOTES. # -# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.402 2004/04/26 22:52:09 sobomax Exp $ +# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.400 2004/04/15 15:11:04 josef Exp $ machine i386 cpu I486_CPU @@ -70,8 +70,7 @@ options SMP # Symmetric MultiProcessor Kernel device apic # I/O APIC -# Bus support. Do not remove isa, even if you have no isa slots -device isa +device isa # Required by npx(4) device eisa device pci @@ -268,7 +267,6 @@ device axe # ASIX Electronics USB ethernet device cue # CATC USB ethernet device kue # Kawasaki LSI USB ethernet -device rue # RealTek RTL8150 USB ethernet # FireWire support device firewire # FireWire bus code --- //depot/vendor/freebsd/src/sys/i386/conf/NOTES 2004/04/22 14:30:37 +++ //depot/user/jhb/acpipci/i386/conf/NOTES 2004/04/16 11:09:59 @@ -4,7 +4,7 @@ # This file contains machine dependent kernel configuration notes. For # machine independent notes, look in /sys/conf/NOTES. # -# $FreeBSD: src/sys/i386/conf/NOTES,v 1.1157 2004/04/22 21:29:02 philip Exp $ +# $FreeBSD: src/sys/i386/conf/NOTES,v 1.1156 2004/04/16 09:29:45 eivind Exp $ # # @@ -450,9 +450,6 @@ #!options ACPI_NO_SEMAPHORES #!options ACPICA_PEDANTIC -# ACPI Asus Extras (LCD backlight/brightness, video output, etc.) -device acpi_asus - # ACPI Toshiba Extras (LCD backlight/brightness, video output, etc.) device acpi_toshiba --- //depot/vendor/freebsd/src/sys/i386/i386/apic_vector.s 2004/04/16 12:30:45 +++ //depot/user/jhb/acpipci/i386/i386/apic_vector.s 2004/04/16 13:35:51 @@ -92,6 +92,8 @@ 2: movl $-1, %eax ; /* send a vector of -1 */ \ jmp 1b +MCOUNT_LABEL(bintr2) + /* * Handle "spurious INTerrupts". * Notes: @@ -107,7 +109,6 @@ iret -MCOUNT_LABEL(bintr2) ISR_VEC(1, apic_isr1) ISR_VEC(2, apic_isr2) ISR_VEC(3, apic_isr3) @@ -115,7 +116,6 @@ ISR_VEC(5, apic_isr5) ISR_VEC(6, apic_isr6) ISR_VEC(7, apic_isr7) -MCOUNT_LABEL(eintr2) #ifdef SMP /* @@ -407,3 +407,5 @@ POP_FRAME iret #endif /* SMP */ + +MCOUNT_LABEL(eintr2) --- //depot/vendor/freebsd/src/sys/i386/i386/elan-mmcr.c 2004/04/27 06:10:41 +++ //depot/user/jhb/acpipci/i386/i386/elan-mmcr.c 2004/04/16 11:09:59 @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/i386/elan-mmcr.c,v 1.28 2004/04/27 13:08:03 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/i386/elan-mmcr.c,v 1.27 2004/04/03 18:42:52 phk Exp $"); #include "opt_cpu.h" #include @@ -189,10 +189,10 @@ if (led_dev[i]) break; sprintf(tmp, "gpio%d", i); + led_dev[i] = + led_create(gpio_led, &led_cookie[i], tmp); mmcrptr[(0xc2a + v) / 2] |= u; gpio_config[i] = buf[i]; - led_dev[i] = - led_create(gpio_led, &led_cookie[i], tmp); break; case '.': gpio_config[i] = buf[i]; --- //depot/vendor/freebsd/src/sys/i386/i386/exception.s 2004/04/16 12:30:45 +++ //depot/user/jhb/acpipci/i386/i386/exception.s 2004/04/16 13:35:51 @@ -317,3 +317,5 @@ movl $0,TF_ERR(%esp) /* XXX should be the error code */ movl $T_PROTFLT,TF_TRAPNO(%esp) jmp alltraps_with_regs_pushed + +MCOUNT_LABEL(etrap) --- //depot/vendor/freebsd/src/sys/i386/i386/mptable.c 2003/12/10 11:30:41 +++ //depot/user/jhb/acpipci/i386/i386/mptable.c 2004/04/27 13:00:22 @@ -48,10 +48,6 @@ #include -/* EISA Edge/Level trigger control registers */ -#define ELCR0 0x4d0 /* eisa irq 0-7 */ -#define ELCR1 0x4d1 /* eisa irq 8-15 */ - /* string defined by the Intel MP Spec as identifying the MP table */ #define MP_SIG 0x5f504d5f /* _MP_ */ @@ -569,7 +565,6 @@ static u_char conforming_trigger(u_char src_bus, u_char src_bus_irq) { - static int eisa_int_control = -1; KASSERT(src_bus <= mptable_maxbusid, ("bus id %d too large", src_bus)); switch (busses[src_bus].bus_type) { @@ -581,9 +576,7 @@ return (0); case EISA: KASSERT(src_bus_irq < 16, ("Invalid EISA IRQ %d", src_bus_irq)); - if (eisa_int_control == -1) - eisa_int_control = inb(ELCR1) << 8 | inb(ELCR0); - if (eisa_int_control & (1 << src_bus_irq)) + if (elcr_read_trigger(src_bus_irq)) /* Level Triggered */ return (0); else --- //depot/vendor/freebsd/src/sys/i386/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/i386/include/float.h 2004/04/16 11:09:59 @@ -27,20 +27,16 @@ * SUCH DAMAGE. * * from: @(#)float.h 7.1 (Berkeley) 5/8/90 - * $FreeBSD: src/sys/i386/include/float.h,v 1.12 2004/04/25 02:36:28 das Exp $ + * $FreeBSD: src/sys/i386/include/float.h,v 1.11 2004/04/07 20:46:05 imp Exp $ */ #ifndef _MACHINE_FLOAT_H_ #define _MACHINE_FLOAT_H_ 1 -#include - #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS 1 /* FP addition rounds to nearest */ -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD (-1) /* i387 semantics are...interesting */ #define DECIMAL_DIG 21 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/i386/include/intr_machdep.h 2003/11/14 11:10:36 +++ //depot/user/jhb/acpipci/i386/include/intr_machdep.h 2004/04/27 13:00:22 @@ -77,6 +77,11 @@ extern struct mtx icu_lock; +/* XXX: The elcr_* prototypes probably belong somewhere else. */ +int elcr_probe(void); +int elcr_read_trigger(u_int irq); +void elcr_resume(void); +void elcr_write_trigger(u_int irq, u_int level_triggered); int intr_add_handler(const char *name, int vector, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); void intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe); --- //depot/vendor/freebsd/src/sys/i386/include/pci_cfgreg.h 2004/02/18 14:45:19 +++ //depot/user/jhb/acpipci/i386/include/pci_cfgreg.h 2004/04/27 10:18:12 @@ -51,6 +51,5 @@ u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); void pci_pir_open(void); -void pci_pir_parse(void); int pci_pir_probe(int bus, int require_parse); int pci_pir_route_interrupt(int bus, int device, int func, int pin); --- //depot/vendor/freebsd/src/sys/i386/isa/atpic.c 2004/04/19 11:41:21 +++ //depot/user/jhb/acpipci/i386/isa/atpic.c 2004/04/27 14:21:57 @@ -93,9 +93,15 @@ #define SLAVE_MODE BASE_SLAVE_MODE #endif +#define IMEN_MASK(ai) (1 << (ai)->at_irq) + +/* XXX: This may belong somewhere else. */ +#define NUM_ISA_IRQS 16 + static void atpic_init(void *dummy); unsigned int imen; /* XXX */ +static int using_elcr; inthand_t IDTVEC(atpic_intr0), IDTVEC(atpic_intr1), IDTVEC(atpic_intr2), @@ -113,8 +119,8 @@ atpic_resume }, (io), (base), IDT_IO_INTS + (base), (imenptr) } #define INTSRC(irq) \ - { { &atpics[(irq) / 8].at_pic }, (irq) % 8, \ - IDTVEC(atpic_intr ## irq ) } + { { &atpics[(irq) / 8].at_pic }, IDTVEC(atpic_intr ## irq ), \ + (irq) % 8 } struct atpic { struct pic at_pic; @@ -126,10 +132,11 @@ struct atpic_intsrc { struct intsrc at_intsrc; - int at_irq; /* Relative to PIC base. */ inthand_t *at_intr; u_long at_count; u_long at_straycount; + int at_irq:8; /* Relative to PIC base. */ + int at_trigger:1; /* 1 => level; 0 => edge */ }; static void atpic_enable_source(struct intsrc *isrc); @@ -166,6 +173,8 @@ INTSRC(15), }; +CTASSERT(sizeof(atintrs) / sizeof(struct atpic_intsrc) == NUM_ISA_IRQS); + static void atpic_enable_source(struct intsrc *isrc) { @@ -173,8 +182,10 @@ struct atpic *ap = (struct atpic *)isrc->is_pic; mtx_lock_spin(&icu_lock); - *ap->at_imen &= ~(1 << ai->at_irq); - outb(ap->at_ioaddr + ICU_IMR_OFFSET, *ap->at_imen); + if (*ap->at_imen & IMEN_MASK(ai)) { + *ap->at_imen &= ~IMEN_MASK(ai); + outb(ap->at_ioaddr + ICU_IMR_OFFSET, *ap->at_imen); + } mtx_unlock_spin(&icu_lock); } @@ -184,8 +195,10 @@ struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; struct atpic *ap = (struct atpic *)isrc->is_pic; + if (ai->at_trigger == 0) + return; mtx_lock_spin(&icu_lock); - *ap->at_imen |= (1 << ai->at_irq); + *ap->at_imen |= IMEN_MASK(ai); outb(ap->at_ioaddr + ICU_IMR_OFFSET, *ap->at_imen); mtx_unlock_spin(&icu_lock); } @@ -243,7 +256,7 @@ struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; struct atpic *ap = (struct atpic *)isrc->is_pic; - return (inb(ap->at_ioaddr) & (1 << ai->at_irq)); + return (inb(ap->at_ioaddr) & IMEN_MASK(ai)); } static void @@ -252,8 +265,11 @@ struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; struct atpic *ap = (struct atpic *)isrc->is_pic; - if (ai->at_irq == 0) + if (ai->at_irq == 0) { i8259_init(ap, ap == &atpics[SLAVE]); + if (ap == &atpics[SLAVE]) + elcr_resume(); + } } static void @@ -318,16 +334,55 @@ atpic_enable_source((struct intsrc *)&atintrs[ICU_SLAVEID]); /* Install low-level interrupt handlers for all of our IRQs. */ - for (i = 0; i < sizeof(atintrs) / sizeof(struct atpic_intsrc); i++) { + for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) { if (i == ICU_SLAVEID) continue; - ai = &atintrs[i]; ai->at_intsrc.is_count = &ai->at_count; ai->at_intsrc.is_straycount = &ai->at_straycount; setidt(((struct atpic *)ai->at_intsrc.is_pic)->at_intbase + ai->at_irq, ai->at_intr, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); } + +#ifdef DEV_MCA + /* For MCA systems, all interrupts are level triggered. */ + if (MCA_system) + for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) + ai->at_trigger = 1; + else +#endif + + /* + * Look for an ELCR. If we find one, update the trigger modes. + * If we don't find one, assume that IRQs 0, 1, 2, and 13 are + * edge triggered and that everything else is level triggered. + * We only use the trigger information to reprogram the ELCR if + * we have one and as an optimization to avoid masking edge + * triggered interrupts. For the case that we don't have an ELCR, + * it doesn't hurt to mask an edge triggered interrupt, so we + * that is why we assume level trigger for any interrupt that we + * aren't sure is edge triggered. + */ + if (elcr_probe() == 0) { + using_elcr = 1; + for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) + ai->at_trigger = elcr_read_trigger(i); + } else { + for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) + switch (i) { + case 0: + case 1: + case 2: + case 8: + case 13: + /* Assume edge trigger. */ + ai->at_trigger = 0; + break; + default: + ai->at_trigger = 1; + break; + } + } } static void @@ -336,7 +391,7 @@ int i; /* Loop through all interrupt sources and add them. */ - for (i = 0; i < sizeof(atintrs) / sizeof(struct atpic_intsrc); i++) { + for (i = 0; i < NUM_ISA_IRQS; i++) { if (i == ICU_SLAVEID) continue; intr_register_source(&atintrs[i].at_intsrc); --- //depot/vendor/freebsd/src/sys/i386/isa/clock.c 2004/04/27 13:05:31 +++ //depot/user/jhb/acpipci/i386/isa/clock.c 2004/04/22 11:06:19 @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/isa/clock.c,v 1.209 2004/04/27 20:03:26 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/isa/clock.c,v 1.208 2004/04/07 20:46:06 imp Exp $"); /* * Routines to handle clock hardware. --- //depot/vendor/freebsd/src/sys/i386/pci/pci_bus.c 2004/02/19 10:35:29 +++ //depot/user/jhb/acpipci/i386/pci/pci_bus.c 2004/04/27 10:18:12 @@ -424,6 +424,7 @@ int legacy_pcib_attach(device_t dev) { + device_t pir; int bus; /* @@ -431,8 +432,11 @@ * our method of routing interrupts if we have one. */ bus = pcib_get_bus(dev); - if (pci_pir_probe(bus, 0)) - pci_pir_parse(); + if (pci_pir_probe(bus, 0)) { + pir = device_add_child(device_get_parent(dev), "pir", 0); + KASSERT(pir != NULL, ("could not add pir0 device")); + device_probe_and_attach(pir); + } device_add_child(dev, "pci", bus); return bus_generic_attach(dev); } --- //depot/vendor/freebsd/src/sys/i386/pci/pci_pir.c 2004/04/16 11:57:35 +++ //depot/user/jhb/acpipci/i386/pci/pci_pir.c 2004/04/27 10:18:12 @@ -67,6 +67,13 @@ int pin; }; +struct pci_dev_lookup { + uint8_t link; + int bus; + int device; + int pin; +}; + typedef void pir_entry_handler(struct PIR_entry *entry, struct PIR_intpin* intpin, void *arg); @@ -82,6 +89,7 @@ struct PIR_intpin *intpin, void *arg); static void pci_pir_initial_irqs(struct PIR_entry *entry, struct PIR_intpin *intpin, void *arg); +static void pci_pir_parse(void); static void pci_pir_print_intpin(struct PIR_entry *entry, struct PIR_intpin *intpin, void *arg); static void pci_pir_print_table(void); @@ -336,7 +344,7 @@ * various interrupt routers as they could read the initial IRQ for each * link. */ -void +static void pci_pir_parse(void) { char tunable_buffer[64]; @@ -630,3 +638,94 @@ return (1); return (0); } + +/* + * The driver for the new-bus psuedo device pir0 for the $PIR table. + */ + +static int +pir_probe(device_t dev) +{ + + device_set_desc(dev, "PCI Interrupt Routing Table"); + return (0); +} + +static int +pir_attach(device_t dev) +{ + + pci_pir_parse(); + return (0); +} + +static void +pir_resume_find_device(struct PIR_entry *entry, struct PIR_intpin *intpin, + void *arg) +{ + struct pci_dev_lookup *pd; + + pd = (struct pci_dev_lookup *)arg; + if (intpin->link != pd->link || pd->bus != -1) + return; + pd->bus = entry->pe_bus; + pd->device = entry->pe_device; + pd->pin = intpin - entry->pe_intpin; +} + +static int +pir_resume(device_t dev) +{ + struct pci_dev_lookup pd; + struct pci_link *pci_link; + int error; + + /* Ask the BIOS to re-route each link that was already routed. */ + TAILQ_FOREACH(pci_link, &pci_links, pl_links) { + if (!PCI_INTERRUPT_VALID(pci_link->pl_irq)) { + KASSERT(!pci_link->pl_routed, + ("link %#x is routed but has invalid PCI IRQ", + pci_link->pl_id)); + continue; + } + if (pci_link->pl_routed) { + pd.bus = -1; + pd.link = pci_link->pl_id; + pci_pir_walk_table(pir_resume_find_device, &pd); + KASSERT(pd.bus != -1, + ("did not find matching entry for link %#x in the $PIR table", + pci_link->pl_id)); + if (bootverbose) + device_printf(dev, + "Using %d.%d.INT%c to route link %#x to IRQ %d\n", + pd.bus, pd.device, pd.pin + 'A', + pci_link->pl_id, pci_link->pl_irq); + error = pci_pir_biosroute(pd.bus, pd.device, 0, pd.pin, + pci_link->pl_irq); + if (error) + device_printf(dev, + "ROUTE_INTERRUPT on resume for link %#x failed.\n", + pci_link->pl_id); + } + } + return (0); +} + +static device_method_t pir_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pir_probe), + DEVMETHOD(device_attach, pir_attach), + DEVMETHOD(device_resume, pir_resume), + + { 0, 0 } +}; + +static driver_t pir_driver = { + "pir", + pir_methods, + 1, +}; + +static devclass_t pir_devclass; + +DRIVER_MODULE(pir, legacy, pir_driver, pir_devclass, 0, 0); --- //depot/vendor/freebsd/src/sys/ia64/acpica/acpi_machdep.c 2004/04/20 19:11:56 +++ //depot/user/jhb/acpipci/ia64/acpica/acpi_machdep.c 2004/01/09 14:52:13 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/ia64/acpica/acpi_machdep.c,v 1.3 2004/04/21 02:10:58 njl Exp $ + * $FreeBSD: src/sys/ia64/acpica/acpi_machdep.c,v 1.2 2003/08/28 16:30:31 njl Exp $ */ #include @@ -37,7 +37,8 @@ { struct acpi_softc *sc; - sc = device_get_softc(dev); + if ((sc = device_get_softc(dev)) == NULL) + return (ENXIO); acpi_install_wakeup_handler(sc); --- //depot/vendor/freebsd/src/sys/ia64/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/ia64/include/float.h 2004/04/16 11:09:59 @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/ia64/include/float.h,v 1.6 2004/04/25 02:36:29 das Exp $ */ +/* $FreeBSD: src/sys/ia64/include/float.h,v 1.5 2004/04/07 20:46:07 imp Exp $ */ /* From: NetBSD: float.h,v 1.6 1997/07/17 21:36:03 thorpej Exp */ /* @@ -37,10 +37,8 @@ #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS 1 /* FP addition rounds to nearest */ -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD 0 /* no promotions */ #define DECIMAL_DIG 35 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/isa/fd.c 2004/04/24 21:35:41 +++ //depot/user/jhb/acpipci/isa/fd.c 2004/04/16 11:09:59 @@ -49,7 +49,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/isa/fd.c,v 1.270 2004/04/25 04:33:56 bde Exp $"); +__FBSDID("$FreeBSD: src/sys/isa/fd.c,v 1.269 2004/04/07 20:46:08 imp Exp $"); #include "opt_fdc.h" #include "card.h" @@ -2600,16 +2600,9 @@ return (0); case FD_STYPE: /* set drive type */ - /* - * Allow setting drive type temporarily iff - * currently unset. Used for fdformat so any - * user can set it, and then start formatting. - */ - if (fd->ft) - return (EINVAL); /* already set */ + if (suser(td) != 0) + return (EPERM); fd->fts[0] = *(struct fd_type *)addr; - fd->ft = &fd->fts[0]; - fd->flags |= FD_UA; return (0); case FD_GOPTS: /* get drive options */ --- //depot/vendor/freebsd/src/sys/kern/imgact_elf.c 2004/04/22 20:05:30 +++ //depot/user/jhb/acpipci/kern/imgact_elf.c 2004/04/16 11:09:59 @@ -29,7 +29,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/imgact_elf.c,v 1.148 2004/04/23 03:01:39 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/imgact_elf.c,v 1.147 2004/04/08 06:37:00 marcel Exp $"); #include #include @@ -528,10 +528,16 @@ imgp->userspace_envv = NULL; imgp->attr = attr; imgp->firstpage = NULL; - imgp->image_header = NULL; + imgp->image_header = (char *)kmem_alloc_wait(exec_map, PAGE_SIZE); imgp->object = NULL; imgp->execlabel = NULL; + if (imgp->image_header == NULL) { + nd->ni_vp = NULL; + error = ENOMEM; + goto fail; + } + /* XXXKSE */ NDINIT(nd, LOOKUP, LOCKLEAF|FOLLOW, UIO_SYSSPACE, file, curthread); @@ -620,6 +626,9 @@ fail: if (imgp->firstpage) exec_unmap_first_page(imgp); + if (imgp->image_header) + kmem_free_wakeup(exec_map, (vm_offset_t)imgp->image_header, + PAGE_SIZE); if (imgp->object) vm_object_deallocate(imgp->object); --- //depot/vendor/freebsd/src/sys/kern/kern_environment.c 2004/04/27 18:30:33 +++ //depot/user/jhb/acpipci/kern/kern_environment.c 2003/06/27 12:30:23 @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_environment.c,v 1.34 2004/04/28 01:27:33 das Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_environment.c,v 1.33 2003/06/11 00:56:55 obrien Exp $"); #include "opt_mac.h" @@ -87,7 +87,7 @@ } */ *uap; { char *name, *value; - size_t len, done, needed; + size_t len, done; int error, i; KASSERT(dynamic_kenv, ("kenv: dynamic_kenv = 0")); @@ -99,27 +99,30 @@ if (error) return (error); #endif - done = needed = 0; + len = 0; + /* Return the size if called with a NULL buffer */ + if (uap->value == NULL) { + sx_slock(&kenv_lock); + for (i = 0; kenvp[i] != NULL; i++) + len += strlen(kenvp[i]) + 1; + sx_sunlock(&kenv_lock); + td->td_retval[0] = len; + return (0); + } + done = 0; sx_slock(&kenv_lock); - for (i = 0; kenvp[i] != NULL; i++) { - len = strlen(kenvp[i]) + 1; - needed += len; - len = min(len, uap->len - done); - /* - * If called with a NULL or insufficiently large - * buffer, just keep computing the required size. - */ - if (uap->value != NULL && len > 0) { - error = copyout(kenvp[i], uap->value + done, - len); - if (error) - break; - done += len; + for (i = 0; kenvp[i] != NULL && done < uap->len; i++) { + len = min(strlen(kenvp[i]) + 1, uap->len - done); + error = copyout(kenvp[i], uap->value + done, + len); + if (error) { + sx_sunlock(&kenv_lock); + return (error); } + done += len; } sx_sunlock(&kenv_lock); - td->td_retval[0] = ((done == needed) ? 0 : needed); - return (error); + return (0); } if ((uap->what == KENV_SET) || --- //depot/vendor/freebsd/src/sys/kern/kern_exec.c 2004/04/22 20:05:30 +++ //depot/user/jhb/acpipci/kern/kern_exec.c 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.243 2004/04/23 03:01:39 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.242 2004/04/11 19:57:11 alc Exp $"); #include "opt_ktrace.h" #include "opt_mac.h" @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -304,7 +303,8 @@ * Allocate temporary demand zeroed space for argument and * environment strings */ - imgp->stringbase = (char *)kmem_alloc_wait(exec_map, ARG_MAX); + imgp->stringbase = (char *)kmem_alloc_wait(exec_map, ARG_MAX + + PAGE_SIZE); if (imgp->stringbase == NULL) { error = ENOMEM; mtx_lock(&Giant); @@ -312,7 +312,7 @@ } imgp->stringp = imgp->stringbase; imgp->stringspace = ARG_MAX; - imgp->image_header = NULL; + imgp->image_header = imgp->stringbase + ARG_MAX; /* * Translate the file name. namei() returns a vnode pointer @@ -328,7 +328,7 @@ error = namei(ndp); if (error) { kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX); + ARG_MAX + PAGE_SIZE); goto exec_fail; } @@ -699,7 +699,7 @@ if (imgp->stringbase != NULL) kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX); + ARG_MAX + PAGE_SIZE); if (imgp->object != NULL) vm_object_deallocate(imgp->object); @@ -800,8 +800,8 @@ vm_page_unlock_queues(); VM_OBJECT_UNLOCK(object); - imgp->firstpage = sf_buf_alloc(ma[0], 0); - imgp->image_header = (char *)sf_buf_kva(imgp->firstpage); + pmap_qenter((vm_offset_t)imgp->image_header, ma, 1); + imgp->firstpage = ma[0]; return (0); } @@ -810,15 +810,13 @@ exec_unmap_first_page(imgp) struct image_params *imgp; { - vm_page_t m; if (imgp->firstpage != NULL) { - m = sf_buf_page(imgp->firstpage); - sf_buf_free(imgp->firstpage); - imgp->firstpage = NULL; + pmap_qremove((vm_offset_t)imgp->image_header, 1); vm_page_lock_queues(); - vm_page_unhold(m); + vm_page_unhold(imgp->firstpage); vm_page_unlock_queues(); + imgp->firstpage = NULL; } } --- //depot/vendor/freebsd/src/sys/kern/kern_jail.c 2004/04/26 12:50:50 +++ //depot/user/jhb/acpipci/kern/kern_jail.c 2004/03/26 08:52:16 @@ -8,7 +8,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_jail.c,v 1.42 2004/04/26 19:46:52 bmilekic Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_jail.c,v 1.41 2004/03/15 12:10:34 pjd Exp $"); #include #include @@ -59,11 +59,6 @@ &jail_getfsstatroot_only, 0, "Processes see only their root file system in getfsstat()"); -int jail_allow_raw_sockets = 0; -SYSCTL_INT(_security_jail, OID_AUTO, allow_raw_sockets, CTLFLAG_RW, - &jail_allow_raw_sockets, 0, - "Prison root can create raw sockets"); - /* allprison, lastprid, and prisoncount are protected by allprison_mtx. */ struct prisonlist allprison; struct mtx allprison_mtx; --- //depot/vendor/freebsd/src/sys/kern/kern_timeout.c 2004/04/24 21:10:43 +++ //depot/user/jhb/acpipci/kern/kern_timeout.c 2004/04/16 11:09:59 @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_timeout.c,v 1.89 2004/04/25 04:10:17 hmp Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_timeout.c,v 1.87 2004/04/08 02:03:49 cperciva Exp $"); #include #include @@ -160,7 +160,7 @@ * George Varghese, published in a technical report entitled "Redesigning * the BSD Callout and Timer Facilities" and modified slightly for inclusion * in FreeBSD by Justin T. Gibbs. The original work on the data structures - * used in this implementation was published by G. Varghese and T. Lauck in + * used in this implementation was published by G.Varghese and A. Lauck in * the paper "Hashed and Hierarchical Timing Wheels: Data Structures for * the Efficient Implementation of a Timer Facility" in the Proceedings of * the 11th ACM Annual Symposium on Operating Systems Principles, @@ -421,6 +421,16 @@ mtx_unlock_spin(&callout_lock); } +/* For binary compatibility. */ +#undef callout_stop +int +callout_stop(c) + struct callout *c; +{ + + return(_callout_stop_safe(c, 0)); +} + int _callout_stop_safe(c, safe) struct callout *c; --- //depot/vendor/freebsd/src/sys/kern/sched_ule.c 2004/04/22 14:40:08 +++ //depot/user/jhb/acpipci/kern/sched_ule.c 2004/04/16 11:09:59 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.105 2004/04/22 21:37:46 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.104 2004/04/09 14:31:29 cognet Exp $"); #include #include @@ -357,7 +357,7 @@ if (class == PRI_TIMESHARE) kseq->ksq_load_timeshare++; kseq->ksq_load++; - if (class != PRI_ITHD && (ke->ke_proc->p_flag & P_NOLOAD) == 0) + if (class != PRI_ITHD) #ifdef SMP kseq->ksq_group->ksg_load++; #else @@ -380,7 +380,7 @@ class = PRI_BASE(ke->ke_ksegrp->kg_pri_class); if (class == PRI_TIMESHARE) kseq->ksq_load_timeshare--; - if (class != PRI_ITHD && (ke->ke_proc->p_flag & P_NOLOAD) == 0) + if (class != PRI_ITHD) #ifdef SMP kseq->ksq_group->ksg_load--; #else --- //depot/vendor/freebsd/src/sys/kern/vfs_export.c 2004/04/21 05:11:15 +++ //depot/user/jhb/acpipci/kern/vfs_export.c 2004/04/16 11:09:59 @@ -35,23 +35,20 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/vfs_export.c,v 1.326 2004/04/21 12:10:30 bde Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_export.c,v 1.325 2004/04/05 21:03:36 imp Exp $"); #include -#include -#include +#include #include -#include +#include #include #include #include -#include -#include -#include +#include +#include +#include #include -#include - static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); static void vfs_free_addrlist(struct netexport *nep); --- //depot/vendor/freebsd/src/sys/kern/vfs_syscalls.c 2004/04/26 08:45:34 +++ //depot/user/jhb/acpipci/kern/vfs_syscalls.c 2004/04/16 11:09:59 @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.345 2004/04/26 15:44:42 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.343 2004/04/06 10:05:02 bde Exp $"); #include "opt_compat.h" #include "opt_mac.h" @@ -183,7 +183,7 @@ caddr_t arg; } */ *uap; { - struct mount *mp, *vmp; + struct mount *mp; int error; struct nameidata nd; @@ -193,13 +193,12 @@ if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_start_write(nd.ni_vp, &vmp, V_WAIT | PCATCH); - mp = nd.ni_vp->v_mount; + error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); vrele(nd.ni_vp); if (error) return (error); error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, td); - vn_finished_write(vmp); + vn_finished_write(mp); return (error); } --- //depot/vendor/freebsd/src/sys/libkern/mcount.c 2004/04/07 13:52:05 +++ //depot/user/jhb/acpipci/libkern/mcount.c 2004/04/16 11:09:59 @@ -39,8 +39,18 @@ #include #include #include +#ifdef DEV_APIC +/* XXX: #ifdef is messy. */ +void bintr2(void); +void eintr2(void); +#endif void bintr(void); void btrap(void); +#if defined(__i386__) +void etrap(void); +#else +#define etrap bintr +#endif void eintr(void); void user(void); #endif @@ -147,11 +157,16 @@ * bintr() instead of calls from all over. */ if ((uintfptr_t)selfpc >= (uintfptr_t)btrap + && (uintfptr_t)selfpc < (uintfptr_t)etrap) { + frompci = (uintfptr_t)btrap - p->lowpc; + } else if ((uintfptr_t)selfpc >= (uintfptr_t)bintr && (uintfptr_t)selfpc < (uintfptr_t)eintr) { - if ((uintfptr_t)selfpc >= (uintfptr_t)bintr) - frompci = (uintfptr_t)bintr - p->lowpc; - else - frompci = (uintfptr_t)btrap - p->lowpc; + frompci = (uintfptr_t)bintr - p->lowpc; +#ifdef DEV_APIC + } else if ((uintfptr_t)selfpc >= (uintfptr_t)bintr2 + && (uintfptr_t)selfpc < (uintfptr_t)eintr2) { + frompci = (uintfptr_t)bintr2 - p->lowpc; +#endif } #endif --- //depot/vendor/freebsd/src/sys/modules/Makefile 2004/04/27 11:04:28 +++ //depot/user/jhb/acpipci/modules/Makefile 2004/04/01 11:35:50 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/modules/Makefile,v 1.376 2004/04/27 17:57:45 vkashyap Exp $ +# $FreeBSD: src/sys/modules/Makefile,v 1.375 2004/03/29 22:41:21 peter Exp $ # pcic -- currently broken and being worked on out of tree. # oldcard -- specialized use for debugging only. @@ -203,7 +203,6 @@ ti \ tl \ trm \ - ${_twa} \ twe \ tx \ txp \ @@ -351,7 +350,6 @@ _ips= ips _mly= mly _s3= s3 -_twa= twa _vesa= vesa .elif ${MACHINE} == "pc98" _canbepm= canbepm --- //depot/vendor/freebsd/src/sys/modules/acpi/Makefile 2004/04/22 23:30:27 +++ //depot/user/jhb/acpipci/modules/acpi/Makefile 2004/03/10 13:15:05 @@ -1,5 +1,5 @@ -# $FreeBSD: src/sys/modules/acpi/Makefile,v 1.39 2004/04/23 06:29:08 philip Exp $ +# $FreeBSD: src/sys/modules/acpi/Makefile,v 1.38 2004/03/01 08:15:26 njl Exp $ -SUBDIR= acpi acpi_asus acpi_toshiba acpi_video +SUBDIR= acpi acpi_toshiba acpi_video .include --- //depot/vendor/freebsd/src/sys/modules/acpi/acpi/Makefile 2004/04/20 19:21:08 +++ //depot/user/jhb/acpipci/modules/acpi/acpi/Makefile 2004/03/10 13:15:05 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/modules/acpi/acpi/Makefile,v 1.5 2004/04/21 02:16:07 njl Exp $ +# $FreeBSD: src/sys/modules/acpi/acpi/Makefile,v 1.4 2004/02/28 19:51:44 njl Exp $ .PATH: ${.CURDIR}/../../../contrib/dev/acpica \ ${.CURDIR}/../../../pci \ @@ -33,17 +33,12 @@ SRCS+= utglobal.c utinit.c utmath.c utmisc.c utobject.c SRCS+= utxface.c -# OSPM layer and core hardware drivers -SRCS+= acpi.c acpi_button.c acpi_isab.c +# OSD layer +SRCS+= acpi.c acpi_acad.c acpi_battery.c acpi_button.c acpi_cmbat.c acpi_cpu.c +SRCS+= acpi_ec.c acpi_isab.c acpi_lid.c SRCS+= acpi_package.c acpi_pci.c acpi_pcib.c acpi_pcib_acpi.c -SRCS+= acpi_pcib_pci.c acpi_powerres.c acpi_resource.c -SRCS+= acpi_timer.c acpi_pci_link.c acpi_thermal.c - -# ACPI hardware drivers, mostly used for mobile systems. -SRCS+= acpi_acad.c acpi_battery.c acpi_cmbat.c acpi_cpu.c -SRCS+= acpi_ec.c acpi_lid.c - -# OSD layer +SRCS+= acpi_pcib_pci.c acpi_powerres.c acpi_resource.c acpi_thermal.c +SRCS+= acpi_timer.c acpi_pci_link.c SRCS+= OsdDebug.c SRCS+= OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c SRCS+= OsdStream.c OsdSynch.c OsdTable.c OsdEnvironment.c --- //depot/vendor/freebsd/src/sys/modules/asr/Makefile 2004/04/21 19:25:31 +++ //depot/user/jhb/acpipci/modules/asr/Makefile 2002/08/02 16:33:14 @@ -1,10 +1,10 @@ -# $FreeBSD: src/sys/modules/asr/Makefile,v 1.4 2004/04/22 02:22:17 njl Exp $ +# $FreeBSD: src/sys/modules/asr/Makefile,v 1.3 2001/04/01 08:33:01 scottl Exp $ .PATH: ${.CURDIR}/../../dev/asr KMOD= asr SRCS= asr.c -SRCS+= opt_scsi.h opt_cam.h +SRCS+= opt_scsi.h opt_cam.h opt_asr.h SRCS+= device_if.h bus_if.h pci_if.h .if ${MACHINE_ARCH} == "alpha" --- //depot/vendor/freebsd/src/sys/modules/ipfilter/Makefile 2004/04/20 07:11:54 +++ //depot/user/jhb/acpipci/modules/ipfilter/Makefile 2003/10/23 14:00:40 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/modules/ipfilter/Makefile,v 1.13 2004/04/20 14:06:42 darrenr Exp $ +# $FreeBSD: src/sys/modules/ipfilter/Makefile,v 1.12 2003/09/23 17:55:04 sam Exp $ .PATH: ${.CURDIR}/../../contrib/ipfilter/netinet @@ -6,11 +6,9 @@ SRCS= mlfk_ipl.c ip_nat.c ip_frag.c ip_state.c ip_proxy.c ip_auth.c \ ip_log.c ip_fil.c fil.c -CFLAGS+= -DUSE_INET6 CFLAGS+= -I${.CURDIR}/../../contrib/ipfilter CFLAGS+= -DIPFILTER=1 -DIPFILTER_LKM -DIPFILTER_LOG -DPFIL_HOOKS # -# If you don't want IPv6 functionality remove -DUSE_INET6 # If you don't want log functionality remove -DIPFILTER_LOG # --- //depot/vendor/freebsd/src/sys/modules/netgraph/Makefile 2004/04/25 02:00:56 +++ //depot/user/jhb/acpipci/modules/netgraph/Makefile 2004/04/19 12:55:20 @@ -1,5 +1,5 @@ # $Whistle: Makefile,v 1.5 1999/01/24 06:48:37 archie Exp $ -# $FreeBSD: src/sys/modules/netgraph/Makefile,v 1.34 2004/04/25 08:56:46 rik Exp $ +# $FreeBSD: src/sys/modules/netgraph/Makefile,v 1.33 2004/04/17 12:42:16 ru Exp $ SUBDIR= UI \ async \ @@ -32,7 +32,6 @@ rfc1490 \ socket \ split \ - sppp \ sync_ar \ sync_sr \ tee \ --- //depot/vendor/freebsd/src/sys/net/bridge.c 2004/04/24 15:15:35 +++ //depot/user/jhb/acpipci/net/bridge.c 2004/03/10 13:15:05 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/net/bridge.c,v 1.77 2004/04/24 22:11:13 luigi Exp $ + * $FreeBSD: src/sys/net/bridge.c,v 1.76 2004/02/25 19:55:27 mlaier Exp $ */ /* @@ -99,16 +99,15 @@ #include #include -#include #include -#include /* for struct arpcom */ #include #include -#include +#include /* for struct arpcom */ #include #include #include +#include /* for struct arpcom */ #ifdef PFIL_HOOKS #include @@ -300,7 +299,7 @@ * updating pointers in ifp2sc. */ static struct cluster_softc * -add_cluster(u_int16_t cluster_id, struct ifnet *ifp) +add_cluster(u_int16_t cluster_id, struct arpcom *ac) { struct cluster_softc *c = NULL; int i; @@ -354,7 +353,7 @@ n_clusters++; found: c = clusters + i; /* the right cluster ... */ - ETHER_ADDR_COPY(c->my_macs[c->ports].etheraddr, IFP2AC(ifp)->ac_enaddr); + ETHER_ADDR_COPY(c->my_macs[c->ports].etheraddr, ac->ac_enaddr); c->ports++; return c; bad: @@ -533,7 +532,7 @@ printf("%s already used, skipping\n", ifp->if_xname); break; } - b->cluster = add_cluster(htons(cluster), ifp); + b->cluster = add_cluster(htons(cluster), (struct arpcom *)ifp); b->flags |= IFF_USED ; snprintf(bdg_stats.s[ifp->if_index].name, sizeof(bdg_stats.s[ifp->if_index].name), --- //depot/vendor/freebsd/src/sys/net/if.c 2004/04/24 15:25:43 +++ //depot/user/jhb/acpipci/net/if.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)if.c 8.5 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/net/if.c,v 1.191 2004/04/24 22:24:48 luigi Exp $ + * $FreeBSD: src/sys/net/if.c,v 1.190 2004/04/19 17:28:15 luigi Exp $ */ #include "opt_compat.h" @@ -319,7 +319,7 @@ case IFT_ISO88025: case IFT_L2VLAN: snprintf(eaddr, 18, "%6D", - IFP2AC(ifp)->ac_enaddr, ":"); + ((struct arpcom *)ifp->if_softc)->ac_enaddr, ":"); break; default: eaddr[0] = '\0'; @@ -1979,7 +1979,7 @@ case IFT_XETHER: case IFT_ISO88025: case IFT_L2VLAN: - bcopy(lladdr, IFP2AC(ifp)->ac_enaddr, len); + bcopy(lladdr, ((struct arpcom *)ifp->if_softc)->ac_enaddr, len); /* * XXX We also need to store the lladdr in LLADDR(sdl), * which is done below. This is a pain because we must --- //depot/vendor/freebsd/src/sys/net/if_arcsubr.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/net/if_arcsubr.c 2004/04/16 11:09:59 @@ -1,5 +1,5 @@ /* $NetBSD: if_arcsubr.c,v 1.36 2001/06/14 05:44:23 itojun Exp $ */ -/* $FreeBSD: src/sys/net/if_arcsubr.c,v 1.20 2004/04/25 09:24:51 luigi Exp $ */ +/* $FreeBSD: src/sys/net/if_arcsubr.c,v 1.19 2004/04/04 11:52:09 luigi Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -107,6 +107,8 @@ struct sockaddr *dst; struct rtentry *rt0; { + struct rtentry *rt; + struct arccom *ac; struct arc_header *ah; int error; u_int8_t atype, adst; @@ -117,7 +119,12 @@ return(ENETDOWN); /* m, m1 aren't initialized yet */ error = 0; + ac = (struct arccom *)ifp; + error = rt_check(&rt, &rt0, dst); + if (error) + goto bad; + switch (dst->sa_family) { #ifdef INET case AF_INET: @@ -129,11 +136,8 @@ adst = arcbroadcastaddr; /* ARCnet broadcast address */ else if (ifp->if_flags & IFF_NOARP) adst = ntohl(SIN(dst)->sin_addr.s_addr) & 0xFF; - else { - error = arpresolve(ifp, rt0, m, dst, &adst); - if (error) - return (error == EWOULDBLOCK ? 0 : error); - } + else if (!arpresolve(ifp, rt, m, dst, &adst)) + return 0; /* not resolved yet */ atype = (ifp->if_flags & IFF_LINK0) ? ARCTYPE_IP_OLD : ARCTYPE_IP; @@ -168,9 +172,13 @@ #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)&adst); - if (error) - return (error); +#ifdef OLDIP6OUTPUT + if (!nd6_resolve(ifp, rt, m, dst, (u_char *)&adst)) + return(0); /* if not yet resolves */ +#else + if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)&adst)) + return(0); /* it must be impossible, but... */ +#endif /* OLDIP6OUTPUT */ atype = ARCTYPE_INET6; break; #endif --- //depot/vendor/freebsd/src/sys/net/if_atmsubr.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/net/if_atmsubr.c 2004/01/13 14:03:34 @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/net/if_atmsubr.c,v 1.35 2004/04/25 09:24:51 luigi Exp $"); +__FBSDID("$FreeBSD: src/sys/net/if_atmsubr.c,v 1.34 2004/01/09 11:25:14 harti Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -126,6 +126,7 @@ int error = 0, sz; struct atm_pseudohdr atmdst, *ad; struct mbuf *m = m0; + struct rtentry *rt; struct atmllc *atmllc; struct atmllc *llc_hdr = NULL; u_int32_t atm_flags; @@ -140,6 +141,13 @@ senderr(ENETDOWN); /* + * check route + */ + error = rt_check(&rt, &rt0, dst); + if (error) + goto bad; + + /* * check for non-native ATM traffic (dst != NULL) */ if (dst) { @@ -148,15 +156,6 @@ #if defined(INET) || defined(INET6) case AF_INET: case AF_INET6: - { - struct rtentry *rt; - /* - * check route - */ - error = rt_check(&rt, &rt0, dst); - if (error) - goto bad; - if (dst->sa_family == AF_INET6) etype = ETHERTYPE_IPV6; else @@ -168,7 +167,6 @@ /* XXX: put ATMARP stuff here */ /* XXX: watch who frees m on failure */ } - } break; #endif /* INET || INET6 */ --- //depot/vendor/freebsd/src/sys/net/if_ethersubr.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/net/if_ethersubr.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.169 2004/04/25 09:24:51 luigi Exp $ + * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.167 2004/04/18 11:01:15 luigi Exp $ */ #include "opt_atalk.h" @@ -132,11 +132,13 @@ struct sockaddr *dst, struct rtentry *rt0) { short type; - int error, hdrcmplt = 0; + int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; + struct rtentry *rt; struct ether_header *eh; int loop_copy = 0; int hlen; /* link layer header length */ + struct arpcom *ac = IFP2AC(ifp); #ifdef MAC error = mac_check_ifnet_transmit(ifp, m); @@ -149,13 +151,16 @@ if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); + error = rt_check(&rt, &rt0, dst); + if (error) + goto bad; + hlen = ETHER_HDR_LEN; switch (dst->sa_family) { #ifdef INET case AF_INET: - error = arpresolve(ifp, rt0, m, dst, edst); - if (error) - return (error == EWOULDBLOCK ? 0 : error); + if (!arpresolve(ifp, rt, m, dst, edst)) + return (0); /* if not yet resolved */ type = htons(ETHERTYPE_IP); break; case AF_ARP: @@ -188,9 +193,10 @@ #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst); - if (error) - return error; + if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) { + /* Something bad happened */ + return(0); + } type = htons(ETHERTYPE_IPV6); break; #endif @@ -211,12 +217,15 @@ { struct at_ifaddr *aa; - if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) - senderr(EHOSTUNREACH); /* XXX */ - if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst)) + if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) { + goto bad; + } + if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) return (0); /* * In the phase 2 case, need to prepend an mbuf for the llc header. + * Since we must preserve the value of m, which is passed to us by + * value, we m_copy() the first mbuf, and use it for our llc header. */ if ( aa->aa_flags & AFA_PHASE2 ) { struct llc llc; @@ -271,7 +280,7 @@ (void)memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost)); else - (void)memcpy(eh->ether_shost, IFP2AC(ifp)->ac_enaddr, + (void)memcpy(eh->ether_shost, ac->ac_enaddr, sizeof(eh->ether_shost)); /* --- //depot/vendor/freebsd/src/sys/net/if_fddisubr.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/net/if_fddisubr.c 2004/04/19 12:55:20 @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp - * $FreeBSD: src/sys/net/if_fddisubr.c,v 1.94 2004/04/25 09:24:51 luigi Exp $ + * $FreeBSD: src/sys/net/if_fddisubr.c,v 1.92 2004/04/18 11:01:15 luigi Exp $ */ #include "opt_atalk.h" @@ -117,7 +117,9 @@ u_int16_t type; int loop_copy = 0, error = 0, hdrcmplt = 0; u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; + struct rtentry *rt; struct fddi_header *fh; + struct arpcom *ac = IFP2AC(ifp); #ifdef MAC error = mac_check_ifnet_transmit(ifp, m); @@ -131,12 +133,15 @@ senderr(ENETDOWN); getmicrotime(&ifp->if_lastchange); + error = rt_check(&rt, &rt0, dst); + if (error) + goto bad; + switch (dst->sa_family) { #ifdef INET case AF_INET: { - error = arpresolve(ifp, rt0, m, dst, edst); - if (error) - return (error == EWOULDBLOCK ? 0 : error); + if (!arpresolve(ifp, rt, m, dst, edst)) + return (0); /* if not yet resolved */ type = htons(ETHERTYPE_IP); break; } @@ -170,9 +175,10 @@ #endif /* INET */ #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst); - if (error) - return (error); /* Something bad happened */ + if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) { + /* Something bad happened */ + return (0); + } type = htons(ETHERTYPE_IPV6); break; #endif /* INET6 */ @@ -186,7 +192,7 @@ #ifdef NETATALK case AF_APPLETALK: { struct at_ifaddr *aa; - if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst)) + if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) return (0); /* * ifaddr is the first thing in at_ifaddr @@ -308,7 +314,7 @@ if (hdrcmplt) bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN); else - bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_shost, + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN); /* --- //depot/vendor/freebsd/src/sys/net/if_gre.c 2004/04/23 10:00:52 +++ //depot/user/jhb/acpipci/net/if_gre.c 2004/03/26 08:52:16 @@ -359,7 +359,7 @@ goto end; } - if (m == NULL) { /* mbuf allocation failed */ + if (m == NULL) { /* impossible */ _IF_DROP(&ifp->if_snd); error = ENOBUFS; goto end; @@ -385,12 +385,8 @@ ifp->if_opackets++; ifp->if_obytes += m->m_pkthdr.len; - /* - * Send it off and with IP_FORWARD flag to prevent it from - * overwriting the ip_id again. ip_id is already set to the - * ip_id of the encapsulated packet. - */ - error = ip_output(m, NULL, &sc->route, IP_FORWARDING, + /* send it off */ + error = ip_output(m, NULL, &sc->route, 0, (struct ip_moptions *)NULL, (struct inpcb *)NULL); end: sc->called = 0; --- //depot/vendor/freebsd/src/sys/net/if_iso88025subr.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/net/if_iso88025subr.c 2004/04/19 12:55:20 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/net/if_iso88025subr.c,v 1.64 2004/04/25 09:24:51 luigi Exp $ + * $FreeBSD: src/sys/net/if_iso88025subr.c,v 1.62 2004/04/18 01:15:32 luigi Exp $ * */ @@ -246,6 +246,7 @@ struct iso88025_header gen_th; struct sockaddr_dl *sdl = NULL; struct rtentry *rt; + struct arpcom *ac = IFP2AC(ifp); #ifdef MAC error = mac_check_ifnet_transmit(ifp, m); @@ -259,12 +260,11 @@ senderr(ENETDOWN); getmicrotime(&ifp->if_lastchange); - /* Calculate routing info length based on arp table entry */ - /* XXX any better way to do this ? */ error = rt_check(&rt, &rt0, dst); if (error) goto bad; + /* Calculate routing info length based on arp table entry */ if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway)) if (SDL_ISO88025(sdl)->trld_rcf != 0) rif_len = TR_RCF_RIFLEN(SDL_ISO88025(sdl)->trld_rcf); @@ -272,7 +272,7 @@ /* Generate a generic 802.5 header for the packet */ gen_th.ac = TR_AC; gen_th.fc = TR_LLC_FRAME; - (void)memcpy((caddr_t)gen_th.iso88025_shost, IFP2AC(ifp)->ac_enaddr, + (void)memcpy((caddr_t)gen_th.iso88025_shost, (caddr_t)ac->ac_enaddr, ISO88025_ADDR_LEN); if (rif_len) { gen_th.iso88025_shost[0] |= TR_RII; @@ -287,9 +287,8 @@ switch (dst->sa_family) { #ifdef INET case AF_INET: - error = arpresolve(ifp, rt0, m, dst, edst); - if (error) - return (error == EWOULDBLOCK ? 0 : error); + if (!arpresolve(ifp, rt, m, dst, edst)) + return (0); /* if not yet resolved */ snap_type = ETHERTYPE_IP; break; case AF_ARP: @@ -322,9 +321,10 @@ #endif /* INET */ #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst); - if (error) - return (error); + if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) { + /* Something bad happened */ + return(0); + } snap_type = ETHERTYPE_IPV6; break; #endif /* INET6 */ --- //depot/vendor/freebsd/src/sys/net/if_vlan.c 2004/04/24 15:25:43 +++ //depot/user/jhb/acpipci/net/if_vlan.c 2004/01/06 10:27:15 @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/net/if_vlan.c,v 1.58 2004/04/24 22:24:48 luigi Exp $ + * $FreeBSD: src/sys/net/if_vlan.c,v 1.57 2004/01/03 03:33:39 sam Exp $ */ /* @@ -691,7 +691,7 @@ struct sockaddr *sa; sa = (struct sockaddr *) &ifr->ifr_data; - bcopy(IFP2AC(ifp)->ac_enaddr, + bcopy(((struct arpcom *)ifp->if_softc)->ac_enaddr, (caddr_t) sa->sa_data, ETHER_ADDR_LEN); } break; --- //depot/vendor/freebsd/src/sys/net/radix.c 2004/04/21 08:31:31 +++ //depot/user/jhb/acpipci/net/radix.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)radix.c 8.5 (Berkeley) 5/19/95 - * $FreeBSD: src/sys/net/radix.c,v 1.36 2004/04/21 15:27:36 luigi Exp $ + * $FreeBSD: src/sys/net/radix.c,v 1.35 2004/04/19 17:28:39 luigi Exp $ */ /* @@ -119,31 +119,6 @@ * that governs a subtree. */ -/* - * Most of the functions in this code assume that the key/mask arguments - * are sockaddr-like structures, where the first byte is an u_char - * indicating the size of the entire structure. - * - * To make the assumption more explicit, we use the LEN() macro to access - * this field. It is safe to pass an expression with side effects - * to LEN() as the argument is evaluated only once. - */ -#define LEN(x) (*(const u_char *)(x)) - -/* - * XXX THIS NEEDS TO BE FIXED - * In the code, pointers to keys and masks are passed as either - * 'void *' (because callers use to pass pointers of various kinds), or - * 'caddr_t' (which is fine for pointer arithmetics, but not very - * clean when you dereference it to access data). Furthermore, caddr_t - * is really 'char *', while the natural type to operate on keys and - * masks would be 'u_char'. This mismatch require a lot of casts and - * intermediate variables to adapt types that clutter the code. - */ - -/* - * Search a node in the tree matching the key. - */ static struct radix_node * rn_search(v_arg, head) void *v_arg; @@ -161,10 +136,6 @@ return (x); } -/* - * Same as above, but with an additional mask. - * XXX note this function is used only once. - */ static struct radix_node * rn_search_m(v_arg, head, m_arg) struct radix_node *head; @@ -188,8 +159,8 @@ void *m_arg, *n_arg; { register caddr_t m = m_arg, n = n_arg; - register caddr_t lim, lim2 = lim = n + LEN(n); - int longer = LEN(n++) - (int)LEN(m++); + register caddr_t lim, lim2 = lim = n + *(u_char *)n; + int longer = (*(u_char *)n++) - (int)(*(u_char *)m++); int masks_are_equal = 1; if (longer > 0) @@ -240,7 +211,7 @@ { register char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask; char *cplim; - int length = min(LEN(cp), LEN(cp2)); + int length = min(*(u_char *)cp, *(u_char *)cp2); if (cp3 == 0) cp3 = rn_ones; @@ -263,7 +234,7 @@ register caddr_t cp = v, cp2; caddr_t cplim; struct radix_node *saved_t, *top = t; - int off = t->rn_offset, vlen = LEN(cp), matched_off; + int off = t->rn_offset, vlen = *(u_char *)cp, matched_off; register int test, b, rn_bit; /* @@ -363,17 +334,6 @@ int rn_debug = 1; #endif -/* - * Whenever we add a new leaf to the tree, we also add a parent node, - * so we allocate them as an array of two elements: the first one must be - * the leaf (see RNTORT() in route.c), the second one is the parent. - * This routine initializes the relevant fields of the nodes, so that - * the leaf is the left child of the parent node, and both nodes have - * (almost) all all fields filled as appropriate. - * (XXX some fields are left unset, see the '#if 0' section). - * The function returns a pointer to the parent node. - */ - static struct radix_node * rn_newpair(v, b, nodes) void *v; @@ -385,14 +345,6 @@ t->rn_bmask = 0x80 >> (b & 7); t->rn_left = tt; t->rn_offset = b >> 3; - -#if 0 /* XXX perhaps we should fill these fields as well. */ - t->rn_parent = t->rn_right = NULL; - - tt->rn_mask = NULL; - tt->rn_dupedkey = NULL; - tt->rn_bmask = 0; -#endif tt->rn_bit = -1; tt->rn_key = (caddr_t)v; tt->rn_parent = t; @@ -416,7 +368,7 @@ { caddr_t v = v_arg; struct radix_node *top = head->rnh_treetop; - int head_off = top->rn_offset, vlen = (int)LEN(v); + int head_off = top->rn_offset, vlen = (int)*((u_char *)v); register struct radix_node *t = rn_search(v_arg, top); register caddr_t cp = v + head_off; register int b; @@ -490,7 +442,7 @@ struct radix_node *saved_x; static int last_zeroed = 0; - if ((mlen = LEN(netmask)) > max_keylen) + if ((mlen = *(u_char *)netmask) > max_keylen) mlen = max_keylen; if (skip == 0) skip = 1; @@ -563,10 +515,10 @@ { register u_char *mp = m_arg, *np = n_arg, *lim; - if (LEN(mp) > LEN(np)) + if (*mp > *np) return 1; /* not really, but need to check longer one first */ - if (LEN(mp) == LEN(np)) - for (lim = mp + LEN(mp); mp < lim;) + if (*mp == *np) + for (lim = mp + *mp; mp < lim;) if (*mp++ > *np++) return 1; return 0; @@ -770,7 +722,7 @@ x = head->rnh_treetop; tt = rn_search(v, x); head_off = x->rn_offset; - vlen = LEN(v); + vlen = *(u_char *)v; saved_tt = tt; top = x; if (tt == 0 || @@ -959,8 +911,7 @@ int lastb; /* - * rn_search_m is sort-of-open-coded here. We cannot use the - * function because we need to keep track of the last node seen. + * rn_search_m is sort-of-open-coded here. */ /* printf("about to search\n"); */ for (rn = h->rnh_treetop; rn->rn_bit >= 0; ) { @@ -1009,13 +960,6 @@ if (rn->rn_bit < lastb) { stopping = 1; /* printf("up too far\n"); */ - /* - * XXX we should jump to the 'Process leaves' - * part, because the values of 'rn' and 'next' - * we compute will not be used. Not a big deal - * because this loop will terminate, but it is - * inefficient and hard to understand! - */ } } @@ -1083,14 +1027,6 @@ /* NOTREACHED */ } -/* - * Allocate and initialize an empty tree. This has 3 nodes, which are - * part of the radix_node_head (in the order ) and are - * marked RNF_ROOT so they cannot be freed. - * The leaves have all-zero and all-one keys, with significant - * bits starting at 'off'. - * Return 1 on success, 0 on error. - */ int rn_inithead(head, off) void **head; @@ -1111,7 +1047,7 @@ ttt = rnh->rnh_nodes + 2; t->rn_right = ttt; t->rn_parent = t; - tt = t->rn_left; /* ... which in turn is rnh->rnh_nodes */ + tt = t->rn_left; tt->rn_flags = t->rn_flags = RNF_ROOT | RNF_ACTIVE; tt->rn_bit = -1 - off; *ttt = *tt; --- //depot/vendor/freebsd/src/sys/net/route.c 2004/04/24 18:40:36 +++ //depot/user/jhb/acpipci/net/route.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)route.c 8.3.1.1 (Berkeley) 2/23/95 - * $FreeBSD: src/sys/net/route.c,v 1.104 2004/04/25 01:39:00 luigi Exp $ + * $FreeBSD: src/sys/net/route.c,v 1.100 2004/04/18 11:46:29 luigi Exp $ */ #include "opt_inet.h" @@ -47,6 +47,8 @@ #include #include +#define SA(p) ((struct sockaddr *)(p)) + static struct rtstat rtstat; struct radix_node_head *rt_tables[AF_MAX+1]; @@ -56,21 +58,6 @@ struct sockaddr *, struct sockaddr *); static void rtable_init(void **); -/* compare two sockaddr structures */ -#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) - -/* - * Convert a 'struct radix_node *' to a 'struct rtentry *'. - * The operation can be done safely (in this code) because a - * 'struct rtentry' starts with two 'struct radix_node''s, the first - * one representing leaf nodes in the routing tree, which is - * what the code in radix.c passes us as a 'struct radix_node'. - * - * But because there are a lot of assumptions in this conversion, - * do not cast explicitly, but always use the macro below. - */ -#define RNTORT(p) ((struct rtentry *)(p)) - static void rtable_init(void **table) { @@ -130,7 +117,7 @@ u_long nflags; int err = 0, msgtype = RTM_MISS; - newrt = NULL; + newrt = 0; bzero(&info, sizeof(info)); /* * Look up the address in the table for that Address Family @@ -146,7 +133,7 @@ * If we find it and it's not the root node, then * get a refernce on the rtentry associated. */ - newrt = rt = RNTORT(rn); + newrt = rt = (struct rtentry *)rn; nflags = rt->rt_flags & ~ignflags; if (report && (nflags & RTF_CLONING)) { /* @@ -154,8 +141,8 @@ * If it requires that it be cloned, do so. * (This implies it wasn't a HOST route.) */ - err = rtrequest(RTM_RESOLVE, dst, NULL, - NULL, 0, &newrt); + err = rtrequest(RTM_RESOLVE, dst, SA(0), + SA(0), 0, &newrt); if (err) { /* * If the cloning didn't succeed, maybe @@ -223,14 +210,13 @@ void rtfree(struct rtentry *rt) { - struct radix_node_head *rnh; + /* + * find the tree for that address family + */ + struct radix_node_head *rnh = rt_tables[rt_key(rt)->sa_family]; - /* XXX the NULL checks are probably useless */ - if (rt == NULL) - panic("rtfree: NULL rt"); - rnh = rt_tables[rt_key(rt)->sa_family]; - if (rnh == NULL) - panic("rtfree: NULL rnh"); + if (rt == 0 || rnh == 0) + panic("rtfree"); RT_LOCK_ASSERT(rt); @@ -299,6 +285,8 @@ RT_UNLOCK(rt); } +/* compare two sockaddr structures */ +#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) /* * Force a routing table entry to the specified @@ -315,12 +303,12 @@ { struct rtentry *rt; int error = 0; - short *stat = NULL; + short *stat = 0; struct rt_addrinfo info; struct ifaddr *ifa; /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet(gateway)) == NULL) { + if ((ifa = ifa_ifwithnet(gateway)) == 0) { error = ENETUNREACH; goto out; } @@ -344,7 +332,7 @@ * which use routing redirects generated by smart gateways * to dynamically build the routing tables. */ - if (rt == NULL || (rt_mask(rt) && rt_mask(rt)->sa_len < 2)) + if (rt == 0 || (rt_mask(rt) && rt_mask(rt)->sa_len < 2)) goto create; /* * Don't listen to the redirect if it's @@ -431,10 +419,11 @@ * as our clue to the interface. Otherwise * we can use the local address. */ - ifa = NULL; - if (flags & RTF_HOST) + ifa = 0; + if (flags & RTF_HOST) { ifa = ifa_ifwithdstaddr(dst); - if (ifa == NULL) + } + if (ifa == 0) ifa = ifa_ifwithaddr(gateway); } else { /* @@ -444,28 +433,28 @@ */ ifa = ifa_ifwithdstaddr(gateway); } - if (ifa == NULL) + if (ifa == 0) ifa = ifa_ifwithnet(gateway); - if (ifa == NULL) { + if (ifa == 0) { struct rtentry *rt = rtalloc1(gateway, 0, 0UL); - if (rt == NULL) - return (NULL); + if (rt == 0) + return (0); RT_REMREF(rt); RT_UNLOCK(rt); - if ((ifa = rt->rt_ifa) == NULL) - return (NULL); + if ((ifa = rt->rt_ifa) == 0) + return (0); } if (ifa->ifa_addr->sa_family != dst->sa_family) { struct ifaddr *oifa = ifa; ifa = ifaof_ifpforaddr(dst, ifa->ifa_ifp); - if (ifa == NULL) + if (ifa == 0) ifa = oifa; } return (ifa); } -static walktree_f_t rt_fixdelete; -static walktree_f_t rt_fixchange; +static int rt_fixdelete(struct radix_node *, void *); +static int rt_fixchange(struct radix_node *, void *); struct rtfc_arg { struct rtentry *rt0; @@ -566,7 +555,7 @@ * Find the correct routing tree to use for this Address Family */ rnh = rt_tables[rt_key(rt)->sa_family]; - if (rnh == NULL) + if (rnh == 0) return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK(rnh); @@ -576,13 +565,13 @@ * but when callers invoke us blindly it may not (sigh). */ rn = rnh->rnh_deladdr(rt_key(rt), rt_mask(rt), rnh); - if (rn == NULL) { + if (rn == 0) { error = ESRCH; goto bad; } KASSERT((rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) == 0, ("unexpected flags 0x%x", rn->rn_flags)); - KASSERT(rt == RNTORT(rn), + KASSERT(rt == (struct rtentry *)rn, ("lookup mismatch, rt %p rn %p", rt, rn)); rt->rt_flags &= ~RTF_UP; @@ -601,8 +590,9 @@ * we held its last reference. */ if (rt->rt_gwroute) { - RTFREE(rt->rt_gwroute); - rt->rt_gwroute = NULL; + struct rtentry *gwrt = rt->rt_gwroute; + RTFREE(gwrt); + rt->rt_gwroute = 0; } /* @@ -644,7 +634,7 @@ * Find the correct routing tree to use for this Address Family */ rnh = rt_tables[dst->sa_family]; - if (rnh == NULL) + if (rnh == 0) return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK(rnh); /* @@ -652,7 +642,7 @@ * a netmask in the tree, nor do we want to clone it. */ if (flags & RTF_HOST) { - netmask = NULL; + netmask = 0; flags &= ~RTF_CLONING; } switch (req) { @@ -662,11 +652,11 @@ * Complain if it is not there and do no more processing. */ rn = rnh->rnh_deladdr(dst, netmask, rnh); - if (rn == NULL) + if (rn == 0) senderr(ESRCH); if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) panic ("rtrequest delete"); - rt = RNTORT(rn); + rt = (struct rtentry *)rn; RT_LOCK(rt); RT_ADDREF(rt); rt->rt_flags &= ~RTF_UP; @@ -687,8 +677,9 @@ * we held its last reference. */ if (rt->rt_gwroute) { - RTFREE(rt->rt_gwroute); - rt->rt_gwroute = NULL; + struct rtentry *gwrt = rt->rt_gwroute; + RTFREE(gwrt); + rt->rt_gwroute = 0; } /* @@ -698,9 +689,8 @@ ifa->ifa_rtrequest(RTM_DELETE, rt, info); /* - * One more rtentry floating around that is not - * linked to the routing table. rttrash will be decremented - * when RTFREE(rt) is eventually called. + * one more rtentry floating around that is not + * linked to the routing table. */ rttrash++; @@ -717,7 +707,7 @@ break; case RTM_RESOLVE: - if (ret_nrt == NULL || (rt = *ret_nrt) == NULL) + if (ret_nrt == 0 || (rt = *ret_nrt) == 0) senderr(EINVAL); ifa = rt->rt_ifa; /* XXX locking? */ @@ -725,7 +715,7 @@ ~(RTF_CLONING | RTF_STATIC); flags |= RTF_WASCLONED; gateway = rt->rt_gateway; - if ((netmask = rt->rt_genmask) == NULL) + if ((netmask = rt->rt_genmask) == 0) flags |= RTF_HOST; goto makeroute; @@ -739,7 +729,7 @@ makeroute: R_Zalloc(rt, struct rtentry *, sizeof(*rt)); - if (rt == NULL) + if (rt == 0) senderr(ENOBUFS); RT_LOCK_INIT(rt); rt->rt_flags = RTF_UP | flags; @@ -778,7 +768,7 @@ /* XXX mtu manipulation will be done in rnh_addaddr -- itojun */ rn = rnh->rnh_addaddr(ndst, netmask, rnh, rt->rt_nodes); - if (rn == NULL) { + if (rn == 0) { struct rtentry *rt2; /* * Uh-oh, we already have one of these in the tree. @@ -803,7 +793,7 @@ * If it still failed to go into the tree, * then un-make it (this should be a function) */ - if (rn == NULL) { + if (rn == 0) { if (rt->rt_gwroute) RTFREE(rt->rt_gwroute); if (rt->rt_ifa) @@ -814,7 +804,7 @@ senderr(EEXIST); } - rt->rt_parent = NULL; + rt->rt_parent = 0; /* * If we got here from RESOLVE, then we are cloning @@ -854,7 +844,7 @@ * hasn't been added to the tree yet. */ if (req == RTM_ADD && - !(rt->rt_flags & RTF_HOST) && rt_mask(rt) != NULL) { + !(rt->rt_flags & RTF_HOST) && rt_mask(rt) != 0) { struct rtfc_arg arg; arg.rnh = rnh; arg.rt0 = rt; @@ -898,13 +888,14 @@ static int rt_fixdelete(struct radix_node *rn, void *vp) { - struct rtentry *rt = RNTORT(rn); + struct rtentry *rt = (struct rtentry *)rn; struct rtentry *rt0 = vp; if (rt->rt_parent == rt0 && !(rt->rt_flags & (RTF_PINNED | RTF_CLONING))) { - return rtrequest(RTM_DELETE, rt_key(rt), NULL, rt_mask(rt), - rt->rt_flags, NULL); + return rtrequest(RTM_DELETE, rt_key(rt), + (struct sockaddr *)0, rt_mask(rt), + rt->rt_flags, (struct rtentry **)0); } return 0; } @@ -922,24 +913,42 @@ * routine just for adds. I'm not sure why I thought it was necessary to do * changes this way. */ +#ifdef DEBUG +static int rtfcdebug = 0; +#endif static int rt_fixchange(struct radix_node *rn, void *vp) { - struct rtentry *rt = RNTORT(rn); + struct rtentry *rt = (struct rtentry *)rn; struct rtfc_arg *ap = vp; struct rtentry *rt0 = ap->rt0; struct radix_node_head *rnh = ap->rnh; u_char *xk1, *xm1, *xk2, *xmp; int i, len, mlen; - /* make sure we have a parent, and route is not pinned or cloning */ +#ifdef DEBUG + if (rtfcdebug) + printf("rt_fixchange: rt %p, rt0 %p\n", rt, rt0); +#endif + if (!rt->rt_parent || - (rt->rt_flags & (RTF_PINNED | RTF_CLONING))) + (rt->rt_flags & (RTF_PINNED | RTF_CLONING))) { +#ifdef DEBUG + if(rtfcdebug) printf("no parent, pinned or cloning\n"); +#endif return 0; + } - if (rt->rt_parent == rt0) /* parent match */ - goto delete_rt; + if (rt->rt_parent == rt0) { +#ifdef DEBUG + if(rtfcdebug) printf("parent match\n"); +#endif + return rtrequest(RTM_DELETE, rt_key(rt), + (struct sockaddr *)0, rt_mask(rt), + rt->rt_flags, (struct rtentry **)0); + } + /* * There probably is a function somewhere which does this... * if not, there should be. @@ -953,23 +962,43 @@ /* avoid applying a less specific route */ xmp = (u_char *)rt_mask(rt->rt_parent); mlen = rt_key(rt->rt_parent)->sa_len; - if (mlen > rt_key(rt0)->sa_len) /* less specific route */ + if (mlen > rt_key(rt0)->sa_len) { +#ifdef DEBUG + if (rtfcdebug) + printf("rt_fixchange: inserting a less " + "specific route\n"); +#endif return 0; - for (i = rnh->rnh_treetop->rn_offset; i < mlen; i++) - if ((xmp[i] & ~(xmp[i] ^ xm1[i])) != xmp[i]) - return 0; /* less specific route */ + } + for (i = rnh->rnh_treetop->rn_offset; i < mlen; i++) { + if ((xmp[i] & ~(xmp[i] ^ xm1[i])) != xmp[i]) { +#ifdef DEBUG + if (rtfcdebug) + printf("rt_fixchange: inserting a less " + "specific route\n"); +#endif + return 0; + } + } - for (i = rnh->rnh_treetop->rn_offset; i < len; i++) - if ((xk2[i] & xm1[i]) != xk1[i]) - return 0; /* no match */ + for (i = rnh->rnh_treetop->rn_offset; i < len; i++) { + if ((xk2[i] & xm1[i]) != xk1[i]) { +#ifdef DEBUG + if(rtfcdebug) printf("no match\n"); +#endif + return 0; + } + } /* * OK, this node is a clone, and matches the node currently being * changed/added under the node's mask. So, get rid of it. */ -delete_rt: - return rtrequest(RTM_DELETE, rt_key(rt), NULL, - rt_mask(rt), rt->rt_flags, NULL); +#ifdef DEBUG + if(rtfcdebug) printf("deleting\n"); +#endif + return rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, + rt_mask(rt), rt->rt_flags, (struct rtentry **)0); } int @@ -977,6 +1006,7 @@ { /* XXX dst may be overwritten, can we move this to below */ struct radix_node_head *rnh = rt_tables[dst->sa_family]; + caddr_t new, old; int dlen = SA_SIZE(dst), glen = SA_SIZE(gate); RT_LOCK_ASSERT(rt); @@ -1000,35 +1030,39 @@ } /* - * Prepare to store the gateway in rt->rt_gateway. - * Both dst and gateway are stored one after the other in the same - * malloc'd chunk. If we have room, we can reuse the old buffer, - * rt_gateway already points to the right place. - * Otherwise, malloc a new block and update the 'dst' address. + * Both dst and gateway are stored in the same malloc'd chunk + * (If I ever get my hands on....) + * if we need to malloc a new chunk, then keep the old one around + * till we don't need it any more. */ - if (rt->rt_gateway == NULL || glen > SA_SIZE(rt->rt_gateway)) { - caddr_t new; - + if (rt->rt_gateway == 0 || glen > SA_SIZE(rt->rt_gateway)) { + old = (caddr_t)rt_key(rt); R_Malloc(new, caddr_t, dlen + glen); - if (new == NULL) + if (new == 0) return ENOBUFS; + rt_key(rt) = new; + } else { /* - * XXX note, we copy from *dst and not *rt_key(rt) because - * rt_setgate() can be called to initialize a newly - * allocated route entry, in which case rt_key(rt) == NULL - * (and also rt->rt_gateway == NULL). - * Free()/free() handle a NULL argument just fine. + * otherwise just overwrite the old one */ - bcopy(dst, new, dlen); - Free(rt_key(rt)); /* free old block, if any */ - rt_key(rt) = new; - rt->rt_gateway = (struct sockaddr *)(new + dlen); + new = (caddr_t)rt_key(rt); + old = 0; } /* - * Copy the new gateway value into the memory chunk. + * copy the new gateway value into the memory chunk + */ + bcopy(gate, (rt->rt_gateway = (struct sockaddr *)(new + dlen)), glen); + + /* + * if we are replacing the chunk (or it's new) we need to + * replace the dst as well */ - bcopy(gate, rt->rt_gateway, glen); + if (old) { + bcopy(dst, new, dlen); + Free(old); + old = 0; + } /* * If there is already a gwroute, it's now almost definitly wrong @@ -1058,7 +1092,7 @@ rt->rt_gwroute = gwrt; if (rt->rt_gwroute == rt) { RTFREE_LOCKED(rt->rt_gwroute); - rt->rt_gwroute = NULL; + rt->rt_gwroute = 0; return EDQUOT; /* failure */ } if (rt->rt_gwroute != NULL) @@ -1114,8 +1148,8 @@ { struct sockaddr *dst; struct sockaddr *netmask; - struct mbuf *m = NULL; - struct rtentry *rt = NULL; + struct mbuf *m = 0; + struct rtentry *rt = 0; struct rt_addrinfo info; int error; @@ -1158,8 +1192,8 @@ RADIX_NODE_HEAD_LOCK(rnh); error = ((rn = rnh->rnh_lookup(dst, netmask, rnh)) == NULL || (rn->rn_flags & RNF_ROOT) || - RNTORT(rn)->rt_ifa != ifa || - !sa_equal((struct sockaddr *)rn->rn_key, dst)); + ((struct rtentry *)rn)->rt_ifa != ifa || + !sa_equal(SA(rn->rn_key), dst)); RADIX_NODE_HEAD_UNLOCK(rnh); if (error) { bad: @@ -1207,36 +1241,17 @@ } /* - * rt_check() is invoked on each layer 2 output path, prior to - * encapsulating outbound packets. - * - * The function is mostly used to find a routing entry for the gateway, - * which in some protocol families could also point to the link-level - * address for the gateway itself (the side effect of revalidating the - * route to the destination is rather pointless at this stage, we did it - * already a moment before in the pr_output() routine to locate the ifp - * and gateway to use). - * - * When we remove the layer-3 to layer-2 mapping tables from the - * routing table, this function can be removed. - * - * === On input === - * *dst is the address of the NEXT HOP (which coincides with the - * final destination if directly reachable); - * *lrt0 points to the cached route to the final destination; - * *lrt is not meaningful; - * - * === Operation === - * If the route is marked down try to find a new route. If the route + * Validate the route rt0 to the specified destination. If the + * route is marked down try to find a new route. If the route * to the gateway is gone, try to setup a new route. Otherwise, * if the route is marked for packets to be rejected, enforce that. * - * === On return === - * *dst is unchanged; - * *lrt0 points to the (possibly new) route to the final destination - * *lrt points to the route to the next hop + * On return lrt contains the route to the destination and lrt0 + * contains the route to the next hop. Their values are meaningul + * ONLY if no error is returned. * - * Their values are meaningful ONLY if no error is returned. + * This routine is invoked on each layer 2 output path, prior to + * encapsulating outbound packets. */ int rt_check(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst) @@ -1263,7 +1278,7 @@ } /* XXX BSD/OS checks dst->sa_family != AF_NS */ if (rt->rt_flags & RTF_GATEWAY) { - if (rt->rt_gwroute == NULL) + if (rt->rt_gwroute == 0) goto lookup; rt = rt->rt_gwroute; RT_LOCK(rt); /* NB: gwroute */ @@ -1275,7 +1290,7 @@ rt = rtalloc1(rt->rt_gateway, 1, 0UL); RT_LOCK(rt0); rt0->rt_gwroute = rt; - if (rt == NULL) { + if (rt == 0) { RT_UNLOCK(rt0); senderr(EHOSTUNREACH); } --- //depot/vendor/freebsd/src/sys/net/route.h 2004/04/24 16:35:38 +++ //depot/user/jhb/acpipci/net/route.h 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)route.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/net/route.h,v 1.60 2004/04/24 23:34:04 luigi Exp $ + * $FreeBSD: src/sys/net/route.h,v 1.58 2004/04/17 15:10:20 luigi Exp $ */ #ifndef _NET_ROUTE_H_ @@ -100,11 +100,6 @@ #endif struct rtentry { struct radix_node rt_nodes[2]; /* tree glue, and other values */ - /* - * XXX struct rtentry must begin with a struct radix_node (or two!) - * because the code does some casts of a 'struct radix_node *' - * to a 'struct rtentry *' - */ #define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key)) #define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask)) struct sockaddr *rt_gateway; /* value */ @@ -324,22 +319,10 @@ void rt_missmsg(int, struct rt_addrinfo *, int, int); void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); void rt_newmaddrmsg(int, struct ifmultiaddr *); +void rtalloc(struct route *); int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *); - -/* - * Note the following locking behavior: - * - * rtalloc_ign() and rtalloc() return ro->ro_rt unlocked - * - * rtalloc1() returns a locked rtentry - * - * rtfree() and RTFREE_LOCKED() require a locked rtentry - * - * RTFREE() uses an unlocked entry. - */ - -void rtalloc_ign(struct route *ro, u_long ignflags); -void rtalloc(struct route *ro); /* XXX deprecated, use rtalloc_ign(ro, 0) */ +void rtalloc_ign(struct route *, u_long); +/* NB: the rtentry is returned locked */ struct rtentry *rtalloc1(struct sockaddr *, int, u_long); int rtexpunge(struct rtentry *); void rtfree(struct rtentry *); --- //depot/vendor/freebsd/src/sys/net/rtsock.c 2004/04/26 12:50:50 +++ //depot/user/jhb/acpipci/net/rtsock.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 - * $FreeBSD: src/sys/net/rtsock.c,v 1.108 2004/04/26 19:46:52 bmilekic Exp $ + * $FreeBSD: src/sys/net/rtsock.c,v 1.107 2004/04/19 07:20:32 ru Exp $ */ #include @@ -48,8 +48,6 @@ #include #include -#include - MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); /* NB: these are not modified */ @@ -289,7 +287,6 @@ int len, error = 0; struct ifnet *ifp = NULL; struct ifaddr *ifa = NULL; - struct sockaddr_in jail; #define senderr(e) { error = e; goto flush;} if (m == NULL || ((m->m_len < sizeof(long)) && @@ -403,16 +400,8 @@ if (ifp) { info.rti_info[RTAX_IFP] = ifaddr_byindex(ifp->if_index)->ifa_addr; - if (jailed(so->so_cred)) { - jail.sin_family = PF_INET; - jail.sin_len = sizeof(jail); - jail.sin_addr.s_addr = - htonl(prison_getip(so->so_cred)); - info.rti_info[RTAX_IFA] = - (struct sockaddr *)&jail; - } else - info.rti_info[RTAX_IFA] = - rt->rt_ifa->ifa_addr; + info.rti_info[RTAX_IFA] = + rt->rt_ifa->ifa_addr; if (ifp->if_flags & IFF_POINTOPOINT) info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; --- //depot/vendor/freebsd/src/sys/netatalk/aarp.c 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/netatalk/aarp.c 2004/04/16 11:09:59 @@ -2,7 +2,7 @@ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * - * $FreeBSD: src/sys/netatalk/aarp.c,v 1.31 2004/04/25 09:24:51 luigi Exp $ + * $FreeBSD: src/sys/netatalk/aarp.c,v 1.30 2004/04/09 03:17:21 rwatson Exp $ */ #include "opt_atalk.h" @@ -29,7 +29,7 @@ #include static void aarptfree(struct aarptab *aat); -static void at_aarpinput(struct ifnet *ifp, struct mbuf *m); +static void at_aarpinput(struct arpcom *ac, struct mbuf *m); #define AARPTAB_BSIZ 9 #define AARPTAB_NB 19 @@ -130,7 +130,7 @@ } static void -aarpwhohas(struct ifnet *ifp, struct sockaddr_at *sat) +aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat) { struct mbuf *m; struct ether_header *eh; @@ -144,7 +144,7 @@ return; } #ifdef MAC - mac_create_mbuf_linklayer(ifp, m); + mac_create_mbuf_linklayer(&ac->ac_if, m); #endif m->m_len = sizeof(*ea); m->m_pkthdr.len = sizeof(*ea); @@ -158,7 +158,7 @@ ea->aarp_hln = sizeof(ea->aarp_sha); ea->aarp_pln = sizeof(ea->aarp_spu); ea->aarp_op = htons(AARPOP_REQUEST); - bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha, + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, sizeof(ea->aarp_sha)); /* @@ -195,7 +195,7 @@ ea->aarp_spnode = AA_SAT(aa)->sat_addr.s_node; ea->aarp_tpnode = sat->sat_addr.s_node; } else { - bcopy(ifp->if_broadcastaddr, (caddr_t)eh->ether_dhost, + bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost, sizeof(eh->ether_dhost)); eh->ether_type = htons(ETHERTYPE_AARP); @@ -211,12 +211,13 @@ sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; - ifp->if_output(ifp, m, &sa, NULL /* route */); + (*ac->ac_if.if_output)(&ac->ac_if, + m, &sa, NULL); /* XXX NULL should be routing information */ } int -aarpresolve(ifp, m, destsat, desten) - struct ifnet *ifp; +aarpresolve(ac, m, destsat, desten) + struct arpcom *ac; struct mbuf *m; struct sockaddr_at *destsat; u_char *desten; @@ -233,8 +234,8 @@ if (aa->aa_flags & AFA_PHASE2) { bcopy(atmulticastaddr, (caddr_t)desten, sizeof(atmulticastaddr)); } else { - bcopy(ifp->if_broadcastaddr, (caddr_t)desten, - sizeof(ifp->if_addrlen)); + bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)desten, + sizeof(ac->ac_if.if_addrlen)); } return (1); } @@ -243,10 +244,13 @@ AARPTAB_LOOK(aat, destsat->sat_addr); if (aat == NULL) { /* No entry */ aat = aarptnew(&destsat->sat_addr); - if (aat == NULL) { /* we should fail more gracefully! */ + if (aat == NULL) { panic("aarpresolve: no free entry"); } - goto done; + aat->aat_hold = m; + AARPTAB_UNLOCK(); + aarpwhohas(ac, destsat); + return (0); } /* found an entry */ aat->aat_timer = 0; @@ -260,10 +264,9 @@ if (aat->aat_hold) { m_freem(aat->aat_hold); } -done: aat->aat_hold = m; AARPTAB_UNLOCK(); - aarpwhohas(ifp, destsat); + aarpwhohas(ac, destsat); return (0); } @@ -272,10 +275,10 @@ struct mbuf *m; { struct arphdr *ar; - struct ifnet *ifp; + struct arpcom *ac; - ifp = m->m_pkthdr.rcvif; - if (ifp->if_flags & IFF_NOARP) + ac = (struct arpcom *)m->m_pkthdr.rcvif; + if (ac->ac_if.if_flags & IFF_NOARP) goto out; if (m->m_len < sizeof(struct arphdr)) { @@ -294,7 +297,7 @@ switch(ntohs(ar->ar_pro)) { case ETHERTYPE_AT : - at_aarpinput(ifp, m); + at_aarpinput(ac, m); return; default: @@ -306,7 +309,7 @@ } static void -at_aarpinput(struct ifnet *ifp, struct mbuf *m) +at_aarpinput(struct arpcom *ac, struct mbuf *m) { struct ether_aarp *ea; struct at_ifaddr *aa; @@ -324,8 +327,8 @@ ea = mtod(m, struct ether_aarp *); /* Check to see if from my hardware address */ - if (!bcmp((caddr_t)ea->aarp_sha, IFP2AC(ifp)->ac_enaddr, - sizeof(IFP2AC(ifp)->ac_enaddr))) { + if (!bcmp((caddr_t)ea->aarp_sha, (caddr_t)ac->ac_enaddr, + sizeof(ac->ac_enaddr))) { m_freem(m); return; } @@ -348,7 +351,7 @@ * Since we don't know the net, we just look for the first * phase 1 address on the interface. */ - for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa; + for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa; aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) { if (AA_SAT(aa)->sat_family == AF_APPLETALK && (aa->aa_flags & AFA_PHASE2) == 0) { @@ -377,7 +380,7 @@ * probed for the same address we'd like to use. Change the * address we're probing for. */ - untimeout(aarpprobe, ifp, aa->aa_ch); + untimeout(aarpprobe, ac, aa->aa_ch); wakeup(aa); m_freem(m); return; @@ -421,7 +424,7 @@ sat.sat_len = sizeof(struct sockaddr_at); sat.sat_family = AF_APPLETALK; sat.sat_addr = spa; - (*ifp->if_output)(ifp, mhold, + (*ac->ac_if.if_output)(&ac->ac_if, mhold, (struct sockaddr *)&sat, NULL); /* XXX */ } else AARPTAB_UNLOCK(); @@ -448,7 +451,7 @@ bcopy((caddr_t)ea->aarp_sha, (caddr_t)ea->aarp_tha, sizeof(ea->aarp_sha)); - bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha, + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, sizeof(ea->aarp_sha)); /* XXX */ @@ -481,7 +484,7 @@ sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; - (*ifp->if_output)(ifp, m, &sa, NULL); /* XXX */ + (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */ return; } @@ -537,7 +540,7 @@ void aarpprobe(void *arg) { - struct ifnet *ifp = arg; + struct arpcom *ac = arg; struct mbuf *m; struct ether_header *eh; struct ether_aarp *ea; @@ -552,7 +555,7 @@ * interface with the same address as we're looking for. If the * net is phase 2, generate an 802.2 and SNAP header. */ - for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa; + for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa; aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) { if (AA_SAT(aa)->sat_family == AF_APPLETALK && (aa->aa_flags & AFA_PROBING)) { @@ -569,14 +572,14 @@ wakeup(aa); return; } else { - aa->aa_ch = timeout(aarpprobe, (caddr_t)ifp, hz / 5); + aa->aa_ch = timeout(aarpprobe, (caddr_t)ac, hz / 5); } if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) { return; } #ifdef MAC - mac_create_mbuf_linklayer(ifp, m); + mac_create_mbuf_linklayer(&ac->ac_if, m); #endif m->m_len = sizeof(*ea); m->m_pkthdr.len = sizeof(*ea); @@ -590,7 +593,7 @@ ea->aarp_hln = sizeof(ea->aarp_sha); ea->aarp_pln = sizeof(ea->aarp_spu); ea->aarp_op = htons(AARPOP_PROBE); - bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha, + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, sizeof(ea->aarp_sha)); eh = (struct ether_header *)sa.sa_data; @@ -615,7 +618,7 @@ sizeof(ea->aarp_tpnet)); ea->aarp_spnode = ea->aarp_tpnode = AA_SAT(aa)->sat_addr.s_node; } else { - bcopy(ifp->if_broadcastaddr, (caddr_t)eh->ether_dhost, + bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost, sizeof(eh->ether_dhost)); eh->ether_type = htons(ETHERTYPE_AARP); ea->aarp_spa = ea->aarp_tpa = AA_SAT(aa)->sat_addr.s_node; @@ -629,7 +632,7 @@ sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; - (*ifp->if_output)(ifp, m, &sa, NULL); /* XXX */ + (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */ aa->aa_probcnt--; } --- //depot/vendor/freebsd/src/sys/netatalk/at_extern.h 2004/04/25 02:25:44 +++ //depot/user/jhb/acpipci/netatalk/at_extern.h 2003/03/06 13:39:20 @@ -1,12 +1,12 @@ /* - * $FreeBSD: src/sys/netatalk/at_extern.h,v 1.14 2004/04/25 09:24:51 luigi Exp $ + * $FreeBSD: src/sys/netatalk/at_extern.h,v 1.13 2003/03/04 23:19:51 jlemon Exp $ */ struct mbuf; struct sockaddr_at; #ifdef _NET_IF_ARP_H_ extern timeout_t aarpprobe; -extern int aarpresolve (struct ifnet *, +extern int aarpresolve (struct arpcom *, struct mbuf *, struct sockaddr_at *, u_char *); --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/common/ng_bluetooth.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/common/ng_bluetooth.c 2003/05/13 10:44:32 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_bluetooth.c,v 1.3 2003/04/26 22:37:31 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/common/ng_bluetooth.c,v 1.3 2004/04/27 16:38:13 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/common/ng_bluetooth.c,v 1.2 2003/05/10 21:44:39 julian Exp $ */ #include @@ -35,7 +35,7 @@ #include #include -#include +#include "ng_bluetooth.h" /* * Bluetooth stack sysctl globals --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c 2004/03/26 08:52:16 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_bt3c_pccard.c,v 1.5 2003/04/01 18:15:21 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c,v 1.6 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c,v 1.5 2004/03/17 17:50:51 njl Exp $ * * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX * @@ -64,10 +64,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include "ng_bt3c.h" +#include "ng_bt3c_var.h" /* Netgraph methods */ static ng_constructor_t ng_bt3c_constructor; --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/drivers/h4/ng_h4.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/drivers/h4/ng_h4.c 2004/01/27 10:15:19 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_h4.c,v 1.5 2003/05/10 05:51:25 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4.c,v 1.7 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4.c,v 1.6 2004/01/26 15:19:43 harti Exp $ * * Based on: * --------- @@ -51,11 +51,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include "ng_h4.h" +#include "ng_h4_var.h" +#include "ng_h4_prse.h" /***************************************************************************** ***************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/drivers/ubt/ng_ubt.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_ubt.c,v 1.16 2003/10/10 19:15:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c,v 1.13 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c,v 1.12 2004/04/09 23:01:39 emax Exp $ */ #include @@ -52,10 +52,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include "ng_ubt.h" +#include "ng_ubt_var.h" /* * USB methods --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/hci/ng_hci_cmds.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/hci/ng_hci_cmds.c 2003/10/23 14:00:40 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_hci_cmds.c,v 1.4 2003/09/08 18:57:51 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_cmds.c,v 1.6 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_cmds.c,v 1.5 2003/10/12 22:04:20 emax Exp $ */ #include @@ -38,13 +38,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_hci_var.h" +#include "ng_hci_cmds.h" +#include "ng_hci_evnt.h" +#include "ng_hci_ulpi.h" +#include "ng_hci_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/hci/ng_hci_evnt.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/hci/ng_hci_evnt.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_hci_evnt.c,v 1.6 2003/09/08 18:57:51 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_evnt.c,v 1.7 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_evnt.c,v 1.6 2004/04/09 23:01:39 emax Exp $ */ #include @@ -38,13 +38,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_hci_var.h" +#include "ng_hci_cmds.h" +#include "ng_hci_evnt.h" +#include "ng_hci_ulpi.h" +#include "ng_hci_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/hci/ng_hci_main.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/hci/ng_hci_main.c 2003/05/13 10:44:32 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_hci_main.c,v 1.2 2003/03/18 00:09:36 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_main.c,v 1.3 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_main.c,v 1.2 2003/05/10 21:44:40 julian Exp $ */ #include @@ -39,14 +39,14 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_hci_var.h" +#include "ng_hci_prse.h" +#include "ng_hci_cmds.h" +#include "ng_hci_evnt.h" +#include "ng_hci_ulpi.h" +#include "ng_hci_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/hci/ng_hci_misc.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/hci/ng_hci_misc.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_hci_misc.c,v 1.5 2003/09/08 18:57:51 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_misc.c,v 1.7 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_misc.c,v 1.6 2004/04/09 23:01:39 emax Exp $ */ #include @@ -37,13 +37,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_hci_var.h" +#include "ng_hci_cmds.h" +#include "ng_hci_evnt.h" +#include "ng_hci_ulpi.h" +#include "ng_hci_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/hci/ng_hci_ulpi.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_hci_ulpi.c,v 1.7 2003/09/08 18:57:51 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c,v 1.7 2004/04/27 16:38:14 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c,v 1.6 2004/04/09 23:01:39 emax Exp $ */ #include @@ -38,13 +38,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_hci_var.h" +#include "ng_hci_cmds.h" +#include "ng_hci_evnt.h" +#include "ng_hci_ulpi.h" +#include "ng_hci_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_cmds.c 2003/10/23 14:00:40 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_cmds.c,v 1.2 2003/09/08 19:11:45 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.c,v 1.4 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_cmds.c,v 1.3 2003/10/12 22:04:21 emax Exp $ */ #include @@ -38,15 +38,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_evnt.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_evnt.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_evnt.c,v 1.5 2003/09/08 19:11:45 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_evnt.c,v 1.7 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_evnt.c,v 1.6 2004/04/09 23:01:40 emax Exp $ */ #include @@ -38,15 +38,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_llpi.c,v 1.5 2003/09/08 19:11:45 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c,v 1.7 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c,v 1.6 2004/04/09 23:01:40 emax Exp $ */ #include @@ -38,15 +38,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_main.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_main.c 2003/05/13 10:44:32 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_main.c,v 1.2 2003/04/28 21:44:59 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_main.c,v 1.3 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_main.c,v 1.2 2003/05/10 21:44:41 julian Exp $ */ #include @@ -38,16 +38,16 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" +#include "ng_l2cap_prse.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_misc.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_misc.c,v 1.5 2003/09/08 19:11:45 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c,v 1.7 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c,v 1.6 2004/04/09 23:01:40 emax Exp $ */ #include @@ -37,15 +37,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" static u_int16_t ng_l2cap_get_cid (ng_l2cap_p); --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_l2cap_ulpi.c,v 1.1 2002/11/24 19:47:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c,v 1.4 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c,v 1.3 2004/04/09 23:01:40 emax Exp $ */ #include @@ -38,14 +38,14 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_l2cap_var.h" +#include "ng_l2cap_cmds.h" +#include "ng_l2cap_evnt.h" +#include "ng_l2cap_llpi.h" +#include "ng_l2cap_ulpi.h" +#include "ng_l2cap_misc.h" /****************************************************************************** ****************************************************************************** --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/socket/ng_btsocket.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/socket/ng_btsocket.c 2003/11/18 11:13:20 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_btsocket.c,v 1.4 2003/09/14 23:29:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket.c,v 1.6 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket.c,v 1.5 2003/11/18 00:39:04 rwatson Exp $ */ #include @@ -44,13 +44,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_btsocket.h" +#include "ng_btsocket_hci_raw.h" +#include "ng_btsocket_l2cap.h" +#include "ng_btsocket_rfcomm.h" static int ng_btsocket_modevent (module_t, int, void *); extern struct domain ng_btsocket_domain; --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c 2004/03/10 13:15:05 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_btsocket_hci_raw.c,v 1.14 2003/09/14 23:29:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c,v 1.13 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c,v 1.12 2004/03/01 03:14:22 rwatson Exp $ */ #include @@ -50,11 +50,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_btsocket.h" +#include "ng_btsocket_hci_raw.h" /* MALLOC define */ #ifdef NG_SEPARATE_MALLOC --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/socket/ng_btsocket_l2cap.c 2004/03/10 13:15:05 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_btsocket_l2cap.c,v 1.16 2003/09/14 23:29:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c,v 1.11 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c,v 1.10 2004/03/01 03:14:22 rwatson Exp $ */ #include @@ -50,11 +50,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_btsocket.h" +#include "ng_btsocket_l2cap.h" /* MALLOC define */ #ifdef NG_SEPARATE_MALLOC --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c 2004/03/10 13:15:05 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_btsocket_l2cap_raw.c,v 1.12 2003/09/14 23:29:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c,v 1.10 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c,v 1.9 2004/03/01 03:14:22 rwatson Exp $ */ #include @@ -49,11 +49,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_btsocket.h" +#include "ng_btsocket_l2cap.h" /* MALLOC define */ #ifdef NG_SEPARATE_MALLOC --- //depot/vendor/freebsd/src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c 2004/04/27 09:40:50 +++ //depot/user/jhb/acpipci/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c 2004/03/10 13:15:05 @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $Id: ng_btsocket_rfcomm.c,v 1.28 2003/09/14 23:29:06 max Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c,v 1.6 2004/04/27 16:38:15 emax Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c,v 1.4 2004/03/01 03:14:22 rwatson Exp $ */ #include @@ -52,12 +52,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include "ng_bluetooth.h" +#include "ng_hci.h" +#include "ng_l2cap.h" +#include "ng_btsocket.h" +#include "ng_btsocket_l2cap.h" +#include "ng_btsocket_rfcomm.h" /* MALLOC define */ #ifdef NG_SEPARATE_MALLOC @@ -2065,12 +2065,9 @@ if (dlci == 0) { /* XXX FIXME assume that remote side will close the socket */ error = ng_btsocket_rfcomm_send_command(s, RFCOMM_FRAME_UA, 0); - if (error == 0) { - if (s->state == NG_BTSOCKET_RFCOMM_SESSION_DISCONNECTING) - s->state = NG_BTSOCKET_RFCOMM_SESSION_CLOSED; /* XXX */ - else - s->state = NG_BTSOCKET_RFCOMM_SESSION_DISCONNECTING; - } else + if (error == 0) + s->state = NG_BTSOCKET_RFCOMM_SESSION_DISCONNECTING; + else s->state = NG_BTSOCKET_RFCOMM_SESSION_CLOSED; /* XXX */ ng_btsocket_rfcomm_session_clean(s); --- //depot/vendor/freebsd/src/sys/netgraph/ng_pptpgre.c 2004/04/26 07:31:42 +++ //depot/user/jhb/acpipci/netgraph/ng_pptpgre.c 2003/11/18 13:11:39 @@ -36,7 +36,7 @@ * * Author: Archie Cobbs * - * $FreeBSD: src/sys/netgraph/ng_pptpgre.c,v 1.32 2004/04/26 14:26:54 archie Exp $ + * $FreeBSD: src/sys/netgraph/ng_pptpgre.c,v 1.31 2003/11/18 20:43:23 archie Exp $ * $Whistle: ng_pptpgre.c,v 1.7 1999/12/08 00:10:06 archie Exp $ */ @@ -477,16 +477,13 @@ /* Check if there's data */ if (m != NULL) { - /* Check if windowing is enabled */ - if (priv->conf.enableWindowing) { - /* Is our transmit window full? */ - if ((u_int32_t)PPTP_SEQ_DIFF(priv->xmitSeq, - priv->recvAck) >= a->xmitWin) { - priv->stats.xmitDrops++; - NG_FREE_M(m); - NG_FREE_ITEM(item); - return (ENOBUFS); - } + /* Is our transmit window full? */ + if ((u_int32_t)PPTP_SEQ_DIFF(priv->xmitSeq, priv->recvAck) + >= a->xmitWin) { + priv->stats.xmitDrops++; + NG_FREE_M(m); + NG_FREE_ITEM(item); + return (ENOBUFS); } /* Sanity check frame length */ @@ -508,10 +505,8 @@ /* Include sequence number if packet contains any data */ if (m != NULL) { gre->hasSeq = 1; - if (priv->conf.enableWindowing) { - a->timeSent[priv->xmitSeq - priv->recvAck] - = ng_pptpgre_time(node); - } + a->timeSent[priv->xmitSeq - priv->recvAck] + = ng_pptpgre_time(node); priv->xmitSeq++; gre->data[0] = htonl(priv->xmitSeq); } @@ -661,36 +656,33 @@ priv->recvAck = ack; /* Update adaptive timeout stuff */ - if (priv->conf.enableWindowing) { - sample = ng_pptpgre_time(node) - a->timeSent[index]; - diff = sample - a->rtt; - a->rtt += PPTP_ACK_ALPHA(diff); - if (diff < 0) - diff = -diff; - a->dev += PPTP_ACK_BETA(diff - a->dev); - a->ato = a->rtt + PPTP_ACK_CHI(a->dev); - if (a->ato > PPTP_MAX_TIMEOUT) - a->ato = PPTP_MAX_TIMEOUT; - if (a->ato < PPTP_MIN_TIMEOUT) - a->ato = PPTP_MIN_TIMEOUT; + sample = ng_pptpgre_time(node) - a->timeSent[index]; + diff = sample - a->rtt; + a->rtt += PPTP_ACK_ALPHA(diff); + if (diff < 0) + diff = -diff; + a->dev += PPTP_ACK_BETA(diff - a->dev); + a->ato = a->rtt + PPTP_ACK_CHI(a->dev); + if (a->ato > PPTP_MAX_TIMEOUT) + a->ato = PPTP_MAX_TIMEOUT; + if (a->ato < PPTP_MIN_TIMEOUT) + a->ato = PPTP_MIN_TIMEOUT; - /* Shift packet transmit times in our transmit window */ - bcopy(a->timeSent + index + 1, a->timeSent, - sizeof(*a->timeSent) - * (PPTP_XMIT_WIN - (index + 1))); + /* Shift packet transmit times in our transmit window */ + bcopy(a->timeSent + index + 1, a->timeSent, + sizeof(*a->timeSent) * (PPTP_XMIT_WIN - (index + 1))); - /* If we sent an entire window, increase window size */ - if (PPTP_SEQ_DIFF(ack, a->winAck) >= 0 - && a->xmitWin < PPTP_XMIT_WIN) { - a->xmitWin++; - a->winAck = ack + a->xmitWin; - } + /* If we sent an entire window, increase window size by one */ + if (PPTP_SEQ_DIFF(ack, a->winAck) >= 0 + && a->xmitWin < PPTP_XMIT_WIN) { + a->xmitWin++; + a->winAck = ack + a->xmitWin; + } - /* Stop/(re)start receive ACK timer as necessary */ - ng_pptpgre_stop_recv_ack_timer(node); - if (priv->recvAck != priv->xmitSeq) - ng_pptpgre_start_recv_ack_timer(node); - } + /* Stop/(re)start receive ACK timer as necessary */ + ng_pptpgre_stop_recv_ack_timer(node); + if (priv->recvAck != priv->xmitSeq) + ng_pptpgre_start_recv_ack_timer(node); } badAck: @@ -760,9 +752,6 @@ struct ng_pptpgre_ackp *const a = &priv->ackp; int remain, ticks; - if (!priv->conf.enableWindowing) - return; - /* Compute how long until oldest unack'd packet times out, and reset the timer to that time. */ KASSERT(a->rackTimerPtr == NULL, ("%s: rackTimer", __func__)); @@ -799,9 +788,6 @@ const priv_p priv = NG_NODE_PRIVATE(node); struct ng_pptpgre_ackp *const a = &priv->ackp; - if (!priv->conf.enableWindowing) - return; - if (callout_stop(&a->rackTimer)) { FREE(a->rackTimerPtr, M_NETGRAPH); priv->timers--; --- //depot/vendor/freebsd/src/sys/netgraph/ng_pptpgre.h 2004/04/26 07:31:42 +++ //depot/user/jhb/acpipci/netgraph/ng_pptpgre.h 2003/11/11 12:12:41 @@ -36,7 +36,7 @@ * * Author: Archie Cobbs * - * $FreeBSD: src/sys/netgraph/ng_pptpgre.h,v 1.8 2004/04/26 14:26:54 archie Exp $ + * $FreeBSD: src/sys/netgraph/ng_pptpgre.h,v 1.7 2003/11/11 12:30:37 ru Exp $ * $Whistle: ng_pptpgre.h,v 1.3 1999/12/08 00:11:36 archie Exp $ */ @@ -45,7 +45,7 @@ /* Node type name and magic cookie */ #define NG_PPTPGRE_NODE_TYPE "pptpgre" -#define NGM_PPTPGRE_COOKIE 1082548365 +#define NGM_PPTPGRE_COOKIE 942783547 /* Hook names */ #define NG_PPTPGRE_HOOK_UPPER "upper" /* to upper layers */ @@ -56,7 +56,6 @@ u_char enabled; /* enables traffic flow */ u_char enableDelayedAck;/* enables delayed acks */ u_char enableAlwaysAck;/* always include ack with data */ - u_char enableWindowing;/* enable windowing algorithm */ u_int16_t cid; /* my call id */ u_int16_t peerCid; /* peer call id */ u_int16_t recvWin; /* peer recv window size */ @@ -69,7 +68,6 @@ { "enabled", &ng_parse_uint8_type }, \ { "enableDelayedAck", &ng_parse_uint8_type }, \ { "enableAlwaysAck", &ng_parse_uint8_type }, \ - { "enableWindowing", &ng_parse_uint8_type }, \ { "cid", &ng_parse_hint16_type }, \ { "peerCid", &ng_parse_hint16_type }, \ { "recvWin", &ng_parse_uint16_type }, \ --- //depot/vendor/freebsd/src/sys/netinet/if_ether.c 2004/04/25 08:02:49 +++ //depot/user/jhb/acpipci/netinet/if_ether.c 2004/04/19 12:55:20 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)if_ether.c 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/netinet/if_ether.c,v 1.127 2004/04/25 15:00:17 luigi Exp $ + * $FreeBSD: src/sys/netinet/if_ether.c,v 1.123 2004/04/18 11:45:49 luigi Exp $ */ /* @@ -102,6 +102,7 @@ static struct ifqueue arpintrq; static int arp_allocated; +static int arpinit_done; static int arp_maxtries = 5; static int useloopback = 1; /* use loopback interface for local traffic */ @@ -167,6 +168,10 @@ RT_LOCK_ASSERT(rt); + if (!arpinit_done) { + arpinit_done = 1; + callout_reset(&arp_callout, hz, arptimer, NULL); + } if (rt->rt_flags & RTF_GATEWAY) return; gate = rt->rt_gateway; @@ -328,40 +333,29 @@ } /* - * Resolve an IP address into an ethernet address. - * On input: - * ifp is the interface we use - * dst is the next hop, - * rt0 is the route to the final destination (possibly useless) - * m is the mbuf - * desten is where we want the address. - * - * On success, desten is filled in and the function returns 0; - * If the packet must be held pending resolution, we return EWOULDBLOCK - * On other errors, we return the corresponding error code. + * Resolve an IP address into an ethernet address. If success, + * desten is filled in. If there is no entry in arptab, + * set one up and broadcast a request for the IP address. + * Hold onto this mbuf and resend it once the address + * is finally resolved. A return value of 1 indicates + * that desten has been filled in and the packet should be sent + * normally; a 0 return indicates that the packet has been + * taken over here, either now or for later transmission. */ int -arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, +arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m, struct sockaddr *dst, u_char *desten) { struct llinfo_arp *la = 0; struct sockaddr_dl *sdl; - int error; - struct rtentry *rt; - error = rt_check(&rt, &rt0, dst); - if (error) { - m_freem(m); - return error; - } - if (m->m_flags & M_BCAST) { /* broadcast */ (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); - return (0); + return (1); } if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); - return (0); + return(1); } if (rt) la = (struct llinfo_arp *)rt->rt_llinfo; @@ -375,7 +369,7 @@ inet_ntoa(SIN(dst)->sin_addr), la ? "la" : "", rt ? "rt" : ""); m_freem(m); - return (EINVAL); /* XXX */ + return (0); } sdl = SDL(rt->rt_gateway); /* @@ -399,7 +393,7 @@ } bcopy(LLADDR(sdl), desten, sdl->sdl_alen); - return (0); + return 1; } /* * If ARP is disabled or static on this interface, stop. @@ -409,7 +403,7 @@ */ if (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) { m_freem(m); - return (EINVAL); + return (0); } /* * There is an arptab entry, but no ethernet address @@ -439,7 +433,7 @@ } RT_UNLOCK(rt); } - return (EWOULDBLOCK); + return (0); } /* @@ -451,6 +445,11 @@ { struct arphdr *ar; + if (!arpinit_done) { + /* NB: this race should not matter */ + arpinit_done = 1; + callout_reset(&arp_callout, hz, arptimer, NULL); + } if (m->m_len < sizeof(struct arphdr) && ((m = m_pullup(m, sizeof(struct arphdr))) == NULL)) { log(LOG_ERR, "arp: runt packet -- m_pullup failed\n"); @@ -570,17 +569,23 @@ /* * If bridging, fall back to using any inet address. */ - if (!BRIDGE_TEST || (ia = TAILQ_FIRST(&in_ifaddrhead)) == NULL) - goto drop; + if (!BRIDGE_TEST || + (ia = TAILQ_FIRST(&in_ifaddrhead)) == NULL) { + m_freem(m); + return; + } match: myaddr = ia->ia_addr.sin_addr; - if (!bcmp(ar_sha(ah), IF_LLADDR(ifp), ifp->if_addrlen)) - goto drop; /* it's from me, ignore it. */ + if (!bcmp(ar_sha(ah), IF_LLADDR(ifp), ifp->if_addrlen)) { + m_freem(m); /* it's from me, ignore it. */ + return; + } if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) { log(LOG_ERR, "arp: link address is broadcast for IP address %s!\n", inet_ntoa(isaddr)); - goto drop; + m_freem(m); + return; } if (isaddr.s_addr == myaddr.s_addr) { log(LOG_ERR, @@ -686,8 +691,10 @@ } } reply: - if (op != ARPOP_REQUEST) - goto drop; + if (op != ARPOP_REQUEST) { + m_freem(m); + return; + } if (itaddr.s_addr == myaddr.s_addr) { /* I am the target */ (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); @@ -697,8 +704,10 @@ if (la == NULL) { struct sockaddr_in sin; - if (!arp_proxyall) - goto drop; + if (!arp_proxyall) { + m_freem(m); + return; + } bzero(&sin, sizeof sin); sin.sin_family = AF_INET; @@ -706,8 +715,10 @@ sin.sin_addr = itaddr; rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL); - if (!rt) - goto drop; + if (!rt) { + m_freem(m); + return; + } /* * Don't send proxies for nodes on the same interface * as this one came out of, or we'll get into a fight @@ -715,7 +726,8 @@ */ if (rt->rt_ifp == ifp) { rtfree(rt); - goto drop; + m_freem(m); + return; } (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); (void)memcpy(ar_sha(ah), IF_LLADDR(ifp), ah->ar_hln); @@ -730,15 +742,18 @@ sin.sin_addr = isaddr; rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL); - if (!rt) - goto drop; + if (!rt) { + m_freem(m); + return; + } if (rt->rt_ifp != ifp) { log(LOG_INFO, "arp_proxy: ignoring request" " from %s via %s, expecting %s\n", inet_ntoa(isaddr), ifp->if_xname, rt->rt_ifp->if_xname); rtfree(rt); - goto drop; + m_freem(m); + return; } rtfree(rt); @@ -765,9 +780,6 @@ sa.sa_len = 2; (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); return; - -drop: - m_freem(m); } #endif @@ -869,6 +881,5 @@ LIST_INIT(&llinfo_arp); callout_init(&arp_callout, CALLOUT_MPSAFE); netisr_register(NETISR_ARP, arpintr, &arpintrq, NETISR_MPSAFE); - callout_reset(&arp_callout, hz, arptimer, NULL); } SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0); --- //depot/vendor/freebsd/src/sys/netinet/in_pcb.c 2004/04/23 16:30:37 +++ //depot/user/jhb/acpipci/netinet/in_pcb.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.146 2004/04/23 23:29:49 silby Exp $ + * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.142 2004/04/07 20:46:13 imp Exp $ */ #include "opt_ipsec.h" @@ -97,9 +97,6 @@ int ipport_reservedhigh = IPPORT_RESERVED - 1; /* 1023 */ int ipport_reservedlow = 0; -/* Shall we allocate ephemeral ports in random order? */ -int ipport_randomized = 1; - #define RANGECHK(var, min, max) \ if ((var) < (min)) { (var) = (min); } \ else if ((var) > (max)) { (var) = (max); } @@ -141,8 +138,6 @@ CTLFLAG_RW|CTLFLAG_SECURE, &ipport_reservedhigh, 0, ""); SYSCTL_INT(_net_inet_ip_portrange, OID_AUTO, reservedlow, CTLFLAG_RW|CTLFLAG_SECURE, &ipport_reservedlow, 0, ""); -SYSCTL_INT(_net_inet_ip_portrange, OID_AUTO, randomized, - CTLFLAG_RW, &ipport_randomized, 0, ""); /* * in_pcb.c: manage the Protocol Control Blocks. @@ -415,9 +410,6 @@ /* * counting down */ - if (ipport_randomized) - *lastport = first - - (arc4random() % (first - last)); count = first - last; do { @@ -433,9 +425,6 @@ /* * counting up */ - if (ipport_randomized) - *lastport = first + - (arc4random() % (last - first)); count = last - first; do { --- //depot/vendor/freebsd/src/sys/netinet/ip_fw.h 2004/04/23 07:31:37 +++ //depot/user/jhb/acpipci/netinet/ip_fw.h 2004/03/10 13:15:05 @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/netinet/ip_fw.h,v 1.84 2004/04/23 14:27:27 andre Exp $ + * $FreeBSD: src/sys/netinet/ip_fw.h,v 1.83 2004/02/25 19:55:28 mlaier Exp $ */ #ifndef _IPFW2_H @@ -95,7 +95,6 @@ O_TCPOPTS, /* arg1 = 2*u8 bitmap */ O_VERREVPATH, /* none */ - O_VERSRCREACH, /* none */ O_PROBE_STATE, /* none */ O_KEEP_STATE, /* none */ --- //depot/vendor/freebsd/src/sys/netinet/ip_fw2.c 2004/04/23 07:31:37 +++ //depot/user/jhb/acpipci/netinet/ip_fw2.c 2004/03/10 13:15:05 @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/netinet/ip_fw2.c,v 1.57 2004/04/23 14:27:27 andre Exp $ + * $FreeBSD: src/sys/netinet/ip_fw2.c,v 1.56 2004/02/25 19:55:28 mlaier Exp $ */ #define DEB(x) @@ -439,27 +439,21 @@ } /* - * The verify_path function checks if a route to the src exists and - * if it is reachable via ifp (when provided). - * * The 'verrevpath' option checks that the interface that an IP packet * arrives on is the same interface that traffic destined for the - * packet's source address would be routed out of. The 'versrcreach' - * option just checks that the source address is reachable via any route - * (except default) in the routing table. These two are a measure to block - * forged packets. This is also commonly known as "anti-spoofing" or Unicast - * Reverse Path Forwarding (Unicast RFP) in Cisco-ese. The name of the knobs - * is purposely reminiscent of the Cisco IOS command, + * packet's source address would be routed out of. This is a measure + * to block forged packets. This is also commonly known as "anti-spoofing" + * or Unicast Reverse Path Forwarding (Unicast RFP) in Cisco-ese. The + * name of the knob is purposely reminisent of the Cisco IOS command, * * ip verify unicast reverse-path - * ip verify unicast source reachable-via any * * which implements the same functionality. But note that syntax is * misleading. The check may be performed on all IP packets whether unicast, * multicast, or broadcast. */ static int -verify_path(struct in_addr src, struct ifnet *ifp) +verify_rev_path(struct in_addr src, struct ifnet *ifp) { struct route ro; struct sockaddr_in *dst; @@ -474,21 +468,10 @@ if (ro.ro_rt == NULL) return 0; - - /* if ifp is provided, check for equality with rtentry */ - if (ifp != NULL && ro.ro_rt->rt_ifp != ifp) { - RTFREE(ro.ro_rt); - return 0; - } - - /* if no ifp provided, check if rtentry is not default route */ - if (ifp == NULL && - satosin(rt_key(ro.ro_rt))->sin_addr.s_addr == INADDR_ANY) { + if ((ifp == NULL) || (ro.ro_rt->rt_ifp->if_index != ifp->if_index)) { RTFREE(ro.ro_rt); return 0; } - - /* found valid route */ RTFREE(ro.ro_rt); return 1; } @@ -1928,13 +1911,7 @@ /* Outgoing packets automatically pass/match */ match = ((oif != NULL) || (m->m_pkthdr.rcvif == NULL) || - verify_path(src_ip, m->m_pkthdr.rcvif)); - break; - - case O_VERSRCREACH: - /* Outgoing packets automatically pass/match */ - match = ((oif != NULL) || - verify_path(src_ip, NULL)); + verify_rev_path(src_ip, m->m_pkthdr.rcvif)); break; case O_IPSEC: @@ -2569,7 +2546,6 @@ case O_TCPOPTS: case O_ESTAB: case O_VERREVPATH: - case O_VERSRCREACH: case O_IPSEC: if (cmdlen != F_INSN_SIZE(ipfw_insn)) goto bad_size; --- //depot/vendor/freebsd/src/sys/netinet/raw_ip.c 2004/04/26 12:50:50 +++ //depot/user/jhb/acpipci/netinet/raw_ip.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 - * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.129 2004/04/26 19:46:52 bmilekic Exp $ + * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.128 2004/04/07 20:46:13 imp Exp $ */ #include "opt_inet6.h" @@ -36,7 +36,6 @@ #include "opt_random_ip_id.h" #include -#include #include #include #include @@ -207,10 +206,6 @@ if (inp->inp_faddr.s_addr && inp->inp_faddr.s_addr != ip->ip_src.s_addr) goto docontinue; - if (jailed(inp->inp_socket->so_cred)) - if (htonl(prison_getip(inp->inp_socket->so_cred)) - != ip->ip_dst.s_addr) - goto docontinue; if (last) { struct mbuf *n; @@ -266,11 +261,7 @@ ip->ip_off = 0; ip->ip_p = inp->inp_ip_p; ip->ip_len = m->m_pkthdr.len; - if (jailed(inp->inp_socket->so_cred)) - ip->ip_src.s_addr = - htonl(prison_getip(inp->inp_socket->so_cred)); - else - ip->ip_src = inp->inp_laddr; + ip->ip_src = inp->inp_laddr; ip->ip_dst.s_addr = dst; ip->ip_ttl = inp->inp_ip_ttl; } else { @@ -279,13 +270,6 @@ return(EMSGSIZE); } ip = mtod(m, struct ip *); - if (jailed(inp->inp_socket->so_cred)) { - if (ip->ip_src.s_addr != - htonl(prison_getip(inp->inp_socket->so_cred))) { - m_freem(m); - return (EPERM); - } - } /* don't allow both user specified and setsockopt options, and don't allow packet length sizes that will crash */ if (((ip->ip_hl != (sizeof (*ip) >> 2)) @@ -534,12 +518,8 @@ INP_INFO_WUNLOCK(&ripcbinfo); return EINVAL; } - if (td && jailed(td->td_ucred) && !jail_allow_raw_sockets) { + if (td && (error = suser(td)) != 0) { INP_INFO_WUNLOCK(&ripcbinfo); - return (EPERM); - } - if (td && (error = suser_cred(td->td_ucred, PRISON_ROOT)) != 0) { - INP_INFO_WUNLOCK(&ripcbinfo); return error; } if (proto >= IPPROTO_MAX || proto < 0) { @@ -638,15 +618,6 @@ if (nam->sa_len != sizeof(*addr)) return EINVAL; - if (jailed(td->td_ucred)) { - if (addr->sin_addr.s_addr == INADDR_ANY) - addr->sin_addr.s_addr = - htonl(prison_getip(td->td_ucred)); - if (htonl(prison_getip(td->td_ucred)) - != addr->sin_addr.s_addr) - return (EADDRNOTAVAIL); - } - if (TAILQ_EMPTY(&ifnet) || (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) || (addr->sin_addr.s_addr && --- //depot/vendor/freebsd/src/sys/netinet/tcp_hostcache.c 2004/04/23 06:56:01 +++ //depot/user/jhb/acpipci/netinet/tcp_hostcache.c 2003/12/03 07:05:06 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/netinet/tcp_hostcache.c,v 1.4 2004/04/23 13:54:28 andre Exp $ + * $FreeBSD: src/sys/netinet/tcp_hostcache.c,v 1.3 2003/12/02 21:25:12 andre Exp $ */ /* @@ -700,7 +700,7 @@ static void tcp_hc_purge(void *arg) { - struct hc_metrics *hc_entry, *hc_next; + struct hc_metrics *hc_entry; int all = (intptr_t)arg; int i; @@ -711,8 +711,8 @@ for (i = 0; i < tcp_hostcache.hashsize; i++) { THC_LOCK(&tcp_hostcache.hashbase[i].hch_mtx); - TAILQ_FOREACH_SAFE(hc_entry, &tcp_hostcache.hashbase[i].hch_bucket, - rmx_q, hc_next) { + TAILQ_FOREACH(hc_entry, &tcp_hostcache.hashbase[i].hch_bucket, + rmx_q) { if (all || hc_entry->rmx_expire <= 0) { TAILQ_REMOVE(&tcp_hostcache.hashbase[i].hch_bucket, hc_entry, rmx_q); --- //depot/vendor/freebsd/src/sys/netinet/tcp_input.c 2004/04/25 20:01:21 +++ //depot/user/jhb/acpipci/netinet/tcp_input.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.235 2004/04/26 02:56:31 silby Exp $ + * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.233 2004/04/07 20:46:13 imp Exp $ */ #include "opt_ipfw.h" /* for ipfw_fwd */ @@ -1532,12 +1532,6 @@ * echo of our outgoing acknowlegement numbers, but some hosts * send a reset with the sequence number at the rightmost edge * of our receive window, and we have to handle this case. - * Note 2: Paul Watson's paper "Slipping in the Window" has shown - * that brute force RST attacks are possible. To combat this, - * we use a much stricter check while in the ESTABLISHED state, - * only accepting RSTs where the sequence number is equal to - * last_ack_sent. In all other states (the states in which a - * RST is more likely), the more permissive check is used. * If we have multiple segments in flight, the intial reset * segment sequence numbers will be to the left of last_ack_sent, * but they will eventually catch up. @@ -1576,10 +1570,6 @@ goto close; case TCPS_ESTABLISHED: - if (tp->last_ack_sent != th->th_seq) { - tcpstat.tcps_badrst++; - goto drop; - } case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: @@ -2803,7 +2793,7 @@ so = inp->inp_socket; /* - * no route to sender, stay with default mss and return + * no route to sender, take default mss and return */ if (maxmtu == 0) return; @@ -2861,7 +2851,7 @@ * else, use the link mtu. */ if (metrics.rmx_mtu) - mss = min(metrics.rmx_mtu, maxmtu) - min_protoh; + mss = metrics.rmx_mtu - min_protoh; else { #ifdef INET6 if (isipv6) { --- //depot/vendor/freebsd/src/sys/netinet/tcp_subr.c 2004/04/19 23:36:09 +++ //depot/user/jhb/acpipci/netinet/tcp_subr.c 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.188 2004/04/20 06:33:39 silby Exp $ + * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.187 2004/04/07 20:46:13 imp Exp $ */ #include "opt_compat.h" @@ -203,7 +203,6 @@ static struct inpcb *tcp_notify(struct inpcb *, int); static void tcp_discardcb(struct tcpcb *); -static void tcp_isn_tick(void *); /* * Target size of TCP PCB hash tables. Must be a power of two. @@ -229,7 +228,6 @@ static uma_zone_t tcpcb_zone; static uma_zone_t tcptw_zone; -struct callout isn_callout; /* * Tcp initialization @@ -288,20 +286,8 @@ syncache_init(); tcp_hc_init(); tcp_reass_init(); - callout_init(&isn_callout, CALLOUT_MPSAFE); - tcp_isn_tick(NULL); - EVENTHANDLER_REGISTER(shutdown_pre_sync, tcp_fini, NULL, - SHUTDOWN_PRI_DEFAULT); } -void -tcp_fini(xtp) - void *xtp; -{ - callout_stop(&isn_callout); - -} - /* * Fill in the IP and TCP headers for an outgoing packet, given the tcpcb. * tcp_template used to store this data in mbufs, but we now recopy it out @@ -1239,7 +1225,7 @@ * depends on this property. In addition, these ISNs should be * unguessable so as to prevent connection hijacking. To satisfy * the requirements of this situation, the algorithm outlined in - * RFC 1948 is used, with only small modifications. + * RFC 1948 is used to generate sequence numbers. * * Implementation details: * @@ -1248,18 +1234,6 @@ * recycling on high speed LANs while still leaving over an hour * before rollover. * - * As reading the *exact* system time is too expensive to be done - * whenever setting up a TCP connection, we increment the time - * offset in two ways. First, a small random positive increment - * is added to isn_offset for each connection that is set up. - * Second, the function tcp_isn_tick fires once per clock tick - * and increments isn_offset as necessary so that sequence numbers - * are incremented at approximately ISN_BYTES_PER_SECOND. The - * random positive increments serve only to ensure that the same - * exact sequence number is never sent out twice (as could otherwise - * happen when a port is recycled in less than the system tick - * interval.) - * * net.inet.tcp.isn_reseed_interval controls the number of seconds * between seeding of isn_secret. This is normally set to zero, * as reseeding should not be necessary. @@ -1267,12 +1241,9 @@ */ #define ISN_BYTES_PER_SECOND 1048576 -#define ISN_STATIC_INCREMENT 4096 -#define ISN_RANDOM_INCREMENT (4096 - 1) u_char isn_secret[32]; int isn_last_reseed; -u_int32_t isn_offset, isn_offset_old; MD5_CTX isn_ctx; tcp_seq @@ -1311,33 +1282,11 @@ MD5Update(&isn_ctx, (u_char *) &isn_secret, sizeof(isn_secret)); MD5Final((u_char *) &md5_buffer, &isn_ctx); new_isn = (tcp_seq) md5_buffer[0]; - isn_offset += ISN_STATIC_INCREMENT + - (arc4random() & ISN_RANDOM_INCREMENT); - new_isn += isn_offset; + new_isn += ticks * (ISN_BYTES_PER_SECOND / hz); return new_isn; } /* - * Increment the offset to the next ISN_BYTES_PER_SECOND / hz boundary - * to keep time flowing at a relatively constant rate. If the random - * increments have already pushed us past the projected offset, do nothing. - */ -static void -tcp_isn_tick(xtp) - void *xtp; -{ - u_int32_t projected_offset; - - projected_offset = isn_offset_old + ISN_BYTES_PER_SECOND / hz; - - if (projected_offset > isn_offset) - isn_offset = projected_offset; - - isn_offset_old = isn_offset; - callout_reset(&isn_callout, 1, tcp_isn_tick, NULL); -} - -/* * When a source quench is received, close congestion window * to one segment. We will gradually open it again as we proceed. */ --- //depot/vendor/freebsd/src/sys/netinet/tcp_var.h 2004/04/25 20:01:21 +++ //depot/user/jhb/acpipci/netinet/tcp_var.h 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.105 2004/04/26 02:56:31 silby Exp $ + * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.102 2004/04/07 20:46:14 imp Exp $ */ #ifndef _NETINET_TCP_VAR_H_ @@ -215,7 +215,7 @@ #define TOF_MSS 0x0010 #define TOF_SCALE 0x0020 #define TOF_SIGNATURE 0x0040 /* signature option present */ -#define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */ +#define TOF_SIGLEN 0x0080 /* sigature length valid (RFC2385) */ u_int32_t to_tsval; u_int32_t to_tsecr; tcp_cc to_cc; /* holds CC or CCnew */ @@ -414,7 +414,6 @@ u_long tcps_badsyn; /* bogus SYN, e.g. premature ACK */ u_long tcps_mturesent; /* resends due to MTU discovery */ u_long tcps_listendrop; /* listen queue overflows */ - u_long tcps_badrst; /* ignored RSTs in the window */ u_long tcps_sc_added; /* entry added to syncache */ u_long tcps_sc_retransmitted; /* syncache entry was retransmitted */ @@ -519,7 +518,6 @@ void tcp_drain(void); void tcp_fasttimo(void); void tcp_init(void); -void tcp_fini(void *); void tcp_reass_init(void); void tcp_input(struct mbuf *, int); u_long tcp_maxmtu(struct in_conninfo *); --- //depot/vendor/freebsd/src/sys/netinet6/nd6.c 2004/04/26 13:35:32 +++ //depot/user/jhb/acpipci/netinet6/nd6.c 2004/04/19 12:55:20 @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/netinet6/nd6.c,v 1.43 2004/04/26 20:31:46 luigi Exp $ */ +/* $FreeBSD: src/sys/netinet6/nd6.c,v 1.41 2004/04/19 07:48:48 luigi Exp $ */ /* $KAME: nd6.c,v 1.144 2001/05/24 07:44:00 itojun Exp $ */ /* @@ -2032,23 +2032,22 @@ } int -nd6_storelladdr(ifp, rt0, m, dst, desten) +nd6_storelladdr(ifp, rt, m, dst, desten) struct ifnet *ifp; - struct rtentry *rt0; + struct rtentry *rt; struct mbuf *m; struct sockaddr *dst; u_char *desten; { int i; struct sockaddr_dl *sdl; - struct rtentry *rt; if (m->m_flags & M_MCAST) { switch (ifp->if_type) { case IFT_ETHER: case IFT_FDDI: #ifdef IFT_L2VLAN - case IFT_L2VLAN: + case IFT_L2VLAN: #endif #ifdef IFT_IEEE80211 case IFT_IEEE80211: @@ -2056,7 +2055,7 @@ case IFT_ISO88025: ETHER_MAP_IPV6_MULTICAST(&SIN6(dst)->sin6_addr, desten); - return (0); + return (1); case IFT_IEEE1394: /* * netbsd can use if_broadcastaddr, but we don't do so @@ -2064,42 +2063,36 @@ */ for (i = 0; i < ifp->if_addrlen; i++) desten[i] = ~0; - return (0); + return (1); case IFT_ARCNET: *desten = 0; - return (0); + return (1); default: m_freem(m); - return (EAFNOSUPPORT); + return (0); } } - i = rt_check(&rt, &rt0, dst); - if (i) { - m_freem(m); - return i; - } - if (rt == NULL) { /* this could happen, if we could not allocate memory */ m_freem(m); - return (ENOMEM); + return (0); } if (rt->rt_gateway->sa_family != AF_LINK) { printf("nd6_storelladdr: something odd happens\n"); m_freem(m); - return (EINVAL); + return (0); } sdl = SDL(rt->rt_gateway); if (sdl->sdl_alen == 0) { /* this should be impossible, but we bark here for debugging */ printf("nd6_storelladdr: sdl_alen == 0\n"); m_freem(m); - return (EINVAL); + return (0); } bcopy(LLADDR(sdl), desten, sdl->sdl_alen); - return (0); + return (1); } static int nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS); --- //depot/vendor/freebsd/src/sys/netipsec/xform_tcp.c 2004/04/20 07:56:50 +++ //depot/user/jhb/acpipci/netipsec/xform_tcp.c 2004/04/16 11:09:59 @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/netipsec/xform_tcp.c,v 1.3 2004/04/20 14:53:35 bms Exp $ */ +/* $FreeBSD: src/sys/netipsec/xform_tcp.c,v 1.2 2004/04/03 05:31:38 bms Exp $ */ /* * Copyright (c) 2003 Bruce M. Simpson @@ -86,7 +86,7 @@ if (sav->spi != htonl(TCP_SIG_SPI)) { DPRINTF(("%s: SPI must be TCP_SIG_SPI (0x1000)\n", - __func__)); + __func__, sav->alg_auth)); return (EINVAL); } if (sav->alg_auth != SADB_X_AALG_TCP_MD5) { --- //depot/vendor/freebsd/src/sys/pc98/pc98/fd.c 2004/04/25 05:45:25 +++ //depot/user/jhb/acpipci/pc98/pc98/fd.c 2004/04/01 11:35:50 @@ -50,7 +50,7 @@ * SUCH DAMAGE. * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 - * $FreeBSD: src/sys/pc98/pc98/fd.c,v 1.147 2004/04/25 12:43:44 nyan Exp $ + * $FreeBSD: src/sys/pc98/pc98/fd.c,v 1.146 2004/03/28 13:40:23 nyan Exp $ */ #include "opt_fdc.h" @@ -3105,16 +3105,9 @@ return (0); case FD_STYPE: /* set drive type */ - /* - * Allow setting drive type temporarily iff - * currently unset. Used for fdformat so any - * user can set it, and then start formatting. - */ - if (fd->ft) - return (EINVAL); /* already set */ + if (suser(td) != 0) + return (EPERM); fd->fts[0] = *(struct fd_type *)addr; - fd->ft = &fd->fts[0]; - fd->flags |= FD_UA; return (0); case FD_GOPTS: /* get drive options */ --- //depot/vendor/freebsd/src/sys/pci/agp.c 2004/04/24 13:55:36 +++ //depot/user/jhb/acpipci/pci/agp.c 2004/03/26 08:52:16 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/pci/agp.c,v 1.39 2004/04/24 20:53:54 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/pci/agp.c,v 1.38 2004/03/17 17:50:52 njl Exp $"); #include "opt_bus.h" @@ -524,6 +524,8 @@ m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i), VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY); VM_OBJECT_UNLOCK(mem->am_obj); + if ((m->flags & PG_ZERO) == 0) + pmap_zero_page(m); AGP_DPF("found page pa=%#x\n", VM_PAGE_TO_PHYS(m)); /* --- //depot/vendor/freebsd/src/sys/pci/agp_i810.c 2004/04/24 13:55:36 +++ //depot/user/jhb/acpipci/pci/agp_i810.c 2004/04/16 11:09:59 @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/pci/agp_i810.c,v 1.28 2004/04/24 20:53:54 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/pci/agp_i810.c,v 1.27 2004/04/03 22:55:12 njl Exp $"); #include "opt_bus.h" @@ -612,6 +612,8 @@ m = vm_page_grab(mem->am_obj, 0, VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY); VM_OBJECT_UNLOCK(mem->am_obj); + if ((m->flags & PG_ZERO) == 0) + pmap_zero_page(m); vm_page_lock_queues(); mem->am_physical = VM_PAGE_TO_PHYS(m); vm_page_wakeup(m); --- //depot/vendor/freebsd/src/sys/pci/amdpm.c 2004/04/20 06:40:39 +++ //depot/user/jhb/acpipci/pci/amdpm.c 2004/03/26 08:52:16 @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/pci/amdpm.c,v 1.13 2004/04/20 13:36:44 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/pci/amdpm.c,v 1.12 2004/03/17 17:50:53 njl Exp $"); #include #include @@ -68,7 +68,6 @@ #define AMDPM_DEVICEID_AMD756PM 0x740b #define AMDPM_DEVICEID_AMD766PM 0x7413 #define AMDPM_DEVICEID_AMD768PM 0x7443 -#define AMDPM_DEVICEID_AMD8111PM 0x746A /* nVidia nForce chipset */ #define AMDPM_VENDORID_NVIDIA 0x10de @@ -151,9 +150,8 @@ if ((vid == AMDPM_VENDORID_AMD) && ((did == AMDPM_DEVICEID_AMD756PM) || (did == AMDPM_DEVICEID_AMD766PM) || - (did == AMDPM_DEVICEID_AMD768PM) || - (did == AMDPM_DEVICEID_AMD8111PM))) { - device_set_desc(dev, "AMD 756/766/768/8111 Power Management Controller"); + (did == AMDPM_DEVICEID_AMD768PM))) { + device_set_desc(dev, "AMD 756/766/768 Power Management Controller"); /* * We have to do this, since the BIOS won't give us the --- //depot/vendor/freebsd/src/sys/powerpc/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/powerpc/include/float.h 2004/04/16 11:09:59 @@ -28,20 +28,16 @@ * * from: @(#)float.h 7.1 (Berkeley) 5/8/90 * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 - * $FreeBSD: src/sys/powerpc/include/float.h,v 1.5 2004/04/25 02:36:29 das Exp $ + * $FreeBSD: src/sys/powerpc/include/float.h,v 1.4 2004/04/07 04:59:59 imp Exp $ */ #ifndef _MACHINE_FLOAT_H_ #define _MACHINE_FLOAT_H_ 1 -#include - #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS 1 /* FP addition rounds to nearest */ -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD 1 /* operands promoted to double */ #define DECIMAL_DIG 35 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/powerpc/include/param.h 2004/04/21 16:01:36 +++ //depot/user/jhb/acpipci/powerpc/include/param.h 2004/02/18 13:44:48 @@ -35,13 +35,15 @@ * SUCH DAMAGE. * * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $FreeBSD: src/sys/powerpc/include/param.h,v 1.14 2004/04/21 22:58:39 grehan Exp $ + * $FreeBSD: src/sys/powerpc/include/param.h,v 1.13 2004/02/11 07:27:34 grehan Exp $ */ /* * Machine dependent constants for PowerPC (32-bit only currently) */ +#include + /* * Round p (pointer or byte index) up to a correctly-aligned value * for all data types (int, long, ...). The result is unsigned int --- //depot/vendor/freebsd/src/sys/powerpc/include/pmap.h 2004/04/21 16:01:36 +++ //depot/user/jhb/acpipci/powerpc/include/pmap.h 2004/04/16 11:09:59 @@ -29,14 +29,13 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $ - * $FreeBSD: src/sys/powerpc/include/pmap.h,v 1.15 2004/04/21 22:59:33 grehan Exp $ + * $FreeBSD: src/sys/powerpc/include/pmap.h,v 1.14 2004/04/11 06:02:23 alc Exp $ */ #ifndef _MACHINE_PMAP_H_ #define _MACHINE_PMAP_H_ #include -#include #if !defined(NPMAPS) #define NPMAPS 32768 --- //depot/vendor/freebsd/src/sys/powerpc/powermac/ata_kauai.c 2004/04/23 16:40:40 +++ //depot/user/jhb/acpipci/powerpc/powermac/ata_kauai.c 2004/04/01 11:35:50 @@ -26,7 +26,7 @@ * */ #include -__FBSDID("$FreeBSD: src/sys/powerpc/powermac/ata_kauai.c,v 1.4 2004/04/23 23:39:53 grehan Exp $"); +__FBSDID("$FreeBSD: src/sys/powerpc/powermac/ata_kauai.c,v 1.3 2004/03/31 07:40:46 grehan Exp $"); /* * Mac 'Kauai' PCI ATA controller @@ -169,7 +169,6 @@ } ch = device_get_softc(dev); - bzero(ch, sizeof(struct ata_channel)); rid = PCIR_BARS; mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); @@ -193,7 +192,6 @@ ch->locking = ata_kauai_locknoop; ch->device[MASTER].setmode = ata_kauai_setmode; ch->device[SLAVE].setmode = ata_kauai_setmode; - ata_generic_hw(ch); return (ata_probe(dev)); } --- //depot/vendor/freebsd/src/sys/powerpc/powermac/ata_macio.c 2004/04/23 16:40:40 +++ //depot/user/jhb/acpipci/powerpc/powermac/ata_macio.c 2004/01/27 10:15:19 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/powerpc/powermac/ata_macio.c,v 1.10 2004/04/23 23:39:53 grehan Exp $ + * $FreeBSD: src/sys/powerpc/powermac/ata_macio.c,v 1.9 2004/01/15 23:52:32 grehan Exp $ */ /* @@ -50,9 +50,9 @@ #include #include -/* +/* * Offset to control registers from base - */ +*/ #define ATA_MACIO_ALTOFFSET 0x160 /* @@ -109,14 +109,14 @@ return (ENXIO); ch = device_get_softc(dev); - bzero(ch, sizeof(struct ata_channel)); rid = 0; - mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~1, 1, + RF_ACTIVE); if (mem == NULL) { device_printf(dev, "could not allocate memory\n"); return (ENXIO); - } + } /* * Set up the resource vectors @@ -128,12 +128,11 @@ ch->r_io[ATA_ALTSTAT].res = mem; ch->r_io[ATA_ALTSTAT].offset = ATA_MACIO_ALTOFFSET; - ch->unit = 0; + ch->unit = 0; ch->flags |= ATA_USE_16BIT; ch->locking = ata_macio_locknoop; ch->device[MASTER].setmode = ata_macio_setmode; ch->device[SLAVE].setmode = ata_macio_setmode; - ata_generic_hw(ch); return (ata_probe(dev)); } --- //depot/vendor/freebsd/src/sys/sparc64/include/float.h 2004/04/24 19:38:09 +++ //depot/user/jhb/acpipci/sparc64/include/float.h 2004/04/16 11:09:59 @@ -32,7 +32,7 @@ * * @(#)float.h 8.1 (Berkeley) 6/11/93 * from: NetBSD: float.h,v 1.3 2001/09/21 20:48:02 eeh Exp - * $FreeBSD: src/sys/sparc64/include/float.h,v 1.5 2004/04/25 02:36:29 das Exp $ + * $FreeBSD: src/sys/sparc64/include/float.h,v 1.4 2004/04/07 05:00:00 imp Exp $ */ #ifndef _MACHINE_FLOAT_H_ @@ -46,10 +46,8 @@ #define FLT_RADIX 2 /* b */ #define FLT_ROUNDS __flt_rounds() -#if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD 0 /* no promotion */ #define DECIMAL_DIG 35 /* max precision in decimal digits */ -#endif #define FLT_MANT_DIG 24 /* p */ #define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */ --- //depot/vendor/freebsd/src/sys/sparc64/pci/psycho.c 2004/04/24 17:35:20 +++ //depot/user/jhb/acpipci/sparc64/pci/psycho.c 2004/01/02 13:35:01 @@ -28,7 +28,7 @@ * * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp * - * $FreeBSD: src/sys/sparc64/pci/psycho.c,v 1.46 2004/04/25 00:30:28 tmm Exp $ + * $FreeBSD: src/sys/sparc64/pci/psycho.c,v 1.45 2003/12/26 14:04:19 obrien Exp $ */ /* @@ -74,6 +74,7 @@ #include "pcib_if.h" +static void psycho_get_ranges(phandle_t, struct upa_ranges **, int *); static void psycho_set_intr(struct psycho_softc *, int, device_t, bus_addr_t, int, driver_intr_t); static int psycho_find_intrmap(struct psycho_softc *, int, bus_addr_t *, @@ -200,8 +201,8 @@ * the IIi. The APB let's the IIi handle two independednt PCI buses, and * appears as two "simba"'s underneath the sabre. * - * "psycho" and "psycho+" are dual UPA to PCI bridges. They sit on the UPA bus - * and manage two PCI buses. "psycho" has two 64-bit 33MHz buses, while + * "psycho" and "psycho+" is a dual UPA to PCI bridge. It sits on the UPA bus + * and manages two PCI buses. "psycho" has two 64-bit 33MHz buses, while * "psycho+" controls both a 64-bit 33Mhz and a 64-bit 66Mhz PCI bus. You * will usually find a "psycho+" since I don't think the original "psycho" * ever shipped, and if it did it would be in the U30. @@ -217,6 +218,17 @@ * * On UltraII machines, there can be any number of "psycho+" ICs, each * providing two PCI buses. + * + * + * XXXX The psycho/sabre node has an `interrupts' attribute. They contain + * the values of the following interrupts in this order: + * + * PCI Bus Error (30) + * DMA UE (2e) + * DMA CE (2f) + * Power Fail (25) + * + * We really should attach handlers for each. */ #ifdef DEBUGGER_ON_POWERFAIL #define PSYCHO_PWRFAIL_INT_FLAGS INTR_FAST @@ -290,6 +302,18 @@ return (ENXIO); } +/* + * SUNW,psycho initialisation .. + * - find the per-psycho registers + * - figure out the IGN. + * - find our partner psycho + * - configure ourselves + * - bus range, bus, + * - interrupt map, + * - setup the chipsets. + * - if we're the first of the pair, initialise the IOMMU, otherwise + * just copy it's tags and addresses. + */ static int psycho_attach(device_t dev) { @@ -325,10 +349,11 @@ * (0) per-PBM configuration and status registers * (1) per-PBM PCI configuration space, containing only the * PBM 256-byte PCI header - * (2) the shared psycho configuration registers + * (2) the shared psycho configuration registers (struct psychoreg) */ reg = nexus_get_reg(dev); nreg = nexus_get_nreg(dev); + /* Register layouts are different. stuupid. */ if (sc->sc_mode == PSYCHO_MODE_PSYCHO) { if (nreg <= 2) panic("psycho_attach: %d not enough registers", nreg); @@ -396,7 +421,9 @@ desc->pd_name, (int)PSYCHO_GCSR_IMPL(csr), (int)PSYCHO_GCSR_VERS(csr), sc->sc_ign, 'A' + sc->sc_half); - /* Setup the PCI control register. */ + /* + * Setup the PCI control register + */ csr = PCICTL_READ8(sc, PCR_CS); csr |= PCICTL_MRLM | PCICTL_ARB_PARK | PCICTL_ERRINTEN | PCICTL_4ENABLE; csr &= ~(PCICTL_SERR | PCICTL_CPU_PRIO | PCICTL_ARB_PRIO | @@ -404,7 +431,9 @@ PCICTL_WRITE8(sc, PCR_CS, csr); if (sc->sc_mode == PSYCHO_MODE_SABRE) { - /* Use the PROM preset for now. */ + /* + * Use the PROM preset for now. + */ csr = PCICTL_READ8(sc, PCR_TAS); if (csr == 0) panic("psycho_attach: sabre TAS not initialized."); @@ -412,6 +441,9 @@ } else sc->sc_dvmabase = -1; + /* Grab the psycho ranges */ + psycho_get_ranges(sc->sc_node, &sc->sc_range, &sc->sc_nrange); + /* Initialize memory and i/o rmans */ sc->sc_io_rman.rm_type = RMAN_ARRAY; sc->sc_io_rman.rm_descr = "Psycho PCI I/O Ports"; @@ -423,11 +455,6 @@ if (rman_init(&sc->sc_mem_rman) != 0 || rman_manage_region(&sc->sc_mem_rman, 0, PSYCHO_MEM_SIZE) != 0) panic("psycho_probe: failed to set up memory rman"); - - sc->sc_nrange = OF_getprop_alloc(sc->sc_node, "ranges", - sizeof(*sc->sc_range), (void **)&sc->sc_range); - if (sc->sc_nrange == -1) - panic("could not get psycho ranges"); /* * Find the addresses of the various bus spaces. * There should not be multiple ones of one kind. @@ -572,7 +599,7 @@ sc->sc_secbus = sc->sc_subbus = ofw_pci_alloc_busno(sc->sc_node); /* * Program the bus range registers. - * NOTE: for the psycho, the second write changes the bus number the + * NOTE: the psycho, the second write changes the bus number the * psycho itself uses for it's configuration space, so these * writes must be kept in this order! * The sabre always uses bus 0, but there only can be one sabre per @@ -678,6 +705,16 @@ return (found); } +/* grovel the OBP for various psycho properties */ +static void +psycho_get_ranges(phandle_t node, struct upa_ranges **rp, int *np) +{ + + *np = OF_getprop_alloc(node, "ranges", sizeof(**rp), (void **)rp); + if (*np == -1) + panic("could not get psycho ranges"); +} + /* * Interrupt handlers. */ @@ -697,6 +734,7 @@ */ if ((afsr & UEAFSR_P_DTE) != 0) iommu_decode_fault(sc->sc_is, afar); + /* It's uncorrectable. Dump the regs and panic. */ panic("%s: uncorrectable DMA error AFAR %#lx AFSR %#lx", device_get_name(sc->sc_dev), (u_long)afar, (u_long)afsr); } @@ -709,6 +747,7 @@ afar = PSYCHO_READ8(sc, PSR_CE_AFA); afsr = PSYCHO_READ8(sc, PSR_CE_AFS); + /* It's correctable. Dump the regs and continue. */ device_printf(sc->sc_dev, "correctable DMA error AFAR %#lx " "AFSR %#lx\n", (u_long)afar, (u_long)afsr); /* Clear the error bits that we caught. */ @@ -724,6 +763,7 @@ afar = PSYCHO_READ8(sc, PSR_PCICTL0 + PCR_AFA); afsr = PSYCHO_READ8(sc, PSR_PCICTL0 + PCR_AFS); + /* It's uncorrectable. Dump the regs and panic. */ panic("%s: PCI bus A error AFAR %#lx AFSR %#lx", device_get_name(sc->sc_dev), (u_long)afar, (u_long)afsr); } @@ -736,6 +776,7 @@ afar = PSYCHO_READ8(sc, PSR_PCICTL1 + PCR_AFA); afsr = PSYCHO_READ8(sc, PSR_PCICTL1 + PCR_AFS); + /* It's uncorrectable. Dump the regs and panic. */ panic("%s: PCI bus B error AFAR %#lx AFSR %#lx", device_get_name(sc->sc_dev), (u_long)afar, (u_long)afsr); } @@ -744,6 +785,7 @@ psycho_powerfail(void *arg) { + /* We lost power. Try to shut down NOW. */ #ifdef DEBUGGER_ON_POWERFAIL struct psycho_softc *sc = (struct psycho_softc *)arg; @@ -767,6 +809,7 @@ } #endif /* PSYCHO_MAP_WAKEUP */ +/* initialise the IOMMU... */ void psycho_iommu_init(struct psycho_softc *sc, int tsbsize) { @@ -787,7 +830,7 @@ name = (char *)malloc(32, M_DEVBUF, M_NOWAIT); if (name == 0) panic("couldn't malloc iommu name"); - snprintf(name, 32, "%s dvma", device_get_nameunit(sc->sc_dev)); + snprintf(name, 32, "%s dvma", device_get_name(sc->sc_dev)); iommu_init(name, is, tsbsize, sc->sc_dvmabase, 0); } @@ -955,7 +998,7 @@ /* * If this is outside of the range for an intpin, it's likely a full * INO, and no mapping is required at all; this happens on the u30, - * where there's no interrupt map at the psycho node. Fortunately, + * where there's no interrupt map at the psycho node. Fortunately, * there seem to be no INOs in the intpin range on this boxen, so * this easy heuristics will do. */ @@ -1042,7 +1085,7 @@ * interrupt vector. * * XXX We only compare INOs rather than IGNs since the firmware may - * not provide the IGN and the IGN is constant for all devices on that + * not provide the IGN and the IGN is constant for all device on that * PCI controller. This could cause problems for the FFB/external * interrupt which has a full vector that can be set arbitrarily. */ @@ -1131,8 +1174,8 @@ if (start != end) panic("psycho_alloc_resource: XXX: interrupt range"); start = end |= sc->sc_ign; - return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, - rid, start, end, count, flags)); + return (bus_alloc_resource(bus, type, rid, start, end, + count, flags)); } switch (type) { case SYS_RES_MEMORY: @@ -1175,8 +1218,7 @@ int error; if (type == SYS_RES_IRQ) - return (BUS_ACTIVATE_RESOURCE(device_get_parent(bus), child, - type, rid, r)); + return (bus_activate_resource(bus, type, rid, r)); if (type == SYS_RES_MEMORY) { /* * Need to memory-map the device space, as some drivers depend @@ -1197,8 +1239,7 @@ { if (type == SYS_RES_IRQ) - return (BUS_DEACTIVATE_RESOURCE(device_get_parent(bus), child, - type, rid, r)); + return (bus_deactivate_resource(bus, type, rid, r)); if (type == SYS_RES_MEMORY) { sparc64_bus_mem_unmap(rman_get_virtual(r), rman_get_size(r)); rman_set_virtual(r, NULL); @@ -1213,8 +1254,7 @@ int error; if (type == SYS_RES_IRQ) - return (BUS_RELEASE_RESOURCE(device_get_parent(bus), child, - type, rid, r)); + return (bus_release_resource(bus, type, rid, r)); if (rman_get_flags(r) & RF_ACTIVE) { error = bus_deactivate_resource(child, type, rid, r); if (error) @@ -1313,6 +1353,9 @@ } #endif +/* + * below here is bus space and bus dma support + */ static bus_space_tag_t psycho_alloc_bus_tag(struct psycho_softc *sc, int type) { --- //depot/vendor/freebsd/src/sys/sparc64/pci/psychoreg.h 2004/04/24 17:35:20 +++ //depot/user/jhb/acpipci/sparc64/pci/psychoreg.h 2003/09/09 13:40:27 @@ -28,7 +28,7 @@ * * from: NetBSD: psychoreg.h,v 1.8 2001/09/10 16:17:06 eeh Exp * - * $FreeBSD: src/sys/sparc64/pci/psychoreg.h,v 1.8 2004/04/25 00:30:28 tmm Exp $ + * $FreeBSD: src/sys/sparc64/pci/psychoreg.h,v 1.7 2003/09/04 15:25:10 tmm Exp $ */ #ifndef _SPARC64_PCI_PSYCHOREG_H_ @@ -46,7 +46,7 @@ */ /* - * psycho register offsets. + * psycho register offset.s * * NB: FFB0 and FFB1 intr map regs also appear at 0x6000 and 0x8000 * respectively. @@ -266,4 +266,52 @@ #define PCSR_SECBUS 0x40 /* Secondary bus number register */ #define PCSR_SUBBUS 0x41 /* Subordinate bus number register */ +/* + * these are the PROM structures we grovel + */ + +/* + * For the physical adddresses split into 3 32 bit values, we deocde + * them like the following (IEEE1275 PCI Bus binding 2.0, 2.2.1.1 + * Numerical Representation): + * + * phys.hi cell: npt000ss bbbbbbbb dddddfff rrrrrrrr + * phys.mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh + * phys.lo cell: llllllll llllllll llllllll llllllll + * + * where these bits affect the address' properties: + * n not-relocatable + * p prefetchable + * t aliased (non-relocatable IO), below 1MB (memory) or + * below 64KB (reloc. IO) + * ss address space code: + * 00 - configuration space + * 01 - I/O space + * 10 - 32 bit memory space + * 11 - 64 bit memory space + * bb..bb 8 bit bus number + * ddddd 5 bit device number + * fff 3 bit function number + * rr..rr 8 bit register number + * hh..hh 32 bit unsigned value + * ll..ll 32 bit unsigned value + * the values of hh..hh and ll..ll are combined to form a larger number. + * + * For config space, we don't have to do much special. For I/O space, + * hh..hh must be zero, and if n == 0 ll..ll is the offset from the + * start of I/O space, otherwise ll..ll is the I/O space. For memory + * space, hh..hh must be zero for the 32 bit space, and is the high 32 + * bits in 64 bit space, with ll..ll being the low 32 bits in both cases, + * with offset handling being driver via `n == 0' as for I/O space. + */ + +/* commonly used */ +#define TAG2BUS(tag) ((tag) >> 16) & 0xff; +#define TAG2DEV(tag) ((tag) >> 11) & 0x1f; +#define TAG2FN(tag) ((tag) >> 8) & 0x7; + +#define INTPCI_MAXOBINO 0x16 /* maximum OBIO INO value for PCI */ +#define INTPCIOBINOX(x) ((x) & 0x1f) /* OBIO ino index (for PCI machines) */ +#define INTPCIINOX(x) (((x) & 0x1c) >> 2) /* PCI ino index */ + #endif /* _SPARC64_PCI_PSYCHOREG_H_ */ --- //depot/vendor/freebsd/src/sys/sparc64/pci/psychovar.h 2004/04/24 17:35:20 +++ //depot/user/jhb/acpipci/sparc64/pci/psychovar.h 2003/07/01 11:39:43 @@ -27,24 +27,28 @@ * * from: NetBSD: psychovar.h,v 1.6 2001/07/20 00:07:13 eeh Exp * - * $FreeBSD: src/sys/sparc64/pci/psychovar.h,v 1.10 2004/04/25 00:30:28 tmm Exp $ + * $FreeBSD: src/sys/sparc64/pci/psychovar.h,v 1.9 2003/07/01 14:52:47 tmm Exp $ */ #ifndef _SPARC64_PCI_PSYCHOVAR_H_ #define _SPARC64_PCI_PSYCHOVAR_H_ /* - * Per-PCI bus on mainbus softc structure; one for sabre, or two - * per pair of psychos. + * per-PCI bus on mainbus softc structure; one for sabre, or two + * per pair of psycho's. */ struct psycho_softc { device_t sc_dev; + /* + * PSYCHO register. we record the base physical address of these + * also as it is the base of the entire PSYCHO + */ vm_paddr_t sc_basepaddr; /* Interrupt Group Number for this device */ int sc_ign; - /* Our tags (from parent). */ + /* our tags (from parent) */ bus_space_tag_t sc_bustag; bus_space_handle_t sc_bushandle; bus_dma_tag_t sc_dmatag; @@ -52,7 +56,7 @@ bus_addr_t sc_pcictl; int sc_clockfreq; - phandle_t sc_node; /* Firmware node. */ + phandle_t sc_node; /* prom node */ int sc_mode; #define PSYCHO_MODE_SABRE 1 #define PSYCHO_MODE_PSYCHO 2 @@ -71,10 +75,15 @@ struct ofw_bus_iinfo sc_iinfo; #endif + /* + * note that the sabre really only has one ranges property, + * used for both simba a and simba b (but the ranges for + * real psychos are the same for PCI A and PCI B anyway). + */ struct upa_ranges *sc_range; int sc_nrange; - /* Tags for PCI access. */ + /* our tags */ bus_space_tag_t sc_cfgt; bus_space_tag_t sc_memt; bus_space_tag_t sc_iot; --- //depot/vendor/freebsd/src/sys/sparc64/sparc64/iommu.c 2004/04/24 17:10:37 +++ //depot/user/jhb/acpipci/sparc64/sparc64/iommu.c 2004/04/16 11:09:59 @@ -97,7 +97,7 @@ * from: @(#)sbus.c 8.1 (Berkeley) 6/11/93 * from: NetBSD: iommu.c,v 1.42 2001/08/06 22:02:58 eeh Exp * - * $FreeBSD: src/sys/sparc64/sparc64/iommu.c,v 1.36 2004/04/25 00:08:15 tmm Exp $ + * $FreeBSD: src/sys/sparc64/sparc64/iommu.c,v 1.35 2004/04/07 05:00:01 imp Exp $ */ /* @@ -361,7 +361,7 @@ is->is_dvmabase = IOTSB_VSTART(is->is_tsbsize); size = IOTSB_BASESZ << is->is_tsbsize; - printf("%s: DVMA map: %#lx to %#lx\n", name, + printf("DVMA map: %#lx to %#lx\n", is->is_dvmabase, is->is_dvmabase + (size << (IO_PAGE_SHIFT - IOTTE_SHIFT)) - 1); --- //depot/vendor/freebsd/src/sys/sys/callout.h 2004/04/20 08:50:49 +++ //depot/user/jhb/acpipci/sys/callout.h 2004/04/16 11:09:59 @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * @(#)callout.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD: src/sys/sys/callout.h,v 1.27 2004/04/20 15:49:31 cperciva Exp $ + * $FreeBSD: src/sys/sys/callout.h,v 1.26 2004/04/07 04:19:49 imp Exp $ */ #ifndef _SYS_CALLOUT_H_ @@ -73,11 +73,12 @@ #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) -#define callout_drain(c) _callout_stop_safe(c, 1) void callout_init(struct callout *, int); #define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING) void callout_reset(struct callout *, int, void (*)(void *), void *); +int callout_stop(struct callout *); #define callout_stop(c) _callout_stop_safe(c, 0) +#define callout_drain(c) _callout_stop_safe(c, 1) int _callout_stop_safe(struct callout *, int); #endif --- //depot/vendor/freebsd/src/sys/sys/imgact.h 2004/04/23 23:45:20 +++ //depot/user/jhb/acpipci/sys/imgact.h 2004/04/16 11:09:59 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/sys/imgact.h,v 1.36 2004/04/24 06:44:33 bde Exp $ + * $FreeBSD: src/sys/sys/imgact.h,v 1.34 2004/04/07 04:19:49 imp Exp $ */ #ifndef _SYS_IMGACT_H_ @@ -34,6 +34,11 @@ #define MAXSHELLCMDLEN 128 +struct label; +struct sysentvec; +struct thread; +struct vm_object; + struct image_params { struct proc *proc; /* our process struct */ char **userspace_argv; /* system call argument */ @@ -54,16 +59,13 @@ char interpreted; /* flag - this executable is interpreted */ char interpreter_name[MAXSHELLCMDLEN]; /* name of the interpreter */ void *auxargs; /* ELF Auxinfo structure pointer */ - struct sf_buf *firstpage; /* first page that we mapped */ + struct vm_page *firstpage; /* first page that we mapped */ char *fname; /* pointer to filename of executable (user space) */ unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */ size_t auxarg_size; }; #ifdef _KERNEL -struct sysentvec; -struct thread; - int exec_check_permissions(struct image_params *); register_t *exec_copyout_strings(struct image_params *); int exec_extract_strings(struct image_params *); --- //depot/vendor/freebsd/src/sys/sys/jail.h 2004/04/26 12:50:50 +++ //depot/user/jhb/acpipci/sys/jail.h 2004/02/18 13:44:48 @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $FreeBSD: src/sys/sys/jail.h,v 1.21 2004/04/26 19:46:52 bmilekic Exp $ + * $FreeBSD: src/sys/sys/jail.h,v 1.20 2004/02/14 18:31:11 rwatson Exp $ * */ @@ -82,7 +82,6 @@ extern int jail_socket_unixiproute_only; extern int jail_sysvipc_allowed; extern int jail_getfsstat_jailrootonly; -extern int jail_allow_raw_sockets; LIST_HEAD(prisonlist, prison); extern struct prisonlist allprison; --- //depot/vendor/freebsd/src/sys/sys/mman.h 2004/04/27 06:15:33 +++ //depot/user/jhb/acpipci/sys/mman.h 2004/04/16 11:09:59 @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)mman.h 8.2 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/sys/mman.h,v 1.39 2004/04/27 13:13:20 mux Exp $ + * $FreeBSD: src/sys/sys/mman.h,v 1.38 2004/04/07 04:19:49 imp Exp $ */ #ifndef _SYS_MMAN_H_ @@ -163,8 +163,8 @@ __BEGIN_DECLS /* - * XXX not yet implemented: posix_mem_offset(), posix_typed_mem_get_info(), - * posix_typed_mem_open(). + * XXX not yet implemented: mlockall(), munlockall(), + * posix_mem_offset(), posix_typed_mem_get_info(), posix_typed_mem_open(). */ #if __BSD_VISIBLE int madvise(void *, size_t, int); --- //depot/vendor/freebsd/src/sys/sys/types.h 2004/04/19 15:50:39 +++ //depot/user/jhb/acpipci/sys/types.h 2004/04/16 11:09:59 @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * @(#)types.h 8.6 (Berkeley) 2/19/95 - * $FreeBSD: src/sys/sys/types.h,v 1.86 2004/04/19 22:49:00 obrien Exp $ + * $FreeBSD: src/sys/sys/types.h,v 1.85 2004/04/07 04:19:50 imp Exp $ */ #ifndef _SYS_TYPES_H_ @@ -49,11 +49,9 @@ typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; -#ifndef _KERNEL typedef unsigned short ushort; /* Sys V compatibility */ typedef unsigned int uint; /* Sys V compatibility */ #endif -#endif /* * XXX POSIX sized integrals that should appear only in . --- //depot/vendor/freebsd/src/sys/ufs/ffs/ffs_vfsops.c 2004/04/26 08:15:19 +++ //depot/user/jhb/acpipci/ufs/ffs/ffs_vfsops.c 2004/04/16 11:09:59 @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_vfsops.c,v 1.231 2004/04/26 15:13:46 bmilekic Exp $"); +__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_vfsops.c,v 1.230 2004/04/07 03:47:20 imp Exp $"); #include "opt_mac.h" #include "opt_quota.h" @@ -1062,9 +1062,6 @@ fs = ump->um_fs; if (fs->fs_magic != FS_UFS1_MAGIC && fs->fs_magic != FS_UFS2_MAGIC) panic("ffs_statfs"); - if (fs->fs_magic == FS_UFS2_MAGIC) - bcopy((caddr_t)"ufs2", - (caddr_t)&sbp->f_fstypename[0], MFSNAMELEN); sbp->f_version = STATFS_VERSION; sbp->f_bsize = fs->fs_fsize; sbp->f_iosize = fs->fs_bsize; @@ -1085,12 +1082,8 @@ sbp->f_asyncreads = mp->mnt_stat.f_asyncreads; sbp->f_owner = mp->mnt_stat.f_owner; sbp->f_fsid = mp->mnt_stat.f_fsid; - if (fs->fs_magic == FS_UFS2_MAGIC) - bcopy((caddr_t)"ufs2", - (caddr_t)&sbp->f_fstypename[0], MFSNAMELEN); - else - bcopy((caddr_t)mp->mnt_stat.f_fstypename, - (caddr_t)&sbp->f_fstypename[0], MFSNAMELEN); + bcopy((caddr_t)mp->mnt_stat.f_fstypename, + (caddr_t)&sbp->f_fstypename[0], MFSNAMELEN); bcopy((caddr_t)mp->mnt_stat.f_mntonname, (caddr_t)&sbp->f_mntonname[0], MNAMELEN); bcopy((caddr_t)mp->mnt_stat.f_mntfromname, --- //depot/vendor/freebsd/src/sys/vm/device_pager.c 2004/04/22 23:15:32 +++ //depot/user/jhb/acpipci/vm/device_pager.c 2004/04/16 11:09:59 @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/device_pager.c,v 1.72 2004/04/23 06:10:58 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/device_pager.c,v 1.71 2004/04/06 20:15:36 imp Exp $"); #include #include @@ -213,7 +213,6 @@ dev = object->handle; offset = m[reqpage]->pindex; VM_OBJECT_UNLOCK(object); - mtx_lock(&Giant); prot = PROT_READ; /* XXX should pass in? */ mapfunc = devsw(dev)->d_mmap; @@ -222,8 +221,6 @@ ret = (*mapfunc)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot); KASSERT(ret == 0, ("dev_pager_getpage: map function returns error")); - mtx_unlock(&Giant); - /* * Replace the passed in reqpage page with our own fake page and * free up the all of the original pages. --- //depot/vendor/freebsd/src/sys/vm/phys_pager.c 2004/04/25 01:00:57 +++ //depot/user/jhb/acpipci/vm/phys_pager.c 2004/01/06 10:27:15 @@ -24,7 +24,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/phys_pager.c,v 1.22 2004/04/25 07:58:59 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/phys_pager.c,v 1.20 2004/01/04 20:55:15 alc Exp $"); #include #include @@ -133,28 +133,26 @@ } } -/* - * Fill as many pages as vm_fault has allocated for us. - */ static int phys_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) { - int i; + int i, s; - VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); + s = splvm(); + vm_page_lock_queues(); + /* + * Fill as many pages as vm_fault has allocated for us. + */ for (i = 0; i < count; i++) { - if (m[i]->valid == 0) { - if ((m[i]->flags & PG_ZERO) == 0) - pmap_zero_page(m[i]); - m[i]->valid = VM_PAGE_BITS_ALL; + if ((m[i]->flags & PG_ZERO) == 0) { + vm_page_unlock_queues(); + pmap_zero_page(m[i]); + vm_page_lock_queues(); } - KASSERT(m[i]->valid == VM_PAGE_BITS_ALL, - ("phys_pager_getpages: partially valid page %p", m[i])); - } - vm_page_lock_queues(); - for (i = 0; i < count; i++) { + vm_page_flag_set(m[i], PG_ZERO); /* Switch off pv_entries */ vm_page_unmanage(m[i]); + m[i]->valid = VM_PAGE_BITS_ALL; m[i]->dirty = 0; /* The requested page must remain busy, the others not. */ if (reqpage != i) { @@ -163,6 +161,8 @@ } } vm_page_unlock_queues(); + splx(s); + return (VM_PAGER_OK); } --- //depot/vendor/freebsd/src/sys/vm/vm_kern.c 2004/04/24 13:55:36 +++ //depot/user/jhb/acpipci/vm/vm_kern.c 2004/04/16 11:09:59 @@ -63,7 +63,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/vm_kern.c,v 1.116 2004/04/24 20:53:55 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/vm_kern.c,v 1.115 2004/04/06 20:15:36 imp Exp $"); #include #include @@ -198,6 +198,8 @@ mem = vm_page_grab(kernel_object, OFF_TO_IDX(offset + i), VM_ALLOC_ZERO | VM_ALLOC_RETRY); + if ((mem->flags & PG_ZERO) == 0) + pmap_zero_page(mem); mem->valid = VM_PAGE_BITS_ALL; vm_page_lock_queues(); vm_page_unmanage(mem); --- //depot/vendor/freebsd/src/sys/vm/vm_map.c 2004/04/23 20:50:40 +++ //depot/user/jhb/acpipci/vm/vm_map.c 2004/04/16 11:09:59 @@ -63,7 +63,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.333 2004/04/24 03:46:44 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.332 2004/04/06 20:15:36 imp Exp $"); #include #include @@ -877,7 +877,7 @@ #endif if (cow & (MAP_PREFAULT|MAP_PREFAULT_PARTIAL)) { - vm_map_pmap_enter(map, start, prot, + vm_map_pmap_enter(map, start, object, OFF_TO_IDX(offset), end - start, cow & MAP_PREFAULT_PARTIAL); } @@ -1243,19 +1243,19 @@ /* * vm_map_pmap_enter: * - * Preload read-only mappings for the given object into the specified + * Preload the mappings for the given object into the specified * map. This eliminates the soft faults on process startup and * immediately after an mmap(2). */ void -vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, +vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags) { vm_offset_t tmpidx; int psize; vm_page_t p, mpte; - if ((prot & VM_PROT_READ) == 0 || object == NULL) + if (object == NULL) return; mtx_lock(&Giant); VM_OBJECT_LOCK(object); @@ -1547,7 +1547,6 @@ if (behav == MADV_WILLNEED) { vm_map_pmap_enter(map, useStart, - current->protection, current->object.vm_object, pindex, (count << PAGE_SHIFT), --- //depot/vendor/freebsd/src/sys/vm/vm_map.h 2004/04/23 20:50:40 +++ //depot/user/jhb/acpipci/vm/vm_map.h 2004/04/16 11:09:59 @@ -57,7 +57,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $FreeBSD: src/sys/vm/vm_map.h,v 1.109 2004/04/24 03:46:44 alc Exp $ + * $FreeBSD: src/sys/vm/vm_map.h,v 1.108 2004/04/06 20:15:36 imp Exp $ */ /* @@ -333,7 +333,7 @@ vm_pindex_t *, vm_prot_t *, boolean_t *); void vm_map_lookup_done (vm_map_t, vm_map_entry_t); boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *); -void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, +void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags); int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t); int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t); --- //depot/vendor/freebsd/src/sys/vm/vm_page.c 2004/04/24 14:38:23 +++ //depot/user/jhb/acpipci/vm/vm_page.c 2004/04/16 11:09:59 @@ -97,7 +97,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/vm_page.c,v 1.281 2004/04/24 21:36:23 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/vm_page.c,v 1.279 2004/04/06 20:15:37 imp Exp $"); #include #include @@ -1421,8 +1421,7 @@ /* * Grab a page, waiting until we are waken up due to the page * changing state. We keep on waiting, if the page continues - * to be in the object. If the page doesn't exist, first allocate it - * and then conditionally zero it. + * to be in the object. If the page doesn't exist, allocate it. * * This routine may block. */ @@ -1448,21 +1447,21 @@ vm_page_wire(m); vm_page_busy(m); vm_page_unlock_queues(); - return (m); + return m; } } + m = vm_page_alloc(object, pindex, allocflags & ~VM_ALLOC_RETRY); if (m == NULL) { VM_OBJECT_UNLOCK(object); VM_WAIT; VM_OBJECT_LOCK(object); if ((allocflags & VM_ALLOC_RETRY) == 0) - return (NULL); + return NULL; goto retrylookup; } - if (allocflags & VM_ALLOC_ZERO && (m->flags & PG_ZERO) == 0) - pmap_zero_page(m); - return (m); + + return m; } /* --- //depot/vendor/freebsd/src/sys/vm/vnode_pager.c 2004/04/22 23:15:32 +++ //depot/user/jhb/acpipci/vm/vnode_pager.c 2004/04/16 11:09:59 @@ -51,7 +51,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/vnode_pager.c,v 1.195 2004/04/23 06:10:58 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/vnode_pager.c,v 1.194 2004/04/06 07:12:32 alc Exp $"); #include #include @@ -618,11 +618,9 @@ vp = object->handle; VM_OBJECT_UNLOCK(object); - mtx_lock(&Giant); rtval = VOP_GETPAGES(vp, m, bytes, reqpage, 0); KASSERT(rtval != EOPNOTSUPP, ("vnode_pager: FS getpages not implemented\n")); - mtx_unlock(&Giant); VM_OBJECT_LOCK(object); return rtval; }