1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * This file is resposible for including all system dependent
48 * headers for the cvmx-* files.
50 * <hr>$Revision: 41586 $<hr>
53 #ifndef __CVMX_PLATFORM_H__
54 #define __CVMX_PLATFORM_H__
59 #define EXTERN_ASM extern "C"
61 #define EXTERN_ASM extern
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
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
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 */
95 /* We are in the Linux userspace on Octeon */
96 #define CVMX_BUILD_FOR_LINUX_USER
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 #elif defined(__FreeBSD__) && defined(_KERNEL)
107 #define CVMX_BUILD_FOR_FREEBSD
109 /* We are building a simple exec standalone image for Octeon */
110 #define CVMX_BUILD_FOR_STANDALONE
114 /* To have a global variable be shared among all cores,
115 * declare with the CVMX_SHARED attribute. Ex:
116 * CVMX_SHARED int myglobal;
117 * This will cause the variable to be placed in a special
118 * section that the loader will map as shared for all cores
119 * This is for data structures use by software ONLY,
120 * as it is not 1-1 VA-PA mapped.
122 #if defined(CVMX_BUILD_FOR_FREEBSD)
125 #define CVMX_SHARED __attribute__ ((cvmx_shared))
129 #if defined(CVMX_BUILD_FOR_UBOOT)
132 #include "cvmx-sysinfo.h"
134 #elif defined(CVMX_BUILD_FOR_LINUX_KERNEL)
136 #include <linux/kernel.h>
137 #include <linux/string.h>
138 #include <linux/types.h>
141 #elif defined(CVMX_BUILD_FOR_LINUX_USER)
151 #include <sys/mman.h>
154 #elif defined(CVMX_BUILD_FOR_LINUX_HOST)
164 #include <sys/mman.h>
167 #elif defined(CVMX_BUILD_FOR_VXWORKS)
176 #elif defined(CVMX_BUILD_FOR_STANDALONE)
186 #elif defined(CVMX_BUILD_FOR_TOOLCHAIN)
196 #elif defined(CVMX_BUILD_FOR_FREEBSD)
198 #include <mips/cavium/cvmx_config.h>
202 #error Unexpected CVMX_BUILD_FOR_* macro
206 #endif /* __CVMX_PLATFORM_H__ */