1 #pragma once 2 3 #include "config.h" 4 5 #include "bios_parser.hpp" 6 #include "bios_table.hpp" 7 #include "handler.hpp" 8 9 #include <stdint.h> 10 11 #include <functional> 12 #include <map> 13 #include <vector> 14 15 #include "libpldm/bios.h" 16 #include "libpldm/bios_table.h" 17 18 namespace pldm 19 { 20 21 using AttributeHandle = uint16_t; 22 using StringHandle = uint16_t; 23 using PossibleValuesByHandle = std::vector<StringHandle>; 24 25 namespace responder 26 { 27 28 namespace bios 29 { 30 31 using AttrTableEntryHandler = 32 std::function<void(const struct pldm_bios_attr_table_entry*)>; 33 34 void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable, 35 AttrTableEntryHandler handler); 36 37 namespace internal 38 { 39 40 /** @brief Constructs all the BIOS Tables 41 * 42 * @param[in] request - Request message 43 * @param[in] payload_length - Request message payload length 44 * @param[in] biosJsonDir - path to fetch the BIOS json files 45 * @param[in] biosTablePath - path where the BIOS tables will be persisted 46 */ 47 Response buildBIOSTables(const pldm_msg* request, size_t payloadLength, 48 const char* biosJsonDir, const char* biosTablePath); 49 } // namespace internal 50 51 class Handler : public CmdHandler 52 { 53 public: 54 Handler() 55 { 56 handlers.emplace(PLDM_GET_DATE_TIME, 57 [this](const pldm_msg* request, size_t payloadLength) { 58 return this->getDateTime(request, payloadLength); 59 }); 60 handlers.emplace(PLDM_GET_BIOS_TABLE, 61 [this](const pldm_msg* request, size_t payloadLength) { 62 return this->getBIOSTable(request, payloadLength); 63 }); 64 } 65 66 /** @brief Handler for GetDateTime 67 * 68 * @param[in] request - Request message payload 69 * @param[return] Response - PLDM Response message 70 */ 71 Response getDateTime(const pldm_msg* request, size_t payloadLength); 72 73 /** @brief Handler for GetBIOSTable 74 * 75 * @param[in] request - Request message 76 * @param[in] payload_length - Request message payload length 77 * @param[return] Response - PLDM Response message 78 */ 79 Response getBIOSTable(const pldm_msg* request, size_t payloadLength); 80 }; 81 82 } // namespace bios 83 84 namespace utils 85 { 86 87 /** @brief Convert epoch time to BCD time 88 * 89 * @param[in] timeSec - Time got from epoch time in seconds 90 * @param[out] seconds - number of seconds in BCD 91 * @param[out] minutes - number of minutes in BCD 92 * @param[out] hours - number of hours in BCD 93 * @param[out] day - day of the month in BCD 94 * @param[out] month - month number in BCD 95 * @param[out] year - year number in BCD 96 */ 97 void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, 98 uint8_t& hours, uint8_t& day, uint8_t& month, 99 uint16_t& year); 100 } // namespace utils 101 102 } // namespace responder 103 } // namespace pldm 104