OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [infra/] [v2_0/] [include/] [cyg_type.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
#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
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):   nickg from an original by hmt
47
// Contributors:  nickg
48
// Date:        1997-09-08
49
// Purpose:     share unambiguously sized types.
50
// Description: we typedef [cyg_][u]int8,16,32 &c for general use.
51
// Usage:       #include "cyg/infra/cyg_type.h"
52
//              ...
53
//              cyg_int32 my_32bit_integer;
54
//              
55
//####DESCRIPTIONEND####
56
//
57
 
58
#include <stddef.h>           // Definition of NULL from the compiler
59
 
60
// -------------------------------------------------------------------------
61
// Some useful macros. These are defined here by default.
62
 
63
// __externC is used in mixed C/C++ headers to force C linkage on an external
64
// definition. It avoids having to put all sorts of ifdefs in.
65
 
66
#ifdef __cplusplus
67
# define __externC extern "C"
68
#else
69
# define __externC extern
70
#endif
71
// Also define externC for now - but it is deprecated
72
#define externC __externC
73
 
74
// -------------------------------------------------------------------------
75
// The header <basetype.h> defines the base types used here. It is
76
// supplied either by the target architecture HAL, or by the host
77
// porting kit. They are all defined as macros, and only those that
78
// make choices other than the defaults given below need be defined.
79
 
80
#define CYG_LSBFIRST 1234
81
#define CYG_MSBFIRST 4321
82
 
83
#include <cyg/hal/basetype.h>
84
 
85
#if (CYG_BYTEORDER != CYG_LSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)
86
# error You must define CYG_BYTEORDER to equal CYG_LSBFIRST or CYG_MSBFIRST
87
#endif
88
 
89
#ifndef CYG_DOUBLE_BYTEORDER
90
#define CYG_DOUBLE_BYTEORDER CYG_BYTEORDER
91
#endif
92
 
93
#ifndef cyg_halint8
94
# define cyg_halint8 char
95
#endif
96
#ifndef cyg_halint16
97
# define cyg_halint16 short
98
#endif
99
#ifndef cyg_halint32
100
# define cyg_halint32 int
101
#endif
102
#ifndef cyg_halint64
103
# define cyg_halint64 long long
104
#endif
105
 
106
#ifndef cyg_halcount8
107
# define cyg_halcount8 int
108
#endif
109
#ifndef cyg_halcount16
110
# define cyg_halcount16 int
111
#endif
112
#ifndef cyg_halcount32
113
# define cyg_halcount32 int
114
#endif
115
#ifndef cyg_halcount64
116
# define cyg_halcount64 long long
117
#endif
118
 
119
#ifndef cyg_haladdress
120
# define cyg_haladdress cyg_uint32
121
#endif
122
#ifndef cyg_haladdrword
123
# define cyg_haladdrword cyg_uint32
124
#endif
125
 
126
#ifndef cyg_halbool
127
# define cyg_halbool int
128
#endif
129
 
130
#ifndef cyg_halatomic
131
# define cyg_halatomic cyg_halint8
132
#endif
133
 
134
// -------------------------------------------------------------------------
135
// Provide a default architecture alignment
136
// This may be overridden in basetype.h if necessary.
137
// These should be straightforward numbers to allow use in assembly.
138
 
139
#ifndef CYGARC_ALIGNMENT
140
# define CYGARC_ALIGNMENT 8
141
#endif
142
// And corresponding power of two alignment
143
#ifndef CYGARC_P2ALIGNMENT
144
# define CYGARC_P2ALIGNMENT 3
145
#endif
146
#if (CYGARC_ALIGNMENT) != (1 << CYGARC_P2ALIGNMENT)
147
# error "Inconsistent CYGARC_ALIGNMENT and CYGARC_P2ALIGNMENT values"
148
#endif
149
 
150
// -------------------------------------------------------------------------
151
// The obvious few that compilers may define for you.
152
// But in case they don't:
153
 
154
#ifndef NULL
155
# define NULL 0
156
#endif
157
 
158
#ifndef __cplusplus
159
 
160
typedef cyg_halbool bool;
161
 
162
# ifndef false
163
#  define false 0
164
# endif
165
 
166
# ifndef true
167
#  define true (!false)
168
# endif
169
 
170
#endif
171
 
172
// -------------------------------------------------------------------------
173
// Allow creation of procedure-like macros that are a single statement,
174
// and must be followed by a semi-colon
175
 
176
#define CYG_MACRO_START do {
177
#define CYG_MACRO_END   } while (0)
178
 
179
#define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
180
 
181
#define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START      \
182
  _type_ __tmp1 = (_name_);                                     \
183
  _type_ __tmp2 = __tmp1;                                       \
184
  __tmp1 = __tmp2;                                              \
185
CYG_MACRO_END
186
 
187
 
188
// -------------------------------------------------------------------------
189
// Reference a symbol without explicitly making use of it. Ensures that
190
// the object containing the symbol will be included when linking.
191
 
192
#define CYG_REFERENCE_OBJECT(__object__)                                 \
193
     CYG_MACRO_START                                                     \
194
     static void *__cygvar_discard_me__ __attribute__ ((unused)) =       \
195
                                                          &(__object__); \
196
     CYG_MACRO_END
197
 
198
// -------------------------------------------------------------------------
199
// Define basic types for using integers in memory and structures;
200
// depends on compiler defaults and CPU type.
201
 
202
typedef unsigned cyg_halint8    cyg_uint8  ;
203
typedef   signed cyg_halint8    cyg_int8   ;
204
 
205
typedef unsigned cyg_halint16   cyg_uint16 ;
206
typedef   signed cyg_halint16   cyg_int16  ;
207
 
208
typedef unsigned cyg_halint32   cyg_uint32 ;
209
typedef   signed cyg_halint32   cyg_int32  ;
210
 
211
typedef unsigned cyg_halint64   cyg_uint64 ;
212
typedef   signed cyg_halint64   cyg_int64  ;
213
 
214
typedef  cyg_halbool            cyg_bool   ;
215
 
216
// -------------------------------------------------------------------------
217
// Define types for using integers in registers for looping and the like;
218
// depends on CPU type, choose what it is most comfortable with, with at
219
// least the range required.
220
 
221
typedef unsigned cyg_halcount8  cyg_ucount8  ;
222
typedef   signed cyg_halcount8  cyg_count8   ;
223
 
224
typedef unsigned cyg_halcount16 cyg_ucount16 ;
225
typedef   signed cyg_halcount16 cyg_count16  ;
226
 
227
typedef unsigned cyg_halcount32 cyg_ucount32 ;
228
typedef   signed cyg_halcount32 cyg_count32  ;
229
 
230
typedef unsigned cyg_halcount64 cyg_ucount64 ;
231
typedef   signed cyg_halcount64 cyg_count64  ;
232
 
233
// -------------------------------------------------------------------------
234
// Define a type to be used for atomic accesses. This type is guaranteed
235
// to be read or written in a single uninterruptible operation. This type
236
// is at least a single byte.
237
 
238
typedef volatile unsigned cyg_halatomic  cyg_atomic;
239
typedef volatile unsigned cyg_halatomic  CYG_ATOMIC;
240
 
241
// -------------------------------------------------------------------------
242
// Define types for access plain, on-the-metal memory or devices.
243
 
244
typedef cyg_uint32  CYG_WORD;
245
typedef cyg_uint8   CYG_BYTE;
246
typedef cyg_uint16  CYG_WORD16;
247
typedef cyg_uint32  CYG_WORD32;
248
typedef cyg_uint64  CYG_WORD64;
249
 
250
typedef cyg_haladdress  CYG_ADDRESS;
251
typedef cyg_haladdrword CYG_ADDRWORD;
252
 
253
// -------------------------------------------------------------------------
254
// Constructor ordering macros.  These are added as annotations to all
255
// static objects to order the constuctors appropriately.
256
 
