Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 1 | /* |
Govindraj Raja | eee28e7 | 2023-08-01 15:52:40 -0500 | [diff] [blame] | 2 | * Copyright (c) 2019-2022, Arm Limited. All rights reserved. |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FCONF_H |
| 8 | #define FCONF_H |
| 9 | |
Claus Pedersen | 785e66c | 2022-09-12 22:42:58 +0000 | [diff] [blame] | 10 | #include <stddef.h> |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | |
| 13 | /* Public API */ |
| 14 | #define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c) |
| 15 | |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 16 | /* |
| 17 | * This macro takes three arguments: |
| 18 | * config: Configuration identifier |
| 19 | * name: property namespace |
| 20 | * callback: populate() function |
| 21 | */ |
| 22 | #define FCONF_REGISTER_POPULATOR(config, name, callback) \ |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 23 | __attribute__((used, section(".fconf_populator"))) \ |
Yann Gautier | 39531c6 | 2022-11-18 14:04:03 +0100 | [diff] [blame] | 24 | static const struct fconf_populator (name##__populator) = { \ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 25 | .config_type = (#config), \ |
Louis Mayencourt | 2711cc8 | 2020-02-24 14:37:25 +0000 | [diff] [blame] | 26 | .info = (#name), \ |
| 27 | .populate = (callback) \ |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | /* |
| 31 | * Populator callback |
| 32 | * |
| 33 | * This structure are used by the fconf_populate function and should only be |
| 34 | * defined by the FCONF_REGISTER_POPULATOR macro. |
| 35 | */ |
| 36 | struct fconf_populator { |
| 37 | /* Description of the data loaded by the callback */ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 38 | const char *config_type; |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 39 | const char *info; |
| 40 | |
| 41 | /* Callback used by fconf_populate function with a provided config dtb. |
| 42 | * Return 0 on success, err_code < 0 otherwise. |
| 43 | */ |
| 44 | int (*populate)(uintptr_t config); |
| 45 | }; |
| 46 | |
Manish V Badarkhe | bb533c7 | 2020-06-11 22:17:30 +0100 | [diff] [blame] | 47 | /* 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] | 48 | int fconf_load_config(unsigned int image_id); |
Louis Mayencourt | 5a15b2d | 2019-10-17 14:46:51 +0100 | [diff] [blame] | 49 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 50 | /* Top level populate function |
| 51 | * |
| 52 | * This function takes a configuration dtb and calls all the registered |
| 53 | * populator callback with it. |
| 54 | * |
| 55 | * Panic on error. |
| 56 | */ |
Madhukar Pappireddy | 8151969 | 2019-12-06 15:46:42 -0600 | [diff] [blame] | 57 | void fconf_populate(const char *config_type, uintptr_t config); |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 58 | |
Louis Mayencourt | 81bd916 | 2019-10-17 15:14:25 +0100 | [diff] [blame] | 59 | /* FCONF specific getter */ |
| 60 | #define fconf__dtb_getter(prop) fconf_dtb_info.prop |
| 61 | |
| 62 | /* Structure used to locally keep a reference to the config dtb. */ |
| 63 | struct fconf_dtb_info_t { |
| 64 | uintptr_t base_addr; |
| 65 | size_t size; |
| 66 | }; |
| 67 | |
| 68 | extern struct fconf_dtb_info_t fconf_dtb_info; |
| 69 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 70 | #endif /* FCONF_H */ |