blob: 412e07abb2104b1fbbe8ddd01cbcbe8bcafd4831 [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"
7
Sampa Misra032bd502019-03-06 05:03:22 -06008#include <stdint.h>
9
John Wang02700402019-10-06 16:34:29 +080010#include <functional>
Sampa Misrab37be312019-07-03 02:26:41 -050011#include <map>
vkaverapa6575b82019-04-03 05:33:52 -050012#include <vector>
13
Sampa Misra032bd502019-03-06 05:03:22 -060014#include "libpldm/bios.h"
John Wang02700402019-10-06 16:34:29 +080015#include "libpldm/bios_table.h"
Sampa Misra032bd502019-03-06 05:03:22 -060016
17namespace pldm
18{
19
vkaverapa6575b82019-04-03 05:33:52 -050020using Response = std::vector<uint8_t>;
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
John Wang02700402019-10-06 16:34:29 +080028using AttrTableEntryHandler =
29 std::function<void(const struct pldm_bios_attr_table_entry*)>;
30
31void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable,
32 AttrTableEntryHandler handler);
33
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050034namespace bios
35{
36/** @brief Register handlers for command from the platform spec
37 */
38void registerHandlers();
Sampa Misrab37be312019-07-03 02:26:41 -050039
40namespace internal
41{
42
43/** @brief Constructs all the BIOS Tables
44 *
45 * @param[in] request - Request message
46 * @param[in] payload_length - Request message payload length
47 * @param[in] biosJsonDir - path to fetch the BIOS json files
48 * @param[in] biosTablePath - path where the BIOS tables will be persisted
49 */
50Response buildBIOSTables(const pldm_msg* request, size_t payloadLength,
51 const char* biosJsonDir, const char* biosTablePath);
52} // end namespace internal
53
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050054} // namespace bios
55
Sampa Misra032bd502019-03-06 05:03:22 -060056/** @brief Handler for GetDateTime
57 *
58 * @param[in] request - Request message payload
vkaverapa6575b82019-04-03 05:33:52 -050059 * @param[return] Response - PLDM Response message
Sampa Misra032bd502019-03-06 05:03:22 -060060 */
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050061Response getDateTime(const pldm_msg* request, size_t payloadLength);
Sampa Misra032bd502019-03-06 05:03:22 -060062
Sampa Misrab37be312019-07-03 02:26:41 -050063/** @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 */
69Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
70
Sampa Misra032bd502019-03-06 05:03:22 -060071namespace utils
72{
73
74/** @brief Convert epoch time to BCD time
75 *
76 * @param[in] timeSec - Time got from epoch time in seconds
77 * @param[out] seconds - number of seconds in BCD
78 * @param[out] minutes - number of minutes in BCD
79 * @param[out] hours - number of hours in BCD
80 * @param[out] day - day of the month in BCD
81 * @param[out] month - month number in BCD
82 * @param[out] year - year number in BCD
83 */
84void epochToBCDTime(uint64_t timeSec, uint8_t& seconds, uint8_t& minutes,
85 uint8_t& hours, uint8_t& day, uint8_t& month,
86 uint16_t& year);
87} // namespace utils
88
89} // namespace responder
90} // namespace pldm