~ubuntu-branches/ubuntu/karmic/openipmi/karmic

« back to all changes in this revision

Viewing changes to include/OpenIPMI/ipmi_sdr.h

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2005-07-04 21:29:17 UTC
  • Revision ID: james.westby@ubuntu.com-20050704212917-igddk5jawjmhrlay
Tags: upstream-2.0.1
Import upstream version 2.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ipmi_sdr.h
 
3
 *
 
4
 * MontaVista IPMI interface for SDRs
 
5
 *
 
6
 * Author: MontaVista Software, Inc.
 
7
 *         Corey Minyard <minyard@mvista.com>
 
8
 *         source@mvista.com
 
9
 *
 
10
 * Copyright 2002,2003 MontaVista Software Inc.
 
11
 *
 
12
 *  This program is free software; you can redistribute it and/or
 
13
 *  modify it under the terms of the GNU Lesser General Public License
 
14
 *  as published by the Free Software Foundation; either version 2 of
 
15
 *  the License, or (at your option) any later version.
 
16
 *
 
17
 *
 
18
 *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 
19
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
20
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
21
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 
22
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 
23
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 
24
 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 
26
 *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
27
 *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 *
 
29
 *  You should have received a copy of the GNU Lesser General Public
 
30
 *  License along with this program; if not, write to the Free
 
31
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
32
 */
 
33
 
 
34
#ifndef _IPMI_SDR_H
 
35
#define _IPMI_SDR_H
 
36
#include <OpenIPMI/ipmi_types.h>
 
37
#include <stdint.h>
 
38
 
 
39
#ifdef __cplusplus
 
