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#ifndef __SMPROTO_H__
25#define __SMPROTO_H__
26
27#include <dev/pms/RefTisa/sat/src/smtypes.h>
28
29/***************** start of util ****************************************/
30osGLOBAL FORCEINLINE void*
31sm_memset(void *s, int c, bit32 n);
32
33osGLOBAL FORCEINLINE void *
34sm_memcpy(void *dst, const void *src, bit32 count);
35
36osGLOBAL char
37*sm_strncpy(char *dst, const char *src, bit32 len);
38
39
40osGLOBAL void
41smhexdump(const char *ptitle, bit8 *pbuf, size_t len);
42/***************** end of util ****************************************/
43
44/***************** start of timer fns ****************************************/
45osGLOBAL void
46smTimerTick(smRoot_t 		*smRoot );
47
48osGLOBAL void
49smInitTimerRequest(
50                   smRoot_t                *smRoot,
51                   smTimerRequest_t        *timerRequest
52                  );
53osGLOBAL void
54smSetTimerRequest(
55                  smRoot_t            *smRoot,
56                  smTimerRequest_t    *timerRequest,
57                  bit32               timeout,
58                  smTimerCBFunc_t     CBFunc,
59                  void                *timerData1,
60                  void                *timerData2,
61                  void                *timerData3
62                  );
63
64osGLOBAL void
65smAddTimer(
66           smRoot_t            *smRoot,
67           smList_t            *timerListHdr,
68           smTimerRequest_t    *timerRequest
69          );
70
71osGLOBAL void
72smKillTimer(
73            smRoot_t            *smRoot,
74            smTimerRequest_t    *timerRequest
75           );
76
77osGLOBAL void
78smProcessTimers(
79                smRoot_t *smRoot
80               );
81
82
83/***************** end of timer fns ****************************************/
84
85osGLOBAL void
86smInitTimers(
87             smRoot_t *smRoot
88            );
89
90osGLOBAL void
91smDeviceDataInit(
92                 smRoot_t *smRoot,
93                 bit32    max_dev
94                );
95
96osGLOBAL void
97smIOInit(
98         smRoot_t *smRoot
99        );
100
101osGLOBAL FORCEINLINE void
102smIOReInit(
103          smRoot_t          *smRoot,
104          smIORequestBody_t *smIORequestBody
105          );
106
107osGLOBAL void
108smDeviceDataReInit(
109                   smRoot_t        *smRoot,
110                   smDeviceData_t  *oneDeviceData
111                  );
112
113osGLOBAL void
114smEnqueueIO(
115             smRoot_t           *smRoot,
116             smSatIOContext_t   *satIOContext
117             );
118
119osGLOBAL FORCEINLINE void
120smsatFreeIntIoResource(
121             smRoot_t           *smRoot,
122             smDeviceData_t     *satDevData,
123             smSatInternalIo_t  *satIntIo
124             );
125
126osGLOBAL smSatInternalIo_t *
127smsatAllocIntIoResource(
128                        smRoot_t              *smRoot,
129                        smIORequest_t         *smIORequest,
130                        smDeviceData_t        *satDevData,
131                        bit32                 dmaAllocLength,
132                        smSatInternalIo_t     *satIntIo);
133
134
135
136osGLOBAL smDeviceData_t *
137smAddToSharedcontext(
138                     smRoot_t                   *smRoot,
139                     agsaDevHandle_t            *agDevHandle,
140                     smDeviceHandle_t           *smDeviceHandle,
141                     agsaDevHandle_t            *agExpDevHandle,
142                     bit32                      phyID
143                    );
144
145osGLOBAL bit32
146smRemoveFromSharedcontext(
147                          smRoot_t                      *smRoot,
148                          agsaDevHandle_t               *agDevHandle,
149                          smDeviceHandle_t              *smDeviceHandle
150                         );
151
152osGLOBAL smDeviceData_t *
153smFindInSharedcontext(
154                      smRoot_t                  *smRoot,
155                      agsaDevHandle_t           *agDevHandle
156                      );
157
158osGLOBAL bit32
159smsatLogSenseAllocate(
160                      smRoot_t                  *smRoot,
161                      smIORequest_t             *smIORequest,
162                      smDeviceHandle_t          *smDeviceHandle,
163                      smScsiInitiatorRequest_t  *smSCSIRequest,
164                      smSatIOContext_t            *satIOContext,
165                      bit32                     payloadSize,
166                      bit32                     flag
167                     );
168
169osGLOBAL bit32
170smsatIDSubStart(
171                 smRoot_t                 *smRoot,
172                 smIORequest_t            *smIORequest,
173                 smDeviceHandle_t         *smDeviceHandle,
174                 smScsiInitiatorRequest_t *smSCSIRequest,
175                 smSatIOContext_t           *satIOContext
176               );
177
178
179osGLOBAL bit32
180smsatIDStart(
181              smRoot_t                  *smRoot,
182              smIORequest_t             *smIORequest,
183              smDeviceHandle_t          *smDeviceHandle,
184              smScsiInitiatorRequest_t  *smSCSIRequest,
185              smSatIOContext_t            *satIOContext
186             );
187
188
189osGLOBAL FORCEINLINE bit32
190smsatIOStart(
191              smRoot_t                  *smRoot,
192              smIORequest_t             *smIORequest,
193              smDeviceHandle_t          *smDeviceHandle,
194              smScsiInitiatorRequest_t  *smSCSIRequest,
195              smSatIOContext_t            *satIOContext
196             );
197
198osGLOBAL void
199smsatSetSensePayload(
200                     smScsiRspSense_t   *pSense,
201                     bit8               SnsKey,
202                     bit32              SnsInfo,
203                     bit16              SnsCode,
204                     smSatIOContext_t     *satIOContext
205		    );
206
207osGLOBAL void
208smsatSetDeferredSensePayload(
209                             smScsiRspSense_t *pSense,
210                             bit8             SnsKey,
211                             bit32            SnsInfo,
212                             bit16            SnsCode,
213                             smSatIOContext_t   *satIOContext
214                            );
215
216osGLOBAL FORCEINLINE bit32
217smsatIOPrepareSGL(
218                  smRoot_t                 *smRoot,
219                  smIORequestBody_t        *smIORequestBody,
220                  smSgl_t                  *smSgl1,
221                  void                     *sglVirtualAddr
222                  );
223osGLOBAL FORCEINLINE void
224smsatBitSet(smRoot_t *smRoot,bit8 *data, bit32 index);
225
226osGLOBAL FORCEINLINE void
227smsatBitClear(smRoot_t *smRoot,bit8 *data, bit32 index);
228
229osGLOBAL FORCEINLINE BOOLEAN
230smsatBitTest(smRoot_t *smRoot,bit8 *data, bit32 index);
231
232osGLOBAL FORCEINLINE bit32
233smsatTagAlloc(
234               smRoot_t         *smRoot,
235               smDeviceData_t   *pSatDevData,
236               bit8             *pTag
237             );
238
239osGLOBAL FORCEINLINE bit32
240smsatTagRelease(
241                smRoot_t         *smRoot,
242                smDeviceData_t   *pSatDevData,
243                bit8              tag
244               );
245
246osGLOBAL FORCEINLINE void
247smsatDecrementPendingIO(
248                        smRoot_t                *smRoot,
249                        smIntContext_t          *smAllShared,
250                        smSatIOContext_t        *satIOContext
251                        );
252
253osGLOBAL smSatIOContext_t *
254smsatPrepareNewIO(
255                  smSatInternalIo_t       *satNewIntIo,
256                  smIORequest_t           *smOrgIORequest,
257                  smDeviceData_t          *satDevData,
258                  smIniScsiCmnd_t         *scsiCmnd,
259                  smSatIOContext_t        *satOrgIOContext
260                 );
261
262osGLOBAL void
263smsatSetDevInfo(
264                 smDeviceData_t            *oneDeviceData,
265                 agsaSATAIdentifyData_t    *SATAIdData
266               );
267
268osGLOBAL void
269smsatInquiryStandard(
270                     bit8                    *pInquiry,
271                     agsaSATAIdentifyData_t  *pSATAIdData,
272                     smIniScsiCmnd_t         *scsiCmnd
273                    );
274
275osGLOBAL void
276smsatInquiryPage0(
277                   bit8                    *pInquiry,
278                   agsaSATAIdentifyData_t  *pSATAIdData
279		 );
280
281osGLOBAL void
282smsatInquiryPage83(
283                    bit8                    *pInquiry,
284                    agsaSATAIdentifyData_t  *pSATAIdData,
285                    smDeviceData_t          *oneDeviceData
286		  );
287
288
289osGLOBAL void
290smsatInquiryPage89(
291                    bit8                    *pInquiry,
292                    agsaSATAIdentifyData_t  *pSATAIdData,
293                    smDeviceData_t          *oneDeviceData,
294                    bit32                   len
295		  );
296
297osGLOBAL void
298smsatInquiryPage80(
299                    bit8                    *pInquiry,
300                    agsaSATAIdentifyData_t  *pSATAIdData
301		   );
302
303osGLOBAL void
304smsatInquiryPageB1(
305                    bit8                    *pInquiry,
306                    agsaSATAIdentifyData_t  *pSATAIdData
307		   );
308
309osGLOBAL void
310smsatDefaultTranslation(
311                        smRoot_t                  *smRoot,
312                        smIORequest_t             *smIORequest,
313                        smSatIOContext_t            *satIOContext,
314                        smScsiRspSense_t          *pSense,
315                        bit8                      ataStatus,
316                        bit8                      ataError,
317                        bit32                     interruptContext
318                       );
319
320osGLOBAL bit32
321smPhyControlSend(
322                  smRoot_t             *smRoot,
323                  smDeviceData_t       *oneDeviceData,
324                  bit8                 phyOp,
325                  smIORequest_t        *CurrentTaskTag,
326                  bit32                queueNumber
327                );
328
329osGLOBAL bit32
330smsatTaskManagement(
331                    smRoot_t          *smRoot,
332                    smDeviceHandle_t  *smDeviceHandle,
333                    bit32             task,
334                    smLUN_t           *lun,
335                    smIORequest_t     *taskTag,
336                    smIORequest_t     *currentTaskTag,
337                    smIORequestBody_t *smIORequestBody
338		   );
339
340osGLOBAL bit32
341smsatTmAbortTask(
342                  smRoot_t                  *smRoot,
343                  smIORequest_t             *currentTaskTag,
344                  smDeviceHandle_t          *smDeviceHandle,
345                  smScsiInitiatorRequest_t  *tiScsiRequest,
346                  smSatIOContext_t            *satIOContext,
347                  smIORequest_t             *taskTag);
348
349osGLOBAL bit32
350smsatStartCheckPowerMode(
351                         smRoot_t                  *smRoot,
352                         smIORequest_t             *currentTaskTag,
353                         smDeviceHandle_t          *smDeviceHandle,
354                         smScsiInitiatorRequest_t  *smScsiRequest,
355                         smSatIOContext_t            *satIOContext
356                        );
357osGLOBAL bit32
358smsatStartResetDevice(
359                       smRoot_t                  *smRoot,
360                       smIORequest_t             *currentTaskTag,
361                       smDeviceHandle_t          *smDeviceHandle,
362                       smScsiInitiatorRequest_t  *smScsiRequest,
363                       smSatIOContext_t            *satIOContext
364                     );
365osGLOBAL void
366smsatAbort(
367           smRoot_t          *smRoot,
368           agsaRoot_t        *agRoot,
369           smSatIOContext_t    *satIOContext
370	  );
371
372osGLOBAL smIORequestBody_t *
373smDequeueIO(smRoot_t          *smRoot);
374
375osGLOBAL bit32
376smsatDecodeSATADeviceType(bit8 * pSignature);
377
378/******************************** beginning of start ******************************************************/
379
380/*! \brief SAT implementation for ATAPI Packet Command.
381 *
382 *  SAT implementation for ATAPI Packet and send FIS request to LL layer.
383 *
384 *  \param   smRoot:           Pointer to TISA initiator driver/port instance.
385 *  \param   smIORequest:      Pointer to TISA I/O request context for this I/O.
386 *  \param   smDeviceHandle:   Pointer to TISA device handle for this I/O.
387 *  \param   smScsiRequest:    Pointer to TISA SCSI I/O request and SGL list.
388 *  \param   smSatIOContext_t:   Pointer to the SAT IO Context
389 *
390 *  \return If command is started successfully
391 *    - \e smIOSuccess: 	  I/O request successfully initiated.
392 *    - \e smIOBusy:        No resources available, try again later.
393 *    - \e smIOIONoDevice:  Invalid device handle.
394 *    - \e smIOError:       Other errors.
395 */
396/*****************************************************************************/
397osGLOBAL bit32
398smsatPacket(
399            smRoot_t                  *smRoot,
400            smIORequest_t             *smIORequest,
401            smDeviceHandle_t          *smDeviceHandle,
402            smScsiInitiatorRequest_t  *smScsiRequest,
403            smSatIOContext_t            *satIOContext
404            );
405
406osGLOBAL void
407smsatPacketCB(
408            agsaRoot_t        *agRoot,
409            agsaIORequest_t   *agIORequest,
410            bit32             agIOStatus,
411            agsaFisHeader_t   *agFirstDword,
412            bit32             agIOInfoLen,
413            void              *agParam,
414            void              *ioContext
415            );
416/*****************************************************************************/
417/*! \brief SAT implementation for smsatExecuteDeviceDiagnostic.
418 *
419 *  This function creates Execute Device Diagnostic fis and sends the request to LL layer
420 *
421 *  \param   smRoot:           Pointer to TISA initiator driver/port instance.
422 *  \param   smIORequest:      Pointer to TISA I/O request context for this I/O.
423 *  \param   smDeviceHandle:   Pointer to TISA device handle for this I/O.
424 *  \param   smScsiRequest:    Pointer to TISA SCSI I/O request and SGL list.
425 *  \param   smSatIOContext_t:   Pointer to the SAT IO Context
426 *
427 *  \return If command is started successfully
428 *    - \e smIOSuccess: 	  I/O request successfully initiated.
429 *    - \e smIOBusy:        No resources available, try again later.
430 *    - \e smIOIONoDevice:  Invalid device handle.
431 *    - \e smIOError:       Other errors.
432
433 */
434/*****************************************************************************/
435osGLOBAL bit32
436smsatExecuteDeviceDiagnostic(
437       smRoot_t                  *smRoot,
438       smIORequest_t             *smIORequest,
439       smDeviceHandle_t          *smDeviceHandle,
440       smScsiInitiatorRequest_t  *smScsiRequest,
441       smSatIOContext_t            *satIOContext
442       );
443
444osGLOBAL void
445smsatExecuteDeviceDiagnosticCB(
446       agsaRoot_t        *agRoot,
447       agsaIORequest_t   *agIORequest,
448       bit32             agIOStatus,
449       agsaFisHeader_t   *agFirstDword,
450       bit32             agIOInfoLen,
451       void              *agParam,
452       void              *ioContext
453       );
454/* set feature for auto activate */
455osGLOBAL bit32
456smsatSetFeaturesAA(
457           smRoot_t                  *smRoot,
458           smIORequest_t             *smIORequest,
459           smDeviceHandle_t          *smDeviceHandle,
460           smScsiInitiatorRequest_t  *smScsiRequest,
461           smSatIOContext_t            *satIOContext
462           );
463osGLOBAL void
464smsatSetFeaturesAACB(
465         agsaRoot_t        *agRoot,
466         agsaIORequest_t   *agIORequest,
467         bit32             agIOStatus,
468         agsaFisHeader_t   *agFirstDword,
469         bit32             agIOInfoLen,
470         void              *agParam,
471         void              *ioContext
472         );
473
474/*****************************************************************************/
475/*! \brief SAT implementation for satSetFeatures.
476 *
477 *  This function creates SetFeatures fis and sends the request to LL layer
478 *
479 *  \param   smRoot:           Pointer to TISA initiator driver/port instance.
480 *  \param   smIORequest:      Pointer to TISA I/O request context for this I/O.
481 *  \param   smDeviceHandle:   Pointer to TISA device handle for this I/O.
482 *  \param   smScsiRequest:    Pointer to TISA SCSI I/O request and SGL list.
483 *  \param   smSatIOContext_t:   Pointer to the SAT IO Context
484 *
485 *  \return If command is started successfully
486 *    - \e smIOSuccess: 	  I/O request successfully initiated.
487 *    - \e smIOBusy:        No resources available, try again later.
488 *    - \e smIOIONoDevice:  Invalid device handle.
489 *    - \e smIOError:       Other errors.
490 */
491/*****************************************************************************/
492osGLOBAL bit32
493smsatSetFeaturesPIO(
494           smRoot_t                  *smRoot,
495           smIORequest_t             *smIORequest,
496           smDeviceHandle_t          *smDeviceHandle,
497           smScsiInitiatorRequest_t  *smScsiRequest,
498           smSatIOContext_t          *satIOContext
499           );
500osGLOBAL void
501smsatSetFeaturesPIOCB(
502          agsaRoot_t        *agRoot,
503          agsaIORequest_t   *agIORequest,
504          bit32             agIOStatus,
505          agsaFisHeader_t   *agFirstDword,
506          bit32             agIOInfoLen,
507          void              *agParam,
508          void              *ioContext
509          );
510
511osGLOBAL bit32
512smsatSetFeaturesDMA(
513           smRoot_t                  *smRoot,
514           smIORequest_t             *smIORequest,
515           smDeviceHandle_t          *smDeviceHandle,
516           smScsiInitiatorRequest_t  *smScsiRequest,
517           smSatIOContext_t            *satIOContext
518           );
519
520osGLOBAL void
521smsatSetFeaturesDMACB(
522         agsaRoot_t        *agRoot,
523         agsaIORequest_t   *agIORequest,
524         bit32             agIOStatus,
525         agsaFisHeader_t   *agFirstDword,
526         bit32             agIOInfoLen,
527         void              *agParam,
528         void              *ioContext
529         );
530
531osGLOBAL bit32
532smsatSetFeaturesReadLookAhead(
533           smRoot_t                  *smRoot,
534           smIORequest_t             *smIORequest,
535           smDeviceHandle_t          *smDeviceHandle,
536           smScsiInitiatorRequest_t  *smScsiRequest,
537           smSatIOContext_t            *satIOContext
538           );
539
540osGLOBAL void
541smsatSetFeaturesReadLookAheadCB(
542         agsaRoot_t        *agRoot,
543         agsaIORequest_t   *agIORequest,
544         bit32             agIOStatus,
545         agsaFisHeader_t   *agFirstDword,
546         bit32             agIOInfoLen,
547         void              *agParam,
548         void              *ioContext
549         );
550
551osGLOBAL bit32
552smsatSetFeaturesVolatileWriteCache(
553           smRoot_t                  *smRoot,
554           smIORequest_t             *smIORequest,
555           smDeviceHandle_t          *smDeviceHandle,
556           smScsiInitiatorRequest_t  *smScsiRequest,
557           smSatIOContext_t            *satIOContext
558           );
559
560osGLOBAL void
561smsatSetFeaturesVolatileWriteCacheCB(
562         agsaRoot_t        *agRoot,
563         agsaIORequest_t   *agIORequest,
564         bit32             agIOStatus,
565         agsaFisHeader_t   *agFirstDword,
566         bit32             agIOInfoLen,
567         void              *agParam,
568         void              *ioContext
569         );
570
571osGLOBAL void
572smsatSMARTEnablePassCB(
573                     agsaRoot_t        *agRoot,
574                     agsaIORequest_t   *agIORequest,
575                     bit32             agIOStatus,
576                     agsaFisHeader_t   *agFirstDword,
577                     bit32             agIOInfoLen,
578                     agsaFrameHandle_t agFrameHandle,
579                     void              *ioContext
580                    );
581
582osGLOBAL void
583smsatSMARTRStatusPassCB(
584                agsaRoot_t        *agRoot,
585                agsaIORequest_t   *agIORequest,
586                bit32             agIOStatus,
587                agsaFisHeader_t   *agFirstDword,
588                bit32             agIOInfoLen,
589                void              *agParam,
590                void              *ioContext
591               );
592osGLOBAL void
593smsatSMARTReadLogCB(
594                agsaRoot_t        *agRoot,
595                agsaIORequest_t   *agIORequest,
596                bit32             agIOStatus,
597                agsaFisHeader_t   *agFirstDword,
598                bit32             agIOInfoLen,
599                void              *agParam,
600                void              *ioContext
601               );
602
603
604/*****************************************************************************/
605/*! \brief SAT implementation for SCSI REQUEST SENSE to ATAPI device.
606 *
607 *  SAT implementation for SCSI REQUEST SENSE.
608 *
609 *  \param   smRoot:           Pointer to TISA initiator driver/port instance.
610 *  \param   smIORequest:      Pointer to TISA I/O request context for this I/O.
611 *  \param   smDeviceHandle:   Pointer to TISA device handle for this I/O.
612 *  \param   smScsiRequest:    Pointer to TISA SCSI I/O request and SGL list.
613 *  \param   smSatIOContext_t:   Pointer to the SAT IO Context
614 *
615 *  \return If command is started successfully
616 *    - \e smIOSuccess: 	  I/O request successfully initiated.
617 *    - \e smIOBusy:        No resources available, try again later.
618 *    - \e smIOIONoDevice:  Invalid device handle.
619 *    - \e smIOError:       Other errors.
620 */
621/*****************************************************************************/
622osGLOBAL bit32
623smsatRequestSenseForATAPI(
624        smRoot_t                  *smRoot,
625        smIORequest_t             *smIORequest,
626        smDeviceHandle_t          *smDeviceHandle,
627        smScsiInitiatorRequest_t  *smScsiRequest,
628        smSatIOContext_t            *satIOContext
629        );
630
631osGLOBAL void
632smsatRequestSenseForATAPICB(
633        agsaRoot_t        *agRoot,
634        agsaIORequest_t   *agIORequest,
635        bit32             agIOStatus,
636        agsaFisHeader_t   *agFirstDword,
637        bit32             agIOInfoLen,
638        void              *agParam,
639        void              *ioContext
640        );
641
642/*****************************************************************************/
643/*! \brief SAT implementation for smsatDeviceReset.
644 *
645 *  This function creates DEVICE RESET fis and sends the request to LL layer
646 *
647 *  \param   smRoot:           Pointer to TISA initiator driver/port instance.
648 *  \param   smIORequest:      Pointer to TISA I/O request context for this I/O.
649 *  \param   smDeviceHandle:   Pointer to TISA device handle for this I/O.
650 *  \param   smScsiRequest:    Pointer to TISA SCSI I/O request and SGL list.
651 *  \param   smSatIOContext_t:   Pointer to the SAT IO Context
652 *
653 *  \return If command is started successfully
654 *    - \e smIOSuccess: 	  I/O request successfully initiated.
655 *    - \e smIOBusy:        No resources available, try again later.
656 *    - \e smIONoDevice:  Invalid device handle.
657 *    - \e smIOError:       Other errors.
658 */
659/*****************************************************************************/
660osGLOBAL bit32
661smsatDeviceReset(
662        smRoot_t                  *smRoot,
663        smIORequest_t             *smIORequest,
664        smDeviceHandle_t          *smDeviceHandle,
665        smScsiInitiatorRequest_t  *smScsiRequest,
666        smSatIOContext_t            *satIOContext
667        );
668
669osGLOBAL void
670smsatDeviceResetCB(
671         agsaRoot_t        *agRoot,
672         agsaIORequest_t   *agIORequest,
673         bit32             agIOStatus,
674         agsaFisHeader_t   *agFirstDword,
675         bit32             agIOInfoLen,
676         void              *agParam,
677         void              *ioContext
678         );
679
680
681osGLOBAL void
682smsatTranslateATAPIErrorsToSCSIErrors(
683        bit8   bCommand,
684        bit8   bATAStatus,
685        bit8   bATAError,
686        bit8   *pSenseKey,
687        bit16  *pSenseCodeInfo
688        );
689
690GLOBAL void
691smsatTranslateATAErrorsToSCSIErrors(
692    bit8   bATAStatus,
693    bit8   bATAError,
694    bit8   *pSenseKey,
695    bit16  *pSenseCodeInfo
696    );
697
698/*****************************************************************************/
699
700osGLOBAL bit32
701smsatRead6(
702           smRoot_t                  *smRoot,
703           smIORequest_t             *smIORequest,
704           smDeviceHandle_t          *smDeviceHandle,
705           smScsiInitiatorRequest_t  *smScsiRequest,
706           smSatIOContext_t            *satIOContext
707	  );
708
709osGLOBAL FORCEINLINE bit32
710smsatRead10(
711            smRoot_t                  *smRoot,
712            smIORequest_t             *smIORequest,
713            smDeviceHandle_t          *smDeviceHandle,
714            smScsiInitiatorRequest_t  *smScsiRequest,
715            smSatIOContext_t            *satIOContext
716	   );
717
718osGLOBAL bit32
719smsatRead12(
720            smRoot_t                  *smRoot,
721            smIORequest_t             *smIORequest,
722            smDeviceHandle_t          *smDeviceHandle,
723            smScsiInitiatorRequest_t  *smScsiRequest,
724            smSatIOContext_t            *satIOContext
725	   );
726
727osGLOBAL bit32
728smsatRead16(
729            smRoot_t                  *smRoot,
730            smIORequest_t             *smIORequest,
731            smDeviceHandle_t          *smDeviceHandle,
732            smScsiInitiatorRequest_t  *smScsiRequest,
733            smSatIOContext_t            *satIOContext
734	   );
735
736osGLOBAL bit32
737smsatWrite6(
738            smRoot_t                  *smRoot,
739            smIORequest_t             *smIORequest,
740            smDeviceHandle_t          *smDeviceHandle,
741            smScsiInitiatorRequest_t  *smScsiRequest,
742            smSatIOContext_t            *satIOContext
743	   );
744
745osGLOBAL FORCEINLINE bit32
746smsatWrite10(
747             smRoot_t                  *smRoot,
748             smIORequest_t             *smIORequest,
749             smDeviceHandle_t          *smDeviceHandle,
750             smScsiInitiatorRequest_t  *smScsiRequest,
751             smSatIOContext_t            *satIOContext
752            );
753
754osGLOBAL bit32
755smsatWrite12(
756             smRoot_t                  *smRoot,
757             smIORequest_t             *smIORequest,
758             smDeviceHandle_t          *smDeviceHandle,
759             smScsiInitiatorRequest_t  *smScsiRequest,
760             smSatIOContext_t            *satIOContext
761            );
762
763osGLOBAL bit32
764smsatWrite16(
765             smRoot_t                  *smRoot,
766             smIORequest_t             *smIORequest,
767             smDeviceHandle_t          *smDeviceHandle,
768             smScsiInitiatorRequest_t  *smScsiRequest,
769             smSatIOContext_t            *satIOContext
770            );
771
772osGLOBAL bit32
773smsatVerify10(
774              smRoot_t                  *smRoot,
775              smIORequest_t             *smIORequest,
776              smDeviceHandle_t          *smDeviceHandle,
777              smScsiInitiatorRequest_t  *smScsiRequest,
778              smSatIOContext_t            *satIOContext
779             );
780
781osGLOBAL bit32
782smsatVerify12(
783              smRoot_t                  *smRoot,
784              smIORequest_t             *smIORequest,
785              smDeviceHandle_t          *smDeviceHandle,
786              smScsiInitiatorRequest_t  *smScsiRequest,
787              smSatIOContext_t            *satIOContext
788             );
789
790osGLOBAL bit32
791smsatVerify16(
792              smRoot_t                  *smRoot,
793              smIORequest_t             *smIORequest,
794              smDeviceHandle_t          *smDeviceHandle,
795              smScsiInitiatorRequest_t  *smScsiRequest,
796              smSatIOContext_t            *satIOContext
797             );
798
799osGLOBAL bit32
800smsatTestUnitReady(
801                   smRoot_t                  *smRoot,
802                   smIORequest_t             *smIORequest,
803                   smDeviceHandle_t          *smDeviceHandle,
804                   smScsiInitiatorRequest_t  *smScsiRequest,
805                   smSatIOContext_t            *satIOContext
806                  );
807
808osGLOBAL bit32
809smsatInquiry(
810             smRoot_t                  *smRoot,
811             smIORequest_t             *smIORequest,
812             smDeviceHandle_t          *smDeviceHandle,
813             smScsiInitiatorRequest_t  *smScsiRequest,
814             smSatIOContext_t            *satIOContext
815            );
816
817osGLOBAL bit32
818smsatRequestSense(
819                  smRoot_t                  *smRoot,
820                  smIORequest_t             *smIORequest,
821                  smDeviceHandle_t          *smDeviceHandle,
822                  smScsiInitiatorRequest_t  *smScsiRequest,
823                  smSatIOContext_t            *satIOContext
824                 );
825
826osGLOBAL bit32
827smsatModeSense6(
828                smRoot_t                  *smRoot,
829                smIORequest_t             *smIORequest,
830                smDeviceHandle_t          *smDeviceHandle,
831                smScsiInitiatorRequest_t  *smScsiRequest,
832                smSatIOContext_t            *satIOContext
833               );
834
835osGLOBAL bit32
836smsatModeSense10(
837                  smRoot_t                  *smRoot,
838                  smIORequest_t             *smIORequest,
839                  smDeviceHandle_t          *smDeviceHandle,
840                  smScsiInitiatorRequest_t  *smScsiRequest,
841                  smSatIOContext_t            *satIOContext
842                 );
843
844osGLOBAL bit32
845smsatReadCapacity10(
846                    smRoot_t                  *smRoot,
847                    smIORequest_t             *smIORequest,
848                    smDeviceHandle_t          *smDeviceHandle,
849                    smScsiInitiatorRequest_t  *smScsiRequest,
850                    smSatIOContext_t            *satIOContext
851                   );
852
853osGLOBAL bit32
854smsatReadCapacity16(
855                    smRoot_t                  *smRoot,
856                    smIORequest_t             *smIORequest,
857                    smDeviceHandle_t          *smDeviceHandle,
858                    smScsiInitiatorRequest_t  *smScsiRequest,
859                    smSatIOContext_t            *satIOContext
860                   );
861
862osGLOBAL bit32
863smsatReportLun(
864               smRoot_t                  *smRoot,
865               smIORequest_t             *smIORequest,
866               smDeviceHandle_t          *smDeviceHandle,
867               smScsiInitiatorRequest_t  *smScsiRequest,
868               smSatIOContext_t            *satIOContext
869              );
870
871osGLOBAL bit32
872smsatFormatUnit(
873                smRoot_t                  *smRoot,
874                smIORequest_t             *smIORequest,
875                smDeviceHandle_t          *smDeviceHandle,
876                smScsiInitiatorRequest_t  *smScsiRequest,
877                smSatIOContext_t            *satIOContext
878               );
879
880osGLOBAL bit32
881smsatSendDiagnostic(
882                    smRoot_t                  *smRoot,
883                    smIORequest_t             *smIORequest,
884                    smDeviceHandle_t          *smDeviceHandle,
885                    smScsiInitiatorRequest_t  *smScsiRequest,
886                    smSatIOContext_t            *satIOContext
887                   );
888
889osGLOBAL bit32
890smsatStartStopUnit(
891                   smRoot_t                  *smRoot,
892                   smIORequest_t             *smIORequest,
893                   smDeviceHandle_t          *smDeviceHandle,
894                   smScsiInitiatorRequest_t  *smScsiRequest,
895                   smSatIOContext_t            *satIOContext
896                  );
897
898osGLOBAL bit32
899smsatWriteSame10(
900                  smRoot_t                  *smRoot,
901                  smIORequest_t             *smIORequest,
902                  smDeviceHandle_t          *smDeviceHandle,
903                  smScsiInitiatorRequest_t  *smScsiRequest,
904                  smSatIOContext_t            *satIOContext
905                 );
906
907osGLOBAL bit32
908smsatWriteSame16(
909                  smRoot_t                  *smRoot,
910                  smIORequest_t             *smIORequest,
911                  smDeviceHandle_t          *smDeviceHandle,
912                  smScsiInitiatorRequest_t  *smScsiRequest,
913                  smSatIOContext_t            *satIOContext
914                 );
915
916osGLOBAL bit32
917smsatLogSense(
918              smRoot_t                  *smRoot,
919              smIORequest_t             *smIORequest,
920              smDeviceHandle_t          *smDeviceHandle,
921              smScsiInitiatorRequest_t  *smScsiRequest,
922              smSatIOContext_t            *satIOContext
923             );
924
925osGLOBAL bit32
926smsatModeSelect6(
927                 smRoot_t                  *smRoot,
928                 smIORequest_t             *smIORequest,
929                 smDeviceHandle_t          *smDeviceHandle,
930                 smScsiInitiatorRequest_t  *smScsiRequest,
931                 smSatIOContext_t            *satIOContext
932                );
933
934
935osGLOBAL bit32
936smsatModeSelect10(
937                  smRoot_t                  *smRoot,
938                  smIORequest_t             *smIORequest,
939                  smDeviceHandle_t          *smDeviceHandle,
940                  smScsiInitiatorRequest_t  *smScsiRequest,
941                  smSatIOContext_t            *satIOContext
942                 );
943
944osGLOBAL bit32
945smsatSynchronizeCache10(
946                        smRoot_t                  *smRoot,
947                        smIORequest_t             *smIORequest,
948                        smDeviceHandle_t          *smDeviceHandle,
949                        smScsiInitiatorRequest_t  *smScsiRequest,
950                        smSatIOContext_t            *satIOContext
951                       );
952
953osGLOBAL bit32
954smsatSynchronizeCache16(
955                        smRoot_t                  *smRoot,
956                        smIORequest_t             *smIORequest,
957                        smDeviceHandle_t          *smDeviceHandle,
958                        smScsiInitiatorRequest_t  *smScsiRequest,
959                        smSatIOContext_t            *satIOContext
960                       );
961
962osGLOBAL bit32
963smsatWriteAndVerify10(
964                      smRoot_t                  *smRoot,
965                      smIORequest_t             *smIORequest,
966                      smDeviceHandle_t          *smDeviceHandle,
967                      smScsiInitiatorRequest_t  *smScsiRequest,
968                      smSatIOContext_t            *satIOContext
969                     );
970
971osGLOBAL bit32
972smsatWriteAndVerify12(
973                      smRoot_t                  *smRoot,
974                      smIORequest_t             *smIORequest,
975                      smDeviceHandle_t          *smDeviceHandle,
976                      smScsiInitiatorRequest_t  *smScsiRequest,
977                      smSatIOContext_t            *satIOContext
978                     );
979
980osGLOBAL bit32
981smsatWriteAndVerify16(
982                      smRoot_t                  *smRoot,
983                      smIORequest_t             *smIORequest,
984                      smDeviceHandle_t          *smDeviceHandle,
985                      smScsiInitiatorRequest_t  *smScsiRequest,
986                      smSatIOContext_t            *satIOContext
987                     );
988
989osGLOBAL bit32
990smsatReadMediaSerialNumber(
991                           smRoot_t                  *smRoot,
992                           smIORequest_t             *smIORequest,
993                           smDeviceHandle_t          *smDeviceHandle,
994                           smScsiInitiatorRequest_t  *smScsiRequest,
995                           smSatIOContext_t            *satIOContext
996                          );
997
998osGLOBAL bit32
999smsatReadBuffer(
1000                smRoot_t                  *smRoot,
1001                smIORequest_t             *smIORequest,
1002                smDeviceHandle_t          *smDeviceHandle,
1003                smScsiInitiatorRequest_t  *smScsiRequest,
1004                smSatIOContext_t            *satIOContext
1005               );
1006
1007osGLOBAL bit32
1008smsatWriteBuffer(
1009                 smRoot_t                  *smRoot,
1010                 smIORequest_t             *smIORequest,
1011                 smDeviceHandle_t          *smDeviceHandle,
1012                 smScsiInitiatorRequest_t  *smScsiRequest,
1013                 smSatIOContext_t            *satIOContext
1014                );
1015
1016osGLOBAL bit32
1017smsatReassignBlocks(
1018                    smRoot_t                  *smRoot,
1019                    smIORequest_t             *smIORequest,
1020                    smDeviceHandle_t          *smDeviceHandle,
1021                    smScsiInitiatorRequest_t  *smScsiRequest,
1022                    smSatIOContext_t            *satIOContext
1023                   );
1024
1025osGLOBAL bit32
1026smsatPassthrough(
1027                    smRoot_t                  *smRoot,
1028                    smIORequest_t             *smIORequest,
1029                    smDeviceHandle_t          *smDeviceHandle,
1030                    smScsiInitiatorRequest_t  *smScsiRequest,
1031                    smSatIOContext_t            *satIOContext
1032                   );
1033
1034osGLOBAL FORCEINLINE bit32
1035smsataLLIOStart(
1036                smRoot_t                  *smRoot,
1037                smIORequest_t             *smIORequest,
1038                smDeviceHandle_t          *smDeviceHandle,
1039                smScsiInitiatorRequest_t  *smScsiRequest,
1040                smSatIOContext_t            *satIOContext
1041               );
1042osGLOBAL bit32
1043smsatTestUnitReady_1(
1044                     smRoot_t                  *smRoot,
1045                     smIORequest_t             *smIORequest,
1046                     smDeviceHandle_t          *smDeviceHandle,
1047                     smScsiInitiatorRequest_t  *smScsiRequest,
1048                     smSatIOContext_t            *satIOContext
1049                    );
1050osGLOBAL bit32
1051smsatStartIDDev(
1052                smRoot_t                  *smRoot,
1053                smIORequest_t             *smIORequest,
1054                smDeviceHandle_t          *smDeviceHandle,
1055                smScsiInitiatorRequest_t  *smScsiRequest,
1056                smSatIOContext_t            *satIOContext
1057               );
1058
1059osGLOBAL bit32
1060smsatSendIDDev(
1061                smRoot_t                  *smRoot,
1062                smIORequest_t             *smIORequest,
1063                smDeviceHandle_t          *smDeviceHandle,
1064                smScsiInitiatorRequest_t  *smScsiRequest,
1065                smSatIOContext_t            *satIOContext
1066               );
1067
1068osGLOBAL bit32
1069smsatRequestSense_1(
1070                    smRoot_t                  *smRoot,
1071                    smIORequest_t             *smIORequest,
1072                    smDeviceHandle_t          *smDeviceHandle,
1073                    smScsiInitiatorRequest_t  *smScsiRequest,
1074                    smSatIOContext_t            *satIOContext
1075                   );
1076
1077osGLOBAL bit32
1078smsatSMARTEnable(
1079                 smRoot_t                  *smRoot,
1080                 smIORequest_t             *smIORequest,
1081                 smDeviceHandle_t          *smDeviceHandle,
1082                 smScsiInitiatorRequest_t  *smScsiRequest,
1083                 smSatIOContext_t            *satIOContext
1084               );
1085
1086osGLOBAL bit32
1087smsatLogSense_2(
1088                smRoot_t                  *smRoot,
1089                smIORequest_t             *smIORequest,
1090                smDeviceHandle_t          *smDeviceHandle,
1091                smScsiInitiatorRequest_t  *smScsiRequest,
1092                smSatIOContext_t            *satIOContext
1093               );
1094
1095osGLOBAL bit32
1096smsatLogSense_3(
1097                smRoot_t                  *smRoot,
1098                smIORequest_t             *smIORequest,
1099                smDeviceHandle_t          *smDeviceHandle,
1100                smScsiInitiatorRequest_t  *smScsiRequest,
1101                smSatIOContext_t            *satIOContext
1102               );
1103
1104osGLOBAL bit32
1105smsatRead_1(
1106            smRoot_t                  *smRoot,
1107            smIORequest_t             *smIORequest,
1108            smDeviceHandle_t          *smDeviceHandle,
1109            smScsiInitiatorRequest_t  *smScsiRequest,
1110            smSatIOContext_t            *satIOContext
1111          );
1112
1113osGLOBAL bit32
1114smsatWrite_1(
1115             smRoot_t                  *smRoot,
1116             smIORequest_t             *smIORequest,
1117             smDeviceHandle_t          *smDeviceHandle,
1118             smScsiInitiatorRequest_t  *smScsiRequest,
1119             smSatIOContext_t            *satIOContext
1120           );
1121
1122osGLOBAL bit32
1123smsatNonChainedWriteNVerify_Verify(
1124                                   smRoot_t                  *smRoot,
1125                                   smIORequest_t             *smIORequest,
1126                                   smDeviceHandle_t          *smDeviceHandle,
1127                                   smScsiInitiatorRequest_t  *smScsiRequest,
1128                                   smSatIOContext_t            *satIOContext
1129                                  );
1130
1131osGLOBAL bit32
1132smsatChainedWriteNVerify_Start_Verify(
1133                                      smRoot_t                  *smRoot,
1134                                      smIORequest_t             *smIORequest,
1135                                      smDeviceHandle_t          *smDeviceHandle,
1136                                      smScsiInitiatorRequest_t  *smScsiRequest,
1137                                      smSatIOContext_t            *satIOContext
1138                                     );
1139
1140osGLOBAL bit32
1141smsatChainedWriteNVerify_Write(
1142                               smRoot_t                  *smRoot,
1143                               smIORequest_t             *smIORequest,
1144                               smDeviceHandle_t          *smDeviceHandle,
1145                               smScsiInitiatorRequest_t  *smScsiRequest,
1146                               smSatIOContext_t            *satIOContext
1147                              );
1148
1149osGLOBAL bit32
1150smsatChainedWriteNVerify_Verify(
1151                                smRoot_t                  *smRoot,
1152                                smIORequest_t             *smIORequest,
1153                                smDeviceHandle_t          *smDeviceHandle,
1154                                smScsiInitiatorRequest_t  *smScsiRequest,
1155                                smSatIOContext_t            *satIOContext
1156                               );
1157osGLOBAL bit32
1158smsatChainedVerify(
1159                    smRoot_t                  *smRoot,
1160                    smIORequest_t             *smIORequest,
1161                    smDeviceHandle_t          *smDeviceHandle,
1162                    smScsiInitiatorRequest_t  *smScsiRequest,
1163                    smSatIOContext_t            *satIOContext
1164		   );
1165
1166osGLOBAL bit32
1167smsatWriteSame10_1(
1168                    smRoot_t                  *smRoot,
1169                    smIORequest_t             *smIORequest,
1170                    smDeviceHandle_t          *smDeviceHandle,
1171                    smScsiInitiatorRequest_t  *smScsiRequest,
1172                    smSatIOContext_t            *satIOContext,
1173                    bit32                     lba
1174                  );
1175
1176osGLOBAL bit32
1177smsatWriteSame10_2(
1178                    smRoot_t                  *smRoot,
1179                    smIORequest_t             *smIORequest,
1180                    smDeviceHandle_t          *smDeviceHandle,
1181                    smScsiInitiatorRequest_t  *smScsiRequest,
1182                    smSatIOContext_t            *satIOContext,
1183                    bit32                     lba
1184                  );
1185
1186osGLOBAL bit32
1187smsatWriteSame10_3(
1188                    smRoot_t                  *smRoot,
1189                    smIORequest_t             *smIORequest,
1190                    smDeviceHandle_t          *smDeviceHandle,
1191                    smScsiInitiatorRequest_t  *smScsiRequest,
1192                    smSatIOContext_t            *satIOContext,
1193                    bit32                     lba
1194                  );
1195
1196osGLOBAL bit32
1197smsatStartStopUnit_1(
1198                     smRoot_t                  *smRoot,
1199                     smIORequest_t             *smIORequest,
1200                     smDeviceHandle_t          *smDeviceHandle,
1201                     smScsiInitiatorRequest_t  *smScsiRequest,
1202                     smSatIOContext_t            *satIOContext
1203		    );
1204
1205osGLOBAL bit32
1206smsatSendDiagnostic_1(
1207                      smRoot_t                  *smRoot,
1208                      smIORequest_t             *smIORequest,
1209                      smDeviceHandle_t          *smDeviceHandle,
1210                      smScsiInitiatorRequest_t  *smScsiRequest,
1211                      smSatIOContext_t            *satIOContext
1212		     );
1213
1214osGLOBAL bit32
1215smsatSendDiagnostic_2(
1216                      smRoot_t                  *smRoot,
1217                      smIORequest_t             *smIORequest,
1218                      smDeviceHandle_t          *smDeviceHandle,
1219                      smScsiInitiatorRequest_t  *smScsiRequest,
1220                      smSatIOContext_t            *satIOContext
1221		     );
1222
1223osGLOBAL bit32
1224smsatModeSelect6n10_1(
1225                      smRoot_t                  *smRoot,
1226                      smIORequest_t             *smIORequest,
1227                      smDeviceHandle_t          *smDeviceHandle,
1228                      smScsiInitiatorRequest_t  *smScsiRequest,
1229                      smSatIOContext_t            *satIOContext
1230		     );
1231
1232osGLOBAL bit32
1233smsatLogSense_1(
1234                smRoot_t                  *smRoot,
1235                smIORequest_t             *smIORequest,
1236                smDeviceHandle_t          *smDeviceHandle,
1237                smScsiInitiatorRequest_t  *smScsiRequest,
1238                smSatIOContext_t            *satIOContext
1239               );
1240
1241osGLOBAL bit32
1242smsatReassignBlocks_2(
1243                      smRoot_t                  *smRoot,
1244                      smIORequest_t             *smIORequest,
1245                      smDeviceHandle_t          *smDeviceHandle,
1246                      smScsiInitiatorRequest_t  *smScsiRequest,
1247                      smSatIOContext_t            *satIOContext,
1248                      bit8                      *LBA
1249                     );
1250
1251osGLOBAL bit32
1252smsatReassignBlocks_1(
1253                      smRoot_t                  *smRoot,
1254                      smIORequest_t             *smIORequest,
1255                      smDeviceHandle_t          *smDeviceHandle,
1256                      smScsiInitiatorRequest_t  *smScsiRequest,
1257                      smSatIOContext_t            *satIOContext,
1258                      smSatIOContext_t            *satOrgIOContext
1259                     );
1260
1261osGLOBAL bit32
1262smsatSendReadLogExt(
1263                     smRoot_t                  *smRoot,
1264                     smIORequest_t             *smIORequest,
1265                     smDeviceHandle_t          *smDeviceHandle,
1266                     smScsiInitiatorRequest_t  *smScsiRequest,
1267                     smSatIOContext_t            *satIOContext
1268		   );
1269
1270osGLOBAL bit32
1271smsatCheckPowerMode(
1272                     smRoot_t                  *smRoot,
1273                     smIORequest_t             *smIORequest,
1274                     smDeviceHandle_t          *smDeviceHandle,
1275                     smScsiInitiatorRequest_t  *smScsiRequest,
1276                     smSatIOContext_t            *satIOContext
1277		   );
1278
1279osGLOBAL bit32
1280smsatResetDevice(
1281                  smRoot_t                  *smRoot,
1282                  smIORequest_t             *smIORequest,
1283                  smDeviceHandle_t          *smDeviceHandle,
1284                  smScsiInitiatorRequest_t  *smScsiRequest,
1285                  smSatIOContext_t            *satIOContext
1286                );
1287
1288osGLOBAL bit32
1289smsatDeResetDevice(
1290                    smRoot_t                  *smRoot,
1291                    smIORequest_t             *smIORequest,
1292                    smDeviceHandle_t          *smDeviceHandle,
1293                    smScsiInitiatorRequest_t  *smScsiRequest,
1294                    smSatIOContext_t            *satIOContext
1295                   );
1296/******************************** beginning of completion ******************************************************/
1297osGLOBAL FORCEINLINE void
1298smllSATACompleted(
1299                  agsaRoot_t        *agRoot,
1300                  agsaIORequest_t   *agIORequest,
1301                  bit32             agIOStatus,
1302                  void              *agFirstDword,
1303                  bit32             agIOInfoLen,
1304                  void              *agParam
1305                 );
1306
1307
1308osGLOBAL FORCEINLINE void
1309smsatNonChainedDataIOCB(
1310                        agsaRoot_t        *agRoot,
1311                        agsaIORequest_t   *agIORequest,
1312                        bit32             agIOStatus,
1313                        agsaFisHeader_t   *agFirstDword,
1314                        bit32             agIOInfoLen,
1315                        void              *agParam,
1316                        void              *ioContext
1317                       );
1318
1319osGLOBAL FORCEINLINE void
1320smsatChainedDataIOCB(
1321                     agsaRoot_t        *agRoot,
1322                     agsaIORequest_t   *agIORequest,
1323                     bit32             agIOStatus,
1324                     agsaFisHeader_t   *agFirstDword,
1325                     bit32             agIOInfoLen,
1326                     void              *agParam,
1327                     void              *ioContext
1328                    );
1329
1330osGLOBAL void
1331smsatNonChainedVerifyCB(
1332                        agsaRoot_t        *agRoot,
1333                        agsaIORequest_t   *agIORequest,
1334                        bit32             agIOStatus,
1335                        agsaFisHeader_t   *agFirstDword,
1336                        bit32             agIOInfoLen,
1337                        agsaFrameHandle_t agFrameHandle,
1338                        void              *ioContext
1339                       );
1340
1341osGLOBAL void
1342smsatChainedVerifyCB(
1343                     agsaRoot_t        *agRoot,
1344                     agsaIORequest_t   *agIORequest,
1345                     bit32             agIOStatus,
1346                     agsaFisHeader_t   *agFirstDword,
1347                     bit32             agIOInfoLen,
1348                     agsaFrameHandle_t agFrameHandle,
1349                     void              *ioContext
1350                    );
1351
1352osGLOBAL void
1353smsatTestUnitReadyCB(
1354                     agsaRoot_t        *agRoot,
1355                     agsaIORequest_t   *agIORequest,
1356                     bit32             agIOStatus,
1357                     agsaFisHeader_t   *agFirstDword,
1358                     bit32             agIOInfoLen,
1359                     agsaFrameHandle_t agFrameHandle,
1360                     void              *ioContext
1361                    );
1362osGLOBAL void
1363smsatRequestSenseCB(
1364                    agsaRoot_t        *agRoot,
1365                    agsaIORequest_t   *agIORequest,
1366                    bit32             agIOStatus,
1367                    agsaFisHeader_t   *agFirstDword,
1368                    bit32             agIOInfoLen,
1369                    void              *agParam,
1370                    void              *ioContext
1371                   );
1372
1373osGLOBAL void
1374smsatSendDiagnosticCB(
1375                       agsaRoot_t        *agRoot,
1376                       agsaIORequest_t   *agIORequest,
1377                       bit32             agIOStatus,
1378                       agsaFisHeader_t   *agFirstDword,
1379                       bit32             agIOInfoLen,
1380                       agsaFrameHandle_t agFrameHandle,
1381                       void              *ioContext
1382                     );
1383
1384osGLOBAL void
1385smsatStartStopUnitCB(
1386                     agsaRoot_t        *agRoot,
1387                     agsaIORequest_t   *agIORequest,
1388                     bit32             agIOStatus,
1389                     agsaFisHeader_t   *agFirstDword,
1390                     bit32             agIOInfoLen,
1391                     agsaFrameHandle_t agFrameHandle,
1392                     void              *ioContext
1393                    );
1394
1395
1396osGLOBAL void
1397smsatWriteSame10CB(
1398                   agsaRoot_t        *agRoot,
1399                   agsaIORequest_t   *agIORequest,
1400                   bit32             agIOStatus,
1401                   agsaFisHeader_t   *agFirstDword,
1402                   bit32             agIOInfoLen,
1403                   agsaFrameHandle_t agFrameHandle,
1404                   void              *ioContext
1405                  );
1406
1407
1408osGLOBAL void
1409smsatLogSenseCB(
1410                agsaRoot_t        *agRoot,
1411                agsaIORequest_t   *agIORequest,
1412                bit32             agIOStatus,
1413                agsaFisHeader_t   *agFirstDword,
1414                bit32             agIOInfoLen,
1415                void              *agParam,
1416                void              *ioCotext
1417               );
1418
1419osGLOBAL void
1420smsatSMARTEnableCB(
1421                   agsaRoot_t        *agRoot,
1422                   agsaIORequest_t   *agIORequest,
1423                   bit32             agIOStatus,
1424                   agsaFisHeader_t   *agFirstDword,
1425                   bit32             agIOInfoLen,
1426                   agsaFrameHandle_t agFrameHandle,
1427                   void              *ioContext
1428                  );
1429
1430osGLOBAL void
1431smsatModeSelect6n10CB(
1432                      agsaRoot_t        *agRoot,
1433                      agsaIORequest_t   *agIORequest,
1434                      bit32             agIOStatus,
1435                      agsaFisHeader_t   *agFirstDword,
1436                      bit32             agIOInfoLen,
1437                      agsaFrameHandle_t agFrameHandle,
1438                      void              *ioContext
1439                     );
1440
1441osGLOBAL void
1442smsatSynchronizeCache10n16CB(
1443                             agsaRoot_t        *agRoot,
1444                             agsaIORequest_t   *agIORequest,
1445                             bit32             agIOStatus,
1446                             agsaFisHeader_t   *agFirstDword,
1447                             bit32             agIOInfoLen,
1448                             agsaFrameHandle_t agFrameHandle,
1449                             void              *ioContext
1450                            );
1451
1452osGLOBAL void
1453smsatNonChainedWriteNVerifyCB(
1454                              agsaRoot_t        *agRoot,
1455                              agsaIORequest_t   *agIORequest,
1456                              bit32             agIOStatus,
1457                              agsaFisHeader_t   *agFirstDword,
1458                              bit32             agIOInfoLen,
1459                              void              *agParam,
1460                              void              *ioContext
1461                             );
1462
1463osGLOBAL void
1464smsatChainedWriteNVerifyCB(
1465                           agsaRoot_t        *agRoot,
1466                           agsaIORequest_t   *agIORequest,
1467                           bit32             agIOStatus,
1468                           agsaFisHeader_t   *agFirstDword,
1469                           bit32             agIOInfoLen,
1470                           void              *agParam,
1471                           void              *ioContext
1472                          );
1473
1474osGLOBAL void
1475smsatReadMediaSerialNumberCB(
1476                             agsaRoot_t        *agRoot,
1477                             agsaIORequest_t   *agIORequest,
1478                             bit32             agIOStatus,
1479                             agsaFisHeader_t   *agFirstDword,
1480                             bit32             agIOInfoLen,
1481                             agsaFrameHandle_t agFrameHandle,
1482                             void              *ioContext
1483                            );
1484
1485osGLOBAL void
1486smsatReadBufferCB(
1487                  agsaRoot_t        *agRoot,
1488                  agsaIORequest_t   *agIORequest,
1489                  bit32             agIOStatus,
1490                  agsaFisHeader_t   *agFirstDword,
1491                  bit32             agIOInfoLen,
1492                  agsaFrameHandle_t agFrameHandle,
1493                  void              *ioContext
1494                 );
1495
1496osGLOBAL void
1497smsatWriteBufferCB(
1498                   agsaRoot_t        *agRoot,
1499                   agsaIORequest_t   *agIORequest,
1500                   bit32             agIOStatus,
1501                   agsaFisHeader_t   *agFirstDword,
1502                   bit32             agIOInfoLen,
1503                   agsaFrameHandle_t agFrameHandle,
1504                   void              *ioContext
1505                  );
1506
1507osGLOBAL void
1508smsatReassignBlocksCB(
1509                      agsaRoot_t        *agRoot,
1510                      agsaIORequest_t   *agIORequest,
1511                      bit32             agIOStatus,
1512                      agsaFisHeader_t   *agFirstDword,
1513                      bit32             agIOInfoLen,
1514                      agsaFrameHandle_t agFrameHandle,
1515                      void              *ioContext
1516                     );
1517
1518osGLOBAL void
1519smsatProcessAbnormalCompletion(
1520                               agsaRoot_t        *agRoot,
1521                               agsaIORequest_t   *agIORequest,
1522                               bit32             agIOStatus,
1523                               agsaFisHeader_t   *agFirstDword,
1524                               bit32             agIOInfoLen,
1525                               void              *agParam,
1526                               smSatIOContext_t    *satIOContext
1527                              );
1528
1529osGLOBAL void
1530smsatDelayedProcessAbnormalCompletion(
1531                                      agsaRoot_t        *agRoot,
1532                                      agsaIORequest_t   *agIORequest,
1533                                      bit32             agIOStatus,
1534                                      agsaFisHeader_t   *agFirstDword,
1535                                      bit32             agIOInfoLen,
1536                                      void              *agParam,
1537                                      smSatIOContext_t    *satIOContext
1538                                     );
1539
1540osGLOBAL void
1541smsatIOCompleted(
1542                 smRoot_t           *smRoot,
1543                 smIORequest_t      *smIORequest,
1544                 agsaFisHeader_t    *agFirstDword,
1545                 bit32              respFisLen,
1546                 agsaFrameHandle_t  agFrameHandle,
1547                 smSatIOContext_t     *satIOContext,
1548                 bit32              interruptContext
1549		);
1550
1551osGLOBAL void
1552smsatEncryptionHandler(
1553                       smRoot_t                *smRoot,
1554                       agsaIORequest_t         *agIORequest,
1555                       bit32                   agIOStatus,
1556                       bit32                   agIOInfoLen,
1557                       void                    *agParam,
1558                       bit32                   agOtherInfo,
1559                       bit32                   interruptContext
1560                      );
1561
1562osGLOBAL void
1563smsatDifHandler(
1564                smRoot_t                *smRoot,
1565                agsaIORequest_t         *agIORequest,
1566                bit32                   agIOStatus,
1567                bit32                   agIOInfoLen,
1568                void                    *agParam,
1569                bit32                   agOtherInfo,
1570                bit32                   interruptContext
1571               );
1572
1573osGLOBAL void
1574smsatProcessAbort(
1575                  smRoot_t           *smRoot,
1576                  smIORequest_t      *smIORequest,
1577                  smSatIOContext_t     *satIOContext
1578                 );
1579
1580osGLOBAL void
1581smsatNonDataIOCB(
1582                  agsaRoot_t        *agRoot,
1583                  agsaIORequest_t   *agIORequest,
1584                  bit32             agIOStatus,
1585                  agsaFisHeader_t   *agFirstDword,
1586                  bit32             agIOInfoLen,
1587                  void              *agParam,
1588                  void              *ioContext
1589                 );
1590
1591osGLOBAL void
1592smsatInquiryCB(
1593               agsaRoot_t        *agRoot,
1594               agsaIORequest_t   *agIORequest,
1595               bit32             agIOStatus,
1596               agsaFisHeader_t   *agFirstDword,
1597               bit32             agIOInfoLen,
1598               void              *agParam,
1599               void              *ioContext
1600              );
1601
1602
1603osGLOBAL void
1604smsatInquiryIntCB(
1605                   smRoot_t                  *smRoot,
1606                   smIORequest_t             *smIORequest,
1607                   smDeviceHandle_t          *smDeviceHandle,
1608                   smScsiInitiatorRequest_t  *smScsiRequest,
1609                   smSatIOContext_t            *satIOContext
1610                  );
1611
1612osGLOBAL void
1613smsatVerify10CB(
1614                agsaRoot_t        *agRoot,
1615                agsaIORequest_t   *agIORequest,
1616                bit32             agIOStatus,
1617                agsaFisHeader_t   *agFirstDword,
1618                bit32             agIOInfoLen,
1619                void              *agParam,
1620                void              *ioContext
1621               );
1622
1623osGLOBAL void
1624smsatReadLogExtCB(
1625                   agsaRoot_t        *agRoot,
1626                   agsaIORequest_t   *agIORequest,
1627                   bit32             agIOStatus,
1628                   agsaFisHeader_t   *agFirstDword,
1629                   bit32             agIOInfoLen,
1630                   void              *agParam,
1631                   void              *ioContext
1632                 );
1633
1634
1635osGLOBAL void
1636smsatIDStartCB(
1637                agsaRoot_t        *agRoot,
1638                agsaIORequest_t   *agIORequest,
1639                bit32             agIOStatus,
1640                agsaFisHeader_t   *agFirstDword,
1641                bit32             agIOInfoLen,
1642                void              *agParam,
1643                void              *ioContext
1644               );
1645
1646osGLOBAL void
1647smSMPCompleted(
1648                agsaRoot_t            *agRoot,
1649                agsaIORequest_t       *agIORequest,
1650                bit32                 agIOStatus,
1651                bit32                 agIOInfoLen,
1652                agsaFrameHandle_t     agFrameHandle
1653              );
1654
1655osGLOBAL void
1656smSMPCompletedCB(
1657                  agsaRoot_t            *agRoot,
1658                  agsaIORequest_t       *agIORequest,
1659                  bit32                 agIOStatus,
1660                  bit32                 agIOInfoLen,
1661                  agsaFrameHandle_t     agFrameHandle
1662                );
1663
1664osGLOBAL void
1665smPhyControlRespRcvd(
1666                      smRoot_t              *smRoot,
1667                      agsaRoot_t            *agRoot,
1668                      agsaIORequest_t       *agIORequest,
1669                      smDeviceData_t        *oneDeviceData,
1670                      smSMPFrameHeader_t    *frameHeader,
1671                      agsaFrameHandle_t     frameHandle,
1672                      smIORequest_t         *CurrentTaskTag
1673                     );
1674
1675osGLOBAL void
1676smsatCheckPowerModeCB(
1677                      agsaRoot_t        *agRoot,
1678                      agsaIORequest_t   *agIORequest,
1679                      bit32             agIOStatus,
1680                      agsaFisHeader_t   *agFirstDword,
1681                      bit32             agIOInfoLen,
1682                      agsaFrameHandle_t agFrameHandle,
1683                      void              *ioContext
1684                     );
1685
1686osGLOBAL void
1687smsatCheckPowerModePassCB(
1688                      agsaRoot_t        *agRoot,
1689                      agsaIORequest_t   *agIORequest,
1690                      bit32             agIOStatus,
1691                      agsaFisHeader_t   *agFirstDword,
1692                      bit32             agIOInfoLen,
1693                      agsaFrameHandle_t agFrameHandle,
1694                      void              *ioContext
1695                     );
1696
1697osGLOBAL void
1698smsatIDDataPassCB(
1699                  agsaRoot_t        *agRoot,
1700                  agsaIORequest_t   *agIORequest,
1701                  bit32             agIOStatus,
1702                  agsaFisHeader_t   *agFirstDword,
1703                  bit32             agIOInfoLen,
1704                  agsaFrameHandle_t agFrameHandle,
1705                  void              *ioContext
1706                 );
1707
1708osGLOBAL void
1709smsatResetDeviceCB(
1710                    agsaRoot_t        *agRoot,
1711                    agsaIORequest_t   *agIORequest,
1712                    bit32             agIOStatus,
1713                    agsaFisHeader_t   *agFirstDword,
1714                    bit32             agIOInfoLen,
1715                    agsaFrameHandle_t agFrameHandle,
1716                    void              *ioContext
1717                  );
1718
1719osGLOBAL void
1720smsatDeResetDeviceCB(
1721                      agsaRoot_t        *agRoot,
1722                      agsaIORequest_t   *agIORequest,
1723                      bit32             agIOStatus,
1724                      agsaFisHeader_t   *agFirstDword,
1725                      bit32             agIOInfoLen,
1726                      agsaFrameHandle_t agFrameHandle,
1727                      void              *ioContext
1728                    );
1729osGLOBAL void
1730smaSATAAbortCB(
1731                agsaRoot_t        *agRoot,
1732                agsaIORequest_t   *agIORequest,
1733                bit32             flag,
1734                bit32             status
1735	      );
1736
1737osGLOBAL void
1738smLocalPhyControlCB(
1739                     agsaRoot_t     *agRoot,
1740                     agsaContext_t  *agContext,
1741                     bit32          phyId,
1742                     bit32          phyOperation,
1743                     bit32          status,
1744                     void           *parm
1745                    );
1746/******************************** end of completion ***********************************************************/
1747
1748/******************************** start of utils    ***********************************************************/
1749osGLOBAL bit32 smsatComputeCDB10LBA(smSatIOContext_t            *satIOContext);
1750osGLOBAL bit32 smsatComputeCDB10TL(smSatIOContext_t            *satIOContext);
1751osGLOBAL bit32 smsatComputeCDB12LBA(smSatIOContext_t            *satIOContext);
1752osGLOBAL bit32 smsatComputeCDB12TL(smSatIOContext_t            *satIOContext);
1753osGLOBAL bit32 smsatComputeCDB16LBA(smSatIOContext_t            *satIOContext);
1754osGLOBAL bit32 smsatComputeCDB16TL(smSatIOContext_t            *satIOContext);
1755osGLOBAL FORCEINLINE bit32 smsatComputeLoopNum(bit32 a, bit32 b);
1756osGLOBAL FORCEINLINE bit32 smsatCheckLimit(bit8 *lba, bit8 *tl, int flag, smDeviceData_t *pSatDevData);
1757
1758osGLOBAL void
1759smsatSplitSGL(
1760            smRoot_t                  *smRoot,
1761            smIORequest_t             *smIORequest,
1762            smDeviceHandle_t          *smDeviceHandle,
1763            smScsiInitiatorRequest_t  *smScsiRequest,
1764            smSatIOContext_t            *satIOContext,
1765            bit32                     split,
1766            bit32                     tl,
1767            bit32                     flag
1768	   );
1769
1770osGLOBAL void
1771smsatPrintSgl(
1772            smRoot_t                  *smRoot,
1773            agsaEsgl_t                *agEsgl,
1774            bit32                     idx
1775            );
1776/******************************** end   of utils    ***********************************************************/
1777
1778
1779osGLOBAL void
1780smsatPassthroughCB(
1781                agsaRoot_t        *agRoot,
1782                agsaIORequest_t   *agIORequest,
1783                bit32             agIOStatus,
1784                agsaFisHeader_t   *agFirstDword,
1785                bit32             agIOInfoLen,
1786                void              *agParam,
1787                void              *ioContext
1788               );
1789
1790
1791#endif                          /* __SMPROTO_H__ */
1792
1793