[Midnightbsd-cvs] src [10126] trunk/sys/dev: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 20:22:51 EDT 2018


Revision: 10126
          http://svnweb.midnightbsd.org/src/?rev=10126
Author:   laffer1
Date:     2018-05-27 20:22:50 -0400 (Sun, 27 May 2018)
Log Message:
-----------
 sync with freebsd

Modified Paths:
--------------
    trunk/sys/dev/atkbdc/atkbd.c
    trunk/sys/dev/atkbdc/atkbd_atkbdc.c
    trunk/sys/dev/atkbdc/atkbdc.c
    trunk/sys/dev/atkbdc/atkbdc_ebus.c
    trunk/sys/dev/atkbdc/atkbdc_isa.c
    trunk/sys/dev/atkbdc/atkbdc_subr.c
    trunk/sys/dev/atkbdc/atkbdc_subr.h
    trunk/sys/dev/atkbdc/atkbdcreg.h
    trunk/sys/dev/atkbdc/atkbdreg.h
    trunk/sys/dev/atkbdc/psm.c
    trunk/sys/dev/atkbdc/psm.h
    trunk/sys/dev/bwi/bitops.h
    trunk/sys/dev/bwi/bwimac.c
    trunk/sys/dev/bwi/bwimac.h
    trunk/sys/dev/bwi/bwiphy.c
    trunk/sys/dev/bwi/bwiphy.h
    trunk/sys/dev/bwi/bwirf.c
    trunk/sys/dev/bwi/bwirf.h
    trunk/sys/dev/bwi/if_bwi.c
    trunk/sys/dev/bwi/if_bwi_pci.c
    trunk/sys/dev/bwi/if_bwireg.h
    trunk/sys/dev/bwi/if_bwivar.h
    trunk/sys/dev/bwn/if_bwn.c
    trunk/sys/dev/bwn/if_bwnreg.h
    trunk/sys/dev/bwn/if_bwnvar.h

Added Paths:
-----------
    trunk/sys/dev/bvm/
    trunk/sys/dev/bvm/bvm_console.c
    trunk/sys/dev/bvm/bvm_dbg.c

Modified: trunk/sys/dev/atkbdc/atkbd.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbd.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbd.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbd.c 283219 2015-05-21 10:40:18Z royger $");
 
 #include "opt_compat.h"
 #include "opt_kbd.h"
@@ -44,19 +45,6 @@
 #include <machine/bus.h>
 #include <machine/resource.h>
 
-#if defined(__i386__) || defined(__amd64__)
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#include <compat/x86bios/x86bios.h>
-#include <machine/pc/bios.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_param.h>
-
-#include <isa/isareg.h>
-#endif /* __i386__ || __amd64__ */
-
 #include <sys/kbio.h>
 #include <dev/kbd/kbdreg.h>
 #include <dev/atkbdc/atkbdreg.h>
@@ -65,6 +53,9 @@
 static timeout_t	atkbd_timeout;
 static void		atkbd_shutdown_final(void *v);
 
+#define DEFAULT_DELAY		0x1  /* 500ms */
+#define DEFAULT_RATE		0x10 /* 14Hz */
+
 int
 atkbd_probe_unit(device_t dev, int irq, int flags)
 {
@@ -239,7 +230,7 @@
 KEYBOARD_DRIVER(atkbd, atkbdsw, atkbd_configure);
 
 /* local functions */
-static int		get_typematic(keyboard_t *kbd);
+static int		set_typematic(keyboard_t *kbd);
 static int		setup_kbd_port(KBDC kbdc, int port, int intr);
 static int		get_kbd_echo(KBDC kbdc);
 static int		probe_keyboard(KBDC kbdc, int flags);
@@ -433,7 +424,7 @@
 			goto bad;
 		}
 		atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
-		get_typematic(kbd);
+		set_typematic(kbd);
 		delay[0] = kbd->kb_delay1;
 		delay[1] = kbd->kb_delay2;
 		atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
@@ -490,7 +481,7 @@
 		init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config);
 		KBD_FOUND_DEVICE(kbd);
 		atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
-		get_typematic(kbd);
+		set_typematic(kbd);
 		delay[0] = kbd->kb_delay1;
 		delay[1] = kbd->kb_delay2;
 		atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
@@ -1089,57 +1080,19 @@
 /* local functions */
 
 static int
-get_typematic(keyboard_t *kbd)
+set_typematic(keyboard_t *kbd)
 {
-#if defined(__i386__) || defined(__amd64__)
-	/*
-	 * Only some systems allow us to retrieve the keyboard repeat
-	 * rate previously set via the BIOS...
-	 */
-	x86regs_t regs;
-	uint8_t *p;
+	int val, error;
+	atkbd_state_t *state = kbd->kb_data;
 
-	/*
-	 * Traditional entry points of int 0x15 and 0x16 are fixed
-	 * and later BIOSes follow them.  (U)EFI CSM specification
-	 * also mandates these fixed entry points.
-	 *
-	 * Validate the entry points here before we proceed further.
-	 * It's known that some recent laptops does not have the
-	 * same entry point and hang on boot if we call it.
-	 */
-	if (x86bios_get_intr(0x15) != 0xf000f859 ||
-	    x86bios_get_intr(0x16) != 0xf000e82e)
-		return (ENODEV);
+	val = typematic(DEFAULT_DELAY, DEFAULT_RATE);
+	error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, val);
+	if (error == 0) {
+		kbd->kb_delay1 = typematic_delay(val);
+		kbd->kb_delay2 = typematic_rate(val);
+	}
 
-	/* Is BIOS system configuration table supported? */
-	x86bios_init_regs(&regs);
-	regs.R_AH = 0xc0;
-	x86bios_intr(&regs, 0x15);
-	if ((regs.R_FLG & PSL_C) != 0 || regs.R_AH != 0)
-		return (ENODEV);
-
-	/* Is int 0x16, function 0x09 supported? */
-	p = x86bios_offset((regs.R_ES << 4) + regs.R_BX);
-	if (readw(p) < 5 || (readb(p + 6) & 0x40) == 0)
-		return (ENODEV);
-
-	/* Is int 0x16, function 0x0306 supported? */
-	x86bios_init_regs(&regs);
-	regs.R_AH = 0x09;
-	x86bios_intr(&regs, 0x16);
-	if ((regs.R_AL & 0x08) == 0)
-		return (ENODEV);
-
-	x86bios_init_regs(&regs);
-	regs.R_AX = 0x0306;
-	x86bios_intr(&regs, 0x16);
-	kbd->kb_delay1 = typematic_delay(regs.R_BH << 5);
-	kbd->kb_delay2 = typematic_rate(regs.R_BL);
-	return (0);
-#else
-	return (ENODEV);
-#endif /* __i386__ || __amd64__ */
+	return (error);
 }
 
 static int

Modified: trunk/sys/dev/atkbdc/atkbd_atkbdc.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbd_atkbdc.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbd_atkbdc.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbd_atkbdc.c 245315 2013-01-11 21:42:23Z imp $");
 
 #include "opt_kbd.h"
 

Modified: trunk/sys/dev/atkbdc/atkbdc.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbdc.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdc.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1996-1999
  * Kazutaka YOKOTA (yokota at zodiac.mech.utsunomiya-u.ac.jp)
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbdc.c 216592 2010-12-20 16:39:43Z tijl $");
 
 #include "opt_kbd.h"
 

Modified: trunk/sys/dev/atkbdc/atkbdc_ebus.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbdc_ebus.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdc_ebus.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * Copyright (c) 2005 Marius Strobl <marius at FreeBSD.org>
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbdc_ebus.c 207354 2010-04-29 06:16:00Z sobomax $");
 
 #include "opt_kbd.h"
 

Modified: trunk/sys/dev/atkbdc/atkbdc_isa.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbdc_isa.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdc_isa.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbdc_isa.c 238164 2012-07-06 12:13:28Z jhb $");
 
 #include "opt_kbd.h"
 

Modified: trunk/sys/dev/atkbdc/atkbdc_subr.c
===================================================================
--- trunk/sys/dev/atkbdc/atkbdc_subr.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdc_subr.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/atkbdc_subr.c 147271 2005-06-10 20:56:38Z marius $");
 
 #include "opt_kbd.h"
 

