mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-26 06:50:10 +00:00

Enforce full include path for includes. Deprecate old paths. The following folders inside include/lib have been left unchanged: - include/lib/cpus/${ARCH} - include/lib/el3_runtime/${ARCH} The reason for this change is that having a global namespace for includes isn't a good idea. It defeats one of the advantages of having folders and it introduces problems that are sometimes subtle (because you may not know the header you are actually including if there are two of them). For example, this patch had to be created because two headers were called the same way:e0ea0928d5
("Fix gpio includes of mt8173 platform to avoid collision."). More recently, this patch has had similar problems:46f9b2c3a2
("drivers: add tzc380 support"). This problem was introduced in commit4ecca33988
("Move include and source files to logical locations"). At that time, there weren't too many headers so it wasn't a real issue. However, time has shown that this creates problems. Platforms that want to preserve the way they include headers may add the removed paths to PLAT_INCLUDES, but this is discouraged. Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
105 lines
2.8 KiB
C
105 lines
2.8 KiB
C
/*
|
|
* Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef BAKERY_LOCK_H
|
|
#define BAKERY_LOCK_H
|
|
|
|
#include <platform_def.h>
|
|
|
|
#define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT
|
|
|
|
#ifndef __ASSEMBLY__
|
|
#include <cdefs.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include <lib/utils_def.h>
|
|
|
|
/*****************************************************************************
|
|
* Internal helpers used by the bakery lock implementation.
|
|
****************************************************************************/
|
|
|
|
/* Convert a ticket to priority */
|
|
static inline unsigned int bakery_get_priority(unsigned int t, unsigned int pos)
|
|
{
|
|
return (t << 8) | pos;
|
|
}
|
|
|
|
#define CHOOSING_TICKET U(0x1)
|
|
#define CHOSEN_TICKET U(0x0)
|
|
|
|
static inline bool bakery_is_choosing(unsigned int info)
|
|
{
|
|
return (info & 1U) == CHOOSING_TICKET;
|
|
}
|
|
|
|
static inline unsigned int bakery_ticket_number(unsigned int info)
|
|
{
|
|
return (info >> 1) & 0x7FFFU;
|
|
}
|
|
|
|
static inline uint16_t make_bakery_data(unsigned int choosing, unsigned int num)
|
|
{
|
|
unsigned int val = (choosing & 0x1U) | (num << 1);
|
|
|
|
return (uint16_t) val;
|
|
}
|
|
|
|
/*****************************************************************************
|
|
* External bakery lock interface.
|
|
****************************************************************************/
|
|
#if USE_COHERENT_MEM
|
|
/*
|
|
* Bakery locks are stored in coherent memory
|
|
*
|
|
* Each lock's data is contiguous and fully allocated by the compiler
|
|
*/
|
|
|
|
typedef struct bakery_lock {
|
|
/*
|
|
* The lock_data is a bit-field of 2 members:
|
|
* Bit[0] : choosing. This field is set when the CPU is
|
|
* choosing its bakery number.
|
|
* Bits[1 - 15] : number. This is the bakery number allocated.
|
|
*/
|
|
volatile uint16_t lock_data[BAKERY_LOCK_MAX_CPUS];
|
|
} bakery_lock_t;
|
|
|
|
#else
|
|
/*
|
|
* Bakery locks are stored in normal .bss memory
|
|
*
|
|
* Each lock's data is spread across multiple cache lines, one per CPU,
|
|
* but multiple locks can share the same cache line.
|
|
* The compiler will allocate enough memory for one CPU's bakery locks,
|
|
* the remaining cache lines are allocated by the linker script
|
|
*/
|
|
|
|
typedef struct bakery_info {
|
|
/*
|
|
* The lock_data is a bit-field of 2 members:
|
|
* Bit[0] : choosing. This field is set when the CPU is
|
|
* choosing its bakery number.
|
|
* Bits[1 - 15] : number. This is the bakery number allocated.
|
|
*/
|
|
volatile uint16_t lock_data;
|
|
} bakery_info_t;
|
|
|
|
typedef bakery_info_t bakery_lock_t;
|
|
|
|
#endif /* __USE_COHERENT_MEM__ */
|
|
|
|
static inline void bakery_lock_init(bakery_lock_t *bakery) {}
|
|
void bakery_lock_get(bakery_lock_t *bakery);
|
|
void bakery_lock_release(bakery_lock_t *bakery);
|
|
|
|
#define DEFINE_BAKERY_LOCK(_name) bakery_lock_t _name __section("bakery_lock")
|
|
|
|
#define DECLARE_BAKERY_LOCK(_name) extern bakery_lock_t _name
|
|
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
#endif /* BAKERY_LOCK_H */
|