Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Dec 2008 18:26:08 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 155334 for review
Message-ID:  <200812271826.mBRIQ84I076591@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=155334

Change 155334 by ed@ed_dull on 2008/12/27 18:26:05

	IFC.

Affected files ...

.. //depot/projects/mpsafetty/Makefile#4 integrate
.. //depot/projects/mpsafetty/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c#2 integrate
.. //depot/projects/mpsafetty/lib/libutil/kinfo_getfile.c#3 integrate
.. //depot/projects/mpsafetty/lib/libutil/kinfo_getvmmap.c#3 integrate
.. //depot/projects/mpsafetty/sbin/geom/misc/subr.c#3 integrate
.. //depot/projects/mpsafetty/sbin/mount/getmntopts.c#2 integrate
.. //depot/projects/mpsafetty/sbin/mount/mount.c#4 integrate
.. //depot/projects/mpsafetty/share/man/man4/ndis.4#2 integrate
.. //depot/projects/mpsafetty/sys/arm/conf/AVILA#8 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/kern_ndis.c#3 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/kern_windrv.c#2 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/ndis_var.h#2 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/ntoskrnl_var.h#3 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/subr_ndis.c#3 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/subr_ntoskrnl.c#2 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/subr_usbd.c#2 integrate
.. //depot/projects/mpsafetty/sys/compat/ndis/usbd_var.h#2 integrate
.. //depot/projects/mpsafetty/sys/dev/cfe/cfe_console.c#4 integrate
.. //depot/projects/mpsafetty/sys/dev/if_ndis/if_ndis.c#6 integrate
.. //depot/projects/mpsafetty/sys/dev/if_ndis/if_ndis_pccard.c#2 integrate
.. //depot/projects/mpsafetty/sys/dev/if_ndis/if_ndis_pci.c#2 integrate
.. //depot/projects/mpsafetty/sys/dev/if_ndis/if_ndis_usb.c#2 integrate
.. //depot/projects/mpsafetty/sys/dev/if_ndis/if_ndisvar.h#3 integrate
.. //depot/projects/mpsafetty/sys/dev/puc/pucdata.c#5 integrate
.. //depot/projects/mpsafetty/sys/dev/sound/pci/hda/hdac.c#13 integrate
.. //depot/projects/mpsafetty/sys/dev/uart/uart_tty.c#6 integrate
.. //depot/projects/mpsafetty/sys/geom/part/g_part_bsd.c#6 integrate
.. //depot/projects/mpsafetty/sys/geom/vinum/geom_vinum_plex.c#3 integrate
.. //depot/projects/mpsafetty/sys/kern/subr_param.c#5 integrate
.. //depot/projects/mpsafetty/sys/kern/vfs_syscalls.c#13 integrate
.. //depot/projects/mpsafetty/sys/modules/ndis/Makefile#2 integrate
.. //depot/projects/mpsafetty/sys/modules/usb2/Makefile#3 integrate
.. //depot/projects/mpsafetty/sys/net/if_tun.c#11 integrate
.. //depot/projects/mpsafetty/sys/net/route.h#7 integrate
.. //depot/projects/mpsafetty/sys/net/rtsock.c#11 integrate
.. //depot/projects/mpsafetty/sys/netinet/in.c#9 integrate
.. //depot/projects/mpsafetty/sys/netinet6/in6.c#9 integrate
.. //depot/projects/mpsafetty/sys/netipsec/ipsec.c#10 integrate
.. //depot/projects/mpsafetty/sys/netipsec/ipsec.h#6 integrate
.. //depot/projects/mpsafetty/usr.bin/make/make.1#3 integrate
.. //depot/projects/mpsafetty/usr.bin/netstat/inet6.c#2 integrate
.. //depot/projects/mpsafetty/usr.bin/top/machine.c#4 integrate
.. //depot/projects/mpsafetty/usr.sbin/arp/arp.c#4 integrate
.. //depot/projects/mpsafetty/usr.sbin/ndiscvt/inf.c#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/ndiscvt/windrv_stub.c#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/ndp/ndp.c#3 integrate
.. //depot/projects/mpsafetty/usr.sbin/pkg_install/add/main.c#3 integrate
.. //depot/projects/mpsafetty/usr.sbin/pkg_install/lib/lib.h#3 integrate
.. //depot/projects/mpsafetty/usr.sbin/pkg_install/lib/plist.c#2 integrate

Differences ...

==== //depot/projects/mpsafetty/Makefile#4 (text+ko) ====

@@ -1,5 +1,5 @@
 #
-# $FreeBSD: src/Makefile,v 1.355 2008/12/01 00:45:51 alfred Exp $
+# $FreeBSD: src/Makefile,v 1.356 2008/12/27 15:07:51 bz Exp $
 #
 # The user-driven targets are:
 #
@@ -298,7 +298,7 @@
 .endif
 .for target in ${TARGETS}
 KERNCONFS!=	cd ${.CURDIR}/sys/${target}/conf && \
