blob: eab143e271d5a65172d6ce1b531b8b34a5b7be30 [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
Pavithra Barithayab3b84b42024-08-23 11:43:57 +053013#include <cstdint>
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
Archana Kakani62dd8ff2024-02-12 10:00:40 -060038 * @param[in] requestPLDMServiceName - Callback for registering the PLDM
39 * service
Tom Joseph7f839f92020-09-21 10:20:44 +053040 */
Andrew Jefferya330b2f2023-05-04 14:55:37 +093041 Handler(int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
Sagar Srinivas11ce8d22022-07-28 11:32:34 -050042 pldm::requester::Handler<pldm::requester::Request>* handler,
Archana Kakani62dd8ff2024-02-12 10:00:40 -060043 pldm::responder::platform_config::Handler* platformConfigHandler,
44 pldm::responder::bios::Callback requestPLDMServiceName);
Deepak Kodihallibc669f12019-11-28 08:52:07 -060045
46 /** @brief Handler for GetDateTime
47 *
48 * @param[in] request - Request message payload
Xiaochao Ma60227a02019-12-04 09:00:12 +080049 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060050 */
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
Xiaochao Ma60227a02019-12-04 09:00:12 +080057 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060058 */
59 Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
John Wang8721ed62019-12-05 14:44:43 +080060
George Liu1b180d82020-07-23 14:01:58 +080061 /** @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
John Wang8721ed62019-12-05 14:44:43 +080069 /** @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);
Xiaochao Ma60227a02019-12-04 09:00:12 +080077
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);
John Wang42174882019-12-20 14:56:59 +080085
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);
John Wang6080aae2020-02-14 09:34:25 +080094
95 private:
96 BIOSConfig biosConfig;
Deepak Kodihallibc669f12019-11-28 08:52:07 -060097};
Sampa Misrab37be312019-07-03 02:26:41 -050098
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050099} // namespace bios
100
Sampa Misra032bd502019-03-06 05:03:22 -0600101namespace 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 */
114void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes,
115 uint8_t& hours, uint8_t& day, uint8_t& month,
116 uint16_t& year);
Xiaochao Ma60227a02019-12-04 09:00:12 +0800117
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 */
128std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours,
129 uint8_t day, uint8_t month, uint16_t year);
Sampa Misra032bd502019-03-06 05:03:22 -0600130} // namespace utils
131
132} // namespace responder
133} // namespace pldm