/home/hillier_g/checkout/most4linux/libnetservices/src/linux/events.c

00001 /*
00002  *  Copyright(c) Siemens AG, Muenchen, Germany, 2005, 2006, 2007
00003  *                           Bernhard Walle <bernhard.walle@gmx.de>
00004  *                           Gernot Hillier <gernot.hillier@siemens.com>
00005  *                           All rights reserved.
00006  *
00007  * ----------------------------------------------------------------------------
00008  * The contents of this file are subject to the Mozilla Public License
00009  * Version 1.1 (the "License"); you may not use this file except in
00010  * compliance with the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  * 
00013  * Software distributed under the License is distributed on an "AS IS"
00014  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
00015  * License for the specific language governing rights and limitations
00016  * under the License.
00017  *
00018  * The Original Code is Siemens code.
00019  * 
00020  * The Initial Developer of the Original Code is Siemens AG.
00021  * Portions created by the Initial Developer are Copyright (C) 2005-06
00022  * the Initial Developer. All Rights Reserved.
00023  * ----------------------------------------------------------------------------
00024  */
00025 #include <signal.h>
00026 #include <pthread.h>
00027 #include <semaphore.h>
00028 #include <time.h>
00029 #include <assert.h>
00030 #include <unistd.h>
00031 #include <sys/types.h>
00032 #include <sys/ioctl.h>
00033 
00034 #include <adjust.h>
00035 #include <mostdef1.h>
00036 #include <mostns1.h>
00037 #include <mostnetsdll.h>
00038 #include <par_cp.h>
00039 
00040 #include "global.h"
00041 #include "most-netservice.h"
00042 #include "service.h"
00043 
00044 
00045 /* -------------------------------------------------------------------------- */
00046 void MnsRequest(word flags)
00047 {
00048     union sigval val;
00049 
00050     PRINT_TRACE("flags = %d", flags);
00051 
00052     val.sival_int = MNS_INT;
00053 
00054     /*
00055      * send the current process a MOST_RT_SIGNAL signal with a MNS_INT value
00056      * because that's the same as an interrupt
00057      *
00058      * The process blocks the signal and the service thread gets notified
00059      */
00060     sigqueue(getpid(), MOST_RT_SIGNAL, val);
00061 }
00062 
00063 /* -------------------------------------------------------------------------- */
00064 void MnsRequestTimer(void)
00065 {
00066     union sigval val;
00067 
00068     PRINT_TRACE();
00069 
00070     val.sival_int = 0;
00071 
00072     /* ensure that si_value.sigval_int is zero */
00073     sigqueue(getpid(), MOST_RT_SIGNAL_TIMER, val);
00074 }
00075 
00076 /* -------------------------------------------------------------------------- */
00077 byte Most_Por_Int(void)
00078 {
00079     int ret;
00080 
00081     PRINT_TRACE();
00082     CHECK_FILEDESCRIPTOR_RET_VAL(-1);
00083 
00084     ret = ioctl(g_control_fd, MOST_NETS_READ_INT);
00085     if (ret < 0) {
00086         PERR_DEBUG("Reading interrupt register failed");
00087         return FALSE;
00088     }
00089 
00090     PRINT_TRACE("Interrupt status: %s", ret ? "active" : "not active");
00091 
00092     return ret;
00093 }
00094 
00095 /* -------------------------------------------------------------------------- */
00096 void MostResetInt(byte mask)
00097 {
00098     int ret;
00099 
00100     PRINT_TRACE();
00101     CHECK_FILEDESCRIPTOR_RET();
00102 
00103     ret = ioctl(g_control_fd, MOST_NETS_IRQ_RESET, &mask);
00104     if (ret != 0) {
00105         PERR_DEBUG("MOST_NETS_IRQ_RESET failed");
00106     }
00107 }
00108 
00109 /* vim: set ts=4 et sw=4: */

Generated on Fri Mar 9 14:48:59 2007 for MOST Adaption Layer for Netservices Library by  doxygen 1.5.0