mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-03 21:48:45 +00:00 
			
		
		
		
	The SBI FWFT extension defines a set of function that can be called to control the configuration of some platform features (misaligned trap delegation, etc). This patch implements sbi_fwft_set() and sbi_fwft_get() as defined in the specification [1]. Link: https://lists.riscv.org/g/tech-prs/message/924 [1] Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 *
 | 
						|
 * Copyright (c) 2024 Rivos Inc.
 | 
						|
 *
 | 
						|
 * Authors:
 | 
						|
 *   Clément Léger <cleger@rivosinc.com>
 | 
						|
 */
 | 
						|
 | 
						|
#include <sbi/sbi_ecall.h>
 | 
						|
#include <sbi/sbi_ecall_interface.h>
 | 
						|
#include <sbi/sbi_error.h>
 | 
						|
#include <sbi/sbi_fwft.h>
 | 
						|
#include <sbi/sbi_trap.h>
 | 
						|
 | 
						|
static int sbi_ecall_fwft_handler(unsigned long extid, unsigned long funcid,
 | 
						|
				 struct sbi_trap_regs *regs,
 | 
						|
				 struct sbi_ecall_return *out)
 | 
						|
{
 | 
						|
	int ret = 0;
 | 
						|
 | 
						|
	switch (funcid) {
 | 
						|
	case SBI_EXT_FWFT_SET:
 | 
						|
		ret = sbi_fwft_set(regs->a0, regs->a1, regs->a2);
 | 
						|
		break;
 | 
						|
	case SBI_EXT_FWFT_GET:
 | 
						|
		ret = sbi_fwft_get(regs->a0, &out->value);
 | 
						|
		break;
 | 
						|
	default:
 | 
						|
		ret = SBI_ENOTSUPP;
 | 
						|
		break;
 | 
						|
	}
 | 
						|
 | 
						|
	return ret;
 | 
						|
}
 | 
						|
 | 
						|
struct sbi_ecall_extension ecall_fwft;
 | 
						|
 | 
						|
static int sbi_ecall_fwft_register_extensions(void)
 | 
						|
{
 | 
						|
	return sbi_ecall_register_extension(&ecall_fwft);
 | 
						|
}
 | 
						|
 | 
						|
struct sbi_ecall_extension ecall_fwft = {
 | 
						|
	.extid_start = SBI_EXT_FWFT,
 | 
						|
	.extid_end = SBI_EXT_FWFT,
 | 
						|
	.register_extensions = sbi_ecall_fwft_register_extensions,
 | 
						|
	.handle = sbi_ecall_fwft_handler,
 | 
						|
};
 |