blob: 6923063b816b8bcdf9ce8d37aa4fc45d0f397b26 [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001#pragma once
2
John Wang6080aae2020-02-14 09:34:25 +08003#include "bios_config.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05004#include "bios_table.hpp"
Andrew Jeffery2abbce72023-10-18 10:17:35 +10305#include "common/instance_id.hpp"
Kamalkumar Patel3c50c822024-01-30 07:14:40 -06006#include "platform_config.hpp"
Deepak Kodihalli1521f6d2020-06-16 08:51:02 -05007#include "pldmd/handler.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -05008#include "requester/handler.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05009
George Liuc453e162022-12-21 17:16:23 +080010#include <libpldm/bios.h>
11#include <libpldm/bios_table.h>
Sampa Misra032bd502019-03-06 05:03:22 -060012#include <stdint.h>
13
Xiaochao Ma60227a02019-12-04 09:00:12 +080014#include <ctime>
John Wang02700402019-10-06 16:34:29 +080015#include <functional>
Sampa Misrab37be312019-07-03 02:26:41 -050016#include <map>
vkaverapa6575b82019-04-03 05:33:52 -050017#include <vector>
18
Sampa Misra032bd502019-03-06 05:03:22 -060019namespace pldm
20{
21
22namespace responder
23{
24
Deepak Kodihallibc669f12019-11-28 08:52:07 -060025namespace bios
26{
27
Deepak Kodihallibc669f12019-11-28 08:52:07 -060028class Handler : public CmdHandler
29{
30 public:
Tom Joseph7f839f92020-09-21 10:20:44 +053031 /** @brief Constructor
32 *
33 * @param[in] fd - socket descriptor to communicate to host
34 * @param[in] eid - MCTP EID of host firmware
Andrew Jefferya330b2f2023-05-04 14:55:37 +093035 * @param[in] instanceIdDb - pointer to an InstanceIdDb object
Sampa Misrac0c79482021-06-02 08:01:54 -050036 * @param[in] handler - PLDM request handler
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060037 * @param[in] platformConfigHandler - pointer to platform config object
Tom Joseph7f839f92020-09-21 10:20:44 +053038 */
Andrew Jefferya330b2f2023-05-04 14:55:37 +093039 Handler(int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
Sagar Srinivas11ce8d22022-07-28 11:32:34 -050040 pldm::requester::Handler<pldm::requester::Request>* handler,
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060041 pldm::responder::platform_config::Handler* platformConfigHandler);
Deepak Kodihallibc669f12019-11-28 08:52:07 -060042
43 /** @brief Handler for GetDateTime
44 *
45 * @param[in] request - Request message payload
Xiaochao Ma60227a02019-12-04 09:00:12 +080046 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060047 */
48 Response getDateTime(const pldm_msg* request, size_t payloadLength);
49
50 /** @brief Handler for GetBIOSTable
51 *
52 * @param[in] request - Request message
53 * @param[in] payload_length - Request message payload length
Xiaochao Ma60227a02019-12-04 09:00:12 +080054 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060055 */
56 Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
John Wang8721ed62019-12-05 14:44:43 +080057
George Liu1b180d82020-07-23 14:01:58 +080058 /** @brief Handler for SetBIOSTable
59 *
60 * @param[in] request - Request message
61 * @param[in] payload_length - Request message payload length
62 * @return Response - PLDM Response message
63 */
64 Response setBIOSTable(const pldm_msg* request, size_t payloadLength);
65
John Wang8721ed62019-12-05 14:44:43 +080066 /** @brief Handler for GetBIOSAttributeCurrentValueByHandle
67 *
68 * @param[in] request - Request message
69 * @param[in] payloadLength - Request message payload length
70 * @return Response - PLDM Response message
71 */
72 Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request,
73 size_t payloadLength);
Xiaochao Ma60227a02019-12-04 09:00:12 +080074
75 /** @brief Handler for SetDateTime
76 *
77 * @param[in] request - Request message payload
78 * @param[in] payloadLength - Request message payload length
79 * @return Response - PLDM Response message
80 */
81 Response setDateTime(const pldm_msg* request, size_t payloadLength);
John Wang42174882019-12-20 14:56:59 +080082
83 /** @brief Handler for setBIOSAttributeCurrentValue
84 *
85 * @param[in] request - Request message
86 * @param[in] payloadLength - Request message payload length
87 * @return Response - PLDM Response message
88 */
89 Response setBIOSAttributeCurrentValue(const pldm_msg* request,
90 size_t payloadLength);
John Wang6080aae2020-02-14 09:34:25 +080091
92 private:
93 BIOSConfig biosConfig;
Deepak Kodihallibc669f12019-11-28 08:52:07 -060094};
Sampa Misrab37be312019-07-03 02:26:41 -050095
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050096} // namespace bios
97
Sampa Misra032bd502019-03-06 05:03:22 -060098namespace utils
99{
100
101/** @brief Convert epoch time to BCD time
102 *
103 * @param[in] timeSec - Time got from epoch time in seconds
104 * @param[out] seconds - number of seconds in BCD
105 * @param[out] minutes - number of minutes in BCD
106 * @param[out] hours - number of hours in BCD
107 * @param[out] day - day of the month in BCD
108 * @param[out] month - month number in BCD
109 * @param[out] year - year number in BCD
110 */
111void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes,
112 uint8_t& hours, uint8_t& day, uint8_t& month,
113 uint16_t& year);
Xiaochao Ma60227a02019-12-04 09:00:12 +0800114
115/** @brief Convert dec time to epoch time
116 *
117 * @param[in] seconds - number of seconds in dec
118 * @param[in] minutes - number of minutes in dec
119 * @param[in] hours - number of hours in dec
120 * @param[in] day - day of the month in dec
121 * @param[in] month - month number in dec
122 * @param[in] year - year number in dec
123 * @return time - epoch time
124 */
125std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours,
126 uint8_t day, uint8_t month, uint16_t year);
Sampa Misra032bd502019-03-06 05:03:22 -0600127} // namespace utils
128
129} // namespace responder
130} // namespace pldm