\hypertarget{scsi__sg_8c_source}{}\doxysection{scsi\+\_\+sg.\+c}
\label{scsi__sg_8c_source}\index{cam/scsi/scsi\_sg.c@{cam/scsi/scsi\_sg.c}}
\mbox{\hyperlink{scsi__sg_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2007 Scott Long}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions, and the following disclaimer,}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00012}00012 \textcolor{comment}{ *    without modification, immediately at the beginning of the file.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00013}00013 \textcolor{comment}{ * 2. The name of the author may not be used to endorse or promote products}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00014}00014 \textcolor{comment}{ *    derived from this software without specific prior written permission.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00020}00020 \textcolor{comment}{ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00029}00029 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00030}00030 \textcolor{comment}{ * scsi\_sg peripheral driver.  This driver is meant to implement the Linux}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00031}00031 \textcolor{comment}{ * SG passthrough interface for SCSI.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00032}00032 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00035}\mbox{\hyperlink{scsi__sg_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00035}} \mbox{\hyperlink{scsi__sg_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/types.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/bio.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/fcntl.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/ioccom.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <sys/conf.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <sys/errno.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <sys/devicestat.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00048}00048 \textcolor{preprocessor}{\#include <sys/proc.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00049}00049 \textcolor{preprocessor}{\#include <sys/uio.h>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00050}00050 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam_8h}{cam/cam.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00052}00052 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__ccb_8h}{cam/cam\_ccb.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00053}00053 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__periph_8h}{cam/cam\_periph.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00054}00054 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__queue_8h}{cam/cam\_queue.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00055}00055 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__xpt__periph_8h}{cam/cam\_xpt\_periph.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00056}00056 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__debug_8h}{cam/cam\_debug.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00057}00057 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cam__sim_8h}{cam/cam\_sim.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00058}00058 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00059}00059 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{scsi__all_8h}{cam/scsi/scsi\_all.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00060}00060 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{scsi__message_8h}{cam/scsi/scsi\_message.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00061}00061 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{scsi__sg_8h}{cam/scsi/scsi\_sg.h}}>}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00063}\mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7}{00063}} \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00064}\mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a321c83f5cfea770255114f4ee2bd2554}{00064}}         \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a321c83f5cfea770255114f4ee2bd2554}{SG\_FLAG\_LOCKED}}            = 0x01,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00065}00065         \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a548ea72a28734385a2e98054f74fd017}{SG\_FLAG\_INVALID}}          = 0x02}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00066}\mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a548ea72a28734385a2e98054f74fd017}{00066}} \} \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7}{sg\_flags}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00067}00067 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00068}\mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7}{00068}} \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00069}00069         \mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7a833d022ea6acf12a248883846f25d49c}{SG\_STATE\_NORMAL}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00070}\mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7a833d022ea6acf12a248883846f25d49c}{00070}} \} \mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7}{sg\_state}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00071}00071 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00072}\mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4d}{00072}} \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00073}\mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da2e323724c49902054393dcfca4de2bd7}{00073}}         \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da2e323724c49902054393dcfca4de2bd7}{SG\_RDWR\_FREE}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00074}\mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da3ccf79d057f5bf0559cf919ba6fe8a00}{00074}}         \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da3ccf79d057f5bf0559cf919ba6fe8a00}{SG\_RDWR\_INPROG}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00075}00075         \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da18979761e24d42e9975986fe699ea1b4}{SG\_RDWR\_DONE}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00076}\mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da18979761e24d42e9975986fe699ea1b4}{00076}} \} \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4d}{sg\_rdwr\_state}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00077}00077 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00078}\mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15}{00078}} \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00079}00079         \mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15a0d112836f75973868e88c3bec6c6dfae}{SG\_CCB\_RDWR\_IO}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00080}\mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15a0d112836f75973868e88c3bec6c6dfae}{00080}} \} \mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15}{sg\_ccb\_types}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00082}\mbox{\hyperlink{scsi__sg_8c_adecfb85cd1107f63e60d11fa90731323}{00082}} \textcolor{preprocessor}{\#define ccb\_type        ppriv\_field0}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00083}\mbox{\hyperlink{scsi__sg_8c_a6f08f8c5cf5ec1983fce9e7c5c6a3e53}{00083}} \textcolor{preprocessor}{\#define ccb\_rdwr        ppriv\_ptr1}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00084}00084 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00085}\mbox{\hyperlink{structsg__rdwr}{00085}} \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00086}\mbox{\hyperlink{structsg__rdwr_a1af5dd3155beae08c1d50041802d109d}{00086}}         \mbox{\hyperlink{structsg__rdwr_a1af5dd3155beae08c1d50041802d109d}{TAILQ\_ENTRY}}(\mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}})  rdwr\_link;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00087}00087         \textcolor{keywordtype}{int}                     tag;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00088}00088         \textcolor{keywordtype}{int}                     state;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00089}00089         \textcolor{keywordtype}{int}                     buf\_len;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00090}00090         \textcolor{keywordtype}{char}                    *buf;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00091}00091         \textcolor{keyword}{union }\mbox{\hyperlink{unionccb}{ccb}}            *\mbox{\hyperlink{mmc__sim__if_8m_a3b75bbd1e046a488543d1dccdbcae16b}{ccb}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00092}00092         \textcolor{keyword}{union }\{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00093}00093                 \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__header}{sg\_header}} \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00094}00094                 \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__io__hdr}{sg\_io\_hdr}} io\_hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00095}\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{00095}}         \} \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00096}00096 \};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00097}00097 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00098}\mbox{\hyperlink{structsg__softc}{00098}} \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00099}\mbox{\hyperlink{structsg__softc_a03e3bf0922e7402fb7767daca11283f3}{00099}}         \mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7}{sg\_state}}                \mbox{\hyperlink{structsg__softc_a03e3bf0922e7402fb7767daca11283f3}{state}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00100}\mbox{\hyperlink{structsg__softc_af9651cdedc7e01361f87e0cd586ad845}{00100}}         \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7}{sg\_flags}}                \mbox{\hyperlink{structsg__softc_af9651cdedc7e01361f87e0cd586ad845}{flags}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00101}\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{00101}}         \textcolor{keywordtype}{int}                     \mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00102}\mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{00102}}         u\_int                   \mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{maxio}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00103}\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{00103}}         \textcolor{keyword}{struct }devstat          *\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00104}00104         \mbox{\hyperlink{cam__queue_8h_a2c1b7587c89969d66bccfd5502f6c7c0}{TAILQ\_HEAD}}(, \mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}})  rdwr\_done;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00105}00105         \textcolor{keyword}{struct }cdev             *dev;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00106}00106         \textcolor{keywordtype}{int}                     sg\_timeout;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00107}00107         \textcolor{keywordtype}{int}                     sg\_user\_timeout;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00108}00108         uint8\_t                 pd\_type;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00109}00109 \};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00110}00110 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00111}\mbox{\hyperlink{scsi__sg_8c_a6368bc1d5613fd1ac5d752e5609ce150}{00111}} \textcolor{keyword}{static} d\_open\_t         \mbox{\hyperlink{scsi__sg_8c_a6368bc1d5613fd1ac5d752e5609ce150}{sgopen}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00112}\mbox{\hyperlink{scsi__sg_8c_ad872400e827bdd2d10386ae4bf2a9241}{00112}} \textcolor{keyword}{static} d\_close\_t        \mbox{\hyperlink{scsi__sg_8c_ad872400e827bdd2d10386ae4bf2a9241}{sgclose}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00113}\mbox{\hyperlink{scsi__sg_8c_a53f307040bac4b146b703a02cc3021a9}{00113}} \textcolor{keyword}{static} d\_ioctl\_t        \mbox{\hyperlink{scsi__sg_8c_a53f307040bac4b146b703a02cc3021a9}{sgioctl}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00114}\mbox{\hyperlink{scsi__sg_8c_a838dcb1cf0b67bc0cf791099c27b7432}{00114}} \textcolor{keyword}{static} d\_write\_t        \mbox{\hyperlink{scsi__sg_8c_a838dcb1cf0b67bc0cf791099c27b7432}{sgwrite}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00115}\mbox{\hyperlink{scsi__sg_8c_ae598f964f0d18d2fb4064a8f67258ffa}{00115}} \textcolor{keyword}{static} d\_read\_t         \mbox{\hyperlink{scsi__sg_8c_ae598f964f0d18d2fb4064a8f67258ffa}{sgread}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00116}00116 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00117}\mbox{\hyperlink{scsi__sg_8c_ace4ffade9310780b7515aa82608c77ce}{00117}} \textcolor{keyword}{static} \mbox{\hyperlink{cam__periph_8h_ae8635482322b2513ab2f662535250ac0}{periph\_init\_t}}       \mbox{\hyperlink{scsi__sg_8c_ace4ffade9310780b7515aa82608c77ce}{sginit}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00118}\mbox{\hyperlink{scsi__sg_8c_acd54b56f5d871039c9d268ea0158118c}{00118}} \textcolor{keyword}{static} \mbox{\hyperlink{cam__periph_8h_a0134746116b0c19d248d1342a16aab04}{periph\_ctor\_t}}       \mbox{\hyperlink{scsi__sg_8c_acd54b56f5d871039c9d268ea0158118c}{sgregister}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00119}\mbox{\hyperlink{scsi__sg_8c_ae40ce8e6da413772f7e6571f518a1f10}{00119}} \textcolor{keyword}{static} \mbox{\hyperlink{cam__periph_8h_a14602bb3ac9272ea2209d63f1e618fca}{periph\_oninv\_t}}     \mbox{\hyperlink{scsi__sg_8c_ae40ce8e6da413772f7e6571f518a1f10}{sgoninvalidate}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00120}\mbox{\hyperlink{scsi__sg_8c_ab1348fd9b13f0732799b0f1cf41841ae}{00120}} \textcolor{keyword}{static} \mbox{\hyperlink{cam__periph_8h_a8d863e438ef46ba796fbf3e77340b3e3}{periph\_dtor\_t}}       \mbox{\hyperlink{scsi__sg_8c_ab1348fd9b13f0732799b0f1cf41841ae}{sgcleanup}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00121}00121 \textcolor{keyword}{static} \textcolor{keywordtype}{void}             \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}(\textcolor{keywordtype}{void} *callback\_arg, uint32\_t code,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00122}00122                                 \textcolor{keyword}{struct} \mbox{\hyperlink{structcam__path}{cam\_path}} *path, \textcolor{keywordtype}{void} *arg);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00123}00123 \textcolor{keyword}{static} \textcolor{keywordtype}{void}             \mbox{\hyperlink{scsi__sg_8c_a960fc3009b1d5102172f6f9d8a3e4755}{sgdone}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *done\_ccb);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00124}00124 \textcolor{keyword}{static} \textcolor{keywordtype}{int}              \mbox{\hyperlink{scsi__sg_8c_a0c6e5a44ca0417699f1e35ef9f107d8d}{sgsendccb}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00125}00125 \textcolor{keyword}{static} \textcolor{keywordtype}{int}              \mbox{\hyperlink{scsi__sg_8c_a5b5ed2680231306f895af4b6f32fded2}{sgsendrdwr}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00126}00126 \textcolor{keyword}{static} \textcolor{keywordtype}{int}              \mbox{\hyperlink{scsi__sg_8c_aefa0577158fd166cdecf34b8fd7bd8fc}{sgerror}}(\textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}}, uint32\_t \mbox{\hyperlink{cam_8h_a14bf0cceb256c2063f776e6cc4aba316}{cam\_flags}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00127}00127                                 uint32\_t sense\_flags);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00128}00128 \textcolor{keyword}{static} \textcolor{keywordtype}{void}             \mbox{\hyperlink{scsi__sg_8c_a04f2d39394147a1c12006834c7ad9ced}{sg\_scsiio\_status}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00129}00129                                          u\_short *hoststat, u\_short *drvstat);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00130}00130 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00131}00131 \textcolor{keyword}{static} \textcolor{keywordtype}{int}              \mbox{\hyperlink{scsi__sg_8c_a10c60cef0f98eee1a801f9b8e6324c54}{scsi\_group\_len}}(u\_char cmd);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00132}00132 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00133}\mbox{\hyperlink{scsi__sg_8c_a2849c5d15556c95a0c8544e241217af1}{00133}} \textcolor{keyword}{static} \textcolor{keyword}{struct }\mbox{\hyperlink{structperiph__driver}{periph\_driver}} \mbox{\hyperlink{scsi__sg_8c_a2849c5d15556c95a0c8544e241217af1}{sgdriver}} =}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00134}00134 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00135}00135         \mbox{\hyperlink{scsi__sg_8c_ace4ffade9310780b7515aa82608c77ce}{sginit}}, \textcolor{stringliteral}{"{}sg"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00136}00136         TAILQ\_HEAD\_INITIALIZER(\mbox{\hyperlink{scsi__sg_8c_a2849c5d15556c95a0c8544e241217af1}{sgdriver}}.units), \textcolor{comment}{/* gen */} 0}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00137}00137 \};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00138}\mbox{\hyperlink{scsi__sg_8c_a4c75a2a517b147de97848e6ba50c1d1f}{00138}} \mbox{\hyperlink{scsi__sg_8c_a4c75a2a517b147de97848e6ba50c1d1f}{PERIPHDRIVER\_DECLARE}}(sg, \mbox{\hyperlink{scsi__sg_8c_a2849c5d15556c95a0c8544e241217af1}{sgdriver}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00139}00139 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00140}\mbox{\hyperlink{scsi__sg_8c_a391d79d545431b8ffcd0bebc446ffce4}{00140}} \textcolor{keyword}{static} \textcolor{keyword}{struct }cdevsw \mbox{\hyperlink{scsi__sg_8c_a391d79d545431b8ffcd0bebc446ffce4}{sg\_cdevsw}} = \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00141}00141         .d\_version =    D\_VERSION,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00142}00142         .d\_flags =      D\_TRACKCLOSE,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00143}00143         .d\_open =       \mbox{\hyperlink{scsi__sg_8c_a6368bc1d5613fd1ac5d752e5609ce150}{sgopen}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00144}00144         .d\_close =      \mbox{\hyperlink{scsi__sg_8c_ad872400e827bdd2d10386ae4bf2a9241}{sgclose}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00145}00145         .d\_ioctl =      \mbox{\hyperlink{scsi__sg_8c_a53f307040bac4b146b703a02cc3021a9}{sgioctl}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00146}00146         .d\_write =      \mbox{\hyperlink{scsi__sg_8c_a838dcb1cf0b67bc0cf791099c27b7432}{sgwrite}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00147}00147         .d\_read =       \mbox{\hyperlink{scsi__sg_8c_ae598f964f0d18d2fb4064a8f67258ffa}{sgread}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00148}00148         .d\_name =       \textcolor{stringliteral}{"{}sg"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00149}00149 \};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00150}00150 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00151}\mbox{\hyperlink{scsi__sg_8c_ae01c37b8a7197c3871c7b46409818d19}{00151}} \textcolor{keyword}{static} \textcolor{keywordtype}{int} \mbox{\hyperlink{scsi__sg_8c_ae01c37b8a7197c3871c7b46409818d19}{sg\_version}} = 30125;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00152}00152 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00153}00153 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00154}00154 \mbox{\hyperlink{scsi__sg_8c_ace4ffade9310780b7515aa82608c77ce}{sginit}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00155}00155 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00156}00156         \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3}{cam\_status}} status;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00158}00158         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00159}00159 \textcolor{comment}{         * Install a global async callback.  This callback will receive aync}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00160}00160 \textcolor{comment}{         * callbacks like "{}new device found"{}.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00161}00161 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00162}00162         status = \mbox{\hyperlink{cam__xpt_8c_a8307586c12fb4774768a25a1fa4e6388}{xpt\_register\_async}}(\mbox{\hyperlink{cam__ccb_8h_a01187b765c0d47bdbc0776db5c5851f0a04183843e65dd16d378d105270a6debd}{AC\_FOUND\_DEVICE}}, \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}, NULL, NULL);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00163}00163 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00164}00164         \textcolor{keywordflow}{if} (status != \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a3487a040bd091973beb62275a7309324}{CAM\_REQ\_CMP}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00165}00165                 printf(\textcolor{stringliteral}{"{}sg: Failed to attach master async callbac "{}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00166}00166                         \textcolor{stringliteral}{"{}due to status 0x\%x!\(\backslash\)n"{}}, status);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00167}00167         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00168}00168 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00170}00170 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00171}\mbox{\hyperlink{scsi__sg_8c_a91edb4a9d92972bc8ccd30475f68d1a5}{00171}} \mbox{\hyperlink{scsi__sg_8c_a91edb4a9d92972bc8ccd30475f68d1a5}{sgdevgonecb}}(\textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00172}00172 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00173}00173         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00174}00174         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00175}00175         \textcolor{keyword}{struct }mtx *mtx;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00176}00176         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00177}00177 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00178}00178         periph = (\textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00179}00179         mtx = \mbox{\hyperlink{cam__periph_8h_a8b9ecf78613a0fdde3d227cf5a109101}{cam\_periph\_mtx}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00180}00180         mtx\_lock(mtx);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00181}00181 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00182}00182         \mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00183}00183         KASSERT(softc-\/>\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}} >= 0, (\textcolor{stringliteral}{"{}Negative open count \%d"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00184}00184                 softc-\/>\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}}));}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00185}00185 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00186}00186         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00187}00187 \textcolor{comment}{         * When we get this callback, we will get no more close calls from}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00188}00188 \textcolor{comment}{         * devfs.  So if we have any dangling opens, we need to release the}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00189}00189 \textcolor{comment}{         * reference held for that particular context.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00190}00190 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00191}00191         \textcolor{keywordflow}{for} (i = 0; i < softc-\/>\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}}; i++)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00192}00192                 \mbox{\hyperlink{cam__periph_8c_a06741cfe8f484a9dad6f9607a233908c}{cam\_periph\_release\_locked}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00193}00193 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00194}00194         softc-\/>\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}} = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00195}00195 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00196}00196         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00197}00197 \textcolor{comment}{         * Release the reference held for the device node, it is gone now.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00198}00198 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00199}00199         \mbox{\hyperlink{cam__periph_8c_a06741cfe8f484a9dad6f9607a233908c}{cam\_periph\_release\_locked}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00200}00200 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00201}00201         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00202}00202 \textcolor{comment}{         * We reference the lock directly here, instead of using}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00203}00203 \textcolor{comment}{         * cam\_periph\_unlock().  The reason is that the final call to}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00204}00204 \textcolor{comment}{         * cam\_periph\_release\_locked() above could result in the periph}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00205}00205 \textcolor{comment}{         * getting freed.  If that is the case, dereferencing the periph}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00206}00206 \textcolor{comment}{         * with a cam\_periph\_unlock() call would cause a page fault.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00207}00207 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00208}00208         mtx\_unlock(mtx);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00209}00209 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00210}00210 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00211}00211 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00212}\mbox{\hyperlink{scsi__sg_8c_a2fe52278f5e5620d62a3b3d9cb74db47}{00212}} \mbox{\hyperlink{scsi__sg_8c_ae40ce8e6da413772f7e6571f518a1f10}{sgoninvalidate}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00213}00213 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00214}00214         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00215}00215 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00216}00216         softc = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00217}00217 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00218}00218         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00219}00219 \textcolor{comment}{         * Deregister any async callbacks.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00220}00220 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00221}00221         \mbox{\hyperlink{cam__xpt_8c_a8307586c12fb4774768a25a1fa4e6388}{xpt\_register\_async}}(0, \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}, periph, periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00222}00222 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00223}00223         softc-\/>\mbox{\hyperlink{structsg__softc_af9651cdedc7e01361f87e0cd586ad845}{flags}} |= \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a548ea72a28734385a2e98054f74fd017}{SG\_FLAG\_INVALID}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00224}00224 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00225}00225         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00226}00226 \textcolor{comment}{         * Tell devfs this device has gone away, and ask for a callback}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00227}00227 \textcolor{comment}{         * when it has cleaned up its state.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00228}00228 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00229}00229         destroy\_dev\_sched\_cb(softc-\/>dev, \mbox{\hyperlink{scsi__sg_8c_a91edb4a9d92972bc8ccd30475f68d1a5}{sgdevgonecb}}, periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00230}00230 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00231}00231         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00232}00232 \textcolor{comment}{         * XXX Return all queued I/O with ENXIO.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00233}00233 \textcolor{comment}{         * XXX Handle any transactions queued to the card}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00234}00234 \textcolor{comment}{         *     with XPT\_ABORT\_CCB.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00235}00235 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00236}00236 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00237}00237 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00238}00238 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00239}00239 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00240}\mbox{\hyperlink{scsi__sg_8c_a6393d99f575b8898b16c815055f2d5ef}{00240}} \mbox{\hyperlink{scsi__sg_8c_ab1348fd9b13f0732799b0f1cf41841ae}{sgcleanup}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00241}00241 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00242}00242         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00243}00243 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00244}00244         softc = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00245}00245 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00246}00246         devstat\_remove\_entry(softc-\/>\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00247}00247 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00248}00248         free(softc, M\_DEVBUF);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00249}00249 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00250}00250 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00251}00251 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00252}\mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{00252}} \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}(\textcolor{keywordtype}{void} *callback\_arg, uint32\_t code, \textcolor{keyword}{struct} \mbox{\hyperlink{structcam__path}{cam\_path}} *path, \textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00253}00253 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00254}00254         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00255}00255 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00256}00256         periph = (\textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *)callback\_arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00257}00257 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00258}00258         \textcolor{keywordflow}{switch} (code) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00259}00259         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam__ccb_8h_a01187b765c0d47bdbc0776db5c5851f0a04183843e65dd16d378d105270a6debd}{AC\_FOUND\_DEVICE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00260}00260         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00261}00261                 \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__getdev}{ccb\_getdev}} *cgd;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00262}00262                 \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3}{cam\_status}} status;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00263}00263 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00264}00264                 cgd = (\textcolor{keyword}{struct }\mbox{\hyperlink{structccb__getdev}{ccb\_getdev}} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00265}00265                 \textcolor{keywordflow}{if} (cgd == NULL)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00266}00266                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00267}00267 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00268}00268                 \textcolor{keywordflow}{if} (cgd-\/>\mbox{\hyperlink{structccb__getdev_a019f53feca9e4c09b563eef64e19c1fd}{protocol}} != \mbox{\hyperlink{cam__ccb_8h_a283e001579038402a95e23bef57107e8a47dbcda94a42ad1914fddef379cb08ce}{PROTO\_SCSI}})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00269}00269                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00270}00270 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00271}00271                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00272}00272 \textcolor{comment}{                 * Allocate a peripheral instance for this device and}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00273}00273 \textcolor{comment}{                 * start the probe process.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00274}00274 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00275}00275                 status = \mbox{\hyperlink{cam__periph_8c_ad5e57f86a941e5a4021b0b026851e445}{cam\_periph\_alloc}}(\mbox{\hyperlink{scsi__sg_8c_acd54b56f5d871039c9d268ea0158118c}{sgregister}}, \mbox{\hyperlink{scsi__sg_8c_ae40ce8e6da413772f7e6571f518a1f10}{sgoninvalidate}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00276}00276                                           \mbox{\hyperlink{scsi__sg_8c_ab1348fd9b13f0732799b0f1cf41841ae}{sgcleanup}}, NULL, \textcolor{stringliteral}{"{}sg"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00277}00277                                           \mbox{\hyperlink{cam__periph_8h_ae648b142a75d7546562342a7b7961e6cada5282ff3d485d68259bc309db51476b}{CAM\_PERIPH\_BIO}}, path,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00278}00278                                           \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}, \mbox{\hyperlink{cam__ccb_8h_a01187b765c0d47bdbc0776db5c5851f0a04183843e65dd16d378d105270a6debd}{AC\_FOUND\_DEVICE}}, cgd);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00279}00279                 \textcolor{keywordflow}{if} ((status != \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a3487a040bd091973beb62275a7309324}{CAM\_REQ\_CMP}}) \&\& (status != \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a167c9bce81d6e65c16734d3e0d59fe24}{CAM\_REQ\_INPROG}})) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00280}00280                         \textcolor{keyword}{const} \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__status__entry}{cam\_status\_entry}} *entry;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00281}00281 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00282}00282                         entry = \mbox{\hyperlink{cam_8c_a95a6eebaa7db28dda125b9c777c02357}{cam\_fetch\_status\_entry}}(status);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00283}00283                         printf(\textcolor{stringliteral}{"{}sgasync: Unable to attach new device "{}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00284}00284                                 \textcolor{stringliteral}{"{}due to status \%\#x: \%s\(\backslash\)n"{}}, status, entry ?}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00285}00285                                 entry-\/>\mbox{\hyperlink{structcam__status__entry_a6eeaf0c1891fbe5794c10b5b3a96a042}{status\_text}} : \textcolor{stringliteral}{"{}Unknown"{}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00286}00286                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00287}00287                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00288}00288         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00289}00289         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00290}00290                 \mbox{\hyperlink{cam__periph_8c_a75ca97e267b2b0a98d4c146ec1967bdc}{cam\_periph\_async}}(periph, code, path, arg);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00291}00291                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00292}00292         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00293}00293 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00294}00294 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00295}00295 \textcolor{keyword}{static} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3}{cam\_status}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00296}\mbox{\hyperlink{scsi__sg_8c_aa0a650c5ea067b83d13a7da3472ad515}{00296}} \mbox{\hyperlink{scsi__sg_8c_acd54b56f5d871039c9d268ea0158118c}{sgregister}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00297}00297 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00298}00298         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00299}00299         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__getdev}{ccb\_getdev}} *cgd;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00300}00300         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__pathinq}{ccb\_pathinq}} cpi;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00301}00301         \textcolor{keyword}{struct }make\_dev\_args args;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00302}00302         \textcolor{keywordtype}{int} no\_tags, error;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00303}00303 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00304}00304         cgd = (\textcolor{keyword}{struct }\mbox{\hyperlink{structccb__getdev}{ccb\_getdev}} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00305}00305         \textcolor{keywordflow}{if} (cgd == NULL) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00306}00306                 printf(\textcolor{stringliteral}{"{}sgregister: no getdev CCB, can't register device\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00307}00307                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a7c519e8cfabb5fd17f4d518c82c17692}{CAM\_REQ\_CMP\_ERR}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00308}00308         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00309}00309 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00310}00310         softc = malloc(\textcolor{keyword}{sizeof}(*softc), M\_DEVBUF, M\_ZERO | M\_NOWAIT);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00311}00311         \textcolor{keywordflow}{if} (softc == NULL) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00312}00312                 printf(\textcolor{stringliteral}{"{}sgregister: Unable to allocate softc\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00313}00313                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a7c519e8cfabb5fd17f4d518c82c17692}{CAM\_REQ\_CMP\_ERR}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00314}00314         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00315}00315 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00316}00316         softc-\/>\mbox{\hyperlink{structsg__softc_a03e3bf0922e7402fb7767daca11283f3}{state}} = \mbox{\hyperlink{scsi__sg_8c_a8a0ac0929c96aa666c9af155e6f0bfa7a833d022ea6acf12a248883846f25d49c}{SG\_STATE\_NORMAL}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00317}00317         softc-\/>pd\_type = \mbox{\hyperlink{scsi__all_8h_aaf542baf40a444b689af23b271bfbebd}{SID\_TYPE}}(\&cgd-\/>\mbox{\hyperlink{structccb__getdev_ae40c7472cbd2a8142162c69e8f66dc55}{inq\_data}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00318}00318         softc-\/>sg\_timeout = \mbox{\hyperlink{scsi__sg_8h_ac4b2178ac0cc38f54c829bd0b9ef981a}{SG\_DEFAULT\_TIMEOUT}} / \mbox{\hyperlink{scsi__sg_8h_a8d6260c41626992174559d15849718cf}{SG\_DEFAULT\_HZ}} * hz;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00319}00319         softc-\/>sg\_user\_timeout = \mbox{\hyperlink{scsi__sg_8h_ac4b2178ac0cc38f54c829bd0b9ef981a}{SG\_DEFAULT\_TIMEOUT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00320}00320         TAILQ\_INIT(\&softc-\/>rdwr\_done);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00321}00321         periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}} = softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00322}00322 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00323}00323         \mbox{\hyperlink{cam__xpt_8h_ae111c3fbe95a53d1bdb2f112d86b929b}{xpt\_path\_inq}}(\&cpi, periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00324}00324 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00325}00325         \textcolor{keywordflow}{if} (cpi.\mbox{\hyperlink{structccb__pathinq_acafc5a0159d616aaa6b45619619dcc1e}{maxio}} == 0)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00326}00326                 softc-\/>\mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{maxio}} = DFLTPHYS;   \textcolor{comment}{/* traditional default */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00327}00327         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (cpi.\mbox{\hyperlink{structccb__pathinq_acafc5a0159d616aaa6b45619619dcc1e}{maxio}} > maxphys)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00328}00328                 softc-\/>\mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{maxio}} = maxphys;            \textcolor{comment}{/* for safety */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00329}00329         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00330}00330                 softc-\/>\mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{maxio}} = cpi.\mbox{\hyperlink{structccb__pathinq_acafc5a0159d616aaa6b45619619dcc1e}{maxio}};     \textcolor{comment}{/* real value */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00331}00331 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00332}00332         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00333}00333 \textcolor{comment}{         * We pass in 0 for all blocksize, since we don't know what the}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00334}00334 \textcolor{comment}{         * blocksize of the device is, if it even has a blocksize.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00335}00335 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00336}00336         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00337}00337         no\_tags = (cgd-\/>\mbox{\hyperlink{structccb__getdev_ae40c7472cbd2a8142162c69e8f66dc55}{inq\_data}}.\mbox{\hyperlink{structscsi__inquiry__data_ab77ae4ac2fb8bd34c6e1b95e2259cdba}{flags}} \& \mbox{\hyperlink{scsi__all_8h_a2654353ac4dfee5fb1a94d06703a6921}{SID\_CmdQue}}) == 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00338}00338         softc-\/>\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}} = devstat\_new\_entry(\textcolor{stringliteral}{"{}sg"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00339}00339                         periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}}, 0,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00340}00340                         DEVSTAT\_NO\_BLOCKSIZE}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00341}00341                         | (no\_tags ? DEVSTAT\_NO\_ORDERED\_TAGS : 0),}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00342}00342                         softc-\/>pd\_type |}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00343}00343                         \mbox{\hyperlink{cam__ccb_8h_ab208430ee4ee01798ab512f38fc0cc7b}{XPORT\_DEVSTAT\_TYPE}}(cpi.\mbox{\hyperlink{structccb__pathinq_aaef7c0420017996140ae4bdede6a8152}{transport}}) |}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00344}00344                         DEVSTAT\_TYPE\_PASS,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00345}00345                         DEVSTAT\_PRIORITY\_PASS);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00346}00346 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00347}00347         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00348}00348 \textcolor{comment}{         * Acquire a reference to the periph before we create the devfs}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00349}00349 \textcolor{comment}{         * instance for it.  We'll release this reference once the devfs}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00350}00350 \textcolor{comment}{         * instance has been freed.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00351}00351 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00352}00352         \textcolor{keywordflow}{if} (\mbox{\hyperlink{cam__periph_8c_a5b3dbda06d83cc62f5ba1be9622efa4b}{cam\_periph\_acquire}}(periph) != 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00353}00353                 \mbox{\hyperlink{cam__xpt_8c_a342b8e2ed77d0b7a12ae7bc49dd2beac}{xpt\_print}}(periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}}, \textcolor{stringliteral}{"{}\%s: lost periph during "{}}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00354}00354                           \textcolor{stringliteral}{"{}registration!\(\backslash\)n"{}}, \_\_func\_\_);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00355}00355                 \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00356}00356                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a7c519e8cfabb5fd17f4d518c82c17692}{CAM\_REQ\_CMP\_ERR}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00357}00357         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00358}00358 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00359}00359         \textcolor{comment}{/* Register the device */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00360}00360         make\_dev\_args\_init(\&args);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00361}00361         args.mda\_devsw = \&\mbox{\hyperlink{scsi__sg_8c_a391d79d545431b8ffcd0bebc446ffce4}{sg\_cdevsw}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00362}00362         args.mda\_unit = periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00363}00363         args.mda\_uid = UID\_ROOT;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00364}00364         args.mda\_gid = GID\_OPERATOR;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00365}00365         args.mda\_mode = 0600;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00366}00366         args.mda\_si\_drv1 = periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00367}00367         error = make\_dev\_s(\&args, \&softc-\/>dev, \textcolor{stringliteral}{"{}\%s\%d"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00368}00368             periph-\/>\mbox{\hyperlink{structcam__periph_a12b5871a0ccca32fa359b1512d5dabad}{periph\_name}}, periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00369}00369         \textcolor{keywordflow}{if} (error != 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00370}00370                 \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00371}00371                 \mbox{\hyperlink{cam__periph_8c_a06741cfe8f484a9dad6f9607a233908c}{cam\_periph\_release\_locked}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00372}00372                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a7c519e8cfabb5fd17f4d518c82c17692}{CAM\_REQ\_CMP\_ERR}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00373}00373         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00374}00374         \textcolor{keywordflow}{if} (periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}} < 26) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00375}00375                 (void)make\_dev\_alias(softc-\/>dev, \textcolor{stringliteral}{"{}sg\%c"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00376}00376                     periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}} + \textcolor{charliteral}{'a'});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00377}00377         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00378}00378                 (void)make\_dev\_alias(softc-\/>dev, \textcolor{stringliteral}{"{}sg\%c\%c"{}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00379}00379                     ((periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}} / 26) -\/ 1) + \textcolor{charliteral}{'a'},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00380}00380                     (periph-\/>\mbox{\hyperlink{structcam__periph_a2b4a50e233de9e726afe3e7e85e63960}{unit\_number}} \% 26) + \textcolor{charliteral}{'a'});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00381}00381         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00382}00382         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00383}00383 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00384}00384         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00385}00385 \textcolor{comment}{         * Add as async callback so that we get}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00386}00386 \textcolor{comment}{         * notified if this device goes away.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00387}00387 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00388}00388         \mbox{\hyperlink{cam__xpt_8c_a8307586c12fb4774768a25a1fa4e6388}{xpt\_register\_async}}(\mbox{\hyperlink{cam__ccb_8h_a01187b765c0d47bdbc0776db5c5851f0ac3008f99f93ca1448f9c8705b1653da5}{AC\_LOST\_DEVICE}}, \mbox{\hyperlink{scsi__sg_8c_a76c3de5af0d3cbc437c31aa7dd5c8743}{sgasync}}, periph, periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00389}00389 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00390}00390         \textcolor{keywordflow}{if} (bootverbose)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00391}00391                 \mbox{\hyperlink{cam__xpt_8c_a62eab2d96b6a86a325df1d826c201746}{xpt\_announce\_periph}}(periph, NULL);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00392}00392 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00393}00393         \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a3487a040bd091973beb62275a7309324}{CAM\_REQ\_CMP}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00394}00394 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00395}00395 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00396}00396 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00397}\mbox{\hyperlink{scsi__sg_8c_a960fc3009b1d5102172f6f9d8a3e4755}{00397}} \mbox{\hyperlink{scsi__sg_8c_a960fc3009b1d5102172f6f9d8a3e4755}{sgdone}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *done\_ccb)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00398}00398 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00399}00399         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00400}00400         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00401}00401 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00402}00402         softc = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00403}00403         csio = \&done\_ccb-\/>\mbox{\hyperlink{unionccb_ab835fc67ca6736b430af71ed7b1780f4}{csio}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00404}00404         switch (csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.ccb\_type) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00405}00405         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15a0d112836f75973868e88c3bec6c6dfae}{SG\_CCB\_RDWR\_IO}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00406}00406         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00407}00407                 \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}} *rdwr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00408}00408 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00409}00409                 devstat\_end\_transaction(softc-\/>\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00410}00410                                         csio-\/>\mbox{\hyperlink{structccb__scsiio_a876ad61cacd6314a81bcb506ed3d4744}{dxfer\_len}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00411}00411                                         csio-\/>\mbox{\hyperlink{structccb__scsiio_a574f17912e1a64938eebd868dbcc6554}{tag\_action}} \& 0xf,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00412}00412                                         ((csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.\mbox{\hyperlink{structccb__hdr_a2b92b9f93c185a3bcd5da48c751c0c05}{flags}} \& \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a97ec6d1cc7973eccb6ad4f17100da965}{CAM\_DIR\_MASK}}) ==}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00413}00413                                         \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a17c5461f834828a5af4980b5ac3a375d}{CAM\_DIR\_NONE}}) ? DEVSTAT\_NO\_DATA :}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00414}00414                                         (csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.\mbox{\hyperlink{structccb__hdr_a2b92b9f93c185a3bcd5da48c751c0c05}{flags}} \& \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676adf60a86f59d84768dceb1af379c0dc3a}{CAM\_DIR\_OUT}}) ?}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00415}00415                                         DEVSTAT\_WRITE : DEVSTAT\_READ,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00416}00416                                         NULL, NULL);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00417}00417 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00418}00418                 rdwr = done\_ccb-\/>\mbox{\hyperlink{unionccb_ab0f218bc2944e08931eb0d935ce4085f}{ccb\_h}}.ccb\_rdwr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00419}00419                 rdwr-\/>state = \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da18979761e24d42e9975986fe699ea1b4}{SG\_RDWR\_DONE}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00420}00420                 wakeup(rdwr);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00421}00421                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00422}00422         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00423}00423         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00424}00424                 panic(\textcolor{stringliteral}{"{}unknown sg CCB type"{}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00425}00425         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00426}00426 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00427}00427 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00428}00428 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00429}\mbox{\hyperlink{scsi__sg_8c_ace91eb8c0e2dd531d79f9dce1705997a}{00429}} \mbox{\hyperlink{scsi__sg_8c_a6368bc1d5613fd1ac5d752e5609ce150}{sgopen}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keywordtype}{int} flags, \textcolor{keywordtype}{int} fmt, \textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00430}00430 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00431}00431         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00432}00432         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00433}00433         \textcolor{keywordtype}{int} error = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00434}00434 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00435}00435         periph = (\textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *)dev-\/>si\_drv1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00436}00436         if (\mbox{\hyperlink{cam__periph_8c_a5b3dbda06d83cc62f5ba1be9622efa4b}{cam\_periph\_acquire}}(periph) != 0)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00437}00437                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00438}00438 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00439}00439         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00440}00440 \textcolor{comment}{         * Don't allow access when we're running at a high securelevel.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00441}00441 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00442}00442         error = securelevel\_gt(td-\/>td\_ucred, 1);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00443}00443         \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00444}00444                 \mbox{\hyperlink{cam__periph_8c_a7b495eee22da0818e6aec8aa176843b7}{cam\_periph\_release}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00445}00445                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00446}00446         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00447}00447 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00448}00448         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00449}00449 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00450}00450         \mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00451}00451         if (softc-\/>\mbox{\hyperlink{structsg__softc_af9651cdedc7e01361f87e0cd586ad845}{flags}} \& \mbox{\hyperlink{scsi__sg_8c_a92cfc840cfa2624408781255f65109a7a548ea72a28734385a2e98054f74fd017}{SG\_FLAG\_INVALID}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00452}00452                 \mbox{\hyperlink{cam__periph_8c_a06741cfe8f484a9dad6f9607a233908c}{cam\_periph\_release\_locked}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00453}00453                 \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00454}00454                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00455}00455         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00456}00456 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00457}00457         softc-\/>\mbox{\hyperlink{structsg__softc_a52eb3cfbb607df30d9bed5708716a071}{open\_count}}++;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00458}00458 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00459}00459         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00460}00460 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00461}00461         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00462}00462 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00463}00463 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00464}00464 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00465}\mbox{\hyperlink{scsi__sg_8c_a54973d70f6822d694cca49f2edb6241d}{00465}} \mbox{\hyperlink{scsi__sg_8c_ad872400e827bdd2d10386ae4bf2a9241}{sgclose}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keywordtype}{int} flag, \textcolor{keywordtype}{int} fmt, \textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00466}00466 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00467}00467         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00468}00468         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}}   *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00469}00469         \textcolor{keyword}{struct }mtx *mtx;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00470}00470 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00471}00471         periph = (\textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *)dev-\/>si\_drv1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00472}00472         mtx = \mbox{\hyperlink{cam__periph_8h_a8b9ecf78613a0fdde3d227cf5a109101}{cam\_periph\_mtx}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00473}00473         mtx\_lock(mtx);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00474}00474 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00475}00475         \mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}} = periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00476}00476         \mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}}-\/>open\_count-\/-\/;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00477}00477 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00478}00478         \mbox{\hyperlink{cam__periph_8c_a06741cfe8f484a9dad6f9607a233908c}{cam\_periph\_release\_locked}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00479}00479 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00480}00480         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00481}00481 \textcolor{comment}{         * We reference the lock directly here, instead of using}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00482}00482 \textcolor{comment}{         * cam\_periph\_unlock().  The reason is that the call to}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00483}00483 \textcolor{comment}{         * cam\_periph\_release\_locked() above could result in the periph}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00484}00484 \textcolor{comment}{         * getting freed.  If that is the case, dereferencing the periph}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00485}00485 \textcolor{comment}{         * with a cam\_periph\_unlock() call would cause a page fault.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00486}00486 \textcolor{comment}{         *}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00487}00487 \textcolor{comment}{         * cam\_periph\_release() avoids this problem using the same method,}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00488}00488 \textcolor{comment}{         * but we're manually acquiring and dropping the lock here to}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00489}00489 \textcolor{comment}{         * protect the open count and avoid another lock acquisition and}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00490}00490 \textcolor{comment}{         * release.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00491}00491 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00492}00492         mtx\_unlock(mtx);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00493}00493 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00494}00494         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00495}00495 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00496}00496 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00497}00497 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00498}\mbox{\hyperlink{scsi__sg_8c_a0202db6cbbfa72a9d323ffd0b737dce4}{00498}} \mbox{\hyperlink{scsi__sg_8c_a53f307040bac4b146b703a02cc3021a9}{sgioctl}}(\textcolor{keyword}{struct} cdev *dev, u\_long cmd, caddr\_t arg, \textcolor{keywordtype}{int} flag, \textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00499}00499 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00500}00500         \textcolor{keyword}{union }\mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{mmc__sim__if_8m_a3b75bbd1e046a488543d1dccdbcae16b}{ccb}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00501}00501         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00502}00502         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00503}00503         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00504}00504         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__io__hdr}{sg\_io\_hdr}} *req;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00505}00505         \textcolor{keywordtype}{int} dir, error;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00506}00506 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00507}00507         periph = (\textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *)dev-\/>si\_drv1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00508}00508         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00509}00509 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00510}00510         \mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *)periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00511}00511         error = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00512}00512 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00513}00513         switch (cmd) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00514}00514         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a20366e42c960758a9fdbc4c1a1585376}{SG\_GET\_VERSION\_NUM}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00515}00515         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00516}00516                 \textcolor{keywordtype}{int} *version = (\textcolor{keywordtype}{int} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00517}00517 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00518}00518                 *version = \mbox{\hyperlink{scsi__sg_8c_ae01c37b8a7197c3871c7b46409818d19}{sg\_version}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00519}00519                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00520}00520         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00521}00521         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a3026b74a2f738200ffa26341f8ad3154}{SG\_SET\_TIMEOUT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00522}00522         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00523}00523                 u\_int user\_timeout = *(u\_int *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00524}00524 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00525}00525                 softc-\/>sg\_user\_timeout = user\_timeout;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00526}00526                 softc-\/>sg\_timeout = user\_timeout / \mbox{\hyperlink{scsi__sg_8h_a8d6260c41626992174559d15849718cf}{SG\_DEFAULT\_HZ}} * hz;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00527}00527                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00528}00528         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00529}00529         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a551f648805bb7e40aab17c14b754a0eb}{SG\_GET\_TIMEOUT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00530}00530                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00531}00531 \textcolor{comment}{                 * The value is returned directly to the syscall.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00532}00532 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00533}00533                 td-\/>td\_retval[0] = softc-\/>sg\_user\_timeout;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00534}00534                 error = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00535}00535                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00536}00536         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ae2e3cdc96eeb266d2aadcf8615bd014f}{SG\_IO}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00537}00537                 req = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__io__hdr}{sg\_io\_hdr}} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00538}00538 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00539}00539                 \textcolor{keywordflow}{if} (req-\/>\mbox{\hyperlink{structsg__io__hdr_a7d35b315f14405b6ec4af7a915f07bff}{cmd\_len}} > \mbox{\hyperlink{cam__ccb_8h_adec61ec38f4f1750296dd5deb88038be}{IOCDBLEN}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00540}00540                         error = EINVAL;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00541}00541                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00542}00542                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00543}00543 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00544}00544                 \textcolor{keywordflow}{if} (req-\/>\mbox{\hyperlink{structsg__io__hdr_a61a0f2f1e7dde62361e5023afbd29e7c}{iovec\_count}} != 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00545}00545                         error = EOPNOTSUPP;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00546}00546                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00547}00547                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00548}00548 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00549}00549                 \mbox{\hyperlink{unionccb}{ccb}} = \mbox{\hyperlink{cam__periph_8h_a3e0b448f630edd6d782fb33e4a12e3f1}{cam\_periph\_getccb}}(periph, \mbox{\hyperlink{cam_8h_a29369d4bf711763f232c214158987e20}{CAM\_PRIORITY\_NORMAL}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00550}00550                 csio = \&\mbox{\hyperlink{unionccb}{ccb}}-\/>\mbox{\hyperlink{unionccb_ab835fc67ca6736b430af71ed7b1780f4}{csio}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00551}00551 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00552}00552                 error = copyin(req-\/>\mbox{\hyperlink{structsg__io__hdr_a00b61856bb55f1c058ced0ae77e50940}{cmdp}}, \&csio-\/>\mbox{\hyperlink{structccb__scsiio_a13387230fb12876920d96b0fe3a74689}{cdb\_io}}.\mbox{\hyperlink{unioncdb__t_a2d84ee02fd9dd4cabf1d6bd187625dc2}{cdb\_bytes}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00553}00553                     req-\/>\mbox{\hyperlink{structsg__io__hdr_a7d35b315f14405b6ec4af7a915f07bff}{cmd\_len}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00554}00554                 \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00555}00555                         \mbox{\hyperlink{cam__xpt_8c_acb560602f4997cc269e6bb54efa93725}{xpt\_release\_ccb}}(\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00556}00556                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00557}00557                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00558}00558 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00559}00559                 \textcolor{keywordflow}{switch}(req-\/>\mbox{\hyperlink{structsg__io__hdr_aced6a389c267ac780ccadd628527f026}{dxfer\_direction}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00560}00560                 \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_aad87ca74b6290e2202b08aebdd304bb5}{SG\_DXFER\_TO\_DEV}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00561}00561                         dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676adf60a86f59d84768dceb1af379c0dc3a}{CAM\_DIR\_OUT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00562}00562                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00563}00563                 \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a202216320f2a375df976219487fa0a7d}{SG\_DXFER\_FROM\_DEV}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00564}00564                         dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a00dc62a475e9a013d8a7f90fcf08f3af}{CAM\_DIR\_IN}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00565}00565                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00566}00566                 \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a62b3d1b4a0bf7921c6d10220f025c3db}{SG\_DXFER\_TO\_FROM\_DEV}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00567}00567                         dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a324efcfe2b4bb312f94a7028687acede}{CAM\_DIR\_BOTH}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00568}00568                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00569}00569                 \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ac1496474132206180ae994a46cf1cd3c}{SG\_DXFER\_NONE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00570}00570                 \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00571}00571                         dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a17c5461f834828a5af4980b5ac3a375d}{CAM\_DIR\_NONE}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00572}00572                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00573}00573                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00574}00574 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00575}00575                 \mbox{\hyperlink{cam__ccb_8h_aa2f54bfe52060582eb17ef5584b8f62b}{cam\_fill\_csio}}(csio,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00576}00576                               \textcolor{comment}{/*retries*/}1,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00577}00577                               \textcolor{comment}{/*cbfcnp*/}NULL,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00578}00578                               dir|\mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676ad020b99f94e8b2864672d09f388dc4e5}{CAM\_DEV\_QFRZDIS}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00579}00579                               \mbox{\hyperlink{scsi__message_8h_ac500601f6c78c28499b430fd47f2aa17}{MSG\_SIMPLE\_Q\_TAG}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00580}00580                               req-\/>\mbox{\hyperlink{structsg__io__hdr_a6688758c89fa09615f1d5419dedcea40}{dxferp}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00581}00581                               req-\/>\mbox{\hyperlink{structsg__io__hdr_adf61d873109ff70bf63ea03fbf52e58f}{dxfer\_len}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00582}00582                               req-\/>\mbox{\hyperlink{structsg__io__hdr_a69fb5ca4d1d23c0884e36a9b371fec97}{mx\_sb\_len}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00583}00583                               req-\/>\mbox{\hyperlink{structsg__io__hdr_a7d35b315f14405b6ec4af7a915f07bff}{cmd\_len}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00584}00584                               req-\/>\mbox{\hyperlink{structsg__io__hdr_a1523ebe1c7fef50ebbca397454310f98}{timeout}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00585}00585 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00586}00586                 error = \mbox{\hyperlink{scsi__sg_8c_a0c6e5a44ca0417699f1e35ef9f107d8d}{sgsendccb}}(periph, \mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00587}00587                 \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00588}00588                         req-\/>\mbox{\hyperlink{structsg__io__hdr_a25251c903b3deaf105e081c523a3a275}{host\_status}} = \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00589}00589                         req-\/>\mbox{\hyperlink{structsg__io__hdr_a494bf87d7f87084dd13fc4ea3ac67817}{driver\_status}} = \mbox{\hyperlink{scsi__sg_8h_a3129407a82e649c3b495dfe1a3fe52e0}{DRIVER\_INVALID}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00590}00590                         \mbox{\hyperlink{cam__xpt_8c_acb560602f4997cc269e6bb54efa93725}{xpt\_release\_ccb}}(\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00591}00591                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00592}00592                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00593}00593 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00594}00594                 req-\/>\mbox{\hyperlink{structsg__io__hdr_a240b8057e0f6960f233b614242b2d4b6}{status}} = csio-\/>\mbox{\hyperlink{structccb__scsiio_a63de880a84354e8722599c3c218f4481}{scsi\_status}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00595}00595                 req-\/>\mbox{\hyperlink{structsg__io__hdr_a637c8cfb09bb211567c9e66734f7d89f}{masked\_status}} = (csio-\/>\mbox{\hyperlink{structccb__scsiio_a63de880a84354e8722599c3c218f4481}{scsi\_status}} >> 1) \& 0x7f;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00596}00596                 \mbox{\hyperlink{scsi__sg_8c_a04f2d39394147a1c12006834c7ad9ced}{sg\_scsiio\_status}}(csio, \&req-\/>\mbox{\hyperlink{structsg__io__hdr_a25251c903b3deaf105e081c523a3a275}{host\_status}}, \&req-\/>\mbox{\hyperlink{structsg__io__hdr_a494bf87d7f87084dd13fc4ea3ac67817}{driver\_status}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00597}00597                 req-\/>\mbox{\hyperlink{structsg__io__hdr_a245cddde037e0c1c414a4f11d6b4f22f}{resid}} = csio-\/>\mbox{\hyperlink{structccb__scsiio_aeb974c780ab5470ba5a8ef184b224c0f}{resid}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00598}00598                 req-\/>\mbox{\hyperlink{structsg__io__hdr_a2dbfb130f5b5eb6488a5be9441808957}{duration}} = csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.\mbox{\hyperlink{structccb__hdr_aafcc3aaf269bd00196097aa9ef85dd9b}{timeout}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00599}00599                 req-\/>\mbox{\hyperlink{structsg__io__hdr_aa594f7b59c4d55a408015cc9370f2530}{info}} = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00600}00600 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00601}00601                 \textcolor{keywordflow}{if} ((csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.\mbox{\hyperlink{structccb__hdr_abcec535dec8d07473cd2af995bf25d88}{status}} \& \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a37b2018e83666ef02a0ac344837ae38f}{CAM\_AUTOSNS\_VALID}})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00602}00602                     \&\& (req-\/>\mbox{\hyperlink{structsg__io__hdr_a982134979069c1ec46261e8b6278d009}{sbp}} != NULL)) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00603}00603                         req-\/>\mbox{\hyperlink{structsg__io__hdr_a3b39885890864834cb6d6b03e25b95a6}{sb\_len\_wr}} = req-\/>\mbox{\hyperlink{structsg__io__hdr_a69fb5ca4d1d23c0884e36a9b371fec97}{mx\_sb\_len}} -\/ csio-\/>\mbox{\hyperlink{structccb__scsiio_a692447632a92215b9089398d63001f8f}{sense\_resid}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00604}00604                         error = copyout(\&csio-\/>\mbox{\hyperlink{structccb__scsiio_a38e04f98dac99a3084f042ec2108054a}{sense\_data}}, req-\/>\mbox{\hyperlink{structsg__io__hdr_a982134979069c1ec46261e8b6278d009}{sbp}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00605}00605                                         req-\/>\mbox{\hyperlink{structsg__io__hdr_a3b39885890864834cb6d6b03e25b95a6}{sb\_len\_wr}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00606}00606                 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00607}00607 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00608}00608                 \mbox{\hyperlink{cam__xpt_8c_acb560602f4997cc269e6bb54efa93725}{xpt\_release\_ccb}}(\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00609}00609                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00610}00610                 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00611}00611         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a123d36f05352e55e10afaa4e194e11d0}{SG\_GET\_RESERVED\_SIZE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00612}00612         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00613}00613                 \textcolor{keywordtype}{int} *size = (\textcolor{keywordtype}{int} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00614}00614                 *size = DFLTPHYS;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00615}00615                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00616}00616         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00617}00617 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00618}00618         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a10cb47f27da85b706e006a8fbd15e5b9}{SG\_GET\_SCSI\_ID}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00619}00619         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00620}00620                 \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__scsi__id}{sg\_scsi\_id}} *\textcolor{keywordtype}{id} = (\textcolor{keyword}{struct }\mbox{\hyperlink{structsg__scsi__id}{sg\_scsi\_id}} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00621}00621 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00622}00622                 \textcolor{keywordtype}{id}-\/>\mbox{\hyperlink{structsg__scsi__id_a8e206cbc344270ec75fcca97b30db77d}{host\_no}} = \mbox{\hyperlink{cam__sim_8h_a046f3a30bb47046dda5770947d1e0a80}{cam\_sim\_path}}(\mbox{\hyperlink{cam__xpt_8c_a9c489a3c42cb061c08fe0dbdaf61fc00}{xpt\_path\_sim}}(periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}}));}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00623}00623                 \textcolor{keywordtype}{id}-\/>channel = \mbox{\hyperlink{cam__xpt_8c_a59f0b7004d3c0cf8257a979c8bee69c7}{xpt\_path\_path\_id}}(periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00624}00624                 \textcolor{keywordtype}{id}-\/>scsi\_id = \mbox{\hyperlink{cam__xpt_8c_ade6ece3b1f31f60097eb81397bdd80df}{xpt\_path\_target\_id}}(periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00625}00625                 \textcolor{keywordtype}{id}-\/>lun = \mbox{\hyperlink{cam__xpt_8c_a8e1d3e8605e605c38025b24dbb62e145}{xpt\_path\_lun\_id}}(periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00626}00626                 \textcolor{keywordtype}{id}-\/>scsi\_type = softc-\/>pd\_type;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00627}00627                 \textcolor{keywordtype}{id}-\/>h\_cmd\_per\_lun = 1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00628}00628                 \textcolor{keywordtype}{id}-\/>d\_queue\_depth = 1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00629}00629                 \textcolor{keywordtype}{id}-\/>unused[0] = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00630}00630                 \textcolor{keywordtype}{id}-\/>unused[1] = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00631}00631                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00632}00632         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00633}00633 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00634}00634         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a232ccea9ab7f07ecee61c4e64594661a}{SG\_GET\_SG\_TABLESIZE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00635}00635         \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00636}00636                 \textcolor{keywordtype}{int} *size = (\textcolor{keywordtype}{int} *)arg;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00637}00637                 *size = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00638}00638                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00639}00639         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00640}00640 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00641}00641         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ac5ca0cb020723db7c27e5b925314e32a}{SG\_EMULATED\_HOST}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00642}00642         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_acbd82164ecad84b8638f63bc47aacbc1}{SG\_SET\_TRANSFORM}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00643}00643         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a7a3abc6e5acc90a1325d45258003c15c}{SG\_GET\_TRANSFORM}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00644}00644         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a8ea4f1f464a755b69c22a1ac32010e01}{SG\_GET\_NUM\_WAITING}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00645}00645         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a7db0ae4b5cd4f1dd1d029666b9e6098b}{SG\_SCSI\_RESET}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00646}00646         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ad3734141bb856e1071cf284925a9cd8f}{SG\_GET\_REQUEST\_TABLE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00647}00647         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ae769636a7b657b9aaab3650c22194af1}{SG\_SET\_KEEP\_ORPHAN}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00648}00648         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ac27de5e9ed89217fb5d44969915cbb05}{SG\_GET\_KEEP\_ORPHAN}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00649}00649         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ac78115c541d12df4cb337f0ff3cf3ac4}{SG\_GET\_ACCESS\_COUNT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00650}00650         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a12325eac00ba367d185a1634729295d8}{SG\_SET\_FORCE\_LOW\_DMA}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00651}00651         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a4212682870df7bed1e74fd8794055d22}{SG\_GET\_LOW\_DMA}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00652}00652         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_aaa223f7fe4106863dc85845eb5dbdbc8}{SG\_SET\_FORCE\_PACK\_ID}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00653}00653         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ad92a1233a51788699b5fccb768cb24da}{SG\_GET\_PACK\_ID}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00654}00654         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a1e01b262c67c2cb702daefdab8cd8f24}{SG\_SET\_RESERVED\_SIZE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00655}00655         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a99dfec75d96824a01b72b407565b00e2}{SG\_GET\_COMMAND\_Q}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00656}00656         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_af2db9b9c81cd8809e93f1bfff5d3c4e2}{SG\_SET\_COMMAND\_Q}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00657}00657         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a1f6738b7c5a80fb7fec9a8b96ed96516}{SG\_SET\_DEBUG}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00658}00658         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_abae11679ab95736b9d25f6e7cb84ee2a}{SG\_NEXT\_CMD\_LEN}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00659}00659         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00660}00660 \textcolor{preprocessor}{\#ifdef CAMDEBUG}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00661}00661                 printf(\textcolor{stringliteral}{"{}sgioctl: rejecting cmd 0x\%lx\(\backslash\)n"{}}, cmd);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00662}00662 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00663}00663                 error = ENODEV;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00664}00664                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00665}00665         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00666}00666 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00667}00667         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00668}00668         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00669}00669 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00670}00670 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00671}00671 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00672}\mbox{\hyperlink{scsi__sg_8c_a74e1fd4f972ce5e0cef6ddd83b56f3ee}{00672}} \mbox{\hyperlink{scsi__sg_8c_a838dcb1cf0b67bc0cf791099c27b7432}{sgwrite}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keyword}{struct} uio *uio, \textcolor{keywordtype}{int} ioflag)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00673}00673 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00674}00674         \textcolor{keyword}{union }\mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{mmc__sim__if_8m_a3b75bbd1e046a488543d1dccdbcae16b}{ccb}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00675}00675         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00676}00676         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00677}00677         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00678}00678         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__header}{sg\_header}} *hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00679}00679         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}} *rdwr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00680}00680         u\_char cdb\_cmd;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00681}00681         \textcolor{keywordtype}{char} *buf;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00682}00682         \textcolor{keywordtype}{int} error = 0, cdb\_len, buf\_len, dir;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00683}00683 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00684}00684         periph = dev-\/>si\_drv1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00685}00685         rdwr = malloc(\textcolor{keyword}{sizeof}(*rdwr), M\_DEVBUF, M\_WAITOK | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00686}00686         \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}} = \&rdwr-\/>\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}.hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00687}00687 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00688}00688         \textcolor{comment}{/* Copy in the header block and sanity check it */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00689}00689         \textcolor{keywordflow}{if} (uio-\/>uio\_resid < \textcolor{keyword}{sizeof}(*\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}})) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00690}00690                 error = EINVAL;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00691}00691                 \textcolor{keywordflow}{goto} out\_hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00692}00692         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00693}00693         error = uiomove(\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}, \textcolor{keyword}{sizeof}(*\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}), uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00694}00694         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00695}00695                 \textcolor{keywordflow}{goto} out\_hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00696}00696 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00697}00697         \textcolor{comment}{/* XXX: We don't support SG 3.x read/write API. */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00698}00698         \textcolor{keywordflow}{if} (\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>reply\_len < 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00699}00699                 error = ENODEV;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00700}00700                 \textcolor{keywordflow}{goto} out\_hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00701}00701         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00702}00702 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00703}00703         \mbox{\hyperlink{unionccb}{ccb}} = \mbox{\hyperlink{cam__xpt_8c_a17fe920aa9698f9b81b06f08d0140fb2}{xpt\_alloc\_ccb}}();}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00704}00704         \textcolor{keywordflow}{if} (\mbox{\hyperlink{unionccb}{ccb}} == NULL) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00705}00705                 error = ENOMEM;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00706}00706                 \textcolor{keywordflow}{goto} out\_hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00707}00707         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00708}00708         csio = \&\mbox{\hyperlink{unionccb}{ccb}}-\/>\mbox{\hyperlink{unionccb_ab835fc67ca6736b430af71ed7b1780f4}{csio}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00709}00709 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00710}00710         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00711}00711 \textcolor{comment}{         * Copy in the CDB block.  The designers of the interface didn't}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00712}00712 \textcolor{comment}{         * bother to provide a size for this in the header, so we have to}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00713}00713 \textcolor{comment}{         * figure it out ourselves.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00714}00714 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00715}00715         \textcolor{keywordflow}{if} (uio-\/>uio\_resid < 1)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00716}00716                 \textcolor{keywordflow}{goto} out\_ccb;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00717}00717         error = uiomove(\&cdb\_cmd, 1, uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00718}00718         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00719}00719                 \textcolor{keywordflow}{goto} out\_ccb;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00720}00720         \textcolor{keywordflow}{if} (\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>twelve\_byte)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00721}00721                 cdb\_len = 12;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00722}00722         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00723}00723                 cdb\_len = \mbox{\hyperlink{scsi__sg_8c_a10c60cef0f98eee1a801f9b8e6324c54}{scsi\_group\_len}}(cdb\_cmd);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00724}00724         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00725}00725 \textcolor{comment}{         * We've already read the first byte of the CDB and advanced the uio}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00726}00726 \textcolor{comment}{         * pointer.  Just read the rest.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00727}00727 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00728}00728         csio-\/>\mbox{\hyperlink{structccb__scsiio_a13387230fb12876920d96b0fe3a74689}{cdb\_io}}.\mbox{\hyperlink{unioncdb__t_a2d84ee02fd9dd4cabf1d6bd187625dc2}{cdb\_bytes}}[0] = cdb\_cmd;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00729}00729         error = uiomove(\&csio-\/>\mbox{\hyperlink{structccb__scsiio_a13387230fb12876920d96b0fe3a74689}{cdb\_io}}.\mbox{\hyperlink{unioncdb__t_a2d84ee02fd9dd4cabf1d6bd187625dc2}{cdb\_bytes}}[1], cdb\_len -\/ 1, uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00730}00730         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00731}00731                 \textcolor{keywordflow}{goto} out\_ccb;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00732}00732 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00733}00733         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00734}00734 \textcolor{comment}{         * Now set up the data block.  Again, the designers didn't bother}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00735}00735 \textcolor{comment}{         * to make this reliable.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00736}00736 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00737}00737         buf\_len = uio-\/>uio\_resid;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00738}00738         \textcolor{keywordflow}{if} (buf\_len != 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00739}00739                 buf = malloc(buf\_len, M\_DEVBUF, M\_WAITOK | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00740}00740                 error = uiomove(buf, buf\_len, uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00741}00741                 \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00742}00742                         \textcolor{keywordflow}{goto} out\_buf;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00743}00743                 dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676adf60a86f59d84768dceb1af379c0dc3a}{CAM\_DIR\_OUT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00744}00744         \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>reply\_len != 0) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00745}00745                 buf = malloc(\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>reply\_len, M\_DEVBUF, M\_WAITOK | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00746}00746                 buf\_len = \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>reply\_len;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00747}00747                 dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a00dc62a475e9a013d8a7f90fcf08f3af}{CAM\_DIR\_IN}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00748}00748         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00749}00749                 buf = NULL;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00750}00750                 buf\_len = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00751}00751                 dir = \mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676a17c5461f834828a5af4980b5ac3a375d}{CAM\_DIR\_NONE}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00752}00752         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00753}00753 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00754}00754         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00755}00755         sc = periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00756}00756         \mbox{\hyperlink{cam__xpt_8c_a64b1b7434225c072f2d9379fe39e359c}{xpt\_setup\_ccb}}(\&\mbox{\hyperlink{unionccb}{ccb}}-\/>\mbox{\hyperlink{unionccb_ab0f218bc2944e08931eb0d935ce4085f}{ccb\_h}}, periph-\/>\mbox{\hyperlink{structcam__periph_ab9f512b2fa31891d84372cd6279670b7}{path}}, \mbox{\hyperlink{cam_8h_a29369d4bf711763f232c214158987e20}{CAM\_PRIORITY\_NORMAL}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00757}00757         \mbox{\hyperlink{cam__ccb_8h_aa2f54bfe52060582eb17ef5584b8f62b}{cam\_fill\_csio}}(csio,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00758}00758                       \textcolor{comment}{/*retries*/}1,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00759}00759                       \mbox{\hyperlink{scsi__sg_8c_a960fc3009b1d5102172f6f9d8a3e4755}{sgdone}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00760}00760                       dir|\mbox{\hyperlink{cam__ccb_8h_a8a331ca6ae1e86223b907c974ef6b676ad020b99f94e8b2864672d09f388dc4e5}{CAM\_DEV\_QFRZDIS}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00761}00761                       \mbox{\hyperlink{scsi__message_8h_ac500601f6c78c28499b430fd47f2aa17}{MSG\_SIMPLE\_Q\_TAG}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00762}00762                       buf,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00763}00763                       buf\_len,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00764}00764                       \mbox{\hyperlink{scsi__sg_8h_ab8704d66b54085d4b5c45f8adb1509d6}{SG\_MAX\_SENSE}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00765}00765                       cdb\_len,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00766}00766                       sc-\/>sg\_timeout);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00767}00767 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00768}00768         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00769}00769 \textcolor{comment}{         * Send off the command and hope that it works. This path does not}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00770}00770 \textcolor{comment}{         * go through sgstart because the I/O is supposed to be asynchronous.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00771}00771 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00772}00772         rdwr-\/>buf = buf;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00773}00773         rdwr-\/>buf\_len = buf\_len;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00774}00774         rdwr-\/>tag = \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>pack\_id;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00775}00775         rdwr-\/>ccb = \mbox{\hyperlink{mmc__sim__if_8m_a3b75bbd1e046a488543d1dccdbcae16b}{ccb}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00776}00776         rdwr-\/>state = \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da3ccf79d057f5bf0559cf919ba6fe8a00}{SG\_RDWR\_INPROG}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00777}00777         \mbox{\hyperlink{unionccb}{ccb}}-\/>\mbox{\hyperlink{unionccb_ab0f218bc2944e08931eb0d935ce4085f}{ccb\_h}}.ccb\_rdwr = rdwr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00778}00778         \mbox{\hyperlink{unionccb}{ccb}}-\/>\mbox{\hyperlink{unionccb_ab0f218bc2944e08931eb0d935ce4085f}{ccb\_h}}.ccb\_type = \mbox{\hyperlink{scsi__sg_8c_a271e0ffe51de796f1833ec2c40ab3f15a0d112836f75973868e88c3bec6c6dfae}{SG\_CCB\_RDWR\_IO}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00779}00779         TAILQ\_INSERT\_TAIL(\&sc-\/>rdwr\_done, rdwr, rdwr\_link);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00780}00780         error = \mbox{\hyperlink{scsi__sg_8c_a5b5ed2680231306f895af4b6f32fded2}{sgsendrdwr}}(periph, \mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00781}00781         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00782}00782         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00783}00783 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00784}00784 out\_buf:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00785}00785         free(buf, M\_DEVBUF);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00786}00786 out\_ccb:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00787}00787         \mbox{\hyperlink{cam__xpt_8c_af1e7540fc366b5cad2e58f29d1de0f60}{xpt\_free\_ccb}}(\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00788}00788 out\_hdr:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00789}00789         free(rdwr, M\_DEVBUF);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00790}00790         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00791}00791 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00792}00792 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00793}00793 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00794}\mbox{\hyperlink{scsi__sg_8c_af44181e4c691169a10f447ba119dce9b}{00794}} \mbox{\hyperlink{scsi__sg_8c_ae598f964f0d18d2fb4064a8f67258ffa}{sgread}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keyword}{struct} uio *uio, \textcolor{keywordtype}{int} ioflag)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00795}00795 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00796}00796         \textcolor{keyword}{struct }\mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00797}00797         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00798}00798         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00799}00799         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__header}{sg\_header}} *hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00800}00800         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__rdwr}{sg\_rdwr}} *rdwr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00801}00801         u\_short hstat, dstat;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00802}00802         \textcolor{keywordtype}{int} error, pack\_len, reply\_len, pack\_id;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00803}00803 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00804}00804         periph = dev-\/>si\_drv1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00805}00805 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00806}00806         \textcolor{comment}{/* XXX The pack len field needs to be updated and written out instead}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00807}00807 \textcolor{comment}{         * of discarded.  Not sure how to do that.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00808}00808 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00809}00809         uio-\/>uio\_rw = UIO\_WRITE;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00810}00810         \textcolor{keywordflow}{if} ((error = uiomove(\&pack\_len, 4, uio)) != 0)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00811}00811                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00812}00812         \textcolor{keywordflow}{if} ((error = uiomove(\&reply\_len, 4, uio)) != 0)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00813}00813                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00814}00814         \textcolor{keywordflow}{if} ((error = uiomove(\&pack\_id, 4, uio)) != 0)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00815}00815                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00816}00816         uio-\/>uio\_rw = UIO\_READ;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00817}00817 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00818}00818         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00819}00819         sc = periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00820}00820 search:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00821}00821         TAILQ\_FOREACH(rdwr, \&sc-\/>rdwr\_done, rdwr\_link) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00822}00822                 \textcolor{keywordflow}{if} (rdwr-\/>tag == pack\_id)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00823}00823                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00824}00824         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00825}00825         \textcolor{keywordflow}{if} ((rdwr == NULL) || (rdwr-\/>state != \mbox{\hyperlink{scsi__sg_8c_a8a94f004c110845d20abb452c5dbfa4da18979761e24d42e9975986fe699ea1b4}{SG\_RDWR\_DONE}})) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00826}00826                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{cam__periph_8h_aca65f2f8c7cf5847b27c39ec84e232d7}{cam\_periph\_sleep}}(periph, rdwr, PCATCH, \textcolor{stringliteral}{"{}sgread"{}}, 0) == ERESTART)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00827}00827                         \textcolor{keywordflow}{return} (EAGAIN);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00828}00828                 \textcolor{keywordflow}{goto} search;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00829}00829         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00830}00830         TAILQ\_REMOVE(\&sc-\/>rdwr\_done, rdwr, rdwr\_link);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00831}00831         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00832}00832 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00833}00833         \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}} = \&rdwr-\/>\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}.hdr;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00834}00834         csio = \&rdwr-\/>ccb-\/>csio;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00835}00835         \mbox{\hyperlink{scsi__sg_8c_a04f2d39394147a1c12006834c7ad9ced}{sg\_scsiio\_status}}(csio, \&hstat, \&dstat);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00836}00836         \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>host\_status = hstat;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00837}00837         \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>driver\_status = dstat;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00838}00838         \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>target\_status = csio-\/>\mbox{\hyperlink{structccb__scsiio_a63de880a84354e8722599c3c218f4481}{scsi\_status}} >> 1;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00839}00839 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00840}00840         \textcolor{keywordflow}{switch} (hstat) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00841}00841         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_af22eecbdc7952000694b299de483d579}{DID\_OK}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00842}00842         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_aead7b6c03fc814701b8ace907be688d4}{DID\_PASSTHROUGH}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00843}00843         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a9742a2f04b61a2e2fa5a35376c5e91ed}{DID\_SOFT\_ERROR}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00844}00844                 \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>result = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00845}00845                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00846}00846         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_aa8c35bfb74ce669034a02461040ea729}{DID\_NO\_CONNECT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00847}00847         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ad279551c25202d14b9ac4d76f020688a}{DID\_BUS\_BUSY}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00848}00848         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a2ad57ae55b2ba7a87bb26de0bde81170}{DID\_TIME\_OUT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00849}00849                 \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>result = EBUSY;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00850}00850                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00851}00851         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a24af5716de8600da8e2d2bcaa307da41}{DID\_BAD\_TARGET}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00852}00852         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a57c2725dc370f502284e079793757244}{DID\_ABORT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00853}00853         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_a3ee2b9774d4892565206d205402e34fa}{DID\_PARITY}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00854}00854         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_adaaef71398cc446e4cd55c5802e0f32d}{DID\_RESET}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00855}00855         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_ae7558a796f2b9eca1d7d0de127fe5af2}{DID\_BAD\_INTR}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00856}00856         \textcolor{keywordflow}{case} \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00857}00857         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00858}00858                 \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>result = EIO;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00859}00859                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00860}00860         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00861}00861 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00862}00862         \textcolor{keywordflow}{if} (dstat == \mbox{\hyperlink{scsi__sg_8h_a9cd13e0b1c001d5dfd7d9e40a08517b2}{DRIVER\_SENSE}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00863}00863                 bcopy(\&csio-\/>\mbox{\hyperlink{structccb__scsiio_a38e04f98dac99a3084f042ec2108054a}{sense\_data}}, \mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>sense\_buffer,}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00864}00864                       min(csio-\/>\mbox{\hyperlink{structccb__scsiio_a571468ac3ea1467d532b8767a90b516c}{sense\_len}}, \mbox{\hyperlink{scsi__sg_8h_ab8704d66b54085d4b5c45f8adb1509d6}{SG\_MAX\_SENSE}}));}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00865}00865 \textcolor{preprocessor}{\#ifdef CAMDEBUG}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00866}00866                 \mbox{\hyperlink{scsi__all_8c_a4c4e999b950a849e9de2497a26efff53}{scsi\_sense\_print}}(csio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00867}00867 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00868}00868         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00869}00869 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00870}00870         error = uiomove(\&\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>result, \textcolor{keyword}{sizeof}(*\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}) -\/}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00871}00871                         offsetof(\textcolor{keyword}{struct} \mbox{\hyperlink{structsg__header}{sg\_header}}, result), uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00872}00872         \textcolor{keywordflow}{if} ((error == 0) \&\& (\mbox{\hyperlink{structsg__rdwr_a62c286c4845d8a7b053d776985b4a989}{hdr}}-\/>result == 0))}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00873}00873                 error = uiomove(rdwr-\/>buf, rdwr-\/>buf\_len, uio);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00874}00874 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00875}00875         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00876}00876         \mbox{\hyperlink{cam__xpt_8c_af1e7540fc366b5cad2e58f29d1de0f60}{xpt\_free\_ccb}}(rdwr-\/>ccb);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00877}00877         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00878}00878         free(rdwr-\/>buf, M\_DEVBUF);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00879}00879         free(rdwr, M\_DEVBUF);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00880}00880         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00881}00881 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00882}00882 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00883}00883 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00884}\mbox{\hyperlink{scsi__sg_8c_a0c6e5a44ca0417699f1e35ef9f107d8d}{00884}} \mbox{\hyperlink{scsi__sg_8c_a0c6e5a44ca0417699f1e35ef9f107d8d}{sgsendccb}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00885}00885 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00886}00886         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00887}00887         \textcolor{keyword}{struct }\mbox{\hyperlink{structcam__periph__map__info}{cam\_periph\_map\_info}} mapinfo;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00888}00888         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00889}00889 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00890}00890         softc = periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00891}00891         bzero(\&mapinfo, \textcolor{keyword}{sizeof}(mapinfo));}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00892}00892 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00893}00893         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00894}00894 \textcolor{comment}{         * cam\_periph\_mapmem calls into proc and vm functions that can}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00895}00895 \textcolor{comment}{         * sleep as well as trigger I/O, so we can't hold the lock.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00896}00896 \textcolor{comment}{         * Dropping it here is reasonably safe.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00897}00897 \textcolor{comment}{         * The only CCB opcode that is possible here is XPT\_SCSI\_IO, no}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00898}00898 \textcolor{comment}{         * need for additional checks.}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00899}00899 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00900}00900         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00901}00901         error = \mbox{\hyperlink{cam__periph_8c_ac2f4c1959a7ea858a031736a09693bbe}{cam\_periph\_mapmem}}(\mbox{\hyperlink{unionccb}{ccb}}, \&mapinfo, softc-\/>\mbox{\hyperlink{structsg__softc_ab0af027ea8af792e756a926928a7290f}{maxio}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00902}00902         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00903}00903         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00904}00904                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00905}00905 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00906}00906         error = \mbox{\hyperlink{cam__periph_8c_a9eb7c5c2381f6769e4ecf63233bfff6f}{cam\_periph\_runccb}}(\mbox{\hyperlink{unionccb}{ccb}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00907}00907                                   \mbox{\hyperlink{scsi__sg_8c_aefa0577158fd166cdecf34b8fd7bd8fc}{sgerror}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00908}00908                                   \mbox{\hyperlink{cam_8h_a14bf0cceb256c2063f776e6cc4aba316a22ee721e6ada9c8fb4a4697789d5246f}{CAM\_RETRY\_SELTO}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00909}00909                                   \mbox{\hyperlink{cam_8h_a06fc87d81c62e9abb8790b6e5713c55ba323bacc6659dffecaffcd935f98954a5}{SF\_RETRY\_UA}},}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00910}00910                                   softc-\/>\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00911}00911 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00912}00912         \mbox{\hyperlink{cam__periph_8h_a66d8b47f5a566db5a6be4697c17886c7}{cam\_periph\_unlock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00913}00913         \mbox{\hyperlink{cam__periph_8c_a54a00fbe30ea8eab256bf8d05c0a28b0}{cam\_periph\_unmapmem}}(\mbox{\hyperlink{unionccb}{ccb}}, \&mapinfo);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00914}00914         \mbox{\hyperlink{cam__periph_8h_a1f320a7fdaff6524ad067970fbab4b27}{cam\_periph\_lock}}(periph);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00915}00915 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00916}00916         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00917}00917 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00918}00918 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00919}00919 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00920}\mbox{\hyperlink{scsi__sg_8c_a5b5ed2680231306f895af4b6f32fded2}{00920}} \mbox{\hyperlink{scsi__sg_8c_a5b5ed2680231306f895af4b6f32fded2}{sgsendrdwr}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcam__periph}{cam\_periph}} *periph, \textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00921}00921 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00922}00922         \textcolor{keyword}{struct }\mbox{\hyperlink{structsg__softc}{sg\_softc}} *softc;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00923}00923 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00924}00924         softc = periph-\/>\mbox{\hyperlink{structcam__periph_a6ba6ec6ae18e7f5935209ff5ca9ba385}{softc}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00925}00925         devstat\_start\_transaction(softc-\/>\mbox{\hyperlink{structsg__softc_a7bfd65c371620fe5e790cd2e9c2ee296}{device\_stats}}, NULL);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00926}00926         \mbox{\hyperlink{cam__xpt_8c_a6ef97382f5b1590b4d2d138516a63bcc}{xpt\_action}}(\mbox{\hyperlink{unionccb}{ccb}});}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00927}00927         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00928}00928 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00929}00929 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00930}00930 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00931}\mbox{\hyperlink{scsi__sg_8c_aefa0577158fd166cdecf34b8fd7bd8fc}{00931}} \mbox{\hyperlink{scsi__sg_8c_aefa0577158fd166cdecf34b8fd7bd8fc}{sgerror}}(\textcolor{keyword}{union} \mbox{\hyperlink{unionccb}{ccb}} *\mbox{\hyperlink{unionccb}{ccb}}, uint32\_t \mbox{\hyperlink{cam_8h_a14bf0cceb256c2063f776e6cc4aba316}{cam\_flags}}, uint32\_t sense\_flags)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00932}00932 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00933}00933 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00934}00934         \textcolor{keywordflow}{return} (\mbox{\hyperlink{cam__periph_8c_ac2010c1d05ec8dff4d1c03f3ec0be8c4}{cam\_periph\_error}}(\mbox{\hyperlink{unionccb}{ccb}}, \mbox{\hyperlink{cam_8h_a14bf0cceb256c2063f776e6cc4aba316}{cam\_flags}}, sense\_flags));}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00935}00935 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00936}00936 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00937}00937 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00938}\mbox{\hyperlink{scsi__sg_8c_a04f2d39394147a1c12006834c7ad9ced}{00938}} \mbox{\hyperlink{scsi__sg_8c_a04f2d39394147a1c12006834c7ad9ced}{sg\_scsiio\_status}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structccb__scsiio}{ccb\_scsiio}} *csio, u\_short *hoststat, u\_short *drvstat)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00939}00939 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00940}00940         \textcolor{keywordtype}{int} status;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00941}00941 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00942}00942         status = csio-\/>\mbox{\hyperlink{structccb__scsiio_a267ba491b17e3e5820fdf56425a635b1}{ccb\_h}}.\mbox{\hyperlink{structccb__hdr_abcec535dec8d07473cd2af995bf25d88}{status}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00943}00943 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00944}00944         \textcolor{keywordflow}{switch} (status \& \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a82f0d57eda0654067dc2db0c2a218caa}{CAM\_STATUS\_MASK}}) \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00945}00945         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a3487a040bd091973beb62275a7309324}{CAM\_REQ\_CMP}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00946}00946                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_af22eecbdc7952000694b299de483d579}{DID\_OK}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00947}00947                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00948}00948                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00949}00949         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a7c519e8cfabb5fd17f4d518c82c17692}{CAM\_REQ\_CMP\_ERR}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00950}00950                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00951}00951                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00952}00952                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00953}00953         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a880e0abf6511fcc6e7967258d6a74dda}{CAM\_REQ\_ABORTED}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00954}00954                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_a57c2725dc370f502284e079793757244}{DID\_ABORT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00955}00955                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00956}00956                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00957}00957         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a12f00b32285d7ae4b17eb8aaeae0d0fb}{CAM\_REQ\_INVALID}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00958}00958                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00959}00959                 *drvstat = \mbox{\hyperlink{scsi__sg_8h_a3129407a82e649c3b495dfe1a3fe52e0}{DRIVER\_INVALID}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00960}00960                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00961}00961         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a45b712a5be7c3910f37757908a444e0b}{CAM\_DEV\_NOT\_THERE}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00962}00962                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_a24af5716de8600da8e2d2bcaa307da41}{DID\_BAD\_TARGET}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00963}00963                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00964}00964                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00965}00965         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3af9e3db4b980b404a4ae381c1c1e4494a}{CAM\_SEL\_TIMEOUT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00966}00966                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_aa8c35bfb74ce669034a02461040ea729}{DID\_NO\_CONNECT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00967}00967                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00968}00968                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00969}00969         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a515f15cec219130718fd7eafc4a1fbea}{CAM\_CMD\_TIMEOUT}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00970}00970                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_a2ad57ae55b2ba7a87bb26de0bde81170}{DID\_TIME\_OUT}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00971}00971                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00972}00972                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00973}00973         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3aeb963e5650478930f8ff1380b169a84f}{CAM\_SCSI\_STATUS\_ERROR}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00974}00974                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00975}00975                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00976}00976                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00977}00977         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a0cb6a35e1cbb336da844264c140f2f17}{CAM\_SCSI\_BUS\_RESET}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00978}00978                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_adaaef71398cc446e4cd55c5802e0f32d}{DID\_RESET}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00979}00979                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00980}00980                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00981}00981         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a5b71c69bd83cc80f16ec16141ac4579a}{CAM\_UNCOR\_PARITY}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00982}00982                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_a3ee2b9774d4892565206d205402e34fa}{DID\_PARITY}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00983}00983                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00984}00984                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00985}00985         \textcolor{keywordflow}{case} \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a5dcab734a4da382f12f43a643ac5ac6a}{CAM\_SCSI\_BUSY}}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00986}00986                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_ad279551c25202d14b9ac4d76f020688a}{DID\_BUS\_BUSY}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00987}00987                 *drvstat = 0;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00988}00988                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00989}00989         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00990}00990                 *hoststat = \mbox{\hyperlink{scsi__sg_8h_aaa31c46db51d1738c543910301c24206}{DID\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00991}00991                 *drvstat = \mbox{\hyperlink{scsi__sg_8h_ac653a37c5ff2c6d3d8e1926f8f000e7c}{DRIVER\_ERROR}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00992}00992         \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00993}00993 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00994}00994         \textcolor{keywordflow}{if} (status \& \mbox{\hyperlink{cam_8h_a9ff49352334e6ad8ce937cf2fdf4cfb3a37b2018e83666ef02a0ac344837ae38f}{CAM\_AUTOSNS\_VALID}})}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00995}00995                 *drvstat = \mbox{\hyperlink{scsi__sg_8h_a9cd13e0b1c001d5dfd7d9e40a08517b2}{DRIVER\_SENSE}};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00996}00996 \}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00997}00997 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00998}00998 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l00999}\mbox{\hyperlink{scsi__sg_8c_a10c60cef0f98eee1a801f9b8e6324c54}{00999}} \mbox{\hyperlink{scsi__sg_8c_a10c60cef0f98eee1a801f9b8e6324c54}{scsi\_group\_len}}(u\_char cmd)}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01000}01000 \{}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01001}01001         \textcolor{keywordtype}{int} len[] = \{6, 10, 10, 12, 12, 12, 10, 10\};}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01002}01002         \textcolor{keywordtype}{int} group;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01003}01003 }
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01004}01004         group = (cmd >> 5) \& 0x7;}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01005}01005         \textcolor{keywordflow}{return} (len[group]);}
\DoxyCodeLine{\Hypertarget{scsi__sg_8c_source_l01006}01006 \}}

\end{DoxyCode}
