summaryrefslogtreecommitdiffstats
path: root/cpukit/libgnat/ada_intrsupp.c
blob: e30d50cbc6715a4b151fad5e4e410b2c291d978b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 *  COPYRIGHT (c) 1989-2010.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems.h>
#include <rtems/bspIo.h>

rtems_id __gnat_binary_semaphore_create(void)
{
  rtems_status_code status;
  rtems_id          semaphore;

  status = rtems_semaphore_create(
    rtems_build_name( 'A', 'I', 'S', 'R' ),
    0,
    RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
    0,
    &semaphore
  );
  if ( status != RTEMS_SUCCESSFUL )
    printk( "__gnat_binary_semaphore_create failed %d\n", status );

  #if defined(GNAT_DEBUG)
    printk( "__gnat_binary_semaphore_create\n" );
  #endif
  return semaphore;
}

int __gnat_binary_semaphore_delete(
  rtems_id semaphore
)
{
  rtems_status_code status;

  #if defined(GNAT_DEBUG)
    printk( "__gnat_binary_semaphore_delete\n" );
  #endif

  status = rtems_semaphore_delete( semaphore );
  if ( status != RTEMS_SUCCESSFUL )
    printk( "__gnat_binary_semaphore_delete failed %d\n", status );

  return 0;
}

int __gnat_binary_semaphore_obtain(
  rtems_id semaphore
)
{
  rtems_status_code status;

  #if defined(GNAT_DEBUG)
    printk( "__gnat_binary_semaphore_obtain\n" );
  #endif

  status = rtems_semaphore_obtain( semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
  if ( status != RTEMS_SUCCESSFUL )
    printk( "__gnat_binary_semaphore_obtain failed %d\n", status );

  return 0;
}

int __gnat_binary_semaphore_release(
  rtems_id semaphore
)
{
  rtems_status_code status;

  #if defined(GNAT_DEBUG)
    printk( "__gnat_binary_semaphore_release\n" );
  #endif

  status = rtems_semaphore_release( semaphore );
  if ( status != RTEMS_SUCCESSFUL )
    printk( "__gnat_binary_semaphore_release failed %d\n", status );

  return 0;
}

int __gnat_binary_semaphore_flush(
  rtems_id semaphore
)
{
  rtems_status_code status;

  printk( "__gnat_binary_semaphore_flush\n" );

  status = rtems_semaphore_flush( semaphore );
  if ( status != RTEMS_SUCCESSFUL )
    printk( "__gnat_binary_semaphore_flush failed %d\n", status );

  return 0;
}

typedef void (*ISRHandler)(void*);
  void *set_vector( void *, rtems_vector_number, int );

int __gnat_interrupt_connect(
  int         vector,
  ISRHandler  handler,
  void       *parameter
)
{
  printk( "__gnat_interrupt_connect( %d, %p, %p )\n", vector, handler, parameter  );
  set_vector( handler, vector, 1 );
  return 0;
}

int __gnat_interrupt_set(
  int         vector,
  ISRHandler  handler
)
{
  printk( "__gnat_interrupt_set( %d, %p )\n", vector, handler );

  set_vector( handler, vector, 1 );
  return 0;
}

ISRHandler __gnat_interrupt_get(
  int         vector
)
{
  printk( "__gnat_interrupt_get( %d )\n", vector );
  return 0;
}

int __gnat_interrupt_number_to_vector(
  int intNum
)
{
  printk( "__gnat_interrupt_number_to_vector( %d )\n", intNum );
  return intNum;
}