-		find [A-Z]*[A-Z] -type f -maxdepth 0 \
+		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
 		! -name DEFAULTS ! -name LINT
 KERNCONFS:=	${KERNCONFS:S/^NOTES$/LINT/}
 universe: universe_${target}

==== //depot/projects/mpsafetty/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c#2 (text+ko) ====

@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stddef.h>
 #include <fcntl.h>
+#include <sys/param.h>
 #include <sys/mount.h>
 #include <sys/mntent.h>
 #include <sys/mnttab.h>

==== //depot/projects/mpsafetty/lib/libutil/kinfo_getfile.c#3 (text+ko) ====

@@ -1,7 +1,7 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libutil/kinfo_getfile.c,v 1.3 2008/12/19 06:47:59 marcus Exp $");
+__FBSDID("$FreeBSD: src/lib/libutil/kinfo_getfile.c,v 1.4 2008/12/27 11:12:23 rwatson Exp $");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/user.h>
 #include <sys/sysctl.h>
 #include <stdlib.h>

==== //depot/projects/mpsafetty/lib/libutil/kinfo_getvmmap.c#3 (text+ko) ====

@@ -1,7 +1,7 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libutil/kinfo_getvmmap.c,v 1.3 2008/12/19 06:47:59 marcus Exp $");
+__FBSDID("$FreeBSD: src/lib/libutil/kinfo_getvmmap.c,v 1.4 2008/12/27 11:12:23 rwatson Exp $");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/user.h>
 #include <sys/sysctl.h>
 #include <stdlib.h>

==== //depot/projects/mpsafetty/sbin/geom/misc/subr.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/geom/misc/subr.c,v 1.9 2008/12/13 14:14:56 lulf Exp $");
+__FBSDID("$FreeBSD: src/sbin/geom/misc/subr.c,v 1.10 2008/12/27 14:24:24 lulf Exp $");
 
 #include <sys/param.h>
 #include <sys/disk.h>
@@ -211,7 +211,7 @@
 	sector = NULL;
 	error = 0;
 
-	fd = open(path, O_RDWR);
+	fd = open(path, O_WRONLY);
 	if (fd == -1)
 		return (errno);
 	mediasize = g_get_mediasize(name);

==== //depot/projects/mpsafetty/sbin/mount/getmntopts.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/mount/getmntopts.c,v 1.18 2005/11/14 17:39:00 rodrigc Exp $");
+__FBSDID("$FreeBSD: src/sbin/mount/getmntopts.c,v 1.19 2008/12/26 22:55:38 obrien Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -130,7 +130,7 @@
 	struct stat sb;
 
 	if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
-		if (!S_ISDIR(sb.st_mode)) 
+		if (!S_ISDIR(sb.st_mode))
 			errx(EX_USAGE, "%s: not a directory", resolved);
 	} else
 		errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
@@ -176,7 +176,7 @@
 	char val[255] = { 0 };
 
 	va_start(ap, fmt);
-	vsnprintf(val, sizeof(val), fmt, ap);  
+	vsnprintf(val, sizeof(val), fmt, ap);
 	va_end(ap);
 	build_iovec(iov, iovlen, name, strdup(val), (size_t)-1);
 }

==== //depot/projects/mpsafetty/sbin/mount/mount.c#4 (text+ko) ====

@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)mount.c	8.25 (Berkeley) 5/8/95";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/sbin/mount/mount.c,v 1.100 2008/12/18 18:44:46 obrien Exp $";
+  "$FreeBSD: src/sbin/mount/mount.c,v 1.102 2008/12/26 22:55:38 obrien Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -145,7 +145,7 @@
 		if (strcmp(vfstype, fs[i]) == 0)
 			return (1);
 	}
-	
+
 	return (0);
 }
 
