5c5f6ed80110e8e341bc2f3380add6b63f2affa8
[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         bool            is_default;
56
57         struct list_item        list;
58
59         void            *ui_info;
60 };
61
62 struct boot_command {
63         char *option_id;
64         char *boot_image_file;
65         char *initrd_file;
66         char *dtb_file;
67         char *boot_args;
68         char *tty;
69 };
70
71 struct boot_status {
72         enum {
73                 BOOT_STATUS_INFO,
74                 BOOT_STATUS_ERROR,
75         } type;
76         char    *message;
77         char    *detail;
78         int     progress;
79 };
80
81 struct interface_info {
82         unsigned int    hwaddr_size;
83         uint8_t         *hwaddr;
84         char            *name;
85         bool            link;
86 };
87
88 struct blockdev_info {
89         char            *name;
90         char            *uuid;
91         char            *mountpoint;
92 };
93
94 struct system_info {
95         char                    *type;
96         char                    *identifier;
97         char                    **platform_primary;
98         char                    **platform_other;
99         unsigned int            n_primary;
100         unsigned int            n_other;
101         char                    **bmc_current;
102         char                    **bmc_golden;
103         unsigned int            n_bmc_current;
104         unsigned int            n_bmc_golden;
105         uint8_t                 *bmc_mac;
106         struct interface_info   **interfaces;
107         unsigned int            n_interfaces;
108         struct blockdev_info    **blockdevs;
109         unsigned int            n_blockdevs;
110 };
111
112 #define HWADDR_SIZE     6
113
114 struct interface_config {
115         uint8_t hwaddr[HWADDR_SIZE];
116         bool    ignore;
117         enum {
118                 CONFIG_METHOD_DHCP,
119                 CONFIG_METHOD_STATIC,
120         } method;
121         union {
122                 struct {
123                 } dhcp_config;
124                 struct {
125                         char *address;
126                         char *gateway;
127                         char *url;
128                 } static_config;
129         };
130 };
131
132 struct network_config {
133         struct interface_config **interfaces;
134         unsigned int            n_interfaces;
135         const char              **dns_servers;
136         unsigned int            n_dns_servers;
137 };
138
139 struct autoboot_option {
140         enum {
141                 BOOT_DEVICE_TYPE,
142                 BOOT_DEVICE_UUID
143         } boot_type;
144         union {
145                 enum device_type        type;
146                 char                    *uuid;
147         };
148 };
149
150 struct config {
151         bool                    autoboot_enabled;
152         unsigned int            autoboot_timeout_sec;
153         struct network_config   network;
154
155         struct autoboot_option  *autoboot_opts;
156         unsigned int            n_autoboot_opts;
157
158         unsigned int            ipmi_bootdev;
159         bool                    ipmi_bootdev_persistent;
160
161         bool                    allow_writes;
162
163         char                    *boot_tty;
164         char                    *lang;
165
166         /* not user-settable */
167         unsigned int            n_tty;
168         char                    **tty_list;
169         bool                    disable_snapshots;
170         bool                    safe_mode;
171         bool                    debug;
172 };
173
174 #endif /* _TYPES_H */