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 | |
| 5 | #include "bios_parser.hpp" |
| 6 | #include "bios_table.hpp" |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 7 | #include "handler.hpp" |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 8 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 11 | #include <functional> |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 12 | #include <map> |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 15 | #include "libpldm/bios.h" |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 16 | #include "libpldm/bios_table.h" |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 17 | |
| 18 | namespace pldm |
| 19 | { |
| 20 | |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 21 | using AttributeHandle = uint16_t; |
| 22 | using StringHandle = uint16_t; |
| 23 | using PossibleValuesByHandle = std::vector<StringHandle>; |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 24 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 25 | namespace responder |
| 26 | { |
| 27 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 28 | namespace bios |
| 29 | { |
| 30 | |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 31 | using AttrTableEntryHandler = |
| 32 | std::function<void(const struct pldm_bios_attr_table_entry*)>; |
| 33 | |
| 34 | void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable, |
| 35 | AttrTableEntryHandler handler); |
| 36 | |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 37 | namespace internal |
| 38 | { |
| 39 | |
| 40 | /** @brief Constructs all the BIOS Tables |
| 41 | * |
| 42 | * @param[in] request - Request message |
| 43 | * @param[in] payload_length - Request message payload length |
| 44 | * @param[in] biosJsonDir - path to fetch the BIOS json files |
| 45 | * @param[in] biosTablePath - path where the BIOS tables will be persisted |
| 46 | */ |
| 47 | Response buildBIOSTables(const pldm_msg* request, size_t payloadLength, |
| 48 | const char* biosJsonDir, const char* biosTablePath); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 49 | } // namespace internal |
| 50 | |
| 51 | class Handler : public CmdHandler |
| 52 | { |
| 53 | public: |
Deepak Kodihalli | d9fb152 | 2019-11-28 10:06:34 -0600 | [diff] [blame] | 54 | Handler(); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 55 | |
| 56 | /** @brief Handler for GetDateTime |
| 57 | * |
| 58 | * @param[in] request - Request message payload |
| 59 | * @param[return] Response - PLDM Response message |
| 60 | */ |
| 61 | Response getDateTime(const pldm_msg* request, size_t payloadLength); |
| 62 | |
| 63 | /** @brief Handler for GetBIOSTable |
| 64 | * |
| 65 | * @param[in] request - Request message |
| 66 | * @param[in] payload_length - Request message payload length |
| 67 | * @param[return] Response - PLDM Response message |
| 68 | */ |
| 69 | Response getBIOSTable(const pldm_msg* request, size_t payloadLength); |
John Wang | 8721ed6 | 2019-12-05 14:44:43 +0800 | [diff] [blame] | 70 | |
| 71 | /** @brief Handler for GetBIOSAttributeCurrentValueByHandle |
| 72 | * |
| 73 | * @param[in] request - Request message |
| 74 | * @param[in] payloadLength - Request message payload length |
| 75 | * @return Response - PLDM Response message |
| 76 | */ |
| 77 | Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request, |
| 78 | size_t payloadLength); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 79 | }; |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 80 | |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 81 | } // namespace bios |
| 82 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 83 | namespace utils |
| 84 | { |
| 85 | |
| 86 | /** @brief Convert epoch time to BCD time |
| 87 | * |
| 88 | * @param[in] timeSec - Time got from epoch time in seconds |
| 89 | * @param[out] seconds - number of seconds in BCD |
| 90 | * @param[out] minutes - number of minutes in BCD |
| 91 | * @param[out] hours - number of hours in BCD |
| 92 | * @param[out] day - day of the month in BCD |
| 93 | * @param[out] month - month number in BCD |
| 94 | * @param[out] year - year number in BCD |
| 95 | */ |
| 96 | void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes, |
| 97 | uint8_t& hours, uint8_t& day, uint8_t& month, |
| 98 | uint16_t& year); |
| 99 | } // namespace utils |
| 100 | |
| 101 | } // namespace responder |
| 102 | } // namespace pldm |