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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [s-osinte-rtems.ads] - Blame information for rev 717

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

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS               --
4
--                                                                          --
5
--                   S Y S T E M . O S _ I N T E R F A C E                  --
6
--                                                                          --
7
--                                   S p e c                                --
8
--                                                                          --
9
--          Copyright (C) 1997-2011 Free Software Foundation, Inc.          --
10
--                                                                          --
11
-- GNARL is free software; you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNARL was developed by the GNARL team at Florida State University.       --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
-- The GNARL files that were developed for RTEMS are maintained by  On-Line --
31
-- Applications Research Corporation (http://www.oarcorp.com)  in  coopera- --
32
-- tion with Ada Core Technologies Inc. and Florida State University.       --
33
--                                                                          --
34
------------------------------------------------------------------------------
35
 
36
--  This is the RTEMS version of this package.
37
--
38
--  RTEMS target names are of the form CPU-rtems.
39
--  This implementation is designed to work on ALL RTEMS targets.
40
--  The RTEMS implementation is primarily based upon the POSIX threads
41
--  API but there are also bindings to GNAT/RTEMS support routines
42
--  to insulate this code from C API specific details and, in some
43
--  cases, obtain target architecture and BSP specific information
44
--  that is unavailable at the time this package is built.
45
 
46
--  This package encapsulates all direct interfaces to OS services
47
--  that are needed by children of System.
48
 
49
--  PLEASE DO NOT add any with-clauses to this package
50
--  or remove the pragma Preelaborate.
51
--  It is designed to be a bottom-level (leaf) package.
52
 
53
with Interfaces.C;
54
package System.OS_Interface is
55
   pragma Preelaborate;
56
 
57
   --  This interface assumes that "unsigned" is a 32-bit entity.  This
58
   --  will correspond to RTEMS object ids.
59
 
60
   subtype rtems_id       is Interfaces.C.unsigned;
61
 
62
   subtype int            is Interfaces.C.int;
63
   subtype short          is Interfaces.C.short;
64
   subtype long           is Interfaces.C.long;
65
   subtype unsigned       is Interfaces.C.unsigned;
66
   subtype unsigned_short is Interfaces.C.unsigned_short;
67
   subtype unsigned_long  is Interfaces.C.unsigned_long;
68
   subtype unsigned_char  is Interfaces.C.unsigned_char;
69
   subtype plain_char     is Interfaces.C.plain_char;
70
   subtype size_t         is Interfaces.C.size_t;
71
 
72
   -----------
73
   -- Errno --
74
   -----------
75
 
76
   function errno return int;
77
   pragma Import (C, errno, "__get_errno");
78
 
79
   EAGAIN    : constant := 11;
80
   EINTR     : constant := 4;
81
   EINVAL    : constant := 22;
82
   ENOMEM    : constant := 12;
83
   ETIMEDOUT : constant := 116;
84
 
85
   -------------
86
   -- Signals --
87
   -------------
88
 
89
   Num_HW_Interrupts : constant := 256;
90
 
91
   Max_HW_Interrupt : constant := Num_HW_Interrupts - 1;
92
   type HW_Interrupt is new int range 0 .. Max_HW_Interrupt;
93
 
94
   Max_Interrupt : constant := Max_HW_Interrupt;
95
 
96
   type Signal is new int range 0 .. Max_Interrupt;
97
 
98
   SIGXCPU     : constant := 0; --  XCPU
99
   SIGHUP      : constant := 1; --  hangup
100
   SIGINT      : constant := 2; --  interrupt (rubout)
101
   SIGQUIT     : constant := 3; --  quit (ASCD FS)
102
   SIGILL      : constant := 4; --  illegal instruction (not reset)
103
   SIGTRAP     : constant := 5; --  trace trap (not reset)
104
   SIGIOT      : constant := 6; --  IOT instruction
105
   SIGABRT     : constant := 6; --  used by abort, replace SIGIOT in the future
106
   SIGEMT      : constant := 7; --  EMT instruction
107
   SIGFPE      : constant := 8; --  floating point exception
108
   SIGKILL     : constant := 9; --  kill (cannot be caught or ignored)
109
   SIGBUS      : constant := 10; --  bus error
110
   SIGSEGV     : constant := 11; --  segmentation violation
111
   SIGSYS      : constant := 12; --  bad argument to system call
112
   SIGPIPE     : constant := 13; --  write on a pipe with no one to read it
113
   SIGALRM     : constant := 14; --  alarm clock
114
   SIGTERM     : constant := 15; --  software termination signal from kill
115
   SIGUSR1     : constant := 16; --  user defined signal 1
116
   SIGUSR2     : constant := 17; --  user defined signal 2
117
 
118
   SIGADAABORT : constant := SIGABRT;
119
 
120
   type Signal_Set is array (Natural range <>) of Signal;
121
 
122
   Unmasked    : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT);
