mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 17:44:19 +00:00

This patch mainly initializes the SPM and provides common APIs for SPM to enable the use of its various features. Signed-off-by: Wenzhen Yu <wenzhen.yu@mediatek.com> Change-Id: I9facb6bf9962bb2d5fcacd945846bfaeb4c87a55
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
/*
|
|
* Copyright (c) 2025, Mediatek Inc. All rights resrved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef MT_SPM_COMMON_H
|
|
#define MT_SPM_COMMON_H
|
|
|
|
#include <lib/bakery_lock.h>
|
|
#include <lib/spinlock.h>
|
|
/*
|
|
* ARM v8.2, the cache will turn off automatically when cpu
|
|
* power down. So, there is no doubt to use the spin_lock here
|
|
*/
|
|
#if !HW_ASSISTED_COHERENCY
|
|
#define MT_SPM_USING_BAKERY_LOCK
|
|
#endif
|
|
|
|
#ifdef MT_SPM_USING_BAKERY_LOCK
|
|
DECLARE_BAKERY_LOCK(spm_lock);
|
|
#define plat_spm_lock() \
|
|
bakery_lock_get(&spm_lock)
|
|
|
|
#define plat_spm_unlock() \
|
|
bakery_lock_release(&spm_lock)
|
|
#else
|
|
extern spinlock_t spm_lock;
|
|
#define plat_spm_lock() \
|
|
spin_lock(&spm_lock)
|
|
|
|
#define plat_spm_unlock() \
|
|
spin_unlock(&spm_lock)
|
|
#endif
|
|
|
|
#define MT_SPM_ERR_NO_FW_LOAD -1
|
|
#define MT_SPM_ERR_KICKED -2
|
|
#define MT_SPM_ERR_RUNNING -3
|
|
#define MT_SPM_ERR_FW_NOT_FOUND -4
|
|
#define MT_SPM_ERR_INVALID -5
|
|
#define MT_SPM_ERR_OVERFLOW -6
|
|
|
|
static inline void spm_lock_get(void)
|
|
{
|
|
plat_spm_lock();
|
|
}
|
|
|
|
static inline void spm_lock_release(void)
|
|
{
|
|
plat_spm_unlock();
|
|
}
|
|
|
|
#endif /* MT_SPM_COMMON_H */
|