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