2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A
2N/A#ifndef _FRU_TAG_H
2N/A#define _FRU_TAG_H
2N/A
2N/A#include <sys/types.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#if defined(_LITTLE_ENDIAN)
2N/A
2N/Atypedef union {
2N/A uint64_t raw_data;
2N/A unsigned char byte[8];
2N/A struct {
2N/A unsigned pl_len : 3;
2N/A unsigned dense : 4;
2N/A unsigned type : 1;
2N/A } a;
2N/A struct {
2N/A unsigned pl_len : 3;
2N/A unsigned dense : 11;
2N/A unsigned type : 2;
2N/A } b;
2N/A struct {
2N/A unsigned pl_len : 5;
2N/A unsigned dense : 8;
2N/A unsigned type : 3;
2N/A } c;
2N/A struct {
2N/A unsigned pl_len : 3;
2N/A unsigned dense : 17;
2N/A unsigned type : 4;
2N/A } d;
2N/A struct {
2N/A unsigned pl_len : 7;
2N/A unsigned dense : 12;
2N/A unsigned type : 5;
2N/A } e;
2N/A struct {
2N/A unsigned pl_len : 12;
2N/A unsigned dense : 14;
2N/A unsigned type : 6;
2N/A } f;
2N/A struct {
2N/A unsigned pl_len : 32;
2N/A unsigned dense : 9;
2N/A unsigned type : 7;
2N/A } g;
2N/A} fru_tag_t;
2N/A
2N/A#else
2N/A
2N/Atypedef union {
2N/A uint64_t raw_data;
2N/A char byte[8];
2N/A struct {
2N/A unsigned type : 1;
2N/A unsigned dense : 4;
2N/A unsigned pl_len : 3;
2N/A } a;
2N/A struct {
2N/A unsigned type : 2;
2N/A unsigned dense : 11;
2N/A unsigned pl_len : 3;
2N/A } b;
2N/A struct {
2N/A unsigned type : 3;
2N/A unsigned dense : 8;
2N/A unsigned pl_len : 5;
2N/A } c;
2N/A struct {
2N/A unsigned type : 4;
2N/A unsigned dense : 17;
2N/A unsigned pl_len : 3;
2N/A } d;
2N/A struct {
2N/A unsigned type : 5;
2N/A unsigned dense : 12;
2N/A unsigned pl_len : 7;
2N/A } e;
2N/A struct {
2N/A unsigned type : 6;
2N/A unsigned dense : 14;
2N/A unsigned pl_len : 12;
2N/A } f;
2N/A struct {
2N/A unsigned type : 7;
2N/A unsigned dense : 9;
2N/A unsigned pl_len : 32;
2N/A } g;
2N/A} fru_tag_t;
2N/A
2N/A#endif /* LITTLE_ENDIAN */
2N/A
2N/A#define FRU_ID_MASK 0xFF
2N/A#define FRU_A_ID 0x00
2N/A#define FRU_B_ID 0x02
2N/A#define FRU_C_ID 0x06
2N/A#define FRU_D_ID 0x0E
2N/A#define FRU_E_ID 0x1E
2N/A#define FRU_F_ID 0x3E
2N/A#define FRU_G_ID 0x7E
2N/A
2N/Atypedef enum { FRU_A = 0x00, FRU_B = 0x80, FRU_C = 0xc0,
2N/A FRU_D = 0xe0, FRU_E = 0xf0, FRU_F = 0xf8,
2N/A FRU_G = 0xfc, FRU_X = 0xfe } fru_tagtype_t;
2N/Achar *get_tagtype_str(fru_tagtype_t e);
2N/Asize_t get_tag_size(fru_tagtype_t tag);
2N/A
2N/A/* Returns -1 on error */
2N/Aint mk_tag(fru_tagtype_t type, uint32_t dense, size_t pl_len,
2N/A fru_tag_t *tag);
2N/A
2N/Afru_tagtype_t get_tag_type(fru_tag_t *tag);
2N/Auint32_t get_tag_dense(fru_tag_t *tag);
2N/Asize_t get_payload_length(fru_tag_t *tag);
2N/A
2N/A/* Returns 1 if equal, 0 if not */
2N/Aint tags_equal(fru_tag_t t1, fru_tag_t t2);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _FRU_TAG_H */