POK
/home/jaouen/pok_official/pok/trunk/libpok/include/arinc653/semaphore.h
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 
00018 #ifdef POK_NEEDS_ARINC653_SEMAPHORE
00019 #ifndef APEX_SEMAPHORE
00020 #define APEX_SEMAPHORE
00021 
00022 #ifndef POK_NEEDS_ARINC653_PROCESS
00023 #define POK_NEEDS_ARINC653_PROCESS 1
00024 #endif
00025 
00026 #include <arinc653/types.h>
00027 #include <arinc653/process.h>
00028 
00029 /*----------------------------------------------------------------------*/
00030 /* */
00031 /* SEMAPHORE constant definitions */
00032 /* */
00033 /*----------------------------------------------------------------------*/
00034 /* implementation dependent */
00035 /* these values are given as example */
00036 /*------------------------------*/
00037 /* max nb of semaphores */
00038 /*------------------------------*/
00039 #define MAX_NUMBER_OF_SEMAPHORES 63
00040 /*------------------------------*/
00041 /* max semaphore value */
00042 /*------------------------------*/
00043 #define MAX_SEMAPHORE_VALUE 32767
00044 /*----------------------------------------------------------------------*/
00045 /* */
00046 /* SEMAPHORE type definitions */
00047 /* */
00048 /*----------------------------------------------------------------------*/
00049 /*------------------------------*/
00050 /* semaphore ident type */
00051 /*------------------------------*/
00052 typedef APEX_INTEGER SEMAPHORE_ID_TYPE;
00053 /*------------------------------*/
00054 /* semaphore value type */
00055 /*------------------------------*/
00056 typedef APEX_INTEGER SEMAPHORE_VALUE_TYPE;
00057 /*------------------------------*/
00058 /* semaphore name type */
00059 /*------------------------------*/
00060 typedef NAME_TYPE SEMAPHORE_NAME_TYPE;
00061 /*------------------------------*/
00062 /* semaphore status type */
00063 /*------------------------------*/
00064 typedef
00065 struct {
00066    SEMAPHORE_VALUE_TYPE CURRENT_VALUE;
00067    SEMAPHORE_VALUE_TYPE MAXIMUM_VALUE;
00068    WAITING_RANGE_TYPE WAITING_PROCESSES;
00069 } SEMAPHORE_STATUS_TYPE;
00070 /*----------------------------------------------------------------------*/
00071 /* */
00072 /* semaphore management services */
00073 /* */
00074 /*----------------------------------------------------------------------*/
00075 /*----------------------------------------------------------------------*/
00076 extern void CREATE_SEMAPHORE (
00077       /*IN */ SEMAPHORE_NAME_TYPE SEMAPHORE_NAME,
00078       /*IN */ SEMAPHORE_VALUE_TYPE CURRENT_VALUE,
00079       /*IN */ SEMAPHORE_VALUE_TYPE MAXIMUM_VALUE,
00080       /*IN */ QUEUING_DISCIPLINE_TYPE QUEUING_DISCIPLINE,
00081       /*OUT*/ SEMAPHORE_ID_TYPE *SEMAPHORE_ID,
00082       /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
00083 /*----------------------------------------------------------------------*/
00084 extern void WAIT_SEMAPHORE (
00085       /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
00086       /*IN */ SYSTEM_TIME_TYPE TIME_OUT,
00087       /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
00088 /*----------------------------------------------------------------------*/
00089 extern void SIGNAL_SEMAPHORE (
00090       /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
00091       /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
00092 /*----------------------------------------------------------------------*/
00093 extern void GET_SEMAPHORE_ID (
00094       /*IN */ SEMAPHORE_NAME_TYPE SEMAPHORE_NAME,
00095       /*OUT*/ SEMAPHORE_ID_TYPE *SEMAPHORE_ID,
00096       /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
00097 /*----------------------------------------------------------------------*/
00098 extern void GET_SEMAPHORE_STATUS (
00099       /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
00100       /*OUT*/ SEMAPHORE_STATUS_TYPE *SEMAPHORE_STATUS,
00101       /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
00102 /*----------------------------------------------------------------------*/
00103 #endif
00104 #endif