]> git.ozlabs.org Git - petitboot/blob - lib/types/types.h
d2a2918c7b3fe2cd077219ab6319b87c5d1dde01
[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 };
68
69 struct blockdev_info {
70         char            *name;
71         char            *uuid;
72         char            *mountpoint;
73 };
74
75 struct system_info {
76         char                    *type;
77         char                    *identifier;
78         struct interface_info   **interfaces;
79         unsigned int            n_interfaces;
80         struct blockdev_info    **blockdevs;
81         unsigned int            n_blockdevs;
82 };
83
84 #define HWADDR_SIZE     6
85
86 struct interface_config {
87         uint8_t hwaddr[HWADDR_SIZE];
88         bool    ignore;
89         enum {
90                 CONFIG_METHOD_DHCP,
91                 CONFIG_METHOD_STATIC,
92         } method;
93         union {
94                 struct {
95                 } dhcp_config;
96                 struct {
97                         char *address;
98                         char *gateway;
99                 } static_config;
100         };
101 };
102
103 struct network_config {
104         struct interface_config **interfaces;
105         unsigned int            n_interfaces;
106         const char              **dns_servers;
107         unsigned int            n_dns_servers;
108 };
109
110 struct boot_priority {
111         enum device_type        type;
112 };
113
114 struct config {
115         bool                    autoboot_enabled;
116         unsigned int            autoboot_timeout_sec;
117         struct network_config   network;
118         struct boot_priority    *boot_priorities;
119         unsigned int            n_boot_priorities;
120 };
121
122 #endif /* _TYPES_H */