arch/riscv/kernel/sbi.c

Source file repositories/reference/linux-study-clean/arch/riscv/kernel/sbi.c

File Facts

System
Linux kernel
Corpus path
arch/riscv/kernel/sbi.c
Extension
.c
Size
19144 bytes
Lines
710
Domain
Architecture Layer
Bucket
arch/riscv
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct fwft_set_req {
	u32 feature;
	unsigned long value;
	unsigned long flags;
	atomic_t error;
};

static void cpu_sbi_fwft_set(void *arg)
{
	struct fwft_set_req *req = arg;
	int ret;

	ret = sbi_fwft_set(req->feature, req->value, req->flags);
	if (ret)
		atomic_set(&req->error, ret);
}

/**
 * sbi_fwft_set() - Set a feature on the local hart
 * @feature: The feature ID to be set
 * @value: The feature value to be set
 * @flags: FWFT feature set flags
 *
 * Return: 0 on success, appropriate linux error code otherwise.
 */
int sbi_fwft_set(u32 feature, unsigned long value, unsigned long flags)
{
	struct sbiret ret;

	if (!sbi_fwft_supported)
		return -EOPNOTSUPP;

	ret = sbi_ecall(SBI_EXT_FWFT, SBI_EXT_FWFT_SET,
			feature, value, flags, 0, 0, 0);

	return sbi_err_map_linux_errno(ret.error);
}

/**
 * sbi_fwft_set_cpumask() - Set a feature for the specified cpumask
 * @mask: CPU mask of cpus that need the feature to be set
 * @feature: The feature ID to be set
 * @value: The feature value to be set
 * @flags: FWFT feature set flags
 *
 * Return: 0 on success, appropriate linux error code otherwise.
 */
int sbi_fwft_set_cpumask(const cpumask_t *mask, u32 feature,
			       unsigned long value, unsigned long flags)
{
	struct fwft_set_req req = {
		.feature = feature,
		.value = value,
		.flags = flags,
		.error = ATOMIC_INIT(0),
	};

	if (!sbi_fwft_supported)
		return -EOPNOTSUPP;

	if (feature & SBI_FWFT_GLOBAL_FEATURE_BIT)
		return -EINVAL;

	on_each_cpu_mask(mask, cpu_sbi_fwft_set, &req, 1);

	return atomic_read(&req.error);
}

/**
 * sbi_set_timer() - Program the timer for next timer event.
 * @stime_value: The value after which next timer event should fire.
 *
 * Return: None.
 */
void sbi_set_timer(uint64_t stime_value)
{
	__sbi_set_timer(stime_value);
}

/**
 * sbi_send_ipi() - Send an IPI to any hart.
 * @cpu: Logical id of the target CPU.
 */
void sbi_send_ipi(unsigned int cpu)
{
	__sbi_send_ipi(cpu);
}
EXPORT_SYMBOL(sbi_send_ipi);

/**

Annotation

Implementation Notes