discover: Ensure destroy_device is called on reinit
[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 enum ipmi_bootdev {
17         IPMI_BOOTDEV_NONE = 0x00,
18         IPMI_BOOTDEV_NETWORK = 0x01,
19         IPMI_BOOTDEV_DISK = 0x2,
20         IPMI_BOOTDEV_SAFE = 0x3,
21         IPMI_BOOTDEV_CDROM = 0x5,
22         IPMI_BOOTDEV_SETUP = 0x6,
23         IPMI_BOOTDEV_INVALID = 0xff,
24 };
25
26 const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev);
27 const char *device_type_display_name(enum device_type type);
28 const char *device_type_name(enum device_type type);
29 enum device_type find_device_type(const char *str);
30
31 struct device {
32         char            *id;
33         enum device_type type;
34         char            *name;
35         char            *description;
36         char            *icon_file;
37
38         int             n_options;
39         struct list     boot_options;
40
41         void            *ui_info;
42 };
43
44 struct boot_option {
45         char            *device_id;
46         char            *id;
47         char            *name;
48         char            *description;
49         char            *icon_file;
50         char            *boot_image_file;
51         char            *initrd_file;
52         char            *dtb_file;
53         char            *boot_args;
54         bool            is_default;
55
56         struct list_item        list;
57
58         void            *ui_info;
59 };
60
61 struct boot_command {
62         char *option_id;
63         char *boot_image_file;
64         char *initrd_file;
65         char *dtb_file;
66         char *boot_args;
67 };
68
69 struct boot_status {
70         enum {
71                 BOOT_STATUS_INFO,
72                 BOOT_STATUS_ERROR,
73         } type;
74         char    *message;
75         char    *detail;
76         int     progress;
77 };
78
79 struct interface_info {
80         unsigned int    hwaddr_size;
81         uint8_t         *hwaddr;
82         char            *name;
83         bool            link;
84 };
85
86 struct blockdev_info {
87         char            *name;
88         char            *uuid;
89         char            *mountpoint;
90 };
91
92 struct system_info {
93         char                    *type;
94         char                    *identifier;
95         struct interface_info   **interfaces;
96         unsigned int            n_interfaces;
97         struct blockdev_info    **blockdevs;
98         unsigned int            n_blockdevs;
99 };
100
101 #define HWADDR_SIZE     6
102
103 struct interface_config {
104         uint8_t hwaddr[HWADDR_SIZE];
105         bool    ignore;
106         enum {
107                 CONFIG_METHOD_DHCP,
108                 CONFIG_METHOD_STATIC,
109         } method;
110         union {
111                 struct {
112                 } dhcp_config;
113                 struct {
114                         char *address;
115                         char *gateway;
116                 } static_config;
117         };
118 };
119
120 struct network_config {
121         struct interface_config **interfaces;
122         unsigned int            n_interfaces;
123         const char              **dns_servers;
124         unsigned int            n_dns_servers;
125 };
126
127 struct autoboot_option {
128         enum {
129                 BOOT_DEVICE_TYPE,
130                 BOOT_DEVICE_UUID
131         } boot_type;
132         union {
133                 enum device_type        type;
134                 char                    *uuid;
135         };
136 };
137
138 struct config {
139         bool                    autoboot_enabled;
140         unsigned int            autoboot_timeout_sec;
141         struct network_config   network;
142
143         struct autoboot_option  *autoboot_opts;
144         unsigned int            n_autoboot_opts;
145
146         unsigned int            ipmi_bootdev;
147         bool                    ipmi_bootdev_persistent;
148
149         char                    *lang;
150
151         /* not user-settable */
152         bool                    safe_mode;
153         bool                    debug;
154 };
155
156 #endif /* _TYPES_H */