8 #include <types/types.h>
10 #define PB_SOCKET_PATH "/tmp/petitboot.ui"
12 #define PB_PROTOCOL_MAX_PAYLOAD_SIZE (64 * 1024)
14 enum pb_protocol_action {
15 PB_PROTOCOL_ACTION_DEVICE_ADD = 0x1,
16 PB_PROTOCOL_ACTION_BOOT_OPTION_ADD = 0x2,
17 PB_PROTOCOL_ACTION_DEVICE_REMOVE = 0x3,
18 /* PB_PROTOCOL_ACTION_BOOT_OPTION_REMOVE = 0x4, */
19 PB_PROTOCOL_ACTION_BOOT = 0x5,
20 PB_PROTOCOL_ACTION_STATUS = 0x6,
21 PB_PROTOCOL_ACTION_CANCEL_DEFAULT = 0x7,
22 PB_PROTOCOL_ACTION_SYSTEM_INFO = 0x8,
25 struct pb_protocol_message {
31 void pb_protocol_dump_device(const struct device *dev, const char *text,
33 int pb_protocol_device_len(const struct device *dev);
34 int pb_protocol_boot_option_len(const struct boot_option *opt);
35 int pb_protocol_boot_len(const struct boot_command *boot);
36 int pb_protocol_boot_status_len(const struct boot_status *status);
37 int pb_protocol_system_info_len(const struct system_info *sysinfo);
38 int pb_protocol_device_cmp(const struct device *a, const struct device *b);
40 int pb_protocol_boot_option_cmp(const struct boot_option *a,
41 const struct boot_option *b);
43 int pb_protocol_serialise_string(char *pos, const char *str);
44 char *pb_protocol_deserialise_string(void *ctx,
45 const struct pb_protocol_message *message);
47 int pb_protocol_serialise_device(const struct device *dev,
48 char *buf, int buf_len);
49 int pb_protocol_serialise_boot_option(const struct boot_option *opt,
50 char *buf, int buf_len);
51 int pb_protocol_serialise_boot_command(const struct boot_command *boot,
52 char *buf, int buf_len);
53 int pb_protocol_serialise_boot_status(const struct boot_status *status,
54 char *buf, int buf_len);
55 int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
56 char *buf, int buf_len);
58 int pb_protocol_write_message(int fd, struct pb_protocol_message *message);
60 struct pb_protocol_message *pb_protocol_create_message(void *ctx,
61 enum pb_protocol_action action, int payload_len);
63 struct pb_protocol_message *pb_protocol_read_message(void *ctx, int fd);
65 int pb_protocol_deserialise_device(struct device *dev,
66 const struct pb_protocol_message *message);
68 int pb_protocol_deserialise_boot_option(struct boot_option *opt,
69 const struct pb_protocol_message *message);
71 int pb_protocol_deserialise_boot_command(struct boot_command *cmd,
72 const struct pb_protocol_message *message);
74 int pb_protocol_deserialise_boot_status(struct boot_status *status,
75 const struct pb_protocol_message *message);
77 int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
78 const struct pb_protocol_message *message);
80 #endif /* _PB_PROTOCOL_H */