blob: 7030f5d58559aea7763be8524b94d437579bfbea [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001#ifndef BIOS_H
2#define BIOS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <asm/byteorder.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "base.h"
13
14/* Response lengths are inclusive of completion code */
15#define PLDM_GET_DATE_TIME_RESP_BYTES 8
16
17enum pldm_bios_commands { PLDM_GET_DATE_TIME = 0x0c };
18
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053019enum pldm_bios_table_types {
20 PLDM_BIOS_STRING_TABLE,
21 PLDM_BIOS_ATTR_TABLE,
22 PLDM_BIOS_ATTR_VAL_TABLE,
23};
24
25struct pldm_bios_string_table_entry {
26 uint16_t string_handle;
27 uint16_t string_length;
28 char name[1];
29} __attribute__((packed));
30
31struct pldm_bios_attr_table_entry {
32 uint16_t attr_handle;
33 uint8_t attr_type;
34 uint16_t string_handle;
35 uint8_t metadata[1];
36} __attribute__((packed));
37
38struct pldm_bios_enum_attr {
39 uint8_t num_possible_values;
40 uint16_t indices[1];
41} __attribute__((packed));
42
43struct pldm_bios_attr_val_table_entry {
44 uint16_t attr_handle;
45 uint8_t attr_type;
46 uint8_t value[1];
47} __attribute__((packed));
48
Priyanga5dcd1802019-06-10 01:50:39 -050049/** @struct pldm_get_date_time_resp
50 *
51 * Structure representing PLDM get date time response
52 */
53struct pldm_get_date_time_resp {
54 uint8_t completion_code; //!< completion code
55 uint8_t seconds; //!< Seconds in BCD format
56 uint8_t minutes; //!< Minutes in BCD format
57 uint8_t hours; //!< Hours in BCD format
58 uint8_t day; //!< Day of the month in BCD format
59 uint8_t month; //!< Month in BCD format
60 uint16_t year; //!< Year in BCD format
61} __attribute__((packed));
62
Sampa Misra032bd502019-03-06 05:03:22 -060063/* Requester */
64
65/* GetDateTime */
66
67/** @brief Create a PLDM request message for GetDateTime
68 *
69 * @param[in] instance_id - Message's instance id
70 * @param[out] msg - Message will be written to this
71 * @return pldm_completion_codes
72 * @note Caller is responsible for memory alloc and dealloc of param
73 * 'msg.body.payload'
74 */
75
76int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
77
78/** @brief Decode a GetDateTime response message
79 *
Zahed Hossain223a73d2019-07-04 12:46:18 -050080 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -050081 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -060082 * @param[out] completion_code - Pointer to response msg's PLDM completion code
83 * @param[out] seconds - Seconds in BCD format
84 * @param[out] minutes - minutes in BCD format
85 * @param[out] hours - hours in BCD format
86 * @param[out] day - day of month in BCD format
87 * @param[out] month - number of month in BCD format
88 * @param[out] year - year in BCD format
89 * @return pldm_completion_codes
90 */
Zahed Hossain223a73d2019-07-04 12:46:18 -050091int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -060092 uint8_t *completion_code, uint8_t *seconds,
93 uint8_t *minutes, uint8_t *hours, uint8_t *day,
94 uint8_t *month, uint16_t *year);
95
96/* Responder */
97
98/* GetDateTime */
99
100/** @brief Create a PLDM response message for GetDateTime
101 *
102 * @param[in] instance_id - Message's instance id
103 * @param[in] completion_code - PLDM completion code
104 * @param[in] seconds - seconds in BCD format
105 * @param[in] minutes - minutes in BCD format
106 * @param[in] hours - hours in BCD format
107 * @param[in] day - day of the month in BCD format
108 * @param[in] month - number of month in BCD format
109 * @param[in] year - year in BCD format
110 * @param[out] msg - Message will be written to this
111 * @return pldm_completion_codes
112 * @note Caller is responsible for memory alloc and dealloc of param
113 * 'msg.body.payload'
114 */
115
116int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
117 uint8_t seconds, uint8_t minutes, uint8_t hours,
118 uint8_t day, uint8_t month, uint16_t year,
119 struct pldm_msg *msg);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* BIOS_H */