123
   Reserved    : constant Signal_Set := (1 .. 1 => SIGKILL);
124
 
125
   type sigset_t is private;
126
 
127
   function sigaddset (set : access sigset_t; sig : Signal) return int;
128
   pragma Import (C, sigaddset, "sigaddset");
129
 
130
   function sigdelset (set : access sigset_t; sig : Signal) return int;
131
   pragma Import (C, sigdelset, "sigdelset");
132
 
133
   function sigfillset (set : access sigset_t) return int;
134
   pragma Import (C, sigfillset, "sigfillset");
135
 
136
   function sigismember (set : access sigset_t; sig : Signal) return int;
137
   pragma Import (C, sigismember, "sigismember");
138
 
139
   function sigemptyset (set : access sigset_t) return int;
140
   pragma Import (C, sigemptyset, "sigemptyset");
141
 
142
   type struct_sigaction is record
143
      sa_flags   : int;
144
      sa_mask    : sigset_t;
145
      sa_handler : System.Address;
146
   end record;
147
   pragma Convention (C, struct_sigaction);
148
   type struct_sigaction_ptr is access all struct_sigaction;
149
 
150
   SA_SIGINFO  : constant := 16#02#;
151
 
152
   SA_ONSTACK : constant := 16#00#;
153
   --  SA_ONSTACK is not defined on RTEMS, but it is referred to in the POSIX
154
   --  implementation of System.Interrupt_Management. Therefore we define a
155
   --  dummy value of zero here so that setting this flag is a nop.
156
 
157
   SIG_BLOCK   : constant := 1;
158
   SIG_UNBLOCK : constant := 2;
159
   SIG_SETMASK : constant := 3;
160
 
161
   SIG_DFL : constant := 0;
162
   SIG_IGN : constant := 1;
163
 
164
   function sigaction
165
     (sig  : Signal;
166
      act  : struct_sigaction_ptr;
167
      oact : struct_sigaction_ptr) return int;
168
   pragma Import (C, sigaction, "sigaction");
169
 
170
   ----------
171
   -- Time --
172
   ----------
173
 
174
   Time_Slice_Supported : constant Boolean := True;
175
   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
176
 
177
   type timespec is private;
178
 
179
   type clockid_t is new int;
180
 
181
   CLOCK_REALTIME  : constant clockid_t;
182
   CLOCK_MONOTONIC : constant clockid_t;
183
 
184
   function clock_gettime
185
     (clock_id : clockid_t;
186
      tp       : access timespec) return int;
187
   pragma Import (C, clock_gettime, "clock_gettime");
188
 
189
   function To_Duration (TS : timespec) return Duration;
190
   pragma Inline (To_Duration);
191
 
192
   function To_Timespec (D : Duration) return timespec;
193
   pragma Inline (To_Timespec);
194
 
195
   -------------------------
196
   -- Priority Scheduling --
197
   -------------------------
198
 
199
   SCHED_FIFO  : constant := 1;
200
   SCHED_RR    : constant := 2;
201
   SCHED_OTHER : constant := 0;
202
 
203
   function To_Target_Priority
204
     (Prio : System.Any_Priority) return Interfaces.C.int;
205
   --  Maps System.Any_Priority to a POSIX priority
206
 
207
   -------------
208
   -- Process --
209
   -------------
210
 
211
   type pid_t is private;
212
 
213
   function kill (pid : pid_t; sig : Signal) return int;
214
   pragma Import (C, kill, "kill");
215
 
216
   function getpid return pid_t;
