1 /*
2  * emu.h
3  *
4  * MontaVista IPMI LAN server include file
5  *
6  * Author: MontaVista Software, Inc.
7  *         Corey Minyard <minyard@mvista.com>
8  *         source@mvista.com
9  *
10  * Copyright 2003,2004,2005,2012 MontaVista Software Inc.
11  *
12  * This software is available to you under a choice of one of two
13  * licenses.  You may choose to be licensed under the terms of the GNU
14  * Lesser General Public License (GPL) Version 2 or the modified BSD
15  * license below.  The following disclamer applies to both licenses:
16  *
17  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * GNU Lesser General Public Licence
29  *
30  *  This program is free software; you can redistribute it and/or
31  *  modify it under the terms of the GNU Lesser General Public License
32  *  as published by the Free Software Foundation; either version 2 of
33  *  the License, or (at your option) any later version.
34  *
35  *  You should have received a copy of the GNU Lesser General Public
36  *  License along with this program; if not, write to the Free
37  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
38  *
39  * Modified BSD Licence
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  *
45  *   1. Redistributions of source code must retain the above copyright
46  *      notice, this list of conditions and the following disclaimer.
47  *   2. Redistributions in binary form must reproduce the above
48  *      copyright notice, this list of conditions and the following
49  *      disclaimer in the documentation and/or other materials provided
50  *      with the distribution.
51  *   3. The name of the author may not be used to endorse or promote
52  *      products derived from this software without specific prior
53  *      written permission.
54  */
55 
56 #ifndef __EMU_IPMI_
57 #define __EMU_IPMI_
58 
59 #include <sys/time.h>
60 #include <OpenIPMI/serv.h>
61 #include <OpenIPMI/mcserv.h>
62 
63 void ipmi_emu_tick(emu_data_t *emu, unsigned int seconds);
64 
65 typedef void (*ipmi_emu_sleep_cb)(emu_data_t *emu, struct timeval *time);
66 
67 emu_data_t *ipmi_emu_alloc(void *user_data, ipmi_emu_sleep_cb sleeper,
68 			   sys_data_t *sysinfo);
69 
70 void *ipmi_emu_get_user_data(emu_data_t *emu);
71 
72 void ipmi_emu_sleep(emu_data_t *emu, struct timeval *time);
73 
74 void ipmi_emu_handle_msg(emu_data_t    *emu,
75 			 lmc_data_t    *srcmc,
76 			 msg_t         *msg,
77 			 unsigned char *rdata,
78 			 unsigned int  *rdata_len);
79 
80 #define IPMI_MC_DYNAMIC_SENSOR_POPULATION	(1 << 0)
81 #define IPMI_MC_PERSIST_SDR			(1 << 1)
82 
83 int ipmi_emu_add_mc(emu_data_t    *emu,
84 		    unsigned char ipmb,
85 		    unsigned char device_id,
86 		    unsigned char has_device_sdrs,
87 		    unsigned char device_revision,
88 		    unsigned char major_fw_rev,
89 		    unsigned char minor_fw_rev,
90 		    unsigned char device_support,
91 		    unsigned char mfg_id[3],
92 		    unsigned char product_id[2],
93 		    unsigned int  flags);
94 
95 lmc_data_t *ipmi_emu_get_bmc_mc(emu_data_t *emu);
96 
97 int ipmi_emu_set_bmc_mc(emu_data_t *emu, unsigned char ipmb);
98 
99 int ipmi_emu_get_mc_by_addr(emu_data_t    *emu,
100 			    unsigned char ipmb,
101 			    lmc_data_t    **mc);
102 
103 /* ATCA support */
104 int ipmi_emu_atca_enable(emu_data_t *emu);
105 int ipmi_emu_atca_set_site(emu_data_t    *emu,
106 			   unsigned char hw_address,
107 			   unsigned char site_type,
108 			   unsigned char site_number);
109 
110 int ipmi_emu_set_addr(emu_data_t *emu, unsigned int addr_num,
111 		      unsigned char addr_type,
112 		      void *addr_data, unsigned int addr_len);
113 int ipmi_emu_clear_addr(emu_data_t *emu, unsigned int addr_num);
114 
115 /* In emu_cmd.c */
116 void ipmi_emu_shutdown(emu_data_t *emu);
117 int ipmi_emu_cmd(emu_out_t *out, emu_data_t *emu, char *cmd_str);
118 int read_command_file(emu_out_t *out, emu_data_t *emu,
119 		      const char *command_file);
120 
121 void emu_set_debug_level(emu_data_t *emu, unsigned int debug_level);
122 
123 #endif /* __EMU_IPMI_ */
124