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 /** @brief Handler for GetDateTime 57 * 58 * @param[in] request - Request message payload 59 * @param[return] Response - PLDM Response message 60 */ 61 Response getDateTime(const pldm_msg* request, size_t payloadLength); 62 63 /** @brief Handler for GetBIOSTable 64 * 65 * @param[in] request - Request message 66 * @param[in] payload_length - Request message payload length 67 * @param[return] Response - PLDM Response message 68 */ 69 Response getBIOSTable(const pldm_msg* request, size_t payloadLength); 70 71 /** @brief Handler for GetBIOSAttributeCurrentValueByHandle 72 * 73 * @param[in] request - Request message 74 * @param[in] payloadLength - Request message payload length 75 * @return Response - PLDM Response message 76 */ 77 Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request, 78 size_t payloadLength); 79 }; 80 81 } // namespace bios 82 83 namespace utils 84 { 85 86 /** @brief Convert epoch time to BCD time 87 * 88 * @param[in] timeSec - Time got from epoch time in seconds 89 * @param[out] seconds - number of seconds in BCD 90 * @param[out] minutes - number of minutes in BCD 91 * @param[out] hours - number of hours in BCD 92 * @param[out] day - day of the month in BCD 93 * @param[out] month - month number in BCD 94 * @param[out] year - year number in BCD 95 */ 96 void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, 97 uint8_t& hours, uint8_t& day, uint8_t& month, 98 uint16_t& year); 99 } // namespace utils 100 101 } // namespace responder 102 } // namespace pldm 103