Modified: trunk/sys/dev/atkbdc/atkbdc_subr.h
===================================================================
--- trunk/sys/dev/atkbdc/atkbdc_subr.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdc_subr.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -24,7 +25,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  *	from: FreeBSD: src/sys/isa/atkbdc_isa.c,v 1.31 2005/05/29 04:42:28 nyan Exp
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/atkbdc/atkbdc_subr.h 147271 2005-06-10 20:56:38Z marius $
  */
 
 #ifndef _DEV_ATKBDC_ATKBDC_SUBR_H_

Modified: trunk/sys/dev/atkbdc/atkbdcreg.h
===================================================================
--- trunk/sys/dev/atkbdc/atkbdcreg.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdcreg.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1996-1999
  * Kazutaka YOKOTA (yokota at zodiac.mech.utsunomiya-u.ac.jp)
@@ -27,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/atkbdc/atkbdcreg.h 216492 2010-12-16 17:14:37Z jhb $
  * from kbdio.h,v 1.8 1998/09/25 11:55:46 yokota Exp
  */
 

Modified: trunk/sys/dev/atkbdc/atkbdreg.h
===================================================================
--- trunk/sys/dev/atkbdc/atkbdreg.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/atkbdreg.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -23,7 +24,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.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/atkbdc/atkbdreg.h 245315 2013-01-11 21:42:23Z imp $
  */
 
 #ifndef _DEV_ATKBDC_ATKBDREG_H_

Modified: trunk/sys/dev/atkbdc/psm.c
===================================================================
--- trunk/sys/dev/atkbdc/psm.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/psm.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1992, 1993 Erik Forsberg.
  * Copyright (c) 1996, 1997 Kazutaka YOKOTA.
@@ -59,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/atkbdc/psm.c 329533 2018-02-18 22:12:20Z wulf $");
 
 #include "opt_isa.h"
 #include "opt_psm.h"
@@ -191,7 +192,8 @@
 	SYNAPTICS_SYSCTL_VSCROLL_VER_AREA,
 	SYNAPTICS_SYSCTL_VSCROLL_MIN_DELTA,
 	SYNAPTICS_SYSCTL_VSCROLL_DIV_MIN,
-	SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX
+	SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX,
+	SYNAPTICS_SYSCTL_TOUCHPAD_OFF
 };
 
 typedef struct synapticsinfo {
@@ -198,6 +200,7 @@
 	struct sysctl_ctx_list	 sysctl_ctx;
 	struct sysctl_oid	*sysctl_tree;
 	int			 directional_scrolls;
+	int			 two_finger_scroll;
 	int			 min_pressure;
 	int			 max_pressure;
 	int			 max_width;
@@ -228,6 +231,7 @@
 	int			 vscroll_min_delta;
 	int			 vscroll_div_min;
 	int			 vscroll_div_max;
+	int			 touchpad_off;
 } synapticsinfo_t;
 
 typedef struct synapticspacket {
@@ -329,13 +333,14 @@
 	struct timeval	lastinputerr;	/* time last sync error happened */
 	struct timeval	taptimeout;	/* tap timeout for touchpads */
 	int		watchdog;	/* watchdog timer flag */
-	struct callout_handle callout;	/* watchdog timer call out */
-	struct callout_handle softcallout; /* buffer timer call out */
+	struct callout	callout;	/* watchdog timer call out */
+	struct callout	softcallout; /* buffer timer call out */
 	struct cdev	*dev;
 	struct cdev	*bdev;
 	int		lasterr;
 	int		cmdcount;
 	struct sigio	*async;		/* Processes waiting for SIGIO */
+	int		extended_buttons;
 };
 static devclass_t psm_devclass;
 
@@ -472,6 +477,10 @@
 static probefunc_t	enable_trackpoint;
 static probefunc_t	enable_versapad;
 
+static void set_trackpoint_parameters(struct psm_softc *sc);
+static void synaptics_passthrough_on(struct psm_softc *sc);
+static void synaptics_passthrough_off(struct psm_softc *sc);
+
 static struct {
 	int		model;
 	u_char		syncmask;
@@ -879,6 +888,13 @@
 			    set_mouse_resolution(kbdc, mode->resolution);
 		set_mouse_scaling(kbdc, 1);
 		set_mouse_mode(kbdc);
+
+		/*
+		 * Trackpoint settings are lost on resume.
+		 * Restore them here.
+		 */
+		if (sc->tphw > 0)
+			set_trackpoint_parameters(sc);
 	}
 
 	/* Record sync on the next data packet we see. */
@@ -1007,7 +1023,7 @@
 
 	/* start the watchdog timer */
 	sc->watchdog = FALSE;
-	sc->callout = timeout(psmtimeout, (void *)(uintptr_t)sc, hz*2);
+	callout_reset(&sc->callout, hz * 2, psmtimeout, sc);
 
 	return (0);
 }
@@ -1026,8 +1042,7 @@
 
 	/* block our watchdog timer */
 	sc->watchdog = FALSE;
-	untimeout(psmtimeout, (void *)(uintptr_t)sc, sc->callout);
-	callout_handle_init(&sc->callout);
+	callout_stop(&sc->callout);
 
 	/* save the current controller command byte */
 	empty_both_buffers(sc->kbdc, 10);
@@ -1465,7 +1480,8 @@
 
 	/* Setup initial state */
 	sc->state = PSM_VALID;
-	callout_handle_init(&sc->callout);
+	callout_init(&sc->callout, 0);
+	callout_init(&sc->softcallout, 0);
 
 	/* Setup our interrupt handler */
 	rid = KBDC_RID_AUX;
@@ -1534,6 +1550,9 @@
 	destroy_dev(sc->dev);
 	destroy_dev(sc->bdev);
 
+	callout_drain(&sc->callout);
+	callout_drain(&sc->softcallout);
+
 	return (0);
 }
 
@@ -1662,8 +1681,7 @@
 	splx(s);
 
 	/* stop the watchdog timer */
-	untimeout(psmtimeout, (void *)(uintptr_t)sc, sc->callout);
-	callout_handle_init(&sc->callout);
+	callout_stop(&sc->callout);
 
 	/* remove anything left in the output buffer */
 	empty_aux_buffer(sc->kbdc, 10);
@@ -1886,7 +1904,7 @@
 	sc->queue.tail = 0;
 	if ((sc->state & PSM_SOFTARMED) != 0) {
 		sc->state &= ~PSM_SOFTARMED;
-		untimeout(psmsoftintr, (void *)(uintptr_t)sc, sc->softcallout);
+		callout_stop(&sc->softcallout);
 	}
 	sc->pqueue_start = sc->pqueue_end;
 }
@@ -2302,7 +2320,7 @@
 	}
 	sc->watchdog = TRUE;
 	splx(s);
-	sc->callout = timeout(psmtimeout, (void *)(uintptr_t)sc, hz);
+	callout_reset(&sc->callout, hz, psmtimeout, sc);
 }
 
 /* Add all sysctls under the debug.psm and hw.psm nodes */
@@ -2394,7 +2412,7 @@
 			sc->flags &= ~PSM_NEED_SYNCBITS;
 			VLOG(2, (LOG_DEBUG,
 			    "psmintr: Sync bytes now %04x,%04x\n",
-			    sc->mode.syncmask[0], sc->mode.syncmask[0]));
+			    sc->mode.syncmask[0], sc->mode.syncmask[1]));
 		} else if ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1]) {
 			VLOG(3, (LOG_DEBUG, "psmintr: out of sync "
 			    "(%04x != %04x) %d cmds since last error.\n",
@@ -2484,13 +2502,13 @@
 		    (sc->pqueue_end == sc->pqueue_start)) {
 			if ((sc->state & PSM_SOFTARMED) != 0) {
 				sc->state &= ~PSM_SOFTARMED;
-				untimeout(psmsoftintr, arg, sc->softcallout);
+				callout_stop(&sc->softcallout);
 			}
 			psmsoftintr(arg);
 		} else if ((sc->state & PSM_SOFTARMED) == 0) {
 			sc->state |= PSM_SOFTARMED;
-			sc->softcallout = timeout(psmsoftintr, arg,
-			    psmhz < 1 ? 1 : (hz/psmhz));
+			callout_reset(&sc->softcallout,
+			    psmhz < 1 ? 1 : (hz/psmhz), psmsoftintr, arg);
 		}
 	}
 }
@@ -2599,7 +2617,7 @@
 	static int guest_buttons;
 	int w, x0, y0;
 