@@ -210,7 +210,7 @@
 restart_mountd(void)
 {
 	struct pidfh *pfh;
-	pid_t mountdpid; 
+	pid_t mountdpid;
 
 	pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid);
 	if (pfh != NULL) {
@@ -302,7 +302,7 @@
 
 	if ((init_flags & MNT_UPDATE) && (ro == 0))
 		options = catopt(options, "noro");
- 
+
 	rval = 0;
 	switch (argc) {
 	case 0:
@@ -503,9 +503,10 @@
 mountfs(const char *vfstype, const char *spec, const char *name, int flags,
 	const char *options, const char *mntopts)
 {
+	static int argc;
 	char *argv[MAX_ARGS];
 	struct statfs sf;
-	int argc, i, ret;
+	int i, ret;
 	char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX];
 
 	/* resolve the mountpoint with realpath(3) */
@@ -566,7 +567,7 @@
 	if (use_mountprog(vfstype)) {
 		ret = exec_mountprog(name, execname, argv);
 	} else {
-		ret = mount_fs(vfstype, argc, argv); 
+		ret = mount_fs(vfstype, argc, argv);
 	}
 
 	free(optbuf);

==== //depot/projects/mpsafetty/share/man/man4/ndis.4#2 (text+ko) ====

@@ -28,7 +28,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 .\" THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man4/ndis.4,v 1.1 2008/08/21 00:40:55 rpaulo Exp $
+.\" $FreeBSD: src/share/man/man4/ndis.4,v 1.2 2008/12/27 08:03:32 weongyo Exp $
 .\"
 .Dd October 13, 2006
 .Dt NDIS 4 i386
@@ -105,7 +105,7 @@
 The
 .Nm
 driver is designed to support mainly Ethernet and wireless
-network devices with PCI and PCMCIA bus attachments.
+network devices with PCI, PCMCIA and USB bus attachments.
 (Cardbus
 devices are also supported as a subset of PCI.)
 It can

==== //depot/projects/mpsafetty/sys/arm/conf/AVILA#8 (text+ko) ====

@@ -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/arm/conf/AVILA,v 1.20 2008/12/20 03:26:09 sam Exp $
+# $FreeBSD: src/sys/arm/conf/AVILA,v 1.21 2008/12/27 17:22:17 bz Exp $
 
 ident		AVILA
 
@@ -31,7 +31,6 @@
 
 makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
 makeoptions	CONF_CFLAGS=-mcpu=xscale
-makeoptions	MODULES_OVERRIDE=""
 #options 	HZ=1000
 options 	HZ=100
 options 	DEVICE_POLLING

==== //depot/projects/mpsafetty/sys/compat/ndis/kern_ndis.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.98 2008/07/23 10:49:27 weongyo Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.100 2008/12/27 09:42:17 weongyo Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,6 +65,9 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ioctl.h>
 
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
 #include <compat/ndis/pe_var.h>
 #include <compat/ndis/cfg_var.h>
 #include <compat/ndis/resource_var.h>
@@ -144,7 +147,6 @@
 		}
 
 		TAILQ_INIT(&ndis_devhead);
-
 		break;
 	case MOD_SHUTDOWN:
 		if (TAILQ_FIRST(&ndis_devhead) == NULL) {
@@ -1199,6 +1201,33 @@
 }
 
 int
+ndis_pnpevent_nic(arg, type)
+	void			*arg;
+	int			type;
+{
+	device_t		dev;
+	struct ndis_softc	*sc;
+	ndis_handle		adapter;
+	ndis_pnpevent_handler	pnpeventfunc;
+
+	dev = arg;
+	sc = device_get_softc(arg);
+	NDIS_LOCK(sc);
+	adapter = sc->ndis_block->nmb_miniportadapterctx;
+	pnpeventfunc = sc->ndis_chars->nmc_pnpevent_handler;
+	NDIS_UNLOCK(sc);
+	if (adapter == NULL || pnpeventfunc == NULL)
+		return(EIO);
+
+	if (sc->ndis_chars->nmc_rsvd0 == NULL)
+		MSCALL4(pnpeventfunc, adapter, type, NULL, 0);
+	else
+		MSCALL4(pnpeventfunc, sc->ndis_chars->nmc_rsvd0, type, NULL, 0);
+
+	return (0);
+}
+
+int
 ndis_init_nic(arg)
 	void			*arg;
 {

==== //depot/projects/mpsafetty/sys/compat/ndis/kern_windrv.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_windrv.c,v 1.14 2007/05/20 22:03:57 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_windrv.c,v 1.15 2008/12/27 08:03:32 weongyo Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -56,6 +56,9 @@
 #include <machine/segments.h>
 #endif
 
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
 #include <compat/ndis/pe_var.h>
 #include <compat/ndis/cfg_var.h>
 #include <compat/ndis/resource_var.h>
@@ -349,9 +352,11 @@
 	if (pe_patch_imports(img, "NDIS", ndis_functbl))
 		return(ENOEXEC);
 
-	/* Dynamically link the HAL.dll routines -- also required. */
-	if (pe_patch_imports(img, "HAL", hal_functbl))
-		return(ENOEXEC);
+	/* Dynamically link the HAL.dll routines -- optional. */
+	if (pe_get_import_descriptor(img, &imp_desc, "HAL") == 0) {
+		if (pe_patch_imports(img, "HAL", hal_functbl))
+			return(ENOEXEC);
+	}
 
 	/* Dynamically link ntoskrnl.exe -- optional. */
 	if (pe_get_import_descriptor(img, &imp_desc, "ntoskrnl") == 0) {

==== //depot/projects/mpsafetty/sys/compat/ndis/ndis_var.h#2 (text+ko) ====

@@ -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/ndis_var.h,v 1.48 2007/12/02 04:04:42 thompsa Exp $
+ * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.49 2008/12/27 08:03:32 weongyo Exp $
  */
 
 #ifndef _NDIS_VAR_H_
@@ -1658,6 +1658,7 @@
 typedef void (*ndis_enable_interrupts_handler)(ndis_handle);
 typedef void (*ndis_disable_interrupts_handler)(ndis_handle);
 typedef void (*ndis_shutdown_handler)(void *);
+typedef void (*ndis_pnpevent_handler)(void *, int, void *, uint32_t);
 typedef void (*ndis_allocdone_handler)(ndis_handle, void *,
 		ndis_physaddr *, uint32_t, void *);
 typedef uint8_t (*ndis_checkforhang_handler)(ndis_handle);
@@ -1739,6 +1740,7 @@
 extern int ndis_reset_nic(void *);
 extern int ndis_halt_nic(void *);
 extern int ndis_shutdown_nic(void *);
+extern int ndis_pnpevent_nic(void *, int);
 extern int ndis_init_nic(void *);
 extern void ndis_return_packet(void *, void *);
 extern int ndis_init_dma(void *);
@@ -1759,6 +1761,7 @@
 extern void NdisFreePacket(ndis_packet *);
 extern ndis_status NdisScheduleWorkItem(ndis_work_item *);
 extern void NdisMSleep(uint32_t);
+extern void ndis_cancel_timerlist(void);
 __END_DECLS
 
 #endif /* _NDIS_VAR_H_ */

==== //depot/projects/mpsafetty/sys/compat/ndis/ntoskrnl_var.h#3 (text+ko) ====

@@ -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.45 2008/09/13 17:34:18 thompsa Exp $
+ * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.46 2008/12/27 08:03:32 weongyo Exp $
  */
 
 #ifndef _NTOSKRNL_VAR_H_
@@ -536,6 +536,11 @@
 
 #define WAITKEY_VALID		0x8000
 
+/* kthread priority  */
+#define	LOW_PRIORITY		0
+#define	LOW_REALTIME_PRIORITY	16
+#define	HIGH_PRIORITY		31
+
 struct thread_context {
 	void			*tc_thrctx;
 	void			*tc_thrfunc;
@@ -989,7 +994,13 @@
 			} s2;
 			void			*irp_fileobj;
 		} irp_overlay;
-		kapc			irp_apc;
+		union {
+			kapc			irp_apc;
+			struct {
+				void		*irp_xfer;
+				void		*irp_dev;
+			} irp_usb;
+		} irp_misc;
 		void			*irp_compkey;
 	} irp_tail;
 };
