1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains all utility functions for MAC CL */
33 /*******************************************************************
35 * @brief Fetch cellCb from Hash list
39 * Function : rgClUtlGetCellCb
42 * - Searches for a cell entry at MAC CL
45 * @return Pointer to cellCb - success
48 * ****************************************************************/
49 PUBLIC ClCellCb * rgClUtlGetCellCb
56 if(cellId >= MAX_NUM_CELL_SUPP)
58 printf("\n Invalid Cell Id [%d]. rgClUtlGetCellCb failed.", cellId);
62 cmHashListFind((CmHashListCp *)&clGlobalCp.cellCbLst, (U8 *)&cellId, sizeof(U16), 0, (PTR *)&cellCb);
67 /*******************************************************************
69 * @brief Reverses bits in a number
73 * Function : reverseBits
76 * Reverses bits in a number
78 * @params[in] Number to be reversed
79 * Number of bits to be reversed
80 * @return Reversed number
82 * ****************************************************************/
83 uint32_t reverseBits(uint32_t num, uint8_t numBits)
85 uint32_t reverse_num = 0;
87 for (i = 0; i < numBits; i++)
90 reverse_num |= 1 << ((numBits - 1) - i);
95 /*******************************************************************
97 * @brief Fills DL DCI payload byte by byte
101 * Function : fillDlDciPayload
104 * Fills DL DCI payload byte by byte
106 * @params[in] Payload buffer pointer
107 * Current Byte position in buffer
108 * Current Bit Position in current byte
110 * Number of bits in value
113 * ****************************************************************/
115 void fillDlDciPayload(uint8_t *buf, uint8_t *bytePos, uint8_t *bitPos,\
116 uint32_t val, uint8_t valSize)
121 uint8_t bytePart1Size;
122 uint8_t bytePart2Size;
124 if(*bitPos + valSize <= 8)
126 bytePart1 = (uint8_t)val;
127 bytePart1 = (~((~0) << valSize)) & bytePart1;
128 buf[*bytePos] |= bytePart1;
131 else if(*bitPos + valSize > 8)
134 bytePart1Size = 8 - *bitPos;
135 bytePart2Size = valSize - bytePart1Size;
137 bytePart1 = ((~((~0) << bytePart1Size)) & temp) << *bitPos;
138 bytePart2 = val >> bytePart1Size;
140 buf[*bytePos] |= bytePart1;
143 fillDlDciPayload(buf, bytePos, bitPos, bytePart2, bytePart2Size);
149 /**********************************************************************
151 **********************************************************************/