-	/* TouchPad PS/2 absolute mode message format
+	/* TouchPad PS/2 absolute mode message format with capFourButtons:
 	 *
 	 *  Bits:        7   6   5   4   3   2   1   0 (LSB)
 	 *  ------------------------------------------------
@@ -2606,7 +2624,7 @@
 	 *  ipacket[0]:  1   0  W3  W2   0  W1   R   L
 	 *  ipacket[1]: Yb  Ya  Y9  Y8  Xb  Xa  X9  X8
 	 *  ipacket[2]: Z7  Z6  Z5  Z4  Z3  Z2  Z1  Z0
-	 *  ipacket[3]:  1   1  Yc  Xc   0  W0   D   U
+	 *  ipacket[3]:  1   1  Yc  Xc   0  W0 D^R U^L
 	 *  ipacket[4]: X7  X6  X5  X4  X3  X2  X1  X0
 	 *  ipacket[5]: Y7  Y6  Y5  Y4  Y3  Y2  Y1  Y0
 	 *
@@ -2620,6 +2638,21 @@
 	 *  Y: y position
 	 *  Z: pressure
 	 *
+	 * Without capFourButtons but with nExtendeButtons and/or capMiddle
+	 *
+	 *  Bits:        7   6   5   4      3      2      1      0 (LSB)
+	 *  ------------------------------------------------------
+	 *  ipacket[3]:  1   1  Yc  Xc      0     W0    E^R    M^L
+	 *  ipacket[4]: X7  X6  X5  X4  X3|b7  X2|b5  X1|b3  X0|b1
+	 *  ipacket[5]: Y7  Y6  Y5  Y4  Y3|b8  Y2|b6  Y1|b4  Y0|b2
+	 *
+	 * Legend:
+	 *  M: Middle physical mouse button
+	 *  E: Extended mouse buttons reported instead of low bits of X and Y
+	 *  b1-b8: Extended mouse buttons
+	 *    Only ((nExtendedButtons + 1) >> 1) bits are used in packet
+	 *    4 and 5, for reading X and Y value they should be zeroed.
+	 *
 	 * Absolute reportable limits:    0 - 6143.
 	 * Typical bezel limits:       1472 - 5472.
 	 * Typical edge marings:       1632 - 5312.
@@ -2673,8 +2706,10 @@
 		w = 4;
 	}
 
-	/* Handle packets from the guest device */
-	/* XXX Documentation? */
+	/*
+	 * Handle packets from the guest device. See:
+	 * Synaptics PS/2 TouchPad Interfacing Guide, Section 5.1
+	 */
 	if (w == 3 && sc->synhw.capPassthrough) {
 		*x = ((pb->ipacket[1] & 0x10) ?
 		    pb->ipacket[4] - 256 : pb->ipacket[4]);
@@ -2694,6 +2729,12 @@
 		goto SYNAPTICS_END;
 	}
 
+	if (sc->syninfo.touchpad_off) {
+		*x = *y = *z = 0;
+		ms->button = ms->obutton;
+		goto SYNAPTICS_END;
+	}
+
 	/* Button presses */
 	touchpad_buttons = 0;
 	if (pb->ipacket[0] & 0x01)
@@ -2702,43 +2743,76 @@
 		touchpad_buttons |= MOUSE_BUTTON3DOWN;
 
 	if (sc->synhw.capExtended && sc->synhw.capFourButtons) {
-		if ((pb->ipacket[3] & 0x01) && (pb->ipacket[0] & 0x01) == 0)
+		if ((pb->ipacket[3] ^ pb->ipacket[0]) & 0x01)
 			touchpad_buttons |= MOUSE_BUTTON4DOWN;
-		if ((pb->ipacket[3] & 0x02) && (pb->ipacket[0] & 0x02) == 0)
+		if ((pb->ipacket[3] ^ pb->ipacket[0]) & 0x02)
 			touchpad_buttons |= MOUSE_BUTTON5DOWN;
-	}
+	} else if (sc->synhw.capExtended && sc->synhw.capMiddle &&
+	    !sc->synhw.capClickPad) {
+		/* Middle Button */
+		if ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x01)
+			touchpad_buttons |= MOUSE_BUTTON2DOWN;
+	} else if (sc->synhw.capExtended && (sc->synhw.nExtendedButtons > 0)) {
+		/* Extended Buttons */
+		if ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x02) {
+			if (sc->syninfo.directional_scrolls) {
+				if (pb->ipacket[4] & 0x01)
+					touchpad_buttons |= MOUSE_BUTTON4DOWN;
+				if (pb->ipacket[5] & 0x01)
+					touchpad_buttons |= MOUSE_BUTTON5DOWN;
+				if (pb->ipacket[4] & 0x02)
+					touchpad_buttons |= MOUSE_BUTTON6DOWN;
+				if (pb->ipacket[5] & 0x02)
+					touchpad_buttons |= MOUSE_BUTTON7DOWN;
+			} else {
+				if (pb->ipacket[4] & 0x01)
+					touchpad_buttons |= MOUSE_BUTTON1DOWN;
+				if (pb->ipacket[5] & 0x01)
+					touchpad_buttons |= MOUSE_BUTTON3DOWN;
+				if (pb->ipacket[4] & 0x02)
+					touchpad_buttons |= MOUSE_BUTTON2DOWN;
+				sc->extended_buttons = touchpad_buttons;
+			}
 
-	/*
-	 * In newer pads - bit 0x02 in the third byte of
-	 * the packet indicates that we have an extended
-	 * button press.
-	 */
-	/* XXX Documentation? */
-	if (pb->ipacket[3] & 0x02) {
-		/*
-		 * if directional_scrolls is not 1, we treat any of
-		 * the scrolling directions as middle-click.
-		 */
-		if (sc->syninfo.directional_scrolls) {
-			if (pb->ipacket[4] & 0x01)
-				touchpad_buttons |= MOUSE_BUTTON4DOWN;
-			if (pb->ipacket[5] & 0x01)
-				touchpad_buttons |= MOUSE_BUTTON5DOWN;
-			if (pb->ipacket[4] & 0x02)
-				touchpad_buttons |= MOUSE_BUTTON6DOWN;
-			if (pb->ipacket[5] & 0x02)
-				touchpad_buttons |= MOUSE_BUTTON7DOWN;
-		} else {
-			if ((pb->ipacket[4] & 0x0F) ||
-			    (pb->ipacket[5] & 0x0F))
-				touchpad_buttons |= MOUSE_BUTTON2DOWN;
+			/*
+			 * Zero out bits used by extended buttons to avoid
+			 * misinterpretation of the data absolute position.
+			 *
+			 * The bits represented by
+			 *
+			 *     (nExtendedButtons + 1) >> 1
+			 *
+			 * will be masked out in both bytes.
+			 * The mask for n bits is computed with the formula
+			 *
+			 *     (1 << n) - 1
+			 */
+			int maskedbits = 0;
+			int mask = 0;
+			maskedbits = (sc->synhw.nExtendedButtons + 1) >> 1;
+			mask = (1 << maskedbits) - 1;
+			pb->ipacket[4] &= ~(mask);
+			pb->ipacket[5] &= ~(mask);
+		} else	if (!sc->syninfo.directional_scrolls &&
+		    !sc->synaction.in_vscroll) {
+			/*
+			 * Keep reporting MOUSE DOWN until we get a new packet
+			 * indicating otherwise.
+			 */
+			touchpad_buttons |= sc->extended_buttons;
 		}
 	}
+	/* Handle ClickPad. */
+	if (sc->synhw.capClickPad &&
+	    ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x01))
+		touchpad_buttons |= MOUSE_BUTTON1DOWN;
 
 	ms->button = touchpad_buttons | guest_buttons;
 
