1 /******************************************************************************* 2 * Copyright (C) 2018 Cadence Design Systems, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to use this Software with Cadence processor cores only and 7 * not with any other processors and platforms, subject to 8 * the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included 11 * in all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21 ******************************************************************************/ 22 23 #ifndef __XF_H 24 #error "xf-types.h mustn't be included directly" 25 #endif 26 27 /******************************************************************************* 28 * Standard includes 29 ******************************************************************************/ 30 31 #ifndef _GNU_SOURCE 32 #define _GNU_SOURCE 33 #endif 34 35 #include <stdarg.h> 36 #include <stdint.h> 37 #include <stdlib.h> 38 #include <string.h> 39 #include <stdio.h> 40 #include <assert.h> 41 #include <errno.h> 42 43 #include <unistd.h> 44 #include <fcntl.h> 45 #include <pthread.h> 46 #include <signal.h> 47 #include <limits.h> 48 #include <sys/mman.h> 49 #include <sys/ioctl.h> 50 #include <sys/time.h> 51 52 /******************************************************************************* 53 * Primitive types 54 ******************************************************************************/ 55 56 typedef uint32_t u32; 57 typedef int32_t s32; 58 typedef uint16_t u16; 59 typedef int16_t s16; 60 typedef uint8_t u8; 61 typedef int8_t s8; 62 63 /******************************************************************************* 64 * Macros definitions 65 ******************************************************************************/ 66 67 /* ...NULL-address specification */ 68 #define XF_PROXY_NULL (~0U) 69 70 /* ...invalid proxy address */ 71 #define XF_PROXY_BADADDR XF_CFG_REMOTE_IPC_POOL_SIZE 72 73 /******************************************************************************* 74 * Auxiliary helpers 75 ******************************************************************************/ 76 77 /* ...next power-of-two calculation */ 78 #define xf_next_power_of_two(v) __xf_power_of_two_1((v) - 1) 79 #define __xf_power_of_two_1(v) __xf_power_of_two_2((v) | ((v) >> 1)) 80 #define __xf_power_of_two_2(v) __xf_power_of_two_3((v) | ((v) >> 2)) 81 #define __xf_power_of_two_3(v) __xf_power_of_two_4((v) | ((v) >> 4)) 82 #define __xf_power_of_two_4(v) __xf_power_of_two_5((v) | ((v) >> 8)) 83 #define __xf_power_of_two_5(v) __xf_power_of_two_6((v) | ((v) >> 16)) 84 #define __xf_power_of_two_6(v) ((v) + 1) 85 86 /* ...check if non-zero value is a power-of-two */ 87 #define xf_is_power_of_two(v) (((v) & ((v) - 1)) == 0) 88 89