]> git.ozlabs.org Git - petitboot/blob - discover/platform.h
ui/ncurses: Keep track of the default boot option
[petitboot] / discover / platform.h
1 #ifndef PLATFORM_H
2 #define PLATFORM_H
3
4 #include <types/types.h>
5 #include <param_list/param_list.h>
6
7 struct platform {
8         const char      *name;
9         bool            (*probe)(struct platform *, void *);
10         int             (*load_config)(struct platform *, struct config *);
11         int             (*save_config)(struct platform *, struct config *);
12         void            (*pre_boot)(struct platform *,
13                                 const struct config *);
14         int             (*get_sysinfo)(struct platform *, struct system_info *);
15         bool            (*restrict_clients)(struct platform *);
16         int             (*set_password)(struct platform *, const char *hash);
17         uint16_t        dhcp_arch_id;
18         void            *platform_data;
19 };
20
21 int platform_init(void *ctx);
22 int platform_fini(void);
23 const struct platform *platform_get(void);
24 int platform_get_sysinfo(struct system_info *info);
25 bool platform_restrict_clients(void);
26 int platform_set_password(const char *hash);
27 void platform_pre_boot(void);
28
29 /* configuration interface */
30 const struct config *config_get(void);
31 int config_set(struct config *config);
32 void config_set_defaults(struct config *config);
33 void config_set_autoboot(bool autoboot_enabled);
34 void config_populate_all(struct config *config, const struct param_list *pl);
35
36 void params_update_network_values(struct param_list *pl,
37         const char *param_name, const struct config *config);
38 void params_update_bootdev_values(struct param_list *pl,
39         const char *param_name, const struct config *config);
40
41 #define __platform_ptrname(_n) __platform_ ## _n
42 #define  _platform_ptrname(_n) __platform_ptrname(_n)
43
44 #define register_platform(p) \
45         static __attribute__((section("platforms"))) \
46                 __attribute__((used)) \
47                 struct platform * _platform_ptrname(__COUNTER__) = &p;
48
49 #endif /* PLATFORM_H */
50