-	/* Check pressure to detect a real wanted action on the
-	 * touchpad. */
+	/*
+	 * Check pressure to detect a real wanted action on the
+	 * touchpad.
+	 */
 	if (*z >= sc->syninfo.min_pressure) {
 		synapticsaction_t *synaction;
 		int cursor, peer, window;
@@ -2751,7 +2825,7 @@
 		int weight_current, weight_previous, weight_len_squared;
 		int div_min, div_max, div_len;
 		int vscroll_hor_area, vscroll_ver_area;
-
+		int two_finger_scroll;
 		int len, weight_prev_x, weight_prev_y;
 		int div_max_x, div_max_y, div_x, div_y;
 
@@ -2778,6 +2852,7 @@
 		div_len = sc->syninfo.div_len;
 		vscroll_hor_area = sc->syninfo.vscroll_hor_area;
 		vscroll_ver_area = sc->syninfo.vscroll_ver_area;
+		two_finger_scroll = sc->syninfo.two_finger_scroll;
 
 		/* Palm detection. */
 		if (!(
@@ -2937,34 +3012,58 @@
 			if (timevalcmp(&sc->lastsoftintr, &sc->taptimeout, >) ||
 			    dxp >= sc->syninfo.vscroll_min_delta ||
 			    dyp >= sc->syninfo.vscroll_min_delta) {
-				/* Check for horizontal scrolling. */
-				if ((vscroll_hor_area > 0 &&
-				    synaction->start_y <= vscroll_hor_area) ||
-				    (vscroll_hor_area < 0 &&
-				     synaction->start_y >=
-				     6143 + vscroll_hor_area))
-					synaction->in_vscroll += 2;
+				/*
+				 * Handle two finger scrolling.
+				 * Note that we don't rely on fingers_nb
+				 * as that keeps the maximum number of fingers.
+				 */
+				if (two_finger_scroll) {
+					if (w == 0) {
+						synaction->in_vscroll +=
+						    dyp ? 2 : 0;
+						synaction->in_vscroll +=
+						    dxp ? 1 : 0;
+					}
+				} else {
+					/* Check for horizontal scrolling. */
+					if ((vscroll_hor_area > 0 &&
+					    synaction->start_y <=
+					        vscroll_hor_area) ||
+					    (vscroll_hor_area < 0 &&
+					     synaction->start_y >=
+					     6143 + vscroll_hor_area))
+						synaction->in_vscroll += 2;
 
-				/* Check for vertical scrolling. */
-				if ((vscroll_ver_area > 0 &&
-				    synaction->start_x <= vscroll_ver_area) ||
-				    (vscroll_ver_area < 0 &&
-				     synaction->start_x >=
-				     6143 + vscroll_ver_area))
-					synaction->in_vscroll += 1;
+					/* Check for vertical scrolling. */
+					if ((vscroll_ver_area > 0 &&
+					    synaction->start_x <=
+						vscroll_ver_area) ||
+					    (vscroll_ver_area < 0 &&
+					     synaction->start_x >=
+					     6143 + vscroll_ver_area))
+						synaction->in_vscroll += 1;
+				}
 
 				/* Avoid conflicts if area overlaps. */
-				if (synaction->in_vscroll == 3)
+				if (synaction->in_vscroll >= 3)
 					synaction->in_vscroll =
 					    (dxp > dyp) ? 2 : 1;
 			}
-			VLOG(5, (LOG_DEBUG,
-			    "synaptics: virtual scrolling: %s "
-			    "(direction=%d, dxp=%d, dyp=%d)\n",
-			    synaction->in_vscroll ? "YES" : "NO",
-			    synaction->in_vscroll, dxp, dyp));
 		}
+		/*
+		 * Reset two finger scrolling when the number of fingers
+		 * is different from two.
+		 */
+		if (two_finger_scroll && w != 0)
+			synaction->in_vscroll = 0;
 
+		VLOG(5, (LOG_DEBUG,
+			"synaptics: virtual scrolling: %s "
+			"(direction=%d, dxp=%d, dyp=%d, fingers=%d)\n",
+			synaction->in_vscroll ? "YES" : "NO",
+			synaction->in_vscroll, dxp, dyp,
+			synaction->fingers_nb));
+
 		weight_prev_x = weight_prev_y = weight_previous;
 		div_max_x = div_max_y = div_max;
 
@@ -3205,6 +3304,7 @@
 	 * That's why the horizontal wheel is disabled by
 	 * default for now.
 	 */
+
 	if (ms->button & MOUSE_BUTTON4DOWN) {
 		*z = -1;
 		ms->button &= ~MOUSE_BUTTON4DOWN;
@@ -3418,7 +3518,7 @@
 			c = ((x < 0) ? MOUSE_PS2_XNEG : 0) |
 			    ((y < 0) ? MOUSE_PS2_YNEG : 0);
 			break;
-	
+
 		case MOUSE_MODEL_4D:
 			/*
 			 *          b7 b6 b5 b4 b3 b2 b1 b0
@@ -3477,8 +3577,11 @@
 			break;
 
 		case MOUSE_MODEL_SYNAPTICS:
-			if (proc_synaptics(sc, pb, &ms, &x, &y, &z) != 0)
+			if (proc_synaptics(sc, pb, &ms, &x, &y, &z) != 0) {
+				VLOG(3, (LOG_DEBUG, "synaptics: "
+				    "packet rejected\n"));
 				goto next;
+			}
 			break;
 
 		case MOUSE_MODEL_TRACKPOINT:
@@ -3535,9 +3638,9 @@
 		    sizeof(sc->queue.buf);
 		sc->queue.count += pb->inputbytes;
 	}
-	pb->inputbytes = 0;
 
 next:
+	pb->inputbytes = 0;
 	if (++sc->pqueue_start >= PSM_PACKETQUEUE)
 		sc->pqueue_start = 0;
 	} while (sc->pqueue_start != sc->pqueue_end);
@@ -4042,6 +4145,10 @@
 		if (arg < -6143 || arg > 6143)
 			return (EINVAL);
 		break;
+        case SYNAPTICS_SYSCTL_TOUCHPAD_OFF:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+		break;
 	default:
 		return (EINVAL);
 	}
@@ -4066,14 +4173,30 @@
 	    0, "Synaptics TouchPad");
 
 	/* hw.psm.synaptics.directional_scrolls. */
-	sc->syninfo.directional_scrolls = 1;
+	sc->syninfo.directional_scrolls = 0;
 	SYSCTL_ADD_INT(&sc->syninfo.sysctl_ctx,
 	    SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
 	    "directional_scrolls", CTLFLAG_RW|CTLFLAG_ANYBODY,
 	    &sc->syninfo.directional_scrolls, 0,
 	    "Enable hardware scrolling pad (if non-zero) or register it as "
-	    "a middle-click (if 0)");
+	    "extended buttons (if 0)");
 
+	/*
+	 * Turn off two finger scroll if we have a
+	 * physical area reserved for scrolling or when
+	 * there's no multi finger support.
+	 */
+	if (sc->synhw.verticalScroll || sc->synhw.capMultiFinger == 0)
+		sc->syninfo.two_finger_scroll = 0;
+	else
+		sc->syninfo.two_finger_scroll = 1;
+	/* hw.psm.synaptics.two_finger_scroll. */
+	SYSCTL_ADD_INT(&sc->syninfo.sysctl_ctx,
+	    SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
+	    "two_finger_scroll", CTLFLAG_RW|CTLFLAG_ANYBODY,
+	    &sc->syninfo.two_finger_scroll, 0,
+	    "Enable two finger scrolling");
+
 	/* hw.psm.synaptics.min_pressure. */
 	sc->syninfo.min_pressure = 16;
 	SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,
@@ -4353,6 +4476,15 @@
 	    &sc->syninfo.vscroll_div_max, SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX,
 	    synaptics_sysctl, "I",
 	    "Divisor for slow scrolling");
+
+	/* hw.psm.synaptics.touchpad_off. */
+	sc->syninfo.touchpad_off = 0;
+	SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,
+	    SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
+	    "touchpad_off", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY,
+	    &sc->syninfo.touchpad_off, SYNAPTICS_SYSCTL_TOUCHPAD_OFF,
+	    synaptics_sysctl, "I",
+	    "Turn off touchpad");
 }
 
 static int
