Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003-2014 FreeIPMI Core Team |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 3 | * |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 16 | * |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 17 | */ |
| 18 | /*****************************************************************************\ |
| 19 | * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. |
| 20 | * Copyright (C) 2007 The Regents of the University of California. |
| 21 | * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). |
| 22 | * Written by Albert Chu <chu11@llnl.gov> |
| 23 | * UCRL-CODE-232183 |
| 24 | * |
| 25 | * This file is part of Ipmi-fru, a tool used for retrieving |
| 26 | * motherboard field replaceable unit (FRU) information. For details, |
| 27 | * see http://www.llnl.gov/linux/. |
| 28 | * |
| 29 | * Ipmi-fru is free software; you can redistribute it and/or modify |
| 30 | * it under the terms of the GNU General Public License as published by the |
| 31 | * Free Software Foundation; either version 3 of the License, or (at your |
| 32 | * option) any later version. |
| 33 | * |
| 34 | * Ipmi-fru is distributed in the hope that it will be useful, but |
| 35 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 36 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 37 | * for more details. |
| 38 | * |
| 39 | * You should have received a copy of the GNU General Public License along |
| 40 | * with Ipmi-fru. If not, see <http://www.gnu.org/licenses/>. |
| 41 | \*****************************************************************************/ |
Ratan Gupta | 19c617b | 2017-02-10 15:39:40 +0530 | [diff] [blame] | 42 | #include "frup.hpp" |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 43 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 44 | #include <ctype.h> |
| 45 | #include <stdio.h> |
| 46 | #include <stdlib.h> |
| 47 | #include <string.h> |
| 48 | #include <systemd/sd-bus.h> |
| 49 | #include <time.h> |
| 50 | #include <unistd.h> |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 51 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 52 | #define TEXTSTR(a) #a |
| 53 | #define ASSERT(x) \ |
| 54 | do \ |
| 55 | { \ |
| 56 | if (0 == (x)) \ |
| 57 | { \ |
| 58 | fprintf(stderr, \ |
| 59 | "Assertion failed: %s, " \ |
| 60 | "%d at \'%s\'\n", \ |
| 61 | __FILE__, __LINE__, TEXTSTR(a)); \ |
| 62 | return -1; \ |
| 63 | } \ |
| 64 | } while (0) |
| 65 | |
| 66 | #define IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX 512 |
| 67 | #define IPMI_FRU_SENTINEL_VALUE 0xC1 |
| 68 | #define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK 0xC0 |
| 69 | #define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT 0x06 |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 70 | #define IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK 0x3F |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 71 | #define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE 0x03 |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 72 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 73 | /* OpenBMC defines for Parser */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 74 | #define IPMI_FRU_AREA_INTERNAL_USE 0x00 |
| 75 | #define IPMI_FRU_AREA_CHASSIS_INFO 0x01 |
| 76 | #define IPMI_FRU_AREA_BOARD_INFO 0x02 |
| 77 | #define IPMI_FRU_AREA_PRODUCT_INFO 0x03 |
| 78 | #define IPMI_FRU_AREA_MULTI_RECORD 0x04 |
| 79 | #define IPMI_FRU_AREA_TYPE_MAX 0x05 |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 80 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 81 | #define OPENBMC_VPD_KEY_LEN 64 |
| 82 | #define OPENBMC_VPD_VAL_LEN 512 |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 83 | |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 84 | constexpr long fruEpochMinutes = 820454400; |
| 85 | |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 86 | struct ipmi_fru_field |
| 87 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 88 | uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; |
| 89 | /* store length of data stored in buffer */ |
| 90 | unsigned int type_length_field_length; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | typedef struct ipmi_fru_field ipmi_fru_field_t; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 94 | /* |
| 95 | * FRU Parser |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 96 | */ |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 97 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 98 | typedef struct ipmi_fru_area_info |
| 99 | { |
| 100 | uint8_t off; |
| 101 | uint8_t len; |
| 102 | } ipmi_fru_area_info_t; |
| 103 | |
| 104 | typedef struct ipmi_fru_common_hdr |
| 105 | { |
| 106 | uint8_t fmtver; |
| 107 | uint8_t internal; |
| 108 | uint8_t chassis; |
| 109 | uint8_t board; |
| 110 | uint8_t product; |
| 111 | uint8_t multirec; |
| 112 | } __attribute__((packed)) ipmi_fru_common_hdr_t; |
| 113 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 114 | const char* vpd_key_names[] = { |
| 115 | "Key Names Table Start", |
| 116 | "Type", /*OPENBMC_VPD_KEY_CHASSIS_TYPE*/ |
| 117 | "Part Number", /*OPENBMC_VPD_KEY_CHASSIS_PART_NUM,*/ |
| 118 | "Serial Number", /*OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM,*/ |
| 119 | "Custom Field 1", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM1,*/ |
| 120 | "Custom Field 2", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM2,*/ |
| 121 | "Custom Field 3", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM3,*/ |
| 122 | "Custom Field 4", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM4,*/ |
| 123 | "Custom Field 5", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM5,*/ |
| 124 | "Custom Field 6", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM6,*/ |
| 125 | "Custom Field 7", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM7,*/ |
| 126 | "Custom Field 8", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 127 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 128 | "Mfg Date", |
| 129 | /* OPENBMC_VPD_KEY_BOARD_MFG_DATE, */ /* not a type/len */ |
| 130 | "Manufacturer", /* OPENBMC_VPD_KEY_BOARD_MFR, */ |
| 131 | "Name", /* OPENBMC_VPD_KEY_BOARD_NAME, */ |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 132 | "Serial Number", /* OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, */ |
| 133 | "Part Number", /* OPENBMC_VPD_KEY_BOARD_PART_NUM, */ |
| 134 | "FRU File ID", /* OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, */ |
| 135 | "Custom Field 1", /*OPENBMC_VPD_KEY_BOARD_CUSTOM1,*/ |
| 136 | "Custom Field 2", /*OPENBMC_VPD_KEY_BOARD_CUSTOM2,*/ |
| 137 | "Custom Field 3", /*OPENBMC_VPD_KEY_BOARD_CUSTOM3,*/ |
| 138 | "Custom Field 4", /*OPENBMC_VPD_KEY_BOARD_CUSTOM4,*/ |
| 139 | "Custom Field 5", /*OPENBMC_VPD_KEY_BOARD_CUSTOM5,*/ |
| 140 | "Custom Field 6", /*OPENBMC_VPD_KEY_BOARD_CUSTOM6,*/ |
| 141 | "Custom Field 7", /*OPENBMC_VPD_KEY_BOARD_CUSTOM7,*/ |
| 142 | "Custom Field 8", /*OPENBMC_VPD_KEY_BOARD_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 143 | |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 144 | "Manufacturer", /* OPENBMC_VPD_KEY_PRODUCT_MFR, */ |
| 145 | "Name", /* OPENBMC_VPD_KEY_PRODUCT_NAME, */ |
| 146 | "Model Number", /* OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, */ |
| 147 | "Version", /* OPENBMC_VPD_KEY_PRODUCT_VER, */ |
| 148 | "Serial Number", /* OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, */ |
| 149 | "Asset Tag", /* OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, */ |
| 150 | "FRU File ID", /* OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, */ |
| 151 | "Custom Field 1", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM1,*/ |
| 152 | "Custom Field 2", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM2,*/ |
| 153 | "Custom Field 3", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM3,*/ |
| 154 | "Custom Field 4", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM4,*/ |
| 155 | "Custom Field 5", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM5,*/ |
| 156 | "Custom Field 6", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM6,*/ |
| 157 | "Custom Field 7", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM7,*/ |
| 158 | "Custom Field 8", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 159 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 160 | "Key Names Table End" /*OPENBMC_VPD_KEY_MAX,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 161 | }; |
| 162 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 163 | /* |
| 164 | * -------------------------------------------------------------------- |
| 165 | * |
| 166 | * -------------------------------------------------------------------- |
| 167 | */ |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 168 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 169 | static size_t _to_time_str(uint32_t mfg_date_time, char* timestr, uint32_t len) |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 170 | { |
| 171 | struct tm tm; |
| 172 | time_t t; |
| 173 | size_t s; |
| 174 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 175 | ASSERT(timestr); |
| 176 | ASSERT(len); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 177 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 178 | memset(&tm, '\0', sizeof(struct tm)); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 179 | |
| 180 | t = mfg_date_time; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 181 | gmtime_r(&t, &tm); |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 182 | s = strftime(timestr, len, "%F - %H:%M:%S UTC", &tm); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 183 | |
| 184 | return s; |
| 185 | } |
| 186 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 187 | /* private method to parse type/length */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 188 | static int _parse_type_length(const void* areabuf, unsigned int areabuflen, |
| 189 | unsigned int current_area_offset, |
| 190 | uint8_t* number_of_data_bytes, |
| 191 | ipmi_fru_field_t* field) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 192 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 193 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 194 | uint8_t type_length; |
| 195 | uint8_t type_code; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 196 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 197 | ASSERT(areabuf); |
| 198 | ASSERT(areabuflen); |
| 199 | ASSERT(number_of_data_bytes); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 200 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 201 | type_length = areabufptr[current_area_offset]; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 202 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 203 | /* ipmi workaround |
| 204 | * |
| 205 | * dell p weredge r610 |
| 206 | * |
| 207 | * my reading of the fru spec is that all non-custom fields are |
| 208 | * required to be listed by the vendor. however, on this |
| 209 | * motherboard, some areas list this, indicating that there is |
| 210 | * no more data to be parsed. so now, for "required" fields, i |
| 211 | * check to see if the type-length field is a sentinel before |
| 212 | * calling this function. |
| 213 | */ |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 214 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 215 | ASSERT(type_length != IPMI_FRU_SENTINEL_VALUE); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 216 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 217 | type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> |
| 218 | IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 219 | (*number_of_data_bytes) = type_length & |
| 220 | IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 221 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 222 | /* special case: this shouldn't be a length of 0x01 (see type/length |
| 223 | * byte format in fru information storage definition). |
| 224 | */ |
| 225 | if (type_code == IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE && |
| 226 | (*number_of_data_bytes) == 0x01) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 227 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 228 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 229 | } |
| 230 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 231 | if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 232 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 233 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 234 | } |
| 235 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 236 | if (field) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 237 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 238 | memset(field->type_length_field, '\0', |
| 239 | IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); |
| 240 | memcpy(field->type_length_field, &areabufptr[current_area_offset], |
| 241 | 1 + (*number_of_data_bytes)); |
| 242 | field->type_length_field_length = 1 + (*number_of_data_bytes); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 243 | } |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 244 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 245 | return (0); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 246 | } |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 247 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 248 | int ipmi_fru_chassis_info_area(const void* areabuf, unsigned int areabuflen, |
| 249 | uint8_t* chassis_type, |
| 250 | ipmi_fru_field_t* chassis_part_number, |
| 251 | ipmi_fru_field_t* chassis_serial_number, |
| 252 | ipmi_fru_field_t* chassis_custom_fields, |
| 253 | unsigned int chassis_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 254 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 255 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 256 | unsigned int area_offset = 0; |
| 257 | unsigned int custom_fields_index = 0; |
| 258 | uint8_t number_of_data_bytes; |
| 259 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 260 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 261 | if (!areabuf || !areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 262 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 263 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 264 | } |
| 265 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 266 | if (chassis_part_number) |
| 267 | memset(chassis_part_number, '\0', sizeof(ipmi_fru_field_t)); |
| 268 | if (chassis_serial_number) |
| 269 | memset(chassis_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 270 | if (chassis_custom_fields && chassis_custom_fields_len) |
| 271 | memset(chassis_custom_fields, '\0', |
| 272 | sizeof(ipmi_fru_field_t) * chassis_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 273 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 274 | if (chassis_type) |
| 275 | (*chassis_type) = areabufptr[area_offset]; |
| 276 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 277 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 278 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 279 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 280 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 281 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 282 | &number_of_data_bytes, chassis_part_number) < 0) |
| 283 | goto cleanup; |
| 284 | area_offset += 1; /* type/length byte */ |
| 285 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 286 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 287 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 288 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 289 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 290 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 291 | &number_of_data_bytes, chassis_serial_number) < 0) |
| 292 | goto cleanup; |
| 293 | area_offset += 1; /* type/length byte */ |
| 294 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 295 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 296 | while (area_offset < areabuflen && |
| 297 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 298 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 299 | ipmi_fru_field_t* field_ptr = NULL; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 300 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 301 | if (chassis_custom_fields && chassis_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 302 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 303 | if (custom_fields_index < chassis_custom_fields_len) |
| 304 | field_ptr = &chassis_custom_fields[custom_fields_index]; |
| 305 | else |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 306 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 307 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 311 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 312 | &number_of_data_bytes, field_ptr) < 0) |
| 313 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 314 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 315 | area_offset += 1; /* type/length byte */ |
| 316 | area_offset += number_of_data_bytes; |
| 317 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 318 | } |
| 319 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 320 | out: |
| 321 | rv = 0; |
| 322 | cleanup: |
| 323 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 324 | } |
| 325 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 326 | int ipmi_fru_board_info_area( |
| 327 | const void* areabuf, unsigned int areabuflen, uint8_t* language_code, |
| 328 | uint32_t* mfg_date_time, ipmi_fru_field_t* board_manufacturer, |
| 329 | ipmi_fru_field_t* board_product_name, ipmi_fru_field_t* board_serial_number, |
| 330 | ipmi_fru_field_t* board_part_number, ipmi_fru_field_t* board_fru_file_id, |
| 331 | ipmi_fru_field_t* board_custom_fields, unsigned int board_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 332 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 333 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 334 | unsigned int area_offset = 0; |
| 335 | unsigned int custom_fields_index = 0; |
| 336 | uint8_t number_of_data_bytes; |
| 337 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 338 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 339 | if (!areabuf || !areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 340 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 341 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 342 | } |
| 343 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 344 | if (board_manufacturer) |
| 345 | memset(board_manufacturer, '\0', sizeof(ipmi_fru_field_t)); |
| 346 | if (board_product_name) |
| 347 | memset(board_product_name, '\0', sizeof(ipmi_fru_field_t)); |
| 348 | if (board_serial_number) |
| 349 | memset(board_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 350 | if (board_part_number) |
| 351 | memset(board_part_number, '\0', sizeof(ipmi_fru_field_t)); |
| 352 | if (board_fru_file_id) |
| 353 | memset(board_fru_file_id, '\0', sizeof(ipmi_fru_field_t)); |
| 354 | if (board_custom_fields && board_custom_fields_len) |
| 355 | memset(board_custom_fields, '\0', |
| 356 | sizeof(ipmi_fru_field_t) * board_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 357 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 358 | if (language_code) |
| 359 | (*language_code) = areabufptr[area_offset]; |
| 360 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 361 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 362 | if (mfg_date_time) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 363 | { |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 364 | unsigned int minutes = areabufptr[area_offset]; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 365 | area_offset++; |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 366 | minutes |= (areabufptr[area_offset] << 8); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 367 | area_offset++; |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 368 | minutes |= (areabufptr[area_offset] << 16); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 369 | area_offset++; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 370 | |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 371 | /* In fru, epoch is 0:00 hrs 1/1/96 == 820454400 |
| 372 | * Remove it directly and remove the time conversion. |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 373 | */ |
Willy Tu | 9084f52 | 2022-11-03 08:17:54 +0000 | [diff] [blame^] | 374 | (*mfg_date_time) = fruEpochMinutes + static_cast<long>(minutes) * 60; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 375 | } |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 376 | else |
| 377 | area_offset += 3; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 378 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 379 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 380 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 381 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 382 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 383 | &number_of_data_bytes, board_manufacturer) < 0) |
| 384 | goto cleanup; |
| 385 | area_offset += 1; /* type/length byte */ |
| 386 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 387 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 388 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 389 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 390 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 391 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 392 | &number_of_data_bytes, board_product_name) < 0) |
| 393 | goto cleanup; |
| 394 | area_offset += 1; /* type/length byte */ |
| 395 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 396 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 397 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 398 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 399 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 400 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 401 | &number_of_data_bytes, board_serial_number) < 0) |
| 402 | goto cleanup; |
| 403 | area_offset += 1; /* type/length byte */ |
| 404 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 405 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 406 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 407 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 408 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 409 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 410 | &number_of_data_bytes, board_part_number) < 0) |
| 411 | goto cleanup; |
| 412 | area_offset += 1; /* type/length byte */ |
| 413 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 414 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 415 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 416 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 417 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 418 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 419 | &number_of_data_bytes, board_fru_file_id) < 0) |
| 420 | goto cleanup; |
| 421 | area_offset += 1; /* type/length byte */ |
| 422 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 423 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 424 | while (area_offset < areabuflen && |
| 425 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 426 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 427 | ipmi_fru_field_t* field_ptr = NULL; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 428 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 429 | if (board_custom_fields && board_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 430 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 431 | if (custom_fields_index < board_custom_fields_len) |
| 432 | field_ptr = &board_custom_fields[custom_fields_index]; |
| 433 | else |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 434 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 435 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 439 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 440 | &number_of_data_bytes, field_ptr) < 0) |
| 441 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 442 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 443 | area_offset += 1; /* type/length byte */ |
| 444 | area_offset += number_of_data_bytes; |
| 445 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 446 | } |
| 447 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 448 | out: |
| 449 | rv = 0; |
| 450 | cleanup: |
| 451 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 452 | } |
| 453 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 454 | int ipmi_fru_product_info_area( |
| 455 | const void* areabuf, unsigned int areabuflen, uint8_t* language_code, |
| 456 | ipmi_fru_field_t* product_manufacturer_name, ipmi_fru_field_t* product_name, |
| 457 | ipmi_fru_field_t* product_part_model_number, |
| 458 | ipmi_fru_field_t* product_version, ipmi_fru_field_t* product_serial_number, |
| 459 | ipmi_fru_field_t* product_asset_tag, ipmi_fru_field_t* product_fru_file_id, |
| 460 | ipmi_fru_field_t* product_custom_fields, |
| 461 | unsigned int product_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 462 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 463 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 464 | unsigned int area_offset = 0; |
| 465 | unsigned int custom_fields_index = 0; |
| 466 | uint8_t number_of_data_bytes; |
| 467 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 468 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 469 | if (!areabuf || !areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 470 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 471 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 472 | } |
| 473 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 474 | if (product_manufacturer_name) |
| 475 | memset(product_manufacturer_name, '\0', sizeof(ipmi_fru_field_t)); |
| 476 | if (product_name) |
| 477 | memset(product_name, '\0', sizeof(ipmi_fru_field_t)); |
| 478 | if (product_part_model_number) |
| 479 | memset(product_part_model_number, '\0', sizeof(ipmi_fru_field_t)); |
| 480 | if (product_version) |
| 481 | memset(product_version, '\0', sizeof(ipmi_fru_field_t)); |
| 482 | if (product_serial_number) |
| 483 | memset(product_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 484 | if (product_asset_tag) |
| 485 | memset(product_asset_tag, '\0', sizeof(ipmi_fru_field_t)); |
| 486 | if (product_fru_file_id) |
| 487 | memset(product_fru_file_id, '\0', sizeof(ipmi_fru_field_t)); |
| 488 | if (product_custom_fields && product_custom_fields_len) |
| 489 | memset(product_custom_fields, '\0', |
| 490 | sizeof(ipmi_fru_field_t) * product_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 491 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 492 | if (language_code) |
| 493 | (*language_code) = areabufptr[area_offset]; |
| 494 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 495 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 496 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 497 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 498 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 499 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 500 | &number_of_data_bytes, |
| 501 | product_manufacturer_name) < 0) |
| 502 | goto cleanup; |
| 503 | area_offset += 1; /* type/length byte */ |
| 504 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 505 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 506 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 507 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 508 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 509 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 510 | &number_of_data_bytes, product_name) < 0) |
| 511 | goto cleanup; |
| 512 | area_offset += 1; /* type/length byte */ |
| 513 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 514 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 515 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 516 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 517 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 518 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 519 | &number_of_data_bytes, |
| 520 | product_part_model_number) < 0) |
| 521 | goto cleanup; |
| 522 | area_offset += 1; /* type/length byte */ |
| 523 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 524 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 525 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 526 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 527 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 528 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 529 | &number_of_data_bytes, product_version) < 0) |
| 530 | goto cleanup; |
| 531 | area_offset += 1; /* type/length byte */ |
| 532 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 533 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 534 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 535 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 536 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 537 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 538 | &number_of_data_bytes, product_serial_number) < 0) |
| 539 | goto cleanup; |
| 540 | area_offset += 1; /* type/length byte */ |
| 541 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 542 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 543 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 544 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 545 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 546 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 547 | &number_of_data_bytes, product_asset_tag) < 0) |
| 548 | goto cleanup; |
| 549 | area_offset += 1; /* type/length byte */ |
| 550 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 551 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 552 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 553 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 554 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 555 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 556 | &number_of_data_bytes, product_fru_file_id) < 0) |
| 557 | goto cleanup; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 558 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 559 | area_offset += 1; /* type/length byte */ |
| 560 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 561 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 562 | while (area_offset < areabuflen && |
| 563 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 564 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 565 | ipmi_fru_field_t* field_ptr = NULL; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 566 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 567 | if (product_custom_fields && product_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 568 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 569 | if (custom_fields_index < product_custom_fields_len) |
| 570 | field_ptr = &product_custom_fields[custom_fields_index]; |
| 571 | else |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 572 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 573 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 574 | } |
| 575 | } |
| 576 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 577 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 578 | &number_of_data_bytes, field_ptr) < 0) |
| 579 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 580 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 581 | area_offset += 1; /* type/length byte */ |
| 582 | area_offset += number_of_data_bytes; |
| 583 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 584 | } |
| 585 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 586 | out: |
| 587 | rv = 0; |
| 588 | cleanup: |
| 589 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 590 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 591 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 592 | void _append_to_dict(uint8_t vpd_key_id, uint8_t* vpd_key_val, |
| 593 | IPMIFruInfo& info) |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 594 | { |
| 595 | int type_length = vpd_key_val[0]; |
Deepak Kodihalli | 8a2a675 | 2017-02-11 03:04:38 -0600 | [diff] [blame] | 596 | int type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> |
| 597 | IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 598 | int vpd_val_len = type_length & |
| 599 | IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 600 | |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 601 | /* Needed to convert each uint8_t byte to a ascii */ |
| 602 | char bin_byte[3] = {0}; |
| 603 | |
| 604 | /* |
| 605 | * Max number of characters needed to represent 1 unsigned byte in string |
Gunnar Mills | c19b813 | 2018-06-14 08:56:17 -0500 | [diff] [blame] | 606 | * is number of bytes multiplied by 2. Extra 3 for 0x and a ending '\0'; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 607 | */ |
| 608 | char bin_in_ascii_len = vpd_val_len * 2 + 3; |
| 609 | |
| 610 | /* Binary converted to ascii in array */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 611 | char* bin_in_ascii = (char*)malloc(bin_in_ascii_len); |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 612 | |
| 613 | /* For reading byte from the area */ |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 614 | int val = 0; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 615 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 616 | char* bin_copy = &((char*)bin_in_ascii)[2]; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 617 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 618 | switch (type_code) |
| 619 | { |
| 620 | case 0: |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 621 | memset(bin_in_ascii, 0x0, bin_in_ascii_len); |
| 622 | |
| 623 | /* Offset 1 is where actual data starts */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 624 | for (val = 1; val <= vpd_val_len; val++) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 625 | { |
| 626 | /* 2 bytes for data and 1 for terminating '\0' */ |
| 627 | snprintf(bin_byte, 3, "%02x", vpd_key_val[val]); |
| 628 | |
| 629 | /* Its a running string so strip off the '\0' */ |
| 630 | strncat(bin_copy, bin_byte, 2); |
| 631 | } |
| 632 | |
| 633 | /* We need the data represented as 0x...... */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 634 | if (vpd_val_len > 0) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 635 | { |
Brad Bishop | ec73c95 | 2018-11-21 16:04:13 -0500 | [diff] [blame] | 636 | memcpy(bin_in_ascii, "0x", 2); |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 637 | } |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 638 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 639 | printf("_append_to_dict: VPD Key = [%s] : Type Code = [BINARY] :" |
| 640 | " Len = [%d] : Val = [%s]\n", |
| 641 | vpd_key_names[vpd_key_id], vpd_val_len, bin_in_ascii); |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 642 | #endif |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 643 | info[vpd_key_id] = std::make_pair(vpd_key_names[vpd_key_id], |
| 644 | bin_in_ascii); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 645 | break; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 646 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 647 | case 3: |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 648 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 649 | printf("_append_to_dict: VPD Key = [%s] : Type Code=[ASCII+Latin]" |
| 650 | " : Len = [%d] : Val = [%s]\n", |
| 651 | vpd_key_names[vpd_key_id], vpd_val_len, &vpd_key_val[1]); |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 652 | #endif |
Deepak Kodihalli | 8a2a675 | 2017-02-11 03:04:38 -0600 | [diff] [blame] | 653 | info[vpd_key_id] = std::make_pair( |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 654 | vpd_key_names[vpd_key_id], |
| 655 | std::string(vpd_key_val + 1, vpd_key_val + 1 + type_length)); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 656 | break; |
| 657 | } |
| 658 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 659 | if (bin_in_ascii) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 660 | { |
| 661 | free(bin_in_ascii); |
| 662 | bin_in_ascii = NULL; |
| 663 | } |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 664 | } |
| 665 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 666 | int parse_fru_area(const uint8_t area, const void* msgbuf, const size_t len, |
| 667 | IPMIFruInfo& info) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 668 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 669 | int rv = -1; |
| 670 | int i = 0; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 671 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 672 | /* Chassis */ |
| 673 | uint8_t chassis_type; |
| 674 | /* Board */ |
| 675 | uint32_t mfg_date_time; |
| 676 | /* Product */ |
| 677 | // unsigned int product_custom_fields_len; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 678 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 679 | // ipmi_fru_area_info_t fru_area_info [ IPMI_FRU_AREA_TYPE_MAX ]; |
| 680 | ipmi_fru_field_t vpd_info[OPENBMC_VPD_KEY_MAX]; |
| 681 | char timestr[OPENBMC_VPD_VAL_LEN]; |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 682 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 683 | // uint8_t* ipmi_fru_field_str=NULL; |
| 684 | // ipmi_fru_common_hdr_t* chdr = NULL; |
| 685 | // uint8_t* hdr = NULL; |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 686 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 687 | ASSERT(msgbuf); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 688 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 689 | for (i = 0; i < OPENBMC_VPD_KEY_MAX; i++) |
| 690 | { |
| 691 | memset(vpd_info[i].type_length_field, '\0', |
| 692 | IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); |
| 693 | vpd_info[i].type_length_field_length = 0; |
| 694 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 695 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 696 | switch (area) |
| 697 | { |
| 698 | case IPMI_FRU_AREA_CHASSIS_INFO: |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 699 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 700 | printf("Chassis : Buf len = [%d]\n", len); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 701 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 702 | ipmi_fru_chassis_info_area( |
| 703 | (uint8_t*)msgbuf + 2, len, &chassis_type, |
| 704 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_PART_NUM], |
| 705 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM], |
| 706 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_CUSTOM1], |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 707 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 708 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 709 | /* Populate VPD Table */ |
| 710 | for (i = 1; i <= OPENBMC_VPD_KEY_CHASSIS_MAX; i++) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 711 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 712 | if (i == OPENBMC_VPD_KEY_CHASSIS_TYPE) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 713 | { |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 714 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 715 | printf("Chassis : Appending [%s] = [%d]\n", |
| 716 | vpd_key_names[i], chassis_type); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 717 | #endif |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 718 | info[i] = std::make_pair(vpd_key_names[i], |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 719 | std::to_string(chassis_type)); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 720 | continue; |
| 721 | } |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 722 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 723 | } |
| 724 | break; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 725 | case IPMI_FRU_AREA_BOARD_INFO: |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 726 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 727 | printf("Board : Buf len = [%d]\n", len); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 728 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 729 | ipmi_fru_board_info_area( |
| 730 | (uint8_t*)msgbuf + 2, len, NULL, &mfg_date_time, |
| 731 | &vpd_info[OPENBMC_VPD_KEY_BOARD_MFR], |
| 732 | &vpd_info[OPENBMC_VPD_KEY_BOARD_NAME], |
| 733 | &vpd_info[OPENBMC_VPD_KEY_BOARD_SERIAL_NUM], |
| 734 | &vpd_info[OPENBMC_VPD_KEY_BOARD_PART_NUM], |
| 735 | &vpd_info[OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID], |
| 736 | &vpd_info[OPENBMC_VPD_KEY_BOARD_CUSTOM1], |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 737 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
| 738 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 739 | /* Populate VPD Table */ |
| 740 | for (i = OPENBMC_VPD_KEY_BOARD_MFG_DATE; |
| 741 | i <= OPENBMC_VPD_KEY_BOARD_MAX; i++) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 742 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 743 | if (i == OPENBMC_VPD_KEY_BOARD_MFG_DATE) |
| 744 | { |
| 745 | _to_time_str(mfg_date_time, timestr, OPENBMC_VPD_VAL_LEN); |
| 746 | #if IPMI_FRU_PARSER_DEBUG |
| 747 | printf("Board : Appending [%s] = [%s]\n", vpd_key_names[i], |
| 748 | timestr); |
| 749 | #endif |
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 750 | info[i] = std::make_pair(vpd_key_names[i], |
| 751 | std::string(timestr)); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 752 | continue; |
| 753 | } |
| 754 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 755 | } |
| 756 | break; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 757 | case IPMI_FRU_AREA_PRODUCT_INFO: |
| 758 | #if IPMI_FRU_PARSER_DEBUG |
| 759 | printf("Product : Buf len = [%d]\n", len); |
| 760 | #endif |
| 761 | ipmi_fru_product_info_area( |
| 762 | (uint8_t*)msgbuf + 2, len, NULL, |
| 763 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_MFR], |
| 764 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_NAME], |
| 765 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM], |
| 766 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_VER], |
| 767 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM], |
| 768 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG], |
| 769 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID], |
| 770 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_CUSTOM1], |
| 771 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
| 772 | |
| 773 | for (i = OPENBMC_VPD_KEY_PRODUCT_MFR; |
| 774 | i <= OPENBMC_VPD_KEY_PRODUCT_MAX; ++i) |
| 775 | { |
| 776 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
| 777 | } |
| 778 | break; |
| 779 | default: |
| 780 | /* TODO: Parse Multi Rec / Internal use area */ |
| 781 | break; |
| 782 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 783 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 784 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 785 | printf("parse_fru_area : Dictionary Packing Complete\n"); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 786 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 787 | rv = 0; |
| 788 | return (rv); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 789 | } |