Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 3 | #include "config.h" |
| 4 | |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 5 | #include "libpldm/bios.h" |
| 6 | #include "libpldm/bios_table.h" |
| 7 | |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 8 | #include "bios_config.hpp" |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 9 | #include "bios_table.hpp" |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 10 | #include "pldmd/dbus_impl_requester.hpp" |
Deepak Kodihalli | 1521f6d | 2020-06-16 08:51:02 -0500 | [diff] [blame] | 11 | #include "pldmd/handler.hpp" |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 12 | #include "requester/handler.hpp" |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 13 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 14 | #include <stdint.h> |
| 15 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 16 | #include <ctime> |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 17 | #include <functional> |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 18 | #include <map> |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 19 | #include <vector> |
| 20 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 21 | namespace pldm |
| 22 | { |
| 23 | |
| 24 | namespace responder |
| 25 | { |
| 26 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 27 | namespace bios |
| 28 | { |
| 29 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 30 | class Handler : public CmdHandler |
| 31 | { |
| 32 | public: |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 33 | /** @brief Constructor |
| 34 | * |
| 35 | * @param[in] fd - socket descriptor to communicate to host |
| 36 | * @param[in] eid - MCTP EID of host firmware |
| 37 | * @param[in] requester - pointer to Requester object |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 38 | * @param[in] handler - PLDM request handler |
Tom Joseph | 7f839f9 | 2020-09-21 10:20:44 +0530 | [diff] [blame] | 39 | */ |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 40 | Handler(int fd, uint8_t eid, dbus_api::Requester* requester, |
| 41 | pldm::requester::Handler<pldm::requester::Request>* handler); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 42 | |
| 43 | /** @brief Handler for GetDateTime |
| 44 | * |
| 45 | * @param[in] request - Request message payload |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 46 | * @return Response - PLDM Response message |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 47 | */ |
| 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 Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 54 | * @return Response - PLDM Response message |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 55 | */ |
| 56 | Response getBIOSTable(const pldm_msg* request, size_t payloadLength); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 57 | |
George Liu | 1b180d8 | 2020-07-23 14:01:58 +0800 | [diff] [blame] | 58 | /** @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 Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 66 | /** @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 Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 74 | |
| 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 Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 82 | |
| 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 Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 91 | |
| 92 | private: |
| 93 | BIOSConfig biosConfig; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 94 | }; |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 95 | |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 96 | } // namespace bios |
| 97 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 98 | namespace 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 | */ |
| 111 | void 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 Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 114 | |
| 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 | */ |
| 125 | std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours, |
| 126 | uint8_t day, uint8_t month, uint16_t year); |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 127 | } // namespace utils |
| 128 | |
| 129 | } // namespace responder |
| 130 | } // namespace pldm |