The ioctl hypercall is used only by the usb host controller driver,

so make it exclusive to that component.  I'm happy to see it gone.
This commit is contained in:
pooka 2013-04-28 09:58:11 +00:00
parent fb2f15afec
commit b985b935c6
6 changed files with 96 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser.c,v 1.33 2013/04/27 16:56:29 pooka Exp $ */
/* $NetBSD: rumpuser.c,v 1.34 2013/04/28 09:58:11 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
__RCSID("$NetBSD: rumpuser.c,v 1.33 2013/04/27 16:56:29 pooka Exp $");
__RCSID("$NetBSD: rumpuser.c,v 1.34 2013/04/28 09:58:11 pooka Exp $");
#endif /* !lint */
#include <sys/ioctl.h>
@ -387,13 +387,6 @@ rumpuser_open(const char *path, int ruflags, int *error)
DOCALL_KLOCK(int, (open(path, flags, 0644)));
}
int
rumpuser_ioctl(int fd, u_long cmd, void *data, int *error)
{
DOCALL_KLOCK(int, (ioctl(fd, cmd, data)));
}
int
rumpuser_close(int fd, int *error)
{

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.2 2010/03/08 10:24:37 pooka Exp $
# $NetBSD: Makefile,v 1.3 2013/04/28 09:58:11 pooka Exp $
#
LIB= rumpdev_ugenhc
@ -8,5 +8,7 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c
CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern
RUMPUSER_COMP= ioctl
.include <bsd.lib.mk>
.include <bsd.klinks.mk>

View File

@ -0,0 +1,50 @@
/* $NetBSD: rumpcomp_user.c,v 1.1 2013/04/28 09:58:11 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <rump/rumpuser_component.h>
#include "rumpcomp_user.h"
int
rumpcomp_ugenhc_ioctl(int fd, u_long cmd, void *data, int *error)
{
void *cookie;
int rv;
cookie = rumpuser_component_unschedule();
rv = ioctl(fd, cmd, data);
if (rv == -1)
*error = errno;
else
*error = 0;
rumpuser_component_schedule(cookie);
return rv;
}

View File

@ -0,0 +1,28 @@
/* $NetBSD: rumpcomp_user.h,v 1.1 2013/04/28 09:58:11 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
int rumpcomp_ugenhc_ioctl(int, u_long, void *, int *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ugenhc.c,v 1.12 2012/10/27 17:18:40 chs Exp $ */
/* $NetBSD: ugenhc.c,v 1.13 2013/04/28 09:58:11 pooka Exp $ */
/*
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.12 2012/10/27 17:18:40 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.13 2013/04/28 09:58:11 pooka Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -81,6 +81,8 @@ __KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.12 2012/10/27 17:18:40 chs Exp $");
#include <rump/rumpuser.h>
#include "rumpcomp_user.h"
#include "rump_private.h"
#include "rump_dev_private.h"
@ -387,7 +389,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
usb_device_descriptor_t uddesc;
totlen = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
memset(buf, 0, totlen);
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_GET_DEVICE_DESC, &uddesc, &ru_error) == -1) {
err = EIO;
goto ret;
@ -403,7 +405,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
ufdesc.ufd_size = len;
ufdesc.ufd_data = buf;
memset(buf, 0, len);
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_GET_FULL_DESC, &ufdesc, &ru_error) == -1) {
err = USBD_IOERROR;
goto ret;
@ -416,7 +418,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
{
struct usb_device_info udi;
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_GET_DEVICEINFO, &udi, &ru_error) == -1) {
printf("ugenhc: get dev info failed: %d\n",
ru_error);
@ -451,7 +453,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_SET_CONFIG, &value, &ru_error) == -1) {
printf("ugenhc: set config failed: %d\n",
ru_error);
@ -467,7 +469,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
totlen = 0;
uai.uai_interface_index = UGETW(req->wIndex);
uai.uai_alt_no = value;
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_SET_ALTINTERFACE, &uai, &ru_error) == -1) {
printf("ugenhc: set alt interface failed: %d\n",
ru_error);
@ -517,7 +519,7 @@ rumpusb_device_ctrl_start(usbd_xfer_handle xfer)
memcpy(&ucr.ucr_request, req, sizeof(ucr.ucr_request));
ucr.ucr_data = buf;
if (rumpuser_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
if (rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[UGEN_EPT_CTRL],
USB_DO_REQUEST, &ucr, &ru_error) == -1) {
if (!mightfail) {
panic("request failed: %d", ru_error);
@ -748,7 +750,7 @@ rumpusb_device_bulk_start(usbd_xfer_handle xfer)
while (RUSB(xfer)->rusb_status == 0) {
if (isread) {
rumpuser_ioctl(sc->sc_ugenfd[endpt],
rumpcomp_ugenhc_ioctl(sc->sc_ugenfd[endpt],
USB_SET_SHORT_XFER, &shortval, &error);
n = rumpuser_read(sc->sc_ugenfd[endpt],
buf+done, len-done, &error);
@ -977,7 +979,7 @@ ugenhc_open(struct usbd_pipe *pipe)
return USBD_INVAL; /* XXX: no mapping */
}
val = 100;
if (rumpuser_ioctl(fd, USB_SET_TIMEOUT, &val,
if (rumpcomp_ugenhc_ioctl(fd, USB_SET_TIMEOUT, &val,
&error) == -1)
panic("timeout set failed");
sc->sc_ugenfd[endpt] = fd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser.h,v 1.85 2013/04/27 16:56:30 pooka Exp $ */
/* $NetBSD: rumpuser.h,v 1.86 2013/04/28 09:58:11 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@ -80,7 +80,6 @@ int rumpuser_memsync(void *, size_t, int *);
#define RUMPUSER_OPEN_DIRECT 0x080000
int rumpuser_open(const char *, int, int *);
int rumpuser_ioctl(int, u_long, void *, int *);
int rumpuser_close(int, int *);
int rumpuser_fsync(int, int *);