138032Speter/*******************************************************************************
238032Speter*Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3261363Sgshapiro*
464562Sgshapiro*Redistribution and use in source and binary forms, with or without modification, are permitted provided
538032Speter*that the following conditions are met:
638032Speter*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
738032Speter*following disclaimer.
838032Speter*2. Redistributions in binary form must reproduce the above copyright notice,
938032Speter*this list of conditions and the following disclaimer in the documentation and/or other materials provided
1038032Speter*with the distribution.
1138032Speter*
1238032Speter*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
1338032Speter*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1438032Speter*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1538032Speter*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1638032Speter*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
1738032Speter*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1838032Speter*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1938032Speter*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
2038032Speter*
2138032Speter* $FreeBSD$
2238032Speter*
2338032Speter********************************************************************************/
2438032Speter/*******************************************************************************/
2538032Speter/** \file
26266692Sgshapiro *
2738032Speter * The file defines utilities for SAS/SATA TD layer
2838032Speter *
2938032Speter */
3038032Speter
31#ifndef __TDUTIL_H__
32#define __TDUTIL_H__
33
34#include <dev/pms/RefTisa/sallsdk/api/sa.h>
35#include <dev/pms/RefTisa/tisa/api/tidefs.h>
36#include <dev/pms/RefTisa/tisa/api/titypes.h>
37#include <dev/pms/RefTisa/tisa/api/tiapi.h>
38#include <dev/pms/RefTisa/tisa/sassata/common/tdlist.h>
39
40
41#define HEXDIGIT2CHAR(x)     (((x) < 10) ? ('0' + (x)) : ('A' + ((x) - 10)))
42/*****************************************************************************
43*! \brief tdDecimal2String
44*
45*  Purpose:  This function converts a given number into a decimal string.
46*
47*  \param s:                  string to be generated
48*  \param num:                number to be converted
49*
50*  \return None
51*
52*  \note - string s should be large enough to store decimal string of
53*        num and a '\0' character
54*
55*****************************************************************************/
56void
57tdDecimal2String(
58  char *s,
59  bit32 num
60  );
61
62void
63tdHexToString (
64  char  *String,
65  bit32  Value1,
66  bit32  Value2,
67  bit32  Strlength
68  );
69
70bit8 tdStr2Bit8 (char *buffer);
71
72bit32 tdStr2ALPA (char *buffer);
73
74void tdStr2WWN (char *buffer, bit8 * NodeName);
75
76void tdWWN2Str (char *buffer, bit8 * NodeName);
77
78/*****************************************************************************
79*! \brief tdNextPowerOf2
80*
81*  Purpose:  This function is called to calculate the next power of 2
82*            value of given value.
83*
84*
85*  \param  Value:             The value for which next power of 2 is requested
86*
87*  \return: The next power of 2 value of given Value
88*
89*****************************************************************************/
90bit32
91tdNextPowerOf2 (
92  bit32 Value
93  );
94
95osGLOBAL agBOOLEAN
96tdListElementOnList(
97    tdList_t *toFindHdr,
98    tdList_t *listHdr
99    );
100
101
102#endif /* __TDUTIL_H__ */
103
104
105
106