cvmx-platform.h revision 210311
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#elif defined(__FreeBSD__) && defined(_KERNEL)
107    #define CVMX_BUILD_FOR_FREEBSD
108#else
109    /* We are building a simple exec standalone image for Octeon */
110    #define CVMX_BUILD_FOR_STANDALONE
111#endif
112
113
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.
121 */
122#if defined(CVMX_BUILD_FOR_FREEBSD)
123#define CVMX_SHARED
124#else
125#define CVMX_SHARED __attribute__ ((cvmx_shared))
126#endif
127
128
129#if defined(CVMX_BUILD_FOR_UBOOT)
130
131    #include <common.h>
132    #include "cvmx-sysinfo.h"
133
134#elif defined(CVMX_BUILD_FOR_LINUX_KERNEL)
135
136    #include <linux/kernel.h>
137    #include <linux/string.h>
138    #include <linux/types.h>
139    #include <stdarg.h>
140
141#elif defined(CVMX_BUILD_FOR_LINUX_USER)
142
143    #include <stddef.h>
144    #include <stdint.h>
145    #include <stdio.h>
146    #include <stdlib.h>
147    #include <stdarg.h>
148    #include <string.h>
149    #include <assert.h>
150    #include <fcntl.h>
151    #include <sys/mman.h>
152    #include <unistd.h>
153
154#elif defined(CVMX_BUILD_FOR_LINUX_HOST)
155
156    #include <stddef.h>
157    #include <stdint.h>
158    #include <stdio.h>
159    #include <stdlib.h>
160    #include <stdarg.h>
161    #include <string.h>
162    #include <assert.h>
163    #include <fcntl.h>
164    #include <sys/mman.h>
165    #include <unistd.h>
166
167#elif defined(CVMX_BUILD_FOR_VXWORKS)
168
169    #include <stdint.h>
170    #include <stdio.h>
171    #include <stdlib.h>
172    #include <stdarg.h>
173    #include <string.h>
174    #include <assert.h>
175
176#elif defined(CVMX_BUILD_FOR_STANDALONE)
177
178    #include <stddef.h>
179    #include <stdint.h>
180    #include <stdio.h>
181    #include <stdlib.h>
182    #include <stdarg.h>
183    #include <string.h>
184    #include <assert.h>
185
186#elif defined(CVMX_BUILD_FOR_TOOLCHAIN)
187
188    #include <stddef.h>
189    #include <stdint.h>
190    #include <stdio.h>
191    #include <stdlib.h>
192    #include <stdarg.h>
193    #include <string.h>
194    #include <assert.h>
195
196#elif defined(CVMX_BUILD_FOR_FREEBSD)
197
198    #include <mips/cavium/cvmx_config.h>
199
200#else
201
202    #error Unexpected CVMX_BUILD_FOR_* macro
203
204#endif
205
206#endif /* __CVMX_PLATFORM_H__ */
207