Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/common_drivers/fru_tools/fru_tools.h

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