blob: 2fbf8abc7d68abf1aaa9af5218c4be67b3f3e5e0 [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
George Liu6492f522020-06-16 10:34:05 +08005#include "libpldm/bios.h"
6#include "libpldm/bios_table.h"
7
John Wang6080aae2020-02-14 09:34:25 +08008#include "bios_config.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05009#include "bios_table.hpp"
Tom Joseph7f839f92020-09-21 10:20:44 +053010#include "pldmd/dbus_impl_requester.hpp"
Deepak Kodihalli1521f6d2020-06-16 08:51:02 -050011#include "pldmd/handler.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -050012
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
36 * @param[in] requester - pointer to Requester object
37 */
38 Handler(int fd, uint8_t eid, dbus_api::Requester* requester);
Deepak Kodihallibc669f12019-11-28 08:52:07 -060039
40 /** @brief Handler for GetDateTime
41 *
42 * @param[in] request - Request message payload
Xiaochao Ma60227a02019-12-04 09:00:12 +080043 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060044 */
45 Response getDateTime(const pldm_msg* request, size_t payloadLength);
46
47 /** @brief Handler for GetBIOSTable
48 *
49 * @param[in] request - Request message
50 * @param[in] payload_length - Request message payload length
Xiaochao Ma60227a02019-12-04 09:00:12 +080051 * @return Response - PLDM Response message
Deepak Kodihallibc669f12019-11-28 08:52:07 -060052 */
53 Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
John Wang8721ed62019-12-05 14:44:43 +080054
George Liu1b180d82020-07-23 14:01:58 +080055 /** @brief Handler for SetBIOSTable
56 *
57 * @param[in] request - Request message
58 * @param[in] payload_length - Request message payload length
59 * @return Response - PLDM Response message
60 */
61 Response setBIOSTable(const pldm_msg* request, size_t payloadLength);
62
John Wang8721ed62019-12-05 14:44:43 +080063 /** @brief Handler for GetBIOSAttributeCurrentValueByHandle
64 *
65 * @param[in] request - Request message
66 * @param[in] payloadLength - Request message payload length
67 * @return Response - PLDM Response message
68 */
69 Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request,
70 size_t payloadLength);
Xiaochao Ma60227a02019-12-04 09:00:12 +080071
72 /** @brief Handler for SetDateTime
73 *
74 * @param[in] request - Request message payload
75 * @param[in] payloadLength - Request message payload length
76 * @return Response - PLDM Response message
77 */
78 Response setDateTime(const pldm_msg* request, size_t payloadLength);
John Wang42174882019-12-20 14:56:59 +080079
80 /** @brief Handler for setBIOSAttributeCurrentValue
81 *
82 * @param[in] request - Request message
83 * @param[in] payloadLength - Request message payload length
84 * @return Response - PLDM Response message
85 */
86 Response setBIOSAttributeCurrentValue(const pldm_msg* request,
87 size_t payloadLength);
John Wang6080aae2020-02-14 09:34:25 +080088
89 private:
90 BIOSConfig biosConfig;
Deepak Kodihallibc669f12019-11-28 08:52:07 -060091};
Sampa Misrab37be312019-07-03 02:26:41 -050092
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050093} // namespace bios
94
Sampa Misra032bd502019-03-06 05:03:22 -060095namespace utils
96{
97
98/** @brief Convert epoch time to BCD time
99 *
100 * @param[in] timeSec - Time got from epoch time in seconds
101 * @param[out] seconds - number of seconds in BCD
102 * @param[out] minutes - number of minutes in BCD
103 * @param[out] hours - number of hours in BCD
104 * @param[out] day - day of the month in BCD
105 * @param[out] month - month number in BCD
106 * @param[out] year - year number in BCD
107 */
108void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes,
109 uint8_t& hours, uint8_t& day, uint8_t& month,
110 uint16_t& year);
Xiaochao Ma60227a02019-12-04 09:00:12 +0800111
112/** @brief Convert dec time to epoch time
113 *
114 * @param[in] seconds - number of seconds in dec
115 * @param[in] minutes - number of minutes in dec
116 * @param[in] hours - number of hours in dec
117 * @param[in] day - day of the month in dec
118 * @param[in] month - month number in dec
119 * @param[in] year - year number in dec
120 * @return time - epoch time
121 */
122std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours,
123 uint8_t day, uint8_t month, uint16_t year);
Sampa Misra032bd502019-03-06 05:03:22 -0600124} // namespace utils
125
126} // namespace responder
127} // namespace pldm