mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-24 22:05:40 +00:00
Add macro to calculate number of elements in an array
This patch defines the ARRAY_SIZE macro for calculating number of elements in an array and uses it where appropriate. Change-Id: I72746a9229f0b259323972b498b9a3999731bc9b
This commit is contained in:
parent
5930eadbe5
commit
a7e98ad514
5 changed files with 13 additions and 12 deletions
|
@ -143,7 +143,7 @@ static int file_to_uuid(const char *filename, uuid_t *uuid)
|
|||
int i;
|
||||
int status = -EINVAL;
|
||||
|
||||
for (i = 0; i < (sizeof(name_uuid) / sizeof(name_uuid[0])); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(name_uuid); i++) {
|
||||
if (strcmp(filename, name_uuid[i].name) == 0) {
|
||||
copy_uuid(uuid, &name_uuid[i].uuid);
|
||||
status = 0;
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
/*******************************************************************************
|
||||
* Structure used for telling the next BL how much of a particular type of
|
||||
* memory is available for its use and how much is already used.
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <arch.h>
|
||||
#include <arch_helpers.h>
|
||||
#include <assert.h>
|
||||
#include <bl_common.h>
|
||||
#include <cassert.h>
|
||||
#include <platform_def.h>
|
||||
#include <string.h>
|
||||
|
@ -89,7 +90,7 @@ void mmap_add_region(unsigned long base_pa, unsigned long base_va,
|
|||
unsigned long size, unsigned attr)
|
||||
{
|
||||
mmap_region_t *mm = mmap;
|
||||
mmap_region_t *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1;
|
||||
mmap_region_t *mm_last = mm + ARRAY_SIZE(mmap) - 1;
|
||||
unsigned long pa_end = base_pa + size - 1;
|
||||
unsigned long va_end = base_va + size - 1;
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ const mmap_region_t fvp_mmap[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
CASSERT((sizeof(fvp_mmap)/sizeof(fvp_mmap[0])) + FVP_BL_REGIONS \
|
||||
CASSERT(ARRAY_SIZE(fvp_mmap) + FVP_BL_REGIONS \
|
||||
<= MAX_MMAP_REGIONS, assert_max_mmap_regions);
|
||||
|
||||
/* Array of secure interrupts to be configured by the gic driver */
|
||||
|
@ -132,9 +132,6 @@ const unsigned int irq_sec_array[] = {
|
|||
IRQ_SEC_SGI_7
|
||||
};
|
||||
|
||||
const unsigned int num_sec_irqs = sizeof(irq_sec_array) /
|
||||
sizeof(irq_sec_array[0]);
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro generating the code for the function setting up the pagetables as per
|
||||
* the platform memory map & initialize the mmu, for the given exception level
|
||||
|
@ -326,7 +323,7 @@ void fvp_gic_init(void)
|
|||
plat_config.gicd_base,
|
||||
BASE_GICR_BASE,
|
||||
irq_sec_array,
|
||||
num_sec_irqs);
|
||||
ARRAY_SIZE(irq_sec_array));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ static const mmap_region_t juno_mmap[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
CASSERT((sizeof(juno_mmap)/sizeof(juno_mmap[0])) + JUNO_BL_REGIONS \
|
||||
CASSERT(ARRAY_SIZE(juno_mmap) + JUNO_BL_REGIONS \
|
||||
<= MAX_MMAP_REGIONS, assert_max_mmap_regions);
|
||||
|
||||
/* Array of secure interrupts to be configured by the gic driver */
|
||||
|
@ -136,9 +136,6 @@ const unsigned int irq_sec_array[] = {
|
|||
IRQ_SEC_SGI_7
|
||||
};
|
||||
|
||||
const unsigned int num_sec_irqs = sizeof(irq_sec_array) /
|
||||
sizeof(irq_sec_array[0]);
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro generating the code for the function setting up the pagetables as per
|
||||
* the platform memory map & initialize the mmu, for the given exception level
|
||||
|
@ -211,5 +208,9 @@ uint64_t plat_get_syscnt_freq(void)
|
|||
|
||||
void plat_gic_init(void)
|
||||
{
|
||||
arm_gic_init(GICC_BASE, GICD_BASE, 0, irq_sec_array, num_sec_irqs);
|
||||
arm_gic_init(GICC_BASE,
|
||||
GICD_BASE,
|
||||
0,
|
||||
irq_sec_array,
|
||||
ARRAY_SIZE(irq_sec_array));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue