1 #ifndef _DEVICE_HANDLER_H
2 #define _DEVICE_HANDLER_H
7 #include <types/types.h>
10 struct discover_device;
11 struct discover_server;
19 struct discover_device {
20 struct device *device;
30 const char *device_path;
31 struct ramdisk_device *ramdisk;
38 struct list boot_options;
42 struct discover_boot_option {
43 struct parser *source;
44 struct discover_device *device;
45 struct boot_option *option;
46 struct list_item list;
48 struct resource *boot_image;
49 struct resource *initrd;
51 struct resource *icon;
55 struct discover_context {
56 struct parser *parser;
58 struct discover_device *device;
59 struct list boot_options;
60 struct pb_url *conf_url;
61 struct network *network;
65 struct ramdisk_device {
73 struct device_handler *device_handler_init(struct discover_server *server,
74 struct waitset *waitset, int dry_run);
76 void device_handler_destroy(struct device_handler *devices);
78 int device_handler_get_device_count(const struct device_handler *handler);
79 const struct discover_device *device_handler_get_device(
80 const struct device_handler *handler, unsigned int index);
82 struct discover_device *discover_device_create(struct device_handler *handler,
84 void device_handler_add_device(struct device_handler *handler,
85 struct discover_device *device);
86 void device_handler_add_ramdisk(struct device_handler *handler,
88 struct ramdisk_device *device_handler_get_ramdisk(
89 struct device_handler *handler);
90 void device_handler_release_ramdisk(struct discover_device *device);
91 int device_handler_discover(struct device_handler *handler,
92 struct discover_device *dev);
93 int device_handler_dhcp(struct device_handler *handler,
94 struct discover_device *dev, struct event *event);
95 int device_handler_conf(struct device_handler *handler,
96 struct discover_device *dev, struct pb_url *url);
97 void device_handler_remove(struct device_handler *handler,
98 struct discover_device *device);
100 void device_handler_boot_status(void *arg, struct boot_status *status);
102 struct discover_context *device_handler_discover_context_create(
103 struct device_handler *handler,
104 struct discover_device *device);
105 void device_handler_discover_context_commit(struct device_handler *handler,
106 struct discover_context *ctx);
108 struct discover_boot_option *discover_boot_option_create(
109 struct discover_context *ctx,
110 struct discover_device *dev);
111 void discover_context_add_boot_option(struct discover_context *ctx,
112 struct discover_boot_option *opt);
114 int device_handler_user_event(struct device_handler *handler,
115 struct event *event);
117 struct discover_device *device_lookup_by_name(struct device_handler *handler,
119 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
121 struct discover_device *device_lookup_by_label(struct device_handler *handler,
123 struct discover_device *device_lookup_by_id(struct device_handler *handler,
125 struct discover_device *device_lookup_by_serial(
126 struct device_handler *device_handler,
129 void discover_device_set_param(struct discover_device *device,
130 const char *name, const char *value);
131 const char *discover_device_get_param(struct discover_device *device,
134 void device_handler_boot(struct device_handler *handler,
135 struct boot_command *cmd);
136 void device_handler_cancel_default(struct device_handler *handler);
137 void device_handler_update_config(struct device_handler *handler,
138 struct config *config);
139 void device_handler_process_url(struct device_handler *handler,
140 const char *url, const char *mac, const char *ip);
141 void device_handler_reinit(struct device_handler *handler);
143 int device_request_write(struct discover_device *dev, bool *release);
144 void device_release_write(struct discover_device *dev, bool release);
146 #endif /* _DEVICE_HANDLER_H */