blob: 23f1318d7bff47078b9462442b5ed516be5a470d [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"
Deepak Kodihalli1521f6d2020-06-16 08:51:02 -05006#include "pldmd/handler.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -05007#include "requester/handler.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05008
George Liuc453e162022-12-21 17:16:23 +08009#include <libpldm/bios.h>
10#include <libpldm/bios_table.h>
Sampa Misra032bd502019-03-06 05:03:22 -060011#include <stdint.h>
12
Xiaochao Ma60227a02019-12-04 09:00:12 +080013#include <ctime>
John Wang02700402019-10-06 16:34:29 +080014#include <functional>
Sampa Misrab37be312019-07-03 02:26:41 -050015#include <map>
vkaverapa6575b82019-04-03 05:33:52 -050016#include <vector>
17
Sampa Misra032bd502019-03-06 05:03:22 -060018namespace pldm
19{
20
21namespace responder
22{
23
Deepak Kodihallibc669f12019-11-28 08:52:07 -060024namespace bios
25{
26
Deepak Kodihallibc669f12019-11-28 08:52:07 -060027class Handler : public CmdHandler
28{
29 public:
Tom Joseph7f839f92020-09-21 10:20:44 +053030 /** @brief Constructor
31 *
32 * @param[in] fd - socket descriptor to communicate to host
33 * @param[in] eid - MCTP EID of host firmware
Andrew Jefferya330b2f2023-05-04 14:55:37 +093034 * @param[in] instanceIdDb - pointer to an InstanceIdDb object
Sampa Misrac0c79482021-06-02 08:01:54 -050035 * @param[in] handler - PLDM request handler
Sagar Srinivas11ce8d22022-07-28 11:32:34 -050036 * @param[in] systemConfig - pointer to SystemConfig object
Tom Joseph7f839f92020-09-21 10:20:44 +053037 */
Andrew Jefferya330b2f2023-05-04 14:55:37 +093038 Handler(int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
Sagar Srinivas11ce8d22022-07-28 11:32:34 -050039 pldm::requester::Handler<pldm::requester::Request>* handler,
40 pldm::responder::oem_bios::Handler* oemBiosHandler);
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