xref: /openbmc/pldm/libpldmresponder/bios.hpp (revision 0270040b)
1 #pragma once
2 
3 #include "config.h"
4 
5 #include "bios_parser.hpp"
6 #include "bios_table.hpp"
7 
8 #include <stdint.h>
9 
10 #include <functional>
11 #include <map>
12 #include <vector>
13 
14 #include "libpldm/bios.h"
15 #include "libpldm/bios_table.h"
16 
17 namespace pldm
18 {
19 
20 using Response = std::vector<uint8_t>;
21 using AttributeHandle = uint16_t;
22 using StringHandle = uint16_t;
23 using PossibleValuesByHandle = std::vector<StringHandle>;
24 
25 namespace responder
26 {
27 
28 using AttrTableEntryHandler =
29     std::function<void(const struct pldm_bios_attr_table_entry*)>;
30 
31 void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable,
32                            AttrTableEntryHandler handler);
33 
34 namespace bios
35 {
36 /** @brief Register handlers for command from the platform spec
37  */
38 void registerHandlers();
39 
40 namespace 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  */
50 Response buildBIOSTables(const pldm_msg* request, size_t payloadLength,
51                          const char* biosJsonDir, const char* biosTablePath);
52 } // end namespace internal
53 
54 } // namespace bios
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);
70 
71 namespace 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  */
84 void 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
91