ui/ncurses: Reset console options on boot
[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         bool    boot_active;
101 };
102
103 struct statuslog_entry {
104         struct status           *status;
105         struct list_item        list;
106 };
107
108 struct interface_info {
109         unsigned int    hwaddr_size;
110         uint8_t         *hwaddr;
111         char            *name;
112         bool            link;
113         char            *address;
114         char            *address_v6;
115 };
116
117 struct blockdev_info {
118         char            *name;
119         char            *uuid;
120         char            *mountpoint;
121 };
122
123 struct system_info {
124         char                    *type;
125         char                    *identifier;
126         char                    **platform_primary;
127         char                    **platform_other;
128         unsigned int            n_primary;
129         unsigned int            n_other;
130         char                    **bmc_current;
131         char                    **bmc_golden;
132         unsigned int            n_bmc_current;
133         unsigned int            n_bmc_golden;
134         uint8_t                 *bmc_mac;
135         struct interface_info   **interfaces;
136         unsigned int            n_interfaces;
137         struct blockdev_info    **blockdevs;
138         unsigned int            n_blockdevs;
139 };
140
141 #define HWADDR_SIZE     6
142
143 struct interface_config {
144         uint8_t hwaddr[HWADDR_SIZE];
145         bool    ignore;
146         enum {
147                 CONFIG_METHOD_DHCP,
148                 CONFIG_METHOD_STATIC,
149         } method;
150         union {
151                 struct {
152                 } dhcp_config;
153                 struct {
154                         char *address;
155                         char *gateway;
156                         char *url;
157                 } static_config;
158         };
159         bool    override;
160 };
161
162 struct network_config {
163         struct interface_config **interfaces;
164         unsigned int            n_interfaces;
165         const char              **dns_servers;
166         unsigned int            n_dns_servers;
167 };
168
169 struct autoboot_option {
170         enum {
171                 BOOT_DEVICE_TYPE,
172                 BOOT_DEVICE_UUID
173         } boot_type;
174         union {
175                 enum device_type        type;
176                 char                    *uuid;
177         };
178 };
179
180 struct config {
181         bool                    autoboot_enabled;
182         unsigned int            autoboot_timeout_sec;
183         struct network_config   network;
184
185         struct autoboot_option  *autoboot_opts;
186         unsigned int            n_autoboot_opts;
187
188         unsigned int            ipmi_bootdev;
189         bool                    ipmi_bootdev_persistent;
190
191         char                    *http_proxy;
192         char                    *https_proxy;
193
194         bool                    allow_writes;
195
196         char                    *boot_console;
197         bool                    manual_console;
198         char                    *lang;
199
200         /* not user-settable */
201         unsigned int            n_consoles;
202         char                    **consoles;
203         bool                    disable_snapshots;
204         bool                    safe_mode;
205         bool                    debug;
206 };
207
208 bool config_autoboot_active(const struct config *config);
209
210 #endif /* _TYPES_H */