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

« back to all changes in this revision

Viewing changes to include/OpenIPMI/internal/ipmi_domain.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_domain.h
 
3
 *
 
4
 * MontaVista IPMI interface for management domains
 
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_DOMAIN_H
 
35
#define _IPMI_DOMAIN_H
 
36
#include <OpenIPMI/ipmi_types.h>
 
37
#include <OpenIPMI/os_handler.h>
 
38
#include <OpenIPMI/ipmi_sdr.h>
 
39
#include <OpenIPMI/ipmi_addr.h>
 
40
 
 
41
#include <OpenIPMI/internal/ipmi_entity.h>
 
42
#include <OpenIPMI/internal/ipmi_sensor.h>
 
43
#include <OpenIPMI/internal/ipmi_control.h>
 
44
 
 
45
/* Handle validation and usecounts on domains. */
 
46
int _ipmi_domain_get(ipmi_domain_t *domain);
 
47
void _ipmi_domain_put(ipmi_domain_t *domain);
 
48
 
 
49
/* Return the OS handler used by the mc. */
 
50
os_handler_t *ipmi_domain_get_os_hnd(ipmi_domain_t *domain);
 
51
 
 
52
/* Return the entity info for the given domain. */
 
53
ipmi_entity_info_t *ipmi_domain_get_entities(ipmi_domain_t *domain);
 
54
 
 
55
/* Should the BMC do a full bus scan at startup?  This is so OEM
 
56
   code can turn this function off.  The value is a boolean. */
 
57
int ipmi_domain_set_full_bus_scan(ipmi_domain_t *domain, int val);
 
58
 
 
59
int ipmi_domain_get_event_rcvr(ipmi_domain_t *domain);
 
60
 
 
61
/* Allocate an MC in the domain.  It doesn't add it to the domain's
 
62
   list, to allow the MC to be setup before that happens. */
 
63
int ipmi_create_mc(ipmi_domain_t *domain,
 
64
                   ipmi_addr_t   *addr,
 
65
                   unsigned int  addr_len,
 
66
                   ipmi_mc_t     **new_mc);
 
67
 
 
68
int _ipmi_remove_mc_from_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
 
69
 
 
70
/* Attempt to find the MC, and if it doesn't exist create it and
 
71
   return it. */
 
72
int _ipmi_find_or_create_mc_by_slave_addr(ipmi_domain_t *domain,
 
73
                                          unsigned int  channel,
 
74
                                          unsigned int  slave_addr,
 
75
                                          ipmi_mc_t     **mc);
 
76
 
 
77
/* Find the MC with the given IPMI address, or return NULL if not
 
78
   found. */
 
79
ipmi_mc_t *_ipmi_find_mc_by_addr(ipmi_domain_t *domain,
 
80
                                 ipmi_addr_t   *addr,
 
81
                                 unsigned int  addr_len);
 
82
 
 
83
/* Return the SDRs for the given MC, or the main set of SDRs if the MC
 
84
   is NULL. */
 
85
void _ipmi_get_sdr_sensors(ipmi_domain_t *domain,
 
86
                           ipmi_mc_t     *mc,
 
87
                           ipmi_sensor_t ***sensors,
 
88
                           unsigned int  *count);
 
89
 
 
90
/* Set the SDRs for the given MC, or the main set of SDRs if the MC is
 
91
   NULL. */
 
92
void _ipmi_set_sdr_sensors(ipmi_domain_t *domain,
 
93
                           ipmi_mc_t     *mc,
 
94
                           ipmi_sensor_t **sensors,
 
95
                           unsigned int  count);
 
96
 
 
97
/* Returns/set the SDRs entity info for the given MC, or the main set
 
98
   of SDRs if the MC is NULL. */
 
99
void *_ipmi_get_sdr_entities(ipmi_domain_t *domain,
 
100
                             ipmi_mc_t     *mc);
 
101
void _ipmi_set_sdr_entities(ipmi_domain_t *domain,
 
102
                            ipmi_mc_t     *mc,
 
103
                            void          *entities);
 
