]> git.ozlabs.org Git - petitboot/blob - discover/platform.h
discover/platform: Add finalise_config_hook
[petitboot] / discover / platform.h
1 #ifndef PLATFORM_H
2 #define PLATFORM_H
3
4 #include <types/types.h>
5
6 struct platform {
7         const char      *name;
8         bool            (*probe)(struct platform *, void *);
9         int             (*load_config)(struct platform *, struct config *);
10         int             (*save_config)(struct platform *, struct config *);
11         void            (*finalise_config)(struct platform *);
12         int             (*get_sysinfo)(struct platform *, struct system_info *);
13         uint16_t        dhcp_arch_id;
14         void            *platform_data;
15 };
16
17 int platform_init(void *ctx);
18 int platform_fini(void);
19 const struct platform *platform_get(void);
20 int platform_get_sysinfo(struct system_info *info);
21 void platform_finalise_config(void);
22
23 /* configuration interface */
24 const struct config *config_get(void);
25 int config_set(struct config *config);
26 void config_set_autoboot(bool autoboot_enabled);
27
28 /* for use by the platform-specific storage code */
29 void config_set_defaults(struct config *config);
30
31 #define __platform_ptrname(_n) __platform_ ## _n
32 #define  _platform_ptrname(_n) __platform_ptrname(_n)
33
34 #define register_platform(p) \
35         static __attribute__((section("platforms"))) \
36                 __attribute__((used)) \
37                 struct platform * _platform_ptrname(__COUNTER__) = &p;
38
39 #endif /* PLATFORM_H */
40