162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/******************************************************************************
362306a36Sopenharmony_ci * Guest OS interface to ARM Xen.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _ASM_ARM_XEN_INTERFACE_H
962306a36Sopenharmony_ci#define _ASM_ARM_XEN_INTERFACE_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/types.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define __DEFINE_GUEST_HANDLE(name, type) \
1662306a36Sopenharmony_ci	typedef struct { union { type *p; uint64_aligned_t q; }; }  \
1762306a36Sopenharmony_ci        __guest_handle_ ## name
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define DEFINE_GUEST_HANDLE_STRUCT(name) \
2062306a36Sopenharmony_ci	__DEFINE_GUEST_HANDLE(name, struct name)
2162306a36Sopenharmony_ci#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
2262306a36Sopenharmony_ci#define GUEST_HANDLE(name)        __guest_handle_ ## name
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define set_xen_guest_handle(hnd, val)			\
2562306a36Sopenharmony_ci	do {						\
2662306a36Sopenharmony_ci		if (sizeof(hnd) == 8)			\
2762306a36Sopenharmony_ci			*(uint64_t *)&(hnd) = 0;	\
2862306a36Sopenharmony_ci		(hnd).p = val;				\
2962306a36Sopenharmony_ci	} while (0)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifndef __ASSEMBLY__
3462306a36Sopenharmony_ci/* Explicitly size integers that represent pfns in the interface with
3562306a36Sopenharmony_ci * Xen so that we can have one ABI that works for 32 and 64 bit guests.
3662306a36Sopenharmony_ci * Note that this means that the xen_pfn_t type may be capable of
3762306a36Sopenharmony_ci * representing pfn's which the guest cannot represent in its own pfn
3862306a36Sopenharmony_ci * type. However since pfn space is controlled by the guest this is
3962306a36Sopenharmony_ci * fine since it simply wouldn't be able to create any sure pfns in
4062306a36Sopenharmony_ci * the first place.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_citypedef uint64_t xen_pfn_t;
4362306a36Sopenharmony_ci#define PRI_xen_pfn "llx"
4462306a36Sopenharmony_citypedef uint64_t xen_ulong_t;
4562306a36Sopenharmony_ci#define PRI_xen_ulong "llx"
4662306a36Sopenharmony_citypedef int64_t xen_long_t;
4762306a36Sopenharmony_ci#define PRI_xen_long "llx"
4862306a36Sopenharmony_ci/* Guest handles for primitive C types. */
4962306a36Sopenharmony_ci__DEFINE_GUEST_HANDLE(uchar, unsigned char);
5062306a36Sopenharmony_ci__DEFINE_GUEST_HANDLE(uint,  unsigned int);
5162306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(char);
5262306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(int);
5362306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(void);
5462306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(uint64_t);
5562306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(uint32_t);
5662306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(xen_pfn_t);
5762306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(xen_ulong_t);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/* Maximum number of virtual CPUs in multi-processor guests. */
6062306a36Sopenharmony_ci#define MAX_VIRT_CPUS 1
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistruct arch_vcpu_info { };
6362306a36Sopenharmony_cistruct arch_shared_info { };
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/* TODO: Move pvclock definitions some place arch independent */
6662306a36Sopenharmony_cistruct pvclock_vcpu_time_info {
6762306a36Sopenharmony_ci	u32   version;
6862306a36Sopenharmony_ci	u32   pad0;
6962306a36Sopenharmony_ci	u64   tsc_timestamp;
7062306a36Sopenharmony_ci	u64   system_time;
7162306a36Sopenharmony_ci	u32   tsc_to_system_mul;
7262306a36Sopenharmony_ci	s8    tsc_shift;
7362306a36Sopenharmony_ci	u8    flags;
7462306a36Sopenharmony_ci	u8    pad[2];
7562306a36Sopenharmony_ci} __attribute__((__packed__)); /* 32 bytes */
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* It is OK to have a 12 bytes struct with no padding because it is packed */
7862306a36Sopenharmony_cistruct pvclock_wall_clock {
7962306a36Sopenharmony_ci	u32   version;
8062306a36Sopenharmony_ci	u32   sec;
8162306a36Sopenharmony_ci	u32   nsec;
8262306a36Sopenharmony_ci	u32   sec_hi;
8362306a36Sopenharmony_ci} __attribute__((__packed__));
8462306a36Sopenharmony_ci#endif
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#endif /* _ASM_ARM_XEN_INTERFACE_H */
87