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

ipmi_sdr.h

Go to the documentation of this file.
00001 /*
00002  * ipmi_sdr.h
00003  *
00004  * MontaVista IPMI interface for SDRs
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_SDR_H
00035 #define _IPMI_SDR_H
00036 #include <OpenIPMI/ipmi_types.h>
00037 #include <stdint.h>
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 #define MAX_SDR_DATA 255
00044 
00045 /* Generic information about an SDR. */
00046 typedef struct ipmi_sdr_s
00047 {
00048     uint16_t record_id;
00049     uint8_t  major_version;
00050     uint8_t  minor_version;
00051     uint8_t  type;
00052     uint8_t  length;
00053     uint8_t  data[MAX_SDR_DATA];
00054 } ipmi_sdr_t;
00055 
00056 /* Opaque type representing a remote SDR repository. */
00057 typedef struct ipmi_sdr_info_s ipmi_sdr_info_t;
00058 
00059 /* Create a local representation of a remote SDR repository.  When
00060    created, it will not automatically fetch the remote SDRs, you need
00061    to do that.  If "sensor" is true, then this will fetch the "sensor"
00062    SDRs using GET DEVICE SDR.  If not, it will use GET SDR for
00063    fetching SDRs. */
00064 int ipmi_sdr_info_alloc(ipmi_domain_t   *domain,
00065                         ipmi_mc_t       *mc,
00066                         unsigned int    lun,
00067                         int             sensor,
00068                         ipmi_sdr_info_t **new_sdrs);
00069 
00070 /* Remove all the SDRs, but don't destroy the SDR repository. */
00071 void ipmi_sdr_clean_out_sdrs(ipmi_sdr_info_t *sdrs);
00072 
00073 /* Destroy an SDR.  Note that if the SDR is currently fetching SDRs,
00074    the destroy cannot complete immediatly, it will be marked for
00075    destruction later.  You can supply a callback that, if not NULL,
00076    will be called when the sdr is destroyed. */
00077 typedef void (*ipmi_sdr_destroyed_t)(ipmi_sdr_info_t *sdrs, void *cb_data);
00078 int ipmi_sdr_info_destroy(ipmi_sdr_info_t      *sdrs,
00079                           ipmi_sdr_destroyed_t handler,
00080                           void                 *cb_data);
00081 
00082 /* Fetch the remote SDRs, but do not wait until the fetch is complete,
00083    return immediately.  When the fetch is complete, call the given
00084    handler. */
00085 typedef void (*ipmi_sdrs_fetched_t)(ipmi_sdr_info_t *sdrs,
00086                                     int             err,
00087                                     int             changed,
00088                                     unsigned int    count,
00089                                     void            *cb_data);
00090 int ipmi_sdr_fetch(ipmi_sdr_info_t     *sdrs,
00091                    ipmi_sdrs_fetched_t handler,
00092                    void                *cb_data);
00093 
00094 /* Return the number of SDRs in the sdr repository. */
00095 int ipmi_get_sdr_count(ipmi_sdr_info_t *sdr,
00096                        unsigned int    *count);
00097 
00098 /* Find the SDR with the given record id. */
00099 int ipmi_get_sdr_by_recid(ipmi_sdr_info_t *sdr,
00100                           int             recid,
00101                           ipmi_sdr_t      *return_sdr);
00102 
00103 /* Find the first SDR with the given type. */
00104 int ipmi_get_sdr_by_type(ipmi_sdr_info_t *sdr,
00105                          int             type,
00106                          ipmi_sdr_t      *return_sdr);
00107 
00108 /* Find the SDR with the given index. The indexes are the internal
00109    array indexes for the SDR, this can be used to iterate through the
00110    SDRs. */
00111 int ipmi_get_sdr_by_index(ipmi_sdr_info_t *sdr,
00112                           int             index,
00113                           ipmi_sdr_t      *return_sdr);
00114 
00115 /* Set an SDR's value.  This is primarily for the OEM SDR fixup code,
00116    so it can fix an SDR and write it back. */
00117 int ipmi_set_sdr_by_index(ipmi_sdr_info_t *sdrs,
00118                           int             index,
00119                           ipmi_sdr_t      *sdr);
00120 
00121 /* Fetch all the sdrs.  The array size should point to a value that
00122    holds the number of elements in the passed in array.  The
00123    array_size will be set to the actual number of elements put into
00124    the array.  If the number of SDRs is larger than the supplied
00125    array_size, this will return E2BIG and do nothing. */
00126 int ipmi_get_all_sdrs(ipmi_sdr_info_t *sdr,
00127                       int             *array_size,
00128                       ipmi_sdr_t      *array);
00129 
00130 /* Get various information from the IPMI SDR info commands. */
00131 int ipmi_sdr_get_major_version(ipmi_sdr_info_t *sdr, int *val);
00132 int ipmi_sdr_get_minor_version(ipmi_sdr_info_t *sdr, int *val);
00133 int ipmi_sdr_get_overflow(ipmi_sdr_info_t *sdr, int *val);
00134 int ipmi_sdr_get_update_mode(ipmi_sdr_info_t *sdr, int *val);
00135 int ipmi_sdr_get_supports_delete_sdr(ipmi_sdr_info_t *sdr, int *val);
00136 int ipmi_sdr_get_supports_partial_add_sdr(ipmi_sdr_info_t *sdr, int *val);
00137 int ipmi_sdr_get_supports_reserve_sdr(ipmi_sdr_info_t *sdr, int *val);
00138 int ipmi_sdr_get_supports_get_sdr_repository_allocation(ipmi_sdr_info_t *sdr,
00139                                                         int             *val);
00140 int ipmi_sdr_get_dynamic_population(ipmi_sdr_info_t *sdr, int *val);
00141 int ipmi_sdr_get_lun_has_sensors(ipmi_sdr_info_t *sdr,
00142                                  unsigned int    lun,
00143                                  int             *val);
00144 
00145 /* Append the SDR to the repository. */
00146 int ipmi_sdr_add(ipmi_sdr_info_t *sdrs,
00147                  ipmi_sdr_t      *sdr);
00148 
00149 /* Store the SDRs into the SDR repository. */
00150 typedef void (*ipmi_sdr_save_cb)(ipmi_sdr_info_t *sdrs, int err, void *cb_data);
00151 int ipmi_sdr_save(ipmi_sdr_info_t  *sdrs,
00152                   ipmi_sdr_save_cb done,
00153                   void             *cb_data);
00154 
00155 #ifdef __cplusplus
00156 }
00157 #endif
00158 
00159 #endif /* _IPMI_SDR_H */

© sourcejam.com 2005-2008