#ifndef _FRU_ACCESS_IMPL_H
#define _FRU_ACCESS_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dial.h>
#include <strings.h>
#include <libdevinfo.h>
#include <sys/systeminfo.h>
#include <picl.h>
#include <picltree.h>
#include <picldefs.h>
#include <syslog.h>
#include <errno.h>
#include <libfru.h>
#include <limits.h>
#include <fru_tag.h>
#include "fru_access.h"
#include "spd_data.h"
typedef enum {CONTAINER_TYPE, SECTION_TYPE, SEGMENT_TYPE, PACKET_TYPE} object_t;
#define TABLE_SIZE 64
#define FRU_CONTAINER_CONF "fru_container.conf"
#define CONTAINER_DIR "/usr/platform/sun4u/lib"
#define SECTION_HDR_TAG 0x08
#define SECTION_HDR_VER 0x0001
#define SECTION_HDR_LENGTH 0x06
#define SECTION_HDR_CRC8 0x00
#define SECTION_HDR_VER_BIT0 0x00
#define SECTION_HDR_VER_BIT1 0x01
#define READ_ONLY_SECTION 1
#define GET_SEGMENT_DESCRIPTOR \
(seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16)
#define GET_SECTION_HDR_VERSION \
(sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
#define SEG_TRAILER_TAG 0x0C
#define SEGMENT_FIXED 1
typedef union {
uint32_t all_bits;
struct {
unsigned read_only : 1;
unsigned unused : 8;
unsigned : 8;
unsigned : 8;
unsigned : 7;
} field;
} sectdescbit_t;
typedef enum {
ENC_STANDARD = 0,
ENC_SPD
} sectencoding_t;
typedef struct {
sectdescbit_t description;
uint32_t address;
uint32_t size;
sectencoding_t encoding;
} sectioninfo_t;
typedef uint16_t headerrev_t;
#define MAX_NUMOF_SECTION 2
typedef struct {
headerrev_t header_ver;
int num_sections;
sectioninfo_t section_info[MAX_NUMOF_SECTION];
} container_info_t;
typedef struct {
uint8_t headertag;
uint8_t headerversion[2];
uint8_t headerlength;
uint8_t headercrc8;
uint8_t segmentcount;
} section_layout_t;
typedef struct {
uint16_t name;
uint16_t descriptor[2];
uint16_t offset;
uint16_t length;
} segment_layout_t;
typedef struct {
int segnum;
int offset;
int length;
int fixed;
} seg_info_t;
typedef uint64_t handle_t;
struct hash_obj;
typedef struct {
handle_t segment_hdl;
fru_tag_t tag;
int tag_size;
uint8_t *payload;
uint32_t paylen;
uint32_t payload_offset;
struct hash_obj *next;
} packet_obj_t;
typedef struct {
handle_t section_hdl;
int num_of_packets;
int trailer_offset;
segment_t segment;
struct hash_obj *pkt_obj_list;
struct hash_obj *next;
} segment_obj_t;
typedef struct {
handle_t cont_hdl;
section_t section;
sectencoding_t encoding;
int num_of_segment;
struct hash_obj *seg_obj_list;
struct hash_obj *next;
} section_obj_t;
typedef struct {
char device_pathname[PATH_MAX];
int num_of_section;
struct hash_obj *sec_obj_list;
} container_obj_t;
typedef struct hash_obj {
int object_type;
handle_t obj_hdl;
union {
container_obj_t *cont_obj;
section_obj_t *sec_obj;
segment_obj_t *seg_obj;
packet_obj_t *pkt_obj;
} u;
struct hash_obj *next;
struct hash_obj *prev;
} hash_obj_t;
unsigned char compute_crc8(unsigned char *bytes, int length);
long compute_crc32(unsigned char *bytes, int length);
long compute_checksum32(unsigned char *bytes, int length);
#ifdef __cplusplus
}
#endif
#endif