1285809Sscottl/*******************************************************************************
2285809Sscottl*Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3285809Sscottl*
4285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided
5285809Sscottl*that the following conditions are met:
6285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7285809Sscottl*following disclaimer.
8285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice,
9285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided
10285809Sscottl*with the distribution.
11285809Sscottl*
12285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13285809Sscottl*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14285809Sscottl*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15285809Sscottl*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16285809Sscottl*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17285809Sscottl*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18285809Sscottl*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19285809Sscottl*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20285809Sscottl*
21285809Sscottl* $FreeBSD$
22285809Sscottl*
23285809Sscottl********************************************************************************/
24285809Sscottl/********************************************************************************
25285809Sscottl*   tmsmapi.h
26285809Sscottl*
27285809Sscottl*   Abstract:   This module contains function prototype of the SAT
28285809Sscottl*               Module (SM) API callback for initiator.
29285809Sscottl*******************************************************************************/
30285809Sscottl
31285809Sscottl#ifndef TDSMAPI_H
32285809Sscottl#define TDSMAPI_H
33285809Sscottl
34285809SscottlosGLOBAL void
35285809SscottltdsmIDCompletedCB(
36285809Sscottl                  smRoot_t   *smRoot,
37285809Sscottl                  smIORequest_t   *smIORequest,
38285809Sscottl                  smDeviceHandle_t   *smDeviceHandle,
39285809Sscottl                  bit32    status,
40285809Sscottl                  void    *IDdata
41285809Sscottl                 );
42285809Sscottl
43285809SscottlosGLOBAL FORCEINLINE void
44285809SscottltdsmIOCompletedCB(
45285809Sscottl                  smRoot_t   *smRoot,
46285809Sscottl                  smIORequest_t   *smIORequest,
47285809Sscottl                  bit32    status,
48285809Sscottl                  bit32    statusDetail,
49285809Sscottl                  smSenseData_t   *senseData,
50285809Sscottl                  bit32    interruptContext
51285809Sscottl                  );
52285809SscottlosGLOBAL void
53285809SscottltdsmEventCB(
54285809Sscottl                smRoot_t          *smRoot,
55285809Sscottl                smDeviceHandle_t  *smDeviceHandle,
56285809Sscottl                smIntrEventType_t  eventType,
57285809Sscottl                bit32              eventStatus,
58285809Sscottl                void              *parm
59285809Sscottl                );
60285809Sscottl
61285809SscottlosGLOBAL FORCEINLINE void
62285809SscottltdsmSingleThreadedEnter(
63285809Sscottl                        smRoot_t   *smRoot,
64285809Sscottl                        bit32       syncLockId
65285809Sscottl                       );
66285809Sscottl
67285809SscottlosGLOBAL FORCEINLINE void
68285809SscottltdsmSingleThreadedLeave(
69285809Sscottl                        smRoot_t   *smRoot,
70285809Sscottl                        bit32       syncLockId
71285809Sscottl                        );
72285809Sscottl
73285809SscottlosGLOBAL FORCEINLINE bit8
74285809SscottltdsmBitScanForward(
75285809Sscottl                  smRoot_t   *smRoot,
76285809Sscottl                  bit32      *Index,
77285809Sscottl                  bit32       Mask
78285809Sscottl                  );
79285809Sscottl
80285809Sscottl#ifdef LINUX_VERSION_CODE
81285809Sscottl
82285809SscottlosGLOBAL FORCEINLINE sbit32
83285809SscottltdsmInterlockedIncrement(
84285809Sscottl                   smRoot_t        *smRoot,
85285809Sscottl                   sbit32 volatile *Addend
86285809Sscottl                   );
87285809Sscottl
88285809SscottlosGLOBAL FORCEINLINE sbit32
89285809SscottltdsmInterlockedDecrement(
90285809Sscottl                   smRoot_t         *smRoot,
91285809Sscottl                   sbit32 volatile  *Addend
92285809Sscottl                   );
93285809Sscottl
94285809SscottlosGLOBAL FORCEINLINE sbit32
95285809SscottltdsmAtomicBitClear(
96285809Sscottl               smRoot_t         *smRoot,
97285809Sscottl               sbit32 volatile  *Destination,
98285809Sscottl               sbit32            Value
99285809Sscottl               );
100285809Sscottl
101285809SscottlosGLOBAL FORCEINLINE sbit32
102285809SscottltdsmAtomicBitSet(
103285809Sscottl               smRoot_t         *smRoot,
104285809Sscottl               sbit32 volatile  *Destination,
105285809Sscottl               sbit32            Value
106285809Sscottl               );
107285809Sscottl
108285809SscottlosGLOBAL FORCEINLINE sbit32
109285809SscottltdsmAtomicExchange(
110285809Sscottl               smRoot_t        *smRoot,
111285809Sscottl               sbit32 volatile *Target,
112285809Sscottl               sbit32           Value
113285809Sscottl               );
114285809Sscottl#else
115285809Sscottl
116285809SscottlosGLOBAL FORCEINLINE sbit32
117285809SscottltdsmInterlockedIncrement(
118285809Sscottl                   smRoot_t        *smRoot,
119285809Sscottl                   sbit32 volatile *Addend
120285809Sscottl                   );
121285809Sscottl
122285809SscottlosGLOBAL FORCEINLINE sbit32
123285809SscottltdsmInterlockedDecrement(
124285809Sscottl                   smRoot_t        *smRoot,
125285809Sscottl                   sbit32 volatile *Addend
126285809Sscottl                   );
127285809Sscottl
128285809SscottlosGLOBAL FORCEINLINE sbit32
129285809SscottltdsmInterlockedAnd(
130285809Sscottl               smRoot_t         *smRoot,
131285809Sscottl               sbit32 volatile  *Destination,
132285809Sscottl               sbit32            Value
133285809Sscottl               );
134285809Sscottl
135285809SscottlosGLOBAL FORCEINLINE sbit32
136285809SscottltdsmInterlockedOr(
137285809Sscottl               smRoot_t         *smRoot,
138285809Sscottl               sbit32 volatile  *Destination,
139285809Sscottl               sbit32            Value
140285809Sscottl               );
141285809Sscottl
142285809SscottlosGLOBAL FORCEINLINE sbit32
143285809SscottltdsmInterlockedExchange(
144285809Sscottl               smRoot_t        *smRoot,
145285809Sscottl               sbit32 volatile *Target,
146285809Sscottl               sbit32           Value
147285809Sscottl               );
148285809Sscottl
149285809Sscottl#endif /*LINUX_VERSION_CODE*/
150285809Sscottl
151285809SscottlosGLOBAL bit32
152285809SscottltdsmAllocMemory(
153285809Sscottl                smRoot_t    *smRoot,
154285809Sscottl                void        **osMemHandle,
155285809Sscottl                void        ** virtPtr,
156285809Sscottl                bit32       * physAddrUpper,
157285809Sscottl                bit32       * physAddrLower,
158285809Sscottl                bit32       alignment,
159285809Sscottl                bit32       allocLength,
160285809Sscottl                smBOOLEAN   isCacheable
161285809Sscottl               );
162285809Sscottl
163285809SscottlosGLOBAL bit32
164285809SscottltdsmFreeMemory(
165285809Sscottl               smRoot_t    *smRoot,
166285809Sscottl               void        *osDMAHandle,
167285809Sscottl               bit32        allocLength
168285809Sscottl              );
169285809Sscottl
170285809SscottlosGLOBAL FORCEINLINE bit32
171285809SscottltdsmRotateQnumber(smRoot_t        *smRoot,
172285809Sscottl                         smDeviceHandle_t *smDeviceHandle
173285809Sscottl                         );
174285809Sscottl
175285809SscottlosGLOBAL bit32
176285809SscottltdsmSetDeviceQueueDepth(smRoot_t      *smRoot,
177285809Sscottl                                 smIORequest_t *smIORequest,
178285809Sscottl                                 bit32          QueueDepth
179285809Sscottl                                 );
180285809Sscottl
181285809Sscottl
182285809Sscottl#ifndef tdsmLogDebugString
183285809SscottlGLOBAL void tdsmLogDebugString(
184285809Sscottl                         smRoot_t     *smRoot,
185285809Sscottl                         bit32        level,
186285809Sscottl                         char         *string,
187285809Sscottl                         void         *ptr1,
188285809Sscottl                         void         *ptr2,
189285809Sscottl                         bit32        value1,
190285809Sscottl                         bit32        value2
191285809Sscottl                         );
192285809Sscottl#endif
193285809Sscottl
194285809Sscottl
195285809Sscottl
196285809SscottlosGLOBAL bit32 tdsmGetTransportParam(
197285809Sscottl                        smRoot_t    *smRoot,
198285809Sscottl                        char        *key,
199285809Sscottl                        char        *subkey1,
200285809Sscottl                        char        *subkey2,
201285809Sscottl                        char        *subkey3,
202285809Sscottl                        char        *subkey4,
203285809Sscottl                        char        *subkey5,
204285809Sscottl                        char        *valueName,
205285809Sscottl                        char        *buffer,
206285809Sscottl                        bit32       bufferLen,
207285809Sscottl                        bit32       *lenReceived
208285809Sscottl                        );
209285809Sscottl
210285809Sscottl#endif  /* TDSMAPI_H */
211285809Sscottl
212