mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-15 03:21:32 +00:00
Convert IRQ-related macros to static inline functions and introduce
wrappers for arch-specific implementations. This follows the style we
defined for multi-arch development.
This is a follow-up update for commit
a7239d126 ("[FIXME] hv: risc-v add denpended implementation in cpu.h").
CPU_IRQ_ENABLE_ON_CONFIG -> local_irq_enable
CPU_IRQ_DISABLE_ON_CONFIG -> local_irq_disable
CPU_INT_ALL_DISABLE -> local_irq_save
CPU_INT_ALL_RESTORE -> local_irq_restore
Tracked-On: #8813
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Yifan Liu <yifan1.liu@intel.com>
58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
/*
|
|
* Copyright (C) 2025 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef SPINLOCK_H
|
|
#define SPINLOCK_H
|
|
|
|
#ifndef ASSEMBLER
|
|
#include <types.h>
|
|
#include <rtl.h>
|
|
#include <cpu.h>
|
|
#include <asm/lib/spinlock.h>
|
|
|
|
/* The common spinlock type */
|
|
typedef arch_spinlock_t spinlock_t;
|
|
|
|
/* The mandatory functions should be implemented by arch spinlock library */
|
|
static inline void arch_spinlock_obtain(arch_spinlock_t *lock);
|
|
static inline void arch_spinlock_release(arch_spinlock_t *lock);
|
|
|
|
/* Function prototypes */
|
|
static inline void spinlock_init(spinlock_t *lock)
|
|
{
|
|
(void)memset(lock, 0U, sizeof(spinlock_t));
|
|
}
|
|
|
|
static inline void spinlock_irqsave_obtain(spinlock_t *lock, uint64_t * flags)
|
|
{
|
|
local_irq_save(flags);
|
|
arch_spinlock_obtain(lock);
|
|
}
|
|
|
|
static inline void spinlock_irqrestore_release(spinlock_t *lock, uint64_t flags)
|
|
{
|
|
arch_spinlock_release(lock);
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
static inline void spinlock_obtain(spinlock_t *lock)
|
|
{
|
|
return arch_spinlock_obtain(lock);
|
|
}
|
|
|
|
static inline void spinlock_release(spinlock_t *lock)
|
|
{
|
|
return arch_spinlock_release(lock);
|
|
}
|
|
|
|
#else /* ASSEMBLER */
|
|
#include <asm/lib/spinlock.h>
|
|
#define spinlock_obtain arch_spinlock_obtain
|
|
#define spinlock_release arch_spinlock_release
|
|
#endif /* ASSEMBLER */
|
|
|
|
#endif /* SPINLOCK_H */
|