ccd_60.c revision 1.1.2.3 1 1.1.2.3 pgoyette /* $NetBSD: ccd_60.c,v 1.1.2.3 2018/03/18 22:49:26 pgoyette Exp $ */
2 1.1.2.2 pgoyette
3 1.1.2.2 pgoyette /*-
4 1.1.2.2 pgoyette * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 1.1.2.2 pgoyette * All rights reserved.
6 1.1.2.2 pgoyette *
7 1.1.2.2 pgoyette * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 pgoyette * modification, are permitted provided that the following conditions
9 1.1.2.2 pgoyette * are met:
10 1.1.2.2 pgoyette * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 pgoyette * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 pgoyette * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 pgoyette * documentation and/or other materials provided with the distribution.
15 1.1.2.2 pgoyette *
16 1.1.2.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1.2.2 pgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1.2.2 pgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1.2.2 pgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1.2.2 pgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1.2.2 pgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1.2.2 pgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1.2.2 pgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1.2.2 pgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1.2.2 pgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1.2.2 pgoyette * POSSIBILITY OF SUCH DAMAGE.
27 1.1.2.2 pgoyette */
28 1.1.2.2 pgoyette #include <sys/cdefs.h>
29 1.1.2.3 pgoyette __KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1.2.3 2018/03/18 22:49:26 pgoyette Exp $");
30 1.1.2.2 pgoyette
31 1.1.2.2 pgoyette #ifdef _KERNEL_OPT
32 1.1.2.2 pgoyette #include "opt_compat_netbsd.h"
33 1.1.2.2 pgoyette #endif
34 1.1.2.2 pgoyette
35 1.1.2.2 pgoyette #include <sys/param.h>
36 1.1.2.2 pgoyette #include <sys/systm.h>
37 1.1.2.2 pgoyette #include <sys/disk.h>
38 1.1.2.2 pgoyette #include <sys/lwp.h>
39 1.1.2.2 pgoyette
40 1.1.2.2 pgoyette #include <dev/ccdvar.h>
41 1.1.2.2 pgoyette #include <compat/sys/ccdvar.h>
42 1.1.2.2 pgoyette
43 1.1.2.2 pgoyette /*
44 1.1.2.2 pgoyette * Compat code must not be called if on a platform where
45 1.1.2.2 pgoyette * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will
46 1.1.2.2 pgoyette * be the same as CCDIOCSET_60
47 1.1.2.2 pgoyette */
48 1.1.2.2 pgoyette static int
49 1.1.2.2 pgoyette compat_60_ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l,
50 1.1.2.2 pgoyette int (*f)(dev_t, u_long, void *, int, struct lwp *))
51 1.1.2.2 pgoyette {
52 1.1.2.2 pgoyette switch (cmd) {
53 1.1.2.2 pgoyette #if defined(COMPAT_60) && !defined(_LP64)
54 1.1.2.2 pgoyette case CCDIOCSET_60: {
55 1.1.2.3 pgoyette int error;
56 1.1.2.3 pgoyette
57 1.1.2.2 pgoyette if (data == NULL)
58 1.1.2.2 pgoyette return 0;
59 1.1.2.2 pgoyette
60 1.1.2.2 pgoyette struct ccd_ioctl ccio;
61 1.1.2.2 pgoyette struct ccd_ioctl_60 *ccio60 = data;
62 1.1.2.2 pgoyette
63 1.1.2.2 pgoyette ccio.ccio_disks = ccio60->ccio_disks;
64 1.1.2.2 pgoyette ccio.ccio_ndisks = ccio60->ccio_ndisks;
65 1.1.2.2 pgoyette ccio.ccio_ileave = ccio60->ccio_ileave;
66 1.1.2.2 pgoyette ccio.ccio_flags = ccio60->ccio_flags;
67 1.1.2.2 pgoyette ccio.ccio_unit = ccio60->ccio_unit;
68 1.1.2.2 pgoyette error = (*f)(dev, CCDIOCSET, &ccio, flag, l);
69 1.1.2.2 pgoyette if (!error) {
70 1.1.2.2 pgoyette /* Copy data back, adjust types if necessary */
71 1.1.2.2 pgoyette ccio60->ccio_disks = ccio.ccio_disks;
72 1.1.2.2 pgoyette ccio60->ccio_ndisks = ccio.ccio_ndisks;
73 1.1.2.2 pgoyette ccio60->ccio_ileave = ccio.ccio_ileave;
74 1.1.2.2 pgoyette ccio60->ccio_flags = ccio.ccio_flags;
75 1.1.2.2 pgoyette ccio60->ccio_unit = ccio.ccio_unit;
76 1.1.2.2 pgoyette ccio60->ccio_size = (size_t)ccio.ccio_size;
77 1.1.2.2 pgoyette }
78 1.1.2.2 pgoyette return error;
79 1.1.2.2 pgoyette }
80 1.1.2.2 pgoyette
81 1.1.2.2 pgoyette case CCDIOCCLR_60:
82 1.1.2.3 pgoyette int error;
83 1.1.2.3 pgoyette
84 1.1.2.2 pgoyette if (data == NULL)
85 1.1.2.2 pgoyette return ENOSYS;
86 1.1.2.2 pgoyette /*
87 1.1.2.2 pgoyette * ccio_size member not used, so existing struct OK
88 1.1.2.2 pgoyette * drop through to existing non-compat version
89 1.1.2.2 pgoyette */
90 1.1.2.2 pgoyette return (*f)(dev, CCDIOCLR, data, flag, l);
91 1.1.2.2 pgoyette #endif /* COMPAT_60 && !_LP64*/
92 1.1.2.2 pgoyette default:
93 1.1.2.2 pgoyette return ENOSYS;
94 1.1.2.2 pgoyette }
95 1.1.2.2 pgoyette }
96 1.1.2.2 pgoyette
97 1.1.2.3 pgoyette int
98 1.1.2.2 pgoyette ccd_60_init(void)
99 1.1.2.2 pgoyette {
100 1.1.2.3 pgoyette compat_ccd_ioctl_60 = compat_60_ccdioctl;
101 1.1.2.3 pgoyette return 0;
102 1.1.2.2 pgoyette }
103 1.1.2.2 pgoyette
104 1.1.2.3 pgoyette int
105 1.1.2.2 pgoyette ccd_60_fini(void)
106 1.1.2.2 pgoyette {
107 1.1.2.3 pgoyette compat_ccd_ioctl_60 = (void *)enosys;
108 1.1.2.3 pgoyette return 0;
109 1.1.2.2 pgoyette }
110