1 |
26 |
unneback |
#ifndef CYGONCE_INFRA_CYG_TYPE_H
|
2 |
|
|
#define CYGONCE_INFRA_CYG_TYPE_H
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// cyg_type.h
|
7 |
|
|
//
|
8 |
|
|
// Standard types, and some useful coding macros.
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
//####COPYRIGHTBEGIN####
|
12 |
|
|
//
|
13 |
|
|
// ----------------------------------------------------------------------------
|
14 |
|
|
// Copyright (C) 1997, 1998, 1999, 2000 Red Hat, Inc.
|
15 |
|
|
//
|
16 |
|
|
// This file is part of the eCos host tools.
|
17 |
|
|
//
|
18 |
|
|
// This program is free software; you can redistribute it and/or modify it
|
19 |
|
|
// under the terms of the GNU General Public License as published by the Free
|
20 |
|
|
// Software Foundation; either version 2 of the License, or (at your option)
|
21 |
|
|
// any later version.
|
22 |
|
|
//
|
23 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
24 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
25 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
26 |
|
|
// more details.
|
27 |
|
|
//
|
28 |
|
|
// You should have received a copy of the GNU General Public License along with
|
29 |
|
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
30 |
|
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
31 |
|
|
//
|
32 |
|
|
// ----------------------------------------------------------------------------
|
33 |
|
|
//
|
34 |
|
|
//####COPYRIGHTEND####
|
35 |
|
|
//==========================================================================
|
36 |
|
|
//#####DESCRIPTIONBEGIN####
|
37 |
|
|
//
|
38 |
|
|
// Author(s): nickg from an original by hmt
|
39 |
|
|
// Contributors: nickg
|
40 |
|
|
// Date: 1997-09-08
|
41 |
|
|
// Purpose: share unambiguously sized types.
|
42 |
|
|
// Description: we typedef [cyg_][u]int8,16,32 &c for general use.
|
43 |
|
|
// Usage: #include "cyg/infra/cyg_type.h"
|
44 |
|
|
// ...
|
45 |
|
|
// cyg_int32 my_32bit_integer;
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
|
50 |
|
|
#include <stddef.h> // Definition of NULL from the compiler
|
51 |
|
|
|
52 |
|
|
// -------------------------------------------------------------------------
|
53 |
|
|
// Some useful macros. These are defined here by default.
|
54 |
|
|
|
55 |
|
|
// externC is used in mixed C/C++ headers to force C linkage on an external
|
56 |
|
|
// definition. It avoids having to put all sorts of ifdefs in.
|
57 |
|
|
|
58 |
|
|
#ifdef __cplusplus
|
59 |
|
|
# define externC extern "C"
|
60 |
|
|
#else
|
61 |
|
|
# define externC extern
|
62 |
|
|
#endif
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
// -------------------------------------------------------------------------
|
66 |
|
|
// The header <basetype.h> defines the base types used here. It is
|
67 |
|
|
// supplied either by the target architecture HAL, or by the host
|
68 |
|
|
// porting kit. They are all defined as macros, and only those that
|
69 |
|
|
// make choices other than the defaults given below need be defined.
|
70 |
|
|
|
71 |
|
|
#define CYG_LSBFIRST 1234
|
72 |
|
|
#define CYG_MSBFIRST 4321
|
73 |
|
|
|
74 |
|
|
#include <cyg/hal/basetype.h>
|
75 |
|
|
|
76 |
|
|
#if (CYG_BYTEORDER != CYG_LSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)
|
77 |
|
|
# error You must define CYG_BYTEORDER to equal CYG_LSBFIRST or CYG_MSBFIRST
|
78 |
|
|
#endif
|
79 |
|
|
|
80 |
|
|
#ifndef CYG_DOUBLE_BYTEORDER
|
81 |
|
|
#define CYG_DOUBLE_BYTEORDER CYG_BYTEORDER
|
82 |
|
|
#endif
|
83 |
|
|
|
84 |
|
|
#ifndef cyg_halint8
|
85 |
|
|
# define cyg_halint8 char
|
86 |
|
|
#endif
|
87 |
|
|
#ifndef cyg_halint16
|
88 |
|
|
# define cyg_halint16 short
|
89 |
|
|
#endif
|
90 |
|
|
#ifndef cyg_halint32
|
91 |
|
|
# define cyg_halint32 int
|
92 |
|
|
#endif
|
93 |
|
|
#ifndef cyg_halint64
|
94 |
|
|
# define cyg_halint64 long long
|
95 |
|
|
#endif
|
96 |
|
|
|
97 |
|
|
#ifndef cyg_halcount8
|
98 |
|
|
# define cyg_halcount8 int
|
99 |
|
|
#endif
|
100 |
|
|
#ifndef cyg_halcount16
|
101 |
|
|
# define cyg_halcount16 int
|
102 |
|
|
#endif
|
103 |
|
|
#ifndef cyg_halcount32
|
104 |
|
|
# define cyg_halcount32 int
|
105 |
|
|
#endif
|
106 |
|
|
#ifndef cyg_halcount64
|
107 |
|
|
# define cyg_halcount64 long long
|
108 |
|
|
#endif
|
109 |
|
|
|
110 |
|
|
#ifndef cyg_haladdress
|
111 |
|
|
# define cyg_haladdress cyg_uint32
|
112 |
|
|
#endif
|
113 |
|
|
#ifndef cyg_haladdrword
|
114 |
|
|
# define cyg_haladdrword cyg_uint32
|
115 |
|
|
#endif
|
116 |
|
|
|
117 |
|
|
#ifndef cyg_halbool
|
118 |
|
|
# ifdef __cplusplus
|
119 |
|
|
# define cyg_halbool bool
|
120 |
|
|
# else
|
121 |
|
|
# define cyg_halbool int
|
122 |
|
|
# endif
|
123 |
|
|
#endif
|
124 |
|
|
|
125 |
|
|
#ifndef cyg_halatomic
|
126 |
|
|
# define cyg_halatomic cyg_halint8
|
127 |
|
|
#endif
|
128 |
|
|
|
129 |
|
|
// -------------------------------------------------------------------------
|
130 |
|
|
// The obvious few that compilers may define for you.
|
131 |
|
|
// But in case they don't:
|
132 |
|
|
|
133 |
|
|
#ifndef NULL
|
134 |
|
|
# define NULL 0
|
135 |
|
|
#endif
|
136 |
|
|
|
137 |
|
|
#ifndef __cplusplus
|
138 |
|
|
|
139 |
|
|
typedef cyg_halbool bool;
|
140 |
|
|
|
141 |
|
|
# ifndef false
|
142 |
|
|
# define false 0
|
143 |
|
|
# endif
|
144 |
|
|
|
145 |
|
|
# ifndef true
|
146 |
|
|
# define true (!false)
|
147 |
|
|
# endif
|
148 |
|
|
|
149 |
|
|
#endif
|
150 |
|
|
|
151 |
|
|
// -------------------------------------------------------------------------
|
152 |
|
|
// Allow creation of procedure-like macros that are a single statement,
|
153 |
|
|
// and must be followed by a semi-colon
|
154 |
|
|
|
155 |
|
|
#define CYG_MACRO_START do {
|
156 |
|
|
#define CYG_MACRO_END } while (0)
|
157 |
|
|
|
158 |
|
|
#define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
|
159 |
|
|
|
160 |
|
|
#define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START \
|
161 |
|
|
_type_ __tmp1 = (_name_); \
|
162 |
|
|
_type_ __tmp2 = __tmp1; \
|
163 |
|
|
__tmp1 = __tmp2; \
|
164 |
|
|
CYG_MACRO_END
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
// -------------------------------------------------------------------------
|
168 |
|
|
// Reference a symbol without explicitly making use of it. Ensures that
|
169 |
|
|
// the object containing the symbol will be included when linking.
|
170 |
|
|
|
171 |
|
|
#define CYG_REFERENCE_OBJECT(__object__) \
|
172 |
|
|
CYG_MACRO_START \
|
173 |
|
|
static void *__cygvar_discard_me__ __attribute__ ((unused)) = \
|
174 |
|
|
&(__object__); \
|
175 |
|
|
CYG_MACRO_END
|
176 |
|
|
|
177 |
|
|
// -------------------------------------------------------------------------
|
178 |
|
|
// Define basic types for using integers in memory and structures;
|
179 |
|
|
// depends on compiler defaults and CPU type.
|
180 |
|
|
|
181 |
|
|
typedef unsigned cyg_halint8 cyg_uint8 ;
|
182 |
|
|
typedef signed cyg_halint8 cyg_int8 ;
|
183 |
|
|
|
184 |
|
|
typedef unsigned cyg_halint16 cyg_uint16 ;
|
185 |
|
|
typedef signed cyg_halint16 cyg_int16 ;
|
186 |
|
|
|
187 |
|
|
typedef unsigned cyg_halint32 cyg_uint32 ;
|
188 |
|
|
typedef signed cyg_halint32 cyg_int32 ;
|
189 |
|
|
|
190 |
|
|
typedef unsigned cyg_halint64 cyg_uint64 ;
|
191 |
|
|
typedef signed cyg_halint64 cyg_int64 ;
|
192 |
|
|
|
193 |
|
|
typedef cyg_halbool cyg_bool ;
|
194 |
|
|
|
195 |
|
|
// -------------------------------------------------------------------------
|
196 |
|
|
// Define types for using integers in registers for looping and the like;
|
197 |
|
|
// depends on CPU type, choose what it is most comfortable with, with at
|
198 |
|
|
// least the range required.
|
199 |
|
|
|
200 |
|
|
typedef unsigned cyg_halcount8 cyg_ucount8 ;
|
201 |
|
|
typedef signed cyg_halcount8 cyg_count8 ;
|
202 |
|
|
|
203 |
|
|
typedef unsigned cyg_halcount16 cyg_ucount16 ;
|
204 |
|
|
typedef signed cyg_halcount16 cyg_count16 ;
|
205 |
|
|
|
206 |
|
|
typedef unsigned cyg_halcount32 cyg_ucount32 ;
|
207 |
|
|
typedef signed cyg_halcount32 cyg_count32 ;
|
208 |
|
|
|
209 |
|
|
typedef unsigned cyg_halcount64 cyg_ucount64 ;
|
210 |
|
|
typedef signed cyg_halcount64 cyg_count64 ;
|
211 |
|
|
|
212 |
|
|
// -------------------------------------------------------------------------
|
213 |
|
|
// Define a type to be used for atomic accesses. This type is guaranteed
|
214 |
|
|
// to be read or written in a single uninterruptible operation. This type
|
215 |
|
|
// is at least a single byte.
|
216 |
|
|
|
217 |
|
|
typedef volatile unsigned cyg_halatomic cyg_atomic;
|
218 |
|
|
typedef volatile unsigned cyg_halatomic CYG_ATOMIC;
|
219 |
|
|
|
220 |
|
|
// -------------------------------------------------------------------------
|
221 |
|
|
// Define types for access plain, on-the-metal memory or devices.
|
222 |
|
|
|
223 |
|
|
typedef cyg_uint32 CYG_WORD;
|
224 |
|
|
typedef cyg_uint8 CYG_BYTE;
|
225 |
|
|
typedef cyg_uint16 CYG_WORD16;
|
226 |
|
|
typedef cyg_uint32 CYG_WORD32;
|
227 |
|
|
typedef cyg_uint64 CYG_WORD64;
|
228 |
|
|
|
229 |
|
|
typedef cyg_haladdress CYG_ADDRESS;
|
230 |
|
|
typedef cyg_haladdrword CYG_ADDRWORD;
|
231 |
|
|
|
232 |
|
|
// -------------------------------------------------------------------------
|
233 |
|
|
// Constructor ordering macros. These are added as annotations to all
|
234 |
|
|
// static objects to order the constuctors appropriately.
|
235 |
|
|
|
236 |
|
|
#if defined(__cplusplus) && defined(__GNUC__)
|
237 |
|
|
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ ) __attribute__((init_priority(_pri_)))
|
238 |
|
|
#else
|
239 |
|
|
// FIXME: should maybe just bomb out if this is attempted anywhere else?
|
240 |
|
|
// Not sure
|
241 |
|
|
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ )
|
242 |
|
|
#endif
|
243 |
|
|
|
244 |
|
|
// The following will be removed eventually as it doesn't allow the use of
|
245 |
|
|
// e.g. pri+5 format
|
246 |
|
|
#define CYG_INIT_PRIORITY( _pri_ ) CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_##_pri_ )
|
247 |
|
|
|
248 |
|
|
#define CYGBLD_ATTRIB_INIT_BEFORE( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_-100)
|
249 |
|
|
#define CYGBLD_ATTRIB_INIT_AFTER( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_+100)
|
250 |
|
|
|
251 |
|
|
#define CYG_INIT_HAL 10000
|
252 |
|
|
#define CYG_INIT_SCHEDULER 11000
|
253 |
|
|
#define CYG_INIT_INTERRUPTS 12000
|
254 |
|
|
#define CYG_INIT_DRIVERS 13000
|
255 |
|
|
#define CYG_INIT_CLOCK 14000
|
256 |
|
|
#define CYG_INIT_IDLE_THREAD 15000
|
257 |
|
|
#define CYG_INIT_THREADS 16000
|
258 |
|
|
#define CYG_INIT_KERNEL 40000
|
259 |
|
|
#define CYG_INIT_IO 49000
|
260 |
|
|
#define CYG_INIT_LIBC 50000
|
261 |
|
|
#define CYG_INIT_COMPAT 55000
|
262 |
|
|
#define CYG_INIT_APPLICATION 60000
|
263 |
|
|
#define CYG_INIT_PREDEFAULT 65534
|
264 |
|
|
#define CYG_INIT_DEFAULT 65535
|
265 |
|
|
|
266 |
|
|
// -------------------------------------------------------------------------
|
267 |
|
|
// COMPILER-SPECIFIC STUFF
|
268 |
|
|
|
269 |
|
|
#ifdef __GNUC__
|
270 |
|
|
// Force a 'C' routine to be called like a 'C++' contructor
|
271 |
|
|
# define CYGBLD_ATTRIB_CONSTRUCTOR __attribute__((constructor))
|
272 |
|
|
|
273 |
|
|
// Define a compiler-specific rune for saying a function doesn't return
|
274 |
|
|
# define CYGBLD_ATTRIB_NORET __attribute__((noreturn))
|
275 |
|
|
|
276 |
|
|
// How to define weak symbols - this is only relevant for ELF and a.out,
|
277 |
|
|
// but that won't be a problem for eCos
|
278 |
|
|
# define CYGBLD_ATTRIB_WEAK __attribute__ ((weak))
|
279 |
|
|
|
280 |
|
|
// How to define alias to symbols. Just pass in the symbol itself, not
|
281 |
|
|
// the string name of the symbol
|
282 |
|
|
# define CYGBLD_ATTRIB_ALIAS(__symbol__) \
|
283 |
|
|
__attribute__ ((alias (#__symbol__)))
|
284 |
|
|
|
285 |
|
|
// This effectively does the reverse of the previous macro. It defines
|
286 |
|
|
// a name that the attributed variable or function will actually have
|
287 |
|
|
// in assembler.
|
288 |
|
|
# define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) \
|
289 |
|
|
__asm__ ( #__symbol__ )
|
290 |
|
|
|
291 |
|
|
// Shows that a function returns the same value when given the same args, but
|
292 |
|
|
// note this can't be used if there are pointer args
|
293 |
|
|
# define CYGBLD_ATTRIB_CONST __attribute__((const))
|
294 |
|
|
|
295 |
|
|
#else // non-GNU
|
296 |
|
|
|
297 |
|
|
# define CYGBLD_ATTRIB_CONSTRUCTOR
|
298 |
|
|
|
299 |
|
|
# define CYGBLD_ATTRIB_NORET
|
300 |
|
|
// This intentionally gives an error only if we actually try to
|
301 |
|
|
// use it. #error would give an error if we simple can't.
|
302 |
|
|
# define CYGBLD_ATTRIB_WEAK !!!-- Attribute weak not defined --!!!
|
303 |
|
|
|
304 |
|
|
# define CYGBLD_ATTRIB_ALIAS(__x__) !!!-- Attribute alias not defined --!!!
|
305 |
|
|
|
306 |
|
|
# define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) !!!-- Asm alias not defined --!!!
|
307 |
|
|
|
308 |
|
|
# define CYGBLD_ATTRIB_CONST
|
309 |
|
|
|
310 |
|
|
#endif
|
311 |
|
|
|
312 |
|
|
// How to define weak aliases. Currently this is simply a mixture of the
|
313 |
|
|
// above
|
314 |
|
|
|
315 |
|
|
# define CYGBLD_ATTRIB_WEAK_ALIAS(__symbol__) \
|
316 |
|
|
CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__)
|
317 |
|
|
|
318 |
|
|
// -------------------------------------------------------------------------
|
319 |
|
|
// Label name macro. Some toolsets generate labels with initial
|
320 |
|
|
// underscores and others don't. This macro should be used on labels
|
321 |
|
|
// that are defined in assembly code or linker scripts so that we can
|
322 |
|
|
// do the right thing.
|
323 |
|
|
|
324 |
|
|
#ifndef CYG_LABEL_NAME
|
325 |
|
|
|
326 |
|
|
#define CYG_LABEL_NAME(_name_) _name_
|
327 |
|
|
|
328 |
|
|
#endif
|
329 |
|
|
|
330 |
|
|
// -------------------------------------------------------------------------
|
331 |
|
|
// Various "flavours" of memory regions that can be described by the
|
332 |
|
|
// Memory Layout Tool (MLT).
|
333 |
|
|
|
334 |
|
|
#define CYGMEM_REGION_ATTR_R 0x01 // Region can be read
|
335 |
|
|
#define CYGMEM_REGION_ATTR_W 0x02 // Region can be written
|
336 |
|
|
|
337 |
|
|
// -------------------------------------------------------------------------
|
338 |
|
|
#endif // CYGONCE_INFRA_CYG_TYPE_H multiple inclusion protection
|
339 |
|
|
// EOF cyg_type.h
|