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