interface.h 2.5 KB

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