@@ -4438,15 +4570,20 @@
 	buttons = 0;
 	synhw.capExtended = (status[0] & 0x80) != 0;
 	if (synhw.capExtended) {
-		synhw.capPassthrough = (status[2] & 0x80) != 0;
-		synhw.capSleep       = (status[2] & 0x10) != 0;
-		synhw.capFourButtons = (status[2] & 0x08) != 0;
-		synhw.capMultiFinger = (status[2] & 0x02) != 0;
-		synhw.capPalmDetect  = (status[2] & 0x01) != 0;
+		synhw.nExtendedQueries = (status[0] & 0x70) != 0;
+		synhw.capMiddle        = (status[0] & 0x04) != 0;
+		synhw.capPassthrough   = (status[2] & 0x80) != 0;
+		synhw.capSleep         = (status[2] & 0x10) != 0;
+		synhw.capFourButtons   = (status[2] & 0x08) != 0;
+		synhw.capMultiFinger   = (status[2] & 0x02) != 0;
+		synhw.capPalmDetect    = (status[2] & 0x01) != 0;
 
 		if (verbose >= 2) {
 			printf("  Extended capabilities:\n");
 			printf("   capExtended: %d\n", synhw.capExtended);
+			printf("   capMiddle: %d\n", synhw.capMiddle);
+			printf("   nExtendedQueries: %d\n",
+			    synhw.nExtendedQueries);
 			printf("   capPassthrough: %d\n", synhw.capPassthrough);
 			printf("   capSleep: %d\n", synhw.capSleep);
 			printf("   capFourButtons: %d\n", synhw.capFourButtons);
@@ -4455,16 +4592,41 @@
 		}
 
 		/*
-		 * If we have bits set in status[0] & 0x70, then we can load
+		 * If nExtendedQueries is 1 or greater, then the TouchPad
+		 * supports this number of extended queries. We can load
 		 * more information about buttons using query 0x09.
 		 */
-		if ((status[0] & 0x70) != 0) {
+		if (synhw.capExtended && synhw.nExtendedQueries) {
 			if (mouse_ext_command(kbdc, 0x09) == 0)
 				return (FALSE);
 			if (get_mouse_status(kbdc, status, 0, 3) != 3)
 				return (FALSE);
-			buttons = (status[1] & 0xf0) >> 4;
+			synhw.verticalScroll   = (status[0] & 0x01) != 0;
+			synhw.horizontalScroll = (status[0] & 0x02) != 0;
+			synhw.verticalWheel    = (status[0] & 0x08) != 0;
+			synhw.nExtendedButtons = (status[1] & 0xf0) >> 4;
+			if (verbose >= 2) {
+				printf("  Extended model ID:\n");
+				printf("   verticalScroll: %d\n",
+				    synhw.verticalScroll);
+				printf("   horizontalScroll: %d\n",
+				    synhw.horizontalScroll);
+				printf("   verticalWheel: %d\n",
+				    synhw.verticalWheel);
+				printf("   nExtendedButtons: %d\n",
+				    synhw.nExtendedButtons);
+			}
+			/*
+			 * Add the number of extended buttons to the total
+			 * button support count, including the middle button
+			 * if capMiddle support bit is set.
+			 */
+			buttons = synhw.nExtendedButtons + synhw.capMiddle;
 		} else
+			/*
+			 * If the capFourButtons support bit is set,
+			 * add a fourth button to the total button count.
+			 */
 			buttons = synhw.capFourButtons ? 1 : 0;
 	}
 	if (verbose >= 2) {
@@ -4474,7 +4636,49 @@
 			printf("  No extended capabilities\n");
 	}
 
+	/* Read the continued capabilities bits. */
+	if (mouse_ext_command(kbdc, 0xc) != 0 &&
+	    get_mouse_status(kbdc, status, 0, 3) == 3) {
+		synhw.capClickPad         = (status[1] & 0x01) << 1;
+		synhw.capClickPad        |= (status[0] & 0x10) != 0;
+		synhw.capDeluxeLEDs       = (status[1] & 0x02) != 0;
+		synhw.noAbsoluteFilter    = (status[1] & 0x04) != 0;
+		synhw.capReportsV         = (status[1] & 0x08) != 0;
+		synhw.capUniformClickPad  = (status[1] & 0x10) != 0;
+		synhw.capReportsMin       = (status[1] & 0x20) != 0;
+		synhw.capInterTouch       = (status[1] & 0x40) != 0;
+		synhw.capReportsMax       = (status[2] & 0x02) != 0;
+		synhw.capClearPad         = (status[2] & 0x04) != 0;
+		synhw.capAdvancedGestures = (status[2] & 0x08) != 0;
+		synhw.capCoveredPad       = (status[2] & 0x80) != 0;
+
+		if (verbose >= 2) {
+			printf("  Continued capabilities:\n");
+			printf("   capClickPad: %d\n", synhw.capClickPad);
+			printf("   capDeluxeLEDs: %d\n", synhw.capDeluxeLEDs);
+			printf("   noAbsoluteFilter: %d\n",
+			    synhw.noAbsoluteFilter);
+			printf("   capReportsV: %d\n", synhw.capReportsV);
+			printf("   capUniformClickPad: %d\n",
+			    synhw.capUniformClickPad);
+			printf("   capReportsMin: %d\n", synhw.capReportsMin);
+			printf("   capInterTouch: %d\n", synhw.capInterTouch);
+			printf("   capReportsMax: %d\n", synhw.capReportsMax);
+			printf("   capClearPad: %d\n", synhw.capClearPad);
+			printf("   capAdvancedGestures: %d\n",
+			    synhw.capAdvancedGestures);
+			printf("   capCoveredPad: %d\n", synhw.capCoveredPad);
+		}
+		buttons += synhw.capClickPad;
+	}
+
 	/*
+	 * Add the default number of 3 buttons to the total
+	 * count of supported buttons reported above.
+	 */
+	buttons += 3;
+
+	/*
 	 * Read the mode byte.
 	 *
 	 * XXX: Note the Synaptics documentation also defines the first
@@ -4501,13 +4705,16 @@
 	/* "Commit" the Set Mode Byte command sent above. */
 	set_mouse_sampling_rate(kbdc, 20);
 
-	buttons += 3;
 	VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons));
 
 	if (sc != NULL) {
+		if (trackpoint_support && synhw.capPassthrough) {
+			synaptics_passthrough_on(sc);
+			enable_trackpoint(kbdc, sc);
+			synaptics_passthrough_off(sc);
+		}
 		/* Create sysctl tree. */
 		synaptics_sysctl_create_tree(sc);
-
 		sc->hw.buttons = buttons;
 	}
 
@@ -4514,16 +4721,62 @@
 	return (TRUE);
 }
 
+static void
+synaptics_passthrough_on(struct psm_softc *sc)
+{
+	int mode_byte;
+
+	mode_byte = 0xc1 | (1 << 5);
+	VLOG(2, (LOG_NOTICE, "psm: setting pass-through mode. %d\n",
+		mode_byte));
+	mouse_ext_command(sc->kbdc, mode_byte);
+
+	/* "Commit" the Set Mode Byte command sent above. */
+	set_mouse_sampling_rate(sc->kbdc, 20);
+}
+
+static void
+synaptics_passthrough_off(struct psm_softc *sc)
+{
+	int mode_byte;
+
+	mode_byte = 0xc1;
+	VLOG(2, (LOG_NOTICE, "psm: turning pass-through mode off.\n"));
+	set_mouse_scaling(sc->kbdc, 2);
+	set_mouse_scaling(sc->kbdc, 1);
+	mouse_ext_command(sc->kbdc, mode_byte);
+
+	/* "Commit" the Set Mode Byte command sent above. */
+	set_mouse_sampling_rate(sc->kbdc, 20);
+}
+
 /* IBM/Lenovo TrackPoint */
 static int
-trackpoint_command(KBDC kbdc, int cmd, int loc, int val)
+trackpoint_command(struct psm_softc *sc, int cmd, int loc, int val)
 {
 	const int seq[] = { 0xe2, cmd, loc, val };
 	int i;
 
-	for (i = 0; i < nitems(seq); i++)
-		if (send_aux_command(kbdc, seq[i]) != PSM_ACK)
+	if (sc->synhw.capPassthrough)
+		synaptics_passthrough_on(sc);
+
+	for (i = 0; i < nitems(seq); i++) {
+		if (sc->synhw.capPassthrough &&
+		    (seq[i] == 0xff || seq[i] == 0xe7))
+			if (send_aux_command(sc->kbdc, 0xe7) != PSM_ACK) {
+				synaptics_passthrough_off(sc);
+				return (EIO);
+			}
+		if (send_aux_command(sc->kbdc, seq[i]) != PSM_ACK) {
+			if (sc->synhw.capPassthrough)
+				synaptics_passthrough_off(sc);
 			return (EIO);
+		}
+	}
+
+	if (sc->synhw.capPassthrough)
+		synaptics_passthrough_off(sc);
+
 	return (0);
 }
 
@@ -4566,7 +4819,7 @@
 		return (0);
 	if (newval < 0 || newval > (tp[TPMASK] == 0 ? 255 : 1))
 		return (EINVAL);