@@ -997,6 +1008,9 @@
 #define irp_csl			s2.u2.irp_csl
 #define irp_pkttype		s2.u2.irp_pkttype
 
+#define	IRP_NDIS_DEV(irp)	(irp)->irp_tail.irp_misc.irp_usb.irp_dev
+#define	IRP_NDISUSB_XFER(irp)	(irp)->irp_tail.irp_misc.irp_usb.irp_xfer
+
 typedef struct irp irp;
 
 #define InterlockedExchangePointer(dst, val)				\
@@ -1009,6 +1023,10 @@
 	(cancel_func)InterlockedExchangePointer(			\
 	(void *)&(ip)->irp_cancelfunc, (void *)(func))
 
+#define	IoSetCancelValue(irp, val)					\
+	(u_long)InterlockedExchangePointer(				\
+	(void *)&(ip)->irp_cancel, (void *)(val))
+
 #define IoGetCurrentIrpStackLocation(irp)				\
 	(irp)->irp_tail.irp_overlay.irp_csl
 
@@ -1035,6 +1053,8 @@
 
 #define IoMarkIrpPending(irp)						\
 	IoGetCurrentIrpStackLocation(irp)->isl_ctl |= SL_PENDING_RETURNED
+#define	IoUnmarkIrpPending(irp)						\
+	IoGetCurrentIrpStackLocation(irp)->isl_ctl &= ~SL_PENDING_RETURNED
 
 #define IoCopyCurrentIrpStackLocationToNext(irp)			\
 	do {								\
@@ -1191,14 +1211,21 @@
 #define STATUS_ALERTED			0x00000101
 #define STATUS_TIMEOUT			0x00000102
 #define STATUS_PENDING			0x00000103
+#define	STATUS_FAILURE			0xC0000001
+#define	STATUS_NOT_IMPLEMENTED		0xC0000002
 #define STATUS_INVALID_PARAMETER	0xC000000D
 #define STATUS_INVALID_DEVICE_REQUEST	0xC0000010
 #define STATUS_MORE_PROCESSING_REQUIRED	0xC0000016
+#define	STATUS_NO_MEMORY		0xC0000017
 #define STATUS_BUFFER_TOO_SMALL		0xC0000023
 #define STATUS_MUTANT_NOT_OWNED		0xC0000046
+#define	STATUS_NOT_SUPPORTED		0xC00000BB
 #define STATUS_INVALID_PARAMETER_2	0xC00000F0
 #define STATUS_INSUFFICIENT_RESOURCES	0xC000009A
+#define	STATUS_DEVICE_NOT_CONNECTED	0xC000009D
+#define	STATUS_CANCELLED		0xC0000120
 #define STATUS_NOT_FOUND		0xC0000225
+#define	STATUS_DEVICE_REMOVED		0xC00002B6
 
 #define STATUS_WAIT_0			0x00000000
 
@@ -1365,6 +1392,7 @@
 extern uint32_t IoConnectInterrupt(kinterrupt **, void *, void *,
 	kspin_lock *, uint32_t, uint8_t, uint8_t, uint8_t, uint8_t,
 	uint32_t, uint8_t);
+extern uint8_t MmIsAddressValid(void *);
 extern void *MmMapIoSpace(uint64_t, uint32_t, uint32_t);
 extern void MmUnmapIoSpace(void *, size_t);
 extern void MmBuildMdlForNonPagedPool(mdl *);

==== //depot/projects/mpsafetty/sys/compat/ndis/subr_ndis.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.114 2008/08/28 15:23:18 attilio Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.115 2008/12/27 08:03:32 weongyo Exp $");
 
 /*
  * This file implements a translation layer between the BSD networking
@@ -95,6 +95,8 @@
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
 
 #include <compat/ndis/pe_var.h>
 #include <compat/ndis/cfg_var.h>
@@ -302,6 +304,15 @@
  */
 #define NDIS_POOL_EXTRA		16
 
+struct ktimer_list {
+	ktimer			*kl_timer;
+	list_entry		kl_next;
+};
+
+static struct list_entry	ndis_timerlist;
+static kspin_lock		ndis_timerlock;
+static int			ndis_isusbdev;
+
 int
 ndis_libinit()
 {
@@ -317,6 +328,9 @@
 		patch++;
 	}
 
+	KeInitializeSpinLock(&ndis_timerlock);
+	InitializeListHead(&ndis_timerlist);
+
 	return(0);
 }
 
