xref: /freebsd/sys/dev/pms/RefTisa/tisa/sassata/common/tdutil.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
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 /*******************************************************************************/
24 /** \file
25  *
26  * The file defines utilities for SAS/SATA TD layer
27  *
28  */
29 
30 #ifndef __TDUTIL_H__
31 #define __TDUTIL_H__
32 
33 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
34 #include <dev/pms/RefTisa/tisa/api/tidefs.h>
35 #include <dev/pms/RefTisa/tisa/api/titypes.h>
36 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
37 #include <dev/pms/RefTisa/tisa/sassata/common/tdlist.h>
38 
39 
40 #define HEXDIGIT2CHAR(x)     (((x) < 10) ? ('0' + (x)) : ('A' + ((x) - 10)))
41 /*****************************************************************************
42 *! \brief tdDecimal2String
43 *
44 *  Purpose:  This function converts a given number into a decimal string.
45 *
46 *  \param s:                  string to be generated
47 *  \param num:                number to be converted
48 *
49 *  \return None
50 *
51 *  \note - string s should be large enough to store decimal string of
52 *        num and a '\0' character
53 *
54 *****************************************************************************/
55 void
56 tdDecimal2String(
57   char *s,
58   bit32 num
59   );
60 
61 void
62 tdHexToString (
63   char  *String,
64   bit32  Value1,
65   bit32  Value2,
66   bit32  Strlength
67   );
68 
69 bit8 tdStr2Bit8 (char *buffer);
70 
71 bit32 tdStr2ALPA (char *buffer);
72 
73 void tdStr2WWN (char *buffer, bit8 * NodeName);
74 
75 void tdWWN2Str (char *buffer, bit8 * NodeName);
76 
77 /*****************************************************************************
78 *! \brief tdNextPowerOf2
79 *
80 *  Purpose:  This function is called to calculate the next power of 2
81 *            value of given value.
82 *
83 *
84 *  \param  Value:             The value for which next power of 2 is requested
85 *
86 *  \return: The next power of 2 value of given Value
87 *
88 *****************************************************************************/
89 bit32
90 tdNextPowerOf2 (
91   bit32 Value
92   );
93 
94 osGLOBAL agBOOLEAN
95 tdListElementOnList(
96     tdList_t *toFindHdr,
97     tdList_t *listHdr
98     );
99 
100 
101 #endif /* __TDUTIL_H__ */
102 
103 
104 
105