]> git.ozlabs.org Git - petitboot/blob - discover/device-handler.h
discover/platform-powerpc: Zero-pad BMC aux-version
[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 struct config;
17
18 struct discover_device {
19         struct device           *device;
20
21         char                    **links;
22         int                     n_links;
23
24         const char              *uuid;
25         const char              *label;
26
27         char                    *mount_path;
28         char                    *root_path;
29         const char              *device_path;
30         struct ramdisk_device   *ramdisk;
31         bool                    mounted;
32         bool                    mounted_rw;
33         bool                    unmount;
34
35         bool                    notified;
36
37         struct list             boot_options;
38         struct list             params;
39 };
40
41 struct discover_boot_option {
42         struct parser           *source;
43         struct discover_device  *device;
44         struct boot_option      *option;
45         struct list_item        list;
46
47         struct resource         *boot_image;
48         struct resource         *initrd;
49         struct resource         *dtb;
50         struct resource         *icon;
51 };
52
53
54 struct discover_context {
55         struct parser           *parser;
56         struct event            *event;
57         struct discover_device  *device;
58         struct list             boot_options;
59         struct pb_url           *conf_url;
60         struct network          *network;
61         void                    *test_data;
62 };
63
64 struct ramdisk_device {
65         const char      *path;
66         char            *snapshot;
67         char            *origin;
68         char            *base;
69         uint64_t        sectors;
70 };
71
72 struct device_handler *device_handler_init(struct discover_server *server,
73                 struct waitset *waitset, int dry_run);
74
75 void device_handler_destroy(struct device_handler *devices);
76
77 int device_handler_get_device_count(const struct device_handler *handler);
78 const struct discover_device *device_handler_get_device(
79         const struct device_handler *handler, unsigned int index);
80
81 struct discover_device *discover_device_create(struct device_handler *handler,
82                 const char *id);
83 void device_handler_add_device(struct device_handler *handler,
84                 struct discover_device *device);
85 void device_handler_add_ramdisk(struct device_handler *handler,
86                 const char *path);
87 struct ramdisk_device *device_handler_get_ramdisk(
88                 struct device_handler *handler);
89 void device_handler_release_ramdisk(struct discover_device *device);
90 int device_handler_discover(struct device_handler *handler,
91                 struct discover_device *dev);
92 int device_handler_dhcp(struct device_handler *handler,
93                 struct discover_device *dev, struct event *event);
94 int device_handler_conf(struct device_handler *handler,
95                 struct discover_device *dev, struct pb_url *url);
96 void device_handler_remove(struct device_handler *handler,
97                 struct discover_device *device);
98
99 struct discover_context *device_handler_discover_context_create(
100                 struct device_handler *handler,
101                 struct discover_device *device);
102 void device_handler_discover_context_commit(struct device_handler *handler,
103                 struct discover_context *ctx);
104
105 struct discover_boot_option *discover_boot_option_create(
106                 struct discover_context *ctx,
107                 struct discover_device *dev);
108 void discover_context_add_boot_option(struct discover_context *ctx,
109                 struct discover_boot_option *opt);
110
111 int device_handler_user_event(struct device_handler *handler,
112                                 struct event *event);
113
114 struct discover_device *device_lookup_by_name(struct device_handler *handler,
115                 const char *name);
116 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
117                 const char *uuid);
118 struct discover_device *device_lookup_by_label(struct device_handler *handler,
119                 const char *label);
120 struct discover_device *device_lookup_by_id(struct device_handler *handler,
121                 const char *id);
122 struct discover_device *device_lookup_by_serial(
123                 struct device_handler *device_handler,
124                 const char *serial);
125
126 void discover_device_set_param(struct discover_device *device,
127                 const char *name, const char *value);
128 const char *discover_device_get_param(struct discover_device *device,
129                 const char *name);
130
131 void device_handler_boot(struct device_handler *handler,
132                 struct boot_command *cmd);
133 void device_handler_cancel_default(struct device_handler *handler);
134 void device_handler_update_config(struct device_handler *handler,
135                 struct config *config);
136 void device_handler_process_url(struct device_handler *handler,
137                 const char *url, const char *mac, const char *ip);
138 void device_handler_reinit(struct device_handler *handler);
139
140 int device_request_write(struct discover_device *dev, bool *release);
141 void device_release_write(struct discover_device *dev, bool release);
142
143 #endif /* _DEVICE_HANDLER_H */