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 #include "common_def.h"
22 * @brief frequency domain allocation function.
26 * Function: freqDomRscAllocType0
28 * This function does allocation in frequency domain resource.
29 * This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order.
31 * @param[in] startPrb - start PRB from where the freq alloc starts.
32 * @param[in] prbSize - number of PRBs to be allocted.
33 * @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
36 void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
38 uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
39 uint8_t firstByte = 1;
40 uint8_t numBits,startBit,byteCount = 5;
44 /* when the startPrb is not in this byteCount */
52 /* max bytecount is 6 nearly equal to 45 bits*/
56 /* when we are filling the second byte, then the start should be equal to 0 */
62 /* calculate the number of bits to be set in this byte */
63 if((remBits+startPrb) <= 8)
66 numBits = 8 - startBit;
68 /* bit operation to set the bits */
69 SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount])
72 /* the ramaining bits should be subtracted with the numBits set in this byte */
78 /*******************************************************************
80 * @brief Reverse and copy fixed buffer to mBuf
84 * Function : oduCpyFixBufToMsg
86 * Functionality: Reverse and copy fixed buffer to mBuf
88 * @params[in] Fixed buffer, msg buffer, length of message
89 * @return ROK - success
92 * ****************************************************************/
93 void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len)
95 uint8_t idx, revIdx, temp;
98 /* ODU_COPY_FIX_BUF_TO_MSG copies fixed buffer in reverse order. \
99 * Hence reversing the fixed buffer before copying in order to \
100 * maintain the actual order*/
101 for(idx = 0, revIdx = len-1; idx < len/2; idx++, revIdx--)
104 fixBuf[idx] = fixBuf[revIdx];
105 fixBuf[revIdx] = temp;
107 ODU_COPY_FIX_BUF_TO_MSG(fixBuf, mBuf, 0, len, (MsgLen *)©Len);
110 /*******************************************************************
112 * @brief Builds PLMN ID
116 * Function : plmnBuildId
118 * Functionality: Building the PLMN ID
120 * @params[in] PLMNID plmn
121 * @params[out] PLMNID in string format
122 * @return ROK - success
125 * ****************************************************************/
126 uint8_t buildPlmnId(Plmn plmn, uint8_t *buf)
130 buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
133 buf[1] = ((0xf0) | (plmn.mcc[2]));
134 buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
138 buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
139 buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
145 /**********************************************************************
147 **********************************************************************/