1 #pragma once 2 3 #include "config.h" 4 5 #include "bios_config.hpp" 6 #include "bios_table.hpp" 7 #include "pldmd/dbus_impl_requester.hpp" 8 #include "pldmd/handler.hpp" 9 #include "requester/handler.hpp" 10 11 #include <libpldm/bios.h> 12 #include <libpldm/bios_table.h> 13 #include <stdint.h> 14 15 #include <ctime> 16 #include <functional> 17 #include <map> 18 #include <vector> 19 20 namespace pldm 21 { 22 23 namespace responder 24 { 25 26 namespace bios 27 { 28 29 class Handler : public CmdHandler 30 { 31 public: 32 /** @brief Constructor 33 * 34 * @param[in] fd - socket descriptor to communicate to host 35 * @param[in] eid - MCTP EID of host firmware 36 * @param[in] requester - pointer to Requester object 37 * @param[in] handler - PLDM request handler 38 */ 39 Handler(int fd, uint8_t eid, dbus_api::Requester* requester, 40 pldm::requester::Handler<pldm::requester::Request>* handler); 41 42 /** @brief Handler for GetDateTime 43 * 44 * @param[in] request - Request message payload 45 * @return Response - PLDM Response message 46 */ 47 Response getDateTime(const pldm_msg* request, size_t payloadLength); 48 49 /** @brief Handler for GetBIOSTable 50 * 51 * @param[in] request - Request message 52 * @param[in] payload_length - Request message payload length 53 * @return Response - PLDM Response message 54 */ 55 Response getBIOSTable(const pldm_msg* request, size_t payloadLength); 56 57 /** @brief Handler for SetBIOSTable 58 * 59 * @param[in] request - Request message 60 * @param[in] payload_length - Request message payload length 61 * @return Response - PLDM Response message 62 */ 63 Response setBIOSTable(const pldm_msg* request, size_t payloadLength); 64 65 /** @brief Handler for GetBIOSAttributeCurrentValueByHandle 66 * 67 * @param[in] request - Request message 68 * @param[in] payloadLength - Request message payload length 69 * @return Response - PLDM Response message 70 */ 71 Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request, 72 size_t payloadLength); 73 74 /** @brief Handler for SetDateTime 75 * 76 * @param[in] request - Request message payload 77 * @param[in] payloadLength - Request message payload length 78 * @return Response - PLDM Response message 79 */ 80 Response setDateTime(const pldm_msg* request, size_t payloadLength); 81 82 /** @brief Handler for setBIOSAttributeCurrentValue 83 * 84 * @param[in] request - Request message 85 * @param[in] payloadLength - Request message payload length 86 * @return Response - PLDM Response message 87 */ 88 Response setBIOSAttributeCurrentValue(const pldm_msg* request, 89 size_t payloadLength); 90 91 private: 92 BIOSConfig biosConfig; 93 }; 94 95 } // namespace bios 96 97 namespace utils 98 { 99 100 /** @brief Convert epoch time to BCD time 101 * 102 * @param[in] timeSec - Time got from epoch time in seconds 103 * @param[out] seconds - number of seconds in BCD 104 * @param[out] minutes - number of minutes in BCD 105 * @param[out] hours - number of hours in BCD 106 * @param[out] day - day of the month in BCD 107 * @param[out] month - month number in BCD 108 * @param[out] year - year number in BCD 109 */ 110 void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, 111 uint8_t& hours, uint8_t& day, uint8_t& month, 112 uint16_t& year); 113 114 /** @brief Convert dec time to epoch time 115 * 116 * @param[in] seconds - number of seconds in dec 117 * @param[in] minutes - number of minutes in dec 118 * @param[in] hours - number of hours in dec 119 * @param[in] day - day of the month in dec 120 * @param[in] month - month number in dec 121 * @param[in] year - year number in dec 122 * @return time - epoch time 123 */ 124 std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours, 125 uint8_t day, uint8_t month, uint16_t year); 126 } // namespace utils 127 128 } // namespace responder 129 } // namespace pldm 130