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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [infra/] [cyg_type.h] - Blame information for rev 790

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

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

powered by: WebSVN 2.1.0

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