]> git.ozlabs.org Git - petitboot/blob - lib/pb-protocol/pb-protocol.h
Initial support for multiple UIs
[petitboot] / lib / pb-protocol / pb-protocol.h
1 #ifndef _PB_PROTOCOL_H
2 #define _PB_PROTOCOL_H
3
4 #include <stdint.h>
5
6 #define PB_SOCKET_PATH "/tmp/petitboot.ui"
7
8 #define PB_PROTOCOL_MAX_PAYLOAD_SIZE 4096
9
10 enum pb_protocol_action {
11         PB_PROTOCOL_ACTION_ADD          = 0x1,
12         PB_PROTOCOL_ACTION_REMOVE       = 0x2,
13 };
14
15 struct pb_protocol_message {
16         uint32_t action;
17         uint32_t payload_len;
18         char     payload[];
19 };
20
21 struct device {
22         char *id;
23         char *name;
24         char *description;
25         char *icon_file;
26
27         struct boot_option {
28                 char *id;
29                 char *name;
30                 char *description;
31                 char *icon_file;
32                 char *boot_image_file;
33                 char *initrd_file;
34                 char *boot_args;
35         } *options;
36         int n_options;
37 };
38
39 int pb_protocol_device_len(struct device *dev);
40
41 int pb_protocol_serialise_string(char *pos, const char *str);
42 char *pb_protocol_deserialise_string(void *ctx,
43                 struct pb_protocol_message *message);
44
45 int pb_protocol_serialise_device(struct device *dev, char *buf, int buf_len);
46
47 int pb_protocol_write_message(int fd, struct pb_protocol_message *message);
48
49 struct pb_protocol_message *pb_protocol_create_message(void *ctx,
50                 int action, int payload_len);
51
52 struct pb_protocol_message *pb_protocol_read_message(void *ctx, int fd);
53
54 struct device *pb_protocol_deserialise_device(void *ctx,
55                 struct pb_protocol_message *message);
56
57 #endif /* _PB_PROTOCOL_H */