forked from Mirrors/opensbi
		
	lib: Add IPI extension in SBI
This patch adds new IPI extension which replaces ipi related v0.1 extensions. This also adds a new API for ipi sending as trap handling is not necessary in v0.2 SBI IPI related extensions. It also modifies the IPI sending code which now accepts hart mask as a value instead of S-mode virtual address. Thus, the caller should set it to exact hart mask value everytime. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
		@@ -95,4 +95,78 @@ static inline int __ffs(unsigned long word)
 | 
			
		||||
 */
 | 
			
		||||
#define ffz(x) __ffs(~(x))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * fls - find last (most-significant) bit set
 | 
			
		||||
 * @x: the word to search
 | 
			
		||||
 *
 | 
			
		||||
 * This is defined the same way as ffs.
 | 
			
		||||
 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static inline int fls(int x)
 | 
			
		||||
{
 | 
			
		||||
	int r = 32;
 | 
			
		||||
 | 
			
		||||
	if (!x)
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (!(x & 0xffff0000u)) {
 | 
			
		||||
		x <<= 16;
 | 
			
		||||
		r -= 16;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(x & 0xff000000u)) {
 | 
			
		||||
		x <<= 8;
 | 
			
		||||
		r -= 8;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(x & 0xf0000000u)) {
 | 
			
		||||
		x <<= 4;
 | 
			
		||||
		r -= 4;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(x & 0xc0000000u)) {
 | 
			
		||||
		x <<= 2;
 | 
			
		||||
		r -= 2;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(x & 0x80000000u)) {
 | 
			
		||||
		x <<= 1;
 | 
			
		||||
		r -= 1;
 | 
			
		||||
	}
 | 
			
		||||
	return r;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * __fls - find last (most-significant) set bit in a long word
 | 
			
		||||
 * @word: the word to search
 | 
			
		||||
 *
 | 
			
		||||
 * Undefined if no set bit exists, so code should check against 0 first.
 | 
			
		||||
 */
 | 
			
		||||
static inline unsigned long __fls(unsigned long word)
 | 
			
		||||
{
 | 
			
		||||
	int num = BITS_PER_LONG - 1;
 | 
			
		||||
 | 
			
		||||
#if BITS_PER_LONG == 64
 | 
			
		||||
	if (!(word & (~0ul << 32))) {
 | 
			
		||||
		num -= 32;
 | 
			
		||||
		word <<= 32;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
 | 
			
		||||
		num -= 16;
 | 
			
		||||
		word <<= 16;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
 | 
			
		||||
		num -= 8;
 | 
			
		||||
		word <<= 8;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
 | 
			
		||||
		num -= 4;
 | 
			
		||||
		word <<= 4;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
 | 
			
		||||
		num -= 2;
 | 
			
		||||
		word <<= 2;
 | 
			
		||||
	}
 | 
			
		||||
	if (!(word & (~0ul << (BITS_PER_LONG-1))))
 | 
			
		||||
		num -= 1;
 | 
			
		||||
	return num;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,8 @@ struct sbi_ipi_data {
 | 
			
		||||
	unsigned long ipi_type;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int sbi_ipi_send_many(struct sbi_scratch *scratch,
 | 
			
		||||
		      struct sbi_trap_info *uptrap,
 | 
			
		||||
		      ulong *pmask, u32 event, void *data);
 | 
			
		||||
int sbi_ipi_send_many(struct sbi_scratch *scratch, ulong hmask,
 | 
			
		||||
		      ulong hbase, u32 event, void *data);
 | 
			
		||||
 | 
			
		||||
void sbi_ipi_clear_smode(struct sbi_scratch *scratch);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user