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