-	error = trackpoint_command(sc->kbdc, tp[TPMASK] == 0 ? 0x81 : 0x47,
+	error = trackpoint_command(sc, tp[TPMASK] == 0 ? 0x81 : 0x47,
 	    tp[TPLOC], tp[TPMASK] == 0 ? newval : tp[TPMASK]);
 	if (error != 0)
 		return (error);
@@ -4589,7 +4842,7 @@
 	    0, "IBM/Lenovo TrackPoint");
 
 	/* hw.psm.trackpoint.sensitivity */
-	sc->tpinfo.sensitivity = 0x64;
+	sc->tpinfo.sensitivity = 0x80;
 	SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx,
 	    SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO,
 	    "sensitivity", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY,
@@ -4697,13 +4950,30 @@
 	    "Skip backups from drags");
 }
 
+static void
+set_trackpoint_parameters(struct psm_softc *sc)
+{
+	trackpoint_command(sc, 0x81, 0x4a, sc->tpinfo.sensitivity);
+	trackpoint_command(sc, 0x81, 0x60, sc->tpinfo.uplateau);
+	trackpoint_command(sc, 0x81, 0x4d, sc->tpinfo.inertia);
+	trackpoint_command(sc, 0x81, 0x57, sc->tpinfo.reach);
+	trackpoint_command(sc, 0x81, 0x58, sc->tpinfo.draghys);
+	trackpoint_command(sc, 0x81, 0x59, sc->tpinfo.mindrag);
+	trackpoint_command(sc, 0x81, 0x5a, sc->tpinfo.upthresh);
+	trackpoint_command(sc, 0x81, 0x5c, sc->tpinfo.threshold);
+	trackpoint_command(sc, 0x81, 0x5d, sc->tpinfo.jenks);
+	trackpoint_command(sc, 0x81, 0x5e, sc->tpinfo.ztime);
+	if (sc->tpinfo.pts == 0x01)
+		trackpoint_command(sc, 0x47, 0x2c, 0x01);
+	if (sc->tpinfo.skipback == 0x01)
+		trackpoint_command(sc, 0x47, 0x2d, 0x08);
+}
+
 static int
 enable_trackpoint(KBDC kbdc, struct psm_softc *sc)
 {
 	int id;
 
-	kbdc = sc->kbdc;
-
 	if (send_aux_command(kbdc, 0xe1) != PSM_ACK ||
 	    read_aux_data(kbdc) != 0x01)
 		return (FALSE);
@@ -4719,23 +4989,14 @@
 		/* Create sysctl tree. */
 		trackpoint_sysctl_create_tree(sc);
 
-		trackpoint_command(kbdc, 0x81, 0x4a, sc->tpinfo.sensitivity);
-		trackpoint_command(kbdc, 0x81, 0x4d, sc->tpinfo.inertia);
-		trackpoint_command(kbdc, 0x81, 0x60, sc->tpinfo.uplateau);
-		trackpoint_command(kbdc, 0x81, 0x57, sc->tpinfo.reach);
-		trackpoint_command(kbdc, 0x81, 0x58, sc->tpinfo.draghys);
-		trackpoint_command(kbdc, 0x81, 0x59, sc->tpinfo.mindrag);
-		trackpoint_command(kbdc, 0x81, 0x5a, sc->tpinfo.upthresh);
-		trackpoint_command(kbdc, 0x81, 0x5c, sc->tpinfo.threshold);
-		trackpoint_command(kbdc, 0x81, 0x5d, sc->tpinfo.jenks);
-		trackpoint_command(kbdc, 0x81, 0x5e, sc->tpinfo.ztime);
-		if (sc->tpinfo.pts == 0x01)
-			trackpoint_command(kbdc, 0x47, 0x2c, 0x01);
-		if (sc->tpinfo.skipback == 0x01)
-			trackpoint_command(kbdc, 0x47, 0x2d, 0x08);
-
-		sc->hw.hwid = id;
-		sc->hw.buttons = 3;
+		/*
+		 * Don't overwrite hwid and buttons when we are
+		 * a guest device.
+		 */
+		if (!sc->synhw.capPassthrough) {
+			sc->hw.hwid = id;
+			sc->hw.buttons = 3;
+		}
 	}
 
 	return (TRUE);

Modified: trunk/sys/dev/atkbdc/psm.h
===================================================================
--- trunk/sys/dev/atkbdc/psm.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/atkbdc/psm.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1992, 1993 Erik Forsberg.
  * Copyright (c) 1996, 1997 Kazutaka YOKOTA.
@@ -21,7 +22,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  *	from: FreeBSD: src/sys/isa/psm.c,v 1.84 2005/01/10 13:05:58 philip
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/atkbdc/psm.h 147271 2005-06-10 20:56:38Z marius $
  */
 
 #ifndef _DEV_ATKBDC_PSM_H_

Added: trunk/sys/dev/bvm/bvm_console.c
===================================================================
--- trunk/sys/dev/bvm/bvm_console.c	                        (rev 0)
+++ trunk/sys/dev/bvm/bvm_console.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -0,0 +1,241 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/sys/dev/bvm/bvm_console.c 245678 2013-01-20 03:42:49Z neel $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/bvm/bvm_console.c 245678 2013-01-20 03:42:49Z neel $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/cons.h>
+#include <sys/tty.h>
+#include <sys/reboot.h>
+#include <sys/bus.h>
+
+#include <sys/kdb.h>
+#include <ddb/ddb.h>
+
+#ifndef	BVMCONS_POLL_HZ
+#define	BVMCONS_POLL_HZ	4
+#endif
+#define BVMBURSTLEN	16	/* max number of bytes to write in one chunk */
+
+static tsw_open_t bvm_tty_open;
+static tsw_close_t bvm_tty_close;
+static tsw_outwakeup_t bvm_tty_outwakeup;
+
+static struct ttydevsw bvm_ttydevsw = {
+	.tsw_flags	= TF_NOPREFIX,
+	.tsw_open	= bvm_tty_open,
+	.tsw_close	= bvm_tty_close,
+	.tsw_outwakeup	= bvm_tty_outwakeup,
+};
+
+static int			polltime;
+static struct callout_handle	bvm_timeouthandle
+    = CALLOUT_HANDLE_INITIALIZER(&bvm_timeouthandle);
+
+#if defined(KDB)
+static int			alt_break_state;
+#endif
+
+#define	BVM_CONS_PORT	0x220
+static int bvm_cons_port = BVM_CONS_PORT;
+
+#define BVM_CONS_SIG	('b' << 8 | 'v')
+
+static void	bvm_timeout(void *);
+
+static cn_probe_t	bvm_cnprobe;
+static cn_init_t	bvm_cninit;
+static cn_term_t	bvm_cnterm;
+static cn_getc_t	bvm_cngetc;
+static cn_putc_t	bvm_cnputc;
+static cn_grab_t 	bvm_cngrab;
+static cn_ungrab_t 	bvm_cnungrab;
+
+CONSOLE_DRIVER(bvm);
+
+static int
+bvm_rcons(u_char *ch)
+{
+	int c;
+
+	c = inl(bvm_cons_port);
+	if (c != -1) {
+		*ch = (u_char)c;
+		return (0);
+	} else
+		return (-1);
+}
+
+static void
+bvm_wcons(u_char ch)
+{
+
+	outl(bvm_cons_port, ch);
+}
+
+static void
+cn_drvinit(void *unused)
+{
+	struct tty *tp;
+
+	if (bvm_consdev.cn_pri != CN_DEAD &&
+	    bvm_consdev.cn_name[0] != '\0') {
+		tp = tty_alloc(&bvm_ttydevsw, NULL);
+		tty_makedev(tp, NULL, "bvmcons");
+	}
+}
+
+static int
+bvm_tty_open(struct tty *tp)
+{
+	polltime = hz / BVMCONS_POLL_HZ;
+	if (polltime < 1)
+		polltime = 1;
+	bvm_timeouthandle = timeout(bvm_timeout, tp, polltime);
+
+	return (0);
+}
+
+static void
+bvm_tty_close(struct tty *tp)
+{
+
+	/* XXX Should be replaced with callout_stop(9) */
+	untimeout(bvm_timeout, tp, bvm_timeouthandle);
+}
+
+static void
+bvm_tty_outwakeup(struct tty *tp)
+{
+	int len, written;
+	u_char buf[BVMBURSTLEN];
+
+	for (;;) {
+		len = ttydisc_getc(tp, buf, sizeof(buf));
+		if (len == 0)
+			break;
+
+		written = 0;
+		while (written < len)
+			bvm_wcons(buf[written++]);
+	}
+}
+
+static void
+bvm_timeout(void *v)
+{
+	struct	tty *tp;
+	int 	c;
+
+	tp = (struct tty *)v;
+
+	tty_lock(tp);
+	while ((c = bvm_cngetc(NULL)) != -1)
+		ttydisc_rint(tp, c, 0);
+	ttydisc_rint_done(tp);
+	tty_unlock(tp);
+
+	bvm_timeouthandle = timeout(bvm_timeout, tp, polltime);
+}
+
+static void
+bvm_cnprobe(struct consdev *cp)
+{
+	int disabled, port;
+
+	disabled = 0;
+	cp->cn_pri = CN_DEAD;
+
+	resource_int_value("bvmconsole", 0, "disabled", &disabled);
+	if (!disabled) {
+		if (resource_int_value("bvmconsole", 0, "port", &port) == 0)
+			bvm_cons_port = port;
+
+		if (inw(bvm_cons_port) == BVM_CONS_SIG)
+			cp->cn_pri = CN_REMOTE;
+	}
+}
+
+static void
+bvm_cninit(struct consdev *cp)
+{
+	int i;
+	const char *bootmsg = "Using bvm console.\n";
+
+	if (boothowto & RB_VERBOSE) {
+		for (i = 0; i < strlen(bootmsg); i++)
+			bvm_cnputc(cp, bootmsg[i]);
+	}
+
+	strcpy(cp->cn_name, "bvmcons");
+}
+
+static void
+bvm_cnterm(struct consdev *cp)
+{
+
+}
+
+static int
+bvm_cngetc(struct consdev *cp)
+{
+	unsigned char ch;
+
+	if (bvm_rcons(&ch) == 0) {
+#if defined(KDB)
+		kdb_alt_break(ch, &alt_break_state);
+#endif
+		return (ch);
+	}
+
+	return (-1);
+}
+
+static void
+bvm_cnputc(struct consdev *cp, int c)
+{
+
+	bvm_wcons(c);
+}
+
+static void
+bvm_cngrab(struct consdev *cp)
+{
+}
+
+static void
+bvm_cnungrab(struct consdev *cp)
+{
+}
+
+SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL);


