YB_Platform/public/rtos/inc/spinlock.h

61 lines
947 B
C
Raw Normal View History

2023-07-13 11:27:03 +08:00
#ifndef KERNEL_API_INC_SPINLOCK_H_
#define KERNEL_API_INC_SPINLOCK_H_
#include <ucps2-intrin.h>
typedef enum
{
SLOCK_L3 = 0,
SLOCK_MAX = 16
}ape_spin_lock_index;
typedef struct{
union
{
unsigned int slock;
};
}spinlock_t;
#define APE_NR 12
typedef struct{
int spinlock_count;
int unspinlock_count;
int spinlock_loop;
}spin_db_info ;
typedef struct{
// spin_db_info spin_per_ape[APE_NR];
spin_db_info spin_per_ape;
}spin_debug_t;
extern int smart_spinlock_init(int lock_index);
extern void smart_spinlock(int lock_index);
extern void smart_spinunlock(int lock_index);
extern int smart_spin_debug_init(int debug_base_addr, int len_bytes);
static inline void smart_spinlock_irq(int lock)
{
__ucps2_IntEn(f_Disable);
smart_spinlock(lock);
}
static inline void smart_spinunlock_irqrestore(int lock)
{
smart_spinunlock(lock);
__ucps2_IntEn(f_Enable);
}
#endif /* KERNEL_API_INC_SPINLOCK_H_ */