257
#if defined(__cplusplus) && defined(__GNUC__) && \
258
    !defined(CYGBLD_ATTRIB_INIT_PRI)
259
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ ) __attribute__((init_priority(_pri_)))
260
#elif !defined(CYGBLD_ATTRIB_INIT_PRI)
261
// FIXME: should maybe just bomb out if this is attempted anywhere else?
262
// Not sure
263
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ )
264
#endif
265
 
266
// The following will be removed eventually as it doesn't allow the use of
267
// e.g. pri+5 format
268
#define CYG_INIT_PRIORITY( _pri_ ) CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_##_pri_ )
269
 
270
#define CYGBLD_ATTRIB_INIT_BEFORE( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_-100)
271
#define CYGBLD_ATTRIB_INIT_AFTER( _pri_ )  CYGBLD_ATTRIB_INIT_PRI(_pri_+100)
272
 
273
#define CYG_INIT_HAL                    10000
274
#define CYG_INIT_SCHEDULER              11000
275
#define CYG_INIT_INTERRUPTS             12000
276
#define CYG_INIT_DRIVERS                13000
277
#define CYG_INIT_CLOCK                  14000
278
#define CYG_INIT_IDLE_THREAD            15000
279
#define CYG_INIT_THREADS                16000
280
#define CYG_INIT_KERNEL                 40000
281
#define CYG_INIT_MEMALLOC               47000
282
#define CYG_INIT_IO                     49000
283
#define CYG_INIT_IO_FS                  50000
284
#define CYG_INIT_LIBC                   52000
285
#define CYG_INIT_COMPAT                 55000
286
#define CYG_INIT_APPLICATION            60000
287
#define CYG_INIT_PREDEFAULT             65534
288
#define CYG_INIT_DEFAULT                65535
289
 
290
// -------------------------------------------------------------------------
291
// Label name macros. Some toolsets generate labels with initial
292
// underscores and others don't. CYG_LABEL_NAME should be used on
293
// labels in C/C++ code that are defined in assembly code or linker
294
// scripts. CYG_LABEL_DEFN is for use in assembly code and linker
295
// scripts where we need to manufacture labels that can be used from
296
// C/C++.
297
// These are default implementations that should work for most targets.
298
// They may be overridden in basetype.h if necessary.
299
 
300
#ifndef CYG_LABEL_NAME
301
 
302
#define CYG_LABEL_NAME(_name_) _name_
303
 
304
#endif
305
 
306
#ifndef CYG_LABEL_DEFN
307
 
308
#define CYG_LABEL_DEFN(_label) _label
309
 
310
#endif
311
 
312
// -------------------------------------------------------------------------
313
// COMPILER-SPECIFIC STUFF
314
 
315
#ifdef __GNUC__
316
// Force a 'C' routine to be called like a 'C++' contructor
317
# if !defined(CYGBLD_ATTRIB_CONSTRUCTOR)
318
#  define CYGBLD_ATTRIB_CONSTRUCTOR __attribute__((constructor))
319
# endif
320
 
321
// Define a compiler-specific rune for saying a function doesn't return
322
# if !defined(CYGBLD_ATTRIB_NORET)
323
#  define CYGBLD_ATTRIB_NORET __attribute__((noreturn))
324
# endif
325
 
326
// How to define weak symbols - this is only relevant for ELF and a.out,
327
// but that won't be a problem for eCos
328
# if !defined(CYGBLD_ATTRIB_WEAK)
329
#  define CYGBLD_ATTRIB_WEAK __attribute__ ((weak))
330
# endif
331
 
