cvmx-platform.h revision 210284
1/***********************license start*************** 2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * * Neither the name of Cavium Networks nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 * 23 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS 25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH 26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES 29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR 30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET 31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT 32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 33 * 34 * 35 * For any questions regarding licensing please contact marketing@caviumnetworks.com 36 * 37 ***********************license end**************************************/ 38 39 40 41 42 43 44/** 45 * @file 46 * 47 * This file is resposible for including all system dependent 48 * headers for the cvmx-* files. 49 * 50 * <hr>$Revision: 41586 $<hr> 51*/ 52 53#ifndef __CVMX_PLATFORM_H__ 54#define __CVMX_PLATFORM_H__ 55 56#include "cvmx-abi.h" 57 58#ifdef __cplusplus 59#define EXTERN_ASM extern "C" 60#else 61#define EXTERN_ASM extern 62#endif 63 64/* This file defines macros for use in determining the current 65 building environment. It defines a single CVMX_BUILD_FOR_* 66 macro representing the target of the build. The current 67 possibilities are: 68 CVMX_BUILD_FOR_UBOOT 69 CVMX_BUILD_FOR_LINUX_KERNEL 70 CVMX_BUILD_FOR_LINUX_USER 71 CVMX_BUILD_FOR_LINUX_HOST 72 CVMX_BUILD_FOR_VXWORKS 73 CVMX_BUILD_FOR_STANDALONE */ 74#if defined(__U_BOOT__) 75 /* We are being used inside of Uboot */ 76 #define CVMX_BUILD_FOR_UBOOT 77#elif defined(__linux__) 78 #if defined(__KERNEL__) 79 /* We are in the Linux kernel on Octeon */ 80 #define CVMX_BUILD_FOR_LINUX_KERNEL 81 #elif !defined(__mips__) 82 /* We are being used under Linux but not on Octeon. Assume 83 we are on a Linux host with an Octeon target over PCI/PCIe */ 84 #ifndef CVMX_BUILD_FOR_LINUX_HOST 85 #define CVMX_BUILD_FOR_LINUX_HOST 86 #endif 87 #else 88 #ifdef CVMX_BUILD_FOR_LINUX_HOST 89 /* This is a manual special case. The host PCI utilities can 90 be configured to run on Octeon. In this case it is impossible 91 to tell the difference between the normal userspace setup 92 and using cvmx_read/write_csr over the PCI bus. The host 93 utilites force this define to fix this */ 94 #else 95 /* We are in the Linux userspace on Octeon */ 96 #define CVMX_BUILD_FOR_LINUX_USER 97 #endif 98 #endif 99#elif defined(_WRS_KERNEL) || defined(VXWORKS_USER_MAPPINGS) 100 /* We are in VxWorks on Octeon */ 101 #define CVMX_BUILD_FOR_VXWORKS 102#elif defined(_OCTEON_TOOLCHAIN_RUNTIME) 103 /* To build the simple exec toolchain runtime (newlib) library. We 104 should only use features available on all Octeon models. */ 105 #define CVMX_BUILD_FOR_TOOLCHAIN 106#else 107 /* We are building a simple exec standalone image for Octeon */ 108 #define CVMX_BUILD_FOR_STANDALONE 109#endif 110 111 112/* To have a global variable be shared among all cores, 113 * declare with the CVMX_SHARED attribute. Ex: 114 * CVMX_SHARED int myglobal; 115 * This will cause the variable to be placed in a special 116 * section that the loader will map as shared for all cores 117 * This is for data structures use by software ONLY, 118 * as it is not 1-1 VA-PA mapped. 119 */ 120#define CVMX_SHARED __attribute__ ((cvmx_shared)) 121 122 123#if defined(CVMX_BUILD_FOR_UBOOT) 124 125 #include <common.h> 126 #include "cvmx-sysinfo.h" 127 128#elif defined(CVMX_BUILD_FOR_LINUX_KERNEL) 129 130 #include <linux/kernel.h> 131 #include <linux/string.h> 132 #include <linux/types.h> 133 #include <stdarg.h> 134 135#elif defined(CVMX_BUILD_FOR_LINUX_USER) 136 137 #include <stddef.h> 138 #include <stdint.h> 139 #include <stdio.h> 140 #include <stdlib.h> 141 #include <stdarg.h> 142 #include <string.h> 143 #include <assert.h> 144 #include <fcntl.h> 145 #include <sys/mman.h> 146 #include <unistd.h> 147 148#elif defined(CVMX_BUILD_FOR_LINUX_HOST) 149 150 #include <stddef.h> 151 #include <stdint.h> 152 #include <stdio.h> 153 #include <stdlib.h> 154 #include <stdarg.h> 155 #include <string.h> 156 #include <assert.h> 157 #include <fcntl.h> 158 #include <sys/mman.h> 159 #include <unistd.h> 160 161#elif defined(CVMX_BUILD_FOR_VXWORKS) 162 163 #include <stdint.h> 164 #include <stdio.h> 165 #include <stdlib.h> 166 #include <stdarg.h> 167 #include <string.h> 168 #include <assert.h> 169 170#elif defined(CVMX_BUILD_FOR_STANDALONE) 171 172 #include <stddef.h> 173 #include <stdint.h> 174 #include <stdio.h> 175 #include <stdlib.h> 176 #include <stdarg.h> 177 #include <string.h> 178 #include <assert.h> 179 180#elif defined(CVMX_BUILD_FOR_TOOLCHAIN) 181 182 #include <stddef.h> 183 #include <stdint.h> 184 #include <stdio.h> 185 #include <stdlib.h> 186 #include <stdarg.h> 187 #include <string.h> 188 #include <assert.h> 189 190#else 191 192 #error Unexpected CVMX_BUILD_FOR_* macro 193 194#endif 195 196#endif /* __CVMX_PLATFORM_H__ */ 197