blob: 41ac70cf14d6ab442f918b6912535bf2ba848229 [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
5#include "bios_parser.hpp"
6#include "bios_table.hpp"
Deepak Kodihallibc669f12019-11-28 08:52:07 -06007#include "handler.hpp"
Sampa Misrab37be312019-07-03 02:26:41 -05008
Sampa Misra032bd502019-03-06 05:03:22 -06009#include <stdint.h>
10
John Wang02700402019-10-06 16:34:29 +080011#include <functional>
Sampa Misrab37be312019-07-03 02:26:41 -050012#include <map>
vkaverapa6575b82019-04-03 05:33:52 -050013#include <vector>
14
Sampa Misra032bd502019-03-06 05:03:22 -060015#include "libpldm/bios.h"
John Wang02700402019-10-06 16:34:29 +080016#include "libpldm/bios_table.h"
Sampa Misra032bd502019-03-06 05:03:22 -060017
18namespace pldm
19{
20
Sampa Misrab37be312019-07-03 02:26:41 -050021using AttributeHandle = uint16_t;
22using StringHandle = uint16_t;
23using PossibleValuesByHandle = std::vector<StringHandle>;
vkaverapa6575b82019-04-03 05:33:52 -050024
Sampa Misra032bd502019-03-06 05:03:22 -060025namespace responder
26{
27
Deepak Kodihallibc669f12019-11-28 08:52:07 -060028namespace bios
29{
30
John Wang02700402019-10-06 16:34:29 +080031using AttrTableEntryHandler =
32 std::function<void(const struct pldm_bios_attr_table_entry*)>;
33
34void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable,
35 AttrTableEntryHandler handler);
36
Sampa Misrab37be312019-07-03 02:26:41 -050037namespace 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 */
47Response buildBIOSTables(const pldm_msg* request, size_t payloadLength,
48 const char* biosJsonDir, const char* biosTablePath);
Deepak Kodihallibc669f12019-11-28 08:52:07 -060049} // namespace internal
50
51class Handler : public CmdHandler
52{
53 public:
Deepak Kodihallid9fb1522019-11-28 10:06:34 -060054 Handler();
Deepak Kodihallibc669f12019-11-28 08:52:07 -060055
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 Wang8721ed62019-12-05 14:44:43 +080070
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 Kodihallibc669f12019-11-28 08:52:07 -060079};
Sampa Misrab37be312019-07-03 02:26:41 -050080
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050081} // namespace bios
82
Sampa Misra032bd502019-03-06 05:03:22 -060083namespace 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 */
96void 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