/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "fru_access_impl.h"
/*
* function to return section header for simulated SPD fruid
*
* parameters:
* sec_hdr buffer to receive section header
* sec_hdr_len size of buffer sec_hdr
* return value:
* size of returned data (0 if sec_hdr_len too small)
*/
{
if (sec_hdr_len < sizeof (sp_sec_hdr))
return (0);
return (sizeof (sp_sec_hdr));
}
/*
* function to return segment header for simulated SPD fruid
*
* parameters:
* seg_hdr buffer to receive segment header
* seg_hdr_len size of buffer seg_hdr
* return value:
* size of returned data (0 if seg_hdr_len too small)
*/
{
if (seg_hdr_len < sizeof (sp_seg_hdr))
return (0);
return (sizeof (sp_seg_hdr));
}
/*
* Function to convert SPD data into SPD fruid segment.
* The segment comprises two tagged records: DIMM_Capacity and SPD_R.
*
* DIMM_Capacity is a text string showing the total usable size of the
* DIMM (i.e. not including error correction bits). This record is derived
* from module row density and number of rows.
*
* SPD_R contains the entire SPD data area from the DIMM. It is slightly
* massaged to make it easier to display:
* bytes 0 - 63 are presented as is
* bytes 64 - 71 (JEDEC code) are compressed into 2 bytes, matching the
* format used in ManR
* bytes 72 - 92 are copied as is (to bytes 66 - 86)
* byte 93 year of manufacture is expanded to a 2 byte (big endian)
* field which includes the century (to bytes 87 - 88)
* bytes 94 - 127 are copied as is (to bytes 89 - 122)
*
* parameters:
* spd_data pointer to SPD data
* spd_data_len length of supplied SPD data
* sp_seg_ptr pointer to receive address of converted data
* sp_seg_len pointer for size of converted data
* return value:
* 0 - success
* NZ - error code
*/
int
{
int c;
int capacity;
if (spd_data_len < sizeof (spd_data_t))
return (EINVAL);
if (*sp_seg_ptr == NULL)
return (ENOMEM);
/* set up template for SP seg */
if (year < 80)
year += 2000;
else
year += 1900;
/*
* move first 64 bytes of SPD data into SPD-R record
*/
/*
* re-write full data width as big endian
*/
/*
* construct Sun compressed encoding for JEDEC code
*/
break;
}
/*
* move other fields in place
*/
/*
* calculate the capacity and insert into capacity record
*/
/*
* can't handle this memory type
*/
/*
* OK it's 72-bits wide with equal width banks
*/
(capacity > 16)) ||
(capacity > 4)) {
capacity *= 4;
m_or_g = 'M';
}
c = spd->n_mod_rows;
c &= 7;
c++;
}
capacity *= c;
capacity /= 1024;
m_or_g = 'G';
}
} else {
}
/*
* finally, set the checksum
*/
for (c = 0; c < 4; c++) {
((char *)(&sum))[c];
}
*sp_seg_len = sizeof (sp_seg_body);
return (0);
}
/*
* get_spd_data - reads raw data from container
* parameters:
* fd file descriptor for SPD device
* ctr_offset container offset
* ctr_len container size
* spd_data buffer to receive SPD data (length ctr_len)
* return value:
* 0 - success
* NZ - error code
*/
int
{
if (ctr_len < sizeof (spd_data_t))
return (EINVAL);
sizeof (spd_data_t))
return (EIO);
return (0);
}