217
   pragma Import (C, getpid, "getpid");
218
 
219
   ---------
220
   -- LWP --
221
   ---------
222
 
223
   function lwp_self return System.Address;
224
   --  lwp_self does not exist on this thread library, revert to pthread_self
225
   --  which is the closest approximation (with getpid). This function is
226
   --  needed to share 7staprop.adb across POSIX-like targets.
227
   pragma Import (C, lwp_self, "pthread_self");
228
 
229
   -------------
230
   -- Threads --
231
   -------------
232
 
233
   type Thread_Body is access
234
     function (arg : System.Address) return System.Address;
235
   pragma Convention (C, Thread_Body);
236
 
237
   type pthread_t           is private;
238
   subtype Thread_Id        is pthread_t;
239
 
240
   type pthread_mutex_t      is limited private;
241
   type pthread_rwlock_t     is limited private;
242
   type pthread_cond_t       is limited private;
243
   type pthread_attr_t       is limited private;
244
   type pthread_mutexattr_t  is limited private;
245
   type pthread_rwlockattr_t is limited private;
246
   type pthread_condattr_t   is limited private;
247
   type pthread_key_t        is private;
248
 
249
   No_Key : constant pthread_key_t;
250
 
251
   PTHREAD_CREATE_DETACHED : constant := 0;
252
 
253
   PTHREAD_SCOPE_PROCESS : constant := 0;
254
   PTHREAD_SCOPE_SYSTEM  : constant := 1;
255
 
256
   -----------
257
   -- Stack --
258
   -----------
259
 
260
   type stack_t is record
261
      ss_sp    : System.Address;
262
      ss_flags : int;
263
      ss_size  : size_t;
264
   end record;
265
   pragma Convention (C, stack_t);
266
 
267
   function sigaltstack
268
     (ss  : not null access stack_t;
269
      oss : access stack_t) return int;
270
 
271
   Alternate_Stack : aliased System.Address;
272
   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
273
 
274
   Alternate_Stack_Size : constant := 0;
275
   --  No alternate signal stack is used on this platform
276
 
277
   Stack_Base_Available : constant Boolean := False;
278
   --  Indicates whether the stack base is available on this target.
279
   --  This allows us to share s-osinte.adb between all the FSU/RTEMS
280
   --  run time.
281
   --  Note that this value can only be true if pthread_t has a complete
282
   --  definition that corresponds exactly to the C header files.
283
 
284
   function Get_Stack_Base (thread : pthread_t) return Address;
285
   pragma Inline (Get_Stack_Base);
286
   --  returns the stack base of the specified thread.
287
   --  Only call this function when Stack_Base_Available is True.
288
 
289
   --  These two functions are only needed to share s-taprop.adb with
290
   --  FSU threads.
291
 
292
   function Get_Page_Size return size_t;
293
   function Get_Page_Size return Address;
294
   pragma Import (C, Get_Page_Size, "getpagesize");
295
   --  Returns the size of a page
296
 
297
   PROT_ON  : constant := 0;
298
   PROT_OFF : constant := 0;
299
 
300
   function mprotect (addr : Address; len : size_t; prot : int) return int;
301
   pragma Import (C, mprotect);
302
 
303
   -----------------------------------------
304
   --  Nonstandard Thread Initialization  --
305
   -----------------------------------------
306
 
307
   procedure pthread_init;
308
   --  FSU_THREADS requires pthread_init, which is nonstandard
309
   --  and this should be invoked during the elaboration of s-taprop.adb
310
   --
311
   --  RTEMS does not require this so we provide an empty Ada body.
312
 
313
   -------------------------
314
   -- POSIX.1c  Section 3 --
315
   -------------------------
316
 
317
   function sigwait
318
     (set : access sigset_t;
319
      sig : access Signal) return int;
320
   pragma Import (C, sigwait, "sigwait");
321
 
322
   function pthread_kill
323
     (thread : pthread_t;
324
      sig    : Signal) return int;
325
   pragma Import (C, pthread_kill, "pthread_kill");
326
 
327
   function pthread_sigmask
328
     (how  : int;
329
      set  : access sigset_t;
330
      oset : access sigset_t) return int;
