No functional changes.
Change-Id: I2f28f20944f552447ac4e9e755493cd7c0ea1192
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __CPUAMU_H__
-#define __CPUAMU_H__
+#ifndef CPUAMU_H
+#define CPUAMU_H
/*******************************************************************************
* CPU Activity Monitor Unit register specific definitions.
#ifndef __ASSEMBLY__
#include <stdint.h>
-uint64_t cpuamu_cnt_read(int idx);
-void cpuamu_cnt_write(int idx, uint64_t val);
+uint64_t cpuamu_cnt_read(unsigned int idx);
+void cpuamu_cnt_write(unsigned int idx, uint64_t val);
unsigned int cpuamu_read_cpuamcntenset_el0(void);
unsigned int cpuamu_read_cpuamcntenclr_el0(void);
void cpuamu_write_cpuamcntenset_el0(unsigned int mask);
#endif /* __ASSEMBLY__ */
-#endif /* __CPUAMU_H__ */
+#endif /* CPUAMU_H */
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __AMU_H__
-#define __AMU_H__
+#ifndef AMU_H
+#define AMU_H
#include <cassert.h>
#include <platform_def.h>
+#include <stdbool.h>
#include <stdint.h>
+#include <utils_def.h>
/* All group 0 counters */
-#define AMU_GROUP0_COUNTERS_MASK 0xf
+#define AMU_GROUP0_COUNTERS_MASK U(0xf)
#ifdef PLAT_AMU_GROUP1_COUNTERS_MASK
#define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK
#else
-#define AMU_GROUP1_COUNTERS_MASK 0
+#define AMU_GROUP1_COUNTERS_MASK U(0)
#endif
#ifdef PLAT_AMU_GROUP1_NR_COUNTERS
#define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS
#else
-#define AMU_GROUP1_NR_COUNTERS 0
+#define AMU_GROUP1_NR_COUNTERS U(0)
#endif
CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask);
CASSERT(AMU_GROUP1_NR_COUNTERS <= 16, invalid_amu_group1_nr_counters);
-int amu_supported(void);
-void amu_enable(int el2_unused);
+bool amu_supported(void);
+void amu_enable(bool el2_unused);
/* Group 0 configuration helpers */
uint64_t amu_group0_cnt_read(int idx);
void amu_group1_cnt_write(int idx, uint64_t val);
void amu_group1_set_evtype(int idx, unsigned int val);
-#endif /* __AMU_H__ */
+#endif /* AMU_H */
/*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __AMU_PRIVATE_H__
-#define __AMU_PRIVATE_H__
+#ifndef AMU_PRIVATE_H
+#define AMU_PRIVATE_H
#include <stdint.h>
uint64_t amu_group0_cnt_read_internal(int idx);
-void amu_group0_cnt_write_internal(int idx, uint64_t);
+void amu_group0_cnt_write_internal(int idx, uint64_t val);
uint64_t amu_group1_cnt_read_internal(int idx);
-void amu_group1_cnt_write_internal(int idx, uint64_t);
+void amu_group1_cnt_write_internal(int idx, uint64_t val);
void amu_group1_set_evtype_internal(int idx, unsigned int val);
-#endif /* __AMU_PRIVATE_H__ */
+#endif /* AMU_PRIVATE_H */
#include <stdbool.h>
bool mpam_supported(void);
-void mpam_enable(int el2_unused);
+void mpam_enable(bool el2_unused);
#endif /* MPAM_H */
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __SPE_H__
-#define __SPE_H__
+#ifndef SPE_H
+#define SPE_H
-int spe_supported(void);
-void spe_enable(int el2_unused);
+#include <stdbool.h>
+
+bool spe_supported(void);
+void spe_enable(bool el2_unused);
void spe_disable(void);
-#endif /* __SPE_H__ */
+#endif /* SPE_H */
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __SVE_H__
-#define __SVE_H__
+#ifndef SVE_H
+#define SVE_H
-int sve_supported(void);
-void sve_enable(int el2_unused);
+#include <stdbool.h>
-#endif /* __SVE_H__ */
+bool sve_supported(void);
+void sve_enable(bool el2_unused);
+
+#endif /* SVE_H */
.globl cpuamu_write_cpuamcntenclr_el0
/*
- * uint64_t cpuamu_cnt_read(int idx);
+ * uint64_t cpuamu_cnt_read(unsigned int idx);
*
* Given `idx`, read the corresponding AMU counter
* and return it in `x0`.
endfunc cpuamu_cnt_read
/*
- * void cpuamu_cnt_write(int idx, uint64_t val);
+ * void cpuamu_cnt_write(unsigned int idx, uint64_t val);
*
* Given `idx`, write `val` to the corresponding AMU counter.
*/
#include <platform.h>
#include <platform_def.h>
#include <smccc_helpers.h>
+#include <stdbool.h>
#include <string.h>
#include <utils.h>
* When EL2 is implemented but unused `el2_unused` is non-zero, otherwise
* it is zero.
******************************************************************************/
-static void enable_extensions_nonsecure(int el2_unused)
+static void enable_extensions_nonsecure(bool el2_unused)
{
#if IMAGE_BL32
#if ENABLE_AMU
{
uint32_t hsctlr, scr;
cpu_context_t *ctx = cm_get_context(security_state);
- int el2_unused = 0;
+ bool el2_unused = false;
assert(ctx);
isb();
} else if (read_id_pfr1() &
(ID_PFR1_VIRTEXT_MASK << ID_PFR1_VIRTEXT_SHIFT)) {
- el2_unused = 1;
+ el2_unused = true;
/*
* Set the NS bit to access NS copies of certain banked
#include <pubsub_events.h>
#include <smccc_helpers.h>
#include <spe.h>
+#include <stdbool.h>
#include <string.h>
#include <sve.h>
#include <utils.h>
* When EL2 is implemented but unused `el2_unused` is non-zero, otherwise
* it is zero.
******************************************************************************/
-static void enable_extensions_nonsecure(int el2_unused)
+static void enable_extensions_nonsecure(bool el2_unused)
{
#if IMAGE_BL31
#if ENABLE_SPE_FOR_LOWER_ELS
{
uint32_t sctlr_elx, scr_el3, mdcr_el2;
cpu_context_t *ctx = cm_get_context(security_state);
- int el2_unused = 0;
+ bool el2_unused = false;
uint64_t hcr_el2 = 0;
assert(ctx);
sctlr_elx |= SCTLR_EL2_RES1;
write_sctlr_el2(sctlr_elx);
} else if (EL_IMPLEMENTED(2)) {
- el2_unused = 1;
+ el2_unused = true;
/*
* EL2 present but unused, need to disable safely.
#include <arch_helpers.h>
#include <platform.h>
#include <pubsub_events.h>
+#include <stdbool.h>
#define AMU_GROUP0_NR_COUNTERS 4
static struct amu_ctx amu_ctxs[PLATFORM_CORE_COUNT];
-int amu_supported(void)
+bool amu_supported(void)
{
uint64_t features;
features = read_id_pfr0() >> ID_PFR0_AMU_SHIFT;
- return (features & ID_PFR0_AMU_MASK) == 1;
+ return (features & ID_PFR0_AMU_MASK) == 1U;
}
-void amu_enable(int el2_unused)
+void amu_enable(bool el2_unused)
{
- if (amu_supported() == 0)
+ if (!amu_supported())
return;
if (el2_unused) {
/* Read the group 0 counter identified by the given `idx`. */
uint64_t amu_group0_cnt_read(int idx)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP0_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP0_NR_COUNTERS));
return amu_group0_cnt_read_internal(idx);
}
/* Write the group 0 counter identified by the given `idx` with `val`. */
void amu_group0_cnt_write(int idx, uint64_t val)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP0_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP0_NR_COUNTERS));
amu_group0_cnt_write_internal(idx, val);
isb();
/* Read the group 1 counter identified by the given `idx`. */
uint64_t amu_group1_cnt_read(int idx)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
return amu_group1_cnt_read_internal(idx);
}
/* Write the group 1 counter identified by the given `idx` with `val`. */
void amu_group1_cnt_write(int idx, uint64_t val)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
amu_group1_cnt_write_internal(idx, val);
isb();
void amu_group1_set_evtype(int idx, unsigned int val)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
amu_group1_set_evtype_internal(idx, val);
isb();
struct amu_ctx *ctx;
int i;
- if (amu_supported() == 0)
+ if (!amu_supported())
return (void *)-1;
ctx = &amu_ctxs[plat_my_core_pos()];
for (i = 0; i < AMU_GROUP1_NR_COUNTERS; i++)
ctx->group1_cnts[i] = amu_group1_cnt_read(i);
- return 0;
+ return (void *)0;
}
static void *amu_context_restore(const void *arg)
struct amu_ctx *ctx;
int i;
- if (amu_supported() == 0)
+ if (!amu_supported())
return (void *)-1;
ctx = &amu_ctxs[plat_my_core_pos()];
/* Counters were disabled in `amu_context_save()` */
- assert(read_amcntenset0() == 0 && read_amcntenset1() == 0);
+ assert((read_amcntenset0() == 0U) && (read_amcntenset1() == 0U));
/* Restore group 0 counters */
for (i = 0; i < AMU_GROUP0_NR_COUNTERS; i++)
/* Enable group 1 counters */
write_amcntenset1(AMU_GROUP1_COUNTERS_MASK);
- return 0;
+ return (void *)0;
}
SUBSCRIBE_TO_EVENT(psci_suspend_pwrdown_start, amu_context_save);
#include <assert.h>
#include <platform.h>
#include <pubsub_events.h>
+#include <stdbool.h>
#define AMU_GROUP0_NR_COUNTERS 4
static struct amu_ctx amu_ctxs[PLATFORM_CORE_COUNT];
-int amu_supported(void)
+bool amu_supported(void)
{
uint64_t features;
features = read_id_aa64pfr0_el1() >> ID_AA64PFR0_AMU_SHIFT;
- return (features & ID_AA64PFR0_AMU_MASK) == 1;
+ return (features & ID_AA64PFR0_AMU_MASK) == 1U;
}
/*
* Enable counters. This function is meant to be invoked
* by the context management library before exiting from EL3.
*/
-void amu_enable(int el2_unused)
+void amu_enable(bool el2_unused)
{
uint64_t v;
- if (amu_supported() == 0)
+ if (!amu_supported())
return;
if (el2_unused) {
/* Read the group 0 counter identified by the given `idx`. */
uint64_t amu_group0_cnt_read(int idx)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP0_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP0_NR_COUNTERS));
return amu_group0_cnt_read_internal(idx);
}
/* Write the group 0 counter identified by the given `idx` with `val`. */
void amu_group0_cnt_write(int idx, uint64_t val)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP0_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP0_NR_COUNTERS));
amu_group0_cnt_write_internal(idx, val);
isb();
/* Read the group 1 counter identified by the given `idx`. */
uint64_t amu_group1_cnt_read(int idx)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
return amu_group1_cnt_read_internal(idx);
}
/* Write the group 1 counter identified by the given `idx` with `val`. */
void amu_group1_cnt_write(int idx, uint64_t val)
{
- assert(amu_supported() != 0);
- assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
amu_group1_cnt_write_internal(idx, val);
isb();
*/
void amu_group1_set_evtype(int idx, unsigned int val)
{
- assert(amu_supported() != 0);
- assert (idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
+ assert(amu_supported());
+ assert((idx >= 0) && (idx < AMU_GROUP1_NR_COUNTERS));
amu_group1_set_evtype_internal(idx, val);
isb();
struct amu_ctx *ctx = &amu_ctxs[plat_my_core_pos()];
int i;
- if (amu_supported() == 0)
+ if (!amu_supported())
return (void *)-1;
/* Assert that group 0/1 counter configuration is what we expect */
- assert(read_amcntenset0_el0() == AMU_GROUP0_COUNTERS_MASK &&
- read_amcntenset1_el0() == AMU_GROUP1_COUNTERS_MASK);
+ assert((read_amcntenset0_el0() == AMU_GROUP0_COUNTERS_MASK) &&
+ (read_amcntenset1_el0() == AMU_GROUP1_COUNTERS_MASK));
- assert((sizeof(int) * 8) - __builtin_clz(AMU_GROUP1_COUNTERS_MASK)
+ assert(((sizeof(int) * 8) - __builtin_clz(AMU_GROUP1_COUNTERS_MASK))
<= AMU_GROUP1_NR_COUNTERS);
/*
for (i = 0; i < AMU_GROUP1_NR_COUNTERS; i++)
ctx->group1_cnts[i] = amu_group1_cnt_read(i);
- return 0;
+ return (void *)0;
}
static void *amu_context_restore(const void *arg)
struct amu_ctx *ctx = &amu_ctxs[plat_my_core_pos()];
int i;
- if (amu_supported() == 0)
+ if (!amu_supported())
return (void *)-1;
/* Counters were disabled in `amu_context_save()` */
- assert(read_amcntenset0_el0() == 0 && read_amcntenset1_el0() == 0);
+ assert((read_amcntenset0_el0() == 0U) && (read_amcntenset1_el0() == 0U));
- assert((sizeof(int) * 8) - __builtin_clz(AMU_GROUP1_COUNTERS_MASK)
+ assert(((sizeof(int) * 8U) - __builtin_clz(AMU_GROUP1_COUNTERS_MASK))
<= AMU_GROUP1_NR_COUNTERS);
/* Restore group 0 counters */
for (i = 0; i < AMU_GROUP0_NR_COUNTERS; i++)
- if (AMU_GROUP0_COUNTERS_MASK & (1U << i))
+ if ((AMU_GROUP0_COUNTERS_MASK & (1U << i)) != 0U)
amu_group0_cnt_write(i, ctx->group0_cnts[i]);
/* Restore group 1 counters */
for (i = 0; i < AMU_GROUP1_NR_COUNTERS; i++)
- if (AMU_GROUP1_COUNTERS_MASK & (1U << i))
+ if ((AMU_GROUP1_COUNTERS_MASK & (1U << i)) != 0U)
amu_group1_cnt_write(i, ctx->group1_cnts[i]);
/* Restore group 0/1 counter configuration */
write_amcntenset0_el0(AMU_GROUP0_COUNTERS_MASK);
write_amcntenset1_el0(AMU_GROUP1_COUNTERS_MASK);
- return 0;
+ return (void *)0;
}
SUBSCRIBE_TO_EVENT(psci_suspend_pwrdown_start, amu_context_save);
return ((features & ID_AA64PFR0_MPAM_MASK) != 0U);
}
-void mpam_enable(int el2_unused)
+void mpam_enable(bool el2_unused)
{
if (!mpam_supported())
return;
* If EL2 is implemented but unused, disable trapping to EL2 when lower
* ELs access their own MPAM registers.
*/
- if (el2_unused != 0) {
+ if (el2_unused) {
write_mpam2_el2(0);
if ((read_mpamidr_el1() & MPAMIDR_HAS_HCR_BIT) != 0U)
#include <arch_helpers.h>
#include <pubsub.h>
#include <spe.h>
+#include <stdbool.h>
-/*
- * The assembler does not yet understand the psb csync mnemonic
- * so use the equivalent hint instruction.
- */
-#define psb_csync() asm volatile("hint #17")
+static inline void psb_csync(void)
+{
+ /*
+ * The assembler does not yet understand the psb csync mnemonic
+ * so use the equivalent hint instruction.
+ */
+ __asm__ volatile("hint #17");
+}
-int spe_supported(void)
+bool spe_supported(void)
{
uint64_t features;
features = read_id_aa64dfr0_el1() >> ID_AA64DFR0_PMS_SHIFT;
- return (features & ID_AA64DFR0_PMS_MASK) == 1;
+ return (features & ID_AA64DFR0_PMS_MASK) == 1U;
}
-void spe_enable(int el2_unused)
+void spe_enable(bool el2_unused)
{
uint64_t v;
- if (spe_supported() == 0)
+ if (!spe_supported())
return;
if (el2_unused) {
{
uint64_t v;
- if (spe_supported() == 0)
+ if (!spe_supported())
return;
/* Drain buffered data */
static void *spe_drain_buffers_hook(const void *arg)
{
- if (spe_supported() == 0)
+ if (!spe_supported())
return (void *)-1;
/* Drain buffered data */
psb_csync();
dsbnsh();
- return 0;
+
+ return (void *)0;
}
SUBSCRIBE_TO_EVENT(cm_entering_secure_world, spe_drain_buffers_hook);
#include <arch.h>
#include <arch_helpers.h>
#include <pubsub.h>
+#include <stdbool.h>
#include <sve.h>
-int sve_supported(void)
+bool sve_supported(void)
{
uint64_t features;
features = read_id_aa64pfr0_el1() >> ID_AA64PFR0_SVE_SHIFT;
- return (features & ID_AA64PFR0_SVE_MASK) == 1;
+ return (features & ID_AA64PFR0_SVE_MASK) == 1U;
}
static void *disable_sve_hook(const void *arg)
{
uint64_t cptr;
- if (sve_supported() == 0)
+ if (!sve_supported())
return (void *)-1;
/*
* No explicit ISB required here as ERET to switch to Secure
* world covers it
*/
- return 0;
+ return (void *)0;
}
static void *enable_sve_hook(const void *arg)
{
uint64_t cptr;
- if (sve_supported() == 0)
+ if (!sve_supported())
return (void *)-1;
/*
* No explicit ISB required here as ERET to switch to Non-secure
* world covers it
*/
- return 0;
+ return (void *)0;
}
-void sve_enable(int el2_unused)
+void sve_enable(bool el2_unused)
{
uint64_t cptr;
- if (sve_supported() == 0)
+ if (!sve_supported())
return;
#if CTX_INCLUDE_FPREGS