diff options
author | Stewart Smith <stewart@flamingspork.com> | 2021-12-20 22:22:44 +1000 |
---|---|---|
committer | Cédric Le Goater <clg@kaod.org> | 2022-01-03 16:12:45 +0100 |
commit | bd497ddbfc845f55c2de0e65c67e7a8c20687a22 (patch) | |
tree | 4d69db4c1363bf426ba412ea8545c4c8aa559bde /include | |
parent | 7e1397f23f15be0fa916ab921477d0d0c5a8d4aa (diff) | |
download | skiboot-bd497ddbfc845f55c2de0e65c67e7a8c20687a22.zip skiboot-bd497ddbfc845f55c2de0e65c67e7a8c20687a22.tar.gz skiboot-bd497ddbfc845f55c2de0e65c67e7a8c20687a22.tar.bz2 |
Introduce hwprobe facility to avoid hard-coding probe functions
hwprobe is a little system to have different hardware probing modules
run in the dependency order they choose rather than hard coding
that order in core/init.c.
Reviewed-by: Dan Horák <dan@danny.cz>
Signed-off-by: Stewart Smith <stewart@flamingspork.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/skiboot.h | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/include/skiboot.h b/include/skiboot.h index 312a436..d1553c4 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -1,5 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -/* Copyright 2013-2019 IBM Corp. */ +/* Copyright 2013-2019 IBM Corp. + * Copyright 2021 Stewart Smith + */ #ifndef __SKIBOOT_H #define __SKIBOOT_H @@ -346,4 +348,39 @@ extern int fake_nvram_info(uint32_t *total_size); extern int fake_nvram_start_read(void *dst, uint32_t src, uint32_t len); extern int fake_nvram_write(uint32_t offset, void *src, uint32_t size); +/* + * A bunch of hardware needs to be probed, sometimes in a particular order. + * Very simple dependency graph, with a even simpler way to resolve it. + * But it means we can now at link time choose what hardware we support. + * This struct should not be defined directly but with the macros. + */ +struct hwprobe { + const char *name; + void (*probe)(void); + + bool probed; + + /* NULL or NULL-terminated array of strings */ + const char **deps; +}; + +#define DEFINE_HWPROBE(__name, __probe) \ +static const struct hwprobe __used __section(".hwprobes") hwprobe_##__name = { \ + .name = #__name, \ + .probe = __probe, \ + .deps = NULL, \ +} + +#define DEFINE_HWPROBE_DEPS(__name, __probe, ...) \ +static const struct hwprobe __used __section(".hwprobes") hwprobe_##__name = { \ + .name = #__name, \ + .probe = __probe, \ + .deps = (const char *[]){ __VA_ARGS__, NULL}, \ +} + +extern struct hwprobe __hwprobes_start; +extern struct hwprobe __hwprobes_end; + +extern void probe_hardware(void); + #endif /* __SKIBOOT_H */ |