julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <string.h> |
| 7 | #include <config/interface/platform_config.h> |
| 8 | #include <platform/interface/device_region.h> |
| 9 | #include "sp_config_loader.h" |
| 10 | |
| 11 | |
| 12 | struct sp_param_device_region |
| 13 | { |
| 14 | char name[16]; |
| 15 | uintptr_t location; |
| 16 | size_t size; |
| 17 | }; |
| 18 | |
| 19 | /** |
| 20 | * Loads externally provided configuration data originating from |
| 21 | * theh SP manifest. |
| 22 | */ |
| 23 | void sp_config_load(struct ffa_init_info *init_info) |
| 24 | { |
| 25 | /* Load deployment specific configuration */ |
| 26 | for (size_t param_index = 0; param_index < init_info->count; param_index++) { |
| 27 | |
| 28 | if (!strcmp((const char *)init_info->nvp[param_index].name,"DEVICE_REGIONS")) { |
| 29 | |
| 30 | struct sp_param_device_region *d = (struct sp_param_device_region *)init_info->nvp[param_index].value; |
| 31 | |
| 32 | /*Iterate over the device regions*/ |
| 33 | while ((uintptr_t)d < (init_info->nvp[param_index].value + init_info->nvp[param_index].size)) { |
| 34 | |
| 35 | struct device_region device_region; |
| 36 | |
| 37 | strcpy(device_region.dev_class, d->name); |
| 38 | device_region.dev_instance = 0; |
| 39 | device_region.base_addr = d->location; |
| 40 | device_region.io_region_size = d->size; |
| 41 | |
| 42 | platform_config_device_add(&device_region); |
| 43 | |
| 44 | ++d; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |