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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [include/] [kapidata.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_KERNEL_KAPIDATA_H
2
#define CYGONCE_KERNEL_KAPIDATA_H
3
 
4
/*=============================================================================
5
//
6
//      kapidata.h
7
//
8
//      Native API data structures
9
//
10
//==========================================================================
11
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 2002 Bart Veer
15
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
16
//
17
// eCos is free software; you can redistribute it and/or modify it under
18
// the terms of the GNU General Public License as published by the Free
19
// Software Foundation; either version 2 or (at your option) any later version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
22
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License along
27
// with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29
//
30
// As a special exception, if other files instantiate templates or use macros
31
// or inline functions from this file, or you compile this file and link it
32
// with other works to produce a work based on this file, this file does not
33
// by itself cause the resulting work to be covered by the GNU General Public
34
// License. However the source code for this file must still be made available
35
// in accordance with section (3) of the GNU General Public License.
36
//
37
// This exception does not invalidate any other reasons why a work based on
38
// this file might be covered by the GNU General Public License.
39
//
40
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
41
// at http://sources.redhat.com/ecos/ecos-license/
42
// -------------------------------------------
43
//####ECOSGPLCOPYRIGHTEND####
44
//==========================================================================
45
//#####DESCRIPTIONBEGIN####
46
//
47
// Author(s):   nickg
48
// Contributors:        nickg
49
// Date:        1998-03-13
50
// Purpose:     Native API data structures
51
// Description: This file defines the structures used in the native API. The
52
//              sizes of these structures are dependent on the system
53
//              configuration and must be kept in step with their real
54
//              counterparts in the C++ headers.
55
//              IMPORTANT: It is NOT guaranteed that the fields of these
56
//              structures correspond to the equivalent fields in the
57
//              C++ classes they shadow.
58
//
59
//              One oddity with this file is that the way many of the "mirror"
60
//              classes are defined with macros. The resulting structures
61
//              then have a "flat" layout, rather than just declaring a
62
//              member structure directly in the structure. The reason for
63
//              this is that as of GCC 3.x, the C++ compiler will optimise
64
//              classes by removing padding and reusing it for subsequent
65
//              members defined in a derived class. This affects some targets
66
//              (including PowerPC and MIPS at least) when a C++ base class
67
//              includes a long long. By instead arranging for the C structure
68
//              to just list all the members directly, the compiler will then
69
//              behave the same for the C structures as the C++ classes.
70
//
71
//              This means that care has to be taken to follow the same
72
//              methodology if new stuff is added to this file. Even if
73
//              it doesn't contain long longs for your target, it may for
74
//              others, depending on HAL definitions.
75
//
76
// Usage:       included by kapi.h
77
//
78
//####DESCRIPTIONEND####
79
//
80
//==========================================================================*/
81
 
82
#include <pkgconf/system.h>
83
#include <pkgconf/kernel.h>
84
 
85
#include <cyg/infra/cyg_type.h>
86
#include <cyg/hal/hal_intr.h>           // exception defines
87
 
88
/*---------------------------------------------------------------------------*/
89
 
90
#ifdef __cplusplus
91
extern "C" {
92
#endif
93
 
94
/*---------------------------------------------------------------------------*/
95
 
96
#ifndef CYGNUM_KERNEL_SCHED_BITMAP_SIZE
97
#if defined(CYGSEM_KERNEL_SCHED_MLQUEUE)
98
#define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32
99
#elif defined(CYGSEM_KERNEL_SCHED_BITMAP)
100
#define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32
101
#endif
102
#endif
103
 
104
#if CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 8
105
typedef cyg_ucount8 cyg_sched_bitmap;
106
#elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 16
107
typedef cyg_ucount16 cyg_sched_bitmap;
108
#elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 32
109
typedef cyg_ucount32 cyg_sched_bitmap;
110
#elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 64
111
typedef cyg_ucount64 cyg_sched_bitmap;
112
#else
113
#error Bitmaps greater than 64 bits not currently allowed
114
#endif
115
 
116
typedef struct
117
{
118
#if defined(CYGSEM_KERNEL_SCHED_BITMAP)
119
 
120
    cyg_sched_bitmap map;
121
 
122
#elif defined(CYGSEM_KERNEL_SCHED_MLQUEUE)
123
 
124
    cyg_thread *queue;
125
 
126
#elif defined(CYGSEM_KERNEL_SCHED_LOTTERY)
127
 
128
    cyg_thread *queue;
129
 
130
#else
131
 
132
#error Undefined scheduler type
133
 
134
#endif    
135
} cyg_threadqueue;
136
 
137
/*---------------------------------------------------------------------------*/
138
 
139
struct cyg_interrupt
140
{
141
    cyg_vector_t        vector;
142
    cyg_priority_t      priority;
143
    cyg_ISR_t           *isr;
144
    cyg_DSR_t           *dsr;
145
    CYG_ADDRWORD        data;
146
 
147
#ifdef CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST
148
    cyg_ucount32        dsr_count;
149
    cyg_interrupt       *next_dsr;
150
#endif
151
#ifdef CYGIMP_KERNEL_INTERRUPTS_CHAIN
152
    cyg_interrupt       *next;
153
#endif
154
};
155
 
156
 
157
/*---------------------------------------------------------------------------*/
158
 
159
 
160
#if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST)
161
# define CYG_COUNTER_ALARM_LIST_MEMBER \
162
    cyg_alarm           *alarm_list;
163
#elif defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST)
164
# define CYG_COUNTER_ALARM_LIST_MEMBER \
165
    cyg_alarm           *alarm_list[CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE];
166
#else
167
# define CYG_COUNTER_ALARM_LIST_MEMBER
168
#endif
169
 
170
#define CYG_COUNTER_MEMBERS              \
171
    CYG_COUNTER_ALARM_LIST_MEMBER        \
172
    cyg_tick_count_t    counter;         \
173
    cyg_uint32          increment;
174
 
175
struct cyg_counter
176
{
177
    CYG_COUNTER_MEMBERS
178
};
179
 
180
/*---------------------------------------------------------------------------*/
181
 
182
struct cyg_clock
183
{
184
    CYG_COUNTER_MEMBERS
185
    CYG_RESOLUTION_T_MEMBERS
186
};
187
 
188
/*---------------------------------------------------------------------------*/
189
 
190
 
191
#if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST) ||  \
192
    defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST)
193
# define CYG_ALARM_LIST_MEMBERS                     \
194
    cyg_alarm           *next;                      \
195
    cyg_alarm           *prev;
196
#else 
197
# define CYG_ALARM_LIST_MEMBERS
198
#endif
199
 
200
#define CYG_ALARM_MEMBERS           \
201
    CYG_ALARM_LIST_MEMBERS          \
202
    cyg_counter         *counter;   \
203
    cyg_alarm_t         *alarm;     \
204
    CYG_ADDRWORD        data;       \
205
    cyg_tick_count_t    trigger;    \
206
    cyg_tick_count_t    interval;   \
207
    cyg_bool            enabled;
208
 
209
struct cyg_alarm
210
{
211
    CYG_ALARM_MEMBERS
212
};
213
 
214
/*---------------------------------------------------------------------------*/
215
/* Exception controller                                                      */
216
 
217
#ifdef CYGPKG_KERNEL_EXCEPTIONS
218
 
219
# ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
220
#  define CYG_EXCEPTION_CONTROL_MEMBERS                                     \
221
    cyg_exception_handler_t *exception_handler[CYGNUM_HAL_EXCEPTION_COUNT]; \
222
    CYG_ADDRWORD            exception_data[CYGNUM_HAL_EXCEPTION_COUNT];
223
# else
224
#  define CYG_EXCEPTION_CONTROL_MEMBERS                                \
225
    cyg_exception_handler_t *exception_handler; /* Handler function */ \
226
    CYG_ADDRWORD            exception_data;     /* Handler data */
227
# endif
228
 
229
typedef struct
230
{
231
    CYG_EXCEPTION_CONTROL_MEMBERS
232
} cyg_exception_control;
233
 
234
#endif
235
 
236
/*---------------------------------------------------------------------------*/
237
/* Hardware Thread structure                                                 */
238
 
239
#ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT
240
# define CYG_HARDWARETHREAD_STACK_LIMIT_MEMBER \
241
    CYG_ADDRESS         stack_limit;    /* movable stack limit */
242
#else
243
# define CYG_HARDWARETHREAD_STACK_LIMIT_MEMBER
244
#endif
245
 
246
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
247
# define CYG_HARDWARETHREAD_SAVED_CONTEXT_MEMBER \
248
    void                *saved_context; // If non-zero, this points at a more
249
                                        // interesting context than stack_ptr.
250
#else
251
# define CYG_HARDWARETHREAD_SAVED_CONTEXT_MEMBER
252
#endif
253
 
254
typedef void cyg_thread_entry(CYG_ADDRWORD data);
255
 
256
#define CYG_HARDWARETHREAD_MEMBERS                                           \
257
    CYG_ADDRESS         stack_base;   /* pointer to base of stack area */    \
258
    cyg_uint32          stack_size;   /* size of stack area in bytes */      \
259
    CYG_HARDWARETHREAD_STACK_LIMIT_MEMBER                                    \
260
    CYG_ADDRESS         stack_ptr;    /* pointer to saved state on stack */  \
261
    cyg_thread_entry   *entry_point;  /* main entry point (code pointer!) */ \
262
    CYG_ADDRWORD        entry_data;   /* entry point argument */             \
263
    CYG_HARDWARETHREAD_SAVED_CONTEXT_MEMBER
264
 
265
typedef struct
266
{
267
    CYG_HARDWARETHREAD_MEMBERS
268
} cyg_hardwarethread;
269
 
270
/*---------------------------------------------------------------------------*/
271
/* Scheduler Thread structure                                                */
272
 
273
#ifdef CYGPKG_KERNEL_SMP_SUPPORT
274
# define CYG_SCHEDTHREAD_CPU_MEMBER \
275
    cyg_uint32          cpu;            // CPU id of cpu currently running
276
#else
277
# define CYG_SCHEDTHREAD_CPU_MEMBER
278
#endif
279
 
280
#ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
281
# define CYG_SCHEDTHREAD_TIMESLICE_ENABLED_MEMBER \
282
    cyg_bool            timeslice_enabled; /* per-thread timeslice enable */
283
#else
284
# define CYG_SCHEDTHREAD_TIMESLICE_ENABLED_MEMBER
285
#endif
286
 
287
#if defined(CYGSEM_KERNEL_SCHED_BITMAP)
288
# define CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS \
289
    cyg_priority_t      priority;       /* current thread priority */
290
#elif defined(CYGSEM_KERNEL_SCHED_MLQUEUE)
291
# define CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS                                    \
292
    cyg_thread *next;                                                        \
293
    cyg_thread *prev;                                                        \
294
    cyg_priority_t      priority;             /* current thread priority */  \
295
    CYG_SCHEDTHREAD_CPU_MEMBER                                               \
296
    CYG_SCHEDTHREAD_TIMESLICE_ENABLED_MEMBER
297
#elif defined(CYGSEM_KERNEL_SCHED_LOTTERY)
298
# define CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS                                    \
299
    cyg_thread *next;                                                        \
300
    cyg_thread *prev;                                                        \
301
    cyg_priority_t      priority;             /* current thread priority */  \
302
    cyg_priority_t      compensation_tickets; /* sleep compensation */
303
#else
304
# error Undefined scheduler type
305
#endif    
306
 
307
#ifndef CYGSEM_KERNEL_SCHED_ASR_GLOBAL
308
#  define CYG_SCHEDTHREAD_ASR_NONGLOBAL_MEMBER \
309
    void              (*asr)(CYG_ADDRWORD);   // ASR function
310
#else
311
#  define CYG_SCHEDTHREAD_ASR_NONGLOBAL_MEMBER
312
#endif
313
 
314
#ifndef CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL
315
#  define CYG_SCHEDTHREAD_ASR_DATA_NONGLOBAL_MEMBER \
316
    CYG_ADDRWORD        asr_data;       // ASR data pointer
317
#else
318
#  define CYG_SCHEDTHREAD_ASR_DATA_NONGLOBAL_MEMBER
319
#endif
320
 
321
#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT
322
# define CYG_SCHEDTHREAD_ASR_MEMBER                                         \
323
    volatile cyg_ucount32 asr_inhibit; /* If true, blocks calls to ASRs */  \
324
    volatile cyg_bool     asr_pending; /* If true, this thread's ASR    */  \
325
                                       /* should be called. */              \
326
    CYG_SCHEDTHREAD_ASR_NONGLOBAL_MEMBER                                    \
327
    CYG_SCHEDTHREAD_ASR_DATA_NONGLOBAL_MEMBER
328
#else
329
# define CYG_SCHEDTHREAD_ASR_MEMBER
330
#endif
331
 
332
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE
333
# define CYG_SCHEDTHREAD_MUTEX_INV_PROTO_SIMPLE_MEMBERS \
334
    cyg_priority_t      original_priority;              \
335
    cyg_bool            priority_inherited;
336
#else
337
# define CYG_SCHEDTHREAD_MUTEX_INV_PROTO_SIMPLE_MEMBERS
338
#endif
339
 
340
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL
341
# define CYG_SCHEDTHREAD_MUTEX_INV_PROTO_MEMBERS   \
342
    cyg_count32         mutex_count;               \
343
    CYG_SCHEDTHREAD_MUTEX_INV_PROTO_SIMPLE_MEMBERS
344
#else
345
# define CYG_SCHEDTHREAD_MUTEX_INV_PROTO_MEMBERS
346
#endif
347
 
348
#define CYG_SCHEDTHREAD_MEMBERS               \
349
    CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS          \
350
    cyg_threadqueue     *queue;               \
351
    CYG_SCHEDTHREAD_ASR_MEMBER                \
352
    CYG_SCHEDTHREAD_MUTEX_INV_PROTO_MEMBERS
353
 
354
 
355
typedef struct
356
{
357
    CYG_SCHEDTHREAD_MEMBERS
358
} cyg_schedthread;
359
 
360
/* This compiler version test is required because the C++ ABI changed in
361
   GCC v3.x and GCC could now reuse "spare" space from base classes in derived
362
   classes, and in C++ land, cyg_alarm is a base class of cyg_threadtimer.
363
*/
364
#if defined(__GNUC__) && (__GNUC__ < 3)
365
#define CYG_THREADTIMER_MEMBERS \
366
    cyg_alarm           alarm;  \
367
    cyg_thread          *thread;
368
#else
369
#define CYG_THREADTIMER_MEMBERS \
370
    CYG_ALARM_MEMBERS           \
371
    cyg_thread          *thread;
372
#endif
373
 
374
/*---------------------------------------------------------------------------*/
375
/* Thread structure                                                          */
376
 
377
typedef struct
378
{
379
    CYG_THREADTIMER_MEMBERS
380
} cyg_threadtimer;
381
 
382
 
383
typedef enum
384
{
385
    CYG_REASON_NONE,
386
    CYG_REASON_WAIT,
387
    CYG_REASON_DELAY,
388
    CYG_REASON_TIMEOUT,
389
    CYG_REASON_BREAK,
390
    CYG_REASON_DESTRUCT,
391
    CYG_REASON_EXIT,
392
    CYG_REASON_DONE
393
} cyg_reason_t;
394
 
395
#if defined(CYGPKG_KERNEL_EXCEPTIONS) && !defined(CYGSEM_KERNEL_EXCEPTIONS_GLOBAL)
396
# define CYG_THREAD_EXCEPTION_CONTROL_MEMBER \
397
    cyg_exception_control       exception_control;
398
#else
399
# define CYG_THREAD_EXCEPTION_CONTROL_MEMBER
400
#endif
401
 
402
#ifdef CYGFUN_KERNEL_THREADS_TIMER
403
# define CYG_THREAD_TIMER_MEMBER \
404
    cyg_threadtimer     timer;
405
#else
406
# define CYG_THREAD_TIMER_MEMBER
407
#endif
408
 
409
#ifdef CYGVAR_KERNEL_THREADS_DATA
410
# define CYG_THREAD_THREAD_DATA_MEMBER \
411
    CYG_ADDRWORD        thread_data[CYGNUM_KERNEL_THREADS_DATA_MAX];
412
#else
413
# define CYG_THREAD_THREAD_DATA_MEMBER
414
#endif
415
 
416
#ifdef CYGVAR_KERNEL_THREADS_NAME
417
# define CYG_THREAD_NAME_MEMBER \
418
    char                *name;
419
#else
420
# define CYG_THREAD_NAME_MEMBER
421
#endif
422
 
423
#ifdef CYGVAR_KERNEL_THREADS_LIST
424
# define CYG_THREAD_LIST_NEXT_MEMBER \
425
    cyg_thread          *list_next;
426
#else
427
# define CYG_THREAD_LIST_NEXT_MEMBER
428
#endif
429
 
430
 
431
 
432
#ifdef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
433
struct Cyg_Destructor_Entry {
434
    cyg_thread_destructor_fn fn;
435
    cyg_addrword_t data;
436
};
437
# define CYG_THREAD_DESTRUCTORS_MEMBER \
438
   struct Cyg_Destructor_Entry destructors[ CYGNUM_KERNEL_THREADS_DESTRUCTORS ];
439
#else
440
# define CYG_THREAD_DESTRUCTORS_MEMBER
441
#endif
442
 
443
 
444
#define CYG_THREAD_MEMBERS                        \
445
    CYG_HARDWARETHREAD_MEMBERS                    \
446
    CYG_SCHEDTHREAD_MEMBERS                       \
447
                                                  \
448
    cyg_uint32                  state;            \
449
    cyg_ucount32                suspend_count;    \
450
    cyg_ucount32                wakeup_count;     \
451
    CYG_ADDRWORD                wait_info;        \
452
    cyg_uint16                  unique_id;        \
453
                                                  \
454
    CYG_THREAD_EXCEPTION_CONTROL_MEMBER           \
455
    CYG_THREAD_TIMER_MEMBER                       \
456
                                                  \
457
    cyg_reason_t        sleep_reason;             \
458
    cyg_reason_t        wake_reason;              \
459
                                                  \
460
    CYG_THREAD_THREAD_DATA_MEMBER                 \
461
    CYG_THREAD_DESTRUCTORS_MEMBER                 \
462
    CYG_THREAD_NAME_MEMBER                        \
463
    CYG_THREAD_LIST_NEXT_MEMBER
464
 
465
 
466
struct cyg_thread
467
{
468
    CYG_THREAD_MEMBERS
469
};
470
 
471
/*---------------------------------------------------------------------------*/
472
 
473
struct cyg_mbox
474
{
475
    cyg_count32         base;           /* index of first used slot          */
476
    cyg_count32         count;          /* count of used slots               */
477
    cyg_threadqueue     get_threadq;    /* Queue of waiting threads          */
478
#ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT
479
    cyg_threadqueue     put_threadq;    /* Queue of waiting threads          */
480
#endif
481
    void *              itemqueue[ CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE ];
482
};
483
 
484
/*---------------------------------------------------------------------------*/
485
 
486
struct cyg_sem_t
487
{
488
    cyg_count32         count;          /* The semaphore count          */
489
    cyg_threadqueue     queue;          /* Queue of waiting threads     */
490
};
491
 
492
/*---------------------------------------------------------------------------*/
493
 
494
struct cyg_flag_t
495
{
496
    cyg_flag_value_t    value;          /* The flag value               */
497
    cyg_threadqueue     queue;          /* Queue of waiting threads     */
498
};
499
 
500
/*---------------------------------------------------------------------------*/
501
 
502
typedef enum
503
{
504
    CYG_MUTEX_PROTOCOL_NONE,
505
    CYG_MUTEX_PROTOCOL_INHERIT,
506
    CYG_MUTEX_PROTOCOL_CEILING
507
} cyg_mutex_protocol_t;
508
 
509
struct cyg_mutex_t
510
{
511
    cyg_atomic          locked;         /* true if locked               */
512
    cyg_thread          *owner;         /* Current locking thread       */
513
    cyg_threadqueue     queue;          /* Queue of waiting threads     */
514
 
515
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
516
    cyg_mutex_protocol_t protocol;       /* this mutex's protocol        */
517
#endif    
518
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
519
    cyg_priority_t      ceiling;        /* mutex priority ceiling       */
520
#endif
521
 
522
};
523
 
524
/*---------------------------------------------------------------------------*/
525
 
526
struct cyg_cond_t
527
{
528
    cyg_mutex_t         *mutex;         /* Associated mutex             */
529
    cyg_threadqueue     queue;          /* Queue of waiting threads     */
530
};
531
 
532
/*------------------------------------------------------------------------*/
533
 
534
struct cyg_spinlock_t
535
{
536
    cyg_uint32          lock;           /* lock word                     */
537
};
538
 
539
/*------------------------------------------------------------------------*/
540
 
541
/* Memory allocator types now come from the "memalloc" package which is   */
542
/* where the implementation lives.                                        */
543
 
544
#ifdef CYGPKG_MEMALLOC
545
# include <cyg/memalloc/kapidata.h>
546
#endif
547
 
548
#ifdef __cplusplus
549
}
550
#endif
551
 
552
/*---------------------------------------------------------------------------*/
553
/* EOF kapidata.h                                                            */
554
#endif /* CYGONCE_KERNEL_KAPIDATA_H */

powered by: WebSVN 2.1.0

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