331
   pragma Import (C, pthread_sigmask, "pthread_sigmask");
332
 
333
   ----------------------------
334
   --  POSIX.1c  Section 11  --
335
   ----------------------------
336
 
337
   function pthread_mutexattr_init
338
     (attr : access pthread_mutexattr_t) return int;
339
   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
340
 
341
   function pthread_mutexattr_destroy
342
     (attr : access pthread_mutexattr_t) return int;
343
   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
344
 
345
   function pthread_mutex_init
346
     (mutex : access pthread_mutex_t;
347
      attr  : access pthread_mutexattr_t) return int;
348
   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
349
 
350
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
351
   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
352
 
353
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
354
   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
355
 
356
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
357
   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
358
 
359
   function pthread_rwlockattr_init
360
     (attr : access pthread_rwlockattr_t) return int;
361
   pragma Import (C, pthread_rwlockattr_init, "pthread_rwlockattr_init");
362
 
363
   function pthread_rwlockattr_destroy
364
     (attr : access pthread_rwlockattr_t) return int;
365
   pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
366
 
367
   PTHREAD_RWLOCK_PREFER_READER_NP              : constant := 0;
368
   PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
369
   PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
370
 
371
   function pthread_rwlockattr_setkind_np
372
     (attr : access pthread_rwlockattr_t;
373
      pref : int) return int;
374
 
375
   function pthread_rwlock_init
376
     (mutex : access pthread_rwlock_t;
377
      attr  : access pthread_rwlockattr_t) return int;
378
   pragma Import (C, pthread_rwlock_init, "pthread_rwlock_init");
379
 
380
   function pthread_rwlock_destroy
381
     (mutex : access pthread_rwlock_t) return int;
382
   pragma Import (C, pthread_rwlock_destroy, "pthread_rwlock_destroy");
383
 
384
   function pthread_rwlock_rdlock (mutex : access pthread_rwlock_t) return int;
385
   pragma Import (C, pthread_rwlock_rdlock, "pthread_rwlock_rdlock");
386
 
387
   function pthread_rwlock_wrlock (mutex : access pthread_rwlock_t) return int;
388
   pragma Import (C, pthread_rwlock_wrlock, "pthread_rwlock_wrlock");
389
 
390
   function pthread_rwlock_unlock (mutex : access pthread_rwlock_t) return int;
391
   pragma Import (C, pthread_rwlock_unlock, "pthread_rwlock_unlock");
392
 
393
   function pthread_condattr_init
394
     (attr : access pthread_condattr_t) return int;
395
   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
396
 
397
   function pthread_condattr_destroy
398
     (attr : access pthread_condattr_t) return int;
399
   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
400
 
401
   function pthread_cond_init
402
     (cond : access pthread_cond_t;
403
      attr : access pthread_condattr_t) return int;
404
   pragma Import (C, pthread_cond_init, "pthread_cond_init");
405
 
406
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
407
   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
408
 
409
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
410
   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
411
 
412
   function pthread_cond_wait
413
     (cond  : access pthread_cond_t;
414
      mutex : access pthread_mutex_t) return int;
415
   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
416
 
417
   function pthread_cond_timedwait
418
     (cond    : access pthread_cond_t;
419
      mutex   : access pthread_mutex_t;
420
      abstime : access timespec) return int;
421
   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
422
 
423
   Relative_Timed_Wait : constant Boolean := False;
424
   --  pthread_cond_timedwait requires an absolute delay time
425
 
426
   --------------------------
427
   -- POSIX.1c  Section 13 --
428
   --------------------------
429
 
430
   PTHREAD_PRIO_NONE    : constant := 0;
431
   PTHREAD_PRIO_PROTECT : constant := 2;
432
   PTHREAD_PRIO_INHERIT : constant := 1;
433
 
434
   function pthread_mutexattr_setprotocol
435
     (attr     : access pthread_mutexattr_t;
436
      protocol : int) return int;
437
   pragma Import (C, pthread_mutexattr_setprotocol);
438
 
439
   function pthread_mutexattr_setprioceiling
440
     (attr     : access pthread_mutexattr_t;
441
      prioceiling : int) return int;
442
   pragma Import
