Oleksandr Andrushchenko | 365d88a | 2020-08-06 12:42:46 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 |
| 2 | * |
| 3 | * Guest OS interface to ARM Xen. |
| 4 | * |
| 5 | * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012 |
| 6 | */ |
| 7 | |
| 8 | #ifndef _ASM_ARM_XEN_INTERFACE_H |
| 9 | #define _ASM_ARM_XEN_INTERFACE_H |
| 10 | |
| 11 | #ifndef __ASSEMBLY__ |
| 12 | #include <linux/types.h> |
| 13 | #endif |
| 14 | |
| 15 | #define uint64_aligned_t u64 __attribute__((aligned(8))) |
| 16 | |
| 17 | #define __DEFINE_GUEST_HANDLE(name, type) \ |
| 18 | typedef struct { union { type * p; uint64_aligned_t q; }; } \ |
| 19 | __guest_handle_ ## name |
| 20 | |
| 21 | #define DEFINE_GUEST_HANDLE_STRUCT(name) \ |
| 22 | __DEFINE_GUEST_HANDLE(name, struct name) |
| 23 | #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) |
| 24 | #define GUEST_HANDLE(name) __guest_handle_ ## name |
| 25 | |
| 26 | #define set_xen_guest_handle(hnd, val) \ |
| 27 | do { \ |
| 28 | if (sizeof(hnd) == 8) \ |
| 29 | *(u64 *)&(hnd) = 0; \ |
| 30 | (hnd).p = val; \ |
| 31 | } while (0) |
| 32 | |
| 33 | #define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op |
| 34 | |
| 35 | #ifndef __ASSEMBLY__ |
| 36 | /* Explicitly size integers that represent pfns in the interface with |
| 37 | * Xen so that we can have one ABI that works for 32 and 64 bit guests. |
| 38 | * Note that this means that the xen_pfn_t type may be capable of |
| 39 | * representing pfn's which the guest cannot represent in its own pfn |
| 40 | * type. However since pfn space is controlled by the guest this is |
| 41 | * fine since it simply wouldn't be able to create any sure pfns in |
| 42 | * the first place. |
| 43 | */ |
| 44 | typedef u64 xen_pfn_t; |
| 45 | #define PRI_xen_pfn "llx" |
| 46 | typedef u64 xen_ulong_t; |
| 47 | #define PRI_xen_ulong "llx" |
| 48 | typedef s64 xen_long_t; |
| 49 | #define PRI_xen_long "llx" |
| 50 | /* Guest handles for primitive C types. */ |
| 51 | __DEFINE_GUEST_HANDLE(uchar, unsigned char); |
| 52 | __DEFINE_GUEST_HANDLE(uint, unsigned int); |
| 53 | DEFINE_GUEST_HANDLE(char); |
| 54 | DEFINE_GUEST_HANDLE(int); |
| 55 | DEFINE_GUEST_HANDLE(void); |
| 56 | DEFINE_GUEST_HANDLE(u64); |
| 57 | DEFINE_GUEST_HANDLE(u32); |
| 58 | DEFINE_GUEST_HANDLE(xen_pfn_t); |
| 59 | DEFINE_GUEST_HANDLE(xen_ulong_t); |
| 60 | |
| 61 | /* Maximum number of virtual CPUs in multi-processor guests. */ |
| 62 | #define MAX_VIRT_CPUS 1 |
| 63 | |
| 64 | struct arch_vcpu_info { }; |
| 65 | struct arch_shared_info { }; |
| 66 | |
| 67 | /* TODO: Move pvclock definitions some place arch independent */ |
| 68 | struct pvclock_vcpu_time_info { |
| 69 | u32 version; |
| 70 | u32 pad0; |
| 71 | u64 tsc_timestamp; |
| 72 | u64 system_time; |
| 73 | u32 tsc_to_system_mul; |
| 74 | s8 tsc_shift; |
| 75 | u8 flags; |
| 76 | u8 pad[2]; |
| 77 | } __attribute__((__packed__)); /* 32 bytes */ |
| 78 | |
| 79 | /* It is OK to have a 12 bytes struct with no padding because it is packed */ |
| 80 | struct pvclock_wall_clock { |
| 81 | u32 version; |
| 82 | u32 sec; |
| 83 | u32 nsec; |
| 84 | u32 sec_hi; |
| 85 | } __attribute__((__packed__)); |
| 86 | #endif |
| 87 | |
| 88 | #endif /* _ASM_ARM_XEN_INTERFACE_H */ |