104
 
 
105
/* Add an MC to the list of MCs in the domain. */
 
106
int ipmi_add_mc_to_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
 
107
 
 
108
/* Remove an MC from the list of MCs in the domain. */
 
109
int ipmi_remove_mc_from_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
 
110
 
 
111
/* The old interfaces (for backwards compatability).  DON'T USE THESE!! */
 
112
struct ipmi_domain_mc_upd_s;
 
113
typedef struct ipmi_domain_mc_upd_s ipmi_domain_mc_upd_t
 
114
     IPMI_TYPE_DEPRECATED;
 
115
int ipmi_domain_register_mc_update_handler(ipmi_domain_t         *domain,
 
116
                                           ipmi_domain_mc_upd_cb handler,
 
117
                                           void                  *cb_data,
 
118
                                           struct ipmi_domain_mc_upd_s  **id)
 
119
     IPMI_FUNC_DEPRECATED;
 
120
void ipmi_domain_remove_mc_update_handler(ipmi_domain_t        *domain,
 
121
                                          struct ipmi_domain_mc_upd_s *id)
 
122
     IPMI_FUNC_DEPRECATED;
 
123
 
 
124
/* Call any OEM handlers for the given MC. */
 
125
int _ipmi_domain_check_oem_handlers(ipmi_domain_t *domain, ipmi_mc_t *mc);
 
126
 
 
127
/* Scan a system interface address for an MC. */
 
128
void ipmi_start_si_scan(ipmi_domain_t *domain,
 
129
                        int            si_num,
 
130
                        ipmi_domain_cb done_handler,
 
131
                        void           *cb_data);
 
132
 
 
133
/* Add an IPMB address to a list of addresses to not scan.  This way,
 
134
   if you have weak puny devices in IPMB that will break if you do
 
135
   normal IPMB operations, you can have them be ignored. */
 
136
int ipmi_domain_add_ipmb_ignore(ipmi_domain_t *domain,
 
137
                                unsigned char ipmb_addr);
 
138
int ipmi_domain_add_ipmb_ignore_range(ipmi_domain_t *domain,
 
139
                                      unsigned char first_ipmb_addr,
 
140
                                      unsigned char last_ipmb_addr);
 
141
 
 
142
/* If OEM code gets and event and it doesn't deliver it to the user,
 
143
   it should deliver it this way, that way it can be delivered to the
 
144
   user to be deleted. */
 
145
void ipmi_handle_unhandled_event(ipmi_domain_t *domain, ipmi_event_t *event);
 
146
 
 
147
/* Handle a new event from something, usually from an SEL. */
 
148
void _ipmi_domain_system_event_handler(ipmi_domain_t *domain,
 
149
                                       ipmi_mc_t     *mc,
 
150
                                       ipmi_event_t  *event);
 
151
 
 
152
/* Returns the main SDR repository for the domain, or NULL if there is
 
153
   not one. */
 
154
ipmi_sdr_info_t *ipmi_domain_get_main_sdrs(ipmi_domain_t *domain);
 
155
 
 
156
/* Get the number of channels the domain supports. */
 
157
int ipmi_domain_get_num_channels(ipmi_domain_t *domain, int *val);
 
158
 
 
159
/* Get information about a channel by index.  The index is not
 
160
   necessarily the channel number, just an array index (up to the
 
161
   number of channels).  Get the channel number from the returned
 
162
   information. */
 
163
int ipmi_domain_get_channel(ipmi_domain_t    *domain,
 
164
                            int              index,
 
165
                            ipmi_chan_info_t *chan);
 
166
 
 
167
/* These calls deal with OEM-type handlers for domains.  Certain
 
168
   domains can be detected with special means (beyond just the
 
169
   manufacturer and product id) and this allows handlers for these
 
170
   types of domains to be registered.  At the very initial connection
 
171
   of every domain, the handler will be called and it must detect
 
172
   whether this is the specific type of domain or not, do any setup
 
173
   for that domain type, and then call the done routine passed in.
 
174
   Note that the done routine may be called later, (allowing this
 
175
   handler to send messages and the like) but it *must* be called.
 
176
   Note that the error value in the check_done routine should be
 
177
   ENOSYS if the specific OEM handlers were not applicable, 0 if the
 
178
   OEM handlers were installed, and anything else for specific
 
179
   errors installing the OEM handlers. */
 
