The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/mrsas/mrsas_linux.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Kashyap Desai,
    3  * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Kashyap Desai,
    4  * Sibananda Sahu Support: freebsdraid@avagotech.com
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions are
    8  * met:
    9  *
   10  * 1. Redistributions of source code must retain the above copyright notice,
   11  * this list of conditions and the following disclaimer. 2. Redistributions
   12  * in binary form must reproduce the above copyright notice, this list of
   13  * conditions and the following disclaimer in the documentation and/or other
   14  * materials provided with the distribution. 3. Neither the name of the
   15  * <ORGANIZATION> nor the names of its contributors may be used to endorse or
   16  * promote products derived from this software without specific prior written
   17  * permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  *
   31  * The views and conclusions contained in the software and documentation are
   32  * those of the authors and should not be interpreted as representing
   33  * official policies,either expressed or implied, of the FreeBSD Project.
   34  *
   35  * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
   36  * Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
   37  *
   38  */
   39 
   40 #include <sys/cdefs.h>
   41 __FBSDID("$FreeBSD$");
   42 
   43 #include <sys/param.h>
   44 #include <sys/systm.h>
   45 
   46 #if (__FreeBSD_version >= 1001511)
   47 #include <sys/capsicum.h>
   48 #elif (__FreeBSD_version > 900000)
   49 #include <sys/capability.h>
   50 #endif
   51 
   52 #include <sys/conf.h>
   53 #include <sys/kernel.h>
   54 #include <sys/module.h>
   55 #include <sys/file.h>
   56 #include <sys/proc.h>
   57 #include <machine/bus.h>
   58 
   59 #if defined(__amd64__)                  /* Assume amd64 wants 32 bit Linux */
   60 #include <machine/../linux32/linux.h>
   61 #include <machine/../linux32/linux32_proto.h>
   62 #else
   63 #include <machine/../linux/linux.h>
   64 #include <machine/../linux/linux_proto.h>
   65 #endif
   66 #include <compat/linux/linux_ioctl.h>
   67 #include <compat/linux/linux_util.h>
   68 
   69 #include <dev/mrsas/mrsas.h>
   70 #undef COMPAT_FREEBSD32
   71 #include <dev/mrsas/mrsas_ioctl.h>
   72 
   73 /* There are multiple ioctl number ranges that need to be handled */
   74 #define MRSAS_LINUX_IOCTL_MIN  0x4d00
   75 #define MRSAS_LINUX_IOCTL_MAX  0x4d01
   76 
   77 static linux_ioctl_function_t mrsas_linux_ioctl;
   78 static struct linux_ioctl_handler mrsas_linux_handler = {mrsas_linux_ioctl,
   79         MRSAS_LINUX_IOCTL_MIN,
   80 MRSAS_LINUX_IOCTL_MAX};
   81 
   82 SYSINIT(mrsas_register, SI_SUB_KLD, SI_ORDER_MIDDLE,
   83     linux_ioctl_register_handler, &mrsas_linux_handler);
   84 SYSUNINIT(mrsas_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE,
   85     linux_ioctl_unregister_handler, &mrsas_linux_handler);
   86 
   87 static struct linux_device_handler mrsas_device_handler =
   88 {"mrsas", "megaraid_sas", "mrsas0", "megaraid_sas_ioctl_node", -1, 0, 1};
   89 
   90 SYSINIT(mrsas_register2, SI_SUB_KLD, SI_ORDER_MIDDLE,
   91     linux_device_register_handler, &mrsas_device_handler);
   92 SYSUNINIT(mrsas_unregister2, SI_SUB_KLD, SI_ORDER_MIDDLE,
   93     linux_device_unregister_handler, &mrsas_device_handler);
   94 
   95 static int
   96 mrsas_linux_modevent(module_t mod __unused, int cmd __unused, void *data __unused)
   97 {
   98         return (0);
   99 }
  100 
  101 /*
  102  * mrsas_linux_ioctl:   linux emulator IOCtl commands entry point.
  103  *
  104  * This function is the entry point for IOCtls from linux binaries.
  105  * It calls the mrsas_ioctl function for processing
  106  * depending on the IOCTL command received.
  107  */
  108 static int
  109 mrsas_linux_ioctl(struct thread *p, struct linux_ioctl_args *args)
  110 {
  111 #if (__FreeBSD_version >= 1000000)
  112         cap_rights_t rights;
  113 
  114 #endif
  115         struct file *fp;
  116         int error;
  117         u_long cmd = args->cmd;
  118 
  119         if (cmd != MRSAS_LINUX_CMD32) {
  120                 error = ENOTSUP;
  121                 goto END;
  122         }
  123 #if (__FreeBSD_version >= 1000000)
  124         error = fget(p, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp);
  125 #elif (__FreeBSD_version <= 900000)
  126         error = fget(p, args->fd, &fp);
  127 #else                                   /* For FreeBSD version greater than
  128                                          * 9.0.0 but less than 10.0.0 */
  129         error = fget(p, args->fd, CAP_IOCTL, &fp);
  130 #endif
  131         if (error != 0)
  132                 goto END;
  133 
  134         error = fo_ioctl(fp, cmd, (caddr_t)args->arg, p->td_ucred, p);
  135         fdrop(fp, p);
  136 END:
  137         return (error);
  138 }
  139 
  140 DEV_MODULE(mrsas_linux, mrsas_linux_modevent, NULL);
  141 MODULE_DEPEND(mrsas, linux, 1, 1, 1);

Cache object: 9a9f8028eb26ebd75534afeb69856384


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.