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" |
Deepak Kodihalli | 1521f6d | 2020-06-16 08:51:02 -0500 | [diff] [blame] | 10 | #include "pldmd/handler.hpp" |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 11 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 12 | #include <stdint.h> |
| 13 | |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 14 | #include <ctime> |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 15 | #include <functional> |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 16 | #include <map> |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 19 | namespace pldm |
| 20 | { |
| 21 | |
| 22 | namespace responder |
| 23 | { |
| 24 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 25 | namespace bios |
| 26 | { |
| 27 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 28 | class Handler : public CmdHandler |
| 29 | { |
| 30 | public: |
Deepak Kodihalli | d9fb152 | 2019-11-28 10:06:34 -0600 | [diff] [blame] | 31 | Handler(); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 32 | |
| 33 | /** @brief Handler for GetDateTime |
| 34 | * |
| 35 | * @param[in] request - Request message payload |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 36 | * @return Response - PLDM Response message |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 37 | */ |
| 38 | Response getDateTime(const pldm_msg* request, size_t payloadLength); |
| 39 | |
| 40 | /** @brief Handler for GetBIOSTable |
| 41 | * |
| 42 | * @param[in] request - Request message |
| 43 | * @param[in] payload_length - Request message payload length |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 44 | * @return Response - PLDM Response message |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 45 | */ |
| 46 | Response getBIOSTable(const pldm_msg* request, size_t payloadLength); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 47 | |
| 48 | /** @brief Handler for GetBIOSAttributeCurrentValueByHandle |
| 49 | * |
| 50 | * @param[in] request - Request message |
| 51 | * @param[in] payloadLength - Request message payload length |
| 52 | * @return Response - PLDM Response message |
| 53 | */ |
| 54 | Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request, |
| 55 | size_t payloadLength); |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 56 | |
| 57 | /** @brief Handler for SetDateTime |
| 58 | * |
| 59 | * @param[in] request - Request message payload |
| 60 | * @param[in] payloadLength - Request message payload length |
| 61 | * @return Response - PLDM Response message |
| 62 | */ |
| 63 | Response setDateTime(const pldm_msg* request, size_t payloadLength); |
John Wang | 4217488 | 2019-12-20 14:56:59 +0800 | [diff] [blame] | 64 | |
| 65 | /** @brief Handler for setBIOSAttributeCurrentValue |
| 66 | * |
| 67 | * @param[in] request - Request message |
| 68 | * @param[in] payloadLength - Request message payload length |
| 69 | * @return Response - PLDM Response message |
| 70 | */ |
| 71 | Response setBIOSAttributeCurrentValue(const pldm_msg* request, |
| 72 | size_t payloadLength); |
John Wang | 6080aae | 2020-02-14 09:34:25 +0800 | [diff] [blame] | 73 | |
| 74 | private: |
| 75 | BIOSConfig biosConfig; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 76 | }; |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 77 | |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 78 | } // namespace bios |
| 79 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 80 | namespace utils |
| 81 | { |
| 82 | |
| 83 | /** @brief Convert epoch time to BCD time |
| 84 | * |
| 85 | * @param[in] timeSec - Time got from epoch time in seconds |
| 86 | * @param[out] seconds - number of seconds in BCD |
| 87 | * @param[out] minutes - number of minutes in BCD |
| 88 | * @param[out] hours - number of hours in BCD |
| 89 | * @param[out] day - day of the month in BCD |
| 90 | * @param[out] month - month number in BCD |
| 91 | * @param[out] year - year number in BCD |
| 92 | */ |
| 93 | void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, |
| 94 | uint8_t& hours, uint8_t& day, uint8_t& month, |
| 95 | uint16_t& year); |
Xiaochao Ma | 60227a0 | 2019-12-04 09:00:12 +0800 | [diff] [blame] | 96 | |
| 97 | /** @brief Convert dec time to epoch time |
| 98 | * |
| 99 | * @param[in] seconds - number of seconds in dec |
| 100 | * @param[in] minutes - number of minutes in dec |
| 101 | * @param[in] hours - number of hours in dec |
| 102 | * @param[in] day - day of the month in dec |
| 103 | * @param[in] month - month number in dec |
| 104 | * @param[in] year - year number in dec |
| 105 | * @return time - epoch time |
| 106 | */ |
| 107 | std::time_t timeToEpoch(uint8_t seconds, uint8_t minutes, uint8_t hours, |
| 108 | uint8_t day, uint8_t month, uint16_t year); |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 109 | } // namespace utils |
| 110 | |
| 111 | } // namespace responder |
| 112 | } // namespace pldm |