mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-04 14:00:31 +00:00 
			
		
		
		
	We add simple bitmap library which will help us create and maintain bitmaps. It will also help us create a simple HART mask library. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
		
			
				
	
	
		
			41 lines
		
	
	
		
			856 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			856 B
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 *
 | 
						|
 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
 | 
						|
 *
 | 
						|
 * Authors:
 | 
						|
 *   Anup Patel <anup.patel@wdc.com>
 | 
						|
 */
 | 
						|
 | 
						|
#include <sbi/sbi_bitmap.h>
 | 
						|
 | 
						|
void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
 | 
						|
		  const unsigned long *bitmap2, int bits)
 | 
						|
{
 | 
						|
	int k;
 | 
						|
	int nr = BITS_TO_LONGS(bits);
 | 
						|
 | 
						|
	for (k = 0; k < nr; k++)
 | 
						|
		dst[k] = bitmap1[k] & bitmap2[k];
 | 
						|
}
 | 
						|
 | 
						|
void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
 | 
						|
		 const unsigned long *bitmap2, int bits)
 | 
						|
{
 | 
						|
	int k;
 | 
						|
	int nr = BITS_TO_LONGS(bits);
 | 
						|
 | 
						|
	for (k = 0; k < nr; k++)
 | 
						|
		dst[k] = bitmap1[k] | bitmap2[k];
 | 
						|
}
 | 
						|
 | 
						|
void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
 | 
						|
		  const unsigned long *bitmap2, int bits)
 | 
						|
{
 | 
						|
	int k;
 | 
						|
	int nr = BITS_TO_LONGS(bits);
 | 
						|
 | 
						|
	for (k = 0; k < nr; k++)
 | 
						|
		dst[k] = bitmap1[k] ^ bitmap2[k];
 | 
						|
}
 |