]> git.ozlabs.org Git - petitboot/blob - ui/common/discover-client.h
config: Implement config messages
[petitboot] / ui / common / discover-client.h
1 #ifndef _DISCOVER_CLIENT_H
2 #define _DISCOVER_CLIENT_H
3
4 #include <types/types.h>
5 #include <waiter/waiter.h>
6
7 struct discover_client;
8
9 struct pb_boot_data {
10         char *image;
11         char *initrd;
12         char *dtb;
13         char *args;
14 };
15
16 /**
17  * struct discover_client_ops - Application supplied client info.
18  * @device_add: PB_PROTOCOL_ACTION_ADD event callback.
19  * @device_remove: PB_PROTOCOL_ACTION_REMOVE event callback.
20  * @cb_arg: Client managed convenience variable passed to callbacks.
21  */
22
23 struct discover_client_ops {
24         int (*device_add)(struct device *device, void *arg);
25         int (*boot_option_add)(struct device *dev, struct boot_option *option,
26                         void *arg);
27         void (*device_remove)(struct device *device, void *arg);
28         void (*update_status)(struct boot_status *status, void *arg);
29         void (*update_sysinfo)(struct system_info *sysinfo, void *arg);
30         void (*update_config)(struct config *sysinfo, void *arg);
31         void *cb_arg;
32 };
33
34 struct discover_client *discover_client_init(struct waitset *waitset,
35         const struct discover_client_ops *ops, void *cb_arg);
36
37 void discover_client_destroy(struct discover_client *client);
38
39 /**
40  * Get the number of devices that the discover client has stored. This
41  * is the set of devices that have been added and not removed
42  *
43  * @param client The discover client
44  * @return       The number of devices that have been added.
45  */
46 int discover_client_device_count(struct discover_client *client);
47
48 /**
49  * Get the device at a specific index.
50  * @param client A pointer to the discover client
51  * @param index  The index of the device to retrieve
52  * @return       The device at the specified index, or NULL if none exists
53  */
54 struct device *discover_client_get_device(struct discover_client *client,
55                 int index);
56
57 /* Tell the discover server to boot an image
58  * @param client A pointer to the discover client
59  * @param boot_command The command to boot
60  */
61 int discover_client_boot(struct discover_client *client,
62                 const struct device *device,
63                 const struct boot_option *boot_option,
64                 const struct pb_boot_data *data);
65
66 /* Tell the discover server to cancel the default boot option, if any
67  */
68 int discover_client_cancel_default(struct discover_client *client);
69 #endif