mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-26 06:50:10 +00:00
fix(drtm): sort the address-map in ascending order
As per the specification the address map region in the DLME data must be sorted. Change-Id: Ibf39dad33ef7ce739d6ec8632198df55a4e8a1c3 Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
This commit is contained in:
parent
277713e0ae
commit
7cf3784814
1 changed files with 19 additions and 1 deletions
|
@ -1,10 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 Arm Limited. All rights reserved.
|
* Copyright (c) 2022-2025 Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <plat/common/platform.h>
|
#include <plat/common/platform.h>
|
||||||
#include <services/drtm_svc.h>
|
#include <services/drtm_svc.h>
|
||||||
|
@ -23,6 +24,20 @@ static uint8_t drtm_address_map[DRTM_ADDRESS_MAP_SIZE];
|
||||||
|
|
||||||
static uint64_t drtm_address_map_size;
|
static uint64_t drtm_address_map_size;
|
||||||
|
|
||||||
|
static int compare_regions(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const drtm_mem_region_t *region_a = (const drtm_mem_region_t *)a;
|
||||||
|
const drtm_mem_region_t *region_b = (const drtm_mem_region_t *)b;
|
||||||
|
|
||||||
|
if (region_a->region_address < region_b->region_address) {
|
||||||
|
return -1;
|
||||||
|
} else if (region_a->region_address > region_b->region_address) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
drtm_memory_region_descriptor_table_t *drtm_build_address_map(void)
|
drtm_memory_region_descriptor_table_t *drtm_build_address_map(void)
|
||||||
{
|
{
|
||||||
/* Set up pointer to DRTM memory map. */
|
/* Set up pointer to DRTM memory map. */
|
||||||
|
@ -75,6 +90,9 @@ drtm_memory_region_descriptor_table_t *drtm_build_address_map(void)
|
||||||
|
|
||||||
map->num_regions = i;
|
map->num_regions = i;
|
||||||
|
|
||||||
|
qsort(map->region, map->num_regions, sizeof(drtm_mem_region_t),
|
||||||
|
compare_regions);
|
||||||
|
|
||||||
/* Store total size of address map. */
|
/* Store total size of address map. */
|
||||||
drtm_address_map_size = sizeof(drtm_memory_region_descriptor_table_t);
|
drtm_address_map_size = sizeof(drtm_memory_region_descriptor_table_t);
|
||||||
drtm_address_map_size += (i * sizeof(drtm_mem_region_t));
|
drtm_address_map_size += (i * sizeof(drtm_mem_region_t));
|
||||||
|
|
Loading…
Add table
Reference in a new issue