443
     (C, pthread_mutexattr_setprioceiling,
444
      "pthread_mutexattr_setprioceiling");
445
 
446
   type struct_sched_param is record
447
      sched_priority      : int;
448
      ss_low_priority     : int;
449
      ss_replenish_period : timespec;
450
      ss_initial_budget   : timespec;
451
   end record;
452
   pragma Convention (C, struct_sched_param);
453
 
454
   function pthread_setschedparam
455
     (thread : pthread_t;
456
      policy : int;
457
      param  : access struct_sched_param) return int;
458
   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
459
 
460
   function pthread_attr_setscope
461
     (attr            : access pthread_attr_t;
462
      contentionscope : int) return int;
463
   pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
464
 
465
   function pthread_attr_setinheritsched
466
     (attr         : access pthread_attr_t;
467
      inheritsched : int) return int;
468
   pragma Import (C, pthread_attr_setinheritsched);
469
 
470
   function pthread_attr_setschedpolicy
471
     (attr   : access pthread_attr_t;
472
      policy : int) return int;
473
   pragma Import (C, pthread_attr_setschedpolicy);
474
 
475
   function pthread_attr_setschedparam
476
     (attr        : access pthread_attr_t;
477
      sched_param : int) return int;
478
   pragma Import (C, pthread_attr_setschedparam);
479
 
480
   function sched_yield return int;
481
   pragma Import (C, sched_yield, "sched_yield");
482
 
483
   ---------------------------
484
   -- P1003.1c - Section 16 --
485
   ---------------------------
486
 
487
   function pthread_attr_init (attributes : access pthread_attr_t) return int;
488
   pragma Import (C, pthread_attr_init, "pthread_attr_init");
489
 
490
   function pthread_attr_destroy
491
     (attributes : access pthread_attr_t) return int;
492
   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
493
 
494
   function pthread_attr_setdetachstate
495
     (attr        : access pthread_attr_t;
496
      detachstate : int) return int;
497
   pragma Import (C, pthread_attr_setdetachstate);
498
 
499
   function pthread_attr_setstacksize
500
     (attr      : access pthread_attr_t;
501
      stacksize : size_t) return int;
502
   pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
503
 
504
   function pthread_create
505
     (thread        : access pthread_t;
506
      attributes    : access pthread_attr_t;
507
      start_routine : Thread_Body;
508
      arg           : System.Address) return int;
509
   pragma Import (C, pthread_create, "pthread_create");
510
 
511
   procedure pthread_exit (status : System.Address);
512
   pragma Import (C, pthread_exit, "pthread_exit");
513
 
514
   function pthread_self return pthread_t;
515
   pragma Import (C, pthread_self, "pthread_self");
516
 
517
   --------------------------
518
   -- POSIX.1c  Section 17 --
519
   --------------------------
520
 
521
   function pthread_setspecific
522
     (key   : pthread_key_t;
523
      value : System.Address) return int;
524
   pragma Import (C, pthread_setspecific, "pthread_setspecific");
525
 
526
   function pthread_getspecific (key : pthread_key_t) return System.Address;
527
   pragma Import (C, pthread_getspecific, "pthread_getspecific");
528
 
529
   type destructor_pointer is access procedure (arg : System.Address);
530
   pragma Convention (C, destructor_pointer);
531
 
532
   function pthread_key_create
533
     (key        : access pthread_key_t;
534
      destructor : destructor_pointer) return int;
535
   pragma Import (C, pthread_key_create, "pthread_key_create");
536
 
537
   ------------------------------------------------------------
538
   --   Binary Semaphore Wrapper to Support Interrupt Tasks  --
539
   ------------------------------------------------------------
540
 
541
   type Binary_Semaphore_Id is new rtems_id;
542
 
543
   function Binary_Semaphore_Create return Binary_Semaphore_Id;
544
   pragma Import (
545
      C,
546
      Binary_Semaphore_Create,
547
      "__gnat_binary_semaphore_create");
548
 
549
   function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
550
   pragma Import (
551
      C,
552
      Binary_Semaphore_Delete,
553
      "__gnat_binary_semaphore_delete");
554
 
555
   function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
556
   pragma Import (
557
      C,
558
      Binary_Semaphore_Obtain,
559
      "__gnat_binary_semaphore_obtain");