180
typedef void (*ipmi_domain_oem_check_done)(ipmi_domain_t *domain,
 
181
                                           int           err,
 
182
                                           void          *cb_data);
 
183
typedef int (*ipmi_domain_oem_check)(ipmi_domain_t              *domain,
 
184
                                     ipmi_domain_oem_check_done done,
 
185
                                     void                       *cb_data);
 
186
int ipmi_register_domain_oem_check(ipmi_domain_oem_check check,
 
187
                                   void                  *cb_data);
 
188
int ipmi_deregister_domain_oem_check(ipmi_domain_oem_check check,
 
189
                                     void                  *cb_data);
 
190
 
 
191
/* Register OEM data for the domain.  Note that you can set a function
 
192
   that will be called after all the domain messages have been flushed
 
193
   but before anything else is destroyed.  If the OEM data or
 
194
   destroyer is NULL, it will not be called. */
 
195
typedef void (*ipmi_domain_destroy_oem_data_cb)(ipmi_domain_t *domain,
 
196
                                                void          *oem_data);
 
197
void ipmi_domain_set_oem_data(ipmi_domain_t                   *domain,
 
198
                              void                            *oem_data,
 
199
                              ipmi_domain_destroy_oem_data_cb destroyer);
 
200
void *ipmi_domain_get_oem_data(ipmi_domain_t *domain);
 
201
 
 
202
/* Register a call that will be done at the beginning of the domain
 
203
   shutdown process.  Setting it to NULL will disable it. */
 
204
typedef void (*ipmi_domain_shutdown_cb)(ipmi_domain_t *domain);
 
205
void ipmi_domain_set_oem_shutdown_handler(ipmi_domain_t           *domain,
 
206
                                          ipmi_domain_shutdown_cb handler);
 
207
 
 
208
/* Set the domain type for a domain. */
 
209
void ipmi_domain_set_type(ipmi_domain_t *domain, enum ipmi_domain_type dtype);
 
210
 
 
211
/* OEM code can call then when it know that an MC scan is complete, to
 
212
   speed things up. */
 
213
void _ipmi_mc_scan_done(ipmi_domain_t *domain);
 
214
 
 
215
/* Can be used to generate unique numbers for a domain. */
 
216
unsigned int ipmi_domain_get_unique_num(ipmi_domain_t *domain);
 
217
 
 
218
/* Initialize the domain code, called only once at init time. */
 
219
int _ipmi_domain_init(void);
 
220
 
 
221
/* Clean up the global domain memory. */
 
222
void _ipmi_domain_shutdown(void);
 
223
 
 
224
 
 
225
/* Used as a refcount to know when the domain is completely
 
226
   operational. */
 
227
void _ipmi_get_domain_fully_up(ipmi_domain_t *domain);
 
228
void _ipmi_put_domain_fully_up(ipmi_domain_t *domain);
 
229
 
 
230
 
 
231
/* Option settings. */
 
232
int ipmi_option_SDRs(ipmi_domain_t *domain);
 
233
int ipmi_option_SEL(ipmi_domain_t *domain);
 
234
int ipmi_option_FRUs(ipmi_domain_t *domain);
 
235
int ipmi_option_IPMB_scan(ipmi_domain_t *domain);
 
236
int ipmi_option_OEM_init(ipmi_domain_t *domain);
 
237
int ipmi_option_set_event_rcvr(ipmi_domain_t *domain);
 
238
int ipmi_option_set_sel_time(ipmi_domain_t *domain);
 
239
int ipmi_option_activate_if_possible(ipmi_domain_t *domain);
 
