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