xref: /freebsd/sys/dev/pms/RefTisa/sat/api/tdsmapi.h (revision 0d66206fff44f864ea8a4b220c3a53b4caa959a0)
1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20 *
21 * $FreeBSD$
22 *
23 ********************************************************************************/
24 /********************************************************************************
25 *   tmsmapi.h
26 *
27 *   Abstract:   This module contains function prototype of the SAT
28 *               Module (SM) API callback for initiator.
29 *******************************************************************************/
30 
31 #ifndef TDSMAPI_H
32 #define TDSMAPI_H
33 
34 osGLOBAL void
35 tdsmIDCompletedCB(
36                   smRoot_t   *smRoot,
37                   smIORequest_t   *smIORequest,
38                   smDeviceHandle_t   *smDeviceHandle,
39                   bit32    status,
40                   void    *IDdata
41                  );
42 
43 osGLOBAL FORCEINLINE void
44 tdsmIOCompletedCB(
45                   smRoot_t   *smRoot,
46                   smIORequest_t   *smIORequest,
47                   bit32    status,
48                   bit32    statusDetail,
49                   smSenseData_t   *senseData,
50                   bit32    interruptContext
51                   );
52 osGLOBAL void
53 tdsmEventCB(
54                 smRoot_t          *smRoot,
55                 smDeviceHandle_t  *smDeviceHandle,
56                 smIntrEventType_t  eventType,
57                 bit32              eventStatus,
58                 void              *parm
59                 );
60 
61 osGLOBAL FORCEINLINE void
62 tdsmSingleThreadedEnter(
63                         smRoot_t   *smRoot,
64                         bit32       syncLockId
65                        );
66 
67 osGLOBAL FORCEINLINE void
68 tdsmSingleThreadedLeave(
69                         smRoot_t   *smRoot,
70                         bit32       syncLockId
71                         );
72 
73 osGLOBAL FORCEINLINE bit8
74 tdsmBitScanForward(
75                   smRoot_t   *smRoot,
76                   bit32      *Index,
77                   bit32       Mask
78                   );
79 
80 #ifdef LINUX_VERSION_CODE
81 
82 osGLOBAL FORCEINLINE sbit32
83 tdsmInterlockedIncrement(
84                    smRoot_t        *smRoot,
85                    sbit32 volatile *Addend
86                    );
87 
88 osGLOBAL FORCEINLINE sbit32
89 tdsmInterlockedDecrement(
90                    smRoot_t         *smRoot,
91                    sbit32 volatile  *Addend
92                    );
93 
94 osGLOBAL FORCEINLINE sbit32
95 tdsmAtomicBitClear(
96                smRoot_t         *smRoot,
97                sbit32 volatile  *Destination,
98                sbit32            Value
99                );
100 
101 osGLOBAL FORCEINLINE sbit32
102 tdsmAtomicBitSet(
103                smRoot_t         *smRoot,
104                sbit32 volatile  *Destination,
105                sbit32            Value
106                );
107 
108 osGLOBAL FORCEINLINE sbit32
109 tdsmAtomicExchange(
110                smRoot_t        *smRoot,
111                sbit32 volatile *Target,
112                sbit32           Value
113                );
114 #else
115 
116 osGLOBAL FORCEINLINE sbit32
117 tdsmInterlockedIncrement(
118                    smRoot_t        *smRoot,
119                    sbit32 volatile *Addend
120                    );
121 
122 osGLOBAL FORCEINLINE sbit32
123 tdsmInterlockedDecrement(
124                    smRoot_t        *smRoot,
125                    sbit32 volatile *Addend
126                    );
127 
128 osGLOBAL FORCEINLINE sbit32
129 tdsmInterlockedAnd(
130                smRoot_t         *smRoot,
131                sbit32 volatile  *Destination,
132                sbit32            Value
133                );
134 
135 osGLOBAL FORCEINLINE sbit32
136 tdsmInterlockedOr(
137                smRoot_t         *smRoot,
138                sbit32 volatile  *Destination,
139                sbit32            Value
140                );
141 
142 osGLOBAL FORCEINLINE sbit32
143 tdsmInterlockedExchange(
144                smRoot_t        *smRoot,
145                sbit32 volatile *Target,
146                sbit32           Value
147                );
148 
149 #endif /*LINUX_VERSION_CODE*/
150 
151 osGLOBAL bit32
152 tdsmAllocMemory(
153                 smRoot_t    *smRoot,
154                 void        **osMemHandle,
155                 void        ** virtPtr,
156                 bit32       * physAddrUpper,
157                 bit32       * physAddrLower,
158                 bit32       alignment,
159                 bit32       allocLength,
160                 smBOOLEAN   isCacheable
161                );
162 
163 osGLOBAL bit32
164 tdsmFreeMemory(
165                smRoot_t    *smRoot,
166                void        *osDMAHandle,
167                bit32        allocLength
168               );
169 
170 osGLOBAL FORCEINLINE bit32
171 tdsmRotateQnumber(smRoot_t        *smRoot,
172                          smDeviceHandle_t *smDeviceHandle
173                          );
174 
175 osGLOBAL bit32
176 tdsmSetDeviceQueueDepth(smRoot_t      *smRoot,
177                                  smIORequest_t *smIORequest,
178                                  bit32          QueueDepth
179                                  );
180 
181 
182 #ifndef tdsmLogDebugString
183 GLOBAL void tdsmLogDebugString(
184                          smRoot_t     *smRoot,
185                          bit32        level,
186                          char         *string,
187                          void         *ptr1,
188                          void         *ptr2,
189                          bit32        value1,
190                          bit32        value2
191                          );
192 #endif
193 
194 
195 
196 osGLOBAL bit32 tdsmGetTransportParam(
197                         smRoot_t    *smRoot,
198                         char        *key,
199                         char        *subkey1,
200                         char        *subkey2,
201                         char        *subkey3,
202                         char        *subkey4,
203                         char        *subkey5,
204                         char        *valueName,
205                         char        *buffer,
206                         bit32       bufferLen,
207                         bit32       *lenReceived
208                         );
209 
210 #endif  /* TDSMAPI_H */
211 
212