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 ********************************************************************************/
22 /*******************************************************************************/
23 /*! \file saframe.c
24 * \brief The file implements the functions to read frame content
25 */
26
27
28 /******************************************************************************/
29 #include <sys/cdefs.h>
30 #include <dev/pms/config.h>
31
32 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
33 #ifdef SA_ENABLE_TRACE_FUNCTIONS
34 #ifdef siTraceFileID
35 #undef siTraceFileID
36 #endif
37 #define siTraceFileID 'D'
38 #endif
39
40 /******************************************************************************/
41 /*! \brief Read 32 bits from a frame
42 *
43 * Read 32 bits from a frame
44 *
45 * \param agRoot Handles for this instance of SAS/SATA LLL
46 * \param agFrame The frame handler
47 * \param frameOffset Offset in bytes from the beginning of valid frame bytes or IU
48 to the 32-bit value to read
49 *
50 * \return The read value
51 *
52 */
53 /*******************************************************************************/
saFrameReadBit32(agsaRoot_t * agRoot,agsaFrameHandle_t agFrame,bit32 frameOffset)54 GLOBAL bit32 saFrameReadBit32(
55 agsaRoot_t *agRoot,
56 agsaFrameHandle_t agFrame,
57 bit32 frameOffset
58 )
59 {
60 bit8 *payloadAddr;
61 bit32 value = 0;
62
63 smTraceFuncEnter(hpDBG_VERY_LOUD, "zr");
64
65 if ( agNULL != agFrame )
66 {
67 /* Find the address of the payload */
68 payloadAddr = (bit8 *)(agFrame) + frameOffset;
69
70 /* read one DW Data */
71 value = *(bit32 *)payloadAddr;
72 }
73
74
75 /* (5) return value */
76 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zr");
77 return value;
78 }
79
80 /******************************************************************************/
81 /*! \brief Read a block from a frame
82 *
83 * Read a block from a frame
84 *
85 * \param agRoot Handles for this instance of SAS/SATA LLL
86 * \param agFrame The frame handler
87 * \param frameOffset The offset of the frame to start read
88 * \param frameBuffer The pointer to the destination of data read from the frame
89 * \param frameBufLen Number of bytes to read from the frame
90 *
91 * \return -void-
92 *
93 */
94 /*******************************************************************************/
saFrameReadBlock(agsaRoot_t * agRoot,agsaFrameHandle_t agFrame,bit32 frameOffset,void * frameBuffer,bit32 frameBufLen)95 GLOBAL void saFrameReadBlock (
96 agsaRoot_t *agRoot,
97 agsaFrameHandle_t agFrame,
98 bit32 frameOffset,
99 void *frameBuffer,
100 bit32 frameBufLen
101 )
102 {
103 bit8 *payloadAddr;
104 bit32 i;
105
106 smTraceFuncEnter(hpDBG_VERY_LOUD, "zi");
107
108 /* Sanity check */
109 SA_ASSERT(frameBufLen < 4096, "saFrameReadBlock read more than 4k");
110
111 if ( agNULL != agFrame )
112 {
113 /* Find the address of the payload */
114 payloadAddr = (bit8 *)(agFrame) + frameOffset;
115 /* Copy the frame data to the destination frame buffer */
116 for ( i = 0; i < frameBufLen; i ++ )
117 {
118 *(bit8 *)((bit8 *)frameBuffer + i) = *(bit8 *)(payloadAddr + i);
119 }
120 }
121
122 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zi");
123 }
124
125