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 | |
| 84 | struct ipmi_fru_field |
| 85 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 86 | uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; |
| 87 | /* store length of data stored in buffer */ |
| 88 | unsigned int type_length_field_length; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | typedef struct ipmi_fru_field ipmi_fru_field_t; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 92 | /* |
| 93 | * FRU Parser |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 94 | */ |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 95 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 96 | typedef struct ipmi_fru_area_info |
| 97 | { |
| 98 | uint8_t off; |
| 99 | uint8_t len; |
| 100 | } ipmi_fru_area_info_t; |
| 101 | |
| 102 | typedef struct ipmi_fru_common_hdr |
| 103 | { |
| 104 | uint8_t fmtver; |
| 105 | uint8_t internal; |
| 106 | uint8_t chassis; |
| 107 | uint8_t board; |
| 108 | uint8_t product; |
| 109 | uint8_t multirec; |
| 110 | } __attribute__((packed)) ipmi_fru_common_hdr_t; |
| 111 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 112 | const char* vpd_key_names[] = { |
| 113 | "Key Names Table Start", |
| 114 | "Type", /*OPENBMC_VPD_KEY_CHASSIS_TYPE*/ |
| 115 | "Part Number", /*OPENBMC_VPD_KEY_CHASSIS_PART_NUM,*/ |
| 116 | "Serial Number", /*OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM,*/ |
| 117 | "Custom Field 1", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM1,*/ |
| 118 | "Custom Field 2", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM2,*/ |
| 119 | "Custom Field 3", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM3,*/ |
| 120 | "Custom Field 4", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM4,*/ |
| 121 | "Custom Field 5", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM5,*/ |
| 122 | "Custom Field 6", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM6,*/ |
| 123 | "Custom Field 7", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM7,*/ |
| 124 | "Custom Field 8", /*OPENBMC_VPD_KEY_CHASSIS_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 125 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 126 | "Mfg Date", |
| 127 | /* OPENBMC_VPD_KEY_BOARD_MFG_DATE, */ /* not a type/len */ |
| 128 | "Manufacturer", /* OPENBMC_VPD_KEY_BOARD_MFR, */ |
| 129 | "Name", /* OPENBMC_VPD_KEY_BOARD_NAME, */ |
| 130 | "Serial Number", /* OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, */ |
| 131 | "Part Number", /* OPENBMC_VPD_KEY_BOARD_PART_NUM, */ |
| 132 | "FRU File ID", /* OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, */ |
| 133 | "Custom Field 1", /*OPENBMC_VPD_KEY_BOARD_CUSTOM1,*/ |
| 134 | "Custom Field 2", /*OPENBMC_VPD_KEY_BOARD_CUSTOM2,*/ |
| 135 | "Custom Field 3", /*OPENBMC_VPD_KEY_BOARD_CUSTOM3,*/ |
| 136 | "Custom Field 4", /*OPENBMC_VPD_KEY_BOARD_CUSTOM4,*/ |
| 137 | "Custom Field 5", /*OPENBMC_VPD_KEY_BOARD_CUSTOM5,*/ |
| 138 | "Custom Field 6", /*OPENBMC_VPD_KEY_BOARD_CUSTOM6,*/ |
| 139 | "Custom Field 7", /*OPENBMC_VPD_KEY_BOARD_CUSTOM7,*/ |
| 140 | "Custom Field 8", /*OPENBMC_VPD_KEY_BOARD_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 141 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 142 | "Manufacturer", /* OPENBMC_VPD_KEY_PRODUCT_MFR, */ |
| 143 | "Name", /* OPENBMC_VPD_KEY_PRODUCT_NAME, */ |
| 144 | "Model Number", /* OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, */ |
| 145 | "Version", /* OPENBMC_VPD_KEY_PRODUCT_VER, */ |
| 146 | "Serial Number", /* OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, */ |
| 147 | "Asset Tag", /* OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, */ |
| 148 | "FRU File ID", /* OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, */ |
| 149 | "Custom Field 1", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM1,*/ |
| 150 | "Custom Field 2", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM2,*/ |
| 151 | "Custom Field 3", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM3,*/ |
| 152 | "Custom Field 4", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM4,*/ |
| 153 | "Custom Field 5", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM5,*/ |
| 154 | "Custom Field 6", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM6,*/ |
| 155 | "Custom Field 7", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM7,*/ |
| 156 | "Custom Field 8", /*OPENBMC_VPD_KEY_PRODUCT_CUSTOM8,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 157 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 158 | "Key Names Table End" /*OPENBMC_VPD_KEY_MAX,*/ |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 159 | }; |
| 160 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 161 | /* |
| 162 | * -------------------------------------------------------------------- |
| 163 | * |
| 164 | * -------------------------------------------------------------------- |
| 165 | */ |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 166 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 167 | 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] | 168 | { |
| 169 | struct tm tm; |
| 170 | time_t t; |
| 171 | size_t s; |
| 172 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 173 | ASSERT(timestr); |
| 174 | ASSERT(len); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 175 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 176 | memset(&tm, '\0', sizeof(struct tm)); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 177 | |
| 178 | t = mfg_date_time; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 179 | gmtime_r(&t, &tm); |
| 180 | s = strftime(timestr, len, "%F - %H:%M:%S", &tm); |
Hariharasubramanian R | 4a0b6fb | 2015-10-31 22:45:48 -0500 | [diff] [blame] | 181 | |
| 182 | return s; |
| 183 | } |
| 184 | |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 185 | /* private method to parse type/length */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 186 | static int _parse_type_length(const void* areabuf, unsigned int areabuflen, |
| 187 | unsigned int current_area_offset, |
| 188 | uint8_t* number_of_data_bytes, |
| 189 | ipmi_fru_field_t* field) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 190 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 191 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 192 | uint8_t type_length; |
| 193 | uint8_t type_code; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 194 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 195 | ASSERT(areabuf); |
| 196 | ASSERT(areabuflen); |
| 197 | ASSERT(number_of_data_bytes); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 198 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 199 | type_length = areabufptr[current_area_offset]; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 200 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 201 | /* ipmi workaround |
| 202 | * |
| 203 | * dell p weredge r610 |
| 204 | * |
| 205 | * my reading of the fru spec is that all non-custom fields are |
| 206 | * required to be listed by the vendor. however, on this |
| 207 | * motherboard, some areas list this, indicating that there is |
| 208 | * no more data to be parsed. so now, for "required" fields, i |
| 209 | * check to see if the type-length field is a sentinel before |
| 210 | * calling this function. |
| 211 | */ |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 212 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 213 | ASSERT(type_length != IPMI_FRU_SENTINEL_VALUE); |
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 | type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> |
| 216 | IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; |
| 217 | (*number_of_data_bytes) = |
| 218 | type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 219 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 220 | /* special case: this shouldn't be a length of 0x01 (see type/length |
| 221 | * byte format in fru information storage definition). |
| 222 | */ |
| 223 | if (type_code == IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE && |
| 224 | (*number_of_data_bytes) == 0x01) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 225 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 226 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 227 | } |
| 228 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 229 | if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 230 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 231 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 232 | } |
| 233 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 234 | if (field) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 235 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 236 | memset(field->type_length_field, '\0', |
| 237 | IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); |
| 238 | memcpy(field->type_length_field, &areabufptr[current_area_offset], |
| 239 | 1 + (*number_of_data_bytes)); |
| 240 | field->type_length_field_length = 1 + (*number_of_data_bytes); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 241 | } |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 242 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 243 | return (0); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 244 | } |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 245 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 246 | int ipmi_fru_chassis_info_area(const void* areabuf, unsigned int areabuflen, |
| 247 | uint8_t* chassis_type, |
| 248 | ipmi_fru_field_t* chassis_part_number, |
| 249 | ipmi_fru_field_t* chassis_serial_number, |
| 250 | ipmi_fru_field_t* chassis_custom_fields, |
| 251 | unsigned int chassis_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 252 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 253 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 254 | unsigned int area_offset = 0; |
| 255 | unsigned int custom_fields_index = 0; |
| 256 | uint8_t number_of_data_bytes; |
| 257 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 258 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 259 | if (!areabuf || !areabuflen) |
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 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 262 | } |
| 263 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 264 | if (chassis_part_number) |
| 265 | memset(chassis_part_number, '\0', sizeof(ipmi_fru_field_t)); |
| 266 | if (chassis_serial_number) |
| 267 | memset(chassis_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 268 | if (chassis_custom_fields && chassis_custom_fields_len) |
| 269 | memset(chassis_custom_fields, '\0', |
| 270 | sizeof(ipmi_fru_field_t) * chassis_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 271 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 272 | if (chassis_type) |
| 273 | (*chassis_type) = areabufptr[area_offset]; |
| 274 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 275 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 276 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 277 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 278 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 279 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 280 | &number_of_data_bytes, chassis_part_number) < 0) |
| 281 | goto cleanup; |
| 282 | area_offset += 1; /* type/length byte */ |
| 283 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 284 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 285 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 286 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 287 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 288 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 289 | &number_of_data_bytes, chassis_serial_number) < 0) |
| 290 | goto cleanup; |
| 291 | area_offset += 1; /* type/length byte */ |
| 292 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 293 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 294 | while (area_offset < areabuflen && |
| 295 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 296 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 297 | ipmi_fru_field_t* field_ptr = NULL; |
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 | if (chassis_custom_fields && chassis_custom_fields_len) |
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 (custom_fields_index < chassis_custom_fields_len) |
| 302 | field_ptr = &chassis_custom_fields[custom_fields_index]; |
| 303 | else |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 304 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 305 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 309 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 310 | &number_of_data_bytes, field_ptr) < 0) |
| 311 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 312 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 313 | area_offset += 1; /* type/length byte */ |
| 314 | area_offset += number_of_data_bytes; |
| 315 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 316 | } |
| 317 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 318 | out: |
| 319 | rv = 0; |
| 320 | cleanup: |
| 321 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 322 | } |
| 323 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 324 | int ipmi_fru_board_info_area( |
| 325 | const void* areabuf, unsigned int areabuflen, uint8_t* language_code, |
| 326 | uint32_t* mfg_date_time, ipmi_fru_field_t* board_manufacturer, |
| 327 | ipmi_fru_field_t* board_product_name, ipmi_fru_field_t* board_serial_number, |
| 328 | ipmi_fru_field_t* board_part_number, ipmi_fru_field_t* board_fru_file_id, |
| 329 | 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] | 330 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 331 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 332 | uint32_t mfg_date_time_tmp = 0; |
| 333 | unsigned int area_offset = 0; |
| 334 | unsigned int custom_fields_index = 0; |
| 335 | uint8_t number_of_data_bytes; |
| 336 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 337 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 338 | if (!areabuf || !areabuflen) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 339 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 340 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 341 | } |
| 342 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 343 | if (board_manufacturer) |
| 344 | memset(board_manufacturer, '\0', sizeof(ipmi_fru_field_t)); |
| 345 | if (board_product_name) |
| 346 | memset(board_product_name, '\0', sizeof(ipmi_fru_field_t)); |
| 347 | if (board_serial_number) |
| 348 | memset(board_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 349 | if (board_part_number) |
| 350 | memset(board_part_number, '\0', sizeof(ipmi_fru_field_t)); |
| 351 | if (board_fru_file_id) |
| 352 | memset(board_fru_file_id, '\0', sizeof(ipmi_fru_field_t)); |
| 353 | if (board_custom_fields && board_custom_fields_len) |
| 354 | memset(board_custom_fields, '\0', |
| 355 | sizeof(ipmi_fru_field_t) * board_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 356 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 357 | if (language_code) |
| 358 | (*language_code) = areabufptr[area_offset]; |
| 359 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 360 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 361 | if (mfg_date_time) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 362 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 363 | struct tm tm; |
| 364 | time_t t; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 365 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 366 | /* mfg_date_time is little endian - see spec */ |
| 367 | mfg_date_time_tmp |= areabufptr[area_offset]; |
| 368 | area_offset++; |
| 369 | mfg_date_time_tmp |= (areabufptr[area_offset] << 8); |
| 370 | area_offset++; |
| 371 | mfg_date_time_tmp |= (areabufptr[area_offset] << 16); |
| 372 | area_offset++; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 373 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 374 | /* mfg_date_time is in minutes, so multiple by 60 to get seconds */ |
| 375 | mfg_date_time_tmp *= 60; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 376 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 377 | /* posix says individual calls need not clear/set all portions of |
| 378 | * 'struct tm', thus passing 'struct tm' between functions could |
| 379 | * have issues. so we need to memset. |
| 380 | */ |
| 381 | memset(&tm, '\0', sizeof(struct tm)); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 382 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 383 | /* in fru, epoch is 0:00 hrs 1/1/96 |
| 384 | * |
| 385 | * so convert into ansi epoch |
| 386 | */ |
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 | tm.tm_year = 96; /* years since 1900 */ |
| 389 | tm.tm_mon = 0; /* months since january */ |
| 390 | tm.tm_mday = 1; /* 1-31 */ |
| 391 | tm.tm_hour = 0; |
| 392 | tm.tm_min = 0; |
| 393 | tm.tm_sec = 0; |
| 394 | tm.tm_isdst = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 395 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 396 | if ((t = mktime(&tm)) == (time_t)-1) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 397 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 398 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 399 | } |
| 400 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 401 | mfg_date_time_tmp += (uint32_t)t; |
| 402 | (*mfg_date_time) = mfg_date_time_tmp; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 403 | } |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 404 | else |
| 405 | area_offset += 3; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 406 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 407 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 408 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 409 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 410 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 411 | &number_of_data_bytes, board_manufacturer) < 0) |
| 412 | goto cleanup; |
| 413 | area_offset += 1; /* type/length byte */ |
| 414 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 415 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 416 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 417 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 418 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 419 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 420 | &number_of_data_bytes, board_product_name) < 0) |
| 421 | goto cleanup; |
| 422 | area_offset += 1; /* type/length byte */ |
| 423 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 424 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 425 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 426 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 427 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 428 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 429 | &number_of_data_bytes, board_serial_number) < 0) |
| 430 | goto cleanup; |
| 431 | area_offset += 1; /* type/length byte */ |
| 432 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 433 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 434 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 435 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 436 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 437 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 438 | &number_of_data_bytes, board_part_number) < 0) |
| 439 | goto cleanup; |
| 440 | area_offset += 1; /* type/length byte */ |
| 441 | area_offset += number_of_data_bytes; |
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 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 444 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 445 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 446 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 447 | &number_of_data_bytes, board_fru_file_id) < 0) |
| 448 | goto cleanup; |
| 449 | area_offset += 1; /* type/length byte */ |
| 450 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 451 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 452 | while (area_offset < areabuflen && |
| 453 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 454 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 455 | ipmi_fru_field_t* field_ptr = NULL; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 456 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 457 | if (board_custom_fields && board_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 458 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 459 | if (custom_fields_index < board_custom_fields_len) |
| 460 | field_ptr = &board_custom_fields[custom_fields_index]; |
| 461 | else |
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 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 467 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 468 | &number_of_data_bytes, field_ptr) < 0) |
| 469 | goto cleanup; |
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 | area_offset += 1; /* type/length byte */ |
| 472 | area_offset += number_of_data_bytes; |
| 473 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 476 | out: |
| 477 | rv = 0; |
| 478 | cleanup: |
| 479 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 480 | } |
| 481 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 482 | int ipmi_fru_product_info_area( |
| 483 | const void* areabuf, unsigned int areabuflen, uint8_t* language_code, |
| 484 | ipmi_fru_field_t* product_manufacturer_name, ipmi_fru_field_t* product_name, |
| 485 | ipmi_fru_field_t* product_part_model_number, |
| 486 | ipmi_fru_field_t* product_version, ipmi_fru_field_t* product_serial_number, |
| 487 | ipmi_fru_field_t* product_asset_tag, ipmi_fru_field_t* product_fru_file_id, |
| 488 | ipmi_fru_field_t* product_custom_fields, |
| 489 | unsigned int product_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 490 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 491 | const uint8_t* areabufptr = (const uint8_t*)areabuf; |
| 492 | unsigned int area_offset = 0; |
| 493 | unsigned int custom_fields_index = 0; |
| 494 | uint8_t number_of_data_bytes; |
| 495 | int rv = -1; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 496 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 497 | if (!areabuf || !areabuflen) |
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 | return (-1); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 500 | } |
| 501 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 502 | if (product_manufacturer_name) |
| 503 | memset(product_manufacturer_name, '\0', sizeof(ipmi_fru_field_t)); |
| 504 | if (product_name) |
| 505 | memset(product_name, '\0', sizeof(ipmi_fru_field_t)); |
| 506 | if (product_part_model_number) |
| 507 | memset(product_part_model_number, '\0', sizeof(ipmi_fru_field_t)); |
| 508 | if (product_version) |
| 509 | memset(product_version, '\0', sizeof(ipmi_fru_field_t)); |
| 510 | if (product_serial_number) |
| 511 | memset(product_serial_number, '\0', sizeof(ipmi_fru_field_t)); |
| 512 | if (product_asset_tag) |
| 513 | memset(product_asset_tag, '\0', sizeof(ipmi_fru_field_t)); |
| 514 | if (product_fru_file_id) |
| 515 | memset(product_fru_file_id, '\0', sizeof(ipmi_fru_field_t)); |
| 516 | if (product_custom_fields && product_custom_fields_len) |
| 517 | memset(product_custom_fields, '\0', |
| 518 | sizeof(ipmi_fru_field_t) * product_custom_fields_len); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 519 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 520 | if (language_code) |
| 521 | (*language_code) = areabufptr[area_offset]; |
| 522 | area_offset++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 523 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 524 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 525 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 526 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 527 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 528 | &number_of_data_bytes, |
| 529 | product_manufacturer_name) < 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_name) < 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, |
| 548 | product_part_model_number) < 0) |
| 549 | goto cleanup; |
| 550 | area_offset += 1; /* type/length byte */ |
| 551 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 552 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 553 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 554 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 555 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 556 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 557 | &number_of_data_bytes, product_version) < 0) |
| 558 | goto cleanup; |
| 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 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 563 | goto out; |
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 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 566 | &number_of_data_bytes, product_serial_number) < 0) |
| 567 | goto cleanup; |
| 568 | area_offset += 1; /* type/length byte */ |
| 569 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 570 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 571 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 572 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 573 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 574 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 575 | &number_of_data_bytes, product_asset_tag) < 0) |
| 576 | goto cleanup; |
| 577 | area_offset += 1; /* type/length byte */ |
| 578 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 579 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 580 | if (areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) |
| 581 | goto out; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 582 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 583 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 584 | &number_of_data_bytes, product_fru_file_id) < 0) |
| 585 | goto cleanup; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 586 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 587 | area_offset += 1; /* type/length byte */ |
| 588 | area_offset += number_of_data_bytes; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 589 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 590 | while (area_offset < areabuflen && |
| 591 | areabufptr[area_offset] != IPMI_FRU_SENTINEL_VALUE) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 592 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 593 | ipmi_fru_field_t* field_ptr = NULL; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 594 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 595 | if (product_custom_fields && product_custom_fields_len) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 596 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 597 | if (custom_fields_index < product_custom_fields_len) |
| 598 | field_ptr = &product_custom_fields[custom_fields_index]; |
| 599 | else |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 600 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 601 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 602 | } |
| 603 | } |
| 604 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 605 | if (_parse_type_length(areabufptr, areabuflen, area_offset, |
| 606 | &number_of_data_bytes, field_ptr) < 0) |
| 607 | goto cleanup; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 608 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 609 | area_offset += 1; /* type/length byte */ |
| 610 | area_offset += number_of_data_bytes; |
| 611 | custom_fields_index++; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 612 | } |
| 613 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 614 | out: |
| 615 | rv = 0; |
| 616 | cleanup: |
| 617 | return (rv); |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 618 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 619 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 620 | void _append_to_dict(uint8_t vpd_key_id, uint8_t* vpd_key_val, |
| 621 | IPMIFruInfo& info) |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 622 | { |
| 623 | int type_length = vpd_key_val[0]; |
Deepak Kodihalli | 8a2a675 | 2017-02-11 03:04:38 -0600 | [diff] [blame] | 624 | int type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> |
| 625 | IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; |
| 626 | int vpd_val_len = |
| 627 | type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 628 | int sdr = 0; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 629 | |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 630 | /* Needed to convert each uint8_t byte to a ascii */ |
| 631 | char bin_byte[3] = {0}; |
| 632 | |
| 633 | /* |
| 634 | * Max number of characters needed to represent 1 unsigned byte in string |
Gunnar Mills | c19b813 | 2018-06-14 08:56:17 -0500 | [diff] [blame] | 635 | * 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] | 636 | */ |
| 637 | char bin_in_ascii_len = vpd_val_len * 2 + 3; |
| 638 | |
| 639 | /* Binary converted to ascii in array */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 640 | char* bin_in_ascii = (char*)malloc(bin_in_ascii_len); |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 641 | |
| 642 | /* For reading byte from the area */ |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 643 | int val = 0; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 644 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 645 | char* bin_copy = &((char*)bin_in_ascii)[2]; |
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 | switch (type_code) |
| 648 | { |
| 649 | case 0: |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 650 | memset(bin_in_ascii, 0x0, bin_in_ascii_len); |
| 651 | |
| 652 | /* Offset 1 is where actual data starts */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 653 | for (val = 1; val <= vpd_val_len; val++) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 654 | { |
| 655 | /* 2 bytes for data and 1 for terminating '\0' */ |
| 656 | snprintf(bin_byte, 3, "%02x", vpd_key_val[val]); |
| 657 | |
| 658 | /* Its a running string so strip off the '\0' */ |
| 659 | strncat(bin_copy, bin_byte, 2); |
| 660 | } |
| 661 | |
| 662 | /* We need the data represented as 0x...... */ |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 663 | if (vpd_val_len > 0) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 664 | { |
| 665 | strncpy(bin_in_ascii, "0x", 2); |
| 666 | } |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 667 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 668 | printf("_append_to_dict: VPD Key = [%s] : Type Code = [BINARY] :" |
| 669 | " Len = [%d] : Val = [%s]\n", |
| 670 | vpd_key_names[vpd_key_id], vpd_val_len, bin_in_ascii); |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 671 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 672 | info[vpd_key_id] = |
| 673 | std::make_pair(vpd_key_names[vpd_key_id], bin_in_ascii); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 674 | break; |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 675 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 676 | case 3: |
Andrew Geissler | 4e41166 | 2017-06-01 07:26:39 -0500 | [diff] [blame] | 677 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 678 | printf("_append_to_dict: VPD Key = [%s] : Type Code=[ASCII+Latin]" |
| 679 | " : Len = [%d] : Val = [%s]\n", |
| 680 | 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] | 681 | #endif |
Deepak Kodihalli | 8a2a675 | 2017-02-11 03:04:38 -0600 | [diff] [blame] | 682 | info[vpd_key_id] = std::make_pair( |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 683 | vpd_key_names[vpd_key_id], |
| 684 | std::string(vpd_key_val + 1, vpd_key_val + 1 + type_length)); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 685 | break; |
| 686 | } |
| 687 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 688 | if (bin_in_ascii) |
vishwa | 24afbb9 | 2016-06-10 06:08:56 -0500 | [diff] [blame] | 689 | { |
| 690 | free(bin_in_ascii); |
| 691 | bin_in_ascii = NULL; |
| 692 | } |
| 693 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 694 | if (sdr < 0) |
| 695 | { |
| 696 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 697 | printf( |
| 698 | "_append_to_dict : sd_bus_message_append Failed [ %d ] for [%s]\n", |
| 699 | sdr, vpd_key_names[vpd_key_id]); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 700 | #endif |
| 701 | } |
| 702 | } |
| 703 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 704 | int parse_fru_area(const uint8_t area, const void* msgbuf, const size_t len, |
| 705 | IPMIFruInfo& info) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 706 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 707 | int rv = -1; |
| 708 | int i = 0; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 709 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 710 | /* Chassis */ |
| 711 | uint8_t chassis_type; |
| 712 | /* Board */ |
| 713 | uint32_t mfg_date_time; |
| 714 | /* Product */ |
| 715 | // unsigned int product_custom_fields_len; |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 716 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 717 | // ipmi_fru_area_info_t fru_area_info [ IPMI_FRU_AREA_TYPE_MAX ]; |
| 718 | ipmi_fru_field_t vpd_info[OPENBMC_VPD_KEY_MAX]; |
| 719 | char timestr[OPENBMC_VPD_VAL_LEN]; |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 720 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 721 | // uint8_t* ipmi_fru_field_str=NULL; |
| 722 | // ipmi_fru_common_hdr_t* chdr = NULL; |
| 723 | // uint8_t* hdr = NULL; |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 724 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 725 | ASSERT(msgbuf); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 726 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 727 | for (i = 0; i < OPENBMC_VPD_KEY_MAX; i++) |
| 728 | { |
| 729 | memset(vpd_info[i].type_length_field, '\0', |
| 730 | IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); |
| 731 | vpd_info[i].type_length_field_length = 0; |
| 732 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 733 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 734 | switch (area) |
| 735 | { |
| 736 | case IPMI_FRU_AREA_CHASSIS_INFO: |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 737 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 738 | printf("Chassis : Buf len = [%d]\n", len); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 739 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 740 | ipmi_fru_chassis_info_area( |
| 741 | (uint8_t*)msgbuf + 2, len, &chassis_type, |
| 742 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_PART_NUM], |
| 743 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM], |
| 744 | &vpd_info[OPENBMC_VPD_KEY_CHASSIS_CUSTOM1], |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 745 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 746 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 747 | /* Populate VPD Table */ |
| 748 | for (i = 1; i <= OPENBMC_VPD_KEY_CHASSIS_MAX; i++) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 749 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 750 | if (i == OPENBMC_VPD_KEY_CHASSIS_TYPE) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 751 | { |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 752 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 753 | printf("Chassis : Appending [%s] = [%d]\n", |
| 754 | vpd_key_names[i], chassis_type); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 755 | #endif |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 756 | info[i] = std::make_pair(vpd_key_names[i], |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 757 | std::to_string(chassis_type)); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 758 | continue; |
| 759 | } |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 760 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 761 | } |
| 762 | break; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 763 | case IPMI_FRU_AREA_BOARD_INFO: |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 764 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 765 | printf("Board : Buf len = [%d]\n", len); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 766 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 767 | ipmi_fru_board_info_area( |
| 768 | (uint8_t*)msgbuf + 2, len, NULL, &mfg_date_time, |
| 769 | &vpd_info[OPENBMC_VPD_KEY_BOARD_MFR], |
| 770 | &vpd_info[OPENBMC_VPD_KEY_BOARD_NAME], |
| 771 | &vpd_info[OPENBMC_VPD_KEY_BOARD_SERIAL_NUM], |
| 772 | &vpd_info[OPENBMC_VPD_KEY_BOARD_PART_NUM], |
| 773 | &vpd_info[OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID], |
| 774 | &vpd_info[OPENBMC_VPD_KEY_BOARD_CUSTOM1], |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 775 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
| 776 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 777 | /* Populate VPD Table */ |
| 778 | for (i = OPENBMC_VPD_KEY_BOARD_MFG_DATE; |
| 779 | i <= OPENBMC_VPD_KEY_BOARD_MAX; i++) |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 780 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 781 | if (i == OPENBMC_VPD_KEY_BOARD_MFG_DATE) |
| 782 | { |
| 783 | _to_time_str(mfg_date_time, timestr, OPENBMC_VPD_VAL_LEN); |
| 784 | #if IPMI_FRU_PARSER_DEBUG |
| 785 | printf("Board : Appending [%s] = [%s]\n", vpd_key_names[i], |
| 786 | timestr); |
| 787 | #endif |
| 788 | info[i] = |
| 789 | std::make_pair(vpd_key_names[i], std::string(timestr)); |
| 790 | continue; |
| 791 | } |
| 792 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 793 | } |
| 794 | break; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 795 | case IPMI_FRU_AREA_PRODUCT_INFO: |
| 796 | #if IPMI_FRU_PARSER_DEBUG |
| 797 | printf("Product : Buf len = [%d]\n", len); |
| 798 | #endif |
| 799 | ipmi_fru_product_info_area( |
| 800 | (uint8_t*)msgbuf + 2, len, NULL, |
| 801 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_MFR], |
| 802 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_NAME], |
| 803 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM], |
| 804 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_VER], |
| 805 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM], |
| 806 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG], |
| 807 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID], |
| 808 | &vpd_info[OPENBMC_VPD_KEY_PRODUCT_CUSTOM1], |
| 809 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX); |
| 810 | |
| 811 | for (i = OPENBMC_VPD_KEY_PRODUCT_MFR; |
| 812 | i <= OPENBMC_VPD_KEY_PRODUCT_MAX; ++i) |
| 813 | { |
| 814 | _append_to_dict(i, vpd_info[i].type_length_field, info); |
| 815 | } |
| 816 | break; |
| 817 | default: |
| 818 | /* TODO: Parse Multi Rec / Internal use area */ |
| 819 | break; |
| 820 | } |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 821 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 822 | #if IPMI_FRU_PARSER_DEBUG |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 823 | printf("parse_fru_area : Dictionary Packing Complete\n"); |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 824 | #endif |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 825 | rv = 0; |
| 826 | return (rv); |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 827 | } |