]> git.ozlabs.org Git - petitboot/blob - discover/device-handler.h
56d585a8ba117f4e474c4ba1e134dab6c176ef45
[petitboot] / discover / device-handler.h
1 #ifndef _DEVICE_HANDLER_H
2 #define _DEVICE_HANDLER_H
3
4 #include <stdbool.h>
5
6 #include <list/list.h>
7
8 struct device_handler;
9 struct discover_device;
10 struct discover_server;
11 struct boot_option;
12 struct boot_command;
13 struct event;
14 struct device;
15 struct waitset;
16
17 struct discover_device {
18         struct device           *device;
19
20         char                    **links;
21         int                     n_links;
22
23         const char              *uuid;
24         const char              *label;
25
26         char                    *mount_path;
27         const char              *device_path;
28         bool                    mounted;
29         bool                    mounted_rw;
30         bool                    unmount;
31
32         bool                    notified;
33
34         struct list             boot_options;
35         struct list             params;
36 };
37
38 struct discover_boot_option {
39         struct parser           *source;
40         struct discover_device  *device;
41         struct boot_option      *option;
42         struct list_item        list;
43
44         struct resource         *boot_image;
45         struct resource         *initrd;
46         struct resource         *dtb;
47         struct resource         *icon;
48 };
49
50
51 struct discover_context {
52         struct parser           *parser;
53         struct event            *event;
54         struct discover_device  *device;
55         struct list             boot_options;
56         struct pb_url           *conf_url;
57         void                    *test_data;
58 };
59
60 struct device_handler *device_handler_init(struct discover_server *server,
61                 struct waitset *waitset, int dry_run);
62
63 void device_handler_destroy(struct device_handler *devices);
64
65 int device_handler_get_device_count(const struct device_handler *handler);
66 const struct discover_device *device_handler_get_device(
67         const struct device_handler *handler, unsigned int index);
68
69 struct discover_device *discover_device_create(struct device_handler *handler,
70                 const char *id);
71 void device_handler_add_device(struct device_handler *handler,
72                 struct discover_device *device);
73 int device_handler_discover(struct device_handler *handler,
74                 struct discover_device *dev);
75 int device_handler_dhcp(struct device_handler *handler,
76                 struct discover_device *dev, struct event *event);
77 int device_handler_conf(struct device_handler *handler,
78                 struct discover_device *dev, struct pb_url *url);
79 void device_handler_remove(struct device_handler *handler,
80                 struct discover_device *device);
81
82 struct discover_context *device_handler_discover_context_create(
83                 struct device_handler *handler,
84                 struct discover_device *device);
85 void device_handler_discover_context_commit(struct device_handler *handler,
86                 struct discover_context *ctx);
87
88 struct discover_boot_option *discover_boot_option_create(
89                 struct discover_context *ctx,
90                 struct discover_device *dev);
91 void discover_context_add_boot_option(struct discover_context *ctx,
92                 struct discover_boot_option *opt);
93
94 int device_handler_user_event(struct device_handler *handler,
95                                 struct event *event);
96
97 struct discover_device *device_lookup_by_name(struct device_handler *handler,
98                 const char *name);
99 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
100                 const char *uuid);
101 struct discover_device *device_lookup_by_label(struct device_handler *handler,
102                 const char *label);
103 struct discover_device *device_lookup_by_id(struct device_handler *handler,
104                 const char *id);
105 struct discover_device *device_lookup_by_serial(
106                 struct device_handler *device_handler,
107                 const char *serial);
108
109 void discover_device_set_param(struct discover_device *device,
110                 const char *name, const char *value);
111 const char *discover_device_get_param(struct discover_device *device,
112                 const char *name);
113
114 void device_handler_boot(struct device_handler *handler,
115                 struct boot_command *cmd);
116 void device_handler_cancel_default(struct device_handler *handler);
117
118 int device_request_write(struct discover_device *dev, bool *release);
119 void device_release_write(struct discover_device *dev, bool release);
120
121 #endif /* _DEVICE_HANDLER_H */