9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * CDDL HEADER START
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * The contents of this file are subject to the terms of the
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * Common Development and Distribution License (the "License").
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * You may not use this file except in compliance with the License.
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * See the License for the specific language governing permissions
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * and limitations under the License.
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * When distributing Covered Code, include this CDDL HEADER in each
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * If applicable, add the following below this CDDL HEADER, with the
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * fields enclosed by brackets "[]" replaced with your own identifying
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * information: Portions Copyright [yyyy] [name of copyright owner]
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * CDDL HEADER END
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * Use is subject to license terms.
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock#pragma ident "%Z%%M% %I% %E% SMI"
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Extracts bits between index h (high, inclusive) and l (low, exclusive) from
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * u, which must be an unsigned integer.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj#define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU))
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * Error handling
9113a79cf228b8f7bd509b1328adf88659dfe218eschrockipmi_set_error(ipmi_handle_t *ihp, int error, const char *fmt, ...)
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock (void) vsnprintf(ihp->ih_errmsg, sizeof (ihp->ih_errmsg),
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock return (-1);
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock/* ARGSUSED */
9113a79cf228b8f7bd509b1328adf88659dfe218eschrockconst char *
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj for (i = 0; ipmi_errno_table[i].int_name != NULL; i++) {
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock if (str == NULL && (str = strerror(ihp->ih_errno)) == NULL)
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock (void) snprintf(ihp->ih_errbuf, sizeof (ihp->ih_errbuf),
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock * Memory allocation
9113a79cf228b8f7bd509b1328adf88659dfe218eschrock/* ARGSUSED */
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Translation between #defines and strings.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj for (ntp = &ipmi_entity_table[0]; ntp->int_name != NULL; ntp++) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_sensor_type_name(uint8_t type, char *buf, size_t len)
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj for (ntp = &ipmi_sensor_type_table[0]; ntp->int_name != NULL; ntp++) {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjipmi_sensor_units_name(uint8_t type, char *buf, size_t len)
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (ntp = &ipmi_units_type_table[0]; ntp->int_name != NULL; ntp++) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_sensor_reading_name(uint8_t sensor_type, uint8_t reading_type,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Converts a BCD decimal value to an integer.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj for (i = 7; i >= 0; i--) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * See sections 43.15 and 43.16
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * This is a utility function for decoding the strings that are packed into
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * sensor data records. If the type is 6-bit packed ASCII, then it converts
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * the string to an 8-bit ASCII string and copies that into the suuplied buffer.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * If it is 8-bit ASCII, it copies the string into the supplied buffer as-is.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_decode_string(uint8_t type, uint8_t len, char *data, char *buf)
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (len == 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * If the type is 8-bit ASCII, we can simply copy the string and return
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Yuck - they either used BCD plus encoding, which we don't
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * currently handle, or they used an unspecified encoding type.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * In these cases we'll set buf to an empty string. We still
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * need to return the length so that we can get to the next
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Otherwise, it's 6-bit packed ASCII, so we have to convert the
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * data first
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * First we decode the 6-bit string in chunks of 3 bytes as far as
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * possible
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj for (i = 0; i < chunks; i++) {