blob: f72c9e8597522fb0b60acc48e442cad63ad37ca5 [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001#pragma once
2
Sampa Misrab37be312019-07-03 02:26:41 -05003#include "config.h"
4
John Wang6080aae2020-02-14 09:34:25 +08005#include "bios_config.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05006#include "bios_table.hpp"
Deepak Kodihalli1521f6d2020-06-16 08:51:02 -05007#include "pldmd/handler.hpp"
Andrew Jefferya330b2f2023-05-04 14:55:37 +09308#include "pldmd/instance_id.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -05009#include "requester/handler.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -050010
George Liuc453e162022-12-21 17:16:23 +080011#include <libpldm/bios.h>
12#include <libpldm/bios_table.h>
Sampa Misra032bd502019-03-06 05:03:22 -060013#include <stdint.h>
14
Xiaochao Ma60227a02019-12-04 09:00:12 +080015#include <ctime>
John Wang02700402019-10-06 16:34:29 +080016#include <functional>
Sampa Misrab37be312019-07-03 02:26:41 -050017#include <map>
vkaverapa6575b82019-04-03 05:33:52 -050018#include <vector>
19
Sampa Misra032bd502019-03-06 05:03:22 -060020namespace pldm
21{
22
23namespace responder
24{
25
Deepak Kodihallibc669f12019-11-28 08:52:07 -060026namespace bios
27{
28
Deepak Kodihallibc669f12019-11-28 08:52:07 -060029class Handler : public CmdHandler
30{
31 public:
Tom Joseph7f839f92020-09-21 10:20:44 +053032 /** @brief Constructor
33 *
34 * @param[in] fd - socket descriptor to communicate to host
35 * @param[in] eid - MCTP EID of host firmware
Andrew Jefferya330b2f2023-05-04 14:55:37 +093036 * @param[in] instanceIdDb - pointer to an InstanceIdDb object
Sampa Misrac0c79482021-06-02 08:01:54 -050037 * @param[in] handler - PLDM request handler
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,
Sampa Misrac0c79482021-06-02 08:01:54 -050040 pldm::requester::Handler<pldm::requester::Request>* handler);
Deepak Kodihallibc669f12019-11-28 08:52:07 -060041
42 /** @brief Handler for GetDateTime
43 *
44 * @param[in] request - Request message payload
Xiaochao Ma60227a02019-12-04 09:00:12 +080045 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060046 */
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
Xiaochao Ma60227a02019-12-04 09:00:12 +080053 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060054 */
55 Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
John Wang8721ed62019-12-05 14:44:43 +080056
George Liu1b180d82020-07-23 14:01:58 +080057 /** @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
John Wang8721ed62019-12-05 14:44:43 +080065 /** @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);
Xiaochao Ma60227a02019-12-04 09:00:12 +080073
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);
John Wang42174882019-12-20 14:56:59 +080081
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);
John Wang6080aae2020-02-14 09:34:25 +080090
91 private:
92 BIOSConfig biosConfig;
Deepak Kodihallibc669f12019-11-28 08:52:07 -060093};
Sampa Misrab37be312019-07-03 02:26:41 -050094
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050095} // namespace bios
96
Sampa Misra032bd502019-03-06 05:03:22 -060097namespace 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 */
110void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes,
111 uint8_t& hours, uint8_t& day, uint8_t& month,
112 uint16_t& year);
Xiaochao Ma60227a02019-12-04 09:00:12 +0800113
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 */
124std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours,
125 uint8_t day, uint8_t month, uint16_t year);
Sampa Misra032bd502019-03-06 05:03:22 -0600126} // namespace utils
127
128} // namespace responder
129} // namespace pldm