240
 
 
241
/*
 
242
 * Domain attribute handling.
 
243
 *
 
244
 * An attribute is a string name that is registered with the domain along
 
245
 * with a void data item.  This allows things to be attached to the domain
 
246
 * but not directly coupled to the domain.  Names that begin with "ipmi_"
 
247
 * belong to OpenIPMI, DON'T USE THEM.  OEM names should start with
 
248
 * "oem_<type>_".  Other names are free for use by the application.
 
249
 *
 
250
 * Note that attributes are ummutable after creation and cannot be
 
251
 * destroyed.  Destruction only happens when the domain goes away, but
 
252
 * may be delayed to after the domain is gone due to race conditions.
 
253
 */
 
254
 
 
255
/* Attr init function.  Return the data item in the data field.  Returns
 
256
   an error value. */
 
257
typedef int (*ipmi_domain_attr_init_cb)(ipmi_domain_t *domain, void *cb_data,
 
258
                                        void **data);
 
259
 
 
260
/* Called when the attribute is destroyed.  Note that this may happen
 
261
   after domain destruction, so the domain may not exist any more. */
 
262
typedef void (*ipmi_domain_attr_kill_cb)(void *cb_data, void *data);
 
263
 
 
264
typedef struct ipmi_domain_attr_s ipmi_domain_attr_t;
 
265
 
 
266
/* Find an attribute for a domain.  If the attribute is not found,
 
267
   register the attribute.  If the registration occurs, the init()
 
268
   function will be called (if non-null); it must return the data item
 
269
   in the data field.  When the domain is destroyed, the destroy
 
270
   function will be called (if not null). */
 
271
int ipmi_domain_register_attribute(ipmi_domain_t            *domain,
 
272
                                   char                     *name,
 
273
                                   ipmi_domain_attr_init_cb init,
 
274
                                   ipmi_domain_attr_kill_cb destroy,
 
275
                                   void                     *cb_data,
 
276
                                   ipmi_domain_attr_t       **attr);
 
277
 
 
278
/* Find an attribute in an domain.  Returns EINVAL if the name is not
 
279
   registered.  Returns 0 on success, and the data item is
 
280
   returned. */
 
281
int ipmi_domain_find_attribute(ipmi_domain_t      *domain,
 
282
                               char               *name,
 
283
                               ipmi_domain_attr_t **attr);
 
284
 
 
285
/* Like the previous call, but takes a domain id. */
 
286
int ipmi_domain_id_find_attribute(ipmi_domain_id_t   domain_id,
 
287
                                  char               *name,
 
288
                                  ipmi_domain_attr_t **data);
 
289
 
 
290
/* Get the data item from the attr. */
 
291
void *ipmi_domain_attr_get_data(ipmi_domain_attr_t *attr);
 
292
 
 
293
/* Call this when you are done with the attr. */
 
294
void ipmi_domain_attr_put(ipmi_domain_attr_t *attr);
 
295
 
 
296
/* Add/Remove a function, that is called when any new sensor is
 
297
   added to the system and it allows OEM code to update information
 
298
   about  it if there are domain-specific sensor types that need
 
299
   to be adjusted.
 
300
*/
 
301
typedef void (*ipmi_domain_sensor_cb)(ipmi_domain_t *domain,
 
302
                                      ipmi_sensor_t *sensor,
 
303
                                      void          *cb_data);
 
304
 
 
305
int
 
306
ipmi_domain_add_new_sensor_handler(ipmi_domain_t         *domain,
 
307
                                   ipmi_domain_sensor_cb handler,
 
308
                                   void                  *cb_data);
 
309
 
 
310
int
 
311
ipmi_domain_remove_new_sensor_handler(ipmi_domain_t        *domain,
 
312
                                      ipmi_domain_sensor_cb handler,
 
313
                                      void                *cb_data);
 
314
 
 
315
int
 
316
_call_new_sensor_handlers(ipmi_domain_t *domain,
 
317
                         ipmi_sensor_t *sensor);
 
318
 
 
319
 
 
320
#endif /* _IPMI_DOMAIN_H */