1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved. 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 */ 15 #ifndef _WB_CO_INT_H 16 #define _WB_CO_INT_H 17 18 19 #include <stdint.h> 20 21 #ifndef BIT 22 #define BIT(x) (1ul << (x)) 23 #endif 24 /* Bit Values */ 25 #define BIT31 ((uint32_t)(1ul << 31)) 26 #define BIT30 ((uint32_t)(1ul << 30)) 27 #define BIT29 ((uint32_t)(1ul << 29)) 28 #define BIT28 ((uint32_t)(1ul << 28)) 29 #define BIT27 ((uint32_t)(1ul << 27)) 30 #define BIT26 ((uint32_t)(1ul << 26)) 31 #define BIT25 ((uint32_t)(1ul << 25)) 32 #define BIT24 ((uint32_t)(1ul << 24)) 33 #define BIT23 ((uint32_t)(1ul << 23)) 34 #define BIT22 ((uint32_t)(1ul << 22)) 35 #define BIT21 ((uint32_t)(1ul << 21)) 36 #define BIT20 ((uint32_t)(1ul << 20)) 37 #define BIT19 ((uint32_t)(1ul << 19)) 38 #define BIT18 ((uint32_t)(1ul << 18)) 39 #define BIT17 ((uint32_t)(1ul << 17)) 40 #define BIT16 ((uint32_t)(1ul << 16)) 41 #define BIT15 ((uint32_t)(1ul << 15)) 42 #define BIT14 ((uint32_t)(1ul << 14)) 43 #define BIT13 ((uint32_t)(1ul << 13)) 44 #define BIT12 ((uint32_t)(1ul << 12)) 45 #define BIT11 ((uint32_t)(1ul << 11)) 46 #define BIT10 ((uint32_t)(1ul << 10)) 47 #define BIT9 ((uint32_t)(1ul << 9)) 48 #define BIT8 ((uint32_t)(1ul << 8)) 49 #define BIT7 ((uint32_t)(1ul << 7)) 50 #define BIT6 ((uint32_t)(1ul << 6)) 51 #define BIT5 ((uint32_t)(1ul << 5)) 52 #define BIT4 ((uint32_t)(1ul << 4)) 53 #define BIT3 ((uint32_t)(1ul << 3)) 54 #define BIT2 ((uint32_t)(1ul << 2)) 55 #define BIT1 ((uint32_t)(1ul << 1)) 56 #define BIT0 ((uint32_t)(1ul << 0)) 57 #define ALL_BITS (0xFFFFFFFFul) 58 59 typedef enum { 60 FAIL = 0, 61 SUCCESS 62 } STATUS_T; 63 64 #ifndef NULL 65 #define NULL (void *)0 66 #endif 67 68 /* chipsea */ 69 // #ifndef INLINE 70 // #define INLINE static __inline 71 // #endif 72 73 #define SHIFT_DSCR_OFFSET(offst, wdth) (32 - (wdth) - (offst)) 74 #define DSCR_MASK(offst, wdth) (((wdth) < 32) ? \ 75 ((uint32_t)((1 << (wdth)) - 1) << (SHIFT_DSCR_OFFSET(offst, wdth))) : \ 76 (0xFFFFFFFF)) 77 #define GET_DSCR(offst, wdth, ptr) (((*(uint32_t *) ptr) & \ 78 (DSCR_MASK(offst,wdth))) >> (SHIFT_DSCR_OFFSET(offst, wdth))) 79 #define SET_DSCR(offst, wdth, ptr, val) (*(uint32_t *)ptr = ((((uint32_t)(val) << \ 80 (SHIFT_DSCR_OFFSET(offst,wdth))) & (DSCR_MASK(offst,wdth))) | \ 81 ((*(uint32_t *) (ptr)) & (~(DSCR_MASK(offst, wdth)))))) 82 83 #endif // _WB_CO_INT_H 84