40
extern "C" {
 
41
#endif
 
42
 
 
43
#define MAX_SDR_DATA 255
 
44
 
 
45
/* Generic information about an SDR. */
 
46
typedef struct ipmi_sdr_s
 
47
{
 
48
    uint16_t record_id;
 
49
    uint8_t  major_version;
 
50
    uint8_t  minor_version;
 
51
    uint8_t  type;
 
52
    uint8_t  length;
 
53
    uint8_t  data[MAX_SDR_DATA];
 
54
} ipmi_sdr_t;
 
55
 
 
56
/* Opaque type representing a remote SDR repository. */
 
57
typedef struct ipmi_sdr_info_s ipmi_sdr_info_t;
 
58
 
 
59
/* Create a local representation of a remote SDR repository.  When
 
60
   created, it will not automatically fetch the remote SDRs, you need
 
61
   to do that.  If "sensor" is true, then this will fetch the "sensor"
 
62
   SDRs using GET DEVICE SDR.  If not, it will use GET SDR for
 
63
   fetching SDRs. */
 
64
int ipmi_sdr_info_alloc(ipmi_domain_t   *domain,
 
65
                        ipmi_mc_t       *mc,
 
66
                        unsigned int    lun,
 
67
                        int             sensor,
 
68
                        ipmi_sdr_info_t **new_sdrs);
 
69
 
 
70
/* Remove all the SDRs, but don't destroy the SDR repository. */
 
71
void ipmi_sdr_clean_out_sdrs(ipmi_sdr_info_t *sdrs);
 
72
 
 
73
/* Destroy an SDR.  Note that if the SDR is currently fetching SDRs,
 
74
   the destroy cannot complete immediatly, it will be marked for
 
75
   destruction later.  You can supply a callback that, if not NULL,
 
76
   will be called when the sdr is destroyed. */
 
77
typedef void (*ipmi_sdr_destroyed_t)(ipmi_sdr_info_t *sdrs, void *cb_data);
 
78
int ipmi_sdr_info_destroy(ipmi_sdr_info_t      *sdrs,
 
79
                          ipmi_sdr_destroyed_t handler,
 
80
                          void                 *cb_data);
 
81
 
 
82
/* Fetch the remote SDRs, but do not wait until the fetch is complete,
 
83
   return immediately.  When the fetch is complete, call the given
 
84
   handler. */
 
85
typedef void (*ipmi_sdrs_fetched_t)(ipmi_sdr_info_t *sdrs,
 
86
                                    int             err,
 
87
                                    int             changed,
 
88
                                    unsigned int    count,
 
89
                                    void            *cb_data);
 
90
int ipmi_sdr_fetch(ipmi_sdr_info_t     *sdrs,
 
91
                   ipmi_sdrs_fetched_t handler,
 
92
                   void                *cb_data);
 
93
 
 
94
/* Return the number of SDRs in the sdr repository. */
 
95
int ipmi_get_sdr_count(ipmi_sdr_info_t *sdr,
 
96
                       unsigned int    *count);
 
97
 
 
98
/* Find the SDR with the given record id. */
 
99
int ipmi_get_sdr_by_recid(ipmi_sdr_info_t *sdr,
 
100
                          int             recid,
 
101
                          ipmi_sdr_t      *return_sdr);
 
102
 
 
103
/* Find the first SDR with the given type. */
 
104
int ipmi_get_sdr_by_type(ipmi_sdr_info_t *sdr,
 
105
                         int             type,
 
106
                         ipmi_sdr_t      *return_sdr);
 
107
 
 
108
/* Find the SDR with the given index. The indexes are the internal
 
109
   array indexes for the SDR, this can be used to iterate through the
 
110
   SDRs. */
 
111
int ipmi_get_sdr_by_index(ipmi_sdr_info_t *sdr,
 
112
                          int             index,
 
113
                          ipmi_sdr_t      *return_sdr);
 
114
 
 
115
/* Set an SDR's value.  This is primarily for the OEM SDR fixup code,
 
116
   so it can fix an SDR and write it back. */
 
117
int ipmi_set_sdr_by_index(ipmi_sdr_info_t *sdrs,
 
118
                          int             index,
 
119
                          ipmi_sdr_t      *sdr);
 
120
 
 
121
/* Fetch all the sdrs.  The array size should point to a value that
 
122
   holds the number of elements in the passed in array.  The
 
123
   array_size will be set to the actual number of elements put into
 
124
   the array.  If the number of SDRs is larger than the supplied
 
125
   array_size, this will return E2BIG and do nothing. */
 
126
int ipmi_get_all_sdrs(ipmi_sdr_info_t *sdr,
 
127
                      int             *array_size,
 
128
                      ipmi_sdr_t      *array);
 
129
 
 
130
/* Get various information from the IPMI SDR info commands. */
 
131
int ipmi_sdr_get_major_version(ipmi_sdr_info_t *sdr, int *val);
 
132
int ipmi_sdr_get_minor_version(ipmi_sdr_info_t *sdr, int *val);
 
133
int ipmi_sdr_get_overflow(ipmi_sdr_info_t *sdr, int *val);
 
134
int ipmi_sdr_get_update_mode(ipmi_sdr_info_t *sdr, int *val);
 
135
int ipmi_sdr_get_supports_delete_sdr(ipmi_sdr_info_t *sdr, int *val);
 
136
int ipmi_sdr_get_supports_partial_add_sdr(ipmi_sdr_info_t *sdr, int *val);
 
137
int ipmi_sdr_get_supports_reserve_sdr(ipmi_sdr_info_t *sdr, int *val);
 
138
int ipmi_sdr_get_supports_get_sdr_repository_allocation(ipmi_sdr_info_t *sdr,
 
139
                                                        int             *val);
 
140
int ipmi_sdr_get_dynamic_population(ipmi_sdr_info_t *sdr, int *val);
 
141
int ipmi_sdr_get_lun_has_sensors(ipmi_sdr_info_t *sdr,
 
142
                                 unsigned int    lun,
 
143
                                 int             *val);
 
144
 
 
145
/* Append the SDR to the repository. */
 
146
int ipmi_sdr_add(ipmi_sdr_info_t *sdrs,
 
147
                 ipmi_sdr_t      *sdr);
 
148
 
 
149
/* Store the SDRs into the SDR repository. */
 
150
typedef void (*ipmi_sdr_save_cb)(ipmi_sdr_info_t *sdrs, int err, void *cb_data);
 
151
int ipmi_sdr_save(ipmi_sdr_info_t  *sdrs,
 
152
                  ipmi_sdr_save_cb done,
 
153
                  void             *cb_data);
 
154
 
 
155
#ifdef __cplusplus
 
156
}
 
157
#endif
 
158
 
 
159
#endif /* _IPMI_SDR_H */