Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019-2020, ARM Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FCONF_H |
| 8 | #define FCONF_H |
| 9 | |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | /* Public API */ |
| 13 | #define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c) |
| 14 | |
| 15 | #define FCONF_REGISTER_POPULATOR(name, callback) \ |
| 16 | __attribute__((used, section(".fconf_populator"))) \ |
Louis Mayencourt | 2711cc8 | 2020-02-24 14:37:25 +0000 | [diff] [blame] | 17 | const struct fconf_populator (name##__populator) = { \ |
| 18 | .info = (#name), \ |
| 19 | .populate = (callback) \ |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | /* |
| 23 | * Populator callback |
| 24 | * |
| 25 | * This structure are used by the fconf_populate function and should only be |
| 26 | * defined by the FCONF_REGISTER_POPULATOR macro. |
| 27 | */ |
| 28 | struct fconf_populator { |
| 29 | /* Description of the data loaded by the callback */ |
| 30 | const char *info; |
| 31 | |
| 32 | /* Callback used by fconf_populate function with a provided config dtb. |
| 33 | * Return 0 on success, err_code < 0 otherwise. |
| 34 | */ |
| 35 | int (*populate)(uintptr_t config); |
| 36 | }; |
| 37 | |
Louis Mayencourt | 5a15b2d | 2019-10-17 14:46:51 +0100 | [diff] [blame] | 38 | /* Load firmware configuration dtb */ |
| 39 | void fconf_load_config(void); |
| 40 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 41 | /* Top level populate function |
| 42 | * |
| 43 | * This function takes a configuration dtb and calls all the registered |
| 44 | * populator callback with it. |
| 45 | * |
| 46 | * Panic on error. |
| 47 | */ |
| 48 | void fconf_populate(uintptr_t config); |
| 49 | |
Louis Mayencourt | 81bd916 | 2019-10-17 15:14:25 +0100 | [diff] [blame] | 50 | /* FCONF specific getter */ |
| 51 | #define fconf__dtb_getter(prop) fconf_dtb_info.prop |
| 52 | |
| 53 | /* Structure used to locally keep a reference to the config dtb. */ |
| 54 | struct fconf_dtb_info_t { |
| 55 | uintptr_t base_addr; |
| 56 | size_t size; |
| 57 | }; |
| 58 | |
| 59 | extern struct fconf_dtb_info_t fconf_dtb_info; |
| 60 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 61 | #endif /* FCONF_H */ |