[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freeipmi-devel] opinion on new ipmi_kcs_cmd_raw()
From: |
Albert Chu |
Subject: |
[Freeipmi-devel] opinion on new ipmi_kcs_cmd_raw() |
Date: |
Wed, 10 Nov 2004 10:33:57 -0800 |
Just want to gather opinions on this. ipmi_kcs_cmd_raw_interruptible
would be similar.
int8_t
ipmi_kcs_cmd_raw (u_int16_t sms_io_base, u_int8_t lun, u_int8_t fn,
u_int8_t *buf_cmd_rq, u_int32_t buf_rq_len, u_int8_t *buf_cmd_rs,
u_int32_t *buf_rs_len)
{
if (!(sms_io_base && buf_cmd_rq && buf_rq_len > 0
&& buf_cmd_rs && buf_rs_len && *buf_rs_len > 0))
{
errno = EINVAL;
return (-1);
}
{ /* Request Block */
fiid_obj_t obj_hdr_rq = NULL;
u_int8_t *bytes = NULL;
u_int32_t obj_hdr_rq_len, bytes_len;
obj_hdr_rq_len = fiid_obj_len_bytes (tmpl_hdr_kcs);
ERR (obj_hdr_rq_len > 0);
obj_hdr_rq = alloca (obj_hdr_rq_len);
memset (obj_hdr_rq, 0, obj_hdr_rq_len);
ERR (obj_hdr_rq);
ERR (fill_hdr_ipmi_kcs (lun, fn, obj_hdr_rq) != -1);
bytes_len = obj_hdr_rq_len + buf_rq_len;
bytes = alloca (bytes_len);
memset (bytes, 0, bytes_len);
ERR (bytes);
memcpy(bytes, obj_hdr_rq, obj_hdr_rq_len);
memcpy(bytes + obj_hdr_rq_len, buf_cmd_rq, buf_rq_len);
ERR (ipmi_kcs_write (sms_io_base, bytes, bytes_len) != -1);
}
{ /* Response Block */
fiid_obj_t obj_hdr_rs = NULL;
u_int8_t *bytes = NULL;
u_int32_t obj_hdr_rs_len, bytes_read, bytes_len;
obj_hdr_rs_len = fiid_obj_len_bytes (tmpl_hdr_kcs);
ERR (obj_hdr_rs_len != -1);
obj_hdr_rs = alloca (obj_hdr_rs_len);
memset (obj_hdr_rs, 0, obj_hdr_rs_len);
ERR (obj_hdr_rs);
bytes_len = obj_hdr_rs_len + *buf_rs_len;
bytes = alloca (bytes_len);
memset (bytes, 0, bytes_len);
ERR (bytes);
ERR ((bytes_read = ipmi_kcs_read (sms_io_base, bytes, bytes_len)) !=
-1);
if (bytes_read > obj_hdr_rs_len)
{
u_int32_t rs_len = bytes_read - obj_hdr_rs_len;
if (rs_len <= *buf_rs_len)
*buf_rs_len = rs_len;
/* else leave buf_rs_len the same size */
memcpy(buf_cmd_rs, bytes + obj_hdr_rs_len, *buf_rs_len);
}
else
*buf_rs_len = 0;
}
return (0);
}
--
Albert Chu
address@hidden
Lawrence Livermore National Laboratory
- [Freeipmi-devel] opinion on new ipmi_kcs_cmd_raw(),
Albert Chu <=