]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/tcp3d-lld.git/blob - src/tcp3d_utils.h
Commited by migration script
[keystone-rtos/tcp3d-lld.git] / src / tcp3d_utils.h
1 /*\r
2  *\r
3  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ \r
4  * \r
5  * \r
6  *  Redistribution and use in source and binary forms, with or without \r
7  *  modification, are permitted provided that the following conditions \r
8  *  are met:\r
9  *\r
10  *    Redistributions of source code must retain the above copyright \r
11  *    notice, this list of conditions and the following disclaimer.\r
12  *\r
13  *    Redistributions in binary form must reproduce the above copyright\r
14  *    notice, this list of conditions and the following disclaimer in the \r
15  *    documentation and/or other materials provided with the   \r
16  *    distribution.\r
17  *\r
18  *    Neither the name of Texas Instruments Incorporated nor the names of\r
19  *    its contributors may be used to endorse or promote products derived\r
20  *    from this software without specific prior written permission.\r
21  *\r
22  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
23  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
24  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
25  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
26  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
27  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
28  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
29  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
30  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
31  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
32  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
33  *\r
34 */\r
35 \r
36 \r
37 \r
38 #ifndef _TCP3D_UTILS_H_\r
39 #define _TCP3D_UTILS_H_\r
40 \r
41 /* c99 types includes */\r
42 #include <stdint.h>\r
43 #include <stdlib.h>\r
44 \r
45 /* ========================================================================= */\r
46 /**\r
47  * @brief  Macro for providing the address with the alignment requested\r
48  */\r
49 #define ALIGN(Addr, Algnmt) ((Addr+(Algnmt)-1)&(0xFFFF-(Algnmt)+1))\r
50 \r
51 /**\r
52  * @brief  Macro for computing minimum of the two values\r
53  */\r
54 #define MIN(x,y)            ((x) < (y) ? (x):(y))\r
55 \r
56 /**\r
57  * @brief  Macro for computing maximum of the two values\r
58  */\r
59 #define MAX(x,y)            ((x) > (y) ? (x):(y))\r
60 \r
61 /**\r
62  * @brief   Macro for computing hard decisions size in words \r
63  */\r
64 #define COMPUTE_HD_WORD_SIZE(x) (((x)+31)>>5)\r
65 \r
66 /**\r
67  * @brief   Macro for computing hard decisions size in bytes\r
68  */\r
69 #define COMPUTE_HD_BYTE_SIZE(x) (COMPUTE_HD_WORD_SIZE(x)*4)\r
70 \r
71 /**\r
72  * @brief   Macro for computing Kext value for WCDMA using the formula\r
73  *              Kext=4*Ceil(K/4)\r
74  */\r
75 #define COMPUTE_KEXT(a)         (4*((a+3)>>2))\r
76 \r
77 /**\r
78  * @brief   Macro for computing Kout value for WCDMA using the formula\r
79  *              Kout = (2*KEXT-K).\r
80  * @ref     COMPUTE_KEXT macro\r
81  */\r
82 #define COMPUTE_KOUT(x)         ((2*COMPUTE_KEXT(x))-(x))\r
83 \r
84 /**\r
85  * @brief   Macro for computing Kt value for WCDMA using the formula\r
86  *              Kt = 3 - (Kext-K)\r
87  * @ref     COMPUTE_KOUT macro\r
88  */\r
89 #define COMPUTE_KT(x)           (3 -(COMPUTE_KEXT(x)-(x)))\r
90 \r
91 /* ========================================================================= */\r
92 \r
93 /* ========================================================================= */\r
94 /**\r
95  *  \fn         uint32_t Tcp3d_glbMap (uint8_t coreID, uint32_t addr)\r
96  *\r
97  *  \brief      This is a utility function provided as part of TCP3D Driver for\r
98  *              converting the local address to the global address using the \r
99  *              coreID.\r
100  *              The address mapping will be done only if the address falls in\r
101  *              the defined local L2 memory area. Otherwise, the address is\r
102  *              returned as is.\r
103  * \r
104  *  \param[in]      coreID\r
105  *              Core ID value corresponding to the local core. If the coreID\r
106  *              value is invalid, the address translation is not done.\r
107  * \r
108  *  \param[in]      addr\r
109  *              Local address for which the global mapped address is required.\r
110  *\r
111  *  \pre        Pass the coreID value [0-3] depending on where test application\r
112  *              is running.\r
113  *\r
114  *  \post       None\r
115  *\r
116  *  \return     Returns the global address value of the passed local address.\r
117  * \r
118  */\r
119 uint32_t Tcp3d_glbMap (uint8_t coreID, uint32_t addr);\r
120 \r
121 /**\r
122  *  \fn         uint32_t Tcp3d_div32by16(uint32_t num, uint16_t den)\r
123  *\r
124  *  \brief      This is a utility function provided as part of TCP3D Driver for\r
125  *              calculating the division of a 32-bit value by a 16-bit value.\r
126  * \r
127  *  \param[in]      num\r
128  *              Numerator value.\r
129  * \r
130  *  \param[in]      den\r
131  *              Denominator value.\r
132  *\r
133  *  \pre        Pass the coreID value [0-3] depending on where test application\r
134  *              is running.\r
135  *\r
136  *  \post       None\r
137  *\r
138  *  \return     Returns the global address value of the passed local address.\r
139  * \r
140  */\r
141 uint32_t Tcp3d_div32by16(uint32_t num, uint16_t den);\r
142 \r
143 /* ========================================================================= */\r
144 \r
145 #endif /* _TCP3D_UTILS_H_ */\r