Property changes on: trunk/sys/dev/bvm/bvm_console.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/bvm/bvm_dbg.c
===================================================================
--- trunk/sys/dev/bvm/bvm_dbg.c	                        (rev 0)
+++ trunk/sys/dev/bvm/bvm_dbg.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -0,0 +1,101 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/sys/dev/bvm/bvm_dbg.c 245678 2013-01-20 03:42:49Z neel $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/bvm/bvm_dbg.c 245678 2013-01-20 03:42:49Z neel $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+
+#include <gdb/gdb.h>
+
+#include <machine/cpufunc.h>
+
+static gdb_probe_f bvm_dbg_probe;
+static gdb_init_f bvm_dbg_init;
+static gdb_term_f bvm_dbg_term;
+static gdb_getc_f bvm_dbg_getc;
+static gdb_putc_f bvm_dbg_putc;
+
+GDB_DBGPORT(bvm, bvm_dbg_probe, bvm_dbg_init, bvm_dbg_term,
+    bvm_dbg_getc, bvm_dbg_putc);
+
+#define	BVM_DBG_PORT	0x224
+static int bvm_dbg_port = BVM_DBG_PORT;
+
+#define BVM_DBG_SIG	('B' << 8 | 'V')
+
+static int
+bvm_dbg_probe(void)
+{
+	int disabled, port;
+
+	disabled = 0;
+	resource_int_value("bvmdbg", 0, "disabled", &disabled);
+
+	if (!disabled) {
+		if (resource_int_value("bvmdbg", 0, "port", &port) == 0)
+			bvm_dbg_port = port;
+
+		if (inw(bvm_dbg_port) == BVM_DBG_SIG) {
+			/*
+			 * Return a higher priority than 0 to override other
+			 * gdb dbgport providers that may be present (e.g. uart)
+			 */
+			return (1);
+		}
+	}
+
+	return (-1);
+}
+
+static void
+bvm_dbg_init(void)
+{
+}
+
+static void
+bvm_dbg_term(void)
+{
+}
+
+static void
+bvm_dbg_putc(int c)
+{
+
+	outl(bvm_dbg_port, c);
+}
+
+static int
+bvm_dbg_getc(void)
+{
+
+	return (inl(bvm_dbg_port));
+}


Property changes on: trunk/sys/dev/bvm/bvm_dbg.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/bwi/bitops.h
===================================================================
--- trunk/sys/dev/bwi/bitops.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bitops.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 David Young.  All rights reserved.
  *
@@ -29,7 +30,7 @@
  * OF SUCH DAMAGE.
  *
  * $DragonFly: src/sys/dev/netif/bwi/bitops.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/bitops.h 191762 2009-05-03 04:01:43Z imp $
  */
 
 #ifndef _BITOPS_H

Modified: trunk/sys/dev/bwi/bwimac.c
===================================================================
--- trunk/sys/dev/bwi/bwimac.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwimac.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -35,10 +36,11 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwi/bwimac.c 254279 2013-08-13 09:58:27Z adrian $");
 
 #include "opt_inet.h"
 #include "opt_bwi.h"
+#include "opt_wlan.h"
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -1426,7 +1428,8 @@
 		enum ieee80211_phytype modtype;
 		uint16_t ofs;
 
-		modtype = ieee80211_rate2phytype(rt, rs->rs_rates[i]);
+		modtype = ieee80211_rate2phytype(rt,
+		    rs->rs_rates[i] & IEEE80211_RATE_VAL);
 		switch (modtype) {
 		case IEEE80211_T_DS:
 			ofs = 0x4c0;
@@ -1437,7 +1440,9 @@
 		default:
 			panic("unsupported modtype %u\n", modtype);
 		}
-		ofs += 2*(ieee80211_rate2plcp(rs->rs_rates[i], modtype) & 0xf);
+		ofs += 2*(ieee80211_rate2plcp(
+		    rs->rs_rates[i] & IEEE80211_RATE_VAL,
+		    modtype) & 0xf);
 
 		MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, ofs + 0x20,
 			     MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs));

Modified: trunk/sys/dev/bwi/bwimac.h
===================================================================
--- trunk/sys/dev/bwi/bwimac.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwimac.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  * 
  * $DragonFly: src/sys/dev/netif/bwi/bwimac.h,v 1.2 2008/02/15 11:15:38 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/bwimac.h 191762 2009-05-03 04:01:43Z imp $
  */
 
 #ifndef _BWI_MAC_H

Modified: trunk/sys/dev/bwi/bwiphy.c
===================================================================
--- trunk/sys/dev/bwi/bwiphy.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwiphy.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -35,9 +36,10 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwi/bwiphy.c 235338 2012-05-12 15:11:53Z adrian $");
 
 #include "opt_inet.h"
+#include "opt_wlan.h"
 
 #include <sys/param.h>
 #include <sys/endian.h>

Modified: trunk/sys/dev/bwi/bwiphy.h
===================================================================
--- trunk/sys/dev/bwi/bwiphy.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwiphy.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  * 
  * $DragonFly: src/sys/dev/netif/bwi/bwiphy.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/bwiphy.h 191762 2009-05-03 04:01:43Z imp $
  */
 
 #ifndef _BWI_PHY_H

Modified: trunk/sys/dev/bwi/bwirf.c
===================================================================
--- trunk/sys/dev/bwi/bwirf.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwirf.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -35,10 +36,11 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwi/bwirf.c 235338 2012-05-12 15:11:53Z adrian $");
 
 #include "opt_inet.h"
 #include "opt_bwi.h"
+#include "opt_wlan.h"
 
 #include <sys/param.h>
 #include <sys/endian.h>

Modified: trunk/sys/dev/bwi/bwirf.h
===================================================================
--- trunk/sys/dev/bwi/bwirf.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/bwirf.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  * 
  * $DragonFly: src/sys/dev/netif/bwi/bwirf.h,v 1.3 2007/10/03 04:53:19 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/bwirf.h 191762 2009-05-03 04:01:43Z imp $
  */
 
 #ifndef _BWI_RF_H

Modified: trunk/sys/dev/bwi/if_bwi.c
===================================================================
--- trunk/sys/dev/bwi/if_bwi.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/if_bwi.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -35,10 +36,11 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwi/if_bwi.c 308367 2016-11-06 13:50:54Z avos $");
 
 #include "opt_inet.h"
 #include "opt_bwi.h"
