1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | #include <rtems/bspIo.h> |
---|
16 | |
---|
17 | rtems_id __gnat_binary_semaphore_create(void) |
---|
18 | { |
---|
19 | rtems_status_code status; |
---|
20 | rtems_id semaphore; |
---|
21 | |
---|
22 | status = rtems_semaphore_create( |
---|
23 | rtems_build_name( 'A', 'I', 'S', 'R' ), |
---|
24 | 0, |
---|
25 | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO, |
---|
26 | 0, |
---|
27 | &semaphore |
---|
28 | ); |
---|
29 | if ( status != RTEMS_SUCCESSFUL ) |
---|
30 | printk( "__gnat_binary_semaphore_create failed %d\n", status ); |
---|
31 | |
---|
32 | #if defined(GNAT_DEBUG) |
---|
33 | printk( "__gnat_binary_semaphore_create\n" ); |
---|
34 | #endif |
---|
35 | return semaphore; |
---|
36 | } |
---|
37 | |
---|
38 | int __gnat_binary_semaphore_delete( |
---|
39 | rtems_id semaphore |
---|
40 | ) |
---|
41 | { |
---|
42 | rtems_status_code status; |
---|
43 | |
---|
44 | #if defined(GNAT_DEBUG) |
---|
45 | printk( "__gnat_binary_semaphore_delete\n" ); |
---|
46 | #endif |
---|
47 | |
---|
48 | status = rtems_semaphore_delete( semaphore ); |
---|
49 | if ( status != RTEMS_SUCCESSFUL ) |
---|
50 | printk( "__gnat_binary_semaphore_delete failed %d\n", status ); |
---|
51 | |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | int __gnat_binary_semaphore_obtain( |
---|
56 | rtems_id semaphore |
---|
57 | ) |
---|
58 | { |
---|
59 | rtems_status_code status; |
---|
60 | |
---|
61 | #if defined(GNAT_DEBUG) |
---|
62 | printk( "__gnat_binary_semaphore_obtain\n" ); |
---|
63 | #endif |
---|
64 | |
---|
65 | status = rtems_semaphore_obtain( semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
---|
66 | if ( status != RTEMS_SUCCESSFUL ) |
---|
67 | printk( "__gnat_binary_semaphore_obtain failed %d\n", status ); |
---|
68 | |
---|
69 | return 0; |
---|
70 | } |
---|
71 | |
---|
72 | int __gnat_binary_semaphore_release( |
---|
73 | rtems_id semaphore |
---|
74 | ) |
---|
75 | { |
---|
76 | rtems_status_code status; |
---|
77 | |
---|
78 | #if defined(GNAT_DEBUG) |
---|
79 | printk( "__gnat_binary_semaphore_release\n" ); |
---|
80 | #endif |
---|
81 | |
---|
82 | status = rtems_semaphore_release( semaphore ); |
---|
83 | if ( status != RTEMS_SUCCESSFUL ) |
---|
84 | printk( "__gnat_binary_semaphore_release failed %d\n", status ); |
---|
85 | |
---|
86 | return 0; |
---|
87 | } |
---|
88 | |
---|
89 | int __gnat_binary_semaphore_flush( |
---|
90 | rtems_id semaphore |
---|
91 | ) |
---|
92 | { |
---|
93 | rtems_status_code status; |
---|
94 | |
---|
95 | printk( "__gnat_binary_semaphore_flush\n" ); |
---|
96 | |
---|
97 | status = rtems_semaphore_flush( semaphore ); |
---|
98 | if ( status != RTEMS_SUCCESSFUL ) |
---|
99 | printk( "__gnat_binary_semaphore_flush failed %d\n", status ); |
---|
100 | |
---|
101 | return 0; |
---|
102 | } |
---|
103 | |
---|
104 | typedef void (*ISRHandler)(void*); |
---|
105 | void *set_vector( void *, rtems_vector_number, int ); |
---|
106 | |
---|
107 | int __gnat_interrupt_connect( |
---|
108 | int vector, |
---|
109 | ISRHandler handler, |
---|
110 | void *parameter |
---|
111 | ) |
---|
112 | { |
---|
113 | printk( "__gnat_interrupt_connect( %d, %p, %p )\n", vector, handler, parameter ); |
---|
114 | set_vector( handler, vector, 1 ); |
---|
115 | return 0; |
---|
116 | } |
---|
117 | |
---|
118 | int __gnat_interrupt_set( |
---|
119 | int vector, |
---|
120 | ISRHandler handler |
---|
121 | ) |
---|
122 | { |
---|
123 | printk( "__gnat_interrupt_set( %d, %p )\n", vector, handler ); |
---|
124 | |
---|
125 | set_vector( handler, vector, 1 ); |
---|
126 | return 0; |
---|
127 | } |
---|
128 | |
---|
129 | ISRHandler __gnat_interrupt_get( |
---|
130 | int vector |
---|
131 | ) |
---|
132 | { |
---|
133 | printk( "__gnat_interrupt_get( %d )\n", vector ); |
---|
134 | return 0; |
---|
135 | } |
---|
136 | |
---|
137 | int __gnat_interrupt_number_to_vector( |
---|
138 | int intNum |
---|
139 | ) |
---|
140 | { |
---|
141 | printk( "__gnat_interrupt_number_to_vector( %d )\n", intNum ); |
---|
142 | return intNum; |
---|
143 | } |
---|
144 | |
---|