]> git.ozlabs.org Git - petitboot/blob - lib/types/types.h
3bb8c9be456a6030028bb7569f4b256fa2066a3e
[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 autoboot_option {
117         enum {
118                 BOOT_DEVICE_TYPE,
119                 BOOT_DEVICE_UUID
120         } boot_type;
121         union {
122                 enum device_type        type;
123                 char                    *uuid;
124         };
125 };
126
127 struct config {
128         bool                    autoboot_enabled;
129         unsigned int            autoboot_timeout_sec;
130         struct network_config   network;
131
132         struct autoboot_option  *autoboot_opts;
133         unsigned int            n_autoboot_opts;
134
135         unsigned int            ipmi_bootdev;
136         bool                    ipmi_bootdev_persistent;
137
138         char                    *lang;
139
140         /* not user-settable */
141         bool                    safe_mode;
142         bool                    debug;
143 };
144
145 #endif /* _TYPES_H */