FreeBSD/Linux Kernel Cross Reference
sys/cam/cam_compat.c
1 /*-
2 * CAM ioctl compatibility shims
3 *
4 * Copyright (c) 2013 Scott Long
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification, immediately at the beginning of the file.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/types.h>
36 #include <sys/kernel.h>
37 #include <sys/conf.h>
38 #include <sys/fcntl.h>
39
40 #include <sys/lock.h>
41 #include <sys/mutex.h>
42 #include <sys/sysctl.h>
43 #include <sys/kthread.h>
44
45 #include <cam/cam.h>
46 #include <cam/cam_ccb.h>
47 #include <cam/cam_compat.h>
48
49 #include <cam/scsi/scsi_pass.h>
50
51 #include "opt_cam.h"
52
53 int
54 cam_compat_ioctl(struct cdev *dev, u_long *cmd, caddr_t *addr, int *flag, struct thread *td)
55 {
56 int error;
57
58 switch (*cmd) {
59 case CAMIOCOMMAND_0x16:
60 {
61 union ccb *ccb;
62
63 ccb = (union ccb *)*addr;
64 if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS_0x16) {
65 ccb->ccb_h.flags &= ~CAM_SG_LIST_PHYS_0x16;
66 ccb->ccb_h.flags |= CAM_DATA_SG_PADDR;
67 }
68 if (ccb->ccb_h.flags & CAM_DATA_PHYS_0x16) {
69 ccb->ccb_h.flags &= ~CAM_DATA_PHYS_0x16;
70 ccb->ccb_h.flags |= CAM_DATA_PADDR;
71 }
72 if (ccb->ccb_h.flags & CAM_SCATTER_VALID_0x16) {
73 ccb->ccb_h.flags &= CAM_SCATTER_VALID_0x16;
74 ccb->ccb_h.flags |= CAM_DATA_SG;
75 }
76 *cmd = CAMIOCOMMAND;
77 error = EAGAIN;
78 break;
79 }
80 case CAMGETPASSTHRU_0x16:
81 *cmd = CAMGETPASSTHRU;
82 error = EAGAIN;
83 break;
84 default:
85 error = ENOTTY;
86 }
87
88 return (error);
89 }
Cache object: 62ff699697b44d8c77731802e60ef1d4
|