1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
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
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.
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
21 ********************************************************************************/
22 /*******************************************************************************/
24 * \brief The file implements the functions to read frame content
28 /******************************************************************************/
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <dev/pms/config.h>
33 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
34 #ifdef SA_ENABLE_TRACE_FUNCTIONS
38 #define siTraceFileID 'D'
41 /******************************************************************************/
42 /*! \brief Read 32 bits from a frame
44 * Read 32 bits from a frame
46 * \param agRoot Handles for this instance of SAS/SATA LLL
47 * \param agFrame The frame handler
48 * \param frameOffset Offset in bytes from the beginning of valid frame bytes or IU
49 to the 32-bit value to read
51 * \return The read value
54 /*******************************************************************************/
55 GLOBAL bit32 saFrameReadBit32(
57 agsaFrameHandle_t agFrame,
64 smTraceFuncEnter(hpDBG_VERY_LOUD, "zr");
66 if ( agNULL != agFrame )
68 /* Find the address of the payload */
69 payloadAddr = (bit8 *)(agFrame) + frameOffset;
71 /* read one DW Data */
72 value = *(bit32 *)payloadAddr;
76 /* (5) return value */
77 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zr");
81 /******************************************************************************/
82 /*! \brief Read a block from a frame
84 * Read a block from a frame
86 * \param agRoot Handles for this instance of SAS/SATA LLL
87 * \param agFrame The frame handler
88 * \param frameOffset The offset of the frame to start read
89 * \param frameBuffer The pointer to the destination of data read from the frame
90 * \param frameBufLen Number of bytes to read from the frame
95 /*******************************************************************************/
96 GLOBAL void saFrameReadBlock (
98 agsaFrameHandle_t agFrame,
107 smTraceFuncEnter(hpDBG_VERY_LOUD, "zi");
110 SA_ASSERT(frameBufLen < 4096, "saFrameReadBlock read more than 4k");
112 if ( agNULL != agFrame )
114 /* Find the address of the payload */
115 payloadAddr = (bit8 *)(agFrame) + frameOffset;
116 /* Copy the frame data to the destination frame buffer */
117 for ( i = 0; i < frameBufLen; i ++ )
119 *(bit8 *)((bit8 *)frameBuffer + i) = *(bit8 *)(payloadAddr + i);
123 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zi");