From e6381f9cf8c0c62c32d5a4765aaf166f50786914 Mon Sep 17 00:00:00 2001 From: John Powell Date: Thu, 12 May 2022 12:49:55 -0500 Subject: [PATCH] feat(sdei): add a function to return total number of events registered This patch adds a public API to return the total number of registered events. The purpose of this is primarily for DRTM to ensure that no SDEI event can interfere with a dynamic launch. Signed-off-by: John Powell Change-Id: I1d1cba2da7d5566cc340620ee1ce7d7844740b86 --- include/services/sdei.h | 5 ++++- services/std_svc/sdei/sdei_event.c | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/services/sdei.h b/include/services/sdei.h index 063ed6f28..c12a182f0 100644 --- a/include/services/sdei.h +++ b/include/services/sdei.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -137,4 +137,7 @@ void sdei_init(void); /* Public API to dispatch an event to Normal world */ int sdei_dispatch_event(int ev_num); +/* Public API to check how many SDEI events are registered. */ +int sdei_get_registered_event_count(void); + #endif /* SDEI_H */ diff --git a/services/std_svc/sdei/sdei_event.c b/services/std_svc/sdei/sdei_event.c index 0b608e1b6..e0c7971ac 100644 --- a/services/std_svc/sdei/sdei_event.c +++ b/services/std_svc/sdei/sdei_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -99,3 +99,24 @@ sdei_ev_map_t *find_event_map(int ev_num) return NULL; } + +/* + * Return the total number of currently registered SDEI events. + */ +int sdei_get_registered_event_count(void) +{ + const sdei_mapping_t *mapping; + sdei_ev_map_t *map; + unsigned int i; + unsigned int j; + int count = 0; + + /* Add up reg counts for each mapping. */ + for_each_mapping_type(i, mapping) { + iterate_mapping(mapping, j, map) { + count += map->reg_count; + } + } + + return count; +} -- 2.39.5