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 | |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 15 | /* |
| 16 | * This macro takes three arguments: |
| 17 | * config: Configuration identifier |
| 18 | * name: property namespace |
| 19 | * callback: populate() function |
| 20 | */ |
| 21 | #define FCONF_REGISTER_POPULATOR(config, name, callback) \ |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 22 | __attribute__((used, section(".fconf_populator"))) \ |
Louis Mayencourt | 2711cc8 | 2020-02-24 14:37:25 +0000 | [diff] [blame] | 23 | const struct fconf_populator (name##__populator) = { \ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 24 | .config_type = (#config), \ |
Louis Mayencourt | 2711cc8 | 2020-02-24 14:37:25 +0000 | [diff] [blame] | 25 | .info = (#name), \ |
| 26 | .populate = (callback) \ |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | /* |
| 30 | * Populator callback |
| 31 | * |
| 32 | * This structure are used by the fconf_populate function and should only be |
| 33 | * defined by the FCONF_REGISTER_POPULATOR macro. |
| 34 | */ |
| 35 | struct fconf_populator { |
| 36 | /* Description of the data loaded by the callback */ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 37 | const char *config_type; |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 38 | const char *info; |
| 39 | |
| 40 | /* Callback used by fconf_populate function with a provided config dtb. |
| 41 | * Return 0 on success, err_code < 0 otherwise. |
| 42 | */ |
| 43 | int (*populate)(uintptr_t config); |
| 44 | }; |
| 45 | |
Manish V Badarkhe | bb533c7 | 2020-06-11 22:17:30 +0100 | [diff] [blame] | 46 | /* This function supports to load tb_fw_config and fw_config dtb */ |
Manish V Badarkhe | e069f8a | 2020-06-11 22:25:53 +0100 | [diff] [blame] | 47 | int fconf_load_config(unsigned int image_id); |
Louis Mayencourt | 5a15b2d | 2019-10-17 14:46:51 +0100 | [diff] [blame] | 48 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 49 | /* Top level populate function |
| 50 | * |
| 51 | * This function takes a configuration dtb and calls all the registered |
| 52 | * populator callback with it. |
| 53 | * |
| 54 | * Panic on error. |
| 55 | */ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 56 | void fconf_populate(const char *config_type, uintptr_t config); |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 57 | |
Louis Mayencourt | 81bd916 | 2019-10-17 15:14:25 +0100 | [diff] [blame] | 58 | /* FCONF specific getter */ |
| 59 | #define fconf__dtb_getter(prop) fconf_dtb_info.prop |
| 60 | |
| 61 | /* Structure used to locally keep a reference to the config dtb. */ |
| 62 | struct fconf_dtb_info_t { |
| 63 | uintptr_t base_addr; |
| 64 | size_t size; |
| 65 | }; |
| 66 | |
| 67 | extern struct fconf_dtb_info_t fconf_dtb_info; |
| 68 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 69 | #endif /* FCONF_H */ |