1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Guest OS interface to RISC-V Xen. 4 * Initially based on the ARM implementation. 5 */ 6 7 #ifndef __XEN_PUBLIC_ARCH_RISCV_H__ 8 #define __XEN_PUBLIC_ARCH_RISCV_H__ 9 10 #if defined(__XEN__) || defined(__XEN_TOOLS__) || defined(__GNUC__) 11 #define int64_aligned_t int64_t __attribute__((__aligned__(8))) 12 #define uint64_aligned_t uint64_t __attribute__((__aligned__(8))) 13 #endif 14 15 #ifndef __ASSEMBLY__ 16 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ 17 typedef union { type *p; unsigned long q; } \ 18 __guest_handle_ ## name; \ 19 typedef union { type *p; uint64_aligned_t q; } \ 20 __guest_handle_64_ ## name 21 22 /* 23 * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field 24 * in a struct in memory. On RISCV is always 8 bytes sizes and 8 bytes 25 * aligned. 26 * XEN_GUEST_HANDLE_PARAM represents a guest pointer, when passed as an 27 * hypercall argument. It is 4 bytes on riscv32 and 8 bytes on riscv64. 28 */ 29 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \ 30 ___DEFINE_XEN_GUEST_HANDLE(name, type); \ 31 ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) 32 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) 33 #define __XEN_GUEST_HANDLE(name) __guest_handle_64_ ## name 34 #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) 35 #define XEN_GUEST_HANDLE_PARAM(name) __guest_handle_ ## name 36 #define set_xen_guest_handle_raw(hnd, val) \ 37 do { \ 38 typeof(&(hnd)) sxghr_tmp_ = &(hnd); \ 39 sxghr_tmp_->q = 0; \ 40 sxghr_tmp_->p = (val); \ 41 } while ( 0 ) 42 #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) 43 44 typedef uint64_t xen_pfn_t; 45 #define PRI_xen_pfn PRIx64 46 #define PRIu_xen_pfn PRIu64 47 48 typedef uint64_t xen_ulong_t; 49 #define PRI_xen_ulong PRIx64 50 51 #if defined(__XEN__) || defined(__XEN_TOOLS__) 52 53 struct vcpu_guest_context { 54 }; 55 typedef struct vcpu_guest_context vcpu_guest_context_t; 56 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); 57 58 struct xen_arch_domainconfig { 59 }; 60 61 #endif 62 63 /* TODO: add a placeholder entry if no real ones surface */ 64 struct arch_vcpu_info { 65 }; 66 typedef struct arch_vcpu_info arch_vcpu_info_t; 67 68 /* TODO: add a placeholder entry if no real ones surface */ 69 struct arch_shared_info { 70 }; 71 typedef struct arch_shared_info arch_shared_info_t; 72 73 /* 74 * Maximum number of virtual CPUs in legacy multi-processor guests. 75 * Only one. All other VCPUS must use VCPUOP_register_vcpu_info. 76 */ 77 #define XEN_LEGACY_MAX_VCPUS 1 78 79 /* Stub definition of PMU structure */ 80 typedef struct xen_pmu_arch { uint8_t dummy; } xen_pmu_arch_t; 81 #endif 82 83 #endif /* __XEN_PUBLIC_ARCH_RISCV_H__ */ 84 85 /* 86 * Local variables: 87 * mode: C 88 * c-file-style: "BSD" 89 * c-basic-offset: 4 90 * tab-width: 4 91 * indent-tabs-mode: nil 92 * End: 93 */ 94