Home | History | Annotate | Download | only in arch-x86
      1 /******************************************************************************
      2  * arch-x86/xen.h
      3  *
      4  * Guest OS interface to x86 Xen.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a copy
      7  * of this software and associated documentation files (the "Software"), to
      8  * deal in the Software without restriction, including without limitation the
      9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     10  * sell copies of the Software, and to permit persons to whom the Software is
     11  * furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22  * DEALINGS IN THE SOFTWARE.
     23  *
     24  * Copyright (c) 2004-2006, K A Fraser
     25  */
     26 
     27 #include "../xen.h"
     28 
     29 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
     30 #define __XEN_PUBLIC_ARCH_X86_XEN_H__
     31 
     32 /* Structural guest handles introduced in 0x00030201. */
     33 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
     34 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
     35     typedef struct { type *p; } __guest_handle_ ## name
     36 #else
     37 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
     38     typedef type * __guest_handle_ ## name
     39 #endif
     40 
     41 /*
     42  * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field
     43  * in a struct in memory.
     44  * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an
     45  * hypercall argument.
     46  * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but
     47  * they might not be on other architectures.
     48  */
     49 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     50     ___DEFINE_XEN_GUEST_HANDLE(name, type);   \
     51     ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
     52 #define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
     53 #define __XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
     54 #define XEN_GUEST_HANDLE(name)          __XEN_GUEST_HANDLE(name)
     55 #define XEN_GUEST_HANDLE_PARAM(name)    XEN_GUEST_HANDLE(name)
     56 #define set_xen_guest_handle_raw(hnd, val)  do { (hnd).p = val; } while (0)
     57 #ifdef __XEN_TOOLS__
     58 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
     59 #endif
     60 #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
     61 
     62 #if defined(MDE_CPU_IA32)
     63 #include "xen-x86_32.h"
     64 #elif defined(MDE_CPU_X64)
     65 #include "xen-x86_64.h"
     66 #endif
     67 
     68 #ifndef __ASSEMBLY__
     69 typedef UINTN xen_pfn_t;
     70 #define PRI_xen_pfn "lx"
     71 #endif
     72 
     73 #define XEN_HAVE_PV_UPCALL_MASK 1
     74 
     75 /* Maximum number of virtual CPUs in legacy multi-processor guests. */
     76 #define XEN_LEGACY_MAX_VCPUS 32
     77 
     78 #ifndef __ASSEMBLY__
     79 
     80 typedef UINTN xen_ulong_t;
     81 #define PRI_xen_ulong "lx"
     82 
     83 typedef UINT64 tsc_timestamp_t; /* RDTSC timestamp */
     84 
     85 #ifdef MDE_CPU_IA32
     86 #pragma pack(4)
     87 #endif
     88 struct arch_shared_info {
     89     UINTN max_pfn;                  /* max pfn that appears in table */
     90     /* Frame containing list of mfns containing list of mfns containing p2m. */
     91     xen_pfn_t     pfn_to_mfn_frame_list_list;
     92     UINTN nmi_reason;
     93     UINT64 pad[32];
     94 };
     95 typedef struct arch_shared_info arch_shared_info_t;
     96 #ifdef MDE_CPU_IA32
     97 #pragma pack()
     98 #endif
     99 
    100 #endif /* !__ASSEMBLY__ */
    101 
    102 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
    103 
    104 /*
    105  * Local variables:
    106  * mode: C
    107  * c-file-style: "BSD"
    108  * c-basic-offset: 4
    109  * tab-width: 4
    110  * indent-tabs-mode: nil
    111  * End:
    112  */
    113