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