diff options
Diffstat (limited to 'sys/dev')
38 files changed, 648 insertions, 507 deletions
diff --git a/sys/dev/acpi/acpi_pci.c b/sys/dev/acpi/acpi_pci.c index 617f2143952..51aa29d91dd 100644 --- a/sys/dev/acpi/acpi_pci.c +++ b/sys/dev/acpi/acpi_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pci.c,v 1.24 2018/10/21 11:04:26 jmcneill Exp $ */ +/* $NetBSD: acpi_pci.c,v 1.25 2019/01/27 02:08:41 pgoyette Exp $ */ /* * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.24 2018/10/21 11:04:26 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.25 2019/01/27 02:08:41 pgoyette Exp $"); #include <sys/param.h> #include <sys/device.h> diff --git a/sys/dev/ata/ld_ataraid.c b/sys/dev/ata/ld_ataraid.c index ee925d3b31e..986389bdecf 100644 --- a/sys/dev/ata/ld_ataraid.c +++ b/sys/dev/ata/ld_ataraid.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.49 2019/01/27 02:08:41 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.49 2019/01/27 02:08:41 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "bio.h" diff --git a/sys/dev/bio.c b/sys/dev/bio.c index 50505296ac2..bcc64a1ac6d 100644 --- a/sys/dev/bio.c +++ b/sys/dev/bio.c @@ -1,4 +1,4 @@ -/* $NetBSD: bio.c,v 1.13 2015/08/20 14:40:17 christos Exp $ */ +/* $NetBSD: bio.c,v 1.14 2019/01/27 02:08:41 pgoyette Exp $ */ /* $OpenBSD: bio.c,v 1.9 2007/03/20 02:35:55 marco Exp $ */ /* @@ -28,7 +28,7 @@ /* A device controller ioctl tunnelling device. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13 2015/08/20 14:40:17 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.14 2019/01/27 02:08:41 pgoyette Exp $"); #include "opt_compat_netbsd.h" @@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13 2015/08/20 14:40:17 christos Exp $"); #include <sys/mutex.h> #include <sys/proc.h> #include <sys/kauth.h> +#include <sys/compat_stub.h> #include <dev/biovar.h> #include <dev/sysmon/sysmonvar.h> @@ -127,10 +128,8 @@ bioioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) case BIOCDISK: case BIOCDISK_NOVOL: case BIOCVOL: -#ifdef COMPAT_30 case OBIOCDISK: case OBIOCVOL: -#endif error = kauth_authorize_device_passthru(l->l_cred, dev, KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_READCONF, addr); if (error) @@ -190,43 +189,12 @@ bioioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) return ENOENT; } mutex_exit(&bio_lock); -#ifdef COMPAT_30 - switch (cmd) { - case OBIOCDISK: { - struct bioc_disk *bd = - malloc(sizeof(*bd), M_DEVBUF, M_WAITOK|M_ZERO); - - (void)memcpy(bd, addr, sizeof(struct obioc_disk)); - error = bio_delegate_ioctl(common->bc_cookie, - BIOCDISK, bd); - if (error) { - free(bd, M_DEVBUF); - return error; - } - - (void)memcpy(addr, bd, sizeof(struct obioc_disk)); - free(bd, M_DEVBUF); - return 0; - } - case OBIOCVOL: { - struct bioc_vol *bv = - malloc(sizeof(*bv), M_DEVBUF, M_WAITOK|M_ZERO); - - (void)memcpy(bv, addr, sizeof(struct obioc_vol)); - error = bio_delegate_ioctl(common->bc_cookie, - BIOCVOL, bv); - if (error) { - free(bv, M_DEVBUF); - return error; - } - - (void)memcpy(addr, bv, sizeof(struct obioc_vol)); - free(bv, M_DEVBUF); - return 0; - } - } -#endif - error = bio_delegate_ioctl(common->bc_cookie, cmd, addr); + MODULE_CALL_HOOK(compat_bio_30_hook, + (common->bc_cookie, cmd, addr, bio_delegate_ioctl), + enosys(), error); + if (error == ENOSYS) + error = bio_delegate_ioctl(common->bc_cookie, cmd, + addr); return error; } return 0; diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index 21ae7397255..d29ccdc09a7 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.176 2018/03/18 20:33:52 christos Exp $ */ +/* $NetBSD: ccd.c,v 1.177 2019/01/27 02:08:41 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.176 2018/03/18 20:33:52 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.177 2019/01/27 02:08:41 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -115,6 +115,7 @@ __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.176 2018/03/18 20:33:52 christos Exp $"); #include <sys/kthread.h> #include <sys/bufq.h> #include <sys/sysctl.h> +#include <sys/compat_stub.h> #include <uvm/uvm_extern.h> @@ -1080,7 +1081,7 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { int unit = ccdunit(dev); int i, j, lookedup = 0, error = 0; - int part, pmask, make; + int part, pmask, make, hook; struct ccd_softc *cs; struct ccd_ioctl *ccio = (struct ccd_ioctl *)data; kauth_cred_t uc; @@ -1096,7 +1097,10 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) make = 1; break; default: - if ((*compat_ccd_ioctl_60)(0, cmd, NULL, 0, NULL, NULL) == 0) + MODULE_CALL_HOOK(ccd_ioctl_60_hook, + (0, cmd, NULL, 0, NULL, NULL), + enosys(), hook); + if (hook == 0) make = 1; else make = 0; @@ -1107,7 +1111,9 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return ENOENT; uc = kauth_cred_get(); - error = (*compat_ccd_ioctl_60)(dev, cmd, data, flag, l, ccdioctl); + MODULE_CALL_HOOK(ccd_ioctl_60_hook, + (dev, cmd, data, flag, l, ccdioctl), + enosys(), error); if (error != ENOSYS) return error; diff --git a/sys/dev/clockctl.c b/sys/dev/clockctl.c index 0cf726e717b..bb8cc1e924d 100644 --- a/sys/dev/clockctl.c +++ b/sys/dev/clockctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $ */ +/* $NetBSD: clockctl.c,v 1.36 2019/01/27 02:08:41 pgoyette Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.36 2019/01/27 02:08:41 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ntp.h" @@ -46,18 +46,16 @@ __KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $"); #include <sys/device.h> #include <sys/time.h> #include <sys/conf.h> -#ifdef NTP #include <sys/timex.h> -#endif /* NTP */ #include <sys/kauth.h> #include <sys/module.h> #include <sys/mutex.h> +#include <sys/compat_stub.h> #include <sys/clockctl.h> -#ifdef COMPAT_50 #include <compat/sys/clockctl.h> #include <compat/sys/time_types.h> -#endif + kmutex_t clockctl_mtx; int clockctl_refcnt; @@ -245,101 +243,31 @@ clockctlioctl( error = clock_settime1(l->l_proc, args->clock_id, &ts, false); break; } -#ifdef NTP case CLOCKCTL_NTP_ADJTIME: { struct clockctl_ntp_adjtime *args = data; struct timex ntv; + if (vec_ntp_timestatus == NULL) { + error = ENOTTY; + break; + } error = copyin(args->tp, &ntv, sizeof(ntv)); if (error) return (error); - ntp_adjtime1(&ntv); + (*vec_ntp_adjtime1)(&ntv); error = copyout(&ntv, args->tp, sizeof(ntv)); if (error == 0) - args->retval = ntp_timestatus(); - break; - } -#endif /* NTP */ - default: -#ifdef COMPAT_50 - error = compat50_clockctlioctl(dev, cmd, data, flags, l); -#else - error = ENOTTY; -#endif - } - - return (error); -} - -#ifdef COMPAT_50 -int -compat50_clockctlioctl(dev_t dev, u_long cmd, void *data, int flags, - struct lwp *l) -{ - int error = 0; - const struct cdevsw *cd = cdevsw_lookup(dev); - - if (cd == NULL || cd->d_ioctl == NULL) - return ENXIO; - - switch (cmd) { - case CLOCKCTL_OSETTIMEOFDAY: { - struct timeval50 tv50; - struct timeval tv; - struct clockctl50_settimeofday *args = data; - - error = copyin(args->tv, &tv50, sizeof(tv50)); - if (error) - return (error); - timeval50_to_timeval(&tv50, &tv); - error = settimeofday1(&tv, false, args->tzp, l, false); - break; - } - case CLOCKCTL_OADJTIME: { - struct timeval atv, oldatv; - struct timeval50 atv50; - struct clockctl50_adjtime *args = data; - - if (args->delta) { - error = copyin(args->delta, &atv50, sizeof(atv50)); - if (error) - return (error); - timeval50_to_timeval(&atv50, &atv); - } - adjtime1(args->delta ? &atv : NULL, - args->olddelta ? &oldatv : NULL, l->l_proc); - if (args->olddelta) { - timeval_to_timeval50(&oldatv, &atv50); - error = copyout(&atv50, args->olddelta, sizeof(atv50)); - } - break; - } - case CLOCKCTL_OCLOCK_SETTIME: { - struct timespec50 tp50; - struct timespec tp; - struct clockctl50_clock_settime *args = data; - - error = copyin(args->tp, &tp50, sizeof(tp50)); - if (error) - return (error); - timespec50_to_timespec(&tp50, &tp); - error = clock_settime1(l->l_proc, args->clock_id, &tp, true); + args->retval = (*vec_ntp_timestatus)(); break; } -#ifdef NTP - case CLOCKCTL_ONTP_ADJTIME: { - /* The ioctl number changed but the data did not change. */ - error = (cd->d_ioctl)(dev, CLOCKCTL_NTP_ADJTIME, - data, flags, l); - break; - } -#endif default: - error = ENOTTY; + MODULE_CALL_HOOK(clockctl_ioctl_50_hook, + (dev, cmd, data, flags, l), enosys(), error); + if (error == ENOSYS) + error = ENOTTY; } return (error); } -#endif diff --git a/sys/dev/fdt/fdt_subr.c b/sys/dev/fdt/fdt_subr.c index 6ebf86267ab..21189ee5ba8 100644 --- a/sys/dev/fdt/fdt_subr.c +++ b/sys/dev/fdt/fdt_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_subr.c,v 1.24 2018/10/06 16:28:21 skrll Exp $ */ +/* $NetBSD: fdt_subr.c,v 1.25 2019/01/27 02:08:41 pgoyette Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,9 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.24 2018/10/06 16:28:21 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.25 2019/01/27 02:08:41 pgoyette Exp $"); + +#include "opt_fdt.h" #include "opt_fdt.h" diff --git a/sys/dev/gpio/gpio.c b/sys/dev/gpio/gpio.c index 30bfaa5ae00..630cca91754 100644 --- a/sys/dev/gpio/gpio.c +++ b/sys/dev/gpio/gpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpio.c,v 1.61 2018/05/19 13:59:06 thorpej Exp $ */ +/* $NetBSD: gpio.c,v 1.62 2019/01/27 02:08:41 pgoyette Exp $ */ /* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */ /* @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.61 2018/05/19 13:59:06 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.62 2019/01/27 02:08:41 pgoyette Exp $"); /* * General Purpose Input/Output framework. diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c index 53a3898790a..abd282a5cf1 100644 --- a/sys/dev/i2c/i2c.c +++ b/sys/dev/i2c/i2c.c @@ -1,4 +1,4 @@ -/* $NetBSD: i2c.c,v 1.67 2018/12/09 19:21:16 jdolecek Exp $ */ +/* $NetBSD: i2c.c,v 1.68 2019/01/27 02:08:41 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.67 2018/12/09 19:21:16 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.68 2019/01/27 02:08:41 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> diff --git a/sys/dev/ic/ne2000.c b/sys/dev/ic/ne2000.c index a53f634beb1..8f76eceb5d4 100644 --- a/sys/dev/ic/ne2000.c +++ b/sys/dev/ic/ne2000.c @@ -1,4 +1,4 @@ -/* $NetBSD: ne2000.c,v 1.75 2018/07/15 05:16:45 maxv Exp $ */ +/* $NetBSD: ne2000.c,v 1.76 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.75 2018/07/15 05:16:45 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.76 2019/01/27 02:08:42 pgoyette Exp $"); #include "rtl80x9.h" diff --git a/sys/dev/marvell/com_mv.c b/sys/dev/marvell/com_mv.c index 11706626220..e3ab17c84fc 100644 --- a/sys/dev/marvell/com_mv.c +++ b/sys/dev/marvell/com_mv.c @@ -1,4 +1,4 @@ -/* $NetBSD: com_mv.c,v 1.11 2018/12/11 19:40:54 martin Exp $ */ +/* $NetBSD: com_mv.c,v 1.12 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 2007, 2010 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.11 2018/12/11 19:40:54 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.12 2019/01/27 02:08:42 pgoyette Exp $"); #include <sys/param.h> #include <sys/bus.h> diff --git a/sys/dev/pci/ahcisata_pci.c b/sys/dev/pci/ahcisata_pci.c index 92e4fd178cd..79152f72c30 100644 --- a/sys/dev/pci/ahcisata_pci.c +++ b/sys/dev/pci/ahcisata_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_pci.c,v 1.54 2019/01/22 22:22:06 jdolecek Exp $ */ +/* $NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,11 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.54 2019/01/22 22:22:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_ahcisata_pci.h" +#endif #ifdef _KERNEL_OPT #include "opt_ahcisata_pci.h" diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c index 179648ef19c..6e602209b5c 100644 --- a/sys/dev/pci/if_msk.c +++ b/sys/dev/pci/if_msk.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_msk.c,v 1.84 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: if_msk.c,v 1.85 2019/01/27 02:08:42 pgoyette Exp $ */ /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ /* @@ -52,7 +52,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.84 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.85 2019/01/27 02:08:42 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> diff --git a/sys/dev/pci/if_ne_pci.c b/sys/dev/pci/if_ne_pci.c index f5082407fc3..8003863ef18 100644 --- a/sys/dev/pci/if_ne_pci.c +++ b/sys/dev/pci/if_ne_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ne_pci.c,v 1.39 2018/12/09 11:14:02 jdolecek Exp $ */ +/* $NetBSD: if_ne_pci.c,v 1.40 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ne_pci.c,v 1.39 2018/12/09 11:14:02 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ne_pci.c,v 1.40 2019/01/27 02:08:42 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index cecfc558178..2c6d11c1f87 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $NetBSD: mpii.c,v 1.19 2018/12/28 15:06:07 kardel Exp $ */ +/* $NetBSD: mpii.c,v 1.20 2019/01/27 02:08:42 pgoyette Exp $ */ /* $OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov @@ -20,7 +20,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.19 2018/12/28 15:06:07 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.20 2019/01/27 02:08:42 pgoyette Exp $"); #include "bio.h" diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c index d3166fc3c27..7acc0318edd 100644 --- a/sys/dev/pci/ppb.c +++ b/sys/dev/pci/ppb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppb.c,v 1.64 2018/12/07 09:36:26 msaitoh Exp $ */ +/* $NetBSD: ppb.c,v 1.65 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 1996, 1998 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,11 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.64 2018/12/07 09:36:26 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.65 2019/01/27 02:08:42 pgoyette Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_ppb.h" +#endif #ifdef _KERNEL_OPT #include "opt_ppb.h" diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c index 5d5430c264e..de884218d43 100644 --- a/sys/dev/pci/virtio_pci.c +++ b/sys/dev/pci/virtio_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.6 2019/01/14 14:55:37 yamaguchi Exp $ */ +/* $NetBSD: virtio_pci.c,v 1.7 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.6 2019/01/14 14:55:37 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.7 2019/01/27 02:08:42 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -853,4 +853,3 @@ virtio_pci_modcmd(modcmd_t cmd, void *opaque) return error; } - diff --git a/sys/dev/raidframe/rf_compat50.c b/sys/dev/raidframe/rf_compat50.c index e637ecb02eb..108385a5481 100644 --- a/sys/dev/raidframe/rf_compat50.c +++ b/sys/dev/raidframe/rf_compat50.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat50.c,v 1.3 2018/01/18 00:32:49 mrg Exp $ */ +/* $NetBSD: rf_compat50.c,v 1.4 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -39,12 +39,16 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> + +#include <sys/compat_stub.h> #include <dev/raidframe/raidframeio.h> #include <dev/raidframe/raidframevar.h> #include "rf_raid.h" #include "rf_compat50.h" +#include "rf_compat50_mod.h" #include "rf_debugMem.h" typedef struct RF_Config50_s { @@ -214,3 +218,56 @@ out: RF_Free(d_cfg, sizeof(RF_DeviceConfig50_t)); return error; } + +int +raidframe_ioctl_50(int cmd, int initted, RF_Raid_t *raidPtr, int unit, + void *data, RF_Config_t **k_cfg) +{ + int error; + + switch (cmd) { + case RAIDFRAME_GET_INFO50: + if (initted == 0) + return ENXIO; + return rf_get_info50(raidPtr, data); + + case RAIDFRAME_CONFIGURE50: + error = rf_config50(raidPtr, unit, data, k_cfg); + if (error != 0) + return error; + return EAGAIN; /* flag mainline to call generic config */ + } + return EPASSTHROUGH; +} + +void +raidframe_50_init(void) +{ + + MODULE_SET_HOOK(raidframe50_ioctl_hook, "raid50", raidframe_ioctl_50); +} + +void +raidframe_50_fini(void) +{ + + MODULE_UNSET_HOOK(raidframe50_ioctl_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_raid_50, "raid,compat_50,compat_raid_80"); + +static int +compat_raid_50_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + raidframe_50_init(); + return 0; + case MODULE_CMD_FINI: + raidframe_50_fini(); + return 0; + default: + return ENOTTY; + } +} diff --git a/sys/dev/raidframe/rf_compat50.h b/sys/dev/raidframe/rf_compat50.h index 29990c8f4dc..69d3aa82593 100644 --- a/sys/dev/raidframe/rf_compat50.h +++ b/sys/dev/raidframe/rf_compat50.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat50.h,v 1.2 2015/09/06 06:01:00 dholland Exp $ */ +/* $NetBSD: rf_compat50.h,v 1.3 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -47,4 +47,6 @@ int rf_config50(RF_Raid_t *, int, void *, RF_Config_t **); int rf_get_info50(RF_Raid_t *, void *); +int raidframe_ioctl_50(int, int, RF_Raid_t *, int, void *, RF_Config_t **); + #endif /* _RF_COMPAT50_H_ */ diff --git a/sys/dev/raidframe/rf_compat50_mod.h b/sys/dev/raidframe/rf_compat50_mod.h new file mode 100644 index 00000000000..a9447d00beb --- /dev/null +++ b/sys/dev/raidframe/rf_compat50_mod.h @@ -0,0 +1,39 @@ +/* $NetBSD: rf_compat50_mod.h,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RF_COMPAT50_MOD_H_ +#define _RF_COMPAT50_MOD_H_ + +void raidframe_50_fini(void); +void raidframe_50_init(void); + +#endif /* _RF_COMPAT50_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_compat80.c b/sys/dev/raidframe/rf_compat80.c index 53b963da8a3..b6a204b41e4 100644 --- a/sys/dev/raidframe/rf_compat80.c +++ b/sys/dev/raidframe/rf_compat80.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat80.c,v 1.2 2018/01/20 01:32:45 mrg Exp $ */ +/* $NetBSD: rf_compat80.c,v 1.3 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 2017 Matthew R. Green @@ -31,12 +31,16 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> + +#include <sys/compat_stub.h> #include <dev/raidframe/raidframeio.h> #include <dev/raidframe/raidframevar.h> #include "rf_raid.h" #include "rf_compat80.h" +#include "rf_compat80_mod.h" #include "rf_kintf.h" int @@ -217,3 +221,78 @@ rf_config80(RF_Raid_t *raidPtr, int unit, void *data, RF_Config_t **k_cfgp) *k_cfgp = k_cfg; return 0; } + +int +raidframe_ioctl_80(int cmd, int initted, RF_Raid_t *raidPtr, int unit, + void *data, RF_Config_t **k_cfg) +{ +int error; + + switch (cmd) { + case RAIDFRAME_CHECK_RECON_STATUS_EXT80: + case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80: + case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80: + case RAIDFRAME_GET_INFO80: + case RAIDFRAME_GET_COMPONENT_LABEL80: + if (initted == 0) + return ENXIO; + break; + case RAIDFRAME_CONFIGURE80: + break; + case RAIDFRAME_FAIL_DISK80: + return EPASSTHROUGH; + default: + return EINVAL; + } + + switch (cmd) { + case RAIDFRAME_CHECK_RECON_STATUS_EXT80: + return rf_check_recon_status_ext80(raidPtr, data); + case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80: + return rf_check_parityrewrite_status_ext80(raidPtr, data); + case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80: + return rf_check_copyback_status_ext80(raidPtr, data); + case RAIDFRAME_GET_INFO80: + return rf_get_info80(raidPtr, data); + case RAIDFRAME_GET_COMPONENT_LABEL80: + return rf_get_component_label80(raidPtr, data); + case RAIDFRAME_CONFIGURE80: + error = rf_config80(raidPtr, unit, data, k_cfg); + if (error != 0) + return error; + return EAGAIN; /* flag mainline to call generic config */ + } + return EPASSTHROUGH; +} + +void +raidframe_80_init(void) +{ + + MODULE_SET_HOOK(raidframe80_ioctl_hook, "raid80", raidframe_ioctl_80); +} + +void +raidframe_80_fini(void) +{ + + MODULE_UNSET_HOOK(raidframe80_ioctl_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_raid_80, "raid,compat_80"); + +static int +compat_raid_80_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + raidframe_80_init(); + return 0; + case MODULE_CMD_FINI: + raidframe_80_fini(); + return 0; + default: + return ENOTTY; + } +} diff --git a/sys/dev/raidframe/rf_compat80_mod.h b/sys/dev/raidframe/rf_compat80_mod.h new file mode 100644 index 00000000000..9f0a627e5d8 --- /dev/null +++ b/sys/dev/raidframe/rf_compat80_mod.h @@ -0,0 +1,44 @@ +/* $NetBSD: rf_compat80_mod.h,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RF_COMPAT80_MOD_H_ +#define _RF_COMPAT80_MOD_H_ + +struct RF_Raid_s; +struct RF_Config_s; + +int raidframe_ioctl_80(int, int, struct RF_Raid_s *, int, void *, + struct RF_Config_s **); + +void raidframe_80_init(void); +void raidframe_80_fini(void); + +#endif /* _RF_COMPAT80_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 67182036a93..f373aaf0397 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.358 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.358 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -128,6 +128,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp #include <sys/reboot.h> #include <sys/kauth.h> #include <sys/module.h> +#include <sys/compat_stub.h> #include <prop/proplib.h> @@ -149,13 +150,9 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp #include "rf_parityscan.h" #include "rf_threadstuff.h" -#ifdef COMPAT_50 #include "rf_compat50.h" -#endif -#ifdef COMPAT_80 #include "rf_compat80.h" -#endif #ifdef COMPAT_NETBSD32 #include "rf_compat32.h" @@ -1104,16 +1101,6 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) case RAIDFRAME_PARITYMAP_GET_DISABLE: case RAIDFRAME_PARITYMAP_SET_DISABLE: case RAIDFRAME_PARITYMAP_SET_PARAMS: -#ifdef COMPAT_50 - case RAIDFRAME_GET_INFO50: -#endif -#ifdef COMPAT_80 - case RAIDFRAME_CHECK_RECON_STATUS_EXT80: - case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80: - case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80: - case RAIDFRAME_GET_INFO80: - case RAIDFRAME_GET_COMPONENT_LABEL80: -#endif #ifdef COMPAT_NETBSD32 #ifdef _LP64 case RAIDFRAME_GET_INFO32: @@ -1123,38 +1110,44 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return (ENXIO); } - switch (cmd) { -#ifdef COMPAT_50 - case RAIDFRAME_GET_INFO50: - return rf_get_info50(raidPtr, data); - - case RAIDFRAME_CONFIGURE50: - if ((retcode = rf_config50(raidPtr, unit, data, &k_cfg)) != 0) - return retcode; + /* + * Handle compat ioctl calls + * + * * If compat code is not loaded, stub returns ENOSYS and we just + * check the "native" cmd's + * * If compat code is loaded but does not recognize the cmd, it + * returns EPASSTHROUGH, and we just check the "native" cmd's + * * If compat code returns EAGAIN, we need to finish via config + * * Otherwise the cmd has been handled and we just return + */ + MODULE_CALL_HOOK(raidframe50_ioctl_hook, + (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), + enosys(), retcode); + if (retcode == ENOSYS) + retcode = 0; + else if (retcode == EAGAIN) goto config; -#endif - -#ifdef COMPAT_80 - case RAIDFRAME_CHECK_RECON_STATUS_EXT80: - return rf_check_recon_status_ext80(raidPtr, data); - - case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80: - return rf_check_parityrewrite_status_ext80(raidPtr, data); - - case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80: - return rf_check_copyback_status_ext80(raidPtr, data); - - case RAIDFRAME_GET_INFO80: - return rf_get_info80(raidPtr, data); + else if (retcode != EPASSTHROUGH) + return retcode; + + MODULE_CALL_HOOK(raidframe80_ioctl_hook, + (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), + enosys(), retcode); + if (retcode == ENOSYS) + retcode = 0; + else if (retcode == EAGAIN) + goto config; + else if (retcode != EPASSTHROUGH) + return retcode; - case RAIDFRAME_GET_COMPONENT_LABEL80: - return rf_get_component_label80(raidPtr, data); + /* + * XXX + * Handling of FAIL_DISK80 command requires us to retain retcode's + * value of EPASSTHROUGH. If you add more compat code later, make + * sure you don't overwrite retcode and break this! + */ - case RAIDFRAME_CONFIGURE80: - if ((retcode = rf_config80(raidPtr, unit, data, &k_cfg)) != 0) - return retcode; - goto config; -#endif + switch (cmd) { /* configure the system */ case RAIDFRAME_CONFIGURE: @@ -1563,11 +1556,12 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return (0); /* fail a disk & optionally start reconstruction */ - case RAIDFRAME_FAIL_DISK: -#ifdef COMPAT_80 case RAIDFRAME_FAIL_DISK80: -#endif - + /* Check if we called compat code for this cmd */ + if (retcode != EPASSTHROUGH) + return EINVAL; + /* FALLTHRU */ + case RAIDFRAME_FAIL_DISK: if (raidPtr->Layout.map->faultsTolerated == 0) { /* Can't do this on a RAID 0!! */ return(EINVAL); diff --git a/sys/dev/sysmon/sysmon_power.c b/sys/dev/sysmon/sysmon_power.c index 7872d425d45..97065e2f92e 100644 --- a/sys/dev/sysmon/sysmon_power.c +++ b/sys/dev/sysmon/sysmon_power.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.58 2017/10/25 08:12:39 maya Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.59 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.58 2017/10/25 08:12:39 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.59 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.58 2017/10/25 08:12:39 maya Exp $ #include <sys/rndsource.h> #include <sys/module.h> #include <sys/once.h> +#include <sys/compat_stub.h> #include <dev/sysmon/sysmonvar.h> #include <prop/proplib.h> @@ -344,16 +345,10 @@ sysmon_power_daemon_task(struct power_event_dictionary *ped, (struct sysmon_pswitch *)pev_data; pev.pev_type = POWER_EVENT_SWITCH_STATE_CHANGE; -#ifdef COMPAT_40 - pev.pev_switch.psws_state = event; - pev.pev_switch.psws_type = pswitch->smpsw_type; - - if (pswitch->smpsw_name) { - (void)strlcpy(pev.pev_switch.psws_name, - pswitch->smpsw_name, - sizeof(pev.pev_switch.psws_name)); - } -#endif + + MODULE_CALL_VOID_HOOK(compat_sysmon_power_40_hook, + (&pev, pswitch, event), __nothing); + error = sysmon_power_make_dictionary(ped->dict, pswitch, event, diff --git a/sys/dev/usb/if_bwfm_usb.c b/sys/dev/usb/if_bwfm_usb.c index e225bb60707..1396d5f5977 100644 --- a/sys/dev/usb/if_bwfm_usb.c +++ b/sys/dev/usb/if_bwfm_usb.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_usb.c,v 1.8 2018/09/01 22:01:03 riastradh Exp $ */ +/* $NetBSD: if_bwfm_usb.c,v 1.9 2019/01/27 02:08:42 pgoyette Exp $ */ /* $OpenBSD: if_bwfm_usb.c,v 1.2 2017/10/15 14:55:13 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bwfm_usb.c,v 1.8 2018/09/01 22:01:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bwfm_usb.c,v 1.9 2019/01/27 02:08:42 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> diff --git a/sys/dev/usb/if_smsc.c b/sys/dev/usb/if_smsc.c index be57db71958..0755fd2be7a 100644 --- a/sys/dev/usb/if_smsc.c +++ b/sys/dev/usb/if_smsc.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.40 2019/01/22 06:37:54 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.41 2019/01/27 02:08:42 pgoyette Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.40 2019/01/22 06:37:54 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.41 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c index a9ebbe0ed98..6f62b57c796 100644 --- a/sys/dev/usb/if_umb.c +++ b/sys/dev/usb/if_umb.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_umb.c,v 1.7 2018/11/15 10:56:30 maxv Exp $ */ +/* $NetBSD: if_umb.c,v 1.8 2019/01/27 02:08:42 pgoyette Exp $ */ /* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */ /* @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.7 2018/11/15 10:56:30 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.8 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 790ceb25313..e479ad7e4a8 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $ */ +/* $NetBSD: ugen.c,v 1.142 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.142 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $"); #include <sys/proc.h> #include <sys/vnode.h> #include <sys/poll.h> +#include <sys/compat_stub.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -1835,13 +1836,17 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, usbd_fill_deviceinfo(sc->sc_udev, (struct usb_device_info *)addr, 0); break; -#ifdef COMPAT_30 case USB_GET_DEVICEINFO_OLD: - usbd_fill_deviceinfo_old(sc->sc_udev, - (struct usb_device_info_old *)addr, 0); - - break; -#endif + { + int ret; + MODULE_CALL_HOOK(usb_subr_30_fill_hook, + (sc->sc_udev, (struct usb_device_info_old *)addr, 0, + usbd_devinfo_vp, usbd_printBCD), + enosys(), ret); + if (ret == 0) + return 0; + return EINVAL; + } default: return EINVAL; } diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index b8f9923bc37..21048fb33bd 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhid.c,v 1.102 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: uhid.c,v 1.103 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.102 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.103 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.102 2018/09/03 16:29:34 riastradh Exp $") #include <sys/vnode.h> #include <sys/poll.h> #include <sys/intr.h> +#include <sys/compat_stub.h> #include <dev/usb/usb.h> #include <dev/usb/usbhid.h> @@ -652,13 +653,15 @@ uhid_do_ioctl(struct uhid_softc *sc, u_long cmd, void *addr, usbd_fill_deviceinfo(sc->sc_hdev.sc_parent->sc_udev, (struct usb_device_info *)addr, 0); break; -#ifdef COMPAT_30 case USB_GET_DEVICEINFO_OLD: - usbd_fill_deviceinfo_old(sc->sc_hdev.sc_parent->sc_udev, - (struct usb_device_info_old *)addr, 0); - + MODULE_CALL_HOOK(usb_subr_30_fill_hook, + (sc->sc_hdev.sc_parent->sc_udev, + (struct usb_device_info_old *)addr, 0, + usbd_devinfo_vp, usbd_printBCD), + enosys(), err); + if (err == 0) + return 0; break; -#endif case USB_GET_STRING_DESC: { struct usb_string_desc *si = (struct usb_string_desc *)addr; diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index aa359da935b..873504b14f7 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.174 2018/09/18 05:37:54 mrg Exp $ */ +/* $NetBSD: usb.c,v 1.175 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.174 2018/09/18 05:37:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.175 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -64,6 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.174 2018/09/18 05:37:54 mrg Exp $"); #include <sys/once.h> #include <sys/atomic.h> #include <sys/sysctl.h> +#include <sys/compat_stub.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -201,10 +202,6 @@ Static int usb_get_next_event(struct usb_event *); Static void usb_async_intr(void *); Static void usb_soft_intr(void *); -#ifdef COMPAT_30 -Static void usb_copy_old_devinfo(struct usb_device_info_old *, const struct usb_device_info *); -#endif - Static const char *usbrev_str[] = USBREV_STR; static int usb_match(device_t, cfdata_t, void *); @@ -663,22 +660,18 @@ int usbread(dev_t dev, struct uio *uio, int flag) { struct usb_event *ue; -#ifdef COMPAT_30 struct usb_event_old *ueo = NULL; /* XXXGCC */ int useold = 0; -#endif int error, n; if (minor(dev) != USB_DEV_MINOR) return ENXIO; switch (uio->uio_resid) { -#ifdef COMPAT_30 case sizeof(struct usb_event_old): ueo = kmem_zalloc(sizeof(struct usb_event_old), KM_SLEEP); useold = 1; /* FALLTHRU */ -#endif case sizeof(struct usb_event): ue = usb_alloc_event(); break; @@ -702,43 +695,20 @@ usbread(dev_t dev, struct uio *uio, int flag) } mutex_exit(&usb_event_lock); if (!error) { -#ifdef COMPAT_30 if (useold) { /* copy fields to old struct */ - ueo->ue_type = ue->ue_type; - memcpy(&ueo->ue_time, &ue->ue_time, - sizeof(struct timespec)); - switch (ue->ue_type) { - case USB_EVENT_DEVICE_ATTACH: - case USB_EVENT_DEVICE_DETACH: - usb_copy_old_devinfo(&ueo->u.ue_device, &ue->u.ue_device); - break; - - case USB_EVENT_CTRLR_ATTACH: - case USB_EVENT_CTRLR_DETACH: - ueo->u.ue_ctrlr.ue_bus=ue->u.ue_ctrlr.ue_bus; - break; - - case USB_EVENT_DRIVER_ATTACH: - case USB_EVENT_DRIVER_DETACH: - ueo->u.ue_driver.ue_cookie=ue->u.ue_driver.ue_cookie; - memcpy(ueo->u.ue_driver.ue_devname, - ue->u.ue_driver.ue_devname, - sizeof(ue->u.ue_driver.ue_devname)); - break; - default: - ; - } + MODULE_CALL_HOOK(usb_subr_30_copy_hook, + (ue, ueo, uio), enosys(), error); + if (error == ENOSYS) + error = EINVAL; - error = uiomove((void *)ueo, sizeof(*ueo), uio); + if (!error) + error = uiomove((void *)ueo, sizeof(*ueo), uio); } else -#endif error = uiomove((void *)ue, sizeof(*ue), uio); } usb_free_event(ue); -#ifdef COMPAT_30 - if (useold) + if (ueo) kmem_free(ueo, sizeof(struct usb_event_old)); -#endif return error; } @@ -892,7 +862,6 @@ usbioctl(dev_t devt, u_long cmd, void *data, int flag, struct lwp *l) break; } -#ifdef COMPAT_30 case USB_DEVICEINFO_OLD: { struct usbd_device *dev; @@ -908,10 +877,14 @@ usbioctl(dev_t devt, u_long cmd, void *data, int flag, struct lwp *l) error = ENXIO; goto fail; } - usbd_fill_deviceinfo_old(dev, di, 1); - break; + MODULE_CALL_HOOK(usb_subr_30_fill_hook, + (dev, di, 1, usbd_devinfo_vp, usbd_printBCD), + enosys(), error); + if (error == ENOSYS) + error = EINVAL; + if (error) + goto fail; } -#endif case USB_DEVICESTATS: *(struct usb_device_stats *)data = sc->sc_bus->ub_stats; @@ -1259,62 +1232,3 @@ usb_detach(device_t self, int flags) return 0; } - -#ifdef COMPAT_30 -Static void -usb_copy_old_devinfo(struct usb_device_info_old *uo, - const struct usb_device_info *ue) -{ - const unsigned char *p; - unsigned char *q; - int i, n; - - uo->udi_bus = ue->udi_bus; - uo->udi_addr = ue->udi_addr; - uo->udi_cookie = ue->udi_cookie; - for (i = 0, p = (const unsigned char *)ue->udi_product, - q = (unsigned char *)uo->udi_product; - *p && i < USB_MAX_STRING_LEN - 1; p++) { - if (*p < 0x80) - q[i++] = *p; - else { - q[i++] = '?'; - if ((*p & 0xe0) == 0xe0) - p++; - p++; - } - } - q[i] = 0; - - for (i = 0, p = ue->udi_vendor, q = uo->udi_vendor; - *p && i < USB_MAX_STRING_LEN - 1; p++) { - if (* p < 0x80) - q[i++] = *p; - else { - q[i++] = '?'; - p++; - if ((*p & 0xe0) == 0xe0) - p++; - } - } - q[i] = 0; - - memcpy(uo->udi_release, ue->udi_release, sizeof(uo->udi_release)); - - uo->udi_productNo = ue->udi_productNo; - uo->udi_vendorNo = ue->udi_vendorNo; - uo->udi_releaseNo = ue->udi_releaseNo; - uo->udi_class = ue->udi_class; - uo->udi_subclass = ue->udi_subclass; - uo->udi_protocol = ue->udi_protocol; - uo->udi_config = ue->udi_config; - uo->udi_speed = ue->udi_speed; - uo->udi_power = ue->udi_power; - uo->udi_nports = ue->udi_nports; - - for (n=0; n<USB_MAX_DEVNAMES; n++) - memcpy(uo->udi_devnames[n], - ue->udi_devnames[n], USB_MAX_DEVNAMELEN); - memcpy(uo->udi_ports, ue->udi_ports, sizeof(uo->udi_ports)); -} -#endif diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 4c74c63e80a..32f5ac291e2 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.228 2018/10/23 01:49:37 manu Exp $ */ +/* $NetBSD: usb_subr.c,v 1.229 2019/01/27 02:08:42 pgoyette Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.228 2018/10/23 01:49:37 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.229 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -68,8 +68,6 @@ __KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.228 2018/10/23 01:49:37 manu Exp $"); Static usbd_status usbd_set_config(struct usbd_device *, int); Static void usbd_devinfo(struct usbd_device *, int, char *, size_t); -Static void usbd_devinfo_vp(struct usbd_device *, char *, size_t, char *, size_t, - int, int); Static int usbd_getnewaddr(struct usbd_bus *); Static int usbd_print(void *, const char *); Static int usbd_ifprint(void *, const char *); @@ -194,7 +192,7 @@ usbd_get_device_strings(struct usbd_device *ud) } -Static void +void usbd_devinfo_vp(struct usbd_device *dev, char *v, size_t vl, char *p, size_t pl, int usedev, int useencoded) { @@ -1587,76 +1585,6 @@ usbd_fill_deviceinfo(struct usbd_device *dev, struct usb_device_info *di, di->udi_nports = nports; } -#ifdef COMPAT_30 -void -usbd_fill_deviceinfo_old(struct usbd_device *dev, struct usb_device_info_old *di, - int usedev) -{ - struct usbd_port *p; - int i, j, err; - - di->udi_bus = device_unit(dev->ud_bus->ub_usbctl); - di->udi_addr = dev->ud_addr; - di->udi_cookie = dev->ud_cookie; - usbd_devinfo_vp(dev, di->udi_vendor, sizeof(di->udi_vendor), - di->udi_product, sizeof(di->udi_product), usedev, 0); - usbd_printBCD(di->udi_release, sizeof(di->udi_release), - UGETW(dev->ud_ddesc.bcdDevice)); - di->udi_vendorNo = UGETW(dev->ud_ddesc.idVendor); - di->udi_productNo = UGETW(dev->ud_ddesc.idProduct); - di->udi_releaseNo = UGETW(dev->ud_ddesc.bcdDevice); - di->udi_class = dev->ud_ddesc.bDeviceClass; - di->udi_subclass = dev->ud_ddesc.bDeviceSubClass; - di->udi_protocol = dev->ud_ddesc.bDeviceProtocol; - di->udi_config = dev->ud_config; - di->udi_power = dev->ud_selfpowered ? 0 : dev->ud_power; - di->udi_speed = dev->ud_speed; - - if (dev->ud_subdevlen > 0) { - for (i = 0, j = 0; i < dev->ud_subdevlen && - j < USB_MAX_DEVNAMES; i++) { - if (!dev->ud_subdevs[i]) - continue; - strncpy(di->udi_devnames[j], - device_xname(dev->ud_subdevs[i]), USB_MAX_DEVNAMELEN); - di->udi_devnames[j][USB_MAX_DEVNAMELEN-1] = '\0'; - j++; - } - } else { - j = 0; - } - for (/* j is set */; j < USB_MAX_DEVNAMES; j++) - di->udi_devnames[j][0] = 0; /* empty */ - - if (!dev->ud_hub) { - di->udi_nports = 0; - return; - } - - const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; - for (i = 1; i <= __arraycount(di->udi_ports) && i <= nports; - i++) { - p = &dev->ud_hub->uh_ports[i - 1]; - if (p->up_dev) - err = p->up_dev->ud_addr; - else { - const int s = UGETW(p->up_status.wPortStatus); - if (s & UPS_PORT_ENABLED) - err = USB_PORT_ENABLED; - else if (s & UPS_SUSPEND) - err = USB_PORT_SUSPENDED; - else if (s & UPS_PORT_POWER) - err = USB_PORT_POWERED; - else - err = USB_PORT_DISABLED; - } - di->udi_ports[i - 1] = err; - } - di->udi_nports = nports; -} -#endif - - void usb_free_device(struct usbd_device *dev) { diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index bef17f70f11..6c228d6119c 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.h,v 1.95 2018/08/02 06:09:04 riastradh Exp $ */ +/* $NetBSD: usbdi.h,v 1.96 2019/01/27 02:08:42 pgoyette Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ /* @@ -158,10 +158,6 @@ usbd_status usbd_get_interface(struct usbd_interface *, uint8_t *); int usbd_get_no_alts(usb_config_descriptor_t *, int); void usbd_fill_deviceinfo(struct usbd_device *, struct usb_device_info *, int); -#ifdef COMPAT_30 -void usbd_fill_deviceinfo_old(struct usbd_device *, struct usb_device_info_old *, - int); -#endif int usbd_get_interface_altindex(struct usbd_interface *); usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *, @@ -235,6 +231,12 @@ const struct usb_devno *usb_match_device(const struct usb_devno *, usb_match_device((const struct usb_devno *)(tbl), sizeof(tbl) / sizeof((tbl)[0]), sizeof((tbl)[0]), (vendor), (product)) #define USB_PRODUCT_ANY 0xffff +/* compat callbacks */ +void usbd_devinfo_vp(struct usbd_device *, char *, size_t, char *, size_t, + int, int); +int usbd_printBCD(char *, size_t, int); + + /* NetBSD attachment information */ /* Attach data */ diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index 43fd14d2f17..245cb72dfc9 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: usbdivar.h,v 1.117 2018/08/09 06:26:47 mrg Exp $ */ +/* $NetBSD: usbdivar.h,v 1.118 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. @@ -324,7 +324,6 @@ usbd_status usbd_reattach_device(device_t, struct usbd_device *, int, const int *); void usbd_remove_device(struct usbd_device *, struct usbd_port *); -int usbd_printBCD(char *, size_t, int); usbd_status usbd_fill_iface_data(struct usbd_device *, int, int); void usb_free_device(struct usbd_device *); diff --git a/sys/dev/usb/usbroothub.c b/sys/dev/usb/usbroothub.c index 5912d713edb..2e0791a0c04 100644 --- a/sys/dev/usb/usbroothub.c +++ b/sys/dev/usb/usbroothub.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbroothub.c,v 1.7 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: usbroothub.c,v 1.8 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.7 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.8 2019/01/27 02:08:42 pgoyette Exp $"); #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 7ea35b591a7..549cc86e197 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.270 2018/12/10 15:22:35 hannken Exp $ */ +/* $NetBSD: vnd.c,v 1.271 2019/01/27 02:08:41 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.270 2018/12/10 15:22:35 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.271 2019/01/27 02:08:41 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -120,6 +120,7 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.270 2018/12/10 15:22:35 hannken Exp $"); #include <sys/conf.h> #include <sys/kauth.h> #include <sys/module.h> +#include <sys/compat_stub.h> #include <net/zlib.h> @@ -1150,40 +1151,43 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) #endif /* Do the get's first; they don't need initialization or verification */ switch (cmd) { -#ifdef COMPAT_30 - case VNDIOCGET30: { + case VNDIOCGET: if ((error = vndioctl_get(l, data, unit, &vattr)) != 0) return error; - struct vnd_user30 *vnu = data; + struct vnd_user *vnu = data; vnu->vnu_dev = vattr.va_fsid; vnu->vnu_ino = vattr.va_fileid; return 0; - } -#endif -#ifdef COMPAT_50 - case VNDIOCGET50: { - if ((error = vndioctl_get(l, data, unit, &vattr)) != 0) - return error; - struct vnd_user50 *vnu = data; - vnu->vnu_dev = vattr.va_fsid; - vnu->vnu_ino = vattr.va_fileid; - return 0; - } -#endif + default: + /* First check for COMPAT_50 hook */ + MODULE_CALL_HOOK(compat_vndioctl_50_hook, + (cmd, l, data, unit, &vattr, vndioctl_get), + enosys(), error); - case VNDIOCGET: { - if ((error = vndioctl_get(l, data, unit, &vattr)) != 0) - return error; + /* + * If not present, then COMPAT_30 hook also not + * present, so just continue with checks for the + * "write" commands + */ + if (error == ENOSYS) { + error = 0; + break; + } - struct vnd_user *vnu = data; - vnu->vnu_dev = vattr.va_fsid; - vnu->vnu_ino = vattr.va_fileid; - return 0; - } - default: - break; + /* If not already handled, try the COMPAT_30 hook */ + if (error == EPASSTHROUGH) + MODULE_CALL_HOOK(compat_vndioctl_30_hook, + (cmd, l, data, unit, &vattr, vndioctl_get), + enosys(), error); + + /* If no COMPAT_30 module, or not handled, check writes */ + if (error == ENOSYS || error == EPASSTHROUGH) { + error = 0; + break; + } + return error; } vnd = device_lookup_private(&vnd_cd, unit); @@ -1193,12 +1197,13 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) /* Must be open for writes for these commands... */ switch (cmd) { - case VNDIOCSET: - case VNDIOCCLR: -#ifdef COMPAT_50 case VNDIOCSET50: case VNDIOCCLR50: -#endif + if (!compat_vndioctl_50_hook.hooked) + return EINVAL; + /* FALLTHROUGH */ + case VNDIOCSET: + case VNDIOCCLR: case DIOCSDINFO: case DIOCWDINFO: #ifdef __HAVE_OLD_DISKLABEL @@ -1214,9 +1219,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) /* Must be initialized for these... */ switch (cmd) { case VNDIOCCLR: -#ifdef VNDIOCCLR50 case VNDIOCCLR50: -#endif case DIOCGDINFO: case DIOCSDINFO: case DIOCWDINFO: @@ -1241,9 +1244,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) switch (cmd) { -#ifdef VNDIOCSET50 case VNDIOCSET50: -#endif case VNDIOCSET: if (vnd->sc_flags & VNF_INITED) return EBUSY; @@ -1496,9 +1497,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) vndthrottle(vnd, vnd->sc_vp); vio->vnd_osize = dbtob(vnd->sc_size); -#ifdef VNDIOCSET50 if (cmd != VNDIOCSET50) -#endif vio->vnd_size = dbtob(vnd->sc_size); vnd->sc_flags |= VNF_INITED; @@ -1558,9 +1557,7 @@ unlock_and_exit: vndunlock(vnd); return error; -#ifdef VNDIOCCLR50 case VNDIOCCLR50: -#endif case VNDIOCCLR: part = DISKPART(dev); pmask = (1 << part); diff --git a/sys/dev/wscons/files.wscons b/sys/dev/wscons/files.wscons index 8c8102cfe90..6ffc0d9d7cd 100644 --- a/sys/dev/wscons/files.wscons +++ b/sys/dev/wscons/files.wscons @@ -1,4 +1,4 @@ -# $NetBSD: files.wscons,v 1.55 2017/12/18 18:59:32 jmcneill Exp $ +# $NetBSD: files.wscons,v 1.56 2019/01/27 02:08:42 pgoyette Exp $ # # "Workstation Console" glue; attaches frame buffer to emulator & keyboard, @@ -58,6 +58,7 @@ file dev/wscons/wsemul_vt100_subr.c wsdisplay & wsemul_vt100 file dev/wscons/wsemul_vt100_chars.c wsdisplay & wsemul_vt100 file dev/wscons/wsemul_vt100_keys.c wsdisplay & wsemul_vt100 file dev/wscons/wsevent.c wsdisplay | wskbd | wsmouse | wsmux +file dev/wscons/wsevent_50.c compat_50 file dev/wscons/wskbd.c wskbd needs-flag file dev/wscons/wskbdutil.c wskbd needs-flag file dev/wscons/wsmouse.c wsmouse needs-flag diff --git a/sys/dev/wscons/wsevent.c b/sys/dev/wscons/wsevent.c index c26947fc849..6281798b486 100644 --- a/sys/dev/wscons/wsevent.c +++ b/sys/dev/wscons/wsevent.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsevent.c,v 1.39 2018/06/14 10:30:55 uwe Exp $ */ +/* $NetBSD: wsevent.c,v 1.40 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2006, 2008 The NetBSD Foundation, Inc. @@ -104,7 +104,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.39 2018/06/14 10:30:55 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.40 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -120,6 +120,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.39 2018/06/14 10:30:55 uwe Exp $"); #include <sys/vnode.h> #include <sys/select.h> #include <sys/poll.h> +#include <sys/compat_stub.h> #include <dev/wscons/wsconsio.h> #include <dev/wscons/wseventvar.h> @@ -188,47 +189,19 @@ wsevent_fini(struct wseventvar *ev) softint_disestablish(ev->sih); } -#if defined(COMPAT_50) || defined(MODULAR) -static int -wsevent_copyout_events50(const struct wscons_event *events, int cnt, - struct uio *uio) -{ - int i; - - for (i = 0; i < cnt; i++) { - const struct wscons_event *ev = &events[i]; - struct owscons_event ev50; - int error; - - ev50.type = ev->type; - ev50.value = ev->value; - timespec_to_timespec50(&ev->time, &ev50.time); - - error = uiomove(&ev50, sizeof(ev50), uio); - if (error) { - return error; - } - } - return 0; -} -#else /* defined(COMPAT_50) || defined(MODULAR) */ -static int -wsevent_copyout_events50(const struct wscons_event *events, int cnt, - struct uio *uio) -{ - - return EINVAL; -} -#endif /* defined(COMPAT_50) || defined(MODULAR) */ - static int wsevent_copyout_events(const struct wscons_event *events, int cnt, struct uio *uio, int ver) { + int error; switch (ver) { case 0: - return wsevent_copyout_events50(events, cnt, uio); + MODULE_CALL_HOOK(wsevent_50_copyout_events_hook, + (events, cnt, uio), enosys(), error); + if (error == ENOSYS) + error = EINVAL; + return error; case WSEVENT_VERSION: return uiomove(__UNCONST(events), cnt * sizeof(*events), uio); default: diff --git a/sys/dev/wscons/wsevent_50.c b/sys/dev/wscons/wsevent_50.c new file mode 100644 index 00000000000..7a1f5d9ca46 --- /dev/null +++ b/sys/dev/wscons/wsevent_50.c @@ -0,0 +1,160 @@ +/* $NetBSD: wsevent_50.c,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + +/*- + * Copyright (c) 2006, 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)event.c 8.1 (Berkeley) 6/11/93 + */ + +/* + * Internal "wscons_event" queue interface for the keyboard and mouse drivers. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: wsevent_50.c,v 1.2 2019/01/27 02:08:42 pgoyette Exp $"); + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/fcntl.h> +#include <sys/kmem.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/vnode.h> +#include <sys/select.h> +#include <sys/poll.h> +#include <sys/compat_stub.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wseventvar.h> +#include <dev/wscons/wsevent_50.h> + +static int +wsevent_copyout_events50(const struct wscons_event *events, int cnt, + struct uio *uio) +{ + int i; + + for (i = 0; i < cnt; i++) { + const struct wscons_event *ev = &events[i]; + struct owscons_event ev50; + int error; + + ev50.type = ev->type; + ev50.value = ev->value; + timespec_to_timespec50(&ev->time, &ev50.time); + + error = uiomove(&ev50, sizeof(ev50), uio); + if (error) { + return error; + } + } + return 0; +} + +void +wsevent_50_init(void) +{ + + MODULE_SET_HOOK(wsevent_50_copyout_events_hook, "wsc_50", + wsevent_copyout_events50); +} + +void +wsevent_50_fini(void) +{ + + MODULE_UNSET_HOOK(wsevent_50_copyout_events_hook); +} diff --git a/sys/dev/wscons/wsevent_50.h b/sys/dev/wscons/wsevent_50.h new file mode 100644 index 00000000000..b937c1a1c77 --- /dev/null +++ b/sys/dev/wscons/wsevent_50.h @@ -0,0 +1,38 @@ +/* $NetBSD: wsevent_50.h,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DEV_WSCONS_WSEVENT_50_H +#define _DEV_WSCONS_WSEVENT_50_H + +void wsevent_50_init(void); +void wsevent_50_fini(void); + +#endif /* _DEV_WSCONS_WSEVENT_50_H */ |
