path: root/discover/platform.h
diff options
authorJeremy Kerr <>2014-01-29 13:28:06 +0800
committerJeremy Kerr <>2014-01-30 21:59:10 +0800
commitc14b12980885edd035322cd3bc87efff444c39b1 (patch)
tree138bac8bfacd9d1a36d04421d91e0eedf4164da2 /discover/platform.h
parentdea7842fb28ff055b4e0f43a6a1fdaf3c4b5ba89 (diff)
pb-config: Move config storage modules to "platform" modules in discover code
There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr <>
Diffstat (limited to 'discover/platform.h')
1 files changed, 34 insertions, 0 deletions
diff --git a/discover/platform.h b/discover/platform.h
new file mode 100644
index 0000000..44315fa
--- /dev/null
+++ b/discover/platform.h
@@ -0,0 +1,34 @@
+#ifndef PLATFORM_H
+#define PLATFORM_H
+#include <types/types.h>
+struct platform {
+ const char *name;
+ bool (*probe)(struct platform *, void *);
+ int (*load_config)(struct platform *, struct config *);
+ int (*save_config)(struct platform *, struct config *);
+ void *platform_data;
+int platform_init(void *ctx);
+int platform_fini(void);
+/* configuration interface */
+const struct config *config_get(void);
+int config_set(struct config *config);
+void config_set_autoboot(bool autoboot_enabled);
+/* for use by the platform-specific storage code */
+void config_set_defaults(struct config *config);
+#define __platform_ptrname(_n) __platform_ ## _n
+#define _platform_ptrname(_n) __platform_ptrname(_n)
+#define register_platform(p) \
+ static __attribute__((section("platforms"))) \
+ __attribute__((used)) \
+ struct platform * _platform_ptrname(__COUNTER__) = &p;
+#endif /* PLATFORM_H */
OpenPOWER on IntegriCloud