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