summaryrefslogtreecommitdiffstats
path: root/common/recipes-lib/fruid/files/fruid.h
blob: 713658d8d026580bd5fc10049a8ebc7498d8791e (plain)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
 * Copyright 2015-present Facebook. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __FRUID_H__
#define __FRUID_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>
#include <stdint.h>
#include <openbmc/ipmi.h>

#define FRUID_FORMAT_VER           0x01
#define FRUID_OFFSET_MULTIPLIER    8
#define FRUID_AREA_LEN_MULTIPLIER  8

#define FRUID_OFFSET_AREA_INTERNAL        0
#define FRUID_OFFSET_AREA_CHASSIS         1
#define FRUID_OFFSET_AREA_BOARD           2
#define FRUID_OFFSET_AREA_PRODUCT         3
#define FRUID_OFFSET_AREA_MULTIRECORD     4

#define FRUID_CHASSIS_TYPECODE_MIN        1
#define FRUID_CHASSIS_TYPECODE_MAX        32

/* To hold the common header information. */
typedef struct fruid_header_t {
  uint8_t format_ver : 4;
  struct {
    uint8_t internal;
    uint8_t chassis;
    uint8_t board;
    uint8_t product;
    uint8_t multirecord;
  } offset_area;
  uint8_t pad;
  uint8_t chksum;
} fruid_header_t;

/* To hold the Chassis area information. */
typedef struct fruid_area_chassis_t {
  uint8_t format_ver : 4;
  uint8_t area_len;
  uint8_t type;
  char * type_str;
  char * part;
  char * serial;
  char * custom;
  uint8_t chksum;
} fruid_area_chassis_t;

/* To hold the Board area information. */
typedef struct fruid_area_board_t {
  uint8_t format_ver : 4;
  uint8_t area_len;
  uint8_t lang_code;
  uint8_t mfg_time[3];
  char * mfg_time_str;
  char * mfg;
  char * name;
  char * serial;
  char * part;
  char * fruid;
  char * custom;
  uint8_t chksum;
} fruid_area_board_t;

/* To hold the Product area information. */
typedef struct fruid_area_product_t {
  uint8_t format_ver : 4;
  uint8_t area_len;
  uint8_t lang_code;
  char * mfg;
  char * name;
  char * part;
  char * version;
  char * serial;
  char * asset_tag;
  char * fruid;
  char * custom;
  uint8_t chksum;
} fruid_area_product_t;

/* To hold the Multirecord area information. */
typedef struct fruid_area_multirecord_t {
  uint8_t format_ver : 4;
  uint8_t area_len;
  /* TODO: Add more fields to support Multirecord area. */
} fruid_area_multirecord_t;

/* To hold all the fruid information */
typedef struct fruid_info_t {
  struct {
    uint8_t flag;
    char * type_str;
    char * part;
    char * serial;
    char * custom;
  } chassis;
  struct {
    uint8_t flag;
    char * mfg_time_str;
    char * mfg;
    char * name;
    char * serial;
    char * part;
    char * fruid;
    char * custom;
  } board;
  struct {
    uint8_t flag;
    char * mfg;
    char * name;
    char * part;
    char * version;
    char * serial;
    char * asset_tag;
    char * fruid;
    char * custom;
  } product;
} fruid_info_t;

/* To hold the different area offsets. */
typedef struct fruid_eeprom_t {
  uint8_t * header;
  uint8_t * chassis;
  uint8_t * board;
  uint8_t * product;
  uint8_t * multirecord;
} fruid_eeprom_t;

/* List of all the Chassis types. */
const char * fruid_chassis_type [] = {
  "Other",                    /* 0x01 */
  "Unknown",                  /* 0x02 */
  "Desktop",                  /* 0x03 */
  "Low Profile Desktop",      /* 0x04 */
  "Pizza Box",                /* 0x05 */
  "Mini Tower",               /* 0x06 */
  "Tower",                    /* 0x07 */
  "Portable",                 /* 0x08 */
  "Laptop",                   /* 0x09 */
  "Notebook",                 /* 0x0A */
  "Hand Held",                /* 0x0B */
  "Docking Station",          /* 0x0C */
  "All in One",               /* 0x0D */
  "Sub Notebook",             /* 0x0E */
  "Space-saving",             /* 0x0F */
  "Lunch Box",                /* 0x10 */
  "Main Server Chassis",      /* 0x11 */
  "Expansion Chassis",        /* 0x12 */
  "SubChassis",               /* 0x13 */
  "Bus Expansion Chassis",    /* 0x14 */
  "Peripheral Chassis",       /* 0x15 */
  "RAID Chassis",             /* 0x16 */
  "Rack Mount Chassis",       /* 0x17 */
  "Sealed-case PC",           /* 0x18 */
  "Multi-system Chassis",     /* 0x19 */
  "Compact PCI",              /* 0x1A */
  "Advanced TCA",             /* 0x1B */
  "Blade",                    /* 0x1C */
  "Blade Enclosure",          /* 0x1D */
  "Tablet",                   /* 0x1E */
  "Convertible",              /* 0x1F */
  "Detachable"                /* 0x20 */
};

int fruid_parse(const char * bin, fruid_info_t * fruid);
void free_fruid_info(fruid_info_t * fruid);

#ifdef __cplusplus
}
#endif

#endif /* __FRUID_H__ */
OpenPOWER on IntegriCloud