]> git.ozlabs.org Git - petitboot/blob - lib/types/types.h
lib/efi: Add new routines to access efi variables
[petitboot] / lib / types / types.h
1 #ifndef _TYPES_H
2 #define _TYPES_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <list/list.h>
7
8 enum device_type {
9         DEVICE_TYPE_NETWORK,
10         DEVICE_TYPE_DISK,
11         DEVICE_TYPE_USB,
12         DEVICE_TYPE_OPTICAL,
13         DEVICE_TYPE_ANY,
14         DEVICE_TYPE_UNKNOWN,
15 };
16
17 enum ipmi_bootdev {
18         IPMI_BOOTDEV_NONE = 0x00,
19         IPMI_BOOTDEV_NETWORK = 0x01,
20         IPMI_BOOTDEV_DISK = 0x2,
21         IPMI_BOOTDEV_SAFE = 0x3,
22         IPMI_BOOTDEV_CDROM = 0x5,
23         IPMI_BOOTDEV_SETUP = 0x6,
24         IPMI_BOOTDEV_INVALID = 0xff,
25 };
26
27 const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev);
28 const char *device_type_display_name(enum device_type type);
29 const char *device_type_name(enum device_type type);
30 enum device_type find_device_type(const char *str);
31
32 struct device {
33         char            *id;
34         enum device_type type;
35         char            *name;
36         char            *description;
37         char            *icon_file;
38
39         int             n_options;
40         struct list     boot_options;
41
42         void            *ui_info;
43 };
44
45 struct boot_option {
46         char            *device_id;
47         char            *id;
48         char            *name;
49         char            *description;
50         char            *icon_file;
51         char            *boot_image_file;
52         char            *initrd_file;
53         char            *dtb_file;
54         char            *boot_args;
55         char            *args_sig_file;
56         bool            is_default;
57
58         struct list_item        list;
59
60         void            *ui_info;
61
62         enum {
63                 DISCOVER_BOOT_OPTION,
64                 DISCOVER_PLUGIN_OPTION,
65         } type;
66 };
67
68 struct plugin_option {
69         char            *id;
70         char            *name;
71         char            *vendor;
72         char            *vendor_id;
73         char            *version;
74         char            *date;
75         char            *plugin_file;
76
77         unsigned int    n_executables;
78         char            **executables;
79
80         void            *ui_info;
81 };
82
83 struct boot_command {
84         char *option_id;
85         char *boot_image_file;
86         char *initrd_file;
87         char *dtb_file;
88         char *boot_args;
89         char *args_sig_file;
90         char *console;
91 };
92
93 struct status {
94         enum status_type {
95                 STATUS_INFO,
96                 STATUS_ERROR,
97         } type;
98         char    *message;
99         bool    backlog;
100 };
101
102 struct statuslog_entry {
103         struct status           *status;
104         struct list_item        list;
105 };
106
107 struct interface_info {
108         unsigned int    hwaddr_size;
109         uint8_t         *hwaddr;
110         char            *name;
111         bool            link;
112         char            *address;
113         char            *address_v6;
114 };
115
116 struct blockdev_info {
117         char            *name;
118         char            *uuid;
119         char            *mountpoint;
120 };
121
122 struct system_info {
123         char                    *type;
124         char                    *identifier;
125         char                    **platform_primary;
126         char                    **platform_other;
127         unsigned int            n_primary;
128         unsigned int            n_other;
129         char                    **bmc_current;
130         char                    **bmc_golden;
131         unsigned int            n_bmc_current;
132         unsigned int            n_bmc_golden;
133         uint8_t                 *bmc_mac;
134         struct interface_info   **interfaces;
135         unsigned int            n_interfaces;
136         struct blockdev_info    **blockdevs;
137         unsigned int            n_blockdevs;
138 };
139
140 #define HWADDR_SIZE     6
141
142 struct interface_config {
143         uint8_t hwaddr[HWADDR_SIZE];
144         bool    ignore;
145         enum {
146                 CONFIG_METHOD_DHCP,
147                 CONFIG_METHOD_STATIC,
148         } method;
149         union {
150                 struct {
151                 } dhcp_config;
152                 struct {
153                         char *address;
154                         char *gateway;
155                         char *url;
156                 } static_config;
157         };
158         bool    override;
159 };
160
161 struct network_config {
162         struct interface_config **interfaces;
163         unsigned int            n_interfaces;
164         const char              **dns_servers;
165         unsigned int            n_dns_servers;
166 };
167
168 struct autoboot_option {
169         enum {
170                 BOOT_DEVICE_TYPE,
171                 BOOT_DEVICE_UUID
172         } boot_type;
173         union {
174                 enum device_type        type;
175                 char                    *uuid;
176         };
177 };
178
179 struct config {
180         bool                    autoboot_enabled;
181         unsigned int            autoboot_timeout_sec;
182         struct network_config   network;
183
184         struct autoboot_option  *autoboot_opts;
185         unsigned int            n_autoboot_opts;
186
187         unsigned int            ipmi_bootdev;
188         bool                    ipmi_bootdev_persistent;
189
190         char                    *http_proxy;
191         char                    *https_proxy;
192
193         bool                    allow_writes;
194
195         char                    *boot_console;
196         bool                    manual_console;
197         char                    *lang;
198
199         /* not user-settable */
200         unsigned int            n_consoles;
201         char                    **consoles;
202         bool                    disable_snapshots;
203         bool                    safe_mode;
204         bool                    debug;
205 };
206
207 bool config_autoboot_active(const struct config *config);
208
209 #endif /* _TYPES_H */