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