• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: Header file for oal_plat_type.h.
15  */
16 
17 #ifndef __OAL_PLAT_TYPE_H__
18 #define __OAL_PLAT_TYPE_H__
19 
20 #include "osal_adapt.h"
21 #include "td_base.h"
22 /*****************************************************************************
23   1 Include other Head file
24 *****************************************************************************/
25 
26 /*****************************************************************************
27   2 Define macro
28 *****************************************************************************/
29 #define STATIC  static
30 
31 #ifndef INLINE__
32 #ifdef INLINE_TO_FORCEINLINE
33 #define INLINE__    __inline__ __attribute__((always_inline))
34 #else
35 #define INLINE__    __inline
36 #endif
37 #endif
38 
39 #ifdef osal_likely
40 #undef osal_likely
41 #endif
42 #ifdef osal_unlikely
43 #undef osal_unlikely
44 #endif
45 #ifdef HAVE_PCLINT_CHECK
46 #define osal_likely(x)    (x)
47 #define osal_unlikely(x)  (x)
48 #else
49 #define osal_likely(x) __builtin_expect(!!(x), 1)
50 #define osal_unlikely(x) __builtin_expect(!!(x), 0)
51 #endif
52 
53 #define OAL_LIKELY(_expr)       uapi_likely(_expr)
54 #define OAL_UNLIKELY(_expr)     uapi_unlikely(_expr)
55 
56 #define osal_array_size(_array)  (sizeof(_array) / sizeof((_array)[0]))
57 
58 #define hi_tolower(x)          ((x) | 0x20)  /* Works only for digits and letters, but small and fast */
59 #define osal_makeu64(a, b)       ((osal_u64)(((osal_u32)(a)) | ((osal_u64)((osal_u32)(b))) << 32))
60 
61 #ifndef NEWLINE
62 #define NEWLINE                 "\r\n"
63 #endif
64 
65 #define osal_array_size(_array)  (sizeof(_array) / sizeof((_array)[0]))
66 
67 #ifndef OSAL_WRITE_BITS /* 与oal_plat_type.h重定义,先屏蔽后整改 */
68 #define OSAL_WRITE_BITS
osal_write_bits(osal_u32 * data,osal_u32 val,osal_u32 bits,osal_u32 pos)69 static INLINE__ osal_void osal_write_bits(osal_u32 *data, osal_u32 val, osal_u32 bits, osal_u32 pos)
70 {
71     (*data) &= ~((((osal_u32)1 << bits) - 1) << pos);
72     (*data) |= ((val & (((osal_u32)1 << bits) - 1)) << pos);
73 }
74 #endif
75 #define osal_abs_of_diff(_l_a, _l_b) (((_l_a) > (_l_b)) ? ((_l_a) - (_l_b)) : ((_l_b) - (_l_a)))
76 
77 #define osal_bit(nr) (1UL << (nr))
78 
79 #endif /* __OAL_PLAT_TYPE_H */
80