+#include "opt_wlan.h"
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -1394,7 +1396,7 @@
 
 		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
 		wh = mtod(m, struct ieee80211_frame *);
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
 			k = ieee80211_crypto_encap(ni, m);
 			if (k == NULL) {
 				ieee80211_free_node(ni);
@@ -1914,10 +1916,10 @@
 			       lowaddr,			/* lowaddr */
 			       BUS_SPACE_MAXADDR,	/* highaddr */
 			       NULL, NULL,		/* filter, filterarg */
-			       MAXBSIZE,		/* maxsize */
+			       BUS_SPACE_MAXSIZE,	/* maxsize */
 			       BUS_SPACE_UNRESTRICTED,	/* nsegments */
 			       BUS_SPACE_MAXSIZE_32BIT,	/* maxsegsize */
-			       BUS_DMA_ALLOCNOW,	/* flags */
+			       0,			/* flags */
 			       NULL, NULL,		/* lockfunc, lockarg */
 			       &sc->sc_parent_dtag);
 	if (error) {
@@ -1938,7 +1940,7 @@
 				tx_ring_sz,
 				1,
 				BUS_SPACE_MAXSIZE_32BIT,
-				BUS_DMA_ALLOCNOW,
+				0,
 				NULL, NULL,
 				&sc->sc_txring_dtag);
 	if (error) {
@@ -1968,7 +1970,7 @@
 				rx_ring_sz,
 				1,
 				BUS_SPACE_MAXSIZE_32BIT,
-				BUS_DMA_ALLOCNOW,
+				0,
 				NULL, NULL,
 				&sc->sc_rxring_dtag);
 	if (error) {
@@ -2093,7 +2095,7 @@
 				dma_size,
 				1,
 				BUS_SPACE_MAXSIZE_32BIT,
-				BUS_DMA_ALLOCNOW,
+				0,
 				NULL, NULL,
 				&st->stats_ring_dtag);
 	if (error) {
@@ -2141,7 +2143,7 @@
 				dma_size,
 				1,
 				BUS_SPACE_MAXSIZE_32BIT,
-				BUS_DMA_ALLOCNOW,
+				0,
 				NULL, NULL,
 				&st->stats_dtag);
 	if (error) {
@@ -2223,7 +2225,7 @@
 				NULL, NULL,
 				MCLBYTES,
 				1,
-				BUS_SPACE_MAXSIZE_32BIT,
+				MCLBYTES,
 				BUS_DMA_ALLOCNOW,
 				NULL, NULL,
 				&sc->sc_buf_dtag);
@@ -2999,7 +3001,7 @@
 	 */
 	if (ieee80211_radiotap_active_vap(vap)) {
 		sc->sc_tx_th.wt_flags = 0;
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
 		if (ieee80211_rate2phytype(sc->sc_rates, rate) == IEEE80211_T_DS &&
 		    (ic->ic_flags & IEEE80211_F_SHPREAMBLE) &&
@@ -3182,7 +3184,7 @@
 	if (ieee80211_radiotap_active_vap(vap)) {
 		sc->sc_tx_th.wt_flags = 0;
 		/* XXX IEEE80211_BPF_CRYPTO */
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
 		if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
@@ -3818,7 +3820,7 @@
 		sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
 
 	wh = mtod(m, const struct ieee80211_frame_min *);
-	if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+	if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 		sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_WEP;
 
 	sc->sc_rx_th.wr_tsf = hdr->rxh_tsf; /* No endian convertion */

Modified: trunk/sys/dev/bwi/if_bwi_pci.c
===================================================================
--- trunk/sys/dev/bwi/if_bwi_pci.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/if_bwi_pci.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -28,12 +29,14 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwi/if_bwi_pci.c 235338 2012-05-12 15:11:53Z adrian $");
 
 /*
  * PCI/Cardbus front-end for the Broadcom Wireless LAN controller driver.
  */
 
+#include "opt_wlan.h"
+
 #include <sys/param.h>
 #include <sys/systm.h> 
 #include <sys/module.h>

Modified: trunk/sys/dev/bwi/if_bwireg.h
===================================================================
--- trunk/sys/dev/bwi/if_bwireg.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/if_bwireg.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  * 
  * $DragonFly: src/sys/dev/netif/bwi/if_bwireg.h,v 1.4 2007/10/19 14:27:04 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/if_bwireg.h 192279 2009-05-18 01:07:38Z imp $
  */
 
 #ifndef _IF_BWIREG_H

Modified: trunk/sys/dev/bwi/if_bwivar.h
===================================================================
--- trunk/sys/dev/bwi/if_bwivar.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwi/if_bwivar.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  * 
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  * 
  * $DragonFly: src/sys/dev/netif/bwi/if_bwivar.h,v 1.14 2008/02/15 11:15:38 sephe Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwi/if_bwivar.h 206358 2010-04-07 15:29:13Z rpaulo $
  */
 
 #ifndef _IF_BWIVAR_H

Modified: trunk/sys/dev/bwn/if_bwn.c
===================================================================
--- trunk/sys/dev/bwn/if_bwn.c	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwn/if_bwn.c	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Weongyo Jeong <weongyo at freebsd.org>
  * All rights reserved.
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/bwn/if_bwn.c 281826 2015-04-21 11:27:50Z mav $");
 
 /*
  * The Broadcom Wireless LAN controller driver.
@@ -1316,7 +1317,7 @@
 		}
 		KASSERT(ni != NULL, ("%s:%d: fail", __func__, __LINE__));
 		wh = mtod(m, struct ieee80211_frame *);
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
 			k = ieee80211_crypto_encap(ni, m);
 			if (k == NULL) {
 				ieee80211_free_node(ni);
@@ -9179,7 +9180,7 @@
 	struct bwn_dma *dma = &mac->mac_method.dma;
 	struct bwn_rxhdr4 *hdr;
 	bus_dmamap_t map;
-	bus_addr_t paddr = 0;
+	bus_addr_t paddr;
 	struct mbuf *m;
 	int error;
 
@@ -9242,7 +9243,7 @@
 	/*
 	 * Setup RX buf descriptor
 	 */
-	dr->setdesc(dr, desc, paddr, meta->mt_m->m_len -
+	dr->setdesc(dr, desc, meta->mt_paddr, meta->mt_m->m_len -
 	    sizeof(*hdr), 0, 0, 0);
 	return (error);
 }
@@ -9780,7 +9781,7 @@
 	 */
 	if (ieee80211_radiotap_active_vap(vap)) {
 		sc->sc_tx_th.wt_flags = 0;
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
 		if (isshort &&
 		    (rate == BWN_CCK_RATE_2MB || rate == BWN_CCK_RATE_5MB ||
@@ -10319,7 +10320,7 @@
 		sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
 
 	wh = mtod(m, const struct ieee80211_frame_min *);
-	if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+	if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 		sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_WEP;
 
 	bwn_tsf_read(mac, &tsf);
@@ -10381,7 +10382,7 @@
 			       lowaddr,			/* lowaddr */
 			       BUS_SPACE_MAXADDR,	/* highaddr */
 			       NULL, NULL,		/* filter, filterarg */
-			       MAXBSIZE,		/* maxsize */
+			       BUS_SPACE_MAXSIZE,	/* maxsize */
 			       BUS_SPACE_UNRESTRICTED,	/* nsegments */
 			       BUS_SPACE_MAXSIZE,	/* maxsegsize */
 			       0,			/* flags */

Modified: trunk/sys/dev/bwn/if_bwnreg.h
===================================================================
--- trunk/sys/dev/bwn/if_bwnreg.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwn/if_bwnreg.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Weongyo Jeong <weongyo at freebsd.org>
  * All rights reserved.
@@ -26,7 +27,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwn/if_bwnreg.h 203945 2010-02-16 01:44:14Z weongyo $
  */
 
 #ifndef _IF_BWNREG_H

Modified: trunk/sys/dev/bwn/if_bwnvar.h
===================================================================
--- trunk/sys/dev/bwn/if_bwnvar.h	2018-05-28 00:22:33 UTC (rev 10125)
+++ trunk/sys/dev/bwn/if_bwnvar.h	2018-05-28 00:22:50 UTC (rev 10126)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Weongyo Jeong <weongyo at freebsd.org>
  * All rights reserved.
@@ -26,7 +27,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/bwn/if_bwnvar.h 228399 2011-12-10 21:05:06Z eadler $
  */
 
 #ifndef _IF_BWNVAR_H



More information about the Midnightbsd-cvs mailing list