blob: cd3565120dcb99cd5ad964a884fe19537e3694ed [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
Priyanga5dcd1802019-06-10 01:50:39 -050019/** @struct pldm_get_date_time_resp
20 *
21 * Structure representing PLDM get date time response
22 */
23struct pldm_get_date_time_resp {
24 uint8_t completion_code; //!< completion code
25 uint8_t seconds; //!< Seconds in BCD format
26 uint8_t minutes; //!< Minutes in BCD format
27 uint8_t hours; //!< Hours in BCD format
28 uint8_t day; //!< Day of the month in BCD format
29 uint8_t month; //!< Month in BCD format
30 uint16_t year; //!< Year in BCD format
31} __attribute__((packed));
32
Sampa Misra032bd502019-03-06 05:03:22 -060033/* Requester */
34
35/* GetDateTime */
36
37/** @brief Create a PLDM request message for GetDateTime
38 *
39 * @param[in] instance_id - Message's instance id
40 * @param[out] msg - Message will be written to this
41 * @return pldm_completion_codes
42 * @note Caller is responsible for memory alloc and dealloc of param
43 * 'msg.body.payload'
44 */
45
46int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
47
48/** @brief Decode a GetDateTime response message
49 *
50 * @param[in] msg - Response message payload
vkaverapa6575b82019-04-03 05:33:52 -050051 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -060052 * @param[out] completion_code - Pointer to response msg's PLDM completion code
53 * @param[out] seconds - Seconds in BCD format
54 * @param[out] minutes - minutes in BCD format
55 * @param[out] hours - hours in BCD format
56 * @param[out] day - day of month in BCD format
57 * @param[out] month - number of month in BCD format
58 * @param[out] year - year in BCD format
59 * @return pldm_completion_codes
60 */
vkaverapa6575b82019-04-03 05:33:52 -050061int decode_get_date_time_resp(const uint8_t *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -060062 uint8_t *completion_code, uint8_t *seconds,
63 uint8_t *minutes, uint8_t *hours, uint8_t *day,
64 uint8_t *month, uint16_t *year);
65
66/* Responder */
67
68/* GetDateTime */
69
70/** @brief Create a PLDM response message for GetDateTime
71 *
72 * @param[in] instance_id - Message's instance id
73 * @param[in] completion_code - PLDM completion code
74 * @param[in] seconds - seconds in BCD format
75 * @param[in] minutes - minutes in BCD format
76 * @param[in] hours - hours in BCD format
77 * @param[in] day - day of the month in BCD format
78 * @param[in] month - number of month in BCD format
79 * @param[in] year - year in BCD format
80 * @param[out] msg - Message will be written to this
81 * @return pldm_completion_codes
82 * @note Caller is responsible for memory alloc and dealloc of param
83 * 'msg.body.payload'
84 */
85
86int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
87 uint8_t seconds, uint8_t minutes, uint8_t hours,
88 uint8_t day, uint8_t month, uint16_t year,
89 struct pldm_msg *msg);
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* BIOS_H */