1/*- 2 * Copyright (c) 2006 IronPort Systems 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 37 unchanged lines hidden (view full) --- 46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * SUCH DAMAGE. 51 */ 52 53#include <sys/cdefs.h> |
54__FBSDID("$FreeBSD: head/sys/dev/mfi/mfi.c 179392 2008-05-28 23:19:27Z ambrisko $"); |
55 56#include "opt_mfi.h" 57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/sysctl.h> 61#include <sys/malloc.h> 62#include <sys/kernel.h> --- 2040 unchanged lines hidden (view full) --- 2103#endif 2104 2105static int 2106mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td) 2107{ 2108 struct mfi_softc *sc; 2109 union mfi_statrequest *ms; 2110 struct mfi_ioc_packet *ioc; |
2111#ifdef __amd64__ 2112 struct mfi_ioc_packet32 *ioc32; 2113#endif |
2114 struct mfi_ioc_aen *aen; 2115 struct mfi_command *cm = NULL; 2116 uint32_t context; 2117 uint8_t *sense_ptr; 2118 uint8_t *data = NULL, *temp; 2119 int i; 2120 struct mfi_ioc_passthru *iop = (struct mfi_ioc_passthru *)arg; 2121#ifdef __amd64__ --- 41 unchanged lines hidden (view full) --- 2163 if (ld->ld_flags & MFI_DISK_FLAGS_OPEN) 2164 qd->open = 1; 2165 bzero(qd->devname, SPECNAMELEN + 1); 2166 snprintf(qd->devname, SPECNAMELEN, "mfid%d", ld->ld_unit); 2167 mtx_unlock(&sc->mfi_io_lock); 2168 break; 2169 } 2170 case MFI_CMD: |
2171#ifdef __amd64__ 2172 case MFI_CMD32: 2173#endif |
2174 { 2175 devclass_t devclass; 2176 ioc = (struct mfi_ioc_packet *)arg; 2177 int adapter; 2178 2179 adapter = ioc->mfi_adapter_no; 2180 if (device_get_unit(sc->mfi_dev) == 0 && adapter != 0) { 2181 devclass = devclass_find("mfi"); --- 41 unchanged lines hidden (view full) --- 2223 } 2224 2225 /* restore header context */ 2226 cm->cm_frame->header.context = context; 2227 2228 temp = data; 2229 if (cm->cm_flags & MFI_CMD_DATAOUT) { 2230 for (i = 0; i < ioc->mfi_sge_count; i++) { |
2231#ifdef __amd64__ 2232 if (cmd == MFI_CMD) { 2233 /* Native */ 2234 error = copyin(ioc->mfi_sgl[i].iov_base, 2235 temp, 2236 ioc->mfi_sgl[i].iov_len); 2237 } else { 2238 void *temp_convert; 2239 /* 32bit */ 2240 ioc32 = (struct mfi_ioc_packet32 *)ioc; 2241 temp_convert = 2242 PTRIN(ioc32->mfi_sgl[i].iov_base); 2243 error = copyin(temp_convert, 2244 temp, 2245 ioc32->mfi_sgl[i].iov_len); 2246 } 2247#else |
2248 error = copyin(ioc->mfi_sgl[i].iov_base, 2249 temp, 2250 ioc->mfi_sgl[i].iov_len); |
2251#endif |
2252 if (error != 0) { 2253 device_printf(sc->mfi_dev, 2254 "Copy in failed\n"); 2255 goto out; 2256 } 2257 temp = &temp[ioc->mfi_sgl[i].iov_len]; 2258 } 2259 } --- 16 unchanged lines hidden (view full) --- 2276 } 2277 2278 mfi_check_command_post(sc, cm); 2279 mtx_unlock(&sc->mfi_io_lock); 2280 2281 temp = data; 2282 if (cm->cm_flags & MFI_CMD_DATAIN) { 2283 for (i = 0; i < ioc->mfi_sge_count; i++) { |
2284#ifdef __amd64__ 2285 if (cmd == MFI_CMD) { 2286 /* Native */ 2287 error = copyout(temp, 2288 ioc->mfi_sgl[i].iov_base, 2289 ioc->mfi_sgl[i].iov_len); 2290 } else { 2291 void *temp_convert; 2292 /* 32bit */ 2293 ioc32 = (struct mfi_ioc_packet32 *)ioc; 2294 temp_convert = 2295 PTRIN(ioc32->mfi_sgl[i].iov_base); 2296 error = copyout(temp, 2297 temp_convert, 2298 ioc32->mfi_sgl[i].iov_len); 2299 } 2300#else |
2301 error = copyout(temp, 2302 ioc->mfi_sgl[i].iov_base, 2303 ioc->mfi_sgl[i].iov_len); |
2304#endif |
2305 if (error != 0) { 2306 device_printf(sc->mfi_dev, 2307 "Copy out failed\n"); 2308 goto out; 2309 } 2310 temp = &temp[ioc->mfi_sgl[i].iov_len]; 2311 } 2312 } --- 393 unchanged lines hidden --- |