Files
acrn-hypervisor/hypervisor/include/arch/riscv/asm/cpu.h
Haicheng Li 052a58d87d hv: multiarch: riscv: add two cpu interfaces
add wait_sync_change and arch_get_pcpu_num implementation for riscv.
MAX_PCPU_NUM comes from board_info.h generated by config tool.

v2->v3:
remove riscv cpu.c include asm/cpu.h

v1->v2:
implement arch_get_num_available_cpus();

Tracked-On: #8801
signed-off-by: Haicheng Li <haicheng.li@intel.com>
Co-developed-by: hangliu1 <hang1.liu@intel.com>
Signed-off-by: hangliu1 <hang1.liu@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Reviewed-by: Liu, Yifan1 <yifan1.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2025-09-19 15:04:55 +08:00

40 lines
889 B
C

/*
* Copyright (C) 2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef RISCV_CPU_H
#define RISCV_CPU_H
#include <types.h>
#include <lib/util.h>
#include <debug/logmsg.h>
#include <board_info.h>
#define barrier() __asm__ __volatile__("fence": : :"memory")
#define cpu_relax() barrier() /* TODO: replace with yield instruction */
#define NR_CPUS MAX_PCPU_NUM
static inline uint16_t get_pcpu_id(void)
{
/**
* Dummy implementation.
* Official implementations are to be provided in the platform initialization patchset (by Hang).
*/
return 0U;
}
/* Write CSR */
#define cpu_csr_write(reg, csr_val) \
({ \
uint64_t val = (uint64_t)csr_val; \
asm volatile (" csrw " STRINGIFY(reg) ", %0 \n\t" \
:: "r"(val): "memory"); \
})
void wait_sync_change(volatile const uint64_t *sync, uint64_t wake_sync);
#endif /* RISCV_CPU_H */