@@ -1215,6 +1229,16 @@
 	ndis_timer_function	func;
 	void			*ctx;
 {
+	ndis_miniport_block	*block;
+	struct ktimer_list	*kl;
+	struct ndis_softc	*sc;
+	uint8_t			irql;
+
+	block = (ndis_miniport_block *)handle;
+	sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
+	if (sc->ndis_iftype == PNPBus && ndis_isusbdev == 0)
+		ndis_isusbdev = 1;
+
 	/* Save the driver's funcptr and context */
 
 	timer->nmt_timerfunc = func;
@@ -1232,7 +1256,38 @@
 	    ndis_findwrap((funcptr)ndis_timercall), timer);
 	timer->nmt_ktimer.k_dpc = &timer->nmt_kdpc;
 
-	return;
+	if (ndis_isusbdev == 1) {
+		kl = (struct ktimer_list *)malloc(sizeof(*kl), M_DEVBUF,
+		    M_NOWAIT | M_ZERO);
+		if (kl == NULL)
+			panic("out of memory");	/* no way to report errors  */
+
+		kl->kl_timer = &timer->nmt_ktimer;
+		KeAcquireSpinLock(&ndis_timerlock, &irql);
+		InsertHeadList((&ndis_timerlist), (&kl->kl_next));
+		KeReleaseSpinLock(&ndis_timerlock, irql);
+	}
+}
+
+void
+ndis_cancel_timerlist(void)
+{
+	list_entry		*l;
+	struct ktimer_list	*kl;
+	uint8_t			cancelled, irql;
+
+	KeAcquireSpinLock(&ndis_timerlock, &irql);
+
+	while(!IsListEmpty(&ndis_timerlist)) {
+		l = RemoveHeadList(&ndis_timerlist);
+		kl = CONTAINING_RECORD(l, struct ktimer_list, kl_next);
+		KeReleaseSpinLock(&ndis_timerlock, irql);
+		cancelled = KeCancelTimer(kl->kl_timer);
+		free(kl, M_DEVBUF);
+		KeAcquireSpinLock(&ndis_timerlock, &irql);
+	}
+
+	KeReleaseSpinLock(&ndis_timerlock, irql);
 }
 
 /*
@@ -1277,6 +1332,26 @@
 	ndis_timer		*timer;
 	uint8_t			*cancelled;
 {
+	list_entry		*l;
+	struct ktimer_list	*kl;
+	uint8_t			irql;
+
+	if (ndis_isusbdev == 1) {
+		KeAcquireSpinLock(&ndis_timerlock, &irql);
+		l = ndis_timerlist.nle_flink;
+		while(l != &ndis_timerlist) {
+			kl = CONTAINING_RECORD(l, struct ktimer_list, kl_next);
+			if (kl->kl_timer == &timer->nt_ktimer) {
+				RemoveEntryList((&kl->kl_next));
+				l = l->nle_flink;
+				free(kl, M_DEVBUF);
+				continue;
+			}
+			l = l->nle_flink;
+		}
+		KeReleaseSpinLock(&ndis_timerlock, irql);
+	}
+
 	*cancelled = KeCancelTimer(&timer->nt_ktimer);
 	return;
 }

==== //depot/projects/mpsafetty/sys/compat/ndis/subr_ntoskrnl.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.96 2008/06/15 13:37:29 cokane Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.97 2008/12/27 08:03:32 weongyo Exp $");
 
 #include <sys/ctype.h>
 #include <sys/unistd.h>
@@ -207,7 +207,6 @@
 static void *MmMapLockedPagesSpecifyCache(mdl *,
 	uint8_t, uint32_t, void *, uint32_t, uint32_t);
 static void MmUnmapLockedPages(void *, mdl *);
-static uint8_t MmIsAddressValid(void *);
 static device_t ntoskrnl_finddev(device_t, uint64_t, struct resource **);
 static void RtlZeroMemory(void *, size_t);
 static void RtlCopyMemory(void *, const void *, size_t);
@@ -251,6 +250,8 @@
 static uint32_t DbgPrint(char *, ...);
 static void DbgBreakPoint(void);
 static void KeBugCheckEx(uint32_t, u_long, u_long, u_long, u_long);
+static int32_t KeDelayExecutionThread(uint8_t, uint8_t, int64_t *);
+static int32_t KeSetPriorityThread(struct thread *, int32_t);
 static void dummy(void);
 
 static struct mtx ntoskrnl_dispatchlock;
@@ -1143,16 +1144,18 @@
 IoCancelIrp(irp *ip)
 {
 	cancel_func		cfunc;
+	uint8_t			cancelirql;
 
-	IoAcquireCancelSpinLock(&ip->irp_cancelirql);
+	IoAcquireCancelSpinLock(&cancelirql);
 	cfunc = IoSetCancelRoutine(ip, NULL);
 	ip->irp_cancel = TRUE;
-	if (ip->irp_cancelfunc == NULL) {
-		IoReleaseCancelSpinLock(ip->irp_cancelirql);
+	if (cfunc == NULL) {
+		IoReleaseCancelSpinLock(cancelirql);
 		return(FALSE);
 	}
+	ip->irp_cancelirql = cancelirql;
 	MSCALL2(cfunc, IoGetCurrentIrpStackLocation(ip)->isl_devobj, ip);
-	return(TRUE);
+	return (uint8_t)IoSetCancelValue(ip, TRUE);
 }
 
 uint32_t
@@ -1186,24 +1189,27 @@
 	irp			*ip;
 	uint8_t			prioboost;
 {
-	uint32_t		i;
 	uint32_t		status;
 	device_object		*dobj;
 	io_stack_location	*sl;
 	completion_func		cf;
 
-	ip->irp_pendingreturned =
-	    IoGetCurrentIrpStackLocation(ip)->isl_ctl & SL_PENDING_RETURNED;
-	sl = (io_stack_location *)(ip + 1);
+	KASSERT(ip->irp_iostat.isb_status != STATUS_PENDING,
+	    ("incorrect IRP(%p) status (STATUS_PENDING)", ip));
+
+	sl = IoGetCurrentIrpStackLocation(ip);
+	IoSkipCurrentIrpStackLocation(ip);
+
+	do {
+		if (sl->isl_ctl & SL_PENDING_RETURNED)
+			ip->irp_pendingreturned = TRUE;
 
-	for (i = ip->irp_currentstackloc; i < (uint32_t)ip->irp_stackcnt; i++) {
-		if (ip->irp_currentstackloc < ip->irp_stackcnt - 1) {
-			IoSkipCurrentIrpStackLocation(ip);
+		if (ip->irp_currentstackloc != (ip->irp_stackcnt + 1))
 			dobj = IoGetCurrentIrpStackLocation(ip)->isl_devobj;
-		} else
+		else
 			dobj = NULL;
 
-		if (sl[i].isl_completionfunc != NULL &&
+		if (sl->isl_completionfunc != NULL &&
 		    ((ip->irp_iostat.isb_status == STATUS_SUCCESS &&
 		    sl->isl_ctl & SL_INVOKE_ON_SUCCESS) ||
 		    (ip->irp_iostat.isb_status != STATUS_SUCCESS &&
@@ -1214,12 +1220,16 @@
 			status = MSCALL3(cf, dobj, ip, sl->isl_completionctx);
 			if (status == STATUS_MORE_PROCESSING_REQUIRED)
 				return;
+		} else {
+			if ((ip->irp_currentstackloc <= ip->irp_stackcnt) &&
+			    (ip->irp_pendingreturned == TRUE))
+				IoMarkIrpPending(ip);
 		}
 
-		if (IoGetCurrentIrpStackLocation(ip)->isl_ctl &
-		    SL_PENDING_RETURNED)
-			ip->irp_pendingreturned = TRUE;
-	}
+		/* move to the next.  */
+		IoSkipCurrentIrpStackLocation(ip);
+		sl++;
+	} while (ip->irp_currentstackloc <= (ip->irp_stackcnt + 1));
 
 	/* Handle any associated IRPs. */
 