332
// How to define alias to symbols. Just pass in the symbol itself, not
333
// the string name of the symbol
334
# if !defined(CYGBLD_ATTRIB_ALIAS)
335
#  define CYGBLD_ATTRIB_ALIAS(__symbol__) \
336
        __attribute__ ((alias (#__symbol__)))
337
# endif
338
 
339
// This effectively does the reverse of the previous macro. It defines
340
// a name that the attributed variable or function will actually have
341
// in assembler.
342
# if !defined(CYGBLD_ATTRIB_ASM_ALIAS)
343
#  define __Str(x) #x
344
#  define __Xstr(x) __Str(x)
345
#  define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) \
346
             __asm__ ( __Xstr( CYG_LABEL_DEFN( __symbol__ ) ) )
347
# endif
348
 
349
// Shows that a function returns the same value when given the same args, but
350
// note this can't be used if there are pointer args
351
# if !defined(CYGBLD_ATTRIB_CONST)
352
#  define CYGBLD_ATTRIB_CONST __attribute__((const))
353
#endif
354
 
355
// Assign a defined variable to a specific section
356
# if !defined(CYGBLD_ATTRIB_SECTION)
357
#  define CYGBLD_ATTRIB_SECTION(__sect__) __attribute__((section (__sect__)))
358
# endif
359
 
360
// Give a type or object explicit minimum alignment
361
# if !defined(CYGBLD_ATTRIB_ALIGN)
362
#  define CYGBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
363
# endif
364
 
365
// Teach compiler how to check format of printf-like functions
366
# define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \
367
        __attribute__((format (printf, __format__, __args__)))
368
 
369
#else // non-GNU
370
 
371
# define CYGBLD_ATTRIB_CONSTRUCTOR
372
 
373
# define CYGBLD_ATTRIB_NORET
374
    // This intentionally gives an error only if we actually try to
375
    // use it.  #error would give an error if we simply can't.
376
// FIXME: Had to disarm the bomb - the CYGBLD_ATTRIB_WEAK macro is now
377
//        (indirectly) used in host tools.
378
# define CYGBLD_ATTRIB_WEAK /* !!!-- Attribute weak not defined --!!! */
379
 
380
# define CYGBLD_ATTRIB_ALIAS(__x__) !!!-- Attribute alias not defined --!!!
381
 
382
# define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) !!!-- Asm alias not defined --!!!
383
 
384
# define CYGBLD_ATTRIB_CONST
385
 
386
# define CYGBLD_ATTRIB_ALIGN(__align__) !!!-- Alignment alias not defined --!!!
387
 
388
# define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__)
389
 
390
#endif
391
 
392
// How to define weak aliases. Currently this is simply a mixture of the
393
// above
394
 
395
# define CYGBLD_ATTRIB_WEAK_ALIAS(__symbol__) \
396
        CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__)
397
 
398
#ifdef __cplusplus
399
# define __THROW throw()
400
#else
401
# define __THROW
402
#endif
403
 
404
// -------------------------------------------------------------------------
405
// Variable annotations
406
// These annotations may be added to various static variables in the
407
// HAL and kernel to indicate which component they belong to. These
408
// are used by some targets to optimize memory placement of these
409
// variables.
410
 
411
#ifndef CYGBLD_ANNOTATE_VARIABLE_HAL
412
#define CYGBLD_ANNOTATE_VARIABLE_HAL
413
#endif
414
#ifndef CYGBLD_ANNOTATE_VARIABLE_SCHED
415
#define CYGBLD_ANNOTATE_VARIABLE_SCHED
416
#endif
417
#ifndef CYGBLD_ANNOTATE_VARIABLE_CLOCK
418
#define CYGBLD_ANNOTATE_VARIABLE_CLOCK
419
#endif
420
#ifndef CYGBLD_ANNOTATE_VARIABLE_INTR
421
#define CYGBLD_ANNOTATE_VARIABLE_INTR
422
#endif
423
 
424
// -------------------------------------------------------------------------
425
// Various "flavours" of memory regions that can be described by the 
426
// Memory Layout Tool (MLT).
427
 
428
#define CYGMEM_REGION_ATTR_R  0x01  // Region can be read
429
#define CYGMEM_REGION_ATTR_W  0x02  // Region can be written
430
 
431
// -------------------------------------------------------------------------
432
#endif // CYGONCE_INFRA_CYG_TYPE_H multiple inclusion protection
433
// EOF cyg_type.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.