4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include "ipmi_impl.h"
37 * 31.2 Get SEL Info Command.
40 ipmi_sel_get_info(ipmi_handle_t
*ihp
)
47 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
49 cmd
.ic_cmd
= IPMI_CMD_GET_SEL_INFO
;
53 if ((rsp
= ipmi_send(ihp
, &cmd
)) == NULL
)
56 ip
= (ipmi_sel_info_t
*)rsp
->ic_data
;
58 tmp16
= LE_IN16(&ip
->isel_entries
);
59 (void) memcpy(&ip
->isel_entries
, &tmp16
, sizeof (tmp16
));
60 tmp16
= LE_IN16(&ip
->isel_free
);
61 (void) memcpy(&ip
->isel_free
, &tmp16
, sizeof (tmp16
));
62 tmp32
= LE_IN32(&ip
->isel_add_ts
);
63 (void) memcpy(&ip
->isel_add_ts
, &tmp32
, sizeof (tmp32
));
64 tmp32
= LE_IN32(&ip
->isel_erase_ts
);
65 (void) memcpy(&ip
->isel_erase_ts
, &tmp32
, sizeof (tmp32
));
70 typedef struct ipmi_cmd_get_sel_entry
{
71 uint16_t ic_sel_ent_resid
;
72 uint16_t ic_sel_ent_recid
;
73 uint8_t ic_sel_ent_offset
;
74 uint8_t ic_sel_ent_bytes
;
75 } ipmi_cmd_get_sel_entry_t
;
78 ipmi_sel_get_entry(ipmi_handle_t
*ihp
, uint16_t id
)
81 ipmi_sel_event_t
*evp
;
82 ipmi_cmd_get_sel_entry_t data
;
85 data
.ic_sel_ent_resid
= 0;
86 data
.ic_sel_ent_recid
= LE_16(id
);
87 data
.ic_sel_ent_offset
= 0;
88 data
.ic_sel_ent_bytes
= 0xFF;
90 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
92 cmd
.ic_cmd
= IPMI_CMD_GET_SEL_ENTRY
;
93 cmd
.ic_dlen
= sizeof (data
);
96 if ((rsp
= ipmi_send(ihp
, &cmd
)) == NULL
)
99 if (rsp
->ic_dlen
< sizeof (ipmi_sel_event_t
)) {
100 (void) ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
);
104 evp
= (ipmi_sel_event_t
*)rsp
->ic_data
;
106 evp
->isel_ev_next
= LE_IN16(&evp
->isel_ev_next
);
107 evp
->isel_ev_recid
= LE_IN16(&evp
->isel_ev_recid
);
108 if (evp
->isel_ev_rectype
== IPMI_SEL_SYSTEM
||
109 evp
->isel_ev_rectype
>= IPMI_SEL_OEM_LO
) {
111 tmp
= LE_IN32(&evp
->isel_ev_ts
);
112 (void) memcpy(&evp
->isel_ev_ts
, &tmp
, sizeof (tmp
));
118 * SEL time management. For the purposes of libipmi we assume that the SDR
119 * repository and SEL share the same timebase, even though the spec allows for
120 * separate time sources. Hence no function to set the SDR repository time.
123 ipmi_sel_get_time(ipmi_handle_t
*ihp
, uint32_t *tp
)
125 ipmi_cmd_t cmd
, *rsp
;
127 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
129 cmd
.ic_cmd
= IPMI_CMD_GET_SEL_TIME
;
133 if ((rsp
= ipmi_send(ihp
, &cmd
)) == NULL
)
136 if (rsp
->ic_dlen
< sizeof (uint32_t))
137 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));
139 *tp
= LE_IN32(rsp
->ic_data
);
145 ipmi_sel_set_time(ipmi_handle_t
*ihp
, uint32_t t
)
151 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
153 cmd
.ic_cmd
= IPMI_CMD_SET_SEL_TIME
;
154 cmd
.ic_dlen
= sizeof (t
);
157 if (ipmi_send(ihp
, &cmd
) == NULL
)
164 ipmi_sel_get_utc_offset(ipmi_handle_t
*ihp
, int *offp
)
166 ipmi_cmd_t cmd
, *rsp
;
169 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
171 cmd
.ic_cmd
= IPMI_CMD_GET_SEL_UTC_OFFSET
;
175 if ((rsp
= ipmi_send(ihp
, &cmd
)) == NULL
)
178 if (rsp
->ic_dlen
< sizeof (uint16_t))
179 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));
181 off16
= LE_IN16(rsp
->ic_data
);
188 ipmi_sel_set_utc_offset(ipmi_handle_t
*ihp
, int off
)
193 off16
= LE_16(off16
);
195 cmd
.ic_netfn
= IPMI_NETFN_STORAGE
;
197 cmd
.ic_cmd
= IPMI_CMD_SET_SEL_UTC_OFFSET
;
198 cmd
.ic_dlen
= sizeof (off16
);
199 cmd
.ic_data
= &off16
;
201 if (ipmi_send(ihp
, &cmd
) == NULL
)