Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:18

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2010.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include <rtems.h>
0034 #include <rtems/bspIo.h>
0035 
0036 rtems_id __gnat_binary_semaphore_create(void)
0037 {
0038   rtems_status_code status;
0039   rtems_id          semaphore;
0040 
0041   status = rtems_semaphore_create(
0042     rtems_build_name( 'A', 'I', 'S', 'R' ),
0043     0,
0044     RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
0045     0,
0046     &semaphore
0047   );
0048   if ( status != RTEMS_SUCCESSFUL )
0049     printk( "__gnat_binary_semaphore_create failed %d\n", status );
0050 
0051   #if defined(GNAT_DEBUG)
0052     printk( "__gnat_binary_semaphore_create\n" );
0053   #endif
0054   return semaphore;
0055 }
0056 
0057 int __gnat_binary_semaphore_delete(
0058   rtems_id semaphore
0059 )
0060 {
0061   rtems_status_code status;
0062 
0063   #if defined(GNAT_DEBUG)
0064     printk( "__gnat_binary_semaphore_delete\n" );
0065   #endif
0066 
0067   status = rtems_semaphore_delete( semaphore );
0068   if ( status != RTEMS_SUCCESSFUL )
0069     printk( "__gnat_binary_semaphore_delete failed %d\n", status );
0070 
0071   return 0;
0072 }
0073 
0074 int __gnat_binary_semaphore_obtain(
0075   rtems_id semaphore
0076 )
0077 {
0078   rtems_status_code status;
0079 
0080   #if defined(GNAT_DEBUG)
0081     printk( "__gnat_binary_semaphore_obtain\n" );
0082   #endif
0083 
0084   status = rtems_semaphore_obtain( semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
0085   if ( status != RTEMS_SUCCESSFUL )
0086     printk( "__gnat_binary_semaphore_obtain failed %d\n", status );
0087 
0088   return 0;
0089 }
0090 
0091 int __gnat_binary_semaphore_release(
0092   rtems_id semaphore
0093 )
0094 {
0095   rtems_status_code status;
0096 
0097   #if defined(GNAT_DEBUG)
0098     printk( "__gnat_binary_semaphore_release\n" );
0099   #endif
0100 
0101   status = rtems_semaphore_release( semaphore );
0102   if ( status != RTEMS_SUCCESSFUL )
0103     printk( "__gnat_binary_semaphore_release failed %d\n", status );
0104 
0105   return 0;
0106 }
0107 
0108 int __gnat_binary_semaphore_flush(
0109   rtems_id semaphore
0110 )
0111 {
0112   rtems_status_code status;
0113 
0114   printk( "__gnat_binary_semaphore_flush\n" );
0115 
0116   status = rtems_semaphore_flush( semaphore );
0117   if ( status != RTEMS_SUCCESSFUL )
0118     printk( "__gnat_binary_semaphore_flush failed %d\n", status );
0119 
0120   return 0;
0121 }
0122 
0123 typedef void (*ISRHandler)(void*);
0124   void *set_vector( void *, rtems_vector_number, int );
0125 
0126 int __gnat_interrupt_connect(
0127   int         vector,
0128   ISRHandler  handler,
0129   void       *parameter
0130 )
0131 {
0132   printk( "__gnat_interrupt_connect( %d, %p, %p )\n", vector, handler, parameter  );
0133   set_vector( handler, vector, 1 );
0134   return 0;
0135 }
0136 
0137 int __gnat_interrupt_set(
0138   int         vector,
0139   ISRHandler  handler
0140 )
0141 {
0142   printk( "__gnat_interrupt_set( %d, %p )\n", vector, handler );
0143 
0144   set_vector( handler, vector, 1 );
0145   return 0;
0146 }
0147 
0148 ISRHandler __gnat_interrupt_get(
0149   int         vector
0150 )
0151 {
0152   printk( "__gnat_interrupt_get( %d )\n", vector );
0153   return 0;
0154 }
0155 
0156 int __gnat_interrupt_number_to_vector(
0157   int intNum
0158 )
0159 {
0160   printk( "__gnat_interrupt_number_to_vector( %d )\n", intNum );
0161   return intNum;
0162 }
0163