]> git.ozlabs.org Git - petitboot/blob - ui/common/discover-client.h
protocol: Separate device add from boot-option add 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 *args;
13 };
14
15 /**
16  * struct discover_client_ops - Application supplied client info.
17  * @device_add: PB_PROTOCOL_ACTION_ADD event callback.
18  * @device_remove: PB_PROTOCOL_ACTION_REMOVE event callback.
19  * @cb_arg: Client managed convenience variable passed to callbacks.
20  */
21
22 struct discover_client_ops {
23         int (*device_add)(struct device *device, void *arg);
24         int (*boot_option_add)(struct device *dev, struct boot_option *option,
25                         void *arg);
26         void (*device_remove)(struct device *device, void *arg);
27         void *cb_arg;
28 };
29
30 struct discover_client *discover_client_init(struct waitset *waitset,
31         const struct discover_client_ops *ops, void *cb_arg);
32
33 void discover_client_destroy(struct discover_client *client);
34
35 /**
36  * Get the number of devices that the discover client has stored. This
37  * is the set of devices that have been added and not removed
38  *
39  * @param client The discover client
40  * @return       The number of devices that have been added.
41  */
42 int discover_client_device_count(struct discover_client *client);
43
44 /**
45  * Get the device at a specific index.
46  * @param client A pointer to the discover client
47  * @param index  The index of the device to retrieve
48  * @return       The device at the specified index, or NULL if none exists
49  */
50 struct device *discover_client_get_device(struct discover_client *client,
51                 int index);
52
53 /* Tell the discover server to boot an image
54  * @param client A pointer to the discover client
55  * @param boot_command The command to boot
56  */
57 int discover_client_boot(struct discover_client *client,
58                 const struct device *device,
59                 const struct boot_option *boot_option,
60                 const struct pb_boot_data *data);
61 #endif