Main Page | Class List | Directories | File List | Class Members | File Members

ipmi_posix.h

Go to the documentation of this file.
00001 /*
00002  * os_handler.h
00003  *
00004  * MontaVista IPMI os handler interface.
00005  *
00006  * Author: MontaVista Software, Inc.
00007  *         Corey Minyard <minyard@mvista.com>
00008  *         source@mvista.com
00009  *
00010  * Copyright 2002,2003 MontaVista Software Inc.
00011  *
00012  *  This program is free software; you can redistribute it and/or
00013  *  modify it under the terms of the GNU Lesser General Public License
00014  *  as published by the Free Software Foundation; either version 2 of
00015  *  the License, or (at your option) any later version.
00016  *
00017  *
00018  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00019  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00020  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00021  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00023  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00024  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00025  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00026  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00027  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  *
00029  *  You should have received a copy of the GNU Lesser General Public
00030  *  License along with this program; if not, write to the Free
00031  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00032  */
00033 
00034 #ifndef __IPMI_POSIX_H
00035 #define __IPMI_POSIX_H
00036 
00037 #include <OpenIPMI/os_handler.h>
00038 #include <OpenIPMI/selector.h>
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /* These are the defined OS handlers for POSIX with and without
00045    threading.  If you use these (and thus link with the OpenIPMIposix
00046    or OpenIPMIpthread libraries) you must provide posix_vlog().  It is
00047    not provided by the library. */
00048 /* DEPRECATED - This should no longer be used, you should use the
00049    OS-handler function to set your log handler.  If you do not supply
00050    your own os_vlog handler, logs will go to stderr.  If you supply a
00051    posix_vlog handler and don't call set_log_handler in the OS handler,
00052    posix_vlog() will still be used. */
00053 void posix_vlog(char *format,
00054                 enum ipmi_log_type_e log_type,
00055                 va_list ap);
00056 
00057 /* Non-threaded os handler operations */
00058 
00059 /**********************************************************************
00060  * Allocate and set up an OS handler and selector for non-threaded
00061  * use.  This is the one you should use unless you have special needs
00062  * for the selector.
00063  *********************************************************************/
00064 /* Allocate and configure an OS handler. */
00065 os_handler_t *ipmi_posix_setup_os_handler(void);
00066 /* Gets the selector associated with the OS handler. */
00067 selector_t *ipmi_posix_os_handler_get_sel(os_handler_t *os_hnd);
00068 
00069 
00070 /**********************************************************************
00071  * Allocate and free an OS handler that uses non-threaded POSIX calls.
00072  * These are required if you need to know about your selector ahead of
00073  * time.  To use this, do something like:
00074  *   os_hnd = ipmi_posix_get_os_handler();
00075  *   if (!os_hnd) {
00076  *      printf("ipmi_smi_setup_con: Unable to allocate os handler\n");
00077  *      exit(1);
00078  *  }
00079  *
00080  *  rv = sel_alloc_selector(os_hnd, &sel);
00081  *  if (rv)
00082  *      handle_error();
00083  *
00084  *  ipmi_posix_os_handler_set_sel(os_hnd, sel);
00085  *
00086  *  ipmi_init(os_hnd);
00087  *
00088  * You only really need to use this in special circumstances.
00089  *********************************************************************/
00090 os_handler_t *ipmi_posix_get_os_handler(void);
00091 void ipmi_posix_free_os_handler(os_handler_t *os_hnd);
00092 /* You MUST set the SEL you alloc in the OS handler before you do
00093    anything else with the OS handler. */
00094 void ipmi_posix_os_handler_set_sel(os_handler_t *os_hnd, selector_t *sel);
00095 
00096 
00097 /**********************************************************************
00098  * Allocate and set up an OS handler and selector for hreaded use.
00099  * This is the one you should use unless you have special needs for
00100  * the selector.
00101  *********************************************************************/
00102 /* Set up a selector.  wake_sig is used to wake up selects when things
00103    change and they need to wake up.  It must be some unused signal (it
00104    does not have to be queued); a signal handler will be installed for
00105    it. */
00106 os_handler_t *ipmi_posix_thread_setup_os_handler(int wake_sig);
00107 /* Gets the selector associated with the OS handler. */
00108 selector_t *ipmi_posix_thread_os_handler_get_sel(os_handler_t *os_hnd);
00109 
00110 /**********************************************************************
00111  * Special code, like the previous non-threaded ones.  Only needed
00112  * if you have special selector needs.
00113  *********************************************************************/
00114 os_handler_t *ipmi_posix_thread_get_os_handler(void);
00115 void ipmi_posix_thread_free_os_handler(os_handler_t *os_hnd);
00116 void ipmi_posix_thread_os_handler_set_sel(os_handler_t *os_hnd,
00117                                           selector_t   *sel);
00118 
00119 /**********************************************************************
00120  * Internals for the selector code, pay not attention to the man
00121  * behind the curtains...
00122  *********************************************************************/
00123 int posix_mutex_alloc(void**);
00124 void posix_mutex_free(void *);
00125 void posix_mutex_lock(void *);
00126 void posix_mutex_unlock(void *);
00127 
00128 /**********************************************************************
00129  * Cruft, do not use these function any more.
00130  *********************************************************************/
00131 
00132 #ifndef IPMI_FUNC_DEPRECATED
00133 # if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))
00134 #  define IPMI_FUNC_DEPRECATED __attribute__ ((deprecated))
00135 #  define IPMI_TYPE_DEPRECATED __attribute__ ((deprecated))
00136 #  define IPMI_VAR_DEPRECATED __attribute__ ((deprecated))
00137 # else
00138 #  define IPMI_FUNC_DEPRECATED
00139 #  define IPMI_TYPE_DEPRECATED
00140 #  define IPMI_VAR_DEPRECATED
00141 # endif
00142 #endif
00143 
00144 /* Cleanup and free an OS handler. */
00145 void ipmi_posix_cleanup_os_handler(os_handler_t *os_hnd)
00146      IPMI_FUNC_DEPRECATED;
00147 /* Calls sel_select() with the proper data. */
00148 int ipmi_posix_sel_select(os_handler_t   *os_hnd,
00149                            struct timeval *timeout)
00150      IPMI_FUNC_DEPRECATED;
00151 /* Calls sel_select_loop() with the proper data. */
00152 void ipmi_posix_sel_select_loop(os_handler_t *os_hnd)
00153      IPMI_FUNC_DEPRECATED;
00154 
00155 /* Clean up the threaded selector, including returning the signal to
00156    its original state. */
00157 void ipmi_posix_thread_cleanup_os_handler(os_handler_t *os_hnd)
00158      IPMI_FUNC_DEPRECATED;
00159 /* Calls sel_select() with the proper data.  Note that if you send
00160    "wake_sig" to the calling thread, this will return. */
00161 int ipmi_posix_thread_sel_select(os_handler_t   *os_hnd,
00162                                  struct timeval *timeout)
00163      IPMI_FUNC_DEPRECATED;
00164 /* Calls sel_select_loop() with the proper data. */
00165 void ipmi_posix_thread_sel_select_loop(os_handler_t *os_hnd)
00166      IPMI_FUNC_DEPRECATED;
00167 
00168 #ifdef __cplusplus
00169 }
00170 #endif
00171 
00172 #endif /* __IPMI_POSIX_H */

© sourcejam.com 2005-2008