18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/******************************************************************************
38c2ecf20Sopenharmony_ci * Guest OS interface to ARM Xen.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ASM_ARM_XEN_INTERFACE_H
98c2ecf20Sopenharmony_ci#define _ASM_ARM_XEN_INTERFACE_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define __DEFINE_GUEST_HANDLE(name, type) \
168c2ecf20Sopenharmony_ci	typedef struct { union { type *p; uint64_aligned_t q; }; }  \
178c2ecf20Sopenharmony_ci        __guest_handle_ ## name
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define DEFINE_GUEST_HANDLE_STRUCT(name) \
208c2ecf20Sopenharmony_ci	__DEFINE_GUEST_HANDLE(name, struct name)
218c2ecf20Sopenharmony_ci#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
228c2ecf20Sopenharmony_ci#define GUEST_HANDLE(name)        __guest_handle_ ## name
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define set_xen_guest_handle(hnd, val)			\
258c2ecf20Sopenharmony_ci	do {						\
268c2ecf20Sopenharmony_ci		if (sizeof(hnd) == 8)			\
278c2ecf20Sopenharmony_ci			*(uint64_t *)&(hnd) = 0;	\
288c2ecf20Sopenharmony_ci		(hnd).p = val;				\
298c2ecf20Sopenharmony_ci	} while (0)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
348c2ecf20Sopenharmony_ci/* Explicitly size integers that represent pfns in the interface with
358c2ecf20Sopenharmony_ci * Xen so that we can have one ABI that works for 32 and 64 bit guests.
368c2ecf20Sopenharmony_ci * Note that this means that the xen_pfn_t type may be capable of
378c2ecf20Sopenharmony_ci * representing pfn's which the guest cannot represent in its own pfn
388c2ecf20Sopenharmony_ci * type. However since pfn space is controlled by the guest this is
398c2ecf20Sopenharmony_ci * fine since it simply wouldn't be able to create any sure pfns in
408c2ecf20Sopenharmony_ci * the first place.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_citypedef uint64_t xen_pfn_t;
438c2ecf20Sopenharmony_ci#define PRI_xen_pfn "llx"
448c2ecf20Sopenharmony_citypedef uint64_t xen_ulong_t;
458c2ecf20Sopenharmony_ci#define PRI_xen_ulong "llx"
468c2ecf20Sopenharmony_citypedef int64_t xen_long_t;
478c2ecf20Sopenharmony_ci#define PRI_xen_long "llx"
488c2ecf20Sopenharmony_ci/* Guest handles for primitive C types. */
498c2ecf20Sopenharmony_ci__DEFINE_GUEST_HANDLE(uchar, unsigned char);
508c2ecf20Sopenharmony_ci__DEFINE_GUEST_HANDLE(uint,  unsigned int);
518c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(char);
528c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(int);
538c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(void);
548c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(uint64_t);
558c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(uint32_t);
568c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(xen_pfn_t);
578c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE(xen_ulong_t);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Maximum number of virtual CPUs in multi-processor guests. */
608c2ecf20Sopenharmony_ci#define MAX_VIRT_CPUS 1
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct arch_vcpu_info { };
638c2ecf20Sopenharmony_cistruct arch_shared_info { };
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* TODO: Move pvclock definitions some place arch independent */
668c2ecf20Sopenharmony_cistruct pvclock_vcpu_time_info {
678c2ecf20Sopenharmony_ci	u32   version;
688c2ecf20Sopenharmony_ci	u32   pad0;
698c2ecf20Sopenharmony_ci	u64   tsc_timestamp;
708c2ecf20Sopenharmony_ci	u64   system_time;
718c2ecf20Sopenharmony_ci	u32   tsc_to_system_mul;
728c2ecf20Sopenharmony_ci	s8    tsc_shift;
738c2ecf20Sopenharmony_ci	u8    flags;
748c2ecf20Sopenharmony_ci	u8    pad[2];
758c2ecf20Sopenharmony_ci} __attribute__((__packed__)); /* 32 bytes */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* It is OK to have a 12 bytes struct with no padding because it is packed */
788c2ecf20Sopenharmony_cistruct pvclock_wall_clock {
798c2ecf20Sopenharmony_ci	u32   version;
808c2ecf20Sopenharmony_ci	u32   sec;
818c2ecf20Sopenharmony_ci	u32   nsec;
828c2ecf20Sopenharmony_ci	u32   sec_hi;
838c2ecf20Sopenharmony_ci} __attribute__((__packed__));
848c2ecf20Sopenharmony_ci#endif
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#endif /* _ASM_ARM_XEN_INTERFACE_H */
87