@@ -2672,7 +2682,7 @@
  * here, but it doesn't.
  */
 
-static uint8_t
+uint8_t
 MmIsAddressValid(vaddr)
 	void			*vaddr;
 {
@@ -4258,6 +4268,73 @@
 	return(timer->k_header.dh_sigstate);
 }
 
+static int32_t
+KeDelayExecutionThread(wait_mode, alertable, interval)
+        uint8_t                 wait_mode;
+        uint8_t                 alertable;
+        int64_t                 *interval;
+{
+	ktimer                  timer;
+
+	if (wait_mode != 0)
+		panic("invalid wait_mode %d", wait_mode);
+
+	KeInitializeTimer(&timer);
+	KeSetTimer(&timer, *interval, NULL);
+	KeWaitForSingleObject(&timer, 0, 0, alertable, NULL);
+
+	return STATUS_SUCCESS;
+}
+
+static uint64_t
+KeQueryInterruptTime(void)
+{
+	int ticks;
+	struct timeval tv;
+
+	getmicrouptime(&tv);
+
+	ticks = tvtohz(&tv);
+
+	return ticks * ((10000000 + hz - 1) / hz);
+}
+
+static struct thread *
+KeGetCurrentThread(void)
+{
+
+	return curthread;
+}
+
+static int32_t
+KeSetPriorityThread(td, pri)
+	struct thread	*td;
+	int32_t		pri;
+{
+	int32_t old;
+
+	if (td == NULL)
+		return LOW_REALTIME_PRIORITY;
+
+	if (td->td_priority <= PRI_MIN_KERN)
+		old = HIGH_PRIORITY;
+	else if (td->td_priority >= PRI_MAX_KERN)
+		old = LOW_PRIORITY;
+	else
+		old = LOW_REALTIME_PRIORITY;
+
+	thread_lock(td);
+	if (pri == HIGH_PRIORITY)
+		sched_prio(td, PRI_MIN_KERN);
+	if (pri == LOW_REALTIME_PRIORITY)
+		sched_prio(td, PRI_MIN_KERN + (PRI_MAX_KERN - PRI_MIN_KERN) / 2);
+	if (pri == LOW_PRIORITY)
+		sched_prio(td, PRI_MAX_KERN);
+	thread_unlock(td);
+
+	return old;
+}
+
 static void
 dummy()
 {
@@ -4441,6 +4518,10 @@
 	IMPORT_CFUNC(WmiTraceMessage, 0),
 	IMPORT_SFUNC(KeQuerySystemTime, 1),
 	IMPORT_CFUNC(KeTickCount, 0),
+	IMPORT_SFUNC(KeDelayExecutionThread, 3),
+	IMPORT_SFUNC(KeQueryInterruptTime, 0),
+	IMPORT_SFUNC(KeGetCurrentThread, 0),
+	IMPORT_SFUNC(KeSetPriorityThread, 2),
 
 	/*
 	 * This last entry is a catch-all for any function we haven't

==== //depot/projects/mpsafetty/sys/compat/ndis/subr_usbd.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_usbd.c,v 1.3 2005/05/05 03:56:09 wpaul Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_usbd.c,v 1.4 2008/12/27 08:03:32 weongyo Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -45,10 +45,24 @@
 #include <sys/module.h>
 #include <sys/conf.h>
 #include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <machine/bus.h>
 #include <sys/bus.h>
 
 #include <sys/queue.h>
 
+#include <net/if.h>
+#include <net/if_media.h>
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_ioctl.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdivar.h>
+#include <dev/usb/usb_quirks.h>
+#include "usbdevs.h"
+
 #include <compat/ndis/pe_var.h>
 #include <compat/ndis/cfg_var.h>
 #include <compat/ndis/resource_var.h>
@@ -56,18 +70,64 @@
 #include <compat/ndis/ndis_var.h>
 #include <compat/ndis/hal_var.h>
 #include <compat/ndis/usbd_var.h>
+#include <dev/if_ndis/if_ndisvar.h>
 
 static driver_object usbd_driver;
 
-static uint32_t usbd_iodispatch(device_object *, irp *);
+static int32_t		 usbd_func_bulkintr(irp *);
+static int32_t		 usbd_func_vendorclass(irp *);
+static int32_t		 usbd_func_selconf(irp *);
+static int32_t		 usbd_func_getdesc(irp *);
+static usbd_status	 usbd_get_desc_ndis(usbd_device_handle, int, int, int,
+			    void *, int *);
+static union usbd_urb	*usbd_geturb(irp *);
+static usbd_status	 usbd_init_ndispipe(irp *, usb_endpoint_descriptor_t *);
+static usbd_xfer_handle	 usbd_init_ndisxfer(irp *, usb_endpoint_descriptor_t *,
+			    void *, uint32_t);
+static int32_t		 usbd_iodispatch(device_object *, irp *);
+static int32_t		 usbd_ioinvalid(device_object *, irp *);
+static int32_t		 usbd_pnp(device_object *, irp *);
+static int32_t		 usbd_power(device_object *, irp *);
+static void		 usbd_irpcancel(device_object *, irp *);
+static void		 usbd_irpcancel_cb(void *);
+static int32_t		 usbd_submit_urb(irp *);
+static int32_t		 usbd_urb2nt(int32_t);
+static void		 usbd_xfereof(usbd_xfer_handle, usbd_private_handle,
+			    usbd_status);
+static void		 usbd_xferadd(usbd_xfer_handle, usbd_private_handle,
+			    usbd_status);
+static void		 usbd_xfertask(device_object *, void *);
+static void		 dummy(void);
+
+static union usbd_urb	*USBD_CreateConfigurationRequestEx(
+			    usb_config_descriptor_t *,
+			    struct usbd_interface_list_entry *);
+static union usbd_urb	*USBD_CreateConfigurationRequest(
+			    usb_config_descriptor_t *,
+			    uint16_t *);
+static void		 USBD_GetUSBDIVersion(usbd_version_info *);
+static usb_interface_descriptor_t *USBD_ParseConfigurationDescriptorEx(
+			    usb_config_descriptor_t *, void *, int32_t, int32_t,
+			    int32_t, int32_t, int32_t);
+static usb_interface_descriptor_t *USBD_ParseConfigurationDescriptor(
+		    usb_config_descriptor_t *, uint8_t, uint8_t);
 
-static void USBD_GetUSBDIVersion(usbd_version_info *);
-static void dummy(void);
+/*
+ * We need to wrap these functions because these need `context switch' from
+ * Windows to UNIX before it's called.
+ */
+static funcptr usbd_iodispatch_wrap;
+static funcptr usbd_ioinvalid_wrap;
+static funcptr usbd_pnp_wrap;
+static funcptr usbd_power_wrap;
+static funcptr usbd_irpcancel_wrap;
+static funcptr usbd_xfertask_wrap;
 
 int
 usbd_libinit(void)
 {
 	image_patch_table	*patch;
+	int i;
 
 	patch = usbd_functbl;
 	while (patch->ipt_func != NULL) {
@@ -77,14 +137,36 @@
 		patch++;
 	}
 
+	windrv_wrap((funcptr)usbd_ioinvalid,
+	    (funcptr *)&usbd_ioinvalid_wrap, 2, WINDRV_WRAP_STDCALL);
+	windrv_wrap((funcptr)usbd_iodispatch,
+	    (funcptr *)&usbd_iodispatch_wrap, 2, WINDRV_WRAP_STDCALL);
+	windrv_wrap((funcptr)usbd_pnp,
+	    (funcptr *)&usbd_pnp_wrap, 2, WINDRV_WRAP_STDCALL);
+	windrv_wrap((funcptr)usbd_power,
+	    (funcptr *)&usbd_power_wrap, 2, WINDRV_WRAP_STDCALL);
+	windrv_wrap((funcptr)usbd_irpcancel,
+	    (funcptr *)&usbd_irpcancel_wrap, 2, WINDRV_WRAP_STDCALL);
+	windrv_wrap((funcptr)usbd_xfertask,
+	    (funcptr *)&usbd_xfertask_wrap, 2, WINDRV_WRAP_STDCALL);
+
 	/* Create a fake USB driver instance. */
 
 	windrv_bus_attach(&usbd_driver, "USB Bus");
 
 	/* Set up our dipatch routine. */
+	for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
+                usbd_driver.dro_dispatch[i] =
+			(driver_dispatch)usbd_ioinvalid_wrap;
 
 	usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
-	    (driver_dispatch)usbd_iodispatch;
+	    (driver_dispatch)usbd_iodispatch_wrap;
+	usbd_driver.dro_dispatch[IRP_MJ_DEVICE_CONTROL] =
+	    (driver_dispatch)usbd_iodispatch_wrap;
+	usbd_driver.dro_dispatch[IRP_MJ_POWER] =
+	    (driver_dispatch)usbd_power_wrap;
+	usbd_driver.dro_dispatch[IRP_MJ_PNP] =
+	    (driver_dispatch)usbd_pnp_wrap;
 
 	return(0);
 }
@@ -100,17 +182,949 @@
 		patch++;
 	}
 
+	windrv_unwrap(usbd_ioinvalid_wrap);
+	windrv_unwrap(usbd_iodispatch_wrap);
+	windrv_unwrap(usbd_pnp_wrap);
+	windrv_unwrap(usbd_power_wrap);
+	windrv_unwrap(usbd_irpcancel_wrap);
+	windrv_unwrap(usbd_xfertask_wrap);
+
 	free(usbd_driver.dro_drivername.us_buf, M_DEVBUF);
 
 	return(0);
 }
 
-static uint32_t
+static int32_t
 usbd_iodispatch(dobj, ip)
 	device_object		*dobj;
 	irp			*ip;

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812271826.mBRIQ84I076591>