aboutsummaryrefslogtreecommitdiffstats
path: root/include/lib/psci
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-07-18 11:57:21 +0100
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-07-20 13:27:31 +0100
commit97373c33b70725daf58e4491831537392c0d5239 (patch)
tree9a72bc5da7c6145a5cc89674dd102e3e7beb161e /include/lib/psci
parentf00119de5760d5ed876c17884654da14b877386d (diff)
downloadplatform_external_arm-trusted-firmware-97373c33b70725daf58e4491831537392c0d5239.tar.gz
platform_external_arm-trusted-firmware-97373c33b70725daf58e4491831537392c0d5239.tar.bz2
platform_external_arm-trusted-firmware-97373c33b70725daf58e4491831537392c0d5239.zip
PSCI: Replace macros by static inline functions
Fix MISRA C-2012 Directive 4.9 and Rule 21.1 defects. Change-Id: I96c216317d38741ee632d2640cd7b36e6723d5c2 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'include/lib/psci')
-rw-r--r--include/lib/psci/psci.h70
1 files changed, 46 insertions, 24 deletions
diff --git a/include/lib/psci/psci.h b/include/lib/psci/psci.h
index 06434f9e5..1aa963327 100644
--- a/include/lib/psci/psci.h
+++ b/include/lib/psci/psci.h
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __PSCI_H__
-#define __PSCI_H__
+#ifndef PSCI_H
+#define PSCI_H
#include <bakery_lock.h>
#include <bl_common.h>
@@ -71,9 +71,6 @@
#define PSCI_MEM_CHK_RANGE_AARCH32 U(0x84000014)
#define PSCI_MEM_CHK_RANGE_AARCH64 U(0xc4000014)
-/* Macro to help build the psci capabilities bitfield */
-#define define_psci_cap(x) (U(1) << (x & U(0x1f)))
-
/*
* Number of PSCI calls (above) implemented
*/
@@ -124,12 +121,6 @@
#define PSTATE_TYPE_POWERDOWN U(0x1)
#define PSTATE_TYPE_MASK U(0x1)
-#define psci_get_pstate_id(pstate) (((pstate) >> PSTATE_ID_SHIFT) & \
- PSTATE_ID_MASK)
-#define psci_get_pstate_type(pstate) (((pstate) >> PSTATE_TYPE_SHIFT) & \
- PSTATE_TYPE_MASK)
-#define psci_check_power_state(pstate) ((pstate) & PSTATE_VALID_MASK)
-
/*******************************************************************************
* PSCI CPU_FEATURES feature flag specific defines
******************************************************************************/
@@ -182,6 +173,31 @@
#include <stdint.h>
#include <types.h>
+/* Function to help build the psci capabilities bitfield */
+
+static inline unsigned int define_psci_cap(unsigned int x)
+{
+ return U(1) << (x & U(0x1f));
+}
+
+
+/* Power state helper functions */
+
+static inline unsigned int psci_get_pstate_id(unsigned int power_state)
+{
+ return ((power_state) >> PSTATE_ID_SHIFT) & PSTATE_ID_MASK;
+}
+
+static inline unsigned int psci_get_pstate_type(unsigned int power_state)
+{
+ return ((power_state) >> PSTATE_TYPE_SHIFT) & PSTATE_TYPE_MASK;
+}
+
+static inline unsigned int psci_check_power_state(unsigned int power_state)
+{
+ return ((power_state) & PSTATE_VALID_MASK);
+}
+
/*
* These are the states reported by the PSCI_AFFINITY_INFO API for the specified
* CPU. The definitions of these states can be found in Section 5.7.1 in the
@@ -218,24 +234,30 @@ typedef uint8_t plat_local_state_t;
#define PSCI_LOCAL_STATE_RUN U(0)
/*
- * Macro to test whether the plat_local_state is RUN state
+ * Function to test whether the plat_local_state is RUN state
*/
-#define is_local_state_run(plat_local_state) \
- ((plat_local_state) == PSCI_LOCAL_STATE_RUN)
+static inline int is_local_state_run(unsigned int plat_local_state)
+{
+ return (plat_local_state == PSCI_LOCAL_STATE_RUN) ? 1 : 0;
+}
/*
- * Macro to test whether the plat_local_state is RETENTION state
+ * Function to test whether the plat_local_state is RETENTION state
*/
-#define is_local_state_retn(plat_local_state) \
- (((plat_local_state) > PSCI_LOCAL_STATE_RUN) && \
- ((plat_local_state) <= PLAT_MAX_RET_STATE))
+static inline int is_local_state_retn(unsigned int plat_local_state)
+{
+ return ((plat_local_state > PSCI_LOCAL_STATE_RUN) &&
+ (plat_local_state <= PLAT_MAX_RET_STATE)) ? 1 : 0;
+}
/*
- * Macro to test whether the plat_local_state is OFF state
+ * Function to test whether the plat_local_state is OFF state
*/
-#define is_local_state_off(plat_local_state) \
- (((plat_local_state) > PLAT_MAX_RET_STATE) && \
- ((plat_local_state) <= PLAT_MAX_OFF_STATE))
+static inline int is_local_state_off(unsigned int plat_local_state)
+{
+ return ((plat_local_state > PLAT_MAX_RET_STATE) &&
+ (plat_local_state <= PLAT_MAX_OFF_STATE)) ? 1 : 0;
+}
/*****************************************************************************
* This data structure defines the representation of the power state parameter
@@ -339,4 +361,4 @@ void psci_entrypoint(void) __deprecated;
#endif /*__ASSEMBLY__*/
-#endif /* __PSCI_H__ */
+#endif /* PSCI_H */