-
Notifications
You must be signed in to change notification settings - Fork 14
/
fru.h
139 lines (122 loc) · 4.84 KB
/
fru.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* fru.h
* Copyright (C) 2012-2015 Analog Devices
* Author : Robin Getz <[email protected]>
*
* This file is maintained as part of:
* https://github.com/analogdevicesinc/fru_tools
* but is released under this license, so you can use it without having
* your software fall under the GPL. If you make improvements to this,
* although you are not required, it would be nice if you sent me a patch.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* - The use of this software may or may not infringe the patent rights
* of one or more patent holders. This license does not release you
* from the requirement that you obtain separate licenses from these
* patent holders to use this software.
*
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
#ifndef __fru_tools__
#define __fru_tools__
#include <stdbool.h>
#ifndef UNUSED
# ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
# else
# define UNUSED(x) UNUSED_ ## x
# endif
#endif
/*
* These structures/data are based from:
* Platform Management FRU Information
* Storage Definition
* Document Revision 1.1, September 27, 1999
* http://download.intel.com/design/servers/ipmi/FRU1011.pdf
*
* ANSI/VITA 57.1
* FPGA Mezzanine Card (FMC) Standard
* Approved July 2008 (Revised February 2010)
* Used with permission
*/
#define CUSTOM_FIELDS 10
/* Defines from section 13 "TYPE/LENGTH BYTE FORMAT" of FRU spec) */
#define FRU_STRING_BINARY 0
#define FRU_STRING_BCD 1
#define FRU_STRING_SIXBIT 2
#define FRU_STRING_ASCII 3
#define TYPE_CODE(x) ((x[0] >> 6) & 0x3)
#define FIELD_LEN(x) (x[0] & 0x3F)
/* Table 8-1, Common header */
struct FRU_COMMON_HEADER {
unsigned char format_ver; /* Common Header Format Version */
unsigned char internal_offset; /* Internal Use Area Starting. */
unsigned char chassis_offset; /* Chassis Info Area Starting Offset */
unsigned char board_offset; /* Board Area Starting Offset */
unsigned char product_offset; /* Product Info Area Starting Offset */
unsigned char multirecord_offset; /* MultiRecord Area Starting Offset */
unsigned char pad; /* PAD */
unsigned char checksum; /* Common Header Checksum */
};
struct BOARD_INFO {
unsigned char language_code;
unsigned int mfg_date;
unsigned char *manufacturer;
unsigned char *product_name;
unsigned char *serial_number;
unsigned char *part_number;
unsigned char *FRU_file_ID;
unsigned char *custom[CUSTOM_FIELDS];
};
#define NUM_MULTI 3
#define NUM_SUPPLIES 12
struct MULTIRECORD_INFO {
unsigned char *supplies[NUM_SUPPLIES];
unsigned char *connector;
unsigned char *i2c_devices;
};
#define MULTIRECORD_I2C 1
#define MULTIRECORD_CONNECTOR 0
#define MULTIRECORD_DC_OUTPUT 1
#define MULTIRECORD_DC_INPUT 2
/* 0xfa is the FMC-specific MultiRecords, see Rule Rule 5.77 in the FMC spec */
#define MULTIRECORD_FMC 0xFA
/* VITA’s Organizationally Unique Identifier - see rule 5.77 in the FMC spec */
#define VITA_OUI 0x0012A2
struct FRU_DATA {
char *Internal_Area;
char *Chassis_Info;
struct BOARD_INFO *Board_Area;
char *Product_Info;
struct MULTIRECORD_INFO *MultiRecord_Area;
};
extern void printf_err (const char *, ...);
extern void printf_warn (const char *, ...);
extern void printf_info (const char *, ...);
extern struct FRU_DATA * parse_FRU (unsigned char *);
extern void free_FRU (struct FRU_DATA * fru);
extern unsigned char * build_FRU_blob (struct FRU_DATA *, size_t *, bool);
extern time_t min2date(unsigned int mins);
extern void * x_calloc (size_t, size_t);
#endif /* __fru_tools__ */