]> git.ozlabs.org Git - petitboot/blob - lib/types/types.h
ui/ncurses: Keep track of the default boot option
[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         bool            is_autoboot_default;
58
59         struct list_item        list;
60
61         void            *ui_info;
62
63         enum {
64                 DISCOVER_BOOT_OPTION,
65                 DISCOVER_PLUGIN_OPTION,
66         } type;
67 };
68
69 struct plugin_option {
70         char            *id;
71         char            *name;
72         char            *vendor;
73         char            *vendor_id;
74         char            *version;
75         char            *date;
76         char            *plugin_file;
77
78         unsigned int    n_executables;
79         char            **executables;
80
81         void            *ui_info;
82 };
83
84 struct boot_command {
85         char *option_id;
86         char *boot_image_file;
87         char *initrd_file;
88         char *dtb_file;
89         char *boot_args;
90         char *args_sig_file;
91         char *console;
92 };
93
94 struct status {
95         enum status_type {
96                 STATUS_INFO,
97                 STATUS_ERROR,
98         } type;
99         char    *message;
100         bool    backlog;
101         bool    boot_active;
102 };
103
104 struct statuslog_entry {
105         struct status           *status;
106         struct list_item        list;
107 };
108
109 struct interface_info {
110         unsigned int    hwaddr_size;
111         uint8_t         *hwaddr;
112         char            *name;
113         bool            link;
114         char            *address;
115         char            *address_v6;
116 };
117
118 struct blockdev_info {
119         char            *name;
120         char            *uuid;
121         char            *mountpoint;
122 };
123
124 struct system_info {
125         char                    *type;
126         char                    *identifier;
127         char                    **platform_primary;
128         char                    **platform_other;
129         unsigned int            n_primary;
130         unsigned int            n_other;
131         char                    **bmc_current;
132         char                    **bmc_golden;
133         unsigned int            n_bmc_current;
134         unsigned int            n_bmc_golden;
135         uint8_t                 *bmc_mac;
136         struct interface_info   **interfaces;
137         unsigned int            n_interfaces;
138         struct blockdev_info    **blockdevs;
139         unsigned int            n_blockdevs;
140 };
141
142 #define HWADDR_SIZE     6
143
144 struct interface_config {
145         uint8_t hwaddr[HWADDR_SIZE];
146         bool    ignore;
147         enum {
148                 CONFIG_METHOD_DHCP,
149                 CONFIG_METHOD_STATIC,
150         } method;
151         union {
152                 struct {
153                 } dhcp_config;
154                 struct {
155                         char *address;
156                         char *gateway;
157                         char *url;
158                 } static_config;
159         };
160         bool    override;
161 };
162
163 struct network_config {
164         struct interface_config **interfaces;
165         unsigned int            n_interfaces;
166         const char              **dns_servers;
167         unsigned int            n_dns_servers;
168 };
169
170 struct autoboot_option {
171         enum {
172                 BOOT_DEVICE_TYPE,
173                 BOOT_DEVICE_UUID
174         } boot_type;
175         union {
176                 enum device_type        type;
177                 char                    *uuid;
178         };
179 };
180
181 struct config {
182         bool                    autoboot_enabled;
183         unsigned int            autoboot_timeout_sec;
184         struct network_config   network;
185
186         struct autoboot_option  *autoboot_opts;
187         unsigned int            n_autoboot_opts;
188
189         unsigned int            ipmi_bootdev;
190         bool                    ipmi_bootdev_persistent;
191
192         char                    *http_proxy;
193         char                    *https_proxy;
194
195         bool                    allow_writes;
196
197         char                    *boot_console;
198         bool                    manual_console;
199         char                    *lang;
200
201         /* not user-settable */
202         unsigned int            n_consoles;
203         char                    **consoles;
204         bool                    disable_snapshots;
205         bool                    safe_mode;
206         bool                    debug;
207 };
208
209 bool config_autoboot_active(const struct config *config);
210
211 #endif /* _TYPES_H */