mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-03 21:48:45 +00:00 
			
		
		
		
	lib: Introduce SBI_TLB_INFO_INIT() helper macro
We introduce SBI_TLB_INFO_INIT() helper macro to help easy initialization of struct sbi_tlb_info which is passed to the sbi_tlb_request() API. 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>
This commit is contained in:
		
							parent
							
								
									d6d7e18d1d
								
							
						
					
					
						commit
						a4a6a81b7d
					
				@ -41,7 +41,16 @@ struct sbi_tlb_info {
 | 
			
		||||
	unsigned long shart_mask;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define SBI_TLB_INFO_SIZE			sizeof(struct sbi_tlb_info)
 | 
			
		||||
#define SBI_TLB_INFO_INIT(__ptr, __start, __size, __asid, __type, __src_hart) \
 | 
			
		||||
do { \
 | 
			
		||||
	(__ptr)->start = (__start); \
 | 
			
		||||
	(__ptr)->size = (__size); \
 | 
			
		||||
	(__ptr)->asid = (__asid); \
 | 
			
		||||
	(__ptr)->type = (__type); \
 | 
			
		||||
	(__ptr)->shart_mask = 1UL << (__src_hart); \
 | 
			
		||||
} while (0)
 | 
			
		||||
 | 
			
		||||
#define SBI_TLB_INFO_SIZE		sizeof(struct sbi_tlb_info)
 | 
			
		||||
 | 
			
		||||
int sbi_tlb_request(struct sbi_scratch *scratch, ulong hmask,
 | 
			
		||||
		    ulong hbase, struct sbi_tlb_info *tinfo);
 | 
			
		||||
 | 
			
		||||
@ -72,35 +72,31 @@ static int sbi_ecall_legacy_handler(struct sbi_scratch *scratch,
 | 
			
		||||
			ret = sbi_ipi_send_smode(scratch, hmask, 0);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_REMOTE_FENCE_I:
 | 
			
		||||
		tlb_info.start  = 0;
 | 
			
		||||
		tlb_info.size  = 0;
 | 
			
		||||
		tlb_info.type  = SBI_ITLB_FLUSH;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0],
 | 
			
		||||
						&hmask, out_trap);
 | 
			
		||||
		if (ret != SBI_ETRAP)
 | 
			
		||||
		if (ret != SBI_ETRAP) {
 | 
			
		||||
			SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0,
 | 
			
		||||
					  SBI_ITLB_FLUSH, source_hart);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_REMOTE_SFENCE_VMA:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[1];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VMA;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0],
 | 
			
		||||
						&hmask, out_trap);
 | 
			
		||||
		if (ret != SBI_ETRAP)
 | 
			
		||||
		if (ret != SBI_ETRAP) {
 | 
			
		||||
			SBI_TLB_INFO_INIT(&tlb_info, args[1], args[2], 0,
 | 
			
		||||
					  SBI_TLB_FLUSH_VMA, source_hart);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[1];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.asid  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VMA_ASID;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		ret = sbi_load_hart_mask_unpriv(scratch, (ulong *)args[0],
 | 
			
		||||
						&hmask, out_trap);
 | 
			
		||||
		if (ret != SBI_ETRAP)
 | 
			
		||||
		if (ret != SBI_ETRAP) {
 | 
			
		||||
			SBI_TLB_INFO_INIT(&tlb_info, args[1], args[2], args[3],
 | 
			
		||||
					  SBI_TLB_FLUSH_VMA_ASID, source_hart);
 | 
			
		||||
			ret = sbi_tlb_request(scratch, hmask, 0, &tlb_info);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_0_1_SHUTDOWN:
 | 
			
		||||
		sbi_system_shutdown(scratch, 0);
 | 
			
		||||
 | 
			
		||||
@ -59,58 +59,40 @@ static int sbi_ecall_rfence_handler(struct sbi_scratch *scratch,
 | 
			
		||||
 | 
			
		||||
	switch (funcid) {
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_FENCE_I:
 | 
			
		||||
		tlb_info.start  = 0;
 | 
			
		||||
		tlb_info.size  = 0;
 | 
			
		||||
		tlb_info.type  = SBI_ITLB_FLUSH;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0,
 | 
			
		||||
				  SBI_ITLB_FLUSH, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_GVMA;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], 0,
 | 
			
		||||
				  SBI_TLB_FLUSH_GVMA, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.asid  = (unsigned long)args[4];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_GVMA_VMID;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], args[4],
 | 
			
		||||
				  SBI_TLB_FLUSH_GVMA_VMID, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VVMA;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], 0,
 | 
			
		||||
				  SBI_TLB_FLUSH_VVMA, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.asid  = (unsigned long)args[4];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VVMA_ASID;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], args[4],
 | 
			
		||||
				  SBI_TLB_FLUSH_VVMA_ASID, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VMA;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], 0,
 | 
			
		||||
				  SBI_TLB_FLUSH_VMA, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
	case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID:
 | 
			
		||||
		tlb_info.start = (unsigned long)args[2];
 | 
			
		||||
		tlb_info.size  = (unsigned long)args[3];
 | 
			
		||||
		tlb_info.asid  = (unsigned long)args[4];
 | 
			
		||||
		tlb_info.type  = SBI_TLB_FLUSH_VMA_ASID;
 | 
			
		||||
		tlb_info.shart_mask = 1UL << source_hart;
 | 
			
		||||
		SBI_TLB_INFO_INIT(&tlb_info, args[2], args[3], args[4],
 | 
			
		||||
				  SBI_TLB_FLUSH_VMA_ASID, source_hart);
 | 
			
		||||
		ret = sbi_tlb_request(scratch, args[0], args[1], &tlb_info);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		ret = SBI_ENOTSUPP;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user