config: Add boot_device member to config
[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_OPTICAL,
12         DEVICE_TYPE_ANY,
13         DEVICE_TYPE_UNKNOWN,
14 };
15
16 struct device {
17         char            *id;
18         enum device_type type;
19         char            *name;
20         char            *description;
21         char            *icon_file;
22
23         int             n_options;
24         struct list     boot_options;
25
26         void            *ui_info;
27 };
28
29 struct boot_option {
30         char            *device_id;
31         char            *id;
32         char            *name;
33         char            *description;
34         char            *icon_file;
35         char            *boot_image_file;
36         char            *initrd_file;
37         char            *dtb_file;
38         char            *boot_args;
39         bool            is_default;
40
41         struct list_item        list;
42
43         void            *ui_info;
44 };
45
46 struct boot_command {
47         char *option_id;
48         char *boot_image_file;
49         char *initrd_file;
50         char *dtb_file;
51         char *boot_args;
52 };
53
54 struct boot_status {
55         enum {
56                 BOOT_STATUS_INFO,
57                 BOOT_STATUS_ERROR,
58         } type;
59         char    *message;
60         char    *detail;
61         int     progress;
62 };
63
64 struct interface_info {
65         unsigned int    hwaddr_size;
66         uint8_t         *hwaddr;
67         char            *name;
68         bool            link;
69 };
70
71 struct blockdev_info {
72         char            *name;
73         char            *uuid;
74         char            *mountpoint;
75 };
76
77 struct system_info {
78         char                    *type;
79         char                    *identifier;
80         struct interface_info   **interfaces;
81         unsigned int            n_interfaces;
82         struct blockdev_info    **blockdevs;
83         unsigned int            n_blockdevs;
84 };
85
86 #define HWADDR_SIZE     6
87
88 struct interface_config {
89         uint8_t hwaddr[HWADDR_SIZE];
90         bool    ignore;
91         enum {
92                 CONFIG_METHOD_DHCP,
93                 CONFIG_METHOD_STATIC,
94         } method;
95         union {
96                 struct {
97                 } dhcp_config;
98                 struct {
99                         char *address;
100                         char *gateway;
101                 } static_config;
102         };
103 };
104
105 struct network_config {
106         struct interface_config **interfaces;
107         unsigned int            n_interfaces;
108         const char              **dns_servers;
109         unsigned int            n_dns_servers;
110 };
111
112 struct boot_priority {
113         /* Boot options with higher priority values will take precedence over
114          * lower values. Negative priorities signify "don't boot this by
115          * default".
116          */
117         int                     priority;
118         enum device_type        type;
119 };
120
121 struct config {
122         bool                    autoboot_enabled;
123         unsigned int            autoboot_timeout_sec;
124         struct network_config   network;
125         struct boot_priority    *boot_priorities;
126         unsigned int            n_boot_priorities;
127         char                    *boot_device;
128 };
129
130 #endif /* _TYPES_H */