560
 
561
   function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
562
   pragma Import (
563
      C,
564
      Binary_Semaphore_Release,
565
      "__gnat_binary_semaphore_release");
566
 
567
   function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
568
   pragma Import (
569
      C,
570
      Binary_Semaphore_Flush,
571
      "__gnat_binary_semaphore_flush");
572
 
573
   ------------------------------------------------------------
574
   -- Hardware Interrupt Wrappers to Support Interrupt Tasks --
575
   ------------------------------------------------------------
576
 
577
   type Interrupt_Handler is access procedure (parameter : System.Address);
578
   pragma Convention (C, Interrupt_Handler);
579
   type Interrupt_Vector is new System.Address;
580
 
581
   function Interrupt_Connect
582
     (vector    : Interrupt_Vector;
583
      handler   : Interrupt_Handler;
584
      parameter : System.Address := System.Null_Address) return int;
585
   pragma Import (C, Interrupt_Connect, "__gnat_interrupt_connect");
586
   --  Use this to set up an user handler. The routine installs a
587
   --  a user handler which is invoked after RTEMS has saved enough
588
   --  context for a high-level language routine to be safely invoked.
589
 
590
   function Interrupt_Vector_Get
591
     (Vector : Interrupt_Vector) return Interrupt_Handler;
592
   pragma Import (C, Interrupt_Vector_Get, "__gnat_interrupt_get");
593
   --  Use this to get the existing handler for later restoral.
594
 
595
   procedure Interrupt_Vector_Set
596
     (Vector  : Interrupt_Vector;
597
      Handler : Interrupt_Handler);
598
   pragma Import (C, Interrupt_Vector_Set, "__gnat_interrupt_set");
599
   --  Use this to restore a handler obtained using Interrupt_Vector_Get.
600
 
601
   function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
602
   --  Convert a logical interrupt number to the hardware interrupt vector
603
   --  number used to connect the interrupt.
604
   pragma Import (
605
      C,
606
      Interrupt_Number_To_Vector,
607
      "__gnat_interrupt_number_to_vector"
608
   );
609
 
610
private
611
 
612
   type sigset_t is new int;
613
 
614
   type pid_t is new int;
615
 
616
   type time_t is new long;
617
 
618
   type timespec is record
619
      tv_sec  : time_t;
620
      tv_nsec : long;
621
   end record;
622
   pragma Convention (C, timespec);
623
 
624
   CLOCK_REALTIME :  constant clockid_t := 1;
625
   CLOCK_MONOTONIC : constant clockid_t := 4;
626
 
627
   type pthread_attr_t is record
628
      is_initialized  : int;
629
      stackaddr       : System.Address;
630
      stacksize       : int;
631
      contentionscope : int;
632
      inheritsched    : int;
633
      schedpolicy     : int;
634
      schedparam      : struct_sched_param;
635
      cputime_clocked_allowed : int;
636
      detatchstate    : int;
637
   end record;
638
   pragma Convention (C, pthread_attr_t);
639
 
640
   type pthread_condattr_t is record
641
      flags           : int;
642
      process_shared  : int;
643
   end record;
644
   pragma Convention (C, pthread_condattr_t);
645
 
646
   type pthread_mutexattr_t is record
647
      is_initialized  : int;
648
      process_shared  : int;
649
      prio_ceiling    : int;
650
      protocol        : int;
651
      mutex_type      : int;
652
      recursive       : int;
653
   end record;
654
   pragma Convention (C, pthread_mutexattr_t);
655
 
656
   type pthread_rwlockattr_t is record
657
      is_initialized  : int;
658
      process_shared  : int;
659
   end record;
660
   pragma Convention (C, pthread_rwlockattr_t);
661
 
662
   type pthread_t is new rtems_id;
663
 
664
   type pthread_mutex_t is new rtems_id;
665
 
666
   type pthread_rwlock_t is new rtems_id;
667
 
668
   type pthread_cond_t is new rtems_id;
669
 
670
   type pthread_key_t is new rtems_id;
671
 
672
   No_Key : constant pthread_key_t := 0;
673
 
674
end System.OS_Interface;

powered by: WebSVN 2.1.0

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