win-pvdrivers

changeset 37:3ac5c4431dbb

manual merge
author Andy Grover <andy.grover@oracle.com>
date Wed Dec 05 11:14:28 2007 -0800 (2007-12-05)
parents f5a275d63b7d 464d62db9cff
children a5617e7e9f54
files xenpci/xenbus.c xenpci/xenbus.h xenpci/xenpci.c xenpci/xenpci.h xenvbd/xenvbd.c
line diff
     1.1 --- a/common/include/evtchn_public.h	Wed Dec 05 19:56:17 2007 +1100
     1.2 +++ b/common/include/evtchn_public.h	Wed Dec 05 11:14:28 2007 -0800
     1.3 @@ -20,23 +20,23 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  DEFINE_GUID( GUID_XEN_IFACE_EVTCHN, 0xD2D20756, 0xDE69, 0x4447, 0x8A, 0x7D, 0x98, 0x37, 0x19, 0x7D, 0x61, 0x66);
     1.5  //{D2D20756-DE69-4447-8A7D-9837197D6166}
     1.6  
     1.7 -typedef evtchn_port_t
     1.8 -(*PXEN_EVTCHN_ALLOCUNBOUND)(domid_t Domain);
     1.9 -
    1.10  typedef NTSTATUS
    1.11 -(*PXEN_EVTCHN_BIND)(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    1.12 +(*PXEN_EVTCHN_BIND)(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    1.13  
    1.14  typedef NTSTATUS
    1.15 -(*PXEN_EVTCHN_UNBIND)(evtchn_port_t Port);
    1.16 +(*PXEN_EVTCHN_UNBIND)(PVOID Context, evtchn_port_t Port);
    1.17  
    1.18  typedef NTSTATUS
    1.19 -(*PXEN_EVTCHN_MASK)(evtchn_port_t Port);
    1.20 +(*PXEN_EVTCHN_MASK)(PVOID Context, evtchn_port_t Port);
    1.21  
    1.22  typedef NTSTATUS
    1.23 -(*PXEN_EVTCHN_UNMASK)(evtchn_port_t Port);
    1.24 +(*PXEN_EVTCHN_UNMASK)(PVOID Context, evtchn_port_t Port);
    1.25  
    1.26  typedef NTSTATUS
    1.27 -(*PXEN_EVTCHN_NOTIFY)(evtchn_port_t Port);
    1.28 +(*PXEN_EVTCHN_NOTIFY)(PVOID Context, evtchn_port_t Port);
    1.29 +
    1.30 +typedef evtchn_port_t
    1.31 +(*PXEN_EVTCHN_ALLOCUNBOUND)(PVOID Context, domid_t Domain);
    1.32  
    1.33  typedef struct _XENBUS_IFACE_EVTCHN {
    1.34    INTERFACE InterfaceHeader;
     2.1 --- a/common/include/gnttbl_public.h	Wed Dec 05 19:56:17 2007 +1100
     2.2 +++ b/common/include/gnttbl_public.h	Wed Dec 05 11:14:28 2007 -0800
     2.3 @@ -21,9 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  DEFINE_GUID(GUID_XEN_IFACE_GNTTBL, 0x6a71acf8, 0xf6d, 0x4022, 0xba, 0x60, 0x19, 0x98, 0x6e, 0xbe, 0xea, 0x73);
     2.5  
     2.6  typedef grant_ref_t
     2.7 -(*PXEN_GNTTBL_GRANTACCESS)(domid_t domid, unsigned long frame, int readonly);
     2.8 +(*PXEN_GNTTBL_GRANTACCESS)(WDFDEVICE Device, domid_t domid, unsigned long frame, int readonly);
     2.9  typedef BOOLEAN
    2.10 -(*PXEN_GNTTBL_ENDACCESS)(grant_ref_t ref);
    2.11 +(*PXEN_GNTTBL_ENDACCESS)(WDFDEVICE Device, grant_ref_t ref);
    2.12  
    2.13  typedef struct _XEN_IFACE_GNTTBL {
    2.14    INTERFACE InterfaceHeader;
     3.1 --- a/common/include/hypercall.h	Wed Dec 05 19:56:17 2007 +1100
     3.2 +++ b/common/include/hypercall.h	Wed Dec 05 11:14:28 2007 -0800
     3.3 @@ -19,11 +19,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     3.4  
     3.5  #include "xenpci.h"
     3.6  
     3.7 -char *hypercall_stubs;
     3.8 -
     3.9  static __inline int
    3.10 -HYPERVISOR_memory_op(int cmd, void *arg)
    3.11 +HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
    3.12  {
    3.13 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.14    long __res;
    3.15    __asm {
    3.16      mov ebx, cmd
    3.17 @@ -37,8 +36,9 @@ HYPERVISOR_memory_op(int cmd, void *arg)
    3.18  }
    3.19  
    3.20  static __inline int
    3.21 -HYPERVISOR_xen_version(int cmd, void *arg)
    3.22 +HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
    3.23  {
    3.24 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.25    long __res;
    3.26    __asm {
    3.27      mov ebx, cmd
    3.28 @@ -52,8 +52,9 @@ HYPERVISOR_xen_version(int cmd, void *ar
    3.29  }
    3.30  
    3.31  static __inline int
    3.32 -HYPERVISOR_grant_table_op(int cmd, void *uop, unsigned int count)
    3.33 +HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
    3.34  {
    3.35 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.36    long __res;
    3.37    __asm {
    3.38      mov ebx, cmd
    3.39 @@ -68,8 +69,9 @@ HYPERVISOR_grant_table_op(int cmd, void 
    3.40  }
    3.41  
    3.42  static __inline int
    3.43 -HYPERVISOR_mmu_update(mmu_update_t *req, int count, int *success_count, domid_t domid)
    3.44 +HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
    3.45  {
    3.46 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.47    long __res;
    3.48    long _domid = (long)domid;
    3.49    __asm {
    3.50 @@ -86,8 +88,9 @@ HYPERVISOR_mmu_update(mmu_update_t *req,
    3.51  }
    3.52  
    3.53  static __inline int
    3.54 -HYPERVISOR_console_io(int cmd, int count, char *string)
    3.55 +HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
    3.56  {
    3.57 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.58    long __res;
    3.59    __asm {
    3.60      mov ebx, cmd
    3.61 @@ -102,8 +105,9 @@ HYPERVISOR_console_io(int cmd, int count
    3.62  }
    3.63  
    3.64  static __inline int
    3.65 -HYPERVISOR_hvm_op(int op, struct xen_hvm_param *arg)
    3.66 +HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
    3.67  {
    3.68 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.69    long __res;
    3.70    __asm {
    3.71      mov ebx, op
    3.72 @@ -117,8 +121,9 @@ HYPERVISOR_hvm_op(int op, struct xen_hvm
    3.73  }
    3.74  
    3.75  static __inline int
    3.76 -HYPERVISOR_event_channel_op(int cmd, void *op)
    3.77 +HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
    3.78  {
    3.79 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    3.80    long __res;
    3.81    __asm {
    3.82      mov ebx, cmd
    3.83 @@ -132,7 +137,7 @@ HYPERVISOR_event_channel_op(int cmd, voi
    3.84  }
    3.85  
    3.86  static __inline ULONGLONG
    3.87 -hvm_get_parameter(int hvm_param)
    3.88 +hvm_get_parameter(WDFDEVICE Device, int hvm_param)
    3.89  {
    3.90    struct xen_hvm_param a;
    3.91    int retval;
    3.92 @@ -141,7 +146,7 @@ hvm_get_parameter(int hvm_param)
    3.93    a.domid = DOMID_SELF;
    3.94    a.index = hvm_param;
    3.95    //a.value = via;
    3.96 -  retval = HYPERVISOR_hvm_op(HVMOP_get_param, &a);
    3.97 +  retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
    3.98    KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
    3.99    KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
   3.100    return a.value;
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/common/include/public/COPYING	Wed Dec 05 11:14:28 2007 -0800
     4.3 @@ -0,0 +1,38 @@
     4.4 +XEN NOTICE
     4.5 +==========
     4.6 +
     4.7 +This copyright applies to all files within this subdirectory and its
     4.8 +subdirectories:
     4.9 +  include/public/*.h
    4.10 +  include/public/hvm/*.h
    4.11 +  include/public/io/*.h
    4.12 +
    4.13 +The intention is that these files can be freely copied into the source
    4.14 +tree of an operating system when porting that OS to run on Xen. Doing
    4.15 +so does *not* cause the OS to become subject to the terms of the GPL.
    4.16 +
    4.17 +All other files in the Xen source distribution are covered by version
    4.18 +2 of the GNU General Public License except where explicitly stated
    4.19 +otherwise within individual source files.
    4.20 +
    4.21 + -- Keir Fraser (on behalf of the Xen team)
    4.22 +
    4.23 +=====================================================================
    4.24 +
    4.25 +Permission is hereby granted, free of charge, to any person obtaining a copy
    4.26 +of this software and associated documentation files (the "Software"), to
    4.27 +deal in the Software without restriction, including without limitation the
    4.28 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    4.29 +sell copies of the Software, and to permit persons to whom the Software is
    4.30 +furnished to do so, subject to the following conditions:
    4.31 +
    4.32 +The above copyright notice and this permission notice shall be included in
    4.33 +all copies or substantial portions of the Software.
    4.34 +
    4.35 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    4.36 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    4.37 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    4.38 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    4.39 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    4.40 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
    4.41 +DEALINGS IN THE SOFTWARE.
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/common/include/public/acm.h	Wed Dec 05 11:14:28 2007 -0800
     5.3 @@ -0,0 +1,228 @@
     5.4 +/*
     5.5 + * acm.h: Xen access control module interface defintions
     5.6 + *
     5.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
     5.8 + * of this software and associated documentation files (the "Software"), to
     5.9 + * deal in the Software without restriction, including without limitation the
    5.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    5.11 + * sell copies of the Software, and to permit persons to whom the Software is
    5.12 + * furnished to do so, subject to the following conditions:
    5.13 + *
    5.14 + * The above copyright notice and this permission notice shall be included in
    5.15 + * all copies or substantial portions of the Software.
    5.16 + *
    5.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    5.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    5.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    5.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    5.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    5.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    5.23 + * DEALINGS IN THE SOFTWARE.
    5.24 + *
    5.25 + * Reiner Sailer <sailer@watson.ibm.com>
    5.26 + * Copyright (c) 2005, International Business Machines Corporation.
    5.27 + */
    5.28 +
    5.29 +#ifndef _XEN_PUBLIC_ACM_H
    5.30 +#define _XEN_PUBLIC_ACM_H
    5.31 +
    5.32 +#include "xen.h"
    5.33 +
    5.34 +/* if ACM_DEBUG defined, all hooks should
    5.35 + * print a short trace message (comment it out
    5.36 + * when not in testing mode )
    5.37 + */
    5.38 +/* #define ACM_DEBUG */
    5.39 +
    5.40 +#ifdef ACM_DEBUG
    5.41 +#  define printkd(fmt, args...) printk(fmt,## args)
    5.42 +#else
    5.43 +#  define printkd(fmt, args...)
    5.44 +#endif
    5.45 +
    5.46 +/* default ssid reference value if not supplied */
    5.47 +#define ACM_DEFAULT_SSID  0x0
    5.48 +#define ACM_DEFAULT_LOCAL_SSID  0x0
    5.49 +
    5.50 +/* Internal ACM ERROR types */
    5.51 +#define ACM_OK     0
    5.52 +#define ACM_UNDEF   -1
    5.53 +#define ACM_INIT_SSID_ERROR  -2
    5.54 +#define ACM_INIT_SOID_ERROR  -3
    5.55 +#define ACM_ERROR          -4
    5.56 +
    5.57 +/* External ACCESS DECISIONS */
    5.58 +#define ACM_ACCESS_PERMITTED        0
    5.59 +#define ACM_ACCESS_DENIED           -111
    5.60 +#define ACM_NULL_POINTER_ERROR      -200
    5.61 +
    5.62 +/*
    5.63 +   Error codes reported in when trying to test for a new policy
    5.64 +   These error codes are reported in an array of tuples where
    5.65 +   each error code is followed by a parameter describing the error
    5.66 +   more closely, such as a domain id.
    5.67 +*/
    5.68 +#define ACM_EVTCHN_SHARING_VIOLATION       0x100
    5.69 +#define ACM_GNTTAB_SHARING_VIOLATION       0x101
    5.70 +#define ACM_DOMAIN_LOOKUP                  0x102
    5.71 +#define ACM_CHWALL_CONFLICT                0x103
    5.72 +#define ACM_SSIDREF_IN_USE                 0x104
    5.73 +
    5.74 +
    5.75 +/* primary policy in lower 4 bits */
    5.76 +#define ACM_NULL_POLICY 0
    5.77 +#define ACM_CHINESE_WALL_POLICY 1
    5.78 +#define ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY 2
    5.79 +#define ACM_POLICY_UNDEFINED 15
    5.80 +
    5.81 +/* combinations have secondary policy component in higher 4bit */
    5.82 +#define ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY \
    5.83 +    ((ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY << 4) | ACM_CHINESE_WALL_POLICY)
    5.84 +
    5.85 +/* policy: */
    5.86 +#define ACM_POLICY_NAME(X) \
    5.87 + ((X) == (ACM_NULL_POLICY)) ? "NULL" :                        \
    5.88 +    ((X) == (ACM_CHINESE_WALL_POLICY)) ? "CHINESE WALL" :        \
    5.89 +    ((X) == (ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "SIMPLE TYPE ENFORCEMENT" : \
    5.90 +    ((X) == (ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "CHINESE WALL AND SIMPLE TYPE ENFORCEMENT" : \
    5.91 +     "UNDEFINED"
    5.92 +
    5.93 +/* the following policy versions must be increased
    5.94 + * whenever the interpretation of the related
    5.95 + * policy's data structure changes
    5.96 + */
    5.97 +#define ACM_POLICY_VERSION 3
    5.98 +#define ACM_CHWALL_VERSION 1
    5.99 +#define ACM_STE_VERSION  1
   5.100 +
   5.101 +/* defines a ssid reference used by xen */
   5.102 +typedef uint32_t ssidref_t;
   5.103 +
   5.104 +/* hooks that are known to domains */
   5.105 +#define ACMHOOK_none    0
   5.106 +#define ACMHOOK_sharing 1
   5.107 +
   5.108 +/* -------security policy relevant type definitions-------- */
   5.109 +
   5.110 +/* type identifier; compares to "equal" or "not equal" */
   5.111 +typedef uint16_t domaintype_t;
   5.112 +
   5.113 +/* CHINESE WALL POLICY DATA STRUCTURES
   5.114 + *
   5.115 + * current accumulated conflict type set:
   5.116 + * When a domain is started and has a type that is in
   5.117 + * a conflict set, the conflicting types are incremented in
   5.118 + * the aggregate set. When a domain is destroyed, the 
   5.119 + * conflicting types to its type are decremented.
   5.120 + * If a domain has multiple types, this procedure works over
   5.121 + * all those types.
   5.122 + *
   5.123 + * conflict_aggregate_set[i] holds the number of
   5.124 + *   running domains that have a conflict with type i.
   5.125 + *
   5.126 + * running_types[i] holds the number of running domains
   5.127 + *        that include type i in their ssidref-referenced type set
   5.128 + *
   5.129 + * conflict_sets[i][j] is "0" if type j has no conflict
   5.130 + *    with type i and is "1" otherwise.
   5.131 + */
   5.132 +/* high-16 = version, low-16 = check magic */
   5.133 +#define ACM_MAGIC  0x0001debc
   5.134 +
   5.135 +/* each offset in bytes from start of the struct they
   5.136 + * are part of */
   5.137 +
   5.138 +/* V3 of the policy buffer aded a version structure */
   5.139 +struct acm_policy_version
   5.140 +{
   5.141 +    uint32_t major;
   5.142 +    uint32_t minor;
   5.143 +};
   5.144 +
   5.145 +
   5.146 +/* each buffer consists of all policy information for
   5.147 + * the respective policy given in the policy code
   5.148 + *
   5.149 + * acm_policy_buffer, acm_chwall_policy_buffer,
   5.150 + * and acm_ste_policy_buffer need to stay 32-bit aligned
   5.151 + * because we create binary policies also with external
   5.152 + * tools that assume packed representations (e.g. the java tool)
   5.153 + */
   5.154 +struct acm_policy_buffer {
   5.155 +    uint32_t policy_version; /* ACM_POLICY_VERSION */
   5.156 +    uint32_t magic;
   5.157 +    uint32_t len;
   5.158 +    uint32_t policy_reference_offset;
   5.159 +    uint32_t primary_policy_code;
   5.160 +    uint32_t primary_buffer_offset;
   5.161 +    uint32_t secondary_policy_code;
   5.162 +    uint32_t secondary_buffer_offset;
   5.163 +    struct acm_policy_version xml_pol_version; /* add in V3 */
   5.164 +};
   5.165 +
   5.166 +
   5.167 +struct acm_policy_reference_buffer {
   5.168 +    uint32_t len;
   5.169 +};
   5.170 +
   5.171 +struct acm_chwall_policy_buffer {
   5.172 +    uint32_t policy_version; /* ACM_CHWALL_VERSION */
   5.173 +    uint32_t policy_code;
   5.174 +    uint32_t chwall_max_types;
   5.175 +    uint32_t chwall_max_ssidrefs;
   5.176 +    uint32_t chwall_max_conflictsets;
   5.177 +    uint32_t chwall_ssid_offset;
   5.178 +    uint32_t chwall_conflict_sets_offset;
   5.179 +    uint32_t chwall_running_types_offset;
   5.180 +    uint32_t chwall_conflict_aggregate_offset;
   5.181 +};
   5.182 +
   5.183 +struct acm_ste_policy_buffer {
   5.184 +    uint32_t policy_version; /* ACM_STE_VERSION */
   5.185 +    uint32_t policy_code;
   5.186 +    uint32_t ste_max_types;
   5.187 +    uint32_t ste_max_ssidrefs;
   5.188 +    uint32_t ste_ssid_offset;
   5.189 +};
   5.190 +
   5.191 +struct acm_stats_buffer {
   5.192 +    uint32_t magic;
   5.193 +    uint32_t len;
   5.194 +    uint32_t primary_policy_code;
   5.195 +    uint32_t primary_stats_offset;
   5.196 +    uint32_t secondary_policy_code;
   5.197 +    uint32_t secondary_stats_offset;
   5.198 +};
   5.199 +
   5.200 +struct acm_ste_stats_buffer {
   5.201 +    uint32_t ec_eval_count;
   5.202 +    uint32_t gt_eval_count;
   5.203 +    uint32_t ec_denied_count;
   5.204 +    uint32_t gt_denied_count;
   5.205 +    uint32_t ec_cachehit_count;
   5.206 +    uint32_t gt_cachehit_count;
   5.207 +};
   5.208 +
   5.209 +struct acm_ssid_buffer {
   5.210 +    uint32_t len;
   5.211 +    ssidref_t ssidref;
   5.212 +    uint32_t policy_reference_offset;
   5.213 +    uint32_t primary_policy_code;
   5.214 +    uint32_t primary_max_types;
   5.215 +    uint32_t primary_types_offset;
   5.216 +    uint32_t secondary_policy_code;
   5.217 +    uint32_t secondary_max_types;
   5.218 +    uint32_t secondary_types_offset;
   5.219 +};
   5.220 +
   5.221 +#endif
   5.222 +
   5.223 +/*
   5.224 + * Local variables:
   5.225 + * mode: C
   5.226 + * c-set-style: "BSD"
   5.227 + * c-basic-offset: 4
   5.228 + * tab-width: 4
   5.229 + * indent-tabs-mode: nil
   5.230 + * End:
   5.231 + */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/common/include/public/acm_ops.h	Wed Dec 05 11:14:28 2007 -0800
     6.3 @@ -0,0 +1,159 @@
     6.4 +/*
     6.5 + * acm_ops.h: Xen access control module hypervisor commands
     6.6 + *
     6.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
     6.8 + * of this software and associated documentation files (the "Software"), to
     6.9 + * deal in the Software without restriction, including without limitation the
    6.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    6.11 + * sell copies of the Software, and to permit persons to whom the Software is
    6.12 + * furnished to do so, subject to the following conditions:
    6.13 + *
    6.14 + * The above copyright notice and this permission notice shall be included in
    6.15 + * all copies or substantial portions of the Software.
    6.16 + *
    6.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    6.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    6.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    6.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    6.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    6.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    6.23 + * DEALINGS IN THE SOFTWARE.
    6.24 + *
    6.25 + * Reiner Sailer <sailer@watson.ibm.com>
    6.26 + * Copyright (c) 2005,2006 International Business Machines Corporation.
    6.27 + */
    6.28 +
    6.29 +#ifndef __XEN_PUBLIC_ACM_OPS_H__
    6.30 +#define __XEN_PUBLIC_ACM_OPS_H__
    6.31 +
    6.32 +#include "xen.h"
    6.33 +#include "acm.h"
    6.34 +
    6.35 +/*
    6.36 + * Make sure you increment the interface version whenever you modify this file!
    6.37 + * This makes sure that old versions of acm tools will stop working in a
    6.38 + * well-defined way (rather than crashing the machine, for instance).
    6.39 + */
    6.40 +#define ACM_INTERFACE_VERSION   0xAAAA000A
    6.41 +
    6.42 +/************************************************************************/
    6.43 +
    6.44 +/*
    6.45 + * Prototype for this hypercall is:
    6.46 + *  int acm_op(int cmd, void *args)
    6.47 + * @cmd  == ACMOP_??? (access control module operation).
    6.48 + * @args == Operation-specific extra arguments (NULL if none).
    6.49 + */
    6.50 +
    6.51 +
    6.52 +#define ACMOP_setpolicy         1
    6.53 +struct acm_setpolicy {
    6.54 +    /* IN */
    6.55 +    XEN_GUEST_HANDLE_64(void) pushcache;
    6.56 +    uint32_t pushcache_size;
    6.57 +};
    6.58 +
    6.59 +
    6.60 +#define ACMOP_getpolicy         2
    6.61 +struct acm_getpolicy {
    6.62 +    /* IN */
    6.63 +    XEN_GUEST_HANDLE_64(void) pullcache;
    6.64 +    uint32_t pullcache_size;
    6.65 +};
    6.66 +
    6.67 +
    6.68 +#define ACMOP_dumpstats         3
    6.69 +struct acm_dumpstats {
    6.70 +    /* IN */
    6.71 +    XEN_GUEST_HANDLE_64(void) pullcache;
    6.72 +    uint32_t pullcache_size;
    6.73 +};
    6.74 +
    6.75 +
    6.76 +#define ACMOP_getssid           4
    6.77 +#define ACM_GETBY_ssidref  1
    6.78 +#define ACM_GETBY_domainid 2
    6.79 +struct acm_getssid {
    6.80 +    /* IN */
    6.81 +    uint32_t get_ssid_by; /* ACM_GETBY_* */
    6.82 +    union {
    6.83 +        domaintype_t domainid;
    6.84 +        ssidref_t    ssidref;
    6.85 +    } id;
    6.86 +    XEN_GUEST_HANDLE_64(void) ssidbuf;
    6.87 +    uint32_t ssidbuf_size;
    6.88 +};
    6.89 +
    6.90 +#define ACMOP_getdecision      5
    6.91 +struct acm_getdecision {
    6.92 +    /* IN */
    6.93 +    uint32_t get_decision_by1; /* ACM_GETBY_* */
    6.94 +    uint32_t get_decision_by2; /* ACM_GETBY_* */
    6.95 +    union {
    6.96 +        domaintype_t domainid;
    6.97 +        ssidref_t    ssidref;
    6.98 +    } id1;
    6.99 +    union {
   6.100 +        domaintype_t domainid;
   6.101 +        ssidref_t    ssidref;
   6.102 +    } id2;
   6.103 +    uint32_t hook;
   6.104 +    /* OUT */
   6.105 +    uint32_t acm_decision;
   6.106 +};
   6.107 +
   6.108 +
   6.109 +#define ACMOP_chgpolicy        6
   6.110 +struct acm_change_policy {
   6.111 +    /* IN */
   6.112 +    XEN_GUEST_HANDLE_64(void) policy_pushcache;
   6.113 +    uint32_t policy_pushcache_size;
   6.114 +    XEN_GUEST_HANDLE_64(void) del_array;
   6.115 +    uint32_t delarray_size;
   6.116 +    XEN_GUEST_HANDLE_64(void) chg_array;
   6.117 +    uint32_t chgarray_size;
   6.118 +    /* OUT */
   6.119 +    /* array with error code */
   6.120 +    XEN_GUEST_HANDLE_64(void) err_array;
   6.121 +    uint32_t errarray_size;
   6.122 +};
   6.123 +
   6.124 +#define ACMOP_relabeldoms       7
   6.125 +struct acm_relabel_doms {
   6.126 +    /* IN */
   6.127 +    XEN_GUEST_HANDLE_64(void) relabel_map;
   6.128 +    uint32_t relabel_map_size;
   6.129 +    /* OUT */
   6.130 +    XEN_GUEST_HANDLE_64(void) err_array;
   6.131 +    uint32_t errarray_size;
   6.132 +};
   6.133 +
   6.134 +/* future interface to Xen */
   6.135 +struct xen_acmctl {
   6.136 +    uint32_t cmd;
   6.137 +    uint32_t interface_version;
   6.138 +    union {
   6.139 +        struct acm_setpolicy     setpolicy;
   6.140 +        struct acm_getpolicy     getpolicy;
   6.141 +        struct acm_dumpstats     dumpstats;
   6.142 +        struct acm_getssid       getssid;
   6.143 +        struct acm_getdecision   getdecision;
   6.144 +        struct acm_change_policy change_policy;
   6.145 +        struct acm_relabel_doms  relabel_doms;
   6.146 +    } u;
   6.147 +};
   6.148 +
   6.149 +typedef struct xen_acmctl xen_acmctl_t;
   6.150 +DEFINE_XEN_GUEST_HANDLE(xen_acmctl_t);
   6.151 +
   6.152 +#endif /* __XEN_PUBLIC_ACM_OPS_H__ */
   6.153 +
   6.154 +/*
   6.155 + * Local variables:
   6.156 + * mode: C
   6.157 + * c-set-style: "BSD"
   6.158 + * c-basic-offset: 4
   6.159 + * tab-width: 4
   6.160 + * indent-tabs-mode: nil
   6.161 + * End:
   6.162 + */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/common/include/public/arch-ia64.h	Wed Dec 05 11:14:28 2007 -0800
     7.3 @@ -0,0 +1,522 @@
     7.4 +/******************************************************************************
     7.5 + * arch-ia64/hypervisor-if.h
     7.6 + * 
     7.7 + * Guest OS interface to IA64 Xen.
     7.8 + *
     7.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    7.10 + * of this software and associated documentation files (the "Software"), to
    7.11 + * deal in the Software without restriction, including without limitation the
    7.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    7.13 + * sell copies of the Software, and to permit persons to whom the Software is
    7.14 + * furnished to do so, subject to the following conditions:
    7.15 + *
    7.16 + * The above copyright notice and this permission notice shall be included in
    7.17 + * all copies or substantial portions of the Software.
    7.18 + *
    7.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    7.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    7.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    7.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    7.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    7.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    7.25 + * DEALINGS IN THE SOFTWARE.
    7.26 + *
    7.27 + */
    7.28 +
    7.29 +#ifndef __HYPERVISOR_IF_IA64_H__
    7.30 +#define __HYPERVISOR_IF_IA64_H__
    7.31 +
    7.32 +/* Structural guest handles introduced in 0x00030201. */
    7.33 +#if __XEN_INTERFACE_VERSION__ >= 0x00030201
    7.34 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    7.35 +    typedef struct { type *p; } __guest_handle_ ## name
    7.36 +#else
    7.37 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    7.38 +    typedef type * __guest_handle_ ## name
    7.39 +#endif
    7.40 +
    7.41 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    7.42 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
    7.43 +#define XEN_GUEST_HANDLE_64(name)       XEN_GUEST_HANDLE(name)
    7.44 +#define uint64_aligned_t                uint64_t
    7.45 +#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
    7.46 +#ifdef __XEN_TOOLS__
    7.47 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    7.48 +#endif
    7.49 +
    7.50 +#ifndef __ASSEMBLY__
    7.51 +/* Guest handles for primitive C types. */
    7.52 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    7.53 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    7.54 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    7.55 +__DEFINE_XEN_GUEST_HANDLE(u64,   unsigned long);
    7.56 +DEFINE_XEN_GUEST_HANDLE(char);
    7.57 +DEFINE_XEN_GUEST_HANDLE(int);
    7.58 +DEFINE_XEN_GUEST_HANDLE(long);
    7.59 +DEFINE_XEN_GUEST_HANDLE(void);
    7.60 +
    7.61 +typedef unsigned long xen_pfn_t;
    7.62 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    7.63 +#define PRI_xen_pfn "lx"
    7.64 +#endif
    7.65 +
    7.66 +/* Arch specific VIRQs definition */
    7.67 +#define VIRQ_ITC        VIRQ_ARCH_0 /* V. Virtual itc timer */
    7.68 +#define VIRQ_MCA_CMC    VIRQ_ARCH_1 /* MCA cmc interrupt */
    7.69 +#define VIRQ_MCA_CPE    VIRQ_ARCH_2 /* MCA cpe interrupt */
    7.70 +
    7.71 +/* Maximum number of virtual CPUs in multi-processor guests. */
    7.72 +/* WARNING: before changing this, check that shared_info fits on a page */
    7.73 +#define MAX_VIRT_CPUS 64
    7.74 +
    7.75 +#ifndef __ASSEMBLY__
    7.76 +
    7.77 +typedef unsigned long xen_ulong_t;
    7.78 +
    7.79 +#define INVALID_MFN       (~0UL)
    7.80 +
    7.81 +#define MEM_G   (1UL << 30)
    7.82 +#define MEM_M   (1UL << 20)
    7.83 +#define MEM_K   (1UL << 10)
    7.84 +
    7.85 +#define MMIO_START       (3 * MEM_G)
    7.86 +#define MMIO_SIZE        (512 * MEM_M)
    7.87 +
    7.88 +#define VGA_IO_START     0xA0000UL
    7.89 +#define VGA_IO_SIZE      0x20000
    7.90 +
    7.91 +#define LEGACY_IO_START  (MMIO_START + MMIO_SIZE)
    7.92 +#define LEGACY_IO_SIZE   (64*MEM_M)
    7.93 +
    7.94 +#define IO_PAGE_START (LEGACY_IO_START + LEGACY_IO_SIZE)
    7.95 +#define IO_PAGE_SIZE  PAGE_SIZE
    7.96 +
    7.97 +#define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
    7.98 +#define STORE_PAGE_SIZE  PAGE_SIZE
    7.99 +
   7.100 +#define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
   7.101 +#define BUFFER_IO_PAGE_SIZE PAGE_SIZE
   7.102 +
   7.103 +#define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
   7.104 +#define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
   7.105 +
   7.106 +#define IO_SAPIC_START   0xfec00000UL
   7.107 +#define IO_SAPIC_SIZE    0x100000
   7.108 +
   7.109 +#define PIB_START 0xfee00000UL
   7.110 +#define PIB_SIZE 0x200000
   7.111 +
   7.112 +#define GFW_START        (4*MEM_G -16*MEM_M)
   7.113 +#define GFW_SIZE         (16*MEM_M)
   7.114 +
   7.115 +/* Nvram belongs to GFW memory space  */
   7.116 +#define NVRAM_SIZE       (MEM_K * 64)
   7.117 +#define NVRAM_START      (GFW_START + 10 * MEM_M)
   7.118 +
   7.119 +#define NVRAM_VALID_SIG 0x4650494e45584948 		// "HIXENIPF"
   7.120 +struct nvram_save_addr {
   7.121 +    unsigned long addr;
   7.122 +    unsigned long signature;
   7.123 +};
   7.124 +
   7.125 +struct pt_fpreg {
   7.126 +    union {
   7.127 +        unsigned long bits[2];
   7.128 +        long double __dummy;    /* force 16-byte alignment */
   7.129 +    } u;
   7.130 +};
   7.131 +
   7.132 +struct cpu_user_regs {
   7.133 +    /* The following registers are saved by SAVE_MIN: */
   7.134 +    unsigned long b6;  /* scratch */
   7.135 +    unsigned long b7;  /* scratch */
   7.136 +
   7.137 +    unsigned long ar_csd; /* used by cmp8xchg16 (scratch) */
   7.138 +    unsigned long ar_ssd; /* reserved for future use (scratch) */
   7.139 +
   7.140 +    unsigned long r8;  /* scratch (return value register 0) */
   7.141 +    unsigned long r9;  /* scratch (return value register 1) */
   7.142 +    unsigned long r10; /* scratch (return value register 2) */
   7.143 +    unsigned long r11; /* scratch (return value register 3) */
   7.144 +
   7.145 +    unsigned long cr_ipsr; /* interrupted task's psr */
   7.146 +    unsigned long cr_iip;  /* interrupted task's instruction pointer */
   7.147 +    unsigned long cr_ifs;  /* interrupted task's function state */
   7.148 +
   7.149 +    unsigned long ar_unat; /* interrupted task's NaT register (preserved) */
   7.150 +    unsigned long ar_pfs;  /* prev function state  */
   7.151 +    unsigned long ar_rsc;  /* RSE configuration */
   7.152 +    /* The following two are valid only if cr_ipsr.cpl > 0: */
   7.153 +    unsigned long ar_rnat;  /* RSE NaT */
   7.154 +    unsigned long ar_bspstore; /* RSE bspstore */
   7.155 +
   7.156 +    unsigned long pr;  /* 64 predicate registers (1 bit each) */
   7.157 +    unsigned long b0;  /* return pointer (bp) */
   7.158 +    unsigned long loadrs;  /* size of dirty partition << 16 */
   7.159 +
   7.160 +    unsigned long r1;  /* the gp pointer */
   7.161 +    unsigned long r12; /* interrupted task's memory stack pointer */
   7.162 +    unsigned long r13; /* thread pointer */
   7.163 +
   7.164 +    unsigned long ar_fpsr;  /* floating point status (preserved) */
   7.165 +    unsigned long r15;  /* scratch */
   7.166 +
   7.167 + /* The remaining registers are NOT saved for system calls.  */
   7.168 +
   7.169 +    unsigned long r14;  /* scratch */
   7.170 +    unsigned long r2;  /* scratch */
   7.171 +    unsigned long r3;  /* scratch */
   7.172 +    unsigned long r16;  /* scratch */
   7.173 +    unsigned long r17;  /* scratch */
   7.174 +    unsigned long r18;  /* scratch */
   7.175 +    unsigned long r19;  /* scratch */
   7.176 +    unsigned long r20;  /* scratch */
   7.177 +    unsigned long r21;  /* scratch */
   7.178 +    unsigned long r22;  /* scratch */
   7.179 +    unsigned long r23;  /* scratch */
   7.180 +    unsigned long r24;  /* scratch */
   7.181 +    unsigned long r25;  /* scratch */
   7.182 +    unsigned long r26;  /* scratch */
   7.183 +    unsigned long r27;  /* scratch */
   7.184 +    unsigned long r28;  /* scratch */
   7.185 +    unsigned long r29;  /* scratch */
   7.186 +    unsigned long r30;  /* scratch */
   7.187 +    unsigned long r31;  /* scratch */
   7.188 +    unsigned long ar_ccv;  /* compare/exchange value (scratch) */
   7.189 +
   7.190 +    /*
   7.191 +     * Floating point registers that the kernel considers scratch:
   7.192 +     */
   7.193 +    struct pt_fpreg f6;  /* scratch */
   7.194 +    struct pt_fpreg f7;  /* scratch */
   7.195 +    struct pt_fpreg f8;  /* scratch */
   7.196 +    struct pt_fpreg f9;  /* scratch */
   7.197 +    struct pt_fpreg f10;  /* scratch */
   7.198 +    struct pt_fpreg f11;  /* scratch */
   7.199 +    unsigned long r4;  /* preserved */
   7.200 +    unsigned long r5;  /* preserved */
   7.201 +    unsigned long r6;  /* preserved */
   7.202 +    unsigned long r7;  /* preserved */
   7.203 +    unsigned long eml_unat;    /* used for emulating instruction */
   7.204 +    unsigned long pad0;     /* alignment pad */
   7.205 +
   7.206 +};
   7.207 +typedef struct cpu_user_regs cpu_user_regs_t;
   7.208 +
   7.209 +union vac {
   7.210 +    unsigned long value;
   7.211 +    struct {
   7.212 +        int a_int:1;
   7.213 +        int a_from_int_cr:1;
   7.214 +        int a_to_int_cr:1;
   7.215 +        int a_from_psr:1;
   7.216 +        int a_from_cpuid:1;
   7.217 +        int a_cover:1;
   7.218 +        int a_bsw:1;
   7.219 +        long reserved:57;
   7.220 +    };
   7.221 +};
   7.222 +typedef union vac vac_t;
   7.223 +
   7.224 +union vdc {
   7.225 +    unsigned long value;
   7.226 +    struct {
   7.227 +        int d_vmsw:1;
   7.228 +        int d_extint:1;
   7.229 +        int d_ibr_dbr:1;
   7.230 +        int d_pmc:1;
   7.231 +        int d_to_pmd:1;
   7.232 +        int d_itm:1;
   7.233 +        long reserved:58;
   7.234 +    };
   7.235 +};
   7.236 +typedef union vdc vdc_t;
   7.237 +
   7.238 +struct mapped_regs {
   7.239 +    union vac   vac;
   7.240 +    union vdc   vdc;
   7.241 +    unsigned long  virt_env_vaddr;
   7.242 +    unsigned long  reserved1[29];
   7.243 +    unsigned long  vhpi;
   7.244 +    unsigned long  reserved2[95];
   7.245 +    union {
   7.246 +        unsigned long  vgr[16];
   7.247 +        unsigned long bank1_regs[16]; // bank1 regs (r16-r31) when bank0 active
   7.248 +    };
   7.249 +    union {
   7.250 +        unsigned long  vbgr[16];
   7.251 +        unsigned long bank0_regs[16]; // bank0 regs (r16-r31) when bank1 active
   7.252 +    };
   7.253 +    unsigned long  vnat;
   7.254 +    unsigned long  vbnat;
   7.255 +    unsigned long  vcpuid[5];
   7.256 +    unsigned long  reserved3[11];
   7.257 +    unsigned long  vpsr;
   7.258 +    unsigned long  vpr;
   7.259 +    unsigned long  reserved4[76];
   7.260 +    union {
   7.261 +        unsigned long  vcr[128];
   7.262 +        struct {
   7.263 +            unsigned long dcr;  // CR0
   7.264 +            unsigned long itm;
   7.265 +            unsigned long iva;
   7.266 +            unsigned long rsv1[5];
   7.267 +            unsigned long pta;  // CR8
   7.268 +            unsigned long rsv2[7];
   7.269 +            unsigned long ipsr;  // CR16
   7.270 +            unsigned long isr;
   7.271 +            unsigned long rsv3;
   7.272 +            unsigned long iip;
   7.273 +            unsigned long ifa;
   7.274 +            unsigned long itir;
   7.275 +            unsigned long iipa;
   7.276 +            unsigned long ifs;
   7.277 +            unsigned long iim;  // CR24
   7.278 +            unsigned long iha;
   7.279 +            unsigned long rsv4[38];
   7.280 +            unsigned long lid;  // CR64
   7.281 +            unsigned long ivr;
   7.282 +            unsigned long tpr;
   7.283 +            unsigned long eoi;
   7.284 +            unsigned long irr[4];
   7.285 +            unsigned long itv;  // CR72
   7.286 +            unsigned long pmv;
   7.287 +            unsigned long cmcv;
   7.288 +            unsigned long rsv5[5];
   7.289 +            unsigned long lrr0;  // CR80
   7.290 +            unsigned long lrr1;
   7.291 +            unsigned long rsv6[46];
   7.292 +        };
   7.293 +    };
   7.294 +    union {
   7.295 +        unsigned long  reserved5[128];
   7.296 +        struct {
   7.297 +            unsigned long precover_ifs;
   7.298 +            unsigned long unat;  // not sure if this is needed until NaT arch is done
   7.299 +            int interrupt_collection_enabled; // virtual psr.ic
   7.300 +            /* virtual interrupt deliverable flag is evtchn_upcall_mask in
   7.301 +             * shared info area now. interrupt_mask_addr is the address
   7.302 +             * of evtchn_upcall_mask for current vcpu
   7.303 +             */
   7.304 +            unsigned char *interrupt_mask_addr;
   7.305 +            int pending_interruption;
   7.306 +            unsigned char vpsr_pp;
   7.307 +            unsigned char vpsr_dfh;
   7.308 +            unsigned char hpsr_dfh;
   7.309 +            unsigned char hpsr_mfh;
   7.310 +            unsigned long reserved5_1[4];
   7.311 +            int metaphysical_mode; // 1 = use metaphys mapping, 0 = use virtual
   7.312 +            int banknum; // 0 or 1, which virtual register bank is active
   7.313 +            unsigned long rrs[8]; // region registers
   7.314 +            unsigned long krs[8]; // kernel registers
   7.315 +            unsigned long pkrs[8]; // protection key registers
   7.316 +            unsigned long tmp[8]; // temp registers (e.g. for hyperprivops)
   7.317 +        };
   7.318 +    };
   7.319 +};
   7.320 +typedef struct mapped_regs mapped_regs_t;
   7.321 +
   7.322 +struct vpd {
   7.323 +    struct mapped_regs vpd_low;
   7.324 +    unsigned long  reserved6[3456];
   7.325 +    unsigned long  vmm_avail[128];
   7.326 +    unsigned long  reserved7[4096];
   7.327 +};
   7.328 +typedef struct vpd vpd_t;
   7.329 +
   7.330 +struct arch_vcpu_info {
   7.331 +};
   7.332 +typedef struct arch_vcpu_info arch_vcpu_info_t;
   7.333 +
   7.334 +struct arch_shared_info {
   7.335 +    /* PFN of the start_info page.  */
   7.336 +    unsigned long start_info_pfn;
   7.337 +
   7.338 +    /* Interrupt vector for event channel.  */
   7.339 +    int evtchn_vector;
   7.340 +
   7.341 +    uint64_t pad[32];
   7.342 +};
   7.343 +typedef struct arch_shared_info arch_shared_info_t;
   7.344 +
   7.345 +typedef unsigned long xen_callback_t;
   7.346 +
   7.347 +struct ia64_tr_entry {
   7.348 +    unsigned long pte;
   7.349 +    unsigned long itir;
   7.350 +    unsigned long vadr;
   7.351 +    unsigned long rid;
   7.352 +};
   7.353 +
   7.354 +struct vcpu_extra_regs {
   7.355 +    struct ia64_tr_entry itrs[8];
   7.356 +    struct ia64_tr_entry dtrs[8];
   7.357 +    unsigned long iva;
   7.358 +    unsigned long dcr;
   7.359 +    unsigned long event_callback_ip;
   7.360 +};
   7.361 +
   7.362 +struct vcpu_guest_context {
   7.363 +#define VGCF_EXTRA_REGS (1<<1)	/* Get/Set extra regs.  */
   7.364 +    unsigned long flags;       /* VGCF_* flags */
   7.365 +
   7.366 +    struct cpu_user_regs user_regs;
   7.367 +    struct vcpu_extra_regs extra_regs;
   7.368 +    unsigned long privregs_pfn;
   7.369 +};
   7.370 +typedef struct vcpu_guest_context vcpu_guest_context_t;
   7.371 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   7.372 +
   7.373 +/* dom0 vp op */
   7.374 +#define __HYPERVISOR_ia64_dom0vp_op     __HYPERVISOR_arch_0
   7.375 +/*  Map io space in machine address to dom0 physical address space.
   7.376 +    Currently physical assigned address equals to machine address.  */
   7.377 +#define IA64_DOM0VP_ioremap             0
   7.378 +
   7.379 +/* Convert a pseudo physical page frame number to the corresponding
   7.380 +   machine page frame number. If no page is assigned, INVALID_MFN or
   7.381 +   GPFN_INV_MASK is returned depending on domain's non-vti/vti mode.  */
   7.382 +#define IA64_DOM0VP_phystomach          1
   7.383 +
   7.384 +/* Convert a machine page frame number to the corresponding pseudo physical
   7.385 +   page frame number of the caller domain.  */
   7.386 +#define IA64_DOM0VP_machtophys          3
   7.387 +
   7.388 +/* Reserved for future use.  */
   7.389 +#define IA64_DOM0VP_iounmap             4
   7.390 +
   7.391 +/* Unmap and free pages contained in the specified pseudo physical region.  */
   7.392 +#define IA64_DOM0VP_zap_physmap         5
   7.393 +
   7.394 +/* Assign machine page frame to dom0's pseudo physical address space.  */
   7.395 +#define IA64_DOM0VP_add_physmap         6
   7.396 +
   7.397 +/* expose the p2m table into domain */
   7.398 +#define IA64_DOM0VP_expose_p2m          7
   7.399 +
   7.400 +/* xen perfmon */
   7.401 +#define IA64_DOM0VP_perfmon             8
   7.402 +
   7.403 +/* gmfn version of IA64_DOM0VP_add_physmap */
   7.404 +#define IA64_DOM0VP_add_physmap_with_gmfn       9
   7.405 +
   7.406 +/* Add an I/O port space range */
   7.407 +#define IA64_DOM0VP_add_io_space        11
   7.408 +
   7.409 +// flags for page assignement to pseudo physical address space
   7.410 +#define _ASSIGN_readonly                0
   7.411 +#define ASSIGN_readonly                 (1UL << _ASSIGN_readonly)
   7.412 +#define ASSIGN_writable                 (0UL << _ASSIGN_readonly) // dummy flag
   7.413 +/* Internal only: memory attribute must be WC/UC/UCE.  */
   7.414 +#define _ASSIGN_nocache                 1
   7.415 +#define ASSIGN_nocache                  (1UL << _ASSIGN_nocache)
   7.416 +// tlb tracking
   7.417 +#define _ASSIGN_tlb_track               2
   7.418 +#define ASSIGN_tlb_track                (1UL << _ASSIGN_tlb_track)
   7.419 +/* Internal only: associated with PGC_allocated bit */
   7.420 +#define _ASSIGN_pgc_allocated           3
   7.421 +#define ASSIGN_pgc_allocated            (1UL << _ASSIGN_pgc_allocated)
   7.422 +
   7.423 +/* This structure has the same layout of struct ia64_boot_param, defined in
   7.424 +   <asm/system.h>.  It is redefined here to ease use.  */
   7.425 +struct xen_ia64_boot_param {
   7.426 +	unsigned long command_line;	/* physical address of cmd line args */
   7.427 +	unsigned long efi_systab;	/* physical address of EFI system table */
   7.428 +	unsigned long efi_memmap;	/* physical address of EFI memory map */
   7.429 +	unsigned long efi_memmap_size;	/* size of EFI memory map */
   7.430 +	unsigned long efi_memdesc_size;	/* size of an EFI memory map descriptor */
   7.431 +	unsigned int  efi_memdesc_version;	/* memory descriptor version */
   7.432 +	struct {
   7.433 +		unsigned short num_cols;	/* number of columns on console.  */
   7.434 +		unsigned short num_rows;	/* number of rows on console.  */
   7.435 +		unsigned short orig_x;	/* cursor's x position */
   7.436 +		unsigned short orig_y;	/* cursor's y position */
   7.437 +	} console_info;
   7.438 +	unsigned long fpswa;		/* physical address of the fpswa interface */
   7.439 +	unsigned long initrd_start;
   7.440 +	unsigned long initrd_size;
   7.441 +	unsigned long domain_start;	/* va where the boot time domain begins */
   7.442 +	unsigned long domain_size;	/* how big is the boot domain */
   7.443 +};
   7.444 +
   7.445 +#endif /* !__ASSEMBLY__ */
   7.446 +
   7.447 +/* Size of the shared_info area (this is not related to page size).  */
   7.448 +#define XSI_SHIFT			14
   7.449 +#define XSI_SIZE			(1 << XSI_SHIFT)
   7.450 +/* Log size of mapped_regs area (64 KB - only 4KB is used).  */
   7.451 +#define XMAPPEDREGS_SHIFT		12
   7.452 +#define XMAPPEDREGS_SIZE		(1 << XMAPPEDREGS_SHIFT)
   7.453 +/* Offset of XASI (Xen arch shared info) wrt XSI_BASE.  */
   7.454 +#define XMAPPEDREGS_OFS			XSI_SIZE
   7.455 +
   7.456 +/* Hyperprivops.  */
   7.457 +#define HYPERPRIVOP_START		0x1
   7.458 +#define HYPERPRIVOP_RFI			(HYPERPRIVOP_START + 0x0)
   7.459 +#define HYPERPRIVOP_RSM_DT		(HYPERPRIVOP_START + 0x1)
   7.460 +#define HYPERPRIVOP_SSM_DT		(HYPERPRIVOP_START + 0x2)
   7.461 +#define HYPERPRIVOP_COVER		(HYPERPRIVOP_START + 0x3)
   7.462 +#define HYPERPRIVOP_ITC_D		(HYPERPRIVOP_START + 0x4)
   7.463 +#define HYPERPRIVOP_ITC_I		(HYPERPRIVOP_START + 0x5)
   7.464 +#define HYPERPRIVOP_SSM_I		(HYPERPRIVOP_START + 0x6)
   7.465 +#define HYPERPRIVOP_GET_IVR		(HYPERPRIVOP_START + 0x7)
   7.466 +#define HYPERPRIVOP_GET_TPR		(HYPERPRIVOP_START + 0x8)
   7.467 +#define HYPERPRIVOP_SET_TPR		(HYPERPRIVOP_START + 0x9)
   7.468 +#define HYPERPRIVOP_EOI			(HYPERPRIVOP_START + 0xa)
   7.469 +#define HYPERPRIVOP_SET_ITM		(HYPERPRIVOP_START + 0xb)
   7.470 +#define HYPERPRIVOP_THASH		(HYPERPRIVOP_START + 0xc)
   7.471 +#define HYPERPRIVOP_PTC_GA		(HYPERPRIVOP_START + 0xd)
   7.472 +#define HYPERPRIVOP_ITR_D		(HYPERPRIVOP_START + 0xe)
   7.473 +#define HYPERPRIVOP_GET_RR		(HYPERPRIVOP_START + 0xf)
   7.474 +#define HYPERPRIVOP_SET_RR		(HYPERPRIVOP_START + 0x10)
   7.475 +#define HYPERPRIVOP_SET_KR		(HYPERPRIVOP_START + 0x11)
   7.476 +#define HYPERPRIVOP_FC			(HYPERPRIVOP_START + 0x12)
   7.477 +#define HYPERPRIVOP_GET_CPUID		(HYPERPRIVOP_START + 0x13)
   7.478 +#define HYPERPRIVOP_GET_PMD		(HYPERPRIVOP_START + 0x14)
   7.479 +#define HYPERPRIVOP_GET_EFLAG		(HYPERPRIVOP_START + 0x15)
   7.480 +#define HYPERPRIVOP_SET_EFLAG		(HYPERPRIVOP_START + 0x16)
   7.481 +#define HYPERPRIVOP_RSM_BE		(HYPERPRIVOP_START + 0x17)
   7.482 +#define HYPERPRIVOP_GET_PSR		(HYPERPRIVOP_START + 0x18)
   7.483 +#define HYPERPRIVOP_MAX			(0x19)
   7.484 +
   7.485 +/* Fast and light hypercalls.  */
   7.486 +#define __HYPERVISOR_ia64_fast_eoi	__HYPERVISOR_arch_1
   7.487 +
   7.488 +/* Xencomm macros.  */
   7.489 +#define XENCOMM_INLINE_MASK 0xf800000000000000UL
   7.490 +#define XENCOMM_INLINE_FLAG 0x8000000000000000UL
   7.491 +
   7.492 +#define XENCOMM_IS_INLINE(addr) \
   7.493 +  (((unsigned long)(addr) & XENCOMM_INLINE_MASK) == XENCOMM_INLINE_FLAG)
   7.494 +#define XENCOMM_INLINE_ADDR(addr) \
   7.495 +  ((unsigned long)(addr) & ~XENCOMM_INLINE_MASK)
   7.496 +
   7.497 +/* xen perfmon */
   7.498 +#ifdef XEN
   7.499 +#ifndef __ASSEMBLY__
   7.500 +#ifndef _ASM_IA64_PERFMON_H
   7.501 +
   7.502 +#include <xen/list.h>   // asm/perfmon.h requires struct list_head
   7.503 +#include <asm/perfmon.h>
   7.504 +// for PFM_xxx and pfarg_features_t, pfarg_context_t, pfarg_reg_t, pfarg_load_t
   7.505 +
   7.506 +#endif /* _ASM_IA64_PERFMON_H */
   7.507 +
   7.508 +DEFINE_XEN_GUEST_HANDLE(pfarg_features_t);
   7.509 +DEFINE_XEN_GUEST_HANDLE(pfarg_context_t);
   7.510 +DEFINE_XEN_GUEST_HANDLE(pfarg_reg_t);
   7.511 +DEFINE_XEN_GUEST_HANDLE(pfarg_load_t);
   7.512 +#endif /* __ASSEMBLY__ */
   7.513 +#endif /* XEN */
   7.514 +
   7.515 +#endif /* __HYPERVISOR_IF_IA64_H__ */
   7.516 +
   7.517 +/*
   7.518 + * Local variables:
   7.519 + * mode: C
   7.520 + * c-set-style: "BSD"
   7.521 + * c-basic-offset: 4
   7.522 + * tab-width: 4
   7.523 + * indent-tabs-mode: nil
   7.524 + * End:
   7.525 + */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/common/include/public/arch-powerpc.h	Wed Dec 05 11:14:28 2007 -0800
     8.3 @@ -0,0 +1,125 @@
     8.4 +/*
     8.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
     8.6 + * of this software and associated documentation files (the "Software"), to
     8.7 + * deal in the Software without restriction, including without limitation the
     8.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     8.9 + * sell copies of the Software, and to permit persons to whom the Software is
    8.10 + * furnished to do so, subject to the following conditions:
    8.11 + *
    8.12 + * The above copyright notice and this permission notice shall be included in
    8.13 + * all copies or substantial portions of the Software.
    8.14 + *
    8.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    8.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    8.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    8.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    8.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    8.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    8.21 + * DEALINGS IN THE SOFTWARE.
    8.22 + *
    8.23 + * Copyright (C) IBM Corp. 2005, 2006
    8.24 + *
    8.25 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
    8.26 + */
    8.27 +
    8.28 +#ifndef __XEN_PUBLIC_ARCH_PPC_64_H__
    8.29 +#define __XEN_PUBLIC_ARCH_PPC_64_H__
    8.30 +
    8.31 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    8.32 +    typedef struct { \
    8.33 +        int __pad[(sizeof (long long) - sizeof (void *)) / sizeof (int)]; \
    8.34 +        type *p; \
    8.35 +    } __attribute__((__aligned__(8))) __guest_handle_ ## name
    8.36 +
    8.37 +#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
    8.38 +#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
    8.39 +#define set_xen_guest_handle(hnd, val) \
    8.40 +    do { \
    8.41 +        if (sizeof ((hnd).__pad)) \
    8.42 +            (hnd).__pad[0] = 0; \
    8.43 +        (hnd).p = val; \
    8.44 +    } while (0)
    8.45 +
    8.46 +#ifdef __XEN_TOOLS__
    8.47 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    8.48 +#endif
    8.49 +
    8.50 +#ifndef __ASSEMBLY__
    8.51 +/* Guest handles for primitive C types. */
    8.52 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    8.53 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    8.54 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    8.55 +DEFINE_XEN_GUEST_HANDLE(char);
    8.56 +DEFINE_XEN_GUEST_HANDLE(int);
    8.57 +DEFINE_XEN_GUEST_HANDLE(long);
    8.58 +DEFINE_XEN_GUEST_HANDLE(void);
    8.59 +
    8.60 +typedef unsigned long long xen_pfn_t;
    8.61 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    8.62 +#define PRI_xen_pfn "llx"
    8.63 +#endif
    8.64 +
    8.65 +/*
    8.66 + * Pointers and other address fields inside interface structures are padded to
    8.67 + * 64 bits. This means that field alignments aren't different between 32- and
    8.68 + * 64-bit architectures. 
    8.69 + */
    8.70 +/* NB. Multi-level macro ensures __LINE__ is expanded before concatenation. */
    8.71 +#define __MEMORY_PADDING(_X)
    8.72 +#define _MEMORY_PADDING(_X)  __MEMORY_PADDING(_X)
    8.73 +#define MEMORY_PADDING       _MEMORY_PADDING(__LINE__)
    8.74 +
    8.75 +/* And the trap vector is... */
    8.76 +#define TRAP_INSTR "li 0,-1; sc" /* XXX just "sc"? */
    8.77 +
    8.78 +#ifndef __ASSEMBLY__
    8.79 +
    8.80 +#define XENCOMM_INLINE_FLAG (1UL << 63)
    8.81 +
    8.82 +typedef uint64_t xen_ulong_t;
    8.83 +
    8.84 +/* User-accessible registers: nost of these need to be saved/restored
    8.85 + * for every nested Xen invocation. */
    8.86 +struct cpu_user_regs
    8.87 +{
    8.88 +    uint64_t gprs[32];
    8.89 +    uint64_t lr;
    8.90 +    uint64_t ctr;
    8.91 +    uint64_t srr0;
    8.92 +    uint64_t srr1;
    8.93 +    uint64_t pc;
    8.94 +    uint64_t msr;
    8.95 +    uint64_t fpscr;             /* XXX Is this necessary */
    8.96 +    uint64_t xer;
    8.97 +    uint64_t hid4;              /* debug only */
    8.98 +    uint64_t dar;               /* debug only */
    8.99 +    uint32_t dsisr;             /* debug only */
   8.100 +    uint32_t cr;
   8.101 +    uint32_t __pad;             /* good spot for another 32bit reg */
   8.102 +    uint32_t entry_vector;
   8.103 +};
   8.104 +typedef struct cpu_user_regs cpu_user_regs_t;
   8.105 +
   8.106 +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ /* XXX timebase */
   8.107 +
   8.108 +/* ONLY used to communicate with dom0! See also struct exec_domain. */
   8.109 +struct vcpu_guest_context {
   8.110 +    cpu_user_regs_t user_regs;         /* User-level CPU registers     */
   8.111 +    uint64_t sdr1;                     /* Pagetable base               */
   8.112 +    /* XXX etc */
   8.113 +};
   8.114 +typedef struct vcpu_guest_context vcpu_guest_context_t;
   8.115 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   8.116 +
   8.117 +struct arch_shared_info {
   8.118 +    uint64_t boot_timebase;
   8.119 +};
   8.120 +
   8.121 +struct arch_vcpu_info {
   8.122 +};
   8.123 +
   8.124 +/* Support for multi-processor guests. */
   8.125 +#define MAX_VIRT_CPUS 32
   8.126 +#endif
   8.127 +
   8.128 +#endif
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/common/include/public/arch-x86/xen-x86_32.h	Wed Dec 05 11:14:28 2007 -0800
     9.3 @@ -0,0 +1,184 @@
     9.4 +/******************************************************************************
     9.5 + * xen-x86_32.h
     9.6 + * 
     9.7 + * Guest OS interface to x86 32-bit Xen.
     9.8 + * 
     9.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    9.10 + * of this software and associated documentation files (the "Software"), to
    9.11 + * deal in the Software without restriction, including without limitation the
    9.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    9.13 + * sell copies of the Software, and to permit persons to whom the Software is
    9.14 + * furnished to do so, subject to the following conditions:
    9.15 + *
    9.16 + * The above copyright notice and this permission notice shall be included in
    9.17 + * all copies or substantial portions of the Software.
    9.18 + *
    9.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    9.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    9.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    9.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    9.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    9.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    9.25 + * DEALINGS IN THE SOFTWARE.
    9.26 + *
    9.27 + * Copyright (c) 2004-2007, K A Fraser
    9.28 + */
    9.29 +
    9.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
    9.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
    9.32 +
    9.33 +/*
    9.34 + * Hypercall interface:
    9.35 + *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
    9.36 + *  Output: %eax
    9.37 + * Access is via hypercall page (set up by guest loader or via a Xen MSR):
    9.38 + *  call hypercall_page + hypercall-number * 32
    9.39 + * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
    9.40 + */
    9.41 +
    9.42 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
    9.43 +/*
    9.44 + * Legacy hypercall interface:
    9.45 + * As above, except the entry sequence to the hypervisor is:
    9.46 + *  mov $hypercall-number*32,%eax ; int $0x82
    9.47 + */
    9.48 +#define TRAP_INSTR "int $0x82"
    9.49 +#endif
    9.50 +
    9.51 +/*
    9.52 + * These flat segments are in the Xen-private section of every GDT. Since these
    9.53 + * are also present in the initial GDT, many OSes will be able to avoid
    9.54 + * installing their own GDT.
    9.55 + */
    9.56 +#define FLAT_RING1_CS 0xe019    /* GDT index 259 */
    9.57 +#define FLAT_RING1_DS 0xe021    /* GDT index 260 */
    9.58 +#define FLAT_RING1_SS 0xe021    /* GDT index 260 */
    9.59 +#define FLAT_RING3_CS 0xe02b    /* GDT index 261 */
    9.60 +#define FLAT_RING3_DS 0xe033    /* GDT index 262 */
    9.61 +#define FLAT_RING3_SS 0xe033    /* GDT index 262 */
    9.62 +
    9.63 +#define FLAT_KERNEL_CS FLAT_RING1_CS
    9.64 +#define FLAT_KERNEL_DS FLAT_RING1_DS
    9.65 +#define FLAT_KERNEL_SS FLAT_RING1_SS
    9.66 +#define FLAT_USER_CS    FLAT_RING3_CS
    9.67 +#define FLAT_USER_DS    FLAT_RING3_DS
    9.68 +#define FLAT_USER_SS    FLAT_RING3_SS
    9.69 +
    9.70 +#define __HYPERVISOR_VIRT_START_PAE    0xF5800000
    9.71 +#define __MACH2PHYS_VIRT_START_PAE     0xF5800000
    9.72 +#define __MACH2PHYS_VIRT_END_PAE       0xF6800000
    9.73 +#define HYPERVISOR_VIRT_START_PAE      \
    9.74 +    mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
    9.75 +#define MACH2PHYS_VIRT_START_PAE       \
    9.76 +    mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
    9.77 +#define MACH2PHYS_VIRT_END_PAE         \
    9.78 +    mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
    9.79 +
    9.80 +#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
    9.81 +#define __MACH2PHYS_VIRT_START_NONPAE  0xFC000000
    9.82 +#define __MACH2PHYS_VIRT_END_NONPAE    0xFC400000
    9.83 +#define HYPERVISOR_VIRT_START_NONPAE   \
    9.84 +    mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
    9.85 +#define MACH2PHYS_VIRT_START_NONPAE    \
    9.86 +    mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
    9.87 +#define MACH2PHYS_VIRT_END_NONPAE      \
    9.88 +    mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
    9.89 +
    9.90 +#ifdef CONFIG_X86_PAE
    9.91 +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
    9.92 +#define __MACH2PHYS_VIRT_START  __MACH2PHYS_VIRT_START_PAE
    9.93 +#define __MACH2PHYS_VIRT_END    __MACH2PHYS_VIRT_END_PAE
    9.94 +#else
    9.95 +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_NONPAE
    9.96 +#define __MACH2PHYS_VIRT_START  __MACH2PHYS_VIRT_START_NONPAE
    9.97 +#define __MACH2PHYS_VIRT_END    __MACH2PHYS_VIRT_END_NONPAE
    9.98 +#endif
    9.99 +
   9.100 +#ifndef HYPERVISOR_VIRT_START
   9.101 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
   9.102 +#endif
   9.103 +
   9.104 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
   9.105 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
   9.106 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
   9.107 +#ifndef machine_to_phys_mapping
   9.108 +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
   9.109 +#endif
   9.110 +
   9.111 +/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
   9.112 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
   9.113 +#undef __DEFINE_XEN_GUEST_HANDLE
   9.114 +#define __DEFINE_XEN_GUEST_HANDLE(name, type)                   \
   9.115 +    typedef struct { type *p; }                                 \
   9.116 +        __guest_handle_ ## name;                                \
   9.117 +    typedef struct { union { type *p; uint64_aligned_t q; }; }  \
   9.118 +        __guest_handle_64_ ## name
   9.119 +#undef set_xen_guest_handle
   9.120 +#define set_xen_guest_handle(hnd, val)                      \
   9.121 +    do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0;   \
   9.122 +         (hnd).p = val;                                     \
   9.123 +    } while ( 0 )
   9.124 +#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
   9.125 +#define XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
   9.126 +#endif
   9.127 +
   9.128 +#ifndef __ASSEMBLY__
   9.129 +
   9.130 +struct cpu_user_regs {
   9.131 +    uint32_t ebx;
   9.132 +    uint32_t ecx;
   9.133 +    uint32_t edx;
   9.134 +    uint32_t esi;
   9.135 +    uint32_t edi;
   9.136 +    uint32_t ebp;
   9.137 +    uint32_t eax;
   9.138 +    uint16_t error_code;    /* private */
   9.139 +    uint16_t entry_vector;  /* private */
   9.140 +    uint32_t eip;
   9.141 +    uint16_t cs;
   9.142 +    uint8_t  saved_upcall_mask;
   9.143 +    uint8_t  _pad0;
   9.144 +    uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
   9.145 +    uint32_t esp;
   9.146 +    uint16_t ss, _pad1;
   9.147 +    uint16_t es, _pad2;
   9.148 +    uint16_t ds, _pad3;
   9.149 +    uint16_t fs, _pad4;
   9.150 +    uint16_t gs, _pad5;
   9.151 +};
   9.152 +typedef struct cpu_user_regs cpu_user_regs_t;
   9.153 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
   9.154 +
   9.155 +/*
   9.156 + * Page-directory addresses above 4GB do not fit into architectural %cr3.
   9.157 + * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
   9.158 + * must use the following accessor macros to pack/unpack valid MFNs.
   9.159 + */
   9.160 +#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
   9.161 +#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
   9.162 +
   9.163 +struct arch_vcpu_info {
   9.164 +    unsigned long cr2;
   9.165 +    unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
   9.166 +};
   9.167 +typedef struct arch_vcpu_info arch_vcpu_info_t;
   9.168 +
   9.169 +struct xen_callback {
   9.170 +    unsigned long cs;
   9.171 +    unsigned long eip;
   9.172 +};
   9.173 +typedef struct xen_callback xen_callback_t;
   9.174 +
   9.175 +#endif /* !__ASSEMBLY__ */
   9.176 +
   9.177 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
   9.178 +
   9.179 +/*
   9.180 + * Local variables:
   9.181 + * mode: C
   9.182 + * c-set-style: "BSD"
   9.183 + * c-basic-offset: 4
   9.184 + * tab-width: 4
   9.185 + * indent-tabs-mode: nil
   9.186 + * End:
   9.187 + */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/common/include/public/arch-x86/xen-x86_64.h	Wed Dec 05 11:14:28 2007 -0800
    10.3 @@ -0,0 +1,211 @@
    10.4 +/******************************************************************************
    10.5 + * xen-x86_64.h
    10.6 + * 
    10.7 + * Guest OS interface to x86 64-bit Xen.
    10.8 + * 
    10.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   10.10 + * of this software and associated documentation files (the "Software"), to
   10.11 + * deal in the Software without restriction, including without limitation the
   10.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   10.13 + * sell copies of the Software, and to permit persons to whom the Software is
   10.14 + * furnished to do so, subject to the following conditions:
   10.15 + *
   10.16 + * The above copyright notice and this permission notice shall be included in
   10.17 + * all copies or substantial portions of the Software.
   10.18 + *
   10.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   10.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   10.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   10.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   10.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   10.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   10.25 + * DEALINGS IN THE SOFTWARE.
   10.26 + *
   10.27 + * Copyright (c) 2004-2006, K A Fraser
   10.28 + */
   10.29 +
   10.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
   10.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
   10.32 +
   10.33 +/*
   10.34 + * Hypercall interface:
   10.35 + *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
   10.36 + *  Output: %rax
   10.37 + * Access is via hypercall page (set up by guest loader or via a Xen MSR):
   10.38 + *  call hypercall_page + hypercall-number * 32
   10.39 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi)
   10.40 + */
   10.41 +
   10.42 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
   10.43 +/*
   10.44 + * Legacy hypercall interface:
   10.45 + * As above, except the entry sequence to the hypervisor is:
   10.46 + *  mov $hypercall-number*32,%eax ; syscall
   10.47 + * Clobbered: %rcx, %r11, argument registers (as above)
   10.48 + */
   10.49 +#define TRAP_INSTR "syscall"
   10.50 +#endif
   10.51 +
   10.52 +/*
   10.53 + * 64-bit segment selectors
   10.54 + * These flat segments are in the Xen-private section of every GDT. Since these
   10.55 + * are also present in the initial GDT, many OSes will be able to avoid
   10.56 + * installing their own GDT.
   10.57 + */
   10.58 +
   10.59 +#define FLAT_RING3_CS32 0xe023  /* GDT index 260 */
   10.60 +#define FLAT_RING3_CS64 0xe033  /* GDT index 261 */
   10.61 +#define FLAT_RING3_DS32 0xe02b  /* GDT index 262 */
   10.62 +#define FLAT_RING3_DS64 0x0000  /* NULL selector */
   10.63 +#define FLAT_RING3_SS32 0xe02b  /* GDT index 262 */
   10.64 +#define FLAT_RING3_SS64 0xe02b  /* GDT index 262 */
   10.65 +
   10.66 +#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
   10.67 +#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
   10.68 +#define FLAT_KERNEL_DS   FLAT_KERNEL_DS64
   10.69 +#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
   10.70 +#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
   10.71 +#define FLAT_KERNEL_CS   FLAT_KERNEL_CS64
   10.72 +#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
   10.73 +#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
   10.74 +#define FLAT_KERNEL_SS   FLAT_KERNEL_SS64
   10.75 +
   10.76 +#define FLAT_USER_DS64 FLAT_RING3_DS64
   10.77 +#define FLAT_USER_DS32 FLAT_RING3_DS32
   10.78 +#define FLAT_USER_DS   FLAT_USER_DS64
   10.79 +#define FLAT_USER_CS64 FLAT_RING3_CS64
   10.80 +#define FLAT_USER_CS32 FLAT_RING3_CS32
   10.81 +#define FLAT_USER_CS   FLAT_USER_CS64
   10.82 +#define FLAT_USER_SS64 FLAT_RING3_SS64
   10.83 +#define FLAT_USER_SS32 FLAT_RING3_SS32
   10.84 +#define FLAT_USER_SS   FLAT_USER_SS64
   10.85 +
   10.86 +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
   10.87 +#define __HYPERVISOR_VIRT_END   0xFFFF880000000000
   10.88 +#define __MACH2PHYS_VIRT_START  0xFFFF800000000000
   10.89 +#define __MACH2PHYS_VIRT_END    0xFFFF804000000000
   10.90 +
   10.91 +#ifndef HYPERVISOR_VIRT_START
   10.92 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
   10.93 +#define HYPERVISOR_VIRT_END   mk_unsigned_long(__HYPERVISOR_VIRT_END)
   10.94 +#endif
   10.95 +
   10.96 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
   10.97 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
   10.98 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
   10.99 +#ifndef machine_to_phys_mapping
  10.100 +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
  10.101 +#endif
  10.102 +
  10.103 +#ifndef __ASSEMBLY__
  10.104 +
  10.105 +/*
  10.106 + * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
  10.107 + *  @which == SEGBASE_*  ;  @base == 64-bit base address
  10.108 + * Returns 0 on success.
  10.109 + */
  10.110 +#define SEGBASE_FS          0
  10.111 +#define SEGBASE_GS_USER     1
  10.112 +#define SEGBASE_GS_KERNEL   2
  10.113 +#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
  10.114 +
  10.115 +/*
  10.116 + * int HYPERVISOR_iret(void)
  10.117 + * All arguments are on the kernel stack, in the following format.
  10.118 + * Never returns if successful. Current kernel context is lost.
  10.119 + * The saved CS is mapped as follows:
  10.120 + *   RING0 -> RING3 kernel mode.
  10.121 + *   RING1 -> RING3 kernel mode.
  10.122 + *   RING2 -> RING3 kernel mode.
  10.123 + *   RING3 -> RING3 user mode.
  10.124 + * However RING0 indicates that the guest kernel should return to iteself
  10.125 + * directly with
  10.126 + *      orb   $3,1*8(%rsp)
  10.127 + *      iretq
  10.128 + * If flags contains VGCF_in_syscall:
  10.129 + *   Restore RAX, RIP, RFLAGS, RSP.
  10.130 + *   Discard R11, RCX, CS, SS.
  10.131 + * Otherwise:
  10.132 + *   Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.
  10.133 + * All other registers are saved on hypercall entry and restored to user.
  10.134 + */
  10.135 +/* Guest exited in SYSCALL context? Return to guest with SYSRET? */
  10.136 +#define _VGCF_in_syscall 8
  10.137 +#define VGCF_in_syscall  (1<<_VGCF_in_syscall)
  10.138 +#define VGCF_IN_SYSCALL  VGCF_in_syscall
  10.139 +struct iret_context {
  10.140 +    /* Top of stack (%rsp at point of hypercall). */
  10.141 +    uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
  10.142 +    /* Bottom of iret stack frame. */
  10.143 +};
  10.144 +
  10.145 +#ifdef __GNUC__
  10.146 +/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
  10.147 +#define __DECL_REG(name) union { \
  10.148 +    uint64_t r ## name, e ## name; \
  10.149 +    uint32_t _e ## name; \
  10.150 +}
  10.151 +#else
  10.152 +/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
  10.153 +#define __DECL_REG(name) uint64_t r ## name
  10.154 +#endif
  10.155 +
  10.156 +struct cpu_user_regs {
  10.157 +    uint64_t r15;
  10.158 +    uint64_t r14;
  10.159 +    uint64_t r13;
  10.160 +    uint64_t r12;
  10.161 +    __DECL_REG(bp);
  10.162 +    __DECL_REG(bx);
  10.163 +    uint64_t r11;
  10.164 +    uint64_t r10;
  10.165 +    uint64_t r9;
  10.166 +    uint64_t r8;
  10.167 +    __DECL_REG(ax);
  10.168 +    __DECL_REG(cx);
  10.169 +    __DECL_REG(dx);
  10.170 +    __DECL_REG(si);
  10.171 +    __DECL_REG(di);
  10.172 +    uint32_t error_code;    /* private */
  10.173 +    uint32_t entry_vector;  /* private */
  10.174 +    __DECL_REG(ip);
  10.175 +    uint16_t cs, _pad0[1];
  10.176 +    uint8_t  saved_upcall_mask;
  10.177 +    uint8_t  _pad1[3];
  10.178 +    __DECL_REG(flags);      /* rflags.IF == !saved_upcall_mask */
  10.179 +    __DECL_REG(sp);
  10.180 +    uint16_t ss, _pad2[3];
  10.181 +    uint16_t es, _pad3[3];
  10.182 +    uint16_t ds, _pad4[3];
  10.183 +    uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
  10.184 +    uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
  10.185 +};
  10.186 +typedef struct cpu_user_regs cpu_user_regs_t;
  10.187 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
  10.188 +
  10.189 +#undef __DECL_REG
  10.190 +
  10.191 +#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
  10.192 +#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
  10.193 +
  10.194 +struct arch_vcpu_info {
  10.195 +    unsigned long cr2;
  10.196 +    unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
  10.197 +};
  10.198 +typedef struct arch_vcpu_info arch_vcpu_info_t;
  10.199 +
  10.200 +typedef unsigned long xen_callback_t;
  10.201 +
  10.202 +#endif /* !__ASSEMBLY__ */
  10.203 +
  10.204 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */
  10.205 +
  10.206 +/*
  10.207 + * Local variables:
  10.208 + * mode: C
  10.209 + * c-set-style: "BSD"
  10.210 + * c-basic-offset: 4
  10.211 + * tab-width: 4
  10.212 + * indent-tabs-mode: nil
  10.213 + * End:
  10.214 + */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/common/include/public/arch-x86/xen.h	Wed Dec 05 11:14:28 2007 -0800
    11.3 @@ -0,0 +1,205 @@
    11.4 +/******************************************************************************
    11.5 + * arch-x86/xen.h
    11.6 + * 
    11.7 + * Guest OS interface to x86 Xen.
    11.8 + * 
    11.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   11.10 + * of this software and associated documentation files (the "Software"), to
   11.11 + * deal in the Software without restriction, including without limitation the
   11.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   11.13 + * sell copies of the Software, and to permit persons to whom the Software is
   11.14 + * furnished to do so, subject to the following conditions:
   11.15 + *
   11.16 + * The above copyright notice and this permission notice shall be included in
   11.17 + * all copies or substantial portions of the Software.
   11.18 + *
   11.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   11.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   11.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   11.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   11.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   11.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   11.25 + * DEALINGS IN THE SOFTWARE.
   11.26 + *
   11.27 + * Copyright (c) 2004-2006, K A Fraser
   11.28 + */
   11.29 +
   11.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
   11.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_H__
   11.32 +
   11.33 +/* Structural guest handles introduced in 0x00030201. */
   11.34 +#if __XEN_INTERFACE_VERSION__ >= 0x00030201
   11.35 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   11.36 +    typedef struct { type *p; } __guest_handle_ ## name
   11.37 +#else
   11.38 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   11.39 +    typedef type * __guest_handle_ ## name
   11.40 +#endif
   11.41 +
   11.42 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
   11.43 +#define __XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
   11.44 +#define XEN_GUEST_HANDLE(name)          __XEN_GUEST_HANDLE(name)
   11.45 +#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
   11.46 +#ifdef __XEN_TOOLS__
   11.47 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
   11.48 +#endif
   11.49 +
   11.50 +#if defined(__i386__)
   11.51 +#include "xen-x86_32.h"
   11.52 +#elif defined(__x86_64__)
   11.53 +#include "xen-x86_64.h"
   11.54 +#endif
   11.55 +
   11.56 +#ifndef __ASSEMBLY__
   11.57 +/* Guest handles for primitive C types. */
   11.58 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
   11.59 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
   11.60 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
   11.61 +DEFINE_XEN_GUEST_HANDLE(char);
   11.62 +DEFINE_XEN_GUEST_HANDLE(int);
   11.63 +DEFINE_XEN_GUEST_HANDLE(long);
   11.64 +DEFINE_XEN_GUEST_HANDLE(void);
   11.65 +
   11.66 +typedef unsigned long xen_pfn_t;
   11.67 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
   11.68 +#define PRI_xen_pfn "lx"
   11.69 +#endif
   11.70 +
   11.71 +/*
   11.72 + * SEGMENT DESCRIPTOR TABLES
   11.73 + */
   11.74 +/*
   11.75 + * A number of GDT entries are reserved by Xen. These are not situated at the
   11.76 + * start of the GDT because some stupid OSes export hard-coded selector values
   11.77 + * in their ABI. These hard-coded values are always near the start of the GDT,
   11.78 + * so Xen places itself out of the way, at the far end of the GDT.
   11.79 + */
   11.80 +#define FIRST_RESERVED_GDT_PAGE  14
   11.81 +#define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
   11.82 +#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
   11.83 +
   11.84 +/* Maximum number of virtual CPUs in multi-processor guests. */
   11.85 +#define MAX_VIRT_CPUS 32
   11.86 +
   11.87 +#ifndef __ASSEMBLY__
   11.88 +
   11.89 +typedef unsigned long xen_ulong_t;
   11.90 +
   11.91 +/*
   11.92 + * Send an array of these to HYPERVISOR_set_trap_table().
   11.93 + * The privilege level specifies which modes may enter a trap via a software
   11.94 + * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
   11.95 + * privilege levels as follows:
   11.96 + *  Level == 0: Noone may enter
   11.97 + *  Level == 1: Kernel may enter
   11.98 + *  Level == 2: Kernel may enter
   11.99 + *  Level == 3: Everyone may enter
  11.100 + */
  11.101 +#define TI_GET_DPL(_ti)      ((_ti)->flags & 3)
  11.102 +#define TI_GET_IF(_ti)       ((_ti)->flags & 4)
  11.103 +#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
  11.104 +#define TI_SET_IF(_ti,_if)   ((_ti)->flags |= ((!!(_if))<<2))
  11.105 +struct trap_info {
  11.106 +    uint8_t       vector;  /* exception vector                              */
  11.107 +    uint8_t       flags;   /* 0-3: privilege level; 4: clear event enable?  */
  11.108 +    uint16_t      cs;      /* code selector                                 */
  11.109 +    unsigned long address; /* code offset                                   */
  11.110 +};
  11.111 +typedef struct trap_info trap_info_t;
  11.112 +DEFINE_XEN_GUEST_HANDLE(trap_info_t);
  11.113 +
  11.114 +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
  11.115 +
  11.116 +/*
  11.117 + * The following is all CPU context. Note that the fpu_ctxt block is filled 
  11.118 + * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
  11.119 + */
  11.120 +struct vcpu_guest_context {
  11.121 +    /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
  11.122 +    struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
  11.123 +#define VGCF_I387_VALID                (1<<0)
  11.124 +#define VGCF_IN_KERNEL                 (1<<2)
  11.125 +#define _VGCF_i387_valid               0
  11.126 +#define VGCF_i387_valid                (1<<_VGCF_i387_valid)
  11.127 +#define _VGCF_in_kernel                2
  11.128 +#define VGCF_in_kernel                 (1<<_VGCF_in_kernel)
  11.129 +#define _VGCF_failsafe_disables_events 3
  11.130 +#define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
  11.131 +#define _VGCF_syscall_disables_events  4
  11.132 +#define VGCF_syscall_disables_events   (1<<_VGCF_syscall_disables_events)
  11.133 +#define _VGCF_online                   5
  11.134 +#define VGCF_online                    (1<<_VGCF_online)
  11.135 +    unsigned long flags;                    /* VGCF_* flags                 */
  11.136 +    struct cpu_user_regs user_regs;         /* User-level CPU registers     */
  11.137 +    struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
  11.138 +    unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
  11.139 +    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
  11.140 +    unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
  11.141 +    /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
  11.142 +    unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
  11.143 +    unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
  11.144 +#ifdef __i386__
  11.145 +    unsigned long event_callback_cs;        /* CS:EIP of event callback     */
  11.146 +    unsigned long event_callback_eip;
  11.147 +    unsigned long failsafe_callback_cs;     /* CS:EIP of failsafe callback  */
  11.148 +    unsigned long failsafe_callback_eip;
  11.149 +#else
  11.150 +    unsigned long event_callback_eip;
  11.151 +    unsigned long failsafe_callback_eip;
  11.152 +#ifdef __XEN__
  11.153 +    union {
  11.154 +        unsigned long syscall_callback_eip;
  11.155 +        struct {
  11.156 +            unsigned int event_callback_cs;    /* compat CS of event cb     */
  11.157 +            unsigned int failsafe_callback_cs; /* compat CS of failsafe cb  */
  11.158 +        };
  11.159 +    };
  11.160 +#else
  11.161 +    unsigned long syscall_callback_eip;
  11.162 +#endif
  11.163 +#endif
  11.164 +    unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
  11.165 +#ifdef __x86_64__
  11.166 +    /* Segment base addresses. */
  11.167 +    uint64_t      fs_base;
  11.168 +    uint64_t      gs_base_kernel;
  11.169 +    uint64_t      gs_base_user;
  11.170 +#endif
  11.171 +};
  11.172 +typedef struct vcpu_guest_context vcpu_guest_context_t;
  11.173 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
  11.174 +
  11.175 +struct arch_shared_info {
  11.176 +    unsigned long max_pfn;                  /* max pfn that appears in table */
  11.177 +    /* Frame containing list of mfns containing list of mfns containing p2m. */
  11.178 +    xen_pfn_t     pfn_to_mfn_frame_list_list;
  11.179 +    unsigned long nmi_reason;
  11.180 +    uint64_t pad[32];
  11.181 +};
  11.182 +typedef struct arch_shared_info arch_shared_info_t;
  11.183 +
  11.184 +#endif /* !__ASSEMBLY__ */
  11.185 +
  11.186 +/*
  11.187 + * Prefix forces emulation of some non-trapping instructions.
  11.188 + * Currently only CPUID.
  11.189 + */
  11.190 +#ifdef __ASSEMBLY__
  11.191 +#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
  11.192 +#define XEN_CPUID          XEN_EMULATE_PREFIX cpuid
  11.193 +#else
  11.194 +#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
  11.195 +#define XEN_CPUID          XEN_EMULATE_PREFIX "cpuid"
  11.196 +#endif
  11.197 +
  11.198 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
  11.199 +
  11.200 +/*
  11.201 + * Local variables:
  11.202 + * mode: C
  11.203 + * c-set-style: "BSD"
  11.204 + * c-basic-offset: 4
  11.205 + * tab-width: 4
  11.206 + * indent-tabs-mode: nil
  11.207 + * End:
  11.208 + */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/common/include/public/arch-x86_32.h	Wed Dec 05 11:14:28 2007 -0800
    12.3 @@ -0,0 +1,27 @@
    12.4 +/******************************************************************************
    12.5 + * arch-x86_32.h
    12.6 + * 
    12.7 + * Guest OS interface to x86 32-bit Xen.
    12.8 + * 
    12.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   12.10 + * of this software and associated documentation files (the "Software"), to
   12.11 + * deal in the Software without restriction, including without limitation the
   12.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   12.13 + * sell copies of the Software, and to permit persons to whom the Software is
   12.14 + * furnished to do so, subject to the following conditions:
   12.15 + *
   12.16 + * The above copyright notice and this permission notice shall be included in
   12.17 + * all copies or substantial portions of the Software.
   12.18 + *
   12.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   12.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   12.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   12.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   12.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   12.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   12.25 + * DEALINGS IN THE SOFTWARE.
   12.26 + *
   12.27 + * Copyright (c) 2004-2006, K A Fraser
   12.28 + */
   12.29 +
   12.30 +#include "arch-x86/xen.h"
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/common/include/public/arch-x86_64.h	Wed Dec 05 11:14:28 2007 -0800
    13.3 @@ -0,0 +1,27 @@
    13.4 +/******************************************************************************
    13.5 + * arch-x86_64.h
    13.6 + * 
    13.7 + * Guest OS interface to x86 64-bit Xen.
    13.8 + * 
    13.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   13.10 + * of this software and associated documentation files (the "Software"), to
   13.11 + * deal in the Software without restriction, including without limitation the
   13.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   13.13 + * sell copies of the Software, and to permit persons to whom the Software is
   13.14 + * furnished to do so, subject to the following conditions:
   13.15 + *
   13.16 + * The above copyright notice and this permission notice shall be included in
   13.17 + * all copies or substantial portions of the Software.
   13.18 + *
   13.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   13.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   13.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   13.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   13.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   13.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   13.25 + * DEALINGS IN THE SOFTWARE.
   13.26 + *
   13.27 + * Copyright (c) 2004-2006, K A Fraser
   13.28 + */
   13.29 +
   13.30 +#include "arch-x86/xen.h"
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/common/include/public/callback.h	Wed Dec 05 11:14:28 2007 -0800
    14.3 @@ -0,0 +1,92 @@
    14.4 +/******************************************************************************
    14.5 + * callback.h
    14.6 + *
    14.7 + * Register guest OS callbacks with Xen.
    14.8 + *
    14.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   14.10 + * of this software and associated documentation files (the "Software"), to
   14.11 + * deal in the Software without restriction, including without limitation the
   14.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   14.13 + * sell copies of the Software, and to permit persons to whom the Software is
   14.14 + * furnished to do so, subject to the following conditions:
   14.15 + *
   14.16 + * The above copyright notice and this permission notice shall be included in
   14.17 + * all copies or substantial portions of the Software.
   14.18 + *
   14.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   14.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   14.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   14.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   14.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   14.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   14.25 + * DEALINGS IN THE SOFTWARE.
   14.26 + *
   14.27 + * Copyright (c) 2006, Ian Campbell
   14.28 + */
   14.29 +
   14.30 +#ifndef __XEN_PUBLIC_CALLBACK_H__
   14.31 +#define __XEN_PUBLIC_CALLBACK_H__
   14.32 +
   14.33 +#include "xen.h"
   14.34 +
   14.35 +/*
   14.36 + * Prototype for this hypercall is:
   14.37 + *   long callback_op(int cmd, void *extra_args)
   14.38 + * @cmd        == CALLBACKOP_??? (callback operation).
   14.39 + * @extra_args == Operation-specific extra arguments (NULL if none).
   14.40 + */
   14.41 +
   14.42 +#define CALLBACKTYPE_event                 0
   14.43 +#define CALLBACKTYPE_failsafe              1
   14.44 +#define CALLBACKTYPE_syscall               2 /* x86_64 only */
   14.45 +/*
   14.46 + * sysenter is only available on x86_32 with the
   14.47 + * supervisor_mode_kernel option enabled.
   14.48 + */
   14.49 +#define CALLBACKTYPE_sysenter              3
   14.50 +#define CALLBACKTYPE_nmi                   4
   14.51 +
   14.52 +/*
   14.53 + * Disable event deliver during callback? This flag is ignored for event and
   14.54 + * NMI callbacks: event delivery is unconditionally disabled.
   14.55 + */
   14.56 +#define _CALLBACKF_mask_events             0
   14.57 +#define CALLBACKF_mask_events              (1U << _CALLBACKF_mask_events)
   14.58 +
   14.59 +/*
   14.60 + * Register a callback.
   14.61 + */
   14.62 +#define CALLBACKOP_register                0
   14.63 +struct callback_register {
   14.64 +    uint16_t type;
   14.65 +    uint16_t flags;
   14.66 +    xen_callback_t address;
   14.67 +};
   14.68 +typedef struct callback_register callback_register_t;
   14.69 +DEFINE_XEN_GUEST_HANDLE(callback_register_t);
   14.70 +
   14.71 +/*
   14.72 + * Unregister a callback.
   14.73 + *
   14.74 + * Not all callbacks can be unregistered. -EINVAL will be returned if
   14.75 + * you attempt to unregister such a callback.
   14.76 + */
   14.77 +#define CALLBACKOP_unregister              1
   14.78 +struct callback_unregister {
   14.79 +    uint16_t type;
   14.80 +    uint16_t _unused;
   14.81 +};
   14.82 +typedef struct callback_unregister callback_unregister_t;
   14.83 +DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
   14.84 +
   14.85 +#endif /* __XEN_PUBLIC_CALLBACK_H__ */
   14.86 +
   14.87 +/*
   14.88 + * Local variables:
   14.89 + * mode: C
   14.90 + * c-set-style: "BSD"
   14.91 + * c-basic-offset: 4
   14.92 + * tab-width: 4
   14.93 + * indent-tabs-mode: nil
   14.94 + * End:
   14.95 + */
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/common/include/public/dom0_ops.h	Wed Dec 05 11:14:28 2007 -0800
    15.3 @@ -0,0 +1,120 @@
    15.4 +/******************************************************************************
    15.5 + * dom0_ops.h
    15.6 + * 
    15.7 + * Process command requests from domain-0 guest OS.
    15.8 + * 
    15.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   15.10 + * of this software and associated documentation files (the "Software"), to
   15.11 + * deal in the Software without restriction, including without limitation the
   15.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   15.13 + * sell copies of the Software, and to permit persons to whom the Software is
   15.14 + * furnished to do so, subject to the following conditions:
   15.15 + *
   15.16 + * The above copyright notice and this permission notice shall be included in
   15.17 + * all copies or substantial portions of the Software.
   15.18 + *
   15.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   15.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   15.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   15.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   15.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   15.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   15.25 + * DEALINGS IN THE SOFTWARE.
   15.26 + *
   15.27 + * Copyright (c) 2002-2003, B Dragovic
   15.28 + * Copyright (c) 2002-2006, K Fraser
   15.29 + */
   15.30 +
   15.31 +#ifndef __XEN_PUBLIC_DOM0_OPS_H__
   15.32 +#define __XEN_PUBLIC_DOM0_OPS_H__
   15.33 +
   15.34 +#include "xen.h"
   15.35 +#include "platform.h"
   15.36 +
   15.37 +#if __XEN_INTERFACE_VERSION__ >= 0x00030204
   15.38 +#error "dom0_ops.h is a compatibility interface only"
   15.39 +#endif
   15.40 +
   15.41 +#define DOM0_INTERFACE_VERSION XENPF_INTERFACE_VERSION
   15.42 +
   15.43 +#define DOM0_SETTIME          XENPF_settime
   15.44 +#define dom0_settime          xenpf_settime
   15.45 +#define dom0_settime_t        xenpf_settime_t
   15.46 +
   15.47 +#define DOM0_ADD_MEMTYPE      XENPF_add_memtype
   15.48 +#define dom0_add_memtype      xenpf_add_memtype
   15.49 +#define dom0_add_memtype_t    xenpf_add_memtype_t
   15.50 +
   15.51 +#define DOM0_DEL_MEMTYPE      XENPF_del_memtype
   15.52 +#define dom0_del_memtype      xenpf_del_memtype
   15.53 +#define dom0_del_memtype_t    xenpf_del_memtype_t
   15.54 +
   15.55 +#define DOM0_READ_MEMTYPE     XENPF_read_memtype
   15.56 +#define dom0_read_memtype     xenpf_read_memtype
   15.57 +#define dom0_read_memtype_t   xenpf_read_memtype_t
   15.58 +
   15.59 +#define DOM0_MICROCODE        XENPF_microcode_update
   15.60 +#define dom0_microcode        xenpf_microcode_update
   15.61 +#define dom0_microcode_t      xenpf_microcode_update_t
   15.62 +
   15.63 +#define DOM0_PLATFORM_QUIRK   XENPF_platform_quirk
   15.64 +#define dom0_platform_quirk   xenpf_platform_quirk
   15.65 +#define dom0_platform_quirk_t xenpf_platform_quirk_t
   15.66 +
   15.67 +typedef uint64_t cpumap_t;
   15.68 +
   15.69 +/* Unsupported legacy operation -- defined for API compatibility. */
   15.70 +#define DOM0_MSR                 15
   15.71 +struct dom0_msr {
   15.72 +    /* IN variables. */
   15.73 +    uint32_t write;
   15.74 +    cpumap_t cpu_mask;
   15.75 +    uint32_t msr;
   15.76 +    uint32_t in1;
   15.77 +    uint32_t in2;
   15.78 +    /* OUT variables. */
   15.79 +    uint32_t out1;
   15.80 +    uint32_t out2;
   15.81 +};
   15.82 +typedef struct dom0_msr dom0_msr_t;
   15.83 +DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
   15.84 +
   15.85 +/* Unsupported legacy operation -- defined for API compatibility. */
   15.86 +#define DOM0_PHYSICAL_MEMORY_MAP 40
   15.87 +struct dom0_memory_map_entry {
   15.88 +    uint64_t start, end;
   15.89 +    uint32_t flags; /* reserved */
   15.90 +    uint8_t  is_ram;
   15.91 +};
   15.92 +typedef struct dom0_memory_map_entry dom0_memory_map_entry_t;
   15.93 +DEFINE_XEN_GUEST_HANDLE(dom0_memory_map_entry_t);
   15.94 +
   15.95 +struct dom0_op {
   15.96 +    uint32_t cmd;
   15.97 +    uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
   15.98 +    union {
   15.99 +        struct dom0_msr               msr;
  15.100 +        struct dom0_settime           settime;
  15.101 +        struct dom0_add_memtype       add_memtype;
  15.102 +        struct dom0_del_memtype       del_memtype;
  15.103 +        struct dom0_read_memtype      read_memtype;
  15.104 +        struct dom0_microcode         microcode;
  15.105 +        struct dom0_platform_quirk    platform_quirk;
  15.106 +        struct dom0_memory_map_entry  physical_memory_map;
  15.107 +        uint8_t                       pad[128];
  15.108 +    } u;
  15.109 +};
  15.110 +typedef struct dom0_op dom0_op_t;
  15.111 +DEFINE_XEN_GUEST_HANDLE(dom0_op_t);
  15.112 +
  15.113 +#endif /* __XEN_PUBLIC_DOM0_OPS_H__ */
  15.114 +
  15.115 +/*
  15.116 + * Local variables:
  15.117 + * mode: C
  15.118 + * c-set-style: "BSD"
  15.119 + * c-basic-offset: 4
  15.120 + * tab-width: 4
  15.121 + * indent-tabs-mode: nil
  15.122 + * End:
  15.123 + */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/common/include/public/domctl.h	Wed Dec 05 11:14:28 2007 -0800
    16.3 @@ -0,0 +1,481 @@
    16.4 +/******************************************************************************
    16.5 + * domctl.h
    16.6 + * 
    16.7 + * Domain management operations. For use by node control stack.
    16.8 + * 
    16.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   16.10 + * of this software and associated documentation files (the "Software"), to
   16.11 + * deal in the Software without restriction, including without limitation the
   16.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   16.13 + * sell copies of the Software, and to permit persons to whom the Software is
   16.14 + * furnished to do so, subject to the following conditions:
   16.15 + *
   16.16 + * The above copyright notice and this permission notice shall be included in
   16.17 + * all copies or substantial portions of the Software.
   16.18 + *
   16.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   16.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   16.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   16.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   16.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   16.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   16.25 + * DEALINGS IN THE SOFTWARE.
   16.26 + *
   16.27 + * Copyright (c) 2002-2003, B Dragovic
   16.28 + * Copyright (c) 2002-2006, K Fraser
   16.29 + */
   16.30 +
   16.31 +#ifndef __XEN_PUBLIC_DOMCTL_H__
   16.32 +#define __XEN_PUBLIC_DOMCTL_H__
   16.33 +
   16.34 +#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
   16.35 +#error "domctl operations are intended for use by node control tools only"
   16.36 +#endif
   16.37 +
   16.38 +#include "xen.h"
   16.39 +
   16.40 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000005
   16.41 +
   16.42 +struct xenctl_cpumap {
   16.43 +    XEN_GUEST_HANDLE_64(uint8_t) bitmap;
   16.44 +    uint32_t nr_cpus;
   16.45 +};
   16.46 +
   16.47 +/*
   16.48 + * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
   16.49 + * If it is specified as zero, an id is auto-allocated and returned.
   16.50 + */
   16.51 +#define XEN_DOMCTL_createdomain       1
   16.52 +struct xen_domctl_createdomain {
   16.53 +    /* IN parameters */
   16.54 +    uint32_t ssidref;
   16.55 +    xen_domain_handle_t handle;
   16.56 + /* Is this an HVM guest (as opposed to a PV guest)? */
   16.57 +#define _XEN_DOMCTL_CDF_hvm_guest 0
   16.58 +#define XEN_DOMCTL_CDF_hvm_guest  (1U<<_XEN_DOMCTL_CDF_hvm_guest)
   16.59 +    uint32_t flags;
   16.60 +};
   16.61 +typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
   16.62 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
   16.63 +
   16.64 +#define XEN_DOMCTL_destroydomain      2
   16.65 +#define XEN_DOMCTL_pausedomain        3
   16.66 +#define XEN_DOMCTL_unpausedomain      4
   16.67 +#define XEN_DOMCTL_resumedomain      27
   16.68 +
   16.69 +#define XEN_DOMCTL_getdomaininfo      5
   16.70 +struct xen_domctl_getdomaininfo {
   16.71 +    /* OUT variables. */
   16.72 +    domid_t  domain;              /* Also echoed in domctl.domain */
   16.73 + /* Domain is scheduled to die. */
   16.74 +#define _XEN_DOMINF_dying     0
   16.75 +#define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
   16.76 + /* Domain is an HVM guest (as opposed to a PV guest). */
   16.77 +#define _XEN_DOMINF_hvm_guest 1
   16.78 +#define XEN_DOMINF_hvm_guest  (1U<<_XEN_DOMINF_hvm_guest)
   16.79 + /* The guest OS has shut down. */
   16.80 +#define _XEN_DOMINF_shutdown  2
   16.81 +#define XEN_DOMINF_shutdown   (1U<<_XEN_DOMINF_shutdown)
   16.82 + /* Currently paused by control software. */
   16.83 +#define _XEN_DOMINF_paused    3
   16.84 +#define XEN_DOMINF_paused     (1U<<_XEN_DOMINF_paused)
   16.85 + /* Currently blocked pending an event.     */
   16.86 +#define _XEN_DOMINF_blocked   4
   16.87 +#define XEN_DOMINF_blocked    (1U<<_XEN_DOMINF_blocked)
   16.88 + /* Domain is currently running.            */
   16.89 +#define _XEN_DOMINF_running   5
   16.90 +#define XEN_DOMINF_running    (1U<<_XEN_DOMINF_running)
   16.91 + /* Being debugged.  */
   16.92 +#define _XEN_DOMINF_debugged  6
   16.93 +#define XEN_DOMINF_debugged   (1U<<_XEN_DOMINF_debugged)
   16.94 + /* CPU to which this domain is bound.      */
   16.95 +#define XEN_DOMINF_cpumask      255
   16.96 +#define XEN_DOMINF_cpushift       8
   16.97 + /* XEN_DOMINF_shutdown guest-supplied code.  */
   16.98 +#define XEN_DOMINF_shutdownmask 255
   16.99 +#define XEN_DOMINF_shutdownshift 16
  16.100 +    uint32_t flags;              /* XEN_DOMINF_* */
  16.101 +    uint64_aligned_t tot_pages;
  16.102 +    uint64_aligned_t max_pages;
  16.103 +    uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
  16.104 +    uint64_aligned_t cpu_time;
  16.105 +    uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
  16.106 +    uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
  16.107 +    uint32_t ssidref;
  16.108 +    xen_domain_handle_t handle;
  16.109 +};
  16.110 +typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
  16.111 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
  16.112 +
  16.113 +
  16.114 +#define XEN_DOMCTL_getmemlist         6
  16.115 +struct xen_domctl_getmemlist {
  16.116 +    /* IN variables. */
  16.117 +    /* Max entries to write to output buffer. */
  16.118 +    uint64_aligned_t max_pfns;
  16.119 +    /* Start index in guest's page list. */
  16.120 +    uint64_aligned_t start_pfn;
  16.121 +    XEN_GUEST_HANDLE_64(uint64_t) buffer;
  16.122 +    /* OUT variables. */
  16.123 +    uint64_aligned_t num_pfns;
  16.124 +};
  16.125 +typedef struct xen_domctl_getmemlist xen_domctl_getmemlist_t;
  16.126 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getmemlist_t);
  16.127 +
  16.128 +
  16.129 +#define XEN_DOMCTL_getpageframeinfo   7
  16.130 +
  16.131 +#define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
  16.132 +#define XEN_DOMCTL_PFINFO_NOTAB   (0x0U<<28)
  16.133 +#define XEN_DOMCTL_PFINFO_L1TAB   (0x1U<<28)
  16.134 +#define XEN_DOMCTL_PFINFO_L2TAB   (0x2U<<28)
  16.135 +#define XEN_DOMCTL_PFINFO_L3TAB   (0x3U<<28)
  16.136 +#define XEN_DOMCTL_PFINFO_L4TAB   (0x4U<<28)
  16.137 +#define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
  16.138 +#define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
  16.139 +#define XEN_DOMCTL_PFINFO_XTAB    (0xfU<<28) /* invalid page */
  16.140 +#define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
  16.141 +
  16.142 +struct xen_domctl_getpageframeinfo {
  16.143 +    /* IN variables. */
  16.144 +    uint64_aligned_t gmfn; /* GMFN to query */
  16.145 +    /* OUT variables. */
  16.146 +    /* Is the page PINNED to a type? */
  16.147 +    uint32_t type;         /* see above type defs */
  16.148 +};
  16.149 +typedef struct xen_domctl_getpageframeinfo xen_domctl_getpageframeinfo_t;
  16.150 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo_t);
  16.151 +
  16.152 +
  16.153 +#define XEN_DOMCTL_getpageframeinfo2  8
  16.154 +struct xen_domctl_getpageframeinfo2 {
  16.155 +    /* IN variables. */
  16.156 +    uint64_aligned_t num;
  16.157 +    /* IN/OUT variables. */
  16.158 +    XEN_GUEST_HANDLE_64(uint32_t) array;
  16.159 +};
  16.160 +typedef struct xen_domctl_getpageframeinfo2 xen_domctl_getpageframeinfo2_t;
  16.161 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo2_t);
  16.162 +
  16.163 +
  16.164 +/*
  16.165 + * Control shadow pagetables operation
  16.166 + */
  16.167 +#define XEN_DOMCTL_shadow_op         10
  16.168 +
  16.169 +/* Disable shadow mode. */
  16.170 +#define XEN_DOMCTL_SHADOW_OP_OFF         0
  16.171 +
  16.172 +/* Enable shadow mode (mode contains ORed XEN_DOMCTL_SHADOW_ENABLE_* flags). */
  16.173 +#define XEN_DOMCTL_SHADOW_OP_ENABLE      32
  16.174 +
  16.175 +/* Log-dirty bitmap operations. */
  16.176 + /* Return the bitmap and clean internal copy for next round. */
  16.177 +#define XEN_DOMCTL_SHADOW_OP_CLEAN       11
  16.178 + /* Return the bitmap but do not modify internal copy. */
  16.179 +#define XEN_DOMCTL_SHADOW_OP_PEEK        12
  16.180 +
  16.181 +/* Memory allocation accessors. */
  16.182 +#define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
  16.183 +#define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
  16.184 +
  16.185 +/* Legacy enable operations. */
  16.186 + /* Equiv. to ENABLE with no mode flags. */
  16.187 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
  16.188 + /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
  16.189 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
  16.190 + /* Equiv. to ENABLE with mode flags ENABLE_REFCOUNT and ENABLE_TRANSLATE. */
  16.191 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
  16.192 +
  16.193 +/* Mode flags for XEN_DOMCTL_SHADOW_OP_ENABLE. */
  16.194 + /*
  16.195 +  * Shadow pagetables are refcounted: guest does not use explicit mmu
  16.196 +  * operations nor write-protect its pagetables.
  16.197 +  */
  16.198 +#define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
  16.199 + /*
  16.200 +  * Log pages in a bitmap as they are dirtied.
  16.201 +  * Used for live relocation to determine which pages must be re-sent.
  16.202 +  */
  16.203 +#define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
  16.204 + /*
  16.205 +  * Automatically translate GPFNs into MFNs.
  16.206 +  */
  16.207 +#define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
  16.208 + /*
  16.209 +  * Xen does not steal virtual address space from the guest.
  16.210 +  * Requires HVM support.
  16.211 +  */
  16.212 +#define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
  16.213 +
  16.214 +struct xen_domctl_shadow_op_stats {
  16.215 +    uint32_t fault_count;
  16.216 +    uint32_t dirty_count;
  16.217 +};
  16.218 +typedef struct xen_domctl_shadow_op_stats xen_domctl_shadow_op_stats_t;
  16.219 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_stats_t);
  16.220 +
  16.221 +struct xen_domctl_shadow_op {
  16.222 +    /* IN variables. */
  16.223 +    uint32_t       op;       /* XEN_DOMCTL_SHADOW_OP_* */
  16.224 +
  16.225 +    /* OP_ENABLE */
  16.226 +    uint32_t       mode;     /* XEN_DOMCTL_SHADOW_ENABLE_* */
  16.227 +
  16.228 +    /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
  16.229 +    uint32_t       mb;       /* Shadow memory allocation in MB */
  16.230 +
  16.231 +    /* OP_PEEK / OP_CLEAN */
  16.232 +    XEN_GUEST_HANDLE_64(uint8_t) dirty_bitmap;
  16.233 +    uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */
  16.234 +    struct xen_domctl_shadow_op_stats stats;
  16.235 +};
  16.236 +typedef struct xen_domctl_shadow_op xen_domctl_shadow_op_t;
  16.237 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_t);
  16.238 +
  16.239 +
  16.240 +#define XEN_DOMCTL_max_mem           11
  16.241 +struct xen_domctl_max_mem {
  16.242 +    /* IN variables. */
  16.243 +    uint64_aligned_t max_memkb;
  16.244 +};
  16.245 +typedef struct xen_domctl_max_mem xen_domctl_max_mem_t;
  16.246 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_mem_t);
  16.247 +
  16.248 +
  16.249 +#define XEN_DOMCTL_setvcpucontext    12
  16.250 +#define XEN_DOMCTL_getvcpucontext    13
  16.251 +struct xen_domctl_vcpucontext {
  16.252 +    uint32_t              vcpu;                  /* IN */
  16.253 +    XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */
  16.254 +};
  16.255 +typedef struct xen_domctl_vcpucontext xen_domctl_vcpucontext_t;
  16.256 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpucontext_t);
  16.257 +
  16.258 +
  16.259 +#define XEN_DOMCTL_getvcpuinfo       14
  16.260 +struct xen_domctl_getvcpuinfo {
  16.261 +    /* IN variables. */
  16.262 +    uint32_t vcpu;
  16.263 +    /* OUT variables. */
  16.264 +    uint8_t  online;                  /* currently online (not hotplugged)? */
  16.265 +    uint8_t  blocked;                 /* blocked waiting for an event? */
  16.266 +    uint8_t  running;                 /* currently scheduled on its CPU? */
  16.267 +    uint64_aligned_t cpu_time;        /* total cpu time consumed (ns) */
  16.268 +    uint32_t cpu;                     /* current mapping   */
  16.269 +};
  16.270 +typedef struct xen_domctl_getvcpuinfo xen_domctl_getvcpuinfo_t;
  16.271 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getvcpuinfo_t);
  16.272 +
  16.273 +
  16.274 +/* Get/set which physical cpus a vcpu can execute on. */
  16.275 +#define XEN_DOMCTL_setvcpuaffinity    9
  16.276 +#define XEN_DOMCTL_getvcpuaffinity   25
  16.277 +struct xen_domctl_vcpuaffinity {
  16.278 +    uint32_t  vcpu;              /* IN */
  16.279 +    struct xenctl_cpumap cpumap; /* IN/OUT */
  16.280 +};
  16.281 +typedef struct xen_domctl_vcpuaffinity xen_domctl_vcpuaffinity_t;
  16.282 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpuaffinity_t);
  16.283 +
  16.284 +
  16.285 +#define XEN_DOMCTL_max_vcpus         15
  16.286 +struct xen_domctl_max_vcpus {
  16.287 +    uint32_t max;           /* maximum number of vcpus */
  16.288 +};
  16.289 +typedef struct xen_domctl_max_vcpus xen_domctl_max_vcpus_t;
  16.290 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);
  16.291 +
  16.292 +
  16.293 +#define XEN_DOMCTL_scheduler_op      16
  16.294 +/* Scheduler types. */
  16.295 +#define XEN_SCHEDULER_SEDF     4
  16.296 +#define XEN_SCHEDULER_CREDIT   5
  16.297 +/* Set or get info? */
  16.298 +#define XEN_DOMCTL_SCHEDOP_putinfo 0
  16.299 +#define XEN_DOMCTL_SCHEDOP_getinfo 1
  16.300 +struct xen_domctl_scheduler_op {
  16.301 +    uint32_t sched_id;  /* XEN_SCHEDULER_* */
  16.302 +    uint32_t cmd;       /* XEN_DOMCTL_SCHEDOP_* */
  16.303 +    union {
  16.304 +        struct xen_domctl_sched_sedf {
  16.305 +            uint64_aligned_t period;
  16.306 +            uint64_aligned_t slice;
  16.307 +            uint64_aligned_t latency;
  16.308 +            uint32_t extratime;
  16.309 +            uint32_t weight;
  16.310 +        } sedf;
  16.311 +        struct xen_domctl_sched_credit {
  16.312 +            uint16_t weight;
  16.313 +            uint16_t cap;
  16.314 +        } credit;
  16.315 +    } u;
  16.316 +};
  16.317 +typedef struct xen_domctl_scheduler_op xen_domctl_scheduler_op_t;
  16.318 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_scheduler_op_t);
  16.319 +
  16.320 +
  16.321 +#define XEN_DOMCTL_setdomainhandle   17
  16.322 +struct xen_domctl_setdomainhandle {
  16.323 +    xen_domain_handle_t handle;
  16.324 +};
  16.325 +typedef struct xen_domctl_setdomainhandle xen_domctl_setdomainhandle_t;
  16.326 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdomainhandle_t);
  16.327 +
  16.328 +
  16.329 +#define XEN_DOMCTL_setdebugging      18
  16.330 +struct xen_domctl_setdebugging {
  16.331 +    uint8_t enable;
  16.332 +};
  16.333 +typedef struct xen_domctl_setdebugging xen_domctl_setdebugging_t;
  16.334 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdebugging_t);
  16.335 +
  16.336 +
  16.337 +#define XEN_DOMCTL_irq_permission    19
  16.338 +struct xen_domctl_irq_permission {
  16.339 +    uint8_t pirq;
  16.340 +    uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
  16.341 +};
  16.342 +typedef struct xen_domctl_irq_permission xen_domctl_irq_permission_t;
  16.343 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_irq_permission_t);
  16.344 +
  16.345 +
  16.346 +#define XEN_DOMCTL_iomem_permission  20
  16.347 +struct xen_domctl_iomem_permission {
  16.348 +    uint64_aligned_t first_mfn;/* first page (physical page number) in range */
  16.349 +    uint64_aligned_t nr_mfns;  /* number of pages in range (>0) */
  16.350 +    uint8_t  allow_access;     /* allow (!0) or deny (0) access to range? */
  16.351 +};
  16.352 +typedef struct xen_domctl_iomem_permission xen_domctl_iomem_permission_t;
  16.353 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_iomem_permission_t);
  16.354 +
  16.355 +
  16.356 +#define XEN_DOMCTL_ioport_permission 21
  16.357 +struct xen_domctl_ioport_permission {
  16.358 +    uint32_t first_port;              /* first port int range */
  16.359 +    uint32_t nr_ports;                /* size of port range */
  16.360 +    uint8_t  allow_access;            /* allow or deny access to range? */
  16.361 +};
  16.362 +typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
  16.363 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
  16.364 +
  16.365 +
  16.366 +#define XEN_DOMCTL_hypercall_init    22
  16.367 +struct xen_domctl_hypercall_init {
  16.368 +    uint64_aligned_t  gmfn;           /* GMFN to be initialised */
  16.369 +};
  16.370 +typedef struct xen_domctl_hypercall_init xen_domctl_hypercall_init_t;
  16.371 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_hypercall_init_t);
  16.372 +
  16.373 +
  16.374 +#define XEN_DOMCTL_arch_setup        23
  16.375 +#define _XEN_DOMAINSETUP_hvm_guest 0
  16.376 +#define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
  16.377 +#define _XEN_DOMAINSETUP_query 1 /* Get parameters (for save)  */
  16.378 +#define XEN_DOMAINSETUP_query  (1UL<<_XEN_DOMAINSETUP_query)
  16.379 +typedef struct xen_domctl_arch_setup {
  16.380 +    uint64_aligned_t flags;  /* XEN_DOMAINSETUP_* */
  16.381 +#ifdef __ia64__
  16.382 +    uint64_aligned_t bp;     /* mpaddr of boot param area */
  16.383 +    uint64_aligned_t maxmem; /* Highest memory address for MDT.  */
  16.384 +    uint64_aligned_t xsi_va; /* Xen shared_info area virtual address.  */
  16.385 +    uint32_t hypercall_imm;  /* Break imm for Xen hypercalls.  */
  16.386 +#endif
  16.387 +} xen_domctl_arch_setup_t;
  16.388 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
  16.389 +
  16.390 +
  16.391 +#define XEN_DOMCTL_settimeoffset     24
  16.392 +struct xen_domctl_settimeoffset {
  16.393 +    int32_t  time_offset_seconds; /* applied to domain wallclock time */
  16.394 +};
  16.395 +typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
  16.396 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
  16.397 +
  16.398 + 
  16.399 +#define XEN_DOMCTL_gethvmcontext     33
  16.400 +#define XEN_DOMCTL_sethvmcontext     34
  16.401 +typedef struct xen_domctl_hvmcontext {
  16.402 +    uint32_t size; /* IN/OUT: size of buffer / bytes filled */
  16.403 +    XEN_GUEST_HANDLE_64(uint8_t) buffer; /* IN/OUT: data, or call
  16.404 +                                          * gethvmcontext with NULL
  16.405 +                                          * buffer to get size
  16.406 +                                          * req'd */
  16.407 +} xen_domctl_hvmcontext_t;
  16.408 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
  16.409 +
  16.410 +
  16.411 +#define XEN_DOMCTL_set_address_size  35
  16.412 +#define XEN_DOMCTL_get_address_size  36
  16.413 +typedef struct xen_domctl_address_size {
  16.414 +    uint32_t size;
  16.415 +} xen_domctl_address_size_t;
  16.416 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
  16.417 +
  16.418 +
  16.419 +#define XEN_DOMCTL_real_mode_area    26
  16.420 +struct xen_domctl_real_mode_area {
  16.421 +    uint32_t log; /* log2 of Real Mode Area size */
  16.422 +};
  16.423 +typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
  16.424 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
  16.425 +
  16.426 +
  16.427 +#define XEN_DOMCTL_sendtrigger       28
  16.428 +#define XEN_DOMCTL_SENDTRIGGER_NMI    0
  16.429 +#define XEN_DOMCTL_SENDTRIGGER_RESET  1
  16.430 +#define XEN_DOMCTL_SENDTRIGGER_INIT   2
  16.431 +struct xen_domctl_sendtrigger {
  16.432 +    uint32_t  trigger;  /* IN */
  16.433 +    uint32_t  vcpu;     /* IN */
  16.434 +};
  16.435 +typedef struct xen_domctl_sendtrigger xen_domctl_sendtrigger_t;
  16.436 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
  16.437 +
  16.438 + 
  16.439 +struct xen_domctl {
  16.440 +    uint32_t cmd;
  16.441 +    uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
  16.442 +    domid_t  domain;
  16.443 +    union {
  16.444 +        struct xen_domctl_createdomain      createdomain;
  16.445 +        struct xen_domctl_getdomaininfo     getdomaininfo;
  16.446 +        struct xen_domctl_getmemlist        getmemlist;
  16.447 +        struct xen_domctl_getpageframeinfo  getpageframeinfo;
  16.448 +        struct xen_domctl_getpageframeinfo2 getpageframeinfo2;
  16.449 +        struct xen_domctl_vcpuaffinity      vcpuaffinity;
  16.450 +        struct xen_domctl_shadow_op         shadow_op;
  16.451 +        struct xen_domctl_max_mem           max_mem;
  16.452 +        struct xen_domctl_vcpucontext       vcpucontext;
  16.453 +        struct xen_domctl_getvcpuinfo       getvcpuinfo;
  16.454 +        struct xen_domctl_max_vcpus         max_vcpus;
  16.455 +        struct xen_domctl_scheduler_op      scheduler_op;
  16.456 +        struct xen_domctl_setdomainhandle   setdomainhandle;
  16.457 +        struct xen_domctl_setdebugging      setdebugging;
  16.458 +        struct xen_domctl_irq_permission    irq_permission;
  16.459 +        struct xen_domctl_iomem_permission  iomem_permission;
  16.460 +        struct xen_domctl_ioport_permission ioport_permission;
  16.461 +        struct xen_domctl_hypercall_init    hypercall_init;
  16.462 +        struct xen_domctl_arch_setup        arch_setup;
  16.463 +        struct xen_domctl_settimeoffset     settimeoffset;
  16.464 +        struct xen_domctl_real_mode_area    real_mode_area;
  16.465 +        struct xen_domctl_hvmcontext        hvmcontext;
  16.466 +        struct xen_domctl_address_size      address_size;
  16.467 +        struct xen_domctl_sendtrigger       sendtrigger;
  16.468 +        uint8_t                             pad[128];
  16.469 +    } u;
  16.470 +};
  16.471 +typedef struct xen_domctl xen_domctl_t;
  16.472 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_t);
  16.473 +
  16.474 +#endif /* __XEN_PUBLIC_DOMCTL_H__ */
  16.475 +
  16.476 +/*
  16.477 + * Local variables:
  16.478 + * mode: C
  16.479 + * c-set-style: "BSD"
  16.480 + * c-basic-offset: 4
  16.481 + * tab-width: 4
  16.482 + * indent-tabs-mode: nil
  16.483 + * End:
  16.484 + */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/common/include/public/elfnote.h	Wed Dec 05 11:14:28 2007 -0800
    17.3 @@ -0,0 +1,233 @@
    17.4 +/******************************************************************************
    17.5 + * elfnote.h
    17.6 + *
    17.7 + * Definitions used for the Xen ELF notes.
    17.8 + *
    17.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   17.10 + * of this software and associated documentation files (the "Software"), to
   17.11 + * deal in the Software without restriction, including without limitation the
   17.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   17.13 + * sell copies of the Software, and to permit persons to whom the Software is
   17.14 + * furnished to do so, subject to the following conditions:
   17.15 + *
   17.16 + * The above copyright notice and this permission notice shall be included in
   17.17 + * all copies or substantial portions of the Software.
   17.18 + *
   17.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   17.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   17.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   17.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   17.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   17.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   17.25 + * DEALINGS IN THE SOFTWARE.
   17.26 + *
   17.27 + * Copyright (c) 2006, Ian Campbell, XenSource Ltd.
   17.28 + */
   17.29 +
   17.30 +#ifndef __XEN_PUBLIC_ELFNOTE_H__
   17.31 +#define __XEN_PUBLIC_ELFNOTE_H__
   17.32 +
   17.33 +/*
   17.34 + * The notes should live in a PT_NOTE segment and have "Xen" in the
   17.35 + * name field.
   17.36 + *
   17.37 + * Numeric types are either 4 or 8 bytes depending on the content of
   17.38 + * the desc field.
   17.39 + *
   17.40 + * LEGACY indicated the fields in the legacy __xen_guest string which
   17.41 + * this a note type replaces.
   17.42 + */
   17.43 +
   17.44 +/*
   17.45 + * NAME=VALUE pair (string).
   17.46 + */
   17.47 +#define XEN_ELFNOTE_INFO           0
   17.48 +
   17.49 +/*
   17.50 + * The virtual address of the entry point (numeric).
   17.51 + *
   17.52 + * LEGACY: VIRT_ENTRY
   17.53 + */
   17.54 +#define XEN_ELFNOTE_ENTRY          1
   17.55 +
   17.56 +/* The virtual address of the hypercall transfer page (numeric).
   17.57 + *
   17.58 + * LEGACY: HYPERCALL_PAGE. (n.b. legacy value is a physical page
   17.59 + * number not a virtual address)
   17.60 + */
   17.61 +#define XEN_ELFNOTE_HYPERCALL_PAGE 2
   17.62 +
   17.63 +/* The virtual address where the kernel image should be mapped (numeric).
   17.64 + *
   17.65 + * Defaults to 0.
   17.66 + *
   17.67 + * LEGACY: VIRT_BASE
   17.68 + */
   17.69 +#define XEN_ELFNOTE_VIRT_BASE      3
   17.70 +
   17.71 +/*
   17.72 + * The offset of the ELF paddr field from the acutal required
   17.73 + * psuedo-physical address (numeric).
   17.74 + *
   17.75 + * This is used to maintain backwards compatibility with older kernels
   17.76 + * which wrote __PAGE_OFFSET into that field. This field defaults to 0
   17.77 + * if not present.
   17.78 + *
   17.79 + * LEGACY: ELF_PADDR_OFFSET. (n.b. legacy default is VIRT_BASE)
   17.80 + */
   17.81 +#define XEN_ELFNOTE_PADDR_OFFSET   4
   17.82 +
   17.83 +/*
   17.84 + * The version of Xen that we work with (string).
   17.85 + *
   17.86 + * LEGACY: XEN_VER
   17.87 + */
   17.88 +#define XEN_ELFNOTE_XEN_VERSION    5
   17.89 +
   17.90 +/*
   17.91 + * The name of the guest operating system (string).
   17.92 + *
   17.93 + * LEGACY: GUEST_OS
   17.94 + */
   17.95 +#define XEN_ELFNOTE_GUEST_OS       6
   17.96 +
   17.97 +/*
   17.98 + * The version of the guest operating system (string).
   17.99 + *
  17.100 + * LEGACY: GUEST_VER
  17.101 + */
  17.102 +#define XEN_ELFNOTE_GUEST_VERSION  7
  17.103 +
  17.104 +/*
  17.105 + * The loader type (string).
  17.106 + *
  17.107 + * LEGACY: LOADER
  17.108 + */
  17.109 +#define XEN_ELFNOTE_LOADER         8
  17.110 +
  17.111 +/*
  17.112 + * The kernel supports PAE (x86/32 only, string = "yes", "no" or
  17.113 + * "bimodal").
  17.114 + *
  17.115 + * For compatibility with Xen 3.0.3 and earlier the "bimodal" setting
  17.116 + * may be given as "yes,bimodal" which will cause older Xen to treat
  17.117 + * this kernel as PAE.
  17.118 + *
  17.119 + * LEGACY: PAE (n.b. The legacy interface included a provision to
  17.120 + * indicate 'extended-cr3' support allowing L3 page tables to be
  17.121 + * placed above 4G. It is assumed that any kernel new enough to use
  17.122 + * these ELF notes will include this and therefore "yes" here is
  17.123 + * equivalent to "yes[entended-cr3]" in the __xen_guest interface.
  17.124 + */
  17.125 +#define XEN_ELFNOTE_PAE_MODE       9
  17.126 +
  17.127 +/*
  17.128 + * The features supported/required by this kernel (string).
  17.129 + *
  17.130 + * The string must consist of a list of feature names (as given in
  17.131 + * features.h, without the "XENFEAT_" prefix) separated by '|'
  17.132 + * characters. If a feature is required for the kernel to function
  17.133 + * then the feature name must be preceded by a '!' character.
  17.134 + *
  17.135 + * LEGACY: FEATURES
  17.136 + */
  17.137 +#define XEN_ELFNOTE_FEATURES      10
  17.138 +
  17.139 +/*
  17.140 + * The kernel requires the symbol table to be loaded (string = "yes" or "no")
  17.141 + * LEGACY: BSD_SYMTAB (n.b. The legacy treated the presence or absence
  17.142 + * of this string as a boolean flag rather than requiring "yes" or
  17.143 + * "no".
  17.144 + */
  17.145 +#define XEN_ELFNOTE_BSD_SYMTAB    11
  17.146 +
  17.147 +/*
  17.148 + * The lowest address the hypervisor hole can begin at (numeric).
  17.149 + *
  17.150 + * This must not be set higher than HYPERVISOR_VIRT_START. Its presence
  17.151 + * also indicates to the hypervisor that the kernel can deal with the
  17.152 + * hole starting at a higher address.
  17.153 + */
  17.154 +#define XEN_ELFNOTE_HV_START_LOW  12
  17.155 +
  17.156 +/*
  17.157 + * List of maddr_t-sized mask/value pairs describing how to recognize
  17.158 + * (non-present) L1 page table entries carrying valid MFNs (numeric).
  17.159 + */
  17.160 +#define XEN_ELFNOTE_L1_MFN_VALID  13
  17.161 +
  17.162 +/*
  17.163 + * Whether or not the guest supports cooperative suspend cancellation.
  17.164 + */
  17.165 +#define XEN_ELFNOTE_SUSPEND_CANCEL 14
  17.166 +
  17.167 +/*
  17.168 + * The number of the highest elfnote defined.
  17.169 + */
  17.170 +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUSPEND_CANCEL
  17.171 +
  17.172 +/*
  17.173 + * System information exported through crash notes.
  17.174 + *
  17.175 + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO 
  17.176 + * note in case of a system crash. This note will contain various
  17.177 + * information about the system, see xen/include/xen/elfcore.h.
  17.178 + */
  17.179 +#define XEN_ELFNOTE_CRASH_INFO 0x1000001
  17.180 +
  17.181 +/*
  17.182 + * System registers exported through crash notes.
  17.183 + *
  17.184 + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_REGS 
  17.185 + * note per cpu in case of a system crash. This note is architecture
  17.186 + * specific and will contain registers not saved in the "CORE" note.
  17.187 + * See xen/include/xen/elfcore.h for more information.
  17.188 + */
  17.189 +#define XEN_ELFNOTE_CRASH_REGS 0x1000002
  17.190 +
  17.191 +
  17.192 +/*
  17.193 + * xen dump-core none note.
  17.194 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE
  17.195 + * in its dump file to indicate that the file is xen dump-core
  17.196 + * file. This note doesn't have any other information.
  17.197 + * See tools/libxc/xc_core.h for more information.
  17.198 + */
  17.199 +#define XEN_ELFNOTE_DUMPCORE_NONE               0x2000000
  17.200 +
  17.201 +/*
  17.202 + * xen dump-core header note.
  17.203 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER
  17.204 + * in its dump file.
  17.205 + * See tools/libxc/xc_core.h for more information.
  17.206 + */
  17.207 +#define XEN_ELFNOTE_DUMPCORE_HEADER             0x2000001
  17.208 +
  17.209 +/*
  17.210 + * xen dump-core xen version note.
  17.211 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION
  17.212 + * in its dump file. It contains the xen version obtained via the
  17.213 + * XENVER hypercall.
  17.214 + * See tools/libxc/xc_core.h for more information.
  17.215 + */
  17.216 +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION        0x2000002
  17.217 +
  17.218 +/*
  17.219 + * xen dump-core format version note.
  17.220 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION
  17.221 + * in its dump file. It contains a format version identifier.
  17.222 + * See tools/libxc/xc_core.h for more information.
  17.223 + */
  17.224 +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION     0x2000003
  17.225 +
  17.226 +#endif /* __XEN_PUBLIC_ELFNOTE_H__ */
  17.227 +
  17.228 +/*
  17.229 + * Local variables:
  17.230 + * mode: C
  17.231 + * c-set-style: "BSD"
  17.232 + * c-basic-offset: 4
  17.233 + * tab-width: 4
  17.234 + * indent-tabs-mode: nil
  17.235 + * End:
  17.236 + */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/common/include/public/elfstructs.h	Wed Dec 05 11:14:28 2007 -0800
    18.3 @@ -0,0 +1,527 @@
    18.4 +#ifndef __XEN_PUBLIC_ELFSTRUCTS_H__
    18.5 +#define __XEN_PUBLIC_ELFSTRUCTS_H__ 1
    18.6 +/*
    18.7 + * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
    18.8 + *
    18.9 + * Redistribution and use in source and binary forms, with or without
   18.10 + * modification, are permitted provided that the following conditions
   18.11 + * are met:
   18.12 + * 1. Redistributions of source code must retain the above copyright
   18.13 + *    notice, this list of conditions and the following disclaimer.
   18.14 + * 2. Redistributions in binary form must reproduce the above copyright
   18.15 + *    notice, this list of conditions and the following disclaimer in the
   18.16 + *    documentation and/or other materials provided with the distribution.
   18.17 + * 3. The name of the author may not be used to endorse or promote products
   18.18 + *    derived from this software without specific prior written permission
   18.19 + *
   18.20 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18.21 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   18.22 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18.23 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   18.24 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   18.25 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   18.26 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   18.27 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   18.28 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   18.29 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   18.30 + */
   18.31 +
   18.32 +typedef uint8_t		Elf_Byte;
   18.33 +
   18.34 +typedef uint32_t	Elf32_Addr;	/* Unsigned program address */
   18.35 +typedef uint32_t	Elf32_Off;	/* Unsigned file offset */
   18.36 +typedef int32_t		Elf32_Sword;	/* Signed large integer */
   18.37 +typedef uint32_t	Elf32_Word;	/* Unsigned large integer */
   18.38 +typedef uint16_t	Elf32_Half;	/* Unsigned medium integer */
   18.39 +
   18.40 +typedef uint64_t	Elf64_Addr;
   18.41 +typedef uint64_t	Elf64_Off;
   18.42 +typedef int32_t		Elf64_Shalf;
   18.43 +
   18.44 +typedef int32_t		Elf64_Sword;
   18.45 +typedef uint32_t	Elf64_Word;
   18.46 +
   18.47 +typedef int64_t		Elf64_Sxword;
   18.48 +typedef uint64_t	Elf64_Xword;
   18.49 +
   18.50 +typedef uint32_t	Elf64_Half;
   18.51 +typedef uint16_t	Elf64_Quarter;
   18.52 +
   18.53 +/*
   18.54 + * e_ident[] identification indexes
   18.55 + * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
   18.56 + */
   18.57 +#define EI_MAG0		0		/* file ID */
   18.58 +#define EI_MAG1		1		/* file ID */
   18.59 +#define EI_MAG2		2		/* file ID */
   18.60 +#define EI_MAG3		3		/* file ID */
   18.61 +#define EI_CLASS	4		/* file class */
   18.62 +#define EI_DATA		5		/* data encoding */
   18.63 +#define EI_VERSION	6		/* ELF header version */
   18.64 +#define EI_OSABI	7		/* OS/ABI ID */
   18.65 +#define EI_ABIVERSION	8		/* ABI version */
   18.66 +#define EI_PAD		9		/* start of pad bytes */
   18.67 +#define EI_NIDENT	16		/* Size of e_ident[] */
   18.68 +
   18.69 +/* e_ident[] magic number */
   18.70 +#define	ELFMAG0		0x7f		/* e_ident[EI_MAG0] */
   18.71 +#define	ELFMAG1		'E'		/* e_ident[EI_MAG1] */
   18.72 +#define	ELFMAG2		'L'		/* e_ident[EI_MAG2] */
   18.73 +#define	ELFMAG3		'F'		/* e_ident[EI_MAG3] */
   18.74 +#define	ELFMAG		"\177ELF"	/* magic */
   18.75 +#define	SELFMAG		4		/* size of magic */
   18.76 +
   18.77 +/* e_ident[] file class */
   18.78 +#define	ELFCLASSNONE	0		/* invalid */
   18.79 +#define	ELFCLASS32	1		/* 32-bit objs */
   18.80 +#define	ELFCLASS64	2		/* 64-bit objs */
   18.81 +#define	ELFCLASSNUM	3		/* number of classes */
   18.82 +
   18.83 +/* e_ident[] data encoding */
   18.84 +#define ELFDATANONE	0		/* invalid */
   18.85 +#define ELFDATA2LSB	1		/* Little-Endian */
   18.86 +#define ELFDATA2MSB	2		/* Big-Endian */
   18.87 +#define ELFDATANUM	3		/* number of data encode defines */
   18.88 +
   18.89 +/* e_ident[] Operating System/ABI */
   18.90 +#define ELFOSABI_SYSV		0	/* UNIX System V ABI */
   18.91 +#define ELFOSABI_HPUX		1	/* HP-UX operating system */
   18.92 +#define ELFOSABI_NETBSD		2	/* NetBSD */
   18.93 +#define ELFOSABI_LINUX		3	/* GNU/Linux */
   18.94 +#define ELFOSABI_HURD		4	/* GNU/Hurd */
   18.95 +#define ELFOSABI_86OPEN		5	/* 86Open common IA32 ABI */
   18.96 +#define ELFOSABI_SOLARIS	6	/* Solaris */
   18.97 +#define ELFOSABI_MONTEREY	7	/* Monterey */
   18.98 +#define ELFOSABI_IRIX		8	/* IRIX */
   18.99 +#define ELFOSABI_FREEBSD	9	/* FreeBSD */
  18.100 +#define ELFOSABI_TRU64		10	/* TRU64 UNIX */
  18.101 +#define ELFOSABI_MODESTO	11	/* Novell Modesto */
  18.102 +#define ELFOSABI_OPENBSD	12	/* OpenBSD */
  18.103 +#define ELFOSABI_ARM		97	/* ARM */
  18.104 +#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
  18.105 +
  18.106 +/* e_ident */
  18.107 +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
  18.108 +                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
  18.109 +                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
  18.110 +                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)
  18.111 +
  18.112 +/* ELF Header */
  18.113 +typedef struct elfhdr {
  18.114 +	unsigned char	e_ident[EI_NIDENT]; /* ELF Identification */
  18.115 +	Elf32_Half	e_type;		/* object file type */
  18.116 +	Elf32_Half	e_machine;	/* machine */
  18.117 +	Elf32_Word	e_version;	/* object file version */
  18.118 +	Elf32_Addr	e_entry;	/* virtual entry point */
  18.119 +	Elf32_Off	e_phoff;	/* program header table offset */
  18.120 +	Elf32_Off	e_shoff;	/* section header table offset */
  18.121 +	Elf32_Word	e_flags;	/* processor-specific flags */
  18.122 +	Elf32_Half	e_ehsize;	/* ELF header size */
  18.123 +	Elf32_Half	e_phentsize;	/* program header entry size */
  18.124 +	Elf32_Half	e_phnum;	/* number of program header entries */
  18.125 +	Elf32_Half	e_shentsize;	/* section header entry size */
  18.126 +	Elf32_Half	e_shnum;	/* number of section header entries */
  18.127 +	Elf32_Half	e_shstrndx;	/* section header table's "section
  18.128 +					   header string table" entry offset */
  18.129 +} Elf32_Ehdr;
  18.130 +
  18.131 +typedef struct {
  18.132 +	unsigned char	e_ident[EI_NIDENT];	/* Id bytes */
  18.133 +	Elf64_Quarter	e_type;			/* file type */
  18.134 +	Elf64_Quarter	e_machine;		/* machine type */
  18.135 +	Elf64_Half	e_version;		/* version number */
  18.136 +	Elf64_Addr	e_entry;		/* entry point */
  18.137 +	Elf64_Off	e_phoff;		/* Program hdr offset */
  18.138 +	Elf64_Off	e_shoff;		/* Section hdr offset */
  18.139 +	Elf64_Half	e_flags;		/* Processor flags */
  18.140 +	Elf64_Quarter	e_ehsize;		/* sizeof ehdr */
  18.141 +	Elf64_Quarter	e_phentsize;		/* Program header entry size */
  18.142 +	Elf64_Quarter	e_phnum;		/* Number of program headers */
  18.143 +	Elf64_Quarter	e_shentsize;		/* Section header entry size */
  18.144 +	Elf64_Quarter	e_shnum;		/* Number of section headers */
  18.145 +	Elf64_Quarter	e_shstrndx;		/* String table index */
  18.146 +} Elf64_Ehdr;
  18.147 +
  18.148 +/* e_type */
  18.149 +#define ET_NONE		0		/* No file type */
  18.150 +#define ET_REL		1		/* relocatable file */
  18.151 +#define ET_EXEC		2		/* executable file */
  18.152 +#define ET_DYN		3		/* shared object file */
  18.153 +#define ET_CORE		4		/* core file */
  18.154 +#define ET_NUM		5		/* number of types */
  18.155 +#define ET_LOPROC	0xff00		/* reserved range for processor */
  18.156 +#define ET_HIPROC	0xffff		/*  specific e_type */
  18.157 +
  18.158 +/* e_machine */
  18.159 +#define EM_NONE		0		/* No Machine */
  18.160 +#define EM_M32		1		/* AT&T WE 32100 */
  18.161 +#define EM_SPARC	2		/* SPARC */
  18.162 +#define EM_386		3		/* Intel 80386 */
  18.163 +#define EM_68K		4		/* Motorola 68000 */
  18.164 +#define EM_88K		5		/* Motorola 88000 */
  18.165 +#define EM_486		6		/* Intel 80486 - unused? */
  18.166 +#define EM_860		7		/* Intel 80860 */
  18.167 +#define EM_MIPS		8		/* MIPS R3000 Big-Endian only */
  18.168 +/*
  18.169 + * Don't know if EM_MIPS_RS4_BE,
  18.170 + * EM_SPARC64, EM_PARISC,
  18.171 + * or EM_PPC are ABI compliant
  18.172 + */
  18.173 +#define EM_MIPS_RS4_BE	10		/* MIPS R4000 Big-Endian */
  18.174 +#define EM_SPARC64	11		/* SPARC v9 64-bit unoffical */
  18.175 +#define EM_PARISC	15		/* HPPA */
  18.176 +#define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
  18.177 +#define EM_PPC		20		/* PowerPC */
  18.178 +#define EM_PPC64	21		/* PowerPC 64-bit */
  18.179 +#define EM_ARM		40		/* Advanced RISC Machines ARM */
  18.180 +#define EM_ALPHA	41		/* DEC ALPHA */
  18.181 +#define EM_SPARCV9	43		/* SPARC version 9 */
  18.182 +#define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
  18.183 +#define EM_IA_64	50		/* Intel Merced */
  18.184 +#define EM_X86_64	62		/* AMD x86-64 architecture */
  18.185 +#define EM_VAX		75		/* DEC VAX */
  18.186 +
  18.187 +/* Version */
  18.188 +#define EV_NONE		0		/* Invalid */
  18.189 +#define EV_CURRENT	1		/* Current */
  18.190 +#define EV_NUM		2		/* number of versions */
  18.191 +
  18.192 +/* Section Header */
  18.193 +typedef struct {
  18.194 +	Elf32_Word	sh_name;	/* name - index into section header
  18.195 +					   string table section */
  18.196 +	Elf32_Word	sh_type;	/* type */
  18.197 +	Elf32_Word	sh_flags;	/* flags */
  18.198 +	Elf32_Addr	sh_addr;	/* address */
  18.199 +	Elf32_Off	sh_offset;	/* file offset */
  18.200 +	Elf32_Word	sh_size;	/* section size */
  18.201 +	Elf32_Word	sh_link;	/* section header table index link */
  18.202 +	Elf32_Word	sh_info;	/* extra information */
  18.203 +	Elf32_Word	sh_addralign;	/* address alignment */
  18.204 +	Elf32_Word	sh_entsize;	/* section entry size */
  18.205 +} Elf32_Shdr;
  18.206 +
  18.207 +typedef struct {
  18.208 +	Elf64_Half	sh_name;	/* section name */
  18.209 +	Elf64_Half	sh_type;	/* section type */
  18.210 +	Elf64_Xword	sh_flags;	/* section flags */
  18.211 +	Elf64_Addr	sh_addr;	/* virtual address */
  18.212 +	Elf64_Off	sh_offset;	/* file offset */
  18.213 +	Elf64_Xword	sh_size;	/* section size */
  18.214 +	Elf64_Half	sh_link;	/* link to another */
  18.215 +	Elf64_Half	sh_info;	/* misc info */
  18.216 +	Elf64_Xword	sh_addralign;	/* memory alignment */
  18.217 +	Elf64_Xword	sh_entsize;	/* table entry size */
  18.218 +} Elf64_Shdr;
  18.219 +
  18.220 +/* Special Section Indexes */
  18.221 +#define SHN_UNDEF	0		/* undefined */
  18.222 +#define SHN_LORESERVE	0xff00		/* lower bounds of reserved indexes */
  18.223 +#define SHN_LOPROC	0xff00		/* reserved range for processor */
  18.224 +#define SHN_HIPROC	0xff1f		/*   specific section indexes */
  18.225 +#define SHN_ABS		0xfff1		/* absolute value */
  18.226 +#define SHN_COMMON	0xfff2		/* common symbol */
  18.227 +#define SHN_HIRESERVE	0xffff		/* upper bounds of reserved indexes */
  18.228 +
  18.229 +/* sh_type */
  18.230 +#define SHT_NULL	0		/* inactive */
  18.231 +#define SHT_PROGBITS	1		/* program defined information */
  18.232 +#define SHT_SYMTAB	2		/* symbol table section */
  18.233 +#define SHT_STRTAB	3		/* string table section */
  18.234 +#define SHT_RELA	4		/* relocation section with addends*/
  18.235 +#define SHT_HASH	5		/* symbol hash table section */
  18.236 +#define SHT_DYNAMIC	6		/* dynamic section */
  18.237 +#define SHT_NOTE	7		/* note section */
  18.238 +#define SHT_NOBITS	8		/* no space section */
  18.239 +#define SHT_REL		9		/* relation section without addends */
  18.240 +#define SHT_SHLIB	10		/* reserved - purpose unknown */
  18.241 +#define SHT_DYNSYM	11		/* dynamic symbol table section */
  18.242 +#define SHT_NUM		12		/* number of section types */
  18.243 +#define SHT_LOPROC	0x70000000	/* reserved range for processor */
  18.244 +#define SHT_HIPROC	0x7fffffff	/*  specific section header types */
  18.245 +#define SHT_LOUSER	0x80000000	/* reserved range for application */
  18.246 +#define SHT_HIUSER	0xffffffff	/*  specific indexes */
  18.247 +
  18.248 +/* Section names */
  18.249 +#define ELF_BSS         ".bss"		/* uninitialized data */
  18.250 +#define ELF_DATA        ".data"		/* initialized data */
  18.251 +#define ELF_DEBUG       ".debug"	/* debug */
  18.252 +#define ELF_DYNAMIC     ".dynamic"	/* dynamic linking information */
  18.253 +#define ELF_DYNSTR      ".dynstr"	/* dynamic string table */
  18.254 +#define ELF_DYNSYM      ".dynsym"	/* dynamic symbol table */
  18.255 +#define ELF_FINI        ".fini"		/* termination code */
  18.256 +#define ELF_GOT         ".got"		/* global offset table */
  18.257 +#define ELF_HASH        ".hash"		/* symbol hash table */
  18.258 +#define ELF_INIT        ".init"		/* initialization code */
  18.259 +#define ELF_REL_DATA    ".rel.data"	/* relocation data */
  18.260 +#define ELF_REL_FINI    ".rel.fini"	/* relocation termination code */
  18.261 +#define ELF_REL_INIT    ".rel.init"	/* relocation initialization code */
  18.262 +#define ELF_REL_DYN     ".rel.dyn"	/* relocaltion dynamic link info */
  18.263 +#define ELF_REL_RODATA  ".rel.rodata"	/* relocation read-only data */
  18.264 +#define ELF_REL_TEXT    ".rel.text"	/* relocation code */
  18.265 +#define ELF_RODATA      ".rodata"	/* read-only data */
  18.266 +#define ELF_SHSTRTAB    ".shstrtab"	/* section header string table */
  18.267 +#define ELF_STRTAB      ".strtab"	/* string table */
  18.268 +#define ELF_SYMTAB      ".symtab"	/* symbol table */
  18.269 +#define ELF_TEXT        ".text"		/* code */
  18.270 +
  18.271 +
  18.272 +/* Section Attribute Flags - sh_flags */
  18.273 +#define SHF_WRITE	0x1		/* Writable */
  18.274 +#define SHF_ALLOC	0x2		/* occupies memory */
  18.275 +#define SHF_EXECINSTR	0x4		/* executable */
  18.276 +#define SHF_MASKPROC	0xf0000000	/* reserved bits for processor */
  18.277 +					/*  specific section attributes */
  18.278 +
  18.279 +/* Symbol Table Entry */
  18.280 +typedef struct elf32_sym {
  18.281 +	Elf32_Word	st_name;	/* name - index into string table */
  18.282 +	Elf32_Addr	st_value;	/* symbol value */
  18.283 +	Elf32_Word	st_size;	/* symbol size */
  18.284 +	unsigned char	st_info;	/* type and binding */
  18.285 +	unsigned char	st_other;	/* 0 - no defined meaning */
  18.286 +	Elf32_Half	st_shndx;	/* section header index */
  18.287 +} Elf32_Sym;
  18.288 +
  18.289 +typedef struct {
  18.290 +	Elf64_Half	st_name;	/* Symbol name index in str table */
  18.291 +	Elf_Byte	st_info;	/* type / binding attrs */
  18.292 +	Elf_Byte	st_other;	/* unused */
  18.293 +	Elf64_Quarter	st_shndx;	/* section index of symbol */
  18.294 +	Elf64_Xword	st_value;	/* value of symbol */
  18.295 +	Elf64_Xword	st_size;	/* size of symbol */
  18.296 +} Elf64_Sym;
  18.297 +
  18.298 +/* Symbol table index */
  18.299 +#define STN_UNDEF	0		/* undefined */
  18.300 +
  18.301 +/* Extract symbol info - st_info */
  18.302 +#define ELF32_ST_BIND(x)	((x) >> 4)
  18.303 +#define ELF32_ST_TYPE(x)	(((unsigned int) x) & 0xf)
  18.304 +#define ELF32_ST_INFO(b,t)	(((b) << 4) + ((t) & 0xf))
  18.305 +
  18.306 +#define ELF64_ST_BIND(x)	((x) >> 4)
  18.307 +#define ELF64_ST_TYPE(x)	(((unsigned int) x) & 0xf)
  18.308 +#define ELF64_ST_INFO(b,t)	(((b) << 4) + ((t) & 0xf))
  18.309 +
  18.310 +/* Symbol Binding - ELF32_ST_BIND - st_info */
  18.311 +#define STB_LOCAL	0		/* Local symbol */
  18.312 +#define STB_GLOBAL	1		/* Global symbol */
  18.313 +#define STB_WEAK	2		/* like global - lower precedence */
  18.314 +#define STB_NUM		3		/* number of symbol bindings */
  18.315 +#define STB_LOPROC	13		/* reserved range for processor */
  18.316 +#define STB_HIPROC	15		/*  specific symbol bindings */
  18.317 +
  18.318 +/* Symbol type - ELF32_ST_TYPE - st_info */
  18.319 +#define STT_NOTYPE	0		/* not specified */
  18.320 +#define STT_OBJECT	1		/* data object */
  18.321 +#define STT_FUNC	2		/* function */
  18.322 +#define STT_SECTION	3		/* section */
  18.323 +#define STT_FILE	4		/* file */
  18.324 +#define STT_NUM		5		/* number of symbol types */
  18.325 +#define STT_LOPROC	13		/* reserved range for processor */
  18.326 +#define STT_HIPROC	15		/*  specific symbol types */
  18.327 +
  18.328 +/* Relocation entry with implicit addend */
  18.329 +typedef struct {
  18.330 +	Elf32_Addr	r_offset;	/* offset of relocation */
  18.331 +	Elf32_Word	r_info;		/* symbol table index and type */
  18.332 +} Elf32_Rel;
  18.333 +
  18.334 +/* Relocation entry with explicit addend */
  18.335 +typedef struct {
  18.336 +	Elf32_Addr	r_offset;	/* offset of relocation */
  18.337 +	Elf32_Word	r_info;		/* symbol table index and type */
  18.338 +	Elf32_Sword	r_addend;
  18.339 +} Elf32_Rela;
  18.340 +
  18.341 +/* Extract relocation info - r_info */
  18.342 +#define ELF32_R_SYM(i)		((i) >> 8)
  18.343 +#define ELF32_R_TYPE(i)		((unsigned char) (i))
  18.344 +#define ELF32_R_INFO(s,t) 	(((s) << 8) + (unsigned char)(t))
  18.345 +
  18.346 +typedef struct {
  18.347 +	Elf64_Xword	r_offset;	/* where to do it */
  18.348 +	Elf64_Xword	r_info;		/* index & type of relocation */
  18.349 +} Elf64_Rel;
  18.350 +
  18.351 +typedef struct {
  18.352 +	Elf64_Xword	r_offset;	/* where to do it */
  18.353 +	Elf64_Xword	r_info;		/* index & type of relocation */
  18.354 +	Elf64_Sxword	r_addend;	/* adjustment value */
  18.355 +} Elf64_Rela;
  18.356 +
  18.357 +#define	ELF64_R_SYM(info)	((info) >> 32)
  18.358 +#define	ELF64_R_TYPE(info)	((info) & 0xFFFFFFFF)
  18.359 +#define ELF64_R_INFO(s,t) 	(((s) << 32) + (u_int32_t)(t))
  18.360 +
  18.361 +/* Program Header */
  18.362 +typedef struct {
  18.363 +	Elf32_Word	p_type;		/* segment type */
  18.364 +	Elf32_Off	p_offset;	/* segment offset */
  18.365 +	Elf32_Addr	p_vaddr;	/* virtual address of segment */
  18.366 +	Elf32_Addr	p_paddr;	/* physical address - ignored? */
  18.367 +	Elf32_Word	p_filesz;	/* number of bytes in file for seg. */
  18.368 +	Elf32_Word	p_memsz;	/* number of bytes in mem. for seg. */
  18.369 +	Elf32_Word	p_flags;	/* flags */
  18.370 +	Elf32_Word	p_align;	/* memory alignment */
  18.371 +} Elf32_Phdr;
  18.372 +
  18.373 +typedef struct {
  18.374 +	Elf64_Half	p_type;		/* entry type */
  18.375 +	Elf64_Half	p_flags;	/* flags */
  18.376 +	Elf64_Off	p_offset;	/* offset */
  18.377 +	Elf64_Addr	p_vaddr;	/* virtual address */
  18.378 +	Elf64_Addr	p_paddr;	/* physical address */
  18.379 +	Elf64_Xword	p_filesz;	/* file size */
  18.380 +	Elf64_Xword	p_memsz;	/* memory size */
  18.381 +	Elf64_Xword	p_align;	/* memory & file alignment */
  18.382 +} Elf64_Phdr;
  18.383 +
  18.384 +/* Segment types - p_type */
  18.385 +#define PT_NULL		0		/* unused */
  18.386 +#define PT_LOAD		1		/* loadable segment */
  18.387 +#define PT_DYNAMIC	2		/* dynamic linking section */
  18.388 +#define PT_INTERP	3		/* the RTLD */
  18.389 +#define PT_NOTE		4		/* auxiliary information */
  18.390 +#define PT_SHLIB	5		/* reserved - purpose undefined */
  18.391 +#define PT_PHDR		6		/* program header */
  18.392 +#define PT_NUM		7		/* Number of segment types */
  18.393 +#define PT_LOPROC	0x70000000	/* reserved range for processor */
  18.394 +#define PT_HIPROC	0x7fffffff	/*  specific segment types */
  18.395 +
  18.396 +/* Segment flags - p_flags */
  18.397 +#define PF_X		0x1		/* Executable */
  18.398 +#define PF_W		0x2		/* Writable */
  18.399 +#define PF_R		0x4		/* Readable */
  18.400 +#define PF_MASKPROC	0xf0000000	/* reserved bits for processor */
  18.401 +					/*  specific segment flags */
  18.402 +
  18.403 +/* Dynamic structure */
  18.404 +typedef struct {
  18.405 +	Elf32_Sword	d_tag;		/* controls meaning of d_val */
  18.406 +	union {
  18.407 +		Elf32_Word	d_val;	/* Multiple meanings - see d_tag */
  18.408 +		Elf32_Addr	d_ptr;	/* program virtual address */
  18.409 +	} d_un;
  18.410 +} Elf32_Dyn;
  18.411 +
  18.412 +typedef struct {
  18.413 +	Elf64_Xword	d_tag;		/* controls meaning of d_val */
  18.414 +	union {
  18.415 +		Elf64_Addr	d_ptr;
  18.416 +		Elf64_Xword	d_val;
  18.417 +	} d_un;
  18.418 +} Elf64_Dyn;
  18.419 +
  18.420 +/* Dynamic Array Tags - d_tag */
  18.421 +#define DT_NULL		0		/* marks end of _DYNAMIC array */
  18.422 +#define DT_NEEDED	1		/* string table offset of needed lib */
  18.423 +#define DT_PLTRELSZ	2		/* size of relocation entries in PLT */
  18.424 +#define DT_PLTGOT	3		/* address PLT/GOT */
  18.425 +#define DT_HASH		4		/* address of symbol hash table */
  18.426 +#define DT_STRTAB	5		/* address of string table */
  18.427 +#define DT_SYMTAB	6		/* address of symbol table */
  18.428 +#define DT_RELA		7		/* address of relocation table */
  18.429 +#define DT_RELASZ	8		/* size of relocation table */
  18.430 +#define DT_RELAENT	9		/* size of relocation entry */
  18.431 +#define DT_STRSZ	10		/* size of string table */
  18.432 +#define DT_SYMENT	11		/* size of symbol table entry */
  18.433 +#define DT_INIT		12		/* address of initialization func. */
  18.434 +#define DT_FINI		13		/* address of termination function */
  18.435 +#define DT_SONAME	14		/* string table offset of shared obj */
  18.436 +#define DT_RPATH	15		/* string table offset of library
  18.437 +					   search path */
  18.438 +#define DT_SYMBOLIC	16		/* start sym search in shared obj. */
  18.439 +#define DT_REL		17		/* address of rel. tbl. w addends */
  18.440 +#define DT_RELSZ	18		/* size of DT_REL relocation table */
  18.441 +#define DT_RELENT	19		/* size of DT_REL relocation entry */
  18.442 +#define DT_PLTREL	20		/* PLT referenced relocation entry */
  18.443 +#define DT_DEBUG	21		/* bugger */
  18.444 +#define DT_TEXTREL	22		/* Allow rel. mod. to unwritable seg */
  18.445 +#define DT_JMPREL	23		/* add. of PLT's relocation entries */
  18.446 +#define DT_BIND_NOW	24		/* Bind now regardless of env setting */
  18.447 +#define DT_NUM		25		/* Number used. */
  18.448 +#define DT_LOPROC	0x70000000	/* reserved range for processor */
  18.449 +#define DT_HIPROC	0x7fffffff	/*  specific dynamic array tags */
  18.450 +
  18.451 +/* Standard ELF hashing function */
  18.452 +unsigned int elf_hash(const unsigned char *name);
  18.453 +
  18.454 +/*
  18.455 + * Note Definitions
  18.456 + */
  18.457 +typedef struct {
  18.458 +	Elf32_Word namesz;
  18.459 +	Elf32_Word descsz;
  18.460 +	Elf32_Word type;
  18.461 +} Elf32_Note;
  18.462 +
  18.463 +typedef struct {
  18.464 +	Elf64_Half namesz;
  18.465 +	Elf64_Half descsz;
  18.466 +	Elf64_Half type;
  18.467 +} Elf64_Note;
  18.468 +
  18.469 +
  18.470 +#if defined(ELFSIZE)
  18.471 +#define CONCAT(x,y)	__CONCAT(x,y)
  18.472 +#define ELFNAME(x)	CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
  18.473 +#define ELFNAME2(x,y)	CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
  18.474 +#define ELFNAMEEND(x)	CONCAT(x,CONCAT(_elf,ELFSIZE))
  18.475 +#define ELFDEFNNAME(x)	CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
  18.476 +#endif
  18.477 +
  18.478 +#if defined(ELFSIZE) && (ELFSIZE == 32)
  18.479 +#define Elf_Ehdr	Elf32_Ehdr
  18.480 +#define Elf_Phdr	Elf32_Phdr
  18.481 +#define Elf_Shdr	Elf32_Shdr
  18.482 +#define Elf_Sym		Elf32_Sym
  18.483 +#define Elf_Rel		Elf32_Rel
  18.484 +#define Elf_RelA	Elf32_Rela
  18.485 +#define Elf_Dyn		Elf32_Dyn
  18.486 +#define Elf_Word	Elf32_Word
  18.487 +#define Elf_Sword	Elf32_Sword
  18.488 +#define Elf_Addr	Elf32_Addr
  18.489 +#define Elf_Off		Elf32_Off
  18.490 +#define Elf_Nhdr	Elf32_Nhdr
  18.491 +#define Elf_Note	Elf32_Note
  18.492 +
  18.493 +#define ELF_R_SYM	ELF32_R_SYM
  18.494 +#define ELF_R_TYPE	ELF32_R_TYPE
  18.495 +#define ELF_R_INFO	ELF32_R_INFO
  18.496 +#define ELFCLASS	ELFCLASS32
  18.497 +
  18.498 +#define ELF_ST_BIND	ELF32_ST_BIND
  18.499 +#define ELF_ST_TYPE	ELF32_ST_TYPE
  18.500 +#define ELF_ST_INFO	ELF32_ST_INFO
  18.501 +
  18.502 +#define AuxInfo		Aux32Info
  18.503 +#elif defined(ELFSIZE) && (ELFSIZE == 64)
  18.504 +#define Elf_Ehdr	Elf64_Ehdr
  18.505 +#define Elf_Phdr	Elf64_Phdr
  18.506 +#define Elf_Shdr	Elf64_Shdr
  18.507 +#define Elf_Sym		Elf64_Sym
  18.508 +#define Elf_Rel		Elf64_Rel
  18.509 +#define Elf_RelA	Elf64_Rela
  18.510 +#define Elf_Dyn		Elf64_Dyn
  18.511 +#define Elf_Word	Elf64_Word
  18.512 +#define Elf_Sword	Elf64_Sword
  18.513 +#define Elf_Addr	Elf64_Addr
  18.514 +#define Elf_Off		Elf64_Off
  18.515 +#define Elf_Nhdr	Elf64_Nhdr
  18.516 +#define Elf_Note	Elf64_Note
  18.517 +
  18.518 +#define ELF_R_SYM	ELF64_R_SYM
  18.519 +#define ELF_R_TYPE	ELF64_R_TYPE
  18.520 +#define ELF_R_INFO	ELF64_R_INFO
  18.521 +#define ELFCLASS	ELFCLASS64
  18.522 +
  18.523 +#define ELF_ST_BIND	ELF64_ST_BIND
  18.524 +#define ELF_ST_TYPE	ELF64_ST_TYPE
  18.525 +#define ELF_ST_INFO	ELF64_ST_INFO
  18.526 +
  18.527 +#define AuxInfo		Aux64Info
  18.528 +#endif
  18.529 +
  18.530 +#endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/common/include/public/event_channel.h	Wed Dec 05 11:14:28 2007 -0800
    19.3 @@ -0,0 +1,264 @@
    19.4 +/******************************************************************************
    19.5 + * event_channel.h
    19.6 + * 
    19.7 + * Event channels between domains.
    19.8 + * 
    19.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   19.10 + * of this software and associated documentation files (the "Software"), to
   19.11 + * deal in the Software without restriction, including without limitation the
   19.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   19.13 + * sell copies of the Software, and to permit persons to whom the Software is
   19.14 + * furnished to do so, subject to the following conditions:
   19.15 + *
   19.16 + * The above copyright notice and this permission notice shall be included in
   19.17 + * all copies or substantial portions of the Software.
   19.18 + *
   19.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   19.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   19.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   19.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   19.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   19.25 + * DEALINGS IN THE SOFTWARE.
   19.26 + *
   19.27 + * Copyright (c) 2003-2004, K A Fraser.
   19.28 + */
   19.29 +
   19.30 +#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
   19.31 +#define __XEN_PUBLIC_EVENT_CHANNEL_H__
   19.32 +
   19.33 +/*
   19.34 + * Prototype for this hypercall is:
   19.35 + *  int event_channel_op(int cmd, void *args)
   19.36 + * @cmd  == EVTCHNOP_??? (event-channel operation).
   19.37 + * @args == Operation-specific extra arguments (NULL if none).
   19.38 + */
   19.39 +
   19.40 +typedef uint32_t evtchn_port_t;
   19.41 +DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
   19.42 +
   19.43 +/*
   19.44 + * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
   19.45 + * accepting interdomain bindings from domain <remote_dom>. A fresh port
   19.46 + * is allocated in <dom> and returned as <port>.
   19.47 + * NOTES:
   19.48 + *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
   19.49 + *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
   19.50 + */
   19.51 +#define EVTCHNOP_alloc_unbound    6
   19.52 +struct evtchn_alloc_unbound {
   19.53 +    /* IN parameters */
   19.54 +    domid_t dom, remote_dom;
   19.55 +    /* OUT parameters */
   19.56 +    evtchn_port_t port;
   19.57 +};
   19.58 +typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
   19.59 +
   19.60 +/*
   19.61 + * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
   19.62 + * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
   19.63 + * a port that is unbound and marked as accepting bindings from the calling
   19.64 + * domain. A fresh port is allocated in the calling domain and returned as
   19.65 + * <local_port>.
   19.66 + * NOTES:
   19.67 + *  2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
   19.68 + */
   19.69 +#define EVTCHNOP_bind_interdomain 0
   19.70 +struct evtchn_bind_interdomain {
   19.71 +    /* IN parameters. */
   19.72 +    domid_t remote_dom;
   19.73 +    evtchn_port_t remote_port;
   19.74 +    /* OUT parameters. */
   19.75 +    evtchn_port_t local_port;
   19.76 +};
   19.77 +typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
   19.78 +
   19.79 +/*
   19.80 + * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
   19.81 + * vcpu.
   19.82 + * NOTES:
   19.83 + *  1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
   19.84 + *     in xen.h for the classification of each VIRQ.
   19.85 + *  2. Global VIRQs must be allocated on VCPU0 but can subsequently be
   19.86 + *     re-bound via EVTCHNOP_bind_vcpu.
   19.87 + *  3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
   19.88 + *     The allocated event channel is bound to the specified vcpu and the
   19.89 + *     binding cannot be changed.
   19.90 + */
   19.91 +#define EVTCHNOP_bind_virq        1
   19.92 +struct evtchn_bind_virq {
   19.93 +    /* IN parameters. */
   19.94 +    uint32_t virq;
   19.95 +    uint32_t vcpu;
   19.96 +    /* OUT parameters. */
   19.97 +    evtchn_port_t port;
   19.98 +};
   19.99 +typedef struct evtchn_bind_virq evtchn_bind_virq_t;
  19.100 +
  19.101 +/*
  19.102 + * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
  19.103 + * NOTES:
  19.104 + *  1. A physical IRQ may be bound to at most one event channel per domain.
  19.105 + *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
  19.106 + */
  19.107 +#define EVTCHNOP_bind_pirq        2
  19.108 +struct evtchn_bind_pirq {
  19.109 +    /* IN parameters. */
  19.110 +    uint32_t pirq;
  19.111 +#define BIND_PIRQ__WILL_SHARE 1
  19.112 +    uint32_t flags; /* BIND_PIRQ__* */
  19.113 +    /* OUT parameters. */
  19.114 +    evtchn_port_t port;
  19.115 +};
  19.116 +typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
  19.117 +
  19.118 +/*
  19.119 + * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
  19.120 + * NOTES:
  19.121 + *  1. The allocated event channel is bound to the specified vcpu. The binding
  19.122 + *     may not be changed.
  19.123 + */
  19.124 +#define EVTCHNOP_bind_ipi         7
  19.125 +struct evtchn_bind_ipi {
  19.126 +    uint32_t vcpu;
  19.127 +    /* OUT parameters. */
  19.128 +    evtchn_port_t port;
  19.129 +};
  19.130 +typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
  19.131 +
  19.132 +/*
  19.133 + * EVTCHNOP_close: Close a local event channel <port>. If the channel is
  19.134 + * interdomain then the remote end is placed in the unbound state
  19.135 + * (EVTCHNSTAT_unbound), awaiting a new connection.
  19.136 + */
  19.137 +#define EVTCHNOP_close            3
  19.138 +struct evtchn_close {
  19.139 +    /* IN parameters. */
  19.140 +    evtchn_port_t port;
  19.141 +};
  19.142 +typedef struct evtchn_close evtchn_close_t;
  19.143 +
  19.144 +/*
  19.145 + * EVTCHNOP_send: Send an event to the remote end of the channel whose local
  19.146 + * endpoint is <port>.
  19.147 + */
  19.148 +#define EVTCHNOP_send             4
  19.149 +struct evtchn_send {
  19.150 +    /* IN parameters. */
  19.151 +    evtchn_port_t port;
  19.152 +};
  19.153 +typedef struct evtchn_send evtchn_send_t;
  19.154 +
  19.155 +/*
  19.156 + * EVTCHNOP_status: Get the current status of the communication channel which
  19.157 + * has an endpoint at <dom, port>.
  19.158 + * NOTES:
  19.159 + *  1. <dom> may be specified as DOMID_SELF.
  19.160 + *  2. Only a sufficiently-privileged domain may obtain the status of an event
  19.161 + *     channel for which <dom> is not DOMID_SELF.
  19.162 + */
  19.163 +#define EVTCHNOP_status           5
  19.164 +struct evtchn_status {
  19.165 +    /* IN parameters */
  19.166 +    domid_t  dom;
  19.167 +    evtchn_port_t port;
  19.168 +    /* OUT parameters */
  19.169 +#define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
  19.170 +#define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
  19.171 +#define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
  19.172 +#define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
  19.173 +#define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
  19.174 +#define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
  19.175 +    uint32_t status;
  19.176 +    uint32_t vcpu;                 /* VCPU to which this channel is bound.   */
  19.177 +    union {
  19.178 +        struct {
  19.179 +            domid_t dom;
  19.180 +        } unbound; /* EVTCHNSTAT_unbound */
  19.181 +        struct {
  19.182 +            domid_t dom;
  19.183 +            evtchn_port_t port;
  19.184 +        } interdomain; /* EVTCHNSTAT_interdomain */
  19.185 +        uint32_t pirq;      /* EVTCHNSTAT_pirq        */
  19.186 +        uint32_t virq;      /* EVTCHNSTAT_virq        */
  19.187 +    } u;
  19.188 +};
  19.189 +typedef struct evtchn_status evtchn_status_t;
  19.190 +
  19.191 +/*
  19.192 + * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
  19.193 + * event is pending.
  19.194 + * NOTES:
  19.195 + *  1. IPI-bound channels always notify the vcpu specified at bind time.
  19.196 + *     This binding cannot be changed.
  19.197 + *  2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
  19.198 + *     This binding cannot be changed.
  19.199 + *  3. All other channels notify vcpu0 by default. This default is set when
  19.200 + *     the channel is allocated (a port that is freed and subsequently reused
  19.201 + *     has its binding reset to vcpu0).
  19.202 + */
  19.203 +#define EVTCHNOP_bind_vcpu        8
  19.204 +struct evtchn_bind_vcpu {
  19.205 +    /* IN parameters. */
  19.206 +    evtchn_port_t port;
  19.207 +    uint32_t vcpu;
  19.208 +};
  19.209 +typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
  19.210 +
  19.211 +/*
  19.212 + * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
  19.213 + * a notification to the appropriate VCPU if an event is pending.
  19.214 + */
  19.215 +#define EVTCHNOP_unmask           9
  19.216 +struct evtchn_unmask {
  19.217 +    /* IN parameters. */
  19.218 +    evtchn_port_t port;
  19.219 +};
  19.220 +typedef struct evtchn_unmask evtchn_unmask_t;
  19.221 +
  19.222 +/*
  19.223 + * EVTCHNOP_reset: Close all event channels associated with specified domain.
  19.224 + * NOTES:
  19.225 + *  1. <dom> may be specified as DOMID_SELF.
  19.226 + *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
  19.227 + */
  19.228 +#define EVTCHNOP_reset           10
  19.229 +struct evtchn_reset {
  19.230 +    /* IN parameters. */
  19.231 +    domid_t dom;
  19.232 +};
  19.233 +typedef struct evtchn_reset evtchn_reset_t;
  19.234 +
  19.235 +/*
  19.236 + * Argument to event_channel_op_compat() hypercall. Superceded by new
  19.237 + * event_channel_op() hypercall since 0x00030202.
  19.238 + */
  19.239 +struct evtchn_op {
  19.240 +    uint32_t cmd; /* EVTCHNOP_* */
  19.241 +    union {
  19.242 +        struct evtchn_alloc_unbound    alloc_unbound;
  19.243 +        struct evtchn_bind_interdomain bind_interdomain;
  19.244 +        struct evtchn_bind_virq        bind_virq;
  19.245 +        struct evtchn_bind_pirq        bind_pirq;
  19.246 +        struct evtchn_bind_ipi         bind_ipi;
  19.247 +        struct evtchn_close            close;
  19.248 +        struct evtchn_send             send;
  19.249 +        struct evtchn_status           status;
  19.250 +        struct evtchn_bind_vcpu        bind_vcpu;
  19.251 +        struct evtchn_unmask           unmask;
  19.252 +    } u;
  19.253 +};
  19.254 +typedef struct evtchn_op evtchn_op_t;
  19.255 +DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
  19.256 +
  19.257 +#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
  19.258 +
  19.259 +/*
  19.260 + * Local variables:
  19.261 + * mode: C
  19.262 + * c-set-style: "BSD"
  19.263 + * c-basic-offset: 4
  19.264 + * tab-width: 4
  19.265 + * indent-tabs-mode: nil
  19.266 + * End:
  19.267 + */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/common/include/public/features.h	Wed Dec 05 11:14:28 2007 -0800
    20.3 @@ -0,0 +1,71 @@
    20.4 +/******************************************************************************
    20.5 + * features.h
    20.6 + * 
    20.7 + * Feature flags, reported by XENVER_get_features.
    20.8 + * 
    20.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   20.10 + * of this software and associated documentation files (the "Software"), to
   20.11 + * deal in the Software without restriction, including without limitation the
   20.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   20.13 + * sell copies of the Software, and to permit persons to whom the Software is
   20.14 + * furnished to do so, subject to the following conditions:
   20.15 + *
   20.16 + * The above copyright notice and this permission notice shall be included in
   20.17 + * all copies or substantial portions of the Software.
   20.18 + *
   20.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   20.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   20.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   20.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   20.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   20.25 + * DEALINGS IN THE SOFTWARE.
   20.26 + *
   20.27 + * Copyright (c) 2006, Keir Fraser <keir@xensource.com>
   20.28 + */
   20.29 +
   20.30 +#ifndef __XEN_PUBLIC_FEATURES_H__
   20.31 +#define __XEN_PUBLIC_FEATURES_H__
   20.32 +
   20.33 +/*
   20.34 + * If set, the guest does not need to write-protect its pagetables, and can
   20.35 + * update them via direct writes.
   20.36 + */
   20.37 +#define XENFEAT_writable_page_tables       0
   20.38 +
   20.39 +/*
   20.40 + * If set, the guest does not need to write-protect its segment descriptor
   20.41 + * tables, and can update them via direct writes.
   20.42 + */
   20.43 +#define XENFEAT_writable_descriptor_tables 1
   20.44 +
   20.45 +/*
   20.46 + * If set, translation between the guest's 'pseudo-physical' address space
   20.47 + * and the host's machine address space are handled by the hypervisor. In this
   20.48 + * mode the guest does not need to perform phys-to/from-machine translations
   20.49 + * when performing page table operations.
   20.50 + */
   20.51 +#define XENFEAT_auto_translated_physmap    2
   20.52 +
   20.53 +/* If set, the guest is running in supervisor mode (e.g., x86 ring 0). */
   20.54 +#define XENFEAT_supervisor_mode_kernel     3
   20.55 +
   20.56 +/*
   20.57 + * If set, the guest does not need to allocate x86 PAE page directories
   20.58 + * below 4GB. This flag is usually implied by auto_translated_physmap.
   20.59 + */
   20.60 +#define XENFEAT_pae_pgdir_above_4gb        4
   20.61 +
   20.62 +#define XENFEAT_NR_SUBMAPS 1
   20.63 +
   20.64 +#endif /* __XEN_PUBLIC_FEATURES_H__ */
   20.65 +
   20.66 +/*
   20.67 + * Local variables:
   20.68 + * mode: C
   20.69 + * c-set-style: "BSD"
   20.70 + * c-basic-offset: 4
   20.71 + * tab-width: 4
   20.72 + * indent-tabs-mode: nil
   20.73 + * End:
   20.74 + */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/common/include/public/foreign/Makefile	Wed Dec 05 11:14:28 2007 -0800
    21.3 @@ -0,0 +1,37 @@
    21.4 +XEN_ROOT=../../../..
    21.5 +include $(XEN_ROOT)/Config.mk
    21.6 +
    21.7 +architectures := x86_32 x86_64 ia64
    21.8 +headers := $(patsubst %, %.h, $(architectures))
    21.9 +scripts := $(wildcard *.py)
   21.10 +
   21.11 +.PHONY: all clean check-headers
   21.12 +all: $(headers) check-headers
   21.13 +
   21.14 +clean:
   21.15 +	rm -f $(headers)
   21.16 +	rm -f checker checker.c $(XEN_TARGET_ARCH).size
   21.17 +	rm -f *.pyc *.o *~
   21.18 +
   21.19 +ifeq ($(CROSS_COMPILE)$(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
   21.20 +check-headers: checker
   21.21 +	./checker > $(XEN_TARGET_ARCH).size
   21.22 +	diff -u reference.size $(XEN_TARGET_ARCH).size
   21.23 +checker: checker.c $(headers)
   21.24 +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
   21.25 +else
   21.26 +check-headers:
   21.27 +	@echo "cross build: skipping check"
   21.28 +endif
   21.29 +
   21.30 +x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts)
   21.31 +	python mkheader.py $* $@ $(filter %.h,$^)
   21.32 +
   21.33 +x86_64.h: ../arch-x86/xen-x86_64.h ../arch-x86/xen.h ../xen.h $(scripts)
   21.34 +	python mkheader.py $* $@ $(filter %.h,$^)
   21.35 +
   21.36 +ia64.h: ../arch-ia64.h ../xen.h $(scripts)
   21.37 +	python mkheader.py $* $@ $(filter %.h,$^)
   21.38 +
   21.39 +checker.c: $(scripts)
   21.40 +	python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures)
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/common/include/public/foreign/mkchecker.py	Wed Dec 05 11:14:28 2007 -0800
    22.3 @@ -0,0 +1,58 @@
    22.4 +#!/usr/bin/python
    22.5 +
    22.6 +import sys;
    22.7 +from structs import structs;
    22.8 +
    22.9 +# command line arguments
   22.10 +arch    = sys.argv[1];
   22.11 +outfile = sys.argv[2];
   22.12 +archs   = sys.argv[3:];
   22.13 +
   22.14 +f = open(outfile, "w");
   22.15 +f.write('''
   22.16 +/*
   22.17 + * sanity checks for generated foreign headers:
   22.18 + *  - verify struct sizes
   22.19 + *
   22.20 + * generated by %s -- DO NOT EDIT
   22.21 + */
   22.22 +#include <stdio.h>
   22.23 +#include <stdlib.h>
   22.24 +#include <stddef.h>
   22.25 +#include <inttypes.h>
   22.26 +#include "../xen.h"
   22.27 +''');
   22.28 +
   22.29 +for a in archs:
   22.30 +    f.write('#include "%s.h"\n' % a);
   22.31 +
   22.32 +f.write('int main(int argc, char *argv[])\n{\n');
   22.33 +
   22.34 +f.write('\tprintf("\\n");');
   22.35 +f.write('printf("%-20s |", "structs");\n');
   22.36 +for a in archs:
   22.37 +    f.write('\tprintf("%%8s", "%s");\n' % a);
   22.38 +f.write('\tprintf("\\n");');
   22.39 +
   22.40 +f.write('\tprintf("\\n");');
   22.41 +for struct in structs:
   22.42 +    f.write('\tprintf("%%-20s |", "%s");\n' % struct);
   22.43 +    for a in archs:
   22.44 +        if a == arch:
   22.45 +            s = struct; # native
   22.46 +        else:
   22.47 +            s = struct + "_" + a;
   22.48 +        f.write('#ifdef %s_has_no_%s\n' % (a, struct));
   22.49 +        f.write('\tprintf("%8s", "-");\n');
   22.50 +        f.write("#else\n");
   22.51 +        f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
   22.52 +        f.write("#endif\n");
   22.53 +
   22.54 +    f.write('\tprintf("\\n");\n\n');
   22.55 +
   22.56 +f.write('\tprintf("\\n");\n');
   22.57 +f.write('\texit(0);\n');
   22.58 +f.write('}\n');
   22.59 +
   22.60 +f.close();
   22.61 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/common/include/public/foreign/mkheader.py	Wed Dec 05 11:14:28 2007 -0800
    23.3 @@ -0,0 +1,153 @@
    23.4 +#!/usr/bin/python
    23.5 +
    23.6 +import sys, re;
    23.7 +from structs import structs, defines;
    23.8 +
    23.9 +# command line arguments
   23.10 +arch    = sys.argv[1];
   23.11 +outfile = sys.argv[2];
   23.12 +infiles = sys.argv[3:];
   23.13 +
   23.14 +
   23.15 +###########################################################################
   23.16 +# configuration #2: architecture information
   23.17 +
   23.18 +inttypes = {};
   23.19 +header = {};
   23.20 +footer = {};
   23.21 +
   23.22 +# x86_32
   23.23 +inttypes["x86_32"] = {
   23.24 +    "unsigned long" : "uint32_t",
   23.25 +    "long"          : "uint32_t",
   23.26 +    "xen_pfn_t"     : "uint32_t",
   23.27 +};
   23.28 +header["x86_32"] = """
   23.29 +#define __i386___X86_32 1
   23.30 +#pragma pack(4)
   23.31 +""";
   23.32 +footer["x86_32"] = """
   23.33 +#pragma pack()
   23.34 +""";
   23.35 +
   23.36 +# x86_64
   23.37 +inttypes["x86_64"] = {
   23.38 +    "unsigned long" : "__align8__ uint64_t",
   23.39 +    "long"          : "__align8__ uint64_t",
   23.40 +    "xen_pfn_t"     : "__align8__ uint64_t",
   23.41 +};
   23.42 +header["x86_64"] = """
   23.43 +#ifdef __GNUC__
   23.44 +# define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
   23.45 +# define __align8__ __attribute__((aligned (8)))
   23.46 +#else
   23.47 +# define __DECL_REG(name) uint64_t r ## name
   23.48 +# define __align8__ FIXME
   23.49 +#endif
   23.50 +#define __x86_64___X86_64 1
   23.51 +""";
   23.52 +
   23.53 +# ia64
   23.54 +inttypes["ia64"] = {
   23.55 +    "unsigned long" : "__align8__ uint64_t",
   23.56 +    "long"          : "__align8__ uint64_t",
   23.57 +    "xen_pfn_t"     : "__align8__ uint64_t",
   23.58 +    "long double"   : "__align16__ ldouble_t",
   23.59 +};
   23.60 +header["ia64"] = """
   23.61 +#define __align8__ __attribute__((aligned (8)))
   23.62 +#define __align16__ __attribute__((aligned (16)))
   23.63 +typedef unsigned char ldouble_t[16];
   23.64 +""";
   23.65 +
   23.66 +
   23.67 +###########################################################################
   23.68 +# main
   23.69 +
   23.70 +input  = "";
   23.71 +output = "";
   23.72 +fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
   23.73 +
   23.74 +# read input header files
   23.75 +for name in infiles:
   23.76 +    f = open(name, "r");
   23.77 +    input += f.read();
   23.78 +    f.close();
   23.79 +
   23.80 +# add header
   23.81 +output += """
   23.82 +/*
   23.83 + * public xen defines and struct for %s
   23.84 + * generated by %s -- DO NOT EDIT
   23.85 + */
   23.86 +
   23.87 +#ifndef %s
   23.88 +#define %s 1
   23.89 +
   23.90 +""" % (arch, sys.argv[0], fileid, fileid)
   23.91 +
   23.92 +if arch in header:
   23.93 +    output += header[arch];
   23.94 +    output += "\n";
   23.95 +
   23.96 +# add defines to output
   23.97 +for line in re.findall("#define[^\n]+", input):
   23.98 +    for define in defines:
   23.99 +        regex = "#define\s+%s\\b" % define;
  23.100 +        match = re.search(regex, line);
  23.101 +        if None == match:
  23.102 +            continue;
  23.103 +        if define.upper()[0] == define[0]:
  23.104 +            replace = define + "_" + arch.upper();
  23.105 +        else:
  23.106 +            replace = define + "_" + arch;
  23.107 +        regex = "\\b%s\\b" % define;
  23.108 +        output += re.sub(regex, replace, line) + "\n";
  23.109 +output += "\n";
  23.110 +
  23.111 +# delete defines, comments, empty lines
  23.112 +input = re.sub("#define[^\n]+\n", "", input);
  23.113 +input = re.compile("/\*(.*?)\*/", re.S).sub("", input)
  23.114 +input = re.compile("\n\s*\n", re.S).sub("\n", input);
  23.115 +
  23.116 +# add structs to output
  23.117 +for struct in structs:
  23.118 +    regex = "struct\s+%s\s*\{(.*?)\n\};" % struct;
  23.119 +    match = re.search(regex, input, re.S)
  23.120 +    if None == match:
  23.121 +        output += "#define %s_has_no_%s 1\n" % (arch, struct);
  23.122 +    else:
  23.123 +        output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1));
  23.124 +        output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct, arch);
  23.125 +    output += "\n";
  23.126 +
  23.127 +# add footer
  23.128 +if arch in footer:
  23.129 +    output += footer[arch];
  23.130 +    output += "\n";
  23.131 +output += "#endif /* %s */\n" % fileid;
  23.132 +
  23.133 +# replace: defines
  23.134 +for define in defines:
  23.135 +    if define.upper()[0] == define[0]:
  23.136 +        replace = define + "_" + arch.upper();
  23.137 +    else:
  23.138 +        replace = define + "_" + arch;
  23.139 +    output = re.sub("\\b%s\\b" % define, replace, output);
  23.140 +
  23.141 +# replace: structs + struct typedefs
  23.142 +for struct in structs:
  23.143 +    output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output);
  23.144 +    output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
  23.145 +
  23.146 +# replace: integer types
  23.147 +integers = inttypes[arch].keys();
  23.148 +integers.sort(lambda a, b: cmp(len(b),len(a)));
  23.149 +for type in integers:
  23.150 +    output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
  23.151 +
  23.152 +# print results
  23.153 +f = open(outfile, "w");
  23.154 +f.write(output);
  23.155 +f.close;
  23.156 +
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/common/include/public/foreign/reference.size	Wed Dec 05 11:14:28 2007 -0800
    24.3 @@ -0,0 +1,17 @@
    24.4 +
    24.5 +structs              |  x86_32  x86_64    ia64
    24.6 +
    24.7 +start_info           |    1104    1152    1152
    24.8 +trap_info            |       8      16       -
    24.9 +pt_fpreg             |       -       -      16
   24.10 +cpu_user_regs        |      68     200     496
   24.11 +xen_ia64_boot_param  |       -       -      96
   24.12 +ia64_tr_entry        |       -       -      32
   24.13 +vcpu_extra_regs      |       -       -     536
   24.14 +vcpu_guest_context   |    2800    5168    1056
   24.15 +arch_vcpu_info       |      24      16       0
   24.16 +vcpu_time_info       |      32      32      32
   24.17 +vcpu_info            |      64      64      48
   24.18 +arch_shared_info     |     268     280     272
   24.19 +shared_info          |    2584    3368    4384
   24.20 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/common/include/public/foreign/structs.py	Wed Dec 05 11:14:28 2007 -0800
    25.3 @@ -0,0 +1,54 @@
    25.4 +# configuration: what needs translation
    25.5 +
    25.6 +structs = [ "start_info",
    25.7 +            "trap_info",
    25.8 +            "pt_fpreg",
    25.9 +            "cpu_user_regs",
   25.10 +            "xen_ia64_boot_param",
   25.11 +            "ia64_tr_entry",
   25.12 +            "vcpu_extra_regs",
   25.13 +            "vcpu_guest_context",
   25.14 +            "arch_vcpu_info",
   25.15 +            "vcpu_time_info",
   25.16 +            "vcpu_info",
   25.17 +            "arch_shared_info",
   25.18 +            "shared_info" ];
   25.19 +
   25.20 +defines = [ "__i386__",
   25.21 +            "__x86_64__",
   25.22 +
   25.23 +            "FLAT_RING1_CS",
   25.24 +            "FLAT_RING1_DS",
   25.25 +            "FLAT_RING1_SS",
   25.26 +
   25.27 +            "FLAT_RING3_CS64",
   25.28 +            "FLAT_RING3_DS64",
   25.29 +            "FLAT_RING3_SS64",
   25.30 +            "FLAT_KERNEL_CS64",
   25.31 +            "FLAT_KERNEL_DS64",
   25.32 +            "FLAT_KERNEL_SS64",
   25.33 +
   25.34 +            "FLAT_KERNEL_CS",
   25.35 +            "FLAT_KERNEL_DS",
   25.36 +            "FLAT_KERNEL_SS",
   25.37 +
   25.38 +            # x86_{32,64}
   25.39 +            "_VGCF_i387_valid",
   25.40 +            "VGCF_i387_valid",
   25.41 +            "_VGCF_in_kernel",
   25.42 +            "VGCF_in_kernel",
   25.43 +            "_VGCF_failsafe_disables_events",
   25.44 +            "VGCF_failsafe_disables_events",
   25.45 +            "_VGCF_syscall_disables_events",
   25.46 +            "VGCF_syscall_disables_events",
   25.47 +            "_VGCF_online",
   25.48 +            "VGCF_online",
   25.49 +
   25.50 +            # ia64
   25.51 +            "VGCF_EXTRA_REGS",
   25.52 +
   25.53 +            # all archs
   25.54 +            "xen_pfn_to_cr3",
   25.55 +            "MAX_VIRT_CPUS",
   25.56 +            "MAX_GUEST_CMDLINE" ];
   25.57 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/common/include/public/grant_table.h	Wed Dec 05 11:14:28 2007 -0800
    26.3 @@ -0,0 +1,399 @@
    26.4 +/******************************************************************************
    26.5 + * grant_table.h
    26.6 + * 
    26.7 + * Interface for granting foreign access to page frames, and receiving
    26.8 + * page-ownership transfers.
    26.9 + * 
   26.10 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   26.11 + * of this software and associated documentation files (the "Software"), to
   26.12 + * deal in the Software without restriction, including without limitation the
   26.13 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   26.14 + * sell copies of the Software, and to permit persons to whom the Software is
   26.15 + * furnished to do so, subject to the following conditions:
   26.16 + *
   26.17 + * The above copyright notice and this permission notice shall be included in
   26.18 + * all copies or substantial portions of the Software.
   26.19 + *
   26.20 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   26.21 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   26.22 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   26.23 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   26.24 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   26.25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   26.26 + * DEALINGS IN THE SOFTWARE.
   26.27 + *
   26.28 + * Copyright (c) 2004, K A Fraser
   26.29 + */
   26.30 +
   26.31 +#ifndef __XEN_PUBLIC_GRANT_TABLE_H__
   26.32 +#define __XEN_PUBLIC_GRANT_TABLE_H__
   26.33 +
   26.34 +
   26.35 +/***********************************
   26.36 + * GRANT TABLE REPRESENTATION
   26.37 + */
   26.38 +
   26.39 +/* Some rough guidelines on accessing and updating grant-table entries
   26.40 + * in a concurrency-safe manner. For more information, Linux contains a
   26.41 + * reference implementation for guest OSes (arch/xen/kernel/grant_table.c).
   26.42 + * 
   26.43 + * NB. WMB is a no-op on current-generation x86 processors. However, a
   26.44 + *     compiler barrier will still be required.
   26.45 + * 
   26.46 + * Introducing a valid entry into the grant table:
   26.47 + *  1. Write ent->domid.
   26.48 + *  2. Write ent->frame:
   26.49 + *      GTF_permit_access:   Frame to which access is permitted.
   26.50 + *      GTF_accept_transfer: Pseudo-phys frame slot being filled by new
   26.51 + *                           frame, or zero if none.
   26.52 + *  3. Write memory barrier (WMB).
   26.53 + *  4. Write ent->flags, inc. valid type.
   26.54 + * 
   26.55 + * Invalidating an unused GTF_permit_access entry:
   26.56 + *  1. flags = ent->flags.
   26.57 + *  2. Observe that !(flags & (GTF_reading|GTF_writing)).
   26.58 + *  3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
   26.59 + *  NB. No need for WMB as reuse of entry is control-dependent on success of
   26.60 + *      step 3, and all architectures guarantee ordering of ctrl-dep writes.
   26.61 + *
   26.62 + * Invalidating an in-use GTF_permit_access entry:
   26.63 + *  This cannot be done directly. Request assistance from the domain controller
   26.64 + *  which can set a timeout on the use of a grant entry and take necessary
   26.65 + *  action. (NB. This is not yet implemented!).
   26.66 + * 
   26.67 + * Invalidating an unused GTF_accept_transfer entry:
   26.68 + *  1. flags = ent->flags.
   26.69 + *  2. Observe that !(flags & GTF_transfer_committed). [*]
   26.70 + *  3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
   26.71 + *  NB. No need for WMB as reuse of entry is control-dependent on success of
   26.72 + *      step 3, and all architectures guarantee ordering of ctrl-dep writes.
   26.73 + *  [*] If GTF_transfer_committed is set then the grant entry is 'committed'.
   26.74 + *      The guest must /not/ modify the grant entry until the address of the
   26.75 + *      transferred frame is written. It is safe for the guest to spin waiting
   26.76 + *      for this to occur (detect by observing GTF_transfer_completed in
   26.77 + *      ent->flags).
   26.78 + *
   26.79 + * Invalidating a committed GTF_accept_transfer entry:
   26.80 + *  1. Wait for (ent->flags & GTF_transfer_completed).
   26.81 + *
   26.82 + * Changing a GTF_permit_access from writable to read-only:
   26.83 + *  Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing.
   26.84 + * 
   26.85 + * Changing a GTF_permit_access from read-only to writable:
   26.86 + *  Use SMP-safe bit-setting instruction.
   26.87 + */
   26.88 +
   26.89 +/*
   26.90 + * A grant table comprises a packed array of grant entries in one or more
   26.91 + * page frames shared between Xen and a guest.
   26.92 + * [XEN]: This field is written by Xen and read by the sharing guest.
   26.93 + * [GST]: This field is written by the guest and read by Xen.
   26.94 + */
   26.95 +struct grant_entry {
   26.96 +    /* GTF_xxx: various type and flag information.  [XEN,GST] */
   26.97 +    uint16_t flags;
   26.98 +    /* The domain being granted foreign privileges. [GST] */
   26.99 +    domid_t  domid;
  26.100 +    /*
  26.101 +     * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
  26.102 +     * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
  26.103 +     */
  26.104 +    uint32_t frame;
  26.105 +};
  26.106 +typedef struct grant_entry grant_entry_t;
  26.107 +
  26.108 +/*
  26.109 + * Type of grant entry.
  26.110 + *  GTF_invalid: This grant entry grants no privileges.
  26.111 + *  GTF_permit_access: Allow @domid to map/access @frame.
  26.112 + *  GTF_accept_transfer: Allow @domid to transfer ownership of one page frame
  26.113 + *                       to this guest. Xen writes the page number to @frame.
  26.114 + */
  26.115 +#define GTF_invalid         (0U<<0)
  26.116 +#define GTF_permit_access   (1U<<0)
  26.117 +#define GTF_accept_transfer (2U<<0)
  26.118 +#define GTF_type_mask       (3U<<0)
  26.119 +
  26.120 +/*
  26.121 + * Subflags for GTF_permit_access.
  26.122 + *  GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
  26.123 + *  GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
  26.124 + *  GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
  26.125 + */
  26.126 +#define _GTF_readonly       (2)
  26.127 +#define GTF_readonly        (1U<<_GTF_readonly)
  26.128 +#define _GTF_reading        (3)
  26.129 +#define GTF_reading         (1U<<_GTF_reading)
  26.130 +#define _GTF_writing        (4)
  26.131 +#define GTF_writing         (1U<<_GTF_writing)
  26.132 +
  26.133 +/*
  26.134 + * Subflags for GTF_accept_transfer:
  26.135 + *  GTF_transfer_committed: Xen sets this flag to indicate that it is committed
  26.136 + *      to transferring ownership of a page frame. When a guest sees this flag
  26.137 + *      it must /not/ modify the grant entry until GTF_transfer_completed is
  26.138 + *      set by Xen.
  26.139 + *  GTF_transfer_completed: It is safe for the guest to spin-wait on this flag
  26.140 + *      after reading GTF_transfer_committed. Xen will always write the frame
  26.141 + *      address, followed by ORing this flag, in a timely manner.
  26.142 + */
  26.143 +#define _GTF_transfer_committed (2)
  26.144 +#define GTF_transfer_committed  (1U<<_GTF_transfer_committed)
  26.145 +#define _GTF_transfer_completed (3)
  26.146 +#define GTF_transfer_completed  (1U<<_GTF_transfer_completed)
  26.147 +
  26.148 +
  26.149 +/***********************************
  26.150 + * GRANT TABLE QUERIES AND USES
  26.151 + */
  26.152 +
  26.153 +/*
  26.154 + * Reference to a grant entry in a specified domain's grant table.
  26.155 + */
  26.156 +typedef uint32_t grant_ref_t;
  26.157 +
  26.158 +/*
  26.159 + * Handle to track a mapping created via a grant reference.
  26.160 + */
  26.161 +typedef uint32_t grant_handle_t;
  26.162 +
  26.163 +/*
  26.164 + * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
  26.165 + * by devices and/or host CPUs. If successful, <handle> is a tracking number
  26.166 + * that must be presented later to destroy the mapping(s). On error, <handle>
  26.167 + * is a negative status code.
  26.168 + * NOTES:
  26.169 + *  1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address
  26.170 + *     via which I/O devices may access the granted frame.
  26.171 + *  2. If GNTMAP_host_map is specified then a mapping will be added at
  26.172 + *     either a host virtual address in the current address space, or at
  26.173 + *     a PTE at the specified machine address.  The type of mapping to
  26.174 + *     perform is selected through the GNTMAP_contains_pte flag, and the 
  26.175 + *     address is specified in <host_addr>.
  26.176 + *  3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a
  26.177 + *     host mapping is destroyed by other means then it is *NOT* guaranteed
  26.178 + *     to be accounted to the correct grant reference!
  26.179 + */
  26.180 +#define GNTTABOP_map_grant_ref        0
  26.181 +struct gnttab_map_grant_ref {
  26.182 +    /* IN parameters. */
  26.183 +    uint64_t host_addr;
  26.184 +    uint32_t flags;               /* GNTMAP_* */
  26.185 +    grant_ref_t ref;
  26.186 +    domid_t  dom;
  26.187 +    /* OUT parameters. */
  26.188 +    int16_t  status;              /* GNTST_* */
  26.189 +    grant_handle_t handle;
  26.190 +    uint64_t dev_bus_addr;
  26.191 +};
  26.192 +typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t;
  26.193 +DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
  26.194 +
  26.195 +/*
  26.196 + * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
  26.197 + * tracked by <handle>. If <host_addr> or <dev_bus_addr> is zero, that
  26.198 + * field is ignored. If non-zero, they must refer to a device/host mapping
  26.199 + * that is tracked by <handle>
  26.200 + * NOTES:
  26.201 + *  1. The call may fail in an undefined manner if either mapping is not
  26.202 + *     tracked by <handle>.
  26.203 + *  3. After executing a batch of unmaps, it is guaranteed that no stale
  26.204 + *     mappings will remain in the device or host TLBs.
  26.205 + */
  26.206 +#define GNTTABOP_unmap_grant_ref      1
  26.207 +struct gnttab_unmap_grant_ref {
  26.208 +    /* IN parameters. */
  26.209 +    uint64_t host_addr;
  26.210 +    uint64_t dev_bus_addr;
  26.211 +    grant_handle_t handle;
  26.212 +    /* OUT parameters. */
  26.213 +    int16_t  status;              /* GNTST_* */
  26.214 +};
  26.215 +typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
  26.216 +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
  26.217 +
  26.218 +/*
  26.219 + * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
  26.220 + * <nr_frames> pages. The frame addresses are written to the <frame_list>.
  26.221 + * Only <nr_frames> addresses are written, even if the table is larger.
  26.222 + * NOTES:
  26.223 + *  1. <dom> may be specified as DOMID_SELF.
  26.224 + *  2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
  26.225 + *  3. Xen may not support more than a single grant-table page per domain.
  26.226 + */
  26.227 +#define GNTTABOP_setup_table          2
  26.228 +struct gnttab_setup_table {
  26.229 +    /* IN parameters. */
  26.230 +    domid_t  dom;
  26.231 +    uint32_t nr_frames;
  26.232 +    /* OUT parameters. */
  26.233 +    int16_t  status;              /* GNTST_* */
  26.234 +    XEN_GUEST_HANDLE(ulong) frame_list;
  26.235 +};
  26.236 +typedef struct gnttab_setup_table gnttab_setup_table_t;
  26.237 +DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
  26.238 +
  26.239 +/*
  26.240 + * GNTTABOP_dump_table: Dump the contents of the grant table to the
  26.241 + * xen console. Debugging use only.
  26.242 + */
  26.243 +#define GNTTABOP_dump_table           3
  26.244 +struct gnttab_dump_table {
  26.245 +    /* IN parameters. */
  26.246 +    domid_t dom;
  26.247 +    /* OUT parameters. */
  26.248 +    int16_t status;               /* GNTST_* */
  26.249 +};
  26.250 +typedef struct gnttab_dump_table gnttab_dump_table_t;
  26.251 +DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
  26.252 +
  26.253 +/*
  26.254 + * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
  26.255 + * foreign domain has previously registered its interest in the transfer via
  26.256 + * <domid, ref>.
  26.257 + * 
  26.258 + * Note that, even if the transfer fails, the specified page no longer belongs
  26.259 + * to the calling domain *unless* the error is GNTST_bad_page.
  26.260 + */
  26.261 +#define GNTTABOP_transfer                4
  26.262 +struct gnttab_transfer {
  26.263 +    /* IN parameters. */
  26.264 +    xen_pfn_t     mfn;
  26.265 +    domid_t       domid;
  26.266 +    grant_ref_t   ref;
  26.267 +    /* OUT parameters. */
  26.268 +    int16_t       status;
  26.269 +};
  26.270 +typedef struct gnttab_transfer gnttab_transfer_t;
  26.271 +DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
  26.272 +
  26.273 +
  26.274 +/*
  26.275 + * GNTTABOP_copy: Hypervisor based copy
  26.276 + * source and destinations can be eithers MFNs or, for foreign domains,
  26.277 + * grant references. the foreign domain has to grant read/write access
  26.278 + * in its grant table.
  26.279 + *
  26.280 + * The flags specify what type source and destinations are (either MFN
  26.281 + * or grant reference).
  26.282 + *
  26.283 + * Note that this can also be used to copy data between two domains
  26.284 + * via a third party if the source and destination domains had previously
  26.285 + * grant appropriate access to their pages to the third party.
  26.286 + *
  26.287 + * source_offset specifies an offset in the source frame, dest_offset
  26.288 + * the offset in the target frame and  len specifies the number of
  26.289 + * bytes to be copied.
  26.290 + */
  26.291 +
  26.292 +#define _GNTCOPY_source_gref      (0)
  26.293 +#define GNTCOPY_source_gref       (1<<_GNTCOPY_source_gref)
  26.294 +#define _GNTCOPY_dest_gref        (1)
  26.295 +#define GNTCOPY_dest_gref         (1<<_GNTCOPY_dest_gref)
  26.296 +
  26.297 +#define GNTTABOP_copy                 5
  26.298 +typedef struct gnttab_copy {
  26.299 +    /* IN parameters. */
  26.300 +    struct {
  26.301 +        union {
  26.302 +            grant_ref_t ref;
  26.303 +            xen_pfn_t   gmfn;
  26.304 +        } u;
  26.305 +        domid_t  domid;
  26.306 +        uint16_t offset;
  26.307 +    } source, dest;
  26.308 +    uint16_t      len;
  26.309 +    uint16_t      flags;          /* GNTCOPY_* */
  26.310 +    /* OUT parameters. */
  26.311 +    int16_t       status;
  26.312 +} gnttab_copy_t;
  26.313 +DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t);
  26.314 +
  26.315 +/*
  26.316 + * GNTTABOP_query_size: Query the current and maximum sizes of the shared
  26.317 + * grant table.
  26.318 + * NOTES:
  26.319 + *  1. <dom> may be specified as DOMID_SELF.
  26.320 + *  2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
  26.321 + */
  26.322 +#define GNTTABOP_query_size           6
  26.323 +struct gnttab_query_size {
  26.324 +    /* IN parameters. */
  26.325 +    domid_t  dom;
  26.326 +    /* OUT parameters. */
  26.327 +    uint32_t nr_frames;
  26.328 +    uint32_t max_nr_frames;
  26.329 +    int16_t  status;              /* GNTST_* */
  26.330 +};
  26.331 +typedef struct gnttab_query_size gnttab_query_size_t;
  26.332 +DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t);
  26.333 +
  26.334 +
  26.335 +/*
  26.336 + * Bitfield values for update_pin_status.flags.
  26.337 + */
  26.338 + /* Map the grant entry for access by I/O devices. */
  26.339 +#define _GNTMAP_device_map      (0)
  26.340 +#define GNTMAP_device_map       (1<<_GNTMAP_device_map)
  26.341 + /* Map the grant entry for access by host CPUs. */
  26.342 +#define _GNTMAP_host_map        (1)
  26.343 +#define GNTMAP_host_map         (1<<_GNTMAP_host_map)
  26.344 + /* Accesses to the granted frame will be restricted to read-only access. */
  26.345 +#define _GNTMAP_readonly        (2)
  26.346 +#define GNTMAP_readonly         (1<<_GNTMAP_readonly)
  26.347 + /*
  26.348 +  * GNTMAP_host_map subflag:
  26.349 +  *  0 => The host mapping is usable only by the guest OS.
  26.350 +  *  1 => The host mapping is usable by guest OS + current application.
  26.351 +  */
  26.352 +#define _GNTMAP_application_map (3)
  26.353 +#define GNTMAP_application_map  (1<<_GNTMAP_application_map)
  26.354 +
  26.355 + /*
  26.356 +  * GNTMAP_contains_pte subflag:
  26.357 +  *  0 => This map request contains a host virtual address.
  26.358 +  *  1 => This map request contains the machine addess of the PTE to update.
  26.359 +  */
  26.360 +#define _GNTMAP_contains_pte    (4)
  26.361 +#define GNTMAP_contains_pte     (1<<_GNTMAP_contains_pte)
  26.362 +
  26.363 +/*
  26.364 + * Values for error status returns. All errors are -ve.
  26.365 + */
  26.366 +#define GNTST_okay             (0)  /* Normal return.                        */
  26.367 +#define GNTST_general_error    (-1) /* General undefined error.              */
  26.368 +#define GNTST_bad_domain       (-2) /* Unrecognsed domain id.                */
  26.369 +#define GNTST_bad_gntref       (-3) /* Unrecognised or inappropriate gntref. */
  26.370 +#define GNTST_bad_handle       (-4) /* Unrecognised or inappropriate handle. */
  26.371 +#define GNTST_bad_virt_addr    (-5) /* Inappropriate virtual address to map. */
  26.372 +#define GNTST_bad_dev_addr     (-6) /* Inappropriate device address to unmap.*/
  26.373 +#define GNTST_no_device_space  (-7) /* Out of space in I/O MMU.              */
  26.374 +#define GNTST_permission_denied (-8) /* Not enough privilege for operation.  */
  26.375 +#define GNTST_bad_page         (-9) /* Specified page was invalid for op.    */
  26.376 +#define GNTST_bad_copy_arg    (-10) /* copy arguments cross page boundary */
  26.377 +
  26.378 +#define GNTTABOP_error_msgs {                   \
  26.379 +    "okay",                                     \
  26.380 +    "undefined error",                          \
  26.381 +    "unrecognised domain id",                   \
  26.382 +    "invalid grant reference",                  \
  26.383 +    "invalid mapping handle",                   \
  26.384 +    "invalid virtual address",                  \
  26.385 +    "invalid device address",                   \
  26.386 +    "no spare translation slot in the I/O MMU", \
  26.387 +    "permission denied",                        \
  26.388 +    "bad page",                                 \
  26.389 +    "copy arguments cross page boundary"        \
  26.390 +}
  26.391 +
  26.392 +#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */
  26.393 +
  26.394 +/*
  26.395 + * Local variables:
  26.396 + * mode: C
  26.397 + * c-set-style: "BSD"
  26.398 + * c-basic-offset: 4
  26.399 + * tab-width: 4
  26.400 + * indent-tabs-mode: nil
  26.401 + * End:
  26.402 + */
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/common/include/public/hvm/e820.h	Wed Dec 05 11:14:28 2007 -0800
    27.3 @@ -0,0 +1,34 @@
    27.4 +
    27.5 +/*
    27.6 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    27.7 + * of this software and associated documentation files (the "Software"), to
    27.8 + * deal in the Software without restriction, including without limitation the
    27.9 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   27.10 + * sell copies of the Software, and to permit persons to whom the Software is
   27.11 + * furnished to do so, subject to the following conditions:
   27.12 + *
   27.13 + * The above copyright notice and this permission notice shall be included in
   27.14 + * all copies or substantial portions of the Software.
   27.15 + *
   27.16 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   27.17 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   27.18 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   27.19 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   27.20 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   27.21 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   27.22 + * DEALINGS IN THE SOFTWARE.
   27.23 + */
   27.24 +
   27.25 +#ifndef __XEN_PUBLIC_HVM_E820_H__
   27.26 +#define __XEN_PUBLIC_HVM_E820_H__
   27.27 +
   27.28 +/* E820 location in HVM virtual address space. */
   27.29 +#define HVM_E820_PAGE        0x00090000
   27.30 +#define HVM_E820_NR_OFFSET   0x000001E8
   27.31 +#define HVM_E820_OFFSET      0x000002D0
   27.32 +
   27.33 +#define HVM_BELOW_4G_RAM_END        0xF0000000
   27.34 +#define HVM_BELOW_4G_MMIO_START     HVM_BELOW_4G_RAM_END
   27.35 +#define HVM_BELOW_4G_MMIO_LENGTH    ((1ULL << 32) - HVM_BELOW_4G_MMIO_START)
   27.36 +
   27.37 +#endif /* __XEN_PUBLIC_HVM_E820_H__ */
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/common/include/public/hvm/hvm_info_table.h	Wed Dec 05 11:14:28 2007 -0800
    28.3 @@ -0,0 +1,41 @@
    28.4 +/******************************************************************************
    28.5 + * hvm/hvm_info_table.h
    28.6 + * 
    28.7 + * HVM parameter and information table, written into guest memory map.
    28.8 + *
    28.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   28.10 + * of this software and associated documentation files (the "Software"), to
   28.11 + * deal in the Software without restriction, including without limitation the
   28.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   28.13 + * sell copies of the Software, and to permit persons to whom the Software is
   28.14 + * furnished to do so, subject to the following conditions:
   28.15 + *
   28.16 + * The above copyright notice and this permission notice shall be included in
   28.17 + * all copies or substantial portions of the Software.
   28.18 + *
   28.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   28.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   28.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   28.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   28.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   28.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   28.25 + * DEALINGS IN THE SOFTWARE.
   28.26 + */
   28.27 +
   28.28 +#ifndef __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__
   28.29 +#define __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__
   28.30 +
   28.31 +#define HVM_INFO_PFN         0x09F
   28.32 +#define HVM_INFO_OFFSET      0x800
   28.33 +#define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
   28.34 +
   28.35 +struct hvm_info_table {
   28.36 +    char        signature[8]; /* "HVM INFO" */
   28.37 +    uint32_t    length;
   28.38 +    uint8_t     checksum;
   28.39 +    uint8_t     acpi_enabled;
   28.40 +    uint8_t     apic_mode;
   28.41 +    uint32_t    nr_vcpus;
   28.42 +};
   28.43 +
   28.44 +#endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/common/include/public/hvm/hvm_op.h	Wed Dec 05 11:14:28 2007 -0800
    29.3 @@ -0,0 +1,76 @@
    29.4 +/*
    29.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    29.6 + * of this software and associated documentation files (the "Software"), to
    29.7 + * deal in the Software without restriction, including without limitation the
    29.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    29.9 + * sell copies of the Software, and to permit persons to whom the Software is
   29.10 + * furnished to do so, subject to the following conditions:
   29.11 + *
   29.12 + * The above copyright notice and this permission notice shall be included in
   29.13 + * all copies or substantial portions of the Software.
   29.14 + *
   29.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   29.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   29.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   29.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   29.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   29.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   29.21 + * DEALINGS IN THE SOFTWARE.
   29.22 + */
   29.23 +
   29.24 +#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
   29.25 +#define __XEN_PUBLIC_HVM_HVM_OP_H__
   29.26 +
   29.27 +/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
   29.28 +#define HVMOP_set_param           0
   29.29 +#define HVMOP_get_param           1
   29.30 +struct xen_hvm_param {
   29.31 +    domid_t  domid;    /* IN */
   29.32 +    uint32_t index;    /* IN */
   29.33 +    uint64_t value;    /* IN/OUT */
   29.34 +};
   29.35 +typedef struct xen_hvm_param xen_hvm_param_t;
   29.36 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
   29.37 +
   29.38 +/* Set the logical level of one of a domain's PCI INTx wires. */
   29.39 +#define HVMOP_set_pci_intx_level  2
   29.40 +struct xen_hvm_set_pci_intx_level {
   29.41 +    /* Domain to be updated. */
   29.42 +    domid_t  domid;
   29.43 +    /* PCI INTx identification in PCI topology (domain:bus:device:intx). */
   29.44 +    uint8_t  domain, bus, device, intx;
   29.45 +    /* Assertion level (0 = unasserted, 1 = asserted). */
   29.46 +    uint8_t  level;
   29.47 +};
   29.48 +typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;
   29.49 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);
   29.50 +
   29.51 +/* Set the logical level of one of a domain's ISA IRQ wires. */
   29.52 +#define HVMOP_set_isa_irq_level   3
   29.53 +struct xen_hvm_set_isa_irq_level {
   29.54 +    /* Domain to be updated. */
   29.55 +    domid_t  domid;
   29.56 +    /* ISA device identification, by ISA IRQ (0-15). */
   29.57 +    uint8_t  isa_irq;
   29.58 +    /* Assertion level (0 = unasserted, 1 = asserted). */
   29.59 +    uint8_t  level;
   29.60 +};
   29.61 +typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;
   29.62 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);
   29.63 +
   29.64 +#define HVMOP_set_pci_link_route  4
   29.65 +struct xen_hvm_set_pci_link_route {
   29.66 +    /* Domain to be updated. */
   29.67 +    domid_t  domid;
   29.68 +    /* PCI link identifier (0-3). */
   29.69 +    uint8_t  link;
   29.70 +    /* ISA IRQ (1-15), or 0 (disable link). */
   29.71 +    uint8_t  isa_irq;
   29.72 +};
   29.73 +typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;
   29.74 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
   29.75 +
   29.76 +/* Flushes all VCPU TLBs: @arg must be NULL. */
   29.77 +#define HVMOP_flush_tlbs          5
   29.78 +
   29.79 +#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/common/include/public/hvm/ioreq.h	Wed Dec 05 11:14:28 2007 -0800
    30.3 @@ -0,0 +1,122 @@
    30.4 +/*
    30.5 + * ioreq.h: I/O request definitions for device models
    30.6 + * Copyright (c) 2004, Intel Corporation.
    30.7 + * 
    30.8 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    30.9 + * of this software and associated documentation files (the "Software"), to
   30.10 + * deal in the Software without restriction, including without limitation the
   30.11 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   30.12 + * sell copies of the Software, and to permit persons to whom the Software is
   30.13 + * furnished to do so, subject to the following conditions:
   30.14 + *
   30.15 + * The above copyright notice and this permission notice shall be included in
   30.16 + * all copies or substantial portions of the Software.
   30.17 + *
   30.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   30.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   30.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   30.21 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   30.22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   30.23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   30.24 + * DEALINGS IN THE SOFTWARE.
   30.25 + */
   30.26 +
   30.27 +#ifndef _IOREQ_H_
   30.28 +#define _IOREQ_H_
   30.29 +
   30.30 +#define IOREQ_READ      1
   30.31 +#define IOREQ_WRITE     0
   30.32 +
   30.33 +#define STATE_IOREQ_NONE        0
   30.34 +#define STATE_IOREQ_READY       1
   30.35 +#define STATE_IOREQ_INPROCESS   2
   30.36 +#define STATE_IORESP_READY      3
   30.37 +
   30.38 +#define IOREQ_TYPE_PIO          0 /* pio */
   30.39 +#define IOREQ_TYPE_COPY         1 /* mmio ops */
   30.40 +#define IOREQ_TYPE_AND          2
   30.41 +#define IOREQ_TYPE_OR           3
   30.42 +#define IOREQ_TYPE_XOR          4
   30.43 +#define IOREQ_TYPE_XCHG         5
   30.44 +#define IOREQ_TYPE_ADD          6
   30.45 +#define IOREQ_TYPE_TIMEOFFSET   7
   30.46 +#define IOREQ_TYPE_INVALIDATE   8 /* mapcache */
   30.47 +#define IOREQ_TYPE_SUB          9
   30.48 +
   30.49 +/*
   30.50 + * VMExit dispatcher should cooperate with instruction decoder to
   30.51 + * prepare this structure and notify service OS and DM by sending
   30.52 + * virq
   30.53 + */
   30.54 +struct ioreq {
   30.55 +    uint64_t addr;          /*  physical address            */
   30.56 +    uint64_t size;          /*  size in bytes               */
   30.57 +    uint64_t count;         /*  for rep prefixes            */
   30.58 +    uint64_t data;          /*  data (or paddr of data)     */
   30.59 +    uint8_t state:4;
   30.60 +    uint8_t data_is_ptr:1;  /*  if 1, data above is the guest paddr 
   30.61 +                             *   of the real data to use.   */
   30.62 +    uint8_t dir:1;          /*  1=read, 0=write             */
   30.63 +    uint8_t df:1;
   30.64 +    uint8_t type;           /* I/O type                     */
   30.65 +    uint8_t _pad0[6];
   30.66 +    uint64_t io_count;      /* How many IO done on a vcpu   */
   30.67 +};
   30.68 +typedef struct ioreq ioreq_t;
   30.69 +
   30.70 +struct vcpu_iodata {
   30.71 +    struct ioreq vp_ioreq;
   30.72 +    /* Event channel port, used for notifications to/from the device model. */
   30.73 +    uint32_t vp_eport;
   30.74 +    uint32_t _pad0;
   30.75 +};
   30.76 +typedef struct vcpu_iodata vcpu_iodata_t;
   30.77 +
   30.78 +struct shared_iopage {
   30.79 +    struct vcpu_iodata   vcpu_iodata[1];
   30.80 +};
   30.81 +typedef struct shared_iopage shared_iopage_t;
   30.82 +
   30.83 +#define IOREQ_BUFFER_SLOT_NUM     80
   30.84 +struct buffered_iopage {
   30.85 +    unsigned int    read_pointer;
   30.86 +    unsigned int    write_pointer;
   30.87 +    ioreq_t         ioreq[IOREQ_BUFFER_SLOT_NUM];
   30.88 +}; /* NB. Size of this structure must be no greater than one page. */
   30.89 +typedef struct buffered_iopage buffered_iopage_t;
   30.90 +
   30.91 +#if defined(__ia64__)
   30.92 +struct pio_buffer {
   30.93 +    uint32_t page_offset;
   30.94 +    uint32_t pointer;
   30.95 +    uint32_t data_end;
   30.96 +    uint32_t buf_size;
   30.97 +    void *opaque;
   30.98 +};
   30.99 +
  30.100 +#define PIO_BUFFER_IDE_PRIMARY   0 /* I/O port = 0x1F0 */
  30.101 +#define PIO_BUFFER_IDE_SECONDARY 1 /* I/O port = 0x170 */
  30.102 +#define PIO_BUFFER_ENTRY_NUM     2
  30.103 +struct buffered_piopage {
  30.104 +    struct pio_buffer pio[PIO_BUFFER_ENTRY_NUM];
  30.105 +    uint8_t buffer[1];
  30.106 +};
  30.107 +#endif /* defined(__ia64__) */
  30.108 +
  30.109 +#if defined(__i386__) || defined(__x86_64__)
  30.110 +#define ACPI_PM1A_EVT_BLK_ADDRESS           0x0000000000001f40
  30.111 +#define ACPI_PM1A_CNT_BLK_ADDRESS           (ACPI_PM1A_EVT_BLK_ADDRESS + 0x04)
  30.112 +#define ACPI_PM_TMR_BLK_ADDRESS             (ACPI_PM1A_EVT_BLK_ADDRESS + 0x08)
  30.113 +#endif /* defined(__i386__) || defined(__x86_64__) */
  30.114 +
  30.115 +#endif /* _IOREQ_H_ */
  30.116 +
  30.117 +/*
  30.118 + * Local variables:
  30.119 + * mode: C
  30.120 + * c-set-style: "BSD"
  30.121 + * c-basic-offset: 4
  30.122 + * tab-width: 4
  30.123 + * indent-tabs-mode: nil
  30.124 + * End:
  30.125 + */
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/common/include/public/hvm/params.h	Wed Dec 05 11:14:28 2007 -0800
    31.3 @@ -0,0 +1,60 @@
    31.4 +/*
    31.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    31.6 + * of this software and associated documentation files (the "Software"), to
    31.7 + * deal in the Software without restriction, including without limitation the
    31.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    31.9 + * sell copies of the Software, and to permit persons to whom the Software is
   31.10 + * furnished to do so, subject to the following conditions:
   31.11 + *
   31.12 + * The above copyright notice and this permission notice shall be included in
   31.13 + * all copies or substantial portions of the Software.
   31.14 + *
   31.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   31.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   31.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   31.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   31.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   31.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   31.21 + * DEALINGS IN THE SOFTWARE.
   31.22 + */
   31.23 +
   31.24 +#ifndef __XEN_PUBLIC_HVM_PARAMS_H__
   31.25 +#define __XEN_PUBLIC_HVM_PARAMS_H__
   31.26 +
   31.27 +#include "hvm_op.h"
   31.28 +
   31.29 +/*
   31.30 + * Parameter space for HVMOP_{set,get}_param.
   31.31 + */
   31.32 +
   31.33 +/*
   31.34 + * How should CPU0 event-channel notifications be delivered?
   31.35 + * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
   31.36 + * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
   31.37 + *                  Domain = val[47:32], Bus  = val[31:16],
   31.38 + *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
   31.39 + * If val == 0 then CPU0 event-channel notifications are not delivered.
   31.40 + */
   31.41 +#define HVM_PARAM_CALLBACK_IRQ 0
   31.42 +
   31.43 +/*
   31.44 + * These are not used by Xen. They are here for convenience of HVM-guest
   31.45 + * xenbus implementations.
   31.46 + */
   31.47 +#define HVM_PARAM_STORE_PFN    1
   31.48 +#define HVM_PARAM_STORE_EVTCHN 2
   31.49 +
   31.50 +#define HVM_PARAM_PAE_ENABLED  4
   31.51 +
   31.52 +#define HVM_PARAM_IOREQ_PFN    5
   31.53 +
   31.54 +#define HVM_PARAM_BUFIOREQ_PFN 6
   31.55 +
   31.56 +#ifdef __ia64__
   31.57 +#define HVM_PARAM_NVRAM_FD     7
   31.58 +#define HVM_NR_PARAMS          8
   31.59 +#else
   31.60 +#define HVM_NR_PARAMS          7
   31.61 +#endif
   31.62 +
   31.63 +#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/common/include/public/hvm/save.h	Wed Dec 05 11:14:28 2007 -0800
    32.3 @@ -0,0 +1,462 @@
    32.4 +/* 
    32.5 + * hvm/save.h
    32.6 + *
    32.7 + * Structure definitions for HVM state that is held by Xen and must
    32.8 + * be saved along with the domain's memory and device-model state.
    32.9 + *
   32.10 + * 
   32.11 + * Copyright (c) 2007 XenSource Ltd.
   32.12 + *
   32.13 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   32.14 + * of this software and associated documentation files (the "Software"), to
   32.15 + * deal in the Software without restriction, including without limitation the
   32.16 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   32.17 + * sell copies of the Software, and to permit persons to whom the Software is
   32.18 + * furnished to do so, subject to the following conditions:
   32.19 + *
   32.20 + * The above copyright notice and this permission notice shall be included in
   32.21 + * all copies or substantial portions of the Software.
   32.22 + *
   32.23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   32.24 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   32.25 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   32.26 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   32.27 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   32.28 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   32.29 + * DEALINGS IN THE SOFTWARE.
   32.30 + */
   32.31 +
   32.32 +#ifndef __XEN_PUBLIC_HVM_SAVE_H__
   32.33 +#define __XEN_PUBLIC_HVM_SAVE_H__
   32.34 +
   32.35 +/*
   32.36 + * Structures in this header *must* have the same layout in 32bit 
   32.37 + * and 64bit environments: this means that all fields must be explicitly 
   32.38 + * sized types and aligned to their sizes, and the structs must be 
   32.39 + * a multiple of eight bytes long.
   32.40 + *
   32.41 + * Only the state necessary for saving and restoring (i.e. fields 
   32.42 + * that are analogous to actual hardware state) should go in this file. 
   32.43 + * Internal mechanisms should be kept in Xen-private headers.
   32.44 + */
   32.45 +
   32.46 +/* 
   32.47 + * Each entry is preceded by a descriptor giving its type and length
   32.48 + */
   32.49 +struct hvm_save_descriptor {
   32.50 +    uint16_t typecode;          /* Used to demux the various types below */
   32.51 +    uint16_t instance;          /* Further demux within a type */
   32.52 +    uint32_t length;            /* In bytes, *not* including this descriptor */
   32.53 +};
   32.54 +
   32.55 +
   32.56 +/* 
   32.57 + * Each entry has a datatype associated with it: for example, the CPU state 
   32.58 + * is saved as a HVM_SAVE_TYPE(CPU), which has HVM_SAVE_LENGTH(CPU), 
   32.59 + * and is identified by a descriptor with typecode HVM_SAVE_CODE(CPU).
   32.60 + * DECLARE_HVM_SAVE_TYPE binds these things together with some type-system
   32.61 + * ugliness.
   32.62 + */
   32.63 +
   32.64 +#define DECLARE_HVM_SAVE_TYPE(_x, _code, _type)                   \
   32.65 +  struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; }
   32.66 +
   32.67 +#define HVM_SAVE_TYPE(_x) typeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->t)
   32.68 +#define HVM_SAVE_LENGTH(_x) (sizeof (HVM_SAVE_TYPE(_x)))
   32.69 +#define HVM_SAVE_CODE(_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c))
   32.70 +
   32.71 +
   32.72 +/* 
   32.73 + * Save/restore header: general info about the save file. 
   32.74 + */
   32.75 +
   32.76 +#define HVM_FILE_MAGIC   0x54381286
   32.77 +#define HVM_FILE_VERSION 0x00000001
   32.78 +
   32.79 +struct hvm_save_header {
   32.80 +    uint32_t magic;             /* Must be HVM_FILE_MAGIC */
   32.81 +    uint32_t version;           /* File format version */
   32.82 +    uint64_t changeset;         /* Version of Xen that saved this file */
   32.83 +    uint32_t cpuid;             /* CPUID[0x01][%eax] on the saving machine */
   32.84 +    uint32_t pad0;
   32.85 +};
   32.86 +
   32.87 +DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);
   32.88 +
   32.89 +
   32.90 +/*
   32.91 + * Processor
   32.92 + */
   32.93 +
   32.94 +struct hvm_hw_cpu {
   32.95 +    uint8_t  fpu_regs[512];
   32.96 +
   32.97 +    uint64_t rax;
   32.98 +    uint64_t rbx;
   32.99 +    uint64_t rcx;
  32.100 +    uint64_t rdx;
  32.101 +    uint64_t rbp;
  32.102 +    uint64_t rsi;
  32.103 +    uint64_t rdi;
  32.104 +    uint64_t rsp;
  32.105 +    uint64_t r8;
  32.106 +    uint64_t r9;
  32.107 +    uint64_t r10;
  32.108 +    uint64_t r11;
  32.109 +    uint64_t r12;
  32.110 +    uint64_t r13;
  32.111 +    uint64_t r14;
  32.112 +    uint64_t r15;
  32.113 +
  32.114 +    uint64_t rip;
  32.115 +    uint64_t rflags;
  32.116 +
  32.117 +    uint64_t cr0;
  32.118 +    uint64_t cr2;
  32.119 +    uint64_t cr3;
  32.120 +    uint64_t cr4;
  32.121 +
  32.122 +    uint64_t dr0;
  32.123 +    uint64_t dr1;
  32.124 +    uint64_t dr2;
  32.125 +    uint64_t dr3;
  32.126 +    uint64_t dr6;
  32.127 +    uint64_t dr7;    
  32.128 +
  32.129 +    uint32_t cs_sel;
  32.130 +    uint32_t ds_sel;
  32.131 +    uint32_t es_sel;
  32.132 +    uint32_t fs_sel;
  32.133 +    uint32_t gs_sel;
  32.134 +    uint32_t ss_sel;
  32.135 +    uint32_t tr_sel;
  32.136 +    uint32_t ldtr_sel;
  32.137 +
  32.138 +    uint32_t cs_limit;
  32.139 +    uint32_t ds_limit;
  32.140 +    uint32_t es_limit;
  32.141 +    uint32_t fs_limit;
  32.142 +    uint32_t gs_limit;
  32.143 +    uint32_t ss_limit;
  32.144 +    uint32_t tr_limit;
  32.145 +    uint32_t ldtr_limit;
  32.146 +    uint32_t idtr_limit;
  32.147 +    uint32_t gdtr_limit;
  32.148 +
  32.149 +    uint64_t cs_base;
  32.150 +    uint64_t ds_base;
  32.151 +    uint64_t es_base;
  32.152 +    uint64_t fs_base;
  32.153 +    uint64_t gs_base;
  32.154 +    uint64_t ss_base;
  32.155 +    uint64_t tr_base;
  32.156 +    uint64_t ldtr_base;
  32.157 +    uint64_t idtr_base;
  32.158 +    uint64_t gdtr_base;
  32.159 +
  32.160 +    uint32_t cs_arbytes;
  32.161 +    uint32_t ds_arbytes;
  32.162 +    uint32_t es_arbytes;
  32.163 +    uint32_t fs_arbytes;
  32.164 +    uint32_t gs_arbytes;
  32.165 +    uint32_t ss_arbytes;
  32.166 +    uint32_t tr_arbytes;
  32.167 +    uint32_t ldtr_arbytes;
  32.168 +
  32.169 +    uint32_t sysenter_cs;
  32.170 +    uint32_t padding0;
  32.171 +
  32.172 +    uint64_t sysenter_esp;
  32.173 +    uint64_t sysenter_eip;
  32.174 +
  32.175 +    /* msr for em64t */
  32.176 +    uint64_t shadow_gs;
  32.177 +
  32.178 +    /* msr content saved/restored. */
  32.179 +    uint64_t msr_flags;
  32.180 +    uint64_t msr_lstar;
  32.181 +    uint64_t msr_star;
  32.182 +    uint64_t msr_cstar;
  32.183 +    uint64_t msr_syscall_mask;
  32.184 +    uint64_t msr_efer;
  32.185 +
  32.186 +    /* guest's idea of what rdtsc() would return */
  32.187 +    uint64_t tsc;
  32.188 +
  32.189 +    /* pending event, if any */
  32.190 +    union {
  32.191 +        uint32_t pending_event;
  32.192 +        struct {
  32.193 +            uint8_t  pending_vector:8;
  32.194 +            uint8_t  pending_type:3;
  32.195 +            uint8_t  pending_error_valid:1;
  32.196 +            uint32_t pending_reserved:19;
  32.197 +            uint8_t  pending_valid:1;
  32.198 +        };
  32.199 +    };
  32.200 +    /* error code for pending event */
  32.201 +    uint32_t error_code;
  32.202 +};
  32.203 +
  32.204 +DECLARE_HVM_SAVE_TYPE(CPU, 2, struct hvm_hw_cpu);
  32.205 +
  32.206 +
  32.207 +/*
  32.208 + * PIC
  32.209 + */
  32.210 +
  32.211 +struct hvm_hw_vpic {
  32.212 +    /* IR line bitmasks. */
  32.213 +    uint8_t irr;
  32.214 +    uint8_t imr;
  32.215 +    uint8_t isr;
  32.216 +
  32.217 +    /* Line IRx maps to IRQ irq_base+x */
  32.218 +    uint8_t irq_base;
  32.219 +
  32.220 +    /*
  32.221 +     * Where are we in ICW2-4 initialisation (0 means no init in progress)?
  32.222 +     * Bits 0-1 (=x): Next write at A=1 sets ICW(x+1).
  32.223 +     * Bit 2: ICW1.IC4  (1 == ICW4 included in init sequence)
  32.224 +     * Bit 3: ICW1.SNGL (0 == ICW3 included in init sequence)
  32.225 +     */
  32.226 +    uint8_t init_state:4;
  32.227 +
  32.228 +    /* IR line with highest priority. */
  32.229 +    uint8_t priority_add:4;
  32.230 +
  32.231 +    /* Reads from A=0 obtain ISR or IRR? */
  32.232 +    uint8_t readsel_isr:1;
  32.233 +
  32.234 +    /* Reads perform a polling read? */
  32.235 +    uint8_t poll:1;
  32.236 +
  32.237 +    /* Automatically clear IRQs from the ISR during INTA? */
  32.238 +    uint8_t auto_eoi:1;
  32.239 +
  32.240 +    /* Automatically rotate IRQ priorities during AEOI? */
  32.241 +    uint8_t rotate_on_auto_eoi:1;
  32.242 +
  32.243 +    /* Exclude slave inputs when considering in-service IRQs? */
  32.244 +    uint8_t special_fully_nested_mode:1;
  32.245 +
  32.246 +    /* Special mask mode excludes masked IRs from AEOI and priority checks. */
  32.247 +    uint8_t special_mask_mode:1;
  32.248 +
  32.249 +    /* Is this a master PIC or slave PIC? (NB. This is not programmable.) */
  32.250 +    uint8_t is_master:1;
  32.251 +
  32.252 +    /* Edge/trigger selection. */
  32.253 +    uint8_t elcr;
  32.254 +
  32.255 +    /* Virtual INT output. */
  32.256 +    uint8_t int_output;
  32.257 +};
  32.258 +
  32.259 +DECLARE_HVM_SAVE_TYPE(PIC, 3, struct hvm_hw_vpic);
  32.260 +
  32.261 +
  32.262 +/*
  32.263 + * IO-APIC
  32.264 + */
  32.265 +
  32.266 +#ifdef __ia64__
  32.267 +#define VIOAPIC_IS_IOSAPIC 1
  32.268 +#define VIOAPIC_NUM_PINS  24
  32.269 +#else
  32.270 +#define VIOAPIC_NUM_PINS  48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */
  32.271 +#endif
  32.272 +
  32.273 +struct hvm_hw_vioapic {
  32.274 +    uint64_t base_address;
  32.275 +    uint32_t ioregsel;
  32.276 +    uint32_t id;
  32.277 +    union vioapic_redir_entry
  32.278 +    {
  32.279 +        uint64_t bits;
  32.280 +        struct {
  32.281 +            uint8_t vector;
  32.282 +            uint8_t delivery_mode:3;
  32.283 +            uint8_t dest_mode:1;
  32.284 +            uint8_t delivery_status:1;
  32.285 +            uint8_t polarity:1;
  32.286 +            uint8_t remote_irr:1;
  32.287 +            uint8_t trig_mode:1;
  32.288 +            uint8_t mask:1;
  32.289 +            uint8_t reserve:7;
  32.290 +#if !VIOAPIC_IS_IOSAPIC
  32.291 +            uint8_t reserved[4];
  32.292 +            uint8_t dest_id;
  32.293 +#else
  32.294 +            uint8_t reserved[3];
  32.295 +            uint16_t dest_id;
  32.296 +#endif
  32.297 +        } fields;
  32.298 +    } redirtbl[VIOAPIC_NUM_PINS];
  32.299 +};
  32.300 +
  32.301 +DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic);
  32.302 +
  32.303 +
  32.304 +/*
  32.305 + * LAPIC
  32.306 + */
  32.307 +
  32.308 +struct hvm_hw_lapic {
  32.309 +    uint64_t             apic_base_msr;
  32.310 +    uint32_t             disabled; /* VLAPIC_xx_DISABLED */
  32.311 +    uint32_t             timer_divisor;
  32.312 +};
  32.313 +
  32.314 +DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic);
  32.315 +
  32.316 +struct hvm_hw_lapic_regs {
  32.317 +    /* A 4k page of register state */
  32.318 +    uint8_t  data[0x400];
  32.319 +};
  32.320 +
  32.321 +DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs);
  32.322 +
  32.323 +
  32.324 +/*
  32.325 + * IRQs
  32.326 + */
  32.327 +
  32.328 +struct hvm_hw_pci_irqs {
  32.329 +    /*
  32.330 +     * Virtual interrupt wires for a single PCI bus.
  32.331 +     * Indexed by: device*4 + INTx#.
  32.332 +     */
  32.333 +    union {
  32.334 +        DECLARE_BITMAP(i, 32*4);
  32.335 +        uint64_t pad[2];
  32.336 +    };
  32.337 +};
  32.338 +
  32.339 +DECLARE_HVM_SAVE_TYPE(PCI_IRQ, 7, struct hvm_hw_pci_irqs);
  32.340 +
  32.341 +struct hvm_hw_isa_irqs {
  32.342 +    /*
  32.343 +     * Virtual interrupt wires for ISA devices.
  32.344 +     * Indexed by ISA IRQ (assumes no ISA-device IRQ sharing).
  32.345 +     */
  32.346 +    union {
  32.347 +        DECLARE_BITMAP(i, 16);
  32.348 +        uint64_t pad[1];
  32.349 +    };
  32.350 +};
  32.351 +
  32.352 +DECLARE_HVM_SAVE_TYPE(ISA_IRQ, 8, struct hvm_hw_isa_irqs);
  32.353 +
  32.354 +struct hvm_hw_pci_link {
  32.355 +    /*
  32.356 +     * PCI-ISA interrupt router.
  32.357 +     * Each PCI <device:INTx#> is 'wire-ORed' into one of four links using
  32.358 +     * the traditional 'barber's pole' mapping ((device + INTx#) & 3).
  32.359 +     * The router provides a programmable mapping from each link to a GSI.
  32.360 +     */
  32.361 +    uint8_t route[4];
  32.362 +    uint8_t pad0[4];
  32.363 +};
  32.364 +
  32.365 +DECLARE_HVM_SAVE_TYPE(PCI_LINK, 9, struct hvm_hw_pci_link);
  32.366 +
  32.367 +/* 
  32.368 + *  PIT
  32.369 + */
  32.370 +
  32.371 +struct hvm_hw_pit {
  32.372 +    struct hvm_hw_pit_channel {
  32.373 +        uint32_t count; /* can be 65536 */
  32.374 +        uint16_t latched_count;
  32.375 +        uint8_t count_latched;
  32.376 +        uint8_t status_latched;
  32.377 +        uint8_t status;
  32.378 +        uint8_t read_state;
  32.379 +        uint8_t write_state;
  32.380 +        uint8_t write_latch;
  32.381 +        uint8_t rw_mode;
  32.382 +        uint8_t mode;
  32.383 +        uint8_t bcd; /* not supported */
  32.384 +        uint8_t gate; /* timer start */
  32.385 +    } channels[3];  /* 3 x 16 bytes */
  32.386 +    uint32_t speaker_data_on;
  32.387 +    uint32_t pad0;
  32.388 +};
  32.389 +
  32.390 +DECLARE_HVM_SAVE_TYPE(PIT, 10, struct hvm_hw_pit);
  32.391 +
  32.392 +
  32.393 +/* 
  32.394 + * RTC
  32.395 + */ 
  32.396 +
  32.397 +#define RTC_CMOS_SIZE 14
  32.398 +struct hvm_hw_rtc {
  32.399 +    /* CMOS bytes */
  32.400 +    uint8_t cmos_data[RTC_CMOS_SIZE];
  32.401 +    /* Index register for 2-part operations */
  32.402 +    uint8_t cmos_index;
  32.403 +    uint8_t pad0;
  32.404 +};
  32.405 +
  32.406 +DECLARE_HVM_SAVE_TYPE(RTC, 11, struct hvm_hw_rtc);
  32.407 +
  32.408 +
  32.409 +/*
  32.410 + * HPET
  32.411 + */
  32.412 +
  32.413 +#define HPET_TIMER_NUM     3    /* 3 timers supported now */
  32.414 +struct hvm_hw_hpet {
  32.415 +    /* Memory-mapped, software visible registers */
  32.416 +    uint64_t capability;        /* capabilities */
  32.417 +    uint64_t res0;              /* reserved */
  32.418 +    uint64_t config;            /* configuration */
  32.419 +    uint64_t res1;              /* reserved */
  32.420 +    uint64_t isr;               /* interrupt status reg */
  32.421 +    uint64_t res2[25];          /* reserved */
  32.422 +    uint64_t mc64;              /* main counter */
  32.423 +    uint64_t res3;              /* reserved */
  32.424 +    struct {                    /* timers */
  32.425 +        uint64_t config;        /* configuration/cap */
  32.426 +        uint64_t cmp;           /* comparator */
  32.427 +        uint64_t fsb;           /* FSB route, not supported now */
  32.428 +        uint64_t res4;          /* reserved */
  32.429 +    } timers[HPET_TIMER_NUM];
  32.430 +    uint64_t res5[4*(24-HPET_TIMER_NUM)];  /* reserved, up to 0x3ff */
  32.431 +
  32.432 +    /* Hidden register state */
  32.433 +    uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
  32.434 +};
  32.435 +
  32.436 +DECLARE_HVM_SAVE_TYPE(HPET, 12, struct hvm_hw_hpet);
  32.437 +
  32.438 +
  32.439 +/*
  32.440 + * PM timer
  32.441 + */
  32.442 +
  32.443 +struct hvm_hw_pmtimer {
  32.444 +    uint32_t tmr_val;   /* PM_TMR_BLK.TMR_VAL: 32bit free-running counter */
  32.445 +    uint16_t pm1a_sts;  /* PM1a_EVT_BLK.PM1a_STS: status register */
  32.446 +    uint16_t pm1a_en;   /* PM1a_EVT_BLK.PM1a_EN: enable register */
  32.447 +};
  32.448 +
  32.449 +DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer);
  32.450 +
  32.451 +/* 
  32.452 + * Largest type-code in use
  32.453 + */
  32.454 +#define HVM_SAVE_CODE_MAX 13
  32.455 +
  32.456 +
  32.457 +/* 
  32.458 + * The series of save records is teminated by a zero-type, zero-length 
  32.459 + * descriptor.
  32.460 + */
  32.461 +
  32.462 +struct hvm_save_end {};
  32.463 +DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);
  32.464 +
  32.465 +#endif /* __XEN_PUBLIC_HVM_SAVE_H__ */
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/common/include/public/hvm/vmx_assist.h	Wed Dec 05 11:14:28 2007 -0800
    33.3 @@ -0,0 +1,122 @@
    33.4 +/*
    33.5 + * vmx_assist.h: Context definitions for the VMXASSIST world switch.
    33.6 + *
    33.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    33.8 + * of this software and associated documentation files (the "Software"), to
    33.9 + * deal in the Software without restriction, including without limitation the
   33.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   33.11 + * sell copies of the Software, and to permit persons to whom the Software is
   33.12 + * furnished to do so, subject to the following conditions:
   33.13 + *
   33.14 + * The above copyright notice and this permission notice shall be included in
   33.15 + * all copies or substantial portions of the Software.
   33.16 + *
   33.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   33.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   33.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   33.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   33.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   33.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   33.23 + * DEALINGS IN THE SOFTWARE.
   33.24 + *
   33.25 + * Leendert van Doorn, leendert@watson.ibm.com
   33.26 + * Copyright (c) 2005, International Business Machines Corporation.
   33.27 + */
   33.28 +
   33.29 +#ifndef _VMX_ASSIST_H_
   33.30 +#define _VMX_ASSIST_H_
   33.31 +
   33.32 +#define VMXASSIST_BASE         0xD0000
   33.33 +#define VMXASSIST_MAGIC        0x17101966
   33.34 +#define VMXASSIST_MAGIC_OFFSET (VMXASSIST_BASE+8)
   33.35 +
   33.36 +#define VMXASSIST_NEW_CONTEXT (VMXASSIST_BASE + 12)
   33.37 +#define VMXASSIST_OLD_CONTEXT (VMXASSIST_NEW_CONTEXT + 4)
   33.38 +
   33.39 +#ifndef __ASSEMBLY__
   33.40 +
   33.41 +#define NR_EXCEPTION_HANDLER    32
   33.42 +#define NR_INTERRUPT_HANDLERS   16
   33.43 +#define NR_TRAPS        (NR_EXCEPTION_HANDLER+NR_INTERRUPT_HANDLERS)
   33.44 +
   33.45 +union vmcs_arbytes {
   33.46 +    struct arbyte_fields {
   33.47 +        unsigned int seg_type : 4,
   33.48 +            s         : 1,
   33.49 +            dpl       : 2,
   33.50 +            p         : 1,
   33.51 +            reserved0 : 4,
   33.52 +            avl       : 1,
   33.53 +            reserved1 : 1,
   33.54 +            default_ops_size: 1,
   33.55 +            g         : 1,
   33.56 +            null_bit  : 1,
   33.57 +            reserved2 : 15;
   33.58 +    } fields;
   33.59 +    unsigned int bytes;
   33.60 +};
   33.61 +
   33.62 +/*
   33.63 + * World switch state
   33.64 + */
   33.65 +struct vmx_assist_context {
   33.66 +    uint32_t  eip;        /* execution pointer */
   33.67 +    uint32_t  esp;        /* stack pointer */
   33.68 +    uint32_t  eflags;     /* flags register */
   33.69 +    uint32_t  cr0;
   33.70 +    uint32_t  cr3;        /* page table directory */
   33.71 +    uint32_t  cr4;
   33.72 +    uint32_t  idtr_limit; /* idt */
   33.73 +    uint32_t  idtr_base;
   33.74 +    uint32_t  gdtr_limit; /* gdt */
   33.75 +    uint32_t  gdtr_base;
   33.76 +    uint32_t  cs_sel;     /* cs selector */
   33.77 +    uint32_t  cs_limit;
   33.78 +    uint32_t  cs_base;
   33.79 +    union vmcs_arbytes cs_arbytes;
   33.80 +    uint32_t  ds_sel;     /* ds selector */
   33.81 +    uint32_t  ds_limit;
   33.82 +    uint32_t  ds_base;
   33.83 +    union vmcs_arbytes ds_arbytes;
   33.84 +    uint32_t  es_sel;     /* es selector */
   33.85 +    uint32_t  es_limit;
   33.86 +    uint32_t  es_base;
   33.87 +    union vmcs_arbytes es_arbytes;
   33.88 +    uint32_t  ss_sel;     /* ss selector */
   33.89 +    uint32_t  ss_limit;
   33.90 +    uint32_t  ss_base;
   33.91 +    union vmcs_arbytes ss_arbytes;
   33.92 +    uint32_t  fs_sel;     /* fs selector */
   33.93 +    uint32_t  fs_limit;
   33.94 +    uint32_t  fs_base;
   33.95 +    union vmcs_arbytes fs_arbytes;
   33.96 +    uint32_t  gs_sel;     /* gs selector */
   33.97 +    uint32_t  gs_limit;
   33.98 +    uint32_t  gs_base;
   33.99 +    union vmcs_arbytes gs_arbytes;
  33.100 +    uint32_t  tr_sel;     /* task selector */
  33.101 +    uint32_t  tr_limit;
  33.102 +    uint32_t  tr_base;
  33.103 +    union vmcs_arbytes tr_arbytes;
  33.104 +    uint32_t  ldtr_sel;   /* ldtr selector */
  33.105 +    uint32_t  ldtr_limit;
  33.106 +    uint32_t  ldtr_base;
  33.107 +    union vmcs_arbytes ldtr_arbytes;
  33.108 +
  33.109 +    unsigned char rm_irqbase[2];
  33.110 +};
  33.111 +typedef struct vmx_assist_context vmx_assist_context_t;
  33.112 +
  33.113 +#endif /* __ASSEMBLY__ */
  33.114 +
  33.115 +#endif /* _VMX_ASSIST_H_ */
  33.116 +
  33.117 +/*
  33.118 + * Local variables:
  33.119 + * mode: C
  33.120 + * c-set-style: "BSD"
  33.121 + * c-basic-offset: 4
  33.122 + * tab-width: 4
  33.123 + * indent-tabs-mode: nil
  33.124 + * End:
  33.125 + */
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/common/include/public/io/blkif.h	Wed Dec 05 11:14:28 2007 -0800
    34.3 @@ -0,0 +1,128 @@
    34.4 +/******************************************************************************
    34.5 + * blkif.h
    34.6 + * 
    34.7 + * Unified block-device I/O interface for Xen guest OSes.
    34.8 + * 
    34.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   34.10 + * of this software and associated documentation files (the "Software"), to
   34.11 + * deal in the Software without restriction, including without limitation the
   34.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   34.13 + * sell copies of the Software, and to permit persons to whom the Software is
   34.14 + * furnished to do so, subject to the following conditions:
   34.15 + *
   34.16 + * The above copyright notice and this permission notice shall be included in
   34.17 + * all copies or substantial portions of the Software.
   34.18 + *
   34.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   34.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   34.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   34.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   34.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   34.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   34.25 + * DEALINGS IN THE SOFTWARE.
   34.26 + *
   34.27 + * Copyright (c) 2003-2004, Keir Fraser
   34.28 + */
   34.29 +
   34.30 +#ifndef __XEN_PUBLIC_IO_BLKIF_H__
   34.31 +#define __XEN_PUBLIC_IO_BLKIF_H__
   34.32 +
   34.33 +#include "ring.h"
   34.34 +#include "../grant_table.h"
   34.35 +
   34.36 +/*
   34.37 + * Front->back notifications: When enqueuing a new request, sending a
   34.38 + * notification can be made conditional on req_event (i.e., the generic
   34.39 + * hold-off mechanism provided by the ring macros). Backends must set
   34.40 + * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
   34.41 + * 
   34.42 + * Back->front notifications: When enqueuing a new response, sending a
   34.43 + * notification can be made conditional on rsp_event (i.e., the generic
   34.44 + * hold-off mechanism provided by the ring macros). Frontends must set
   34.45 + * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
   34.46 + */
   34.47 +
   34.48 +#ifndef blkif_vdev_t
   34.49 +#define blkif_vdev_t   uint16_t
   34.50 +#endif
   34.51 +#define blkif_sector_t uint64_t
   34.52 +
   34.53 +/*
   34.54 + * REQUEST CODES.
   34.55 + */
   34.56 +#define BLKIF_OP_READ              0
   34.57 +#define BLKIF_OP_WRITE             1
   34.58 +/*
   34.59 + * Recognised only if "feature-barrier" is present in backend xenbus info.
   34.60 + * The "feature_barrier" node contains a boolean indicating whether barrier
   34.61 + * requests are likely to succeed or fail. Either way, a barrier request
   34.62 + * may fail at any time with BLKIF_RSP_EOPNOTSUPP if it is unsupported by
   34.63 + * the underlying block-device hardware. The boolean simply indicates whether
   34.64 + * or not it is worthwhile for the frontend to attempt barrier requests.
   34.65 + * If a backend does not recognise BLKIF_OP_WRITE_BARRIER, it should *not*
   34.66 + * create the "feature-barrier" node!
   34.67 + */
   34.68 +#define BLKIF_OP_WRITE_BARRIER     2
   34.69 +
   34.70 +/*
   34.71 + * Maximum scatter/gather segments per request.
   34.72 + * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
   34.73 + * NB. This could be 12 if the ring indexes weren't stored in the same page.
   34.74 + */
   34.75 +#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
   34.76 +
   34.77 +struct blkif_request_segment {
   34.78 +    grant_ref_t gref;        /* reference to I/O buffer frame        */
   34.79 +    /* @first_sect: first sector in frame to transfer (inclusive).   */
   34.80 +    /* @last_sect: last sector in frame to transfer (inclusive).     */
   34.81 +    uint8_t     first_sect, last_sect;
   34.82 +};
   34.83 +
   34.84 +struct blkif_request {
   34.85 +    uint8_t        operation;    /* BLKIF_OP_???                         */
   34.86 +    uint8_t        nr_segments;  /* number of segments                   */
   34.87 +    blkif_vdev_t   handle;       /* only for read/write requests         */
   34.88 +    uint64_t       id;           /* private guest value, echoed in resp  */
   34.89 +    blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
   34.90 +    struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
   34.91 +};
   34.92 +typedef struct blkif_request blkif_request_t;
   34.93 +
   34.94 +struct blkif_response {
   34.95 +    uint64_t        id;              /* copied from request */
   34.96 +    uint8_t         operation;       /* copied from request */
   34.97 +    int16_t         status;          /* BLKIF_RSP_???       */
   34.98 +};
   34.99 +typedef struct blkif_response blkif_response_t;
  34.100 +
  34.101 +/*
  34.102 + * STATUS RETURN CODES.
  34.103 + */
  34.104 + /* Operation not supported (only happens on barrier writes). */
  34.105 +#define BLKIF_RSP_EOPNOTSUPP  -2
  34.106 + /* Operation failed for some unspecified reason (-EIO). */
  34.107 +#define BLKIF_RSP_ERROR       -1
  34.108 + /* Operation completed successfully. */
  34.109 +#define BLKIF_RSP_OKAY         0
  34.110 +
  34.111 +/*
  34.112 + * Generate blkif ring structures and types.
  34.113 + */
  34.114 +
  34.115 +DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
  34.116 +
  34.117 +#define VDISK_CDROM        0x1
  34.118 +#define VDISK_REMOVABLE    0x2
  34.119 +#define VDISK_READONLY     0x4
  34.120 +
  34.121 +#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
  34.122 +
  34.123 +/*
  34.124 + * Local variables:
  34.125 + * mode: C
  34.126 + * c-set-style: "BSD"
  34.127 + * c-basic-offset: 4
  34.128 + * tab-width: 4
  34.129 + * indent-tabs-mode: nil
  34.130 + * End:
  34.131 + */
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/common/include/public/io/console.h	Wed Dec 05 11:14:28 2007 -0800
    35.3 @@ -0,0 +1,51 @@
    35.4 +/******************************************************************************
    35.5 + * console.h
    35.6 + * 
    35.7 + * Console I/O interface for Xen guest OSes.
    35.8 + * 
    35.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   35.10 + * of this software and associated documentation files (the "Software"), to
   35.11 + * deal in the Software without restriction, including without limitation the
   35.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   35.13 + * sell copies of the Software, and to permit persons to whom the Software is
   35.14 + * furnished to do so, subject to the following conditions:
   35.15 + *
   35.16 + * The above copyright notice and this permission notice shall be included in
   35.17 + * all copies or substantial portions of the Software.
   35.18 + *
   35.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   35.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   35.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   35.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   35.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   35.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   35.25 + * DEALINGS IN THE SOFTWARE.
   35.26 + *
   35.27 + * Copyright (c) 2005, Keir Fraser
   35.28 + */
   35.29 +
   35.30 +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__
   35.31 +#define __XEN_PUBLIC_IO_CONSOLE_H__
   35.32 +
   35.33 +typedef uint32_t XENCONS_RING_IDX;
   35.34 +
   35.35 +#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1))
   35.36 +
   35.37 +struct xencons_interface {
   35.38 +    char in[1024];
   35.39 +    char out[2048];
   35.40 +    XENCONS_RING_IDX in_cons, in_prod;
   35.41 +    XENCONS_RING_IDX out_cons, out_prod;
   35.42 +};
   35.43 +
   35.44 +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */
   35.45 +
   35.46 +/*
   35.47 + * Local variables:
   35.48 + * mode: C
   35.49 + * c-set-style: "BSD"
   35.50 + * c-basic-offset: 4
   35.51 + * tab-width: 4
   35.52 + * indent-tabs-mode: nil
   35.53 + * End:
   35.54 + */
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/common/include/public/io/fbif.h	Wed Dec 05 11:14:28 2007 -0800
    36.3 @@ -0,0 +1,138 @@
    36.4 +/*
    36.5 + * fbif.h -- Xen virtual frame buffer device
    36.6 + *
    36.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    36.8 + * of this software and associated documentation files (the "Software"), to
    36.9 + * deal in the Software without restriction, including without limitation the
   36.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   36.11 + * sell copies of the Software, and to permit persons to whom the Software is
   36.12 + * furnished to do so, subject to the following conditions:
   36.13 + *
   36.14 + * The above copyright notice and this permission notice shall be included in
   36.15 + * all copies or substantial portions of the Software.
   36.16 + *
   36.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   36.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   36.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   36.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   36.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   36.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   36.23 + * DEALINGS IN THE SOFTWARE.
   36.24 + *
   36.25 + * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
   36.26 + * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
   36.27 + */
   36.28 +
   36.29 +#ifndef __XEN_PUBLIC_IO_FBIF_H__
   36.30 +#define __XEN_PUBLIC_IO_FBIF_H__
   36.31 +
   36.32 +/* Out events (frontend -> backend) */
   36.33 +
   36.34 +/*
   36.35 + * Out events may be sent only when requested by backend, and receipt
   36.36 + * of an unknown out event is an error.
   36.37 + */
   36.38 +
   36.39 +/* Event type 1 currently not used */
   36.40 +/*
   36.41 + * Framebuffer update notification event
   36.42 + * Capable frontend sets feature-update in xenstore.
   36.43 + * Backend requests it by setting request-update in xenstore.
   36.44 + */
   36.45 +#define XENFB_TYPE_UPDATE 2
   36.46 +
   36.47 +struct xenfb_update
   36.48 +{
   36.49 +    uint8_t type;    /* XENFB_TYPE_UPDATE */
   36.50 +    int32_t x;      /* source x */
   36.51 +    int32_t y;      /* source y */
   36.52 +    int32_t width;  /* rect width */
   36.53 +    int32_t height; /* rect height */
   36.54 +};
   36.55 +
   36.56 +#define XENFB_OUT_EVENT_SIZE 40
   36.57 +
   36.58 +union xenfb_out_event
   36.59 +{
   36.60 +    uint8_t type;
   36.61 +    struct xenfb_update update;
   36.62 +    char pad[XENFB_OUT_EVENT_SIZE];
   36.63 +};
   36.64 +
   36.65 +/* In events (backend -> frontend) */
   36.66 +
   36.67 +/*
   36.68 + * Frontends should ignore unknown in events.
   36.69 + * No in events currently defined.
   36.70 + */
   36.71 +
   36.72 +#define XENFB_IN_EVENT_SIZE 40
   36.73 +
   36.74 +union xenfb_in_event
   36.75 +{
   36.76 +    uint8_t type;
   36.77 +    char pad[XENFB_IN_EVENT_SIZE];
   36.78 +};
   36.79 +
   36.80 +/* shared page */
   36.81 +
   36.82 +#define XENFB_IN_RING_SIZE 1024
   36.83 +#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
   36.84 +#define XENFB_IN_RING_OFFS 1024
   36.85 +#define XENFB_IN_RING(page) \
   36.86 +    ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
   36.87 +#define XENFB_IN_RING_REF(page, idx) \
   36.88 +    (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
   36.89 +
   36.90 +#define XENFB_OUT_RING_SIZE 2048
   36.91 +#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
   36.92 +#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
   36.93 +#define XENFB_OUT_RING(page) \
   36.94 +    ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
   36.95 +#define XENFB_OUT_RING_REF(page, idx) \
   36.96 +    (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
   36.97 +
   36.98 +struct xenfb_page
   36.99 +{
  36.100 +    uint32_t in_cons, in_prod;
  36.101 +    uint32_t out_cons, out_prod;
  36.102 +
  36.103 +    int32_t width;          /* the width of the framebuffer (in pixels) */
  36.104 +    int32_t height;         /* the height of the framebuffer (in pixels) */
  36.105 +    uint32_t line_length;   /* the length of a row of pixels (in bytes) */
  36.106 +    uint32_t mem_length;    /* the length of the framebuffer (in bytes) */
  36.107 +    uint8_t depth;          /* the depth of a pixel (in bits) */
  36.108 +
  36.109 +    /*
  36.110 +     * Framebuffer page directory
  36.111 +     *
  36.112 +     * Each directory page holds PAGE_SIZE / sizeof(*pd)
  36.113 +     * framebuffer pages, and can thus map up to PAGE_SIZE *
  36.114 +     * PAGE_SIZE / sizeof(*pd) bytes.  With PAGE_SIZE == 4096 and
  36.115 +     * sizeof(unsigned long) == 4, that's 4 Megs.  Two directory
  36.116 +     * pages should be enough for a while.
  36.117 +     */
  36.118 +    unsigned long pd[2];
  36.119 +};
  36.120 +
  36.121 +/*
  36.122 + * Wart: xenkbd needs to know resolution.  Put it here until a better
  36.123 + * solution is found, but don't leak it to the backend.
  36.124 + */
  36.125 +#ifdef __KERNEL__
  36.126 +#define XENFB_WIDTH 800
  36.127 +#define XENFB_HEIGHT 600
  36.128 +#define XENFB_DEPTH 32
  36.129 +#endif
  36.130 +
  36.131 +#endif
  36.132 +
  36.133 +/*
  36.134 + * Local variables:
  36.135 + * mode: C
  36.136 + * c-set-style: "BSD"
  36.137 + * c-basic-offset: 4
  36.138 + * tab-width: 4
  36.139 + * indent-tabs-mode: nil
  36.140 + * End:
  36.141 + */
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/common/include/public/io/kbdif.h	Wed Dec 05 11:14:28 2007 -0800
    37.3 @@ -0,0 +1,130 @@
    37.4 +/*
    37.5 + * kbdif.h -- Xen virtual keyboard/mouse
    37.6 + *
    37.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    37.8 + * of this software and associated documentation files (the "Software"), to
    37.9 + * deal in the Software without restriction, including without limitation the
   37.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   37.11 + * sell copies of the Software, and to permit persons to whom the Software is
   37.12 + * furnished to do so, subject to the following conditions:
   37.13 + *
   37.14 + * The above copyright notice and this permission notice shall be included in
   37.15 + * all copies or substantial portions of the Software.
   37.16 + *
   37.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   37.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   37.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   37.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   37.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   37.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   37.23 + * DEALINGS IN THE SOFTWARE.
   37.24 + *
   37.25 + * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
   37.26 + * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
   37.27 + */
   37.28 +
   37.29 +#ifndef __XEN_PUBLIC_IO_KBDIF_H__
   37.30 +#define __XEN_PUBLIC_IO_KBDIF_H__
   37.31 +
   37.32 +/* In events (backend -> frontend) */
   37.33 +
   37.34 +/*
   37.35 + * Frontends should ignore unknown in events.
   37.36 + */
   37.37 +
   37.38 +/* Pointer movement event */
   37.39 +#define XENKBD_TYPE_MOTION  1
   37.40 +/* Event type 2 currently not used */
   37.41 +/* Key event (includes pointer buttons) */
   37.42 +#define XENKBD_TYPE_KEY     3
   37.43 +/*
   37.44 + * Pointer position event
   37.45 + * Capable backend sets feature-abs-pointer in xenstore.
   37.46 + * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
   37.47 + * request-abs-update in xenstore.
   37.48 + */
   37.49 +#define XENKBD_TYPE_POS     4
   37.50 +
   37.51 +struct xenkbd_motion
   37.52 +{
   37.53 +    uint8_t type;        /* XENKBD_TYPE_MOTION */
   37.54 +    int32_t rel_x;       /* relative X motion */
   37.55 +    int32_t rel_y;       /* relative Y motion */
   37.56 +};
   37.57 +
   37.58 +struct xenkbd_key
   37.59 +{
   37.60 +    uint8_t type;         /* XENKBD_TYPE_KEY */
   37.61 +    uint8_t pressed;      /* 1 if pressed; 0 otherwise */
   37.62 +    uint32_t keycode;     /* KEY_* from linux/input.h */
   37.63 +};
   37.64 +
   37.65 +struct xenkbd_position
   37.66 +{
   37.67 +    uint8_t type;        /* XENKBD_TYPE_POS */
   37.68 +    int32_t abs_x;       /* absolute X position (in FB pixels) */
   37.69 +    int32_t abs_y;       /* absolute Y position (in FB pixels) */
   37.70 +};
   37.71 +
   37.72 +#define XENKBD_IN_EVENT_SIZE 40
   37.73 +
   37.74 +union xenkbd_in_event
   37.75 +{
   37.76 +    uint8_t type;
   37.77 +    struct xenkbd_motion motion;
   37.78 +    struct xenkbd_key key;
   37.79 +    struct xenkbd_position pos;
   37.80 +    char pad[XENKBD_IN_EVENT_SIZE];
   37.81 +};
   37.82 +
   37.83 +/* Out events (frontend -> backend) */
   37.84 +
   37.85 +/*
   37.86 + * Out events may be sent only when requested by backend, and receipt
   37.87 + * of an unknown out event is an error.
   37.88 + * No out events currently defined.
   37.89 + */
   37.90 +
   37.91 +#define XENKBD_OUT_EVENT_SIZE 40
   37.92 +
   37.93 +union xenkbd_out_event
   37.94 +{
   37.95 +    uint8_t type;
   37.96 +    char pad[XENKBD_OUT_EVENT_SIZE];
   37.97 +};
   37.98 +
   37.99 +/* shared page */
  37.100 +
  37.101 +#define XENKBD_IN_RING_SIZE 2048
  37.102 +#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
  37.103 +#define XENKBD_IN_RING_OFFS 1024
  37.104 +#define XENKBD_IN_RING(page) \
  37.105 +    ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
  37.106 +#define XENKBD_IN_RING_REF(page, idx) \
  37.107 +    (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
  37.108 +
  37.109 +#define XENKBD_OUT_RING_SIZE 1024
  37.110 +#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
  37.111 +#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
  37.112 +#define XENKBD_OUT_RING(page) \
  37.113 +    ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
  37.114 +#define XENKBD_OUT_RING_REF(page, idx) \
  37.115 +    (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
  37.116 +
  37.117 +struct xenkbd_page
  37.118 +{
  37.119 +    uint32_t in_cons, in_prod;
  37.120 +    uint32_t out_cons, out_prod;
  37.121 +};
  37.122 +
  37.123 +#endif
  37.124 +
  37.125 +/*
  37.126 + * Local variables:
  37.127 + * mode: C
  37.128 + * c-set-style: "BSD"
  37.129 + * c-basic-offset: 4
  37.130 + * tab-width: 4
  37.131 + * indent-tabs-mode: nil
  37.132 + * End:
  37.133 + */
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/common/include/public/io/netif.h	Wed Dec 05 11:14:28 2007 -0800
    38.3 @@ -0,0 +1,184 @@
    38.4 +/******************************************************************************
    38.5 + * netif.h
    38.6 + * 
    38.7 + * Unified network-device I/O interface for Xen guest OSes.
    38.8 + * 
    38.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   38.10 + * of this software and associated documentation files (the "Software"), to
   38.11 + * deal in the Software without restriction, including without limitation the
   38.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   38.13 + * sell copies of the Software, and to permit persons to whom the Software is
   38.14 + * furnished to do so, subject to the following conditions:
   38.15 + *
   38.16 + * The above copyright notice and this permission notice shall be included in
   38.17 + * all copies or substantial portions of the Software.
   38.18 + *
   38.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   38.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   38.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   38.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   38.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   38.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   38.25 + * DEALINGS IN THE SOFTWARE.
   38.26 + *
   38.27 + * Copyright (c) 2003-2004, Keir Fraser
   38.28 + */
   38.29 +
   38.30 +#ifndef __XEN_PUBLIC_IO_NETIF_H__
   38.31 +#define __XEN_PUBLIC_IO_NETIF_H__
   38.32 +
   38.33 +#include "ring.h"
   38.34 +#include "../grant_table.h"
   38.35 +
   38.36 +/*
   38.37 + * Notifications after enqueuing any type of message should be conditional on
   38.38 + * the appropriate req_event or rsp_event field in the shared ring.
   38.39 + * If the client sends notification for rx requests then it should specify
   38.40 + * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
   38.41 + * that it cannot safely queue packets (as it may not be kicked to send them).
   38.42 + */
   38.43 +
   38.44 +/*
   38.45 + * This is the 'wire' format for packets:
   38.46 + *  Request 1: netif_tx_request -- NETTXF_* (any flags)
   38.47 + * [Request 2: netif_tx_extra]  (only if request 1 has NETTXF_extra_info)
   38.48 + * [Request 3: netif_tx_extra]  (only if request 2 has XEN_NETIF_EXTRA_MORE)
   38.49 + *  Request 4: netif_tx_request -- NETTXF_more_data
   38.50 + *  Request 5: netif_tx_request -- NETTXF_more_data
   38.51 + *  ...
   38.52 + *  Request N: netif_tx_request -- 0
   38.53 + */
   38.54 +
   38.55 +/* Protocol checksum field is blank in the packet (hardware offload)? */
   38.56 +#define _NETTXF_csum_blank     (0)
   38.57 +#define  NETTXF_csum_blank     (1U<<_NETTXF_csum_blank)
   38.58 +
   38.59 +/* Packet data has been validated against protocol checksum. */
   38.60 +#define _NETTXF_data_validated (1)
   38.61 +#define  NETTXF_data_validated (1U<<_NETTXF_data_validated)
   38.62 +
   38.63 +/* Packet continues in the next request descriptor. */
   38.64 +#define _NETTXF_more_data      (2)
   38.65 +#define  NETTXF_more_data      (1U<<_NETTXF_more_data)
   38.66 +
   38.67 +/* Packet to be followed by extra descriptor(s). */
   38.68 +#define _NETTXF_extra_info     (3)
   38.69 +#define  NETTXF_extra_info     (1U<<_NETTXF_extra_info)
   38.70 +
   38.71 +struct netif_tx_request {
   38.72 +    grant_ref_t gref;      /* Reference to buffer page */
   38.73 +    uint16_t offset;       /* Offset within buffer page */
   38.74 +    uint16_t flags;        /* NETTXF_* */
   38.75 +    uint16_t id;           /* Echoed in response message. */
   38.76 +    uint16_t size;         /* Packet size in bytes.       */
   38.77 +};
   38.78 +typedef struct netif_tx_request netif_tx_request_t;
   38.79 +
   38.80 +/* Types of netif_extra_info descriptors. */
   38.81 +#define XEN_NETIF_EXTRA_TYPE_NONE  (0)  /* Never used - invalid */
   38.82 +#define XEN_NETIF_EXTRA_TYPE_GSO   (1)  /* u.gso */
   38.83 +#define XEN_NETIF_EXTRA_TYPE_MAX   (2)
   38.84 +
   38.85 +/* netif_extra_info flags. */
   38.86 +#define _XEN_NETIF_EXTRA_FLAG_MORE (0)
   38.87 +#define XEN_NETIF_EXTRA_FLAG_MORE  (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
   38.88 +
   38.89 +/* GSO types - only TCPv4 currently supported. */
   38.90 +#define XEN_NETIF_GSO_TYPE_TCPV4        (1)
   38.91 +
   38.92 +/*
   38.93 + * This structure needs to fit within both netif_tx_request and
   38.94 + * netif_rx_response for compatibility.
   38.95 + */
   38.96 +struct netif_extra_info {
   38.97 +    uint8_t type;  /* XEN_NETIF_EXTRA_TYPE_* */
   38.98 +    uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
   38.99 +
  38.100 +    union {
  38.101 +        struct {
  38.102 +            /*
  38.103 +             * Maximum payload size of each segment. For example, for TCP this
  38.104 +             * is just the path MSS.
  38.105 +             */
  38.106 +            uint16_t size;
  38.107 +
  38.108 +            /*
  38.109 +             * GSO type. This determines the protocol of the packet and any
  38.110 +             * extra features required to segment the packet properly.
  38.111 +             */
  38.112 +            uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
  38.113 +
  38.114 +            /* Future expansion. */
  38.115 +            uint8_t pad;
  38.116 +
  38.117 +            /*
  38.118 +             * GSO features. This specifies any extra GSO features required
  38.119 +             * to process this packet, such as ECN support for TCPv4.
  38.120 +             */
  38.121 +            uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
  38.122 +        } gso;
  38.123 +
  38.124 +        uint16_t pad[3];
  38.125 +    } u;
  38.126 +};
  38.127 +
  38.128 +struct netif_tx_response {
  38.129 +    uint16_t id;
  38.130 +    int16_t  status;       /* NETIF_RSP_* */
  38.131 +};
  38.132 +typedef struct netif_tx_response netif_tx_response_t;
  38.133 +
  38.134 +struct netif_rx_request {
  38.135 +    uint16_t    id;        /* Echoed in response message.        */
  38.136 +    grant_ref_t gref;      /* Reference to incoming granted frame */
  38.137 +};
  38.138 +typedef struct netif_rx_request netif_rx_request_t;
  38.139 +
  38.140 +/* Packet data has been validated against protocol checksum. */
  38.141 +#define _NETRXF_data_validated (0)
  38.142 +#define  NETRXF_data_validated (1U<<_NETRXF_data_validated)
  38.143 +
  38.144 +/* Protocol checksum field is blank in the packet (hardware offload)? */
  38.145 +#define _NETRXF_csum_blank     (1)
  38.146 +#define  NETRXF_csum_blank     (1U<<_NETRXF_csum_blank)
  38.147 +
  38.148 +/* Packet continues in the next request descriptor. */
  38.149 +#define _NETRXF_more_data      (2)
  38.150 +#define  NETRXF_more_data      (1U<<_NETRXF_more_data)
  38.151 +
  38.152 +/* Packet to be followed by extra descriptor(s). */
  38.153 +#define _NETRXF_extra_info     (3)
  38.154 +#define  NETRXF_extra_info     (1U<<_NETRXF_extra_info)
  38.155 +
  38.156 +struct netif_rx_response {
  38.157 +    uint16_t id;
  38.158 +    uint16_t offset;       /* Offset in page of start of received packet  */
  38.159 +    uint16_t flags;        /* NETRXF_* */
  38.160 +    int16_t  status;       /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
  38.161 +};
  38.162 +typedef struct netif_rx_response netif_rx_response_t;
  38.163 +
  38.164 +/*
  38.165 + * Generate netif ring structures and types.
  38.166 + */
  38.167 +
  38.168 +DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
  38.169 +DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
  38.170 +
  38.171 +#define NETIF_RSP_DROPPED         -2
  38.172 +#define NETIF_RSP_ERROR           -1
  38.173 +#define NETIF_RSP_OKAY             0
  38.174 +/* No response: used for auxiliary requests (e.g., netif_tx_extra). */
  38.175 +#define NETIF_RSP_NULL             1
  38.176 +
  38.177 +#endif
  38.178 +
  38.179 +/*
  38.180 + * Local variables:
  38.181 + * mode: C
  38.182 + * c-set-style: "BSD"
  38.183 + * c-basic-offset: 4
  38.184 + * tab-width: 4
  38.185 + * indent-tabs-mode: nil
  38.186 + * End:
  38.187 + */
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/common/include/public/io/pciif.h	Wed Dec 05 11:14:28 2007 -0800
    39.3 @@ -0,0 +1,83 @@
    39.4 +/*
    39.5 + * PCI Backend/Frontend Common Data Structures & Macros
    39.6 + *
    39.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    39.8 + * of this software and associated documentation files (the "Software"), to
    39.9 + * deal in the Software without restriction, including without limitation the
   39.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   39.11 + * sell copies of the Software, and to permit persons to whom the Software is
   39.12 + * furnished to do so, subject to the following conditions:
   39.13 + *
   39.14 + * The above copyright notice and this permission notice shall be included in
   39.15 + * all copies or substantial portions of the Software.
   39.16 + *
   39.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   39.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   39.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   39.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   39.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   39.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   39.23 + * DEALINGS IN THE SOFTWARE.
   39.24 + *
   39.25 + *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
   39.26 + */
   39.27 +#ifndef __XEN_PCI_COMMON_H__
   39.28 +#define __XEN_PCI_COMMON_H__
   39.29 +
   39.30 +/* Be sure to bump this number if you change this file */
   39.31 +#define XEN_PCI_MAGIC "7"
   39.32 +
   39.33 +/* xen_pci_sharedinfo flags */
   39.34 +#define _XEN_PCIF_active     (0)
   39.35 +#define XEN_PCIF_active      (1<<_XEN_PCI_active)
   39.36 +
   39.37 +/* xen_pci_op commands */
   39.38 +#define XEN_PCI_OP_conf_read    (0)
   39.39 +#define XEN_PCI_OP_conf_write   (1)
   39.40 +
   39.41 +/* xen_pci_op error numbers */
   39.42 +#define XEN_PCI_ERR_success          (0)
   39.43 +#define XEN_PCI_ERR_dev_not_found   (-1)
   39.44 +#define XEN_PCI_ERR_invalid_offset  (-2)
   39.45 +#define XEN_PCI_ERR_access_denied   (-3)
   39.46 +#define XEN_PCI_ERR_not_implemented (-4)
   39.47 +/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
   39.48 +#define XEN_PCI_ERR_op_failed       (-5)
   39.49 +
   39.50 +struct xen_pci_op {
   39.51 +    /* IN: what action to perform: XEN_PCI_OP_* */
   39.52 +    uint32_t cmd;
   39.53 +
   39.54 +    /* OUT: will contain an error number (if any) from errno.h */
   39.55 +    int32_t err;
   39.56 +
   39.57 +    /* IN: which device to touch */
   39.58 +    uint32_t domain; /* PCI Domain/Segment */
   39.59 +    uint32_t bus;
   39.60 +    uint32_t devfn;
   39.61 +
   39.62 +    /* IN: which configuration registers to touch */
   39.63 +    int32_t offset;
   39.64 +    int32_t size;
   39.65 +
   39.66 +    /* IN/OUT: Contains the result after a READ or the value to WRITE */
   39.67 +    uint32_t value;
   39.68 +};
   39.69 +
   39.70 +struct xen_pci_sharedinfo {
   39.71 +    /* flags - XEN_PCIF_* */
   39.72 +    uint32_t flags;
   39.73 +    struct xen_pci_op op;
   39.74 +};
   39.75 +
   39.76 +#endif /* __XEN_PCI_COMMON_H__ */
   39.77 +
   39.78 +/*
   39.79 + * Local variables:
   39.80 + * mode: C
   39.81 + * c-set-style: "BSD"
   39.82 + * c-basic-offset: 4
   39.83 + * tab-width: 4
   39.84 + * indent-tabs-mode: nil
   39.85 + * End:
   39.86 + */
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/common/include/public/io/protocols.h	Wed Dec 05 11:14:28 2007 -0800
    40.3 @@ -0,0 +1,21 @@
    40.4 +#ifndef __XEN_PROTOCOLS_H__
    40.5 +#define __XEN_PROTOCOLS_H__
    40.6 +
    40.7 +#define XEN_IO_PROTO_ABI_X86_32     "x86_32-abi"
    40.8 +#define XEN_IO_PROTO_ABI_X86_64     "x86_64-abi"
    40.9 +#define XEN_IO_PROTO_ABI_IA64       "ia64-abi"
   40.10 +#define XEN_IO_PROTO_ABI_POWERPC64  "powerpc64-abi"
   40.11 +
   40.12 +#if defined(__i386__)
   40.13 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
   40.14 +#elif defined(__x86_64__)
   40.15 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
   40.16 +#elif defined(__ia64__)
   40.17 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64
   40.18 +#elif defined(__powerpc64__)
   40.19 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64
   40.20 +#else
   40.21 +# error arch fixup needed here
   40.22 +#endif
   40.23 +
   40.24 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/common/include/public/io/ring.h	Wed Dec 05 11:14:28 2007 -0800
    41.3 @@ -0,0 +1,299 @@
    41.4 +/******************************************************************************
    41.5 + * ring.h
    41.6 + * 
    41.7 + * Shared producer-consumer ring macros.
    41.8 + *
    41.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   41.10 + * of this software and associated documentation files (the "Software"), to
   41.11 + * deal in the Software without restriction, including without limitation the
   41.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   41.13 + * sell copies of the Software, and to permit persons to whom the Software is
   41.14 + * furnished to do so, subject to the following conditions:
   41.15 + *
   41.16 + * The above copyright notice and this permission notice shall be included in
   41.17 + * all copies or substantial portions of the Software.
   41.18 + *
   41.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   41.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   41.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   41.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   41.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   41.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   41.25 + * DEALINGS IN THE SOFTWARE.
   41.26 + *
   41.27 + * Tim Deegan and Andrew Warfield November 2004.
   41.28 + */
   41.29 +
   41.30 +#ifndef __XEN_PUBLIC_IO_RING_H__
   41.31 +#define __XEN_PUBLIC_IO_RING_H__
   41.32 +
   41.33 +typedef unsigned int RING_IDX;
   41.34 +
   41.35 +/* Round a 32-bit unsigned constant down to the nearest power of two. */
   41.36 +#define __RD2(_x)  (((_x) & 0x00000002) ? 0x2                  : ((_x) & 0x1))
   41.37 +#define __RD4(_x)  (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2    : __RD2(_x))
   41.38 +#define __RD8(_x)  (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4    : __RD4(_x))
   41.39 +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8    : __RD8(_x))
   41.40 +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
   41.41 +
   41.42 +/*
   41.43 + * Calculate size of a shared ring, given the total available space for the
   41.44 + * ring and indexes (_sz), and the name tag of the request/response structure.
   41.45 + * A ring contains as many entries as will fit, rounded down to the nearest 
   41.46 + * power of two (so we can mask with (size-1) to loop around).
   41.47 + */
   41.48 +#define __RING_SIZE(_s, _sz) \
   41.49 +    (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
   41.50 +
   41.51 +/*
   41.52 + * Macros to make the correct C datatypes for a new kind of ring.
   41.53 + * 
   41.54 + * To make a new ring datatype, you need to have two message structures,
   41.55 + * let's say request_t, and response_t already defined.
   41.56 + *
   41.57 + * In a header where you want the ring datatype declared, you then do:
   41.58 + *
   41.59 + *     DEFINE_RING_TYPES(mytag, request_t, response_t);
   41.60 + *
   41.61 + * These expand out to give you a set of types, as you can see below.
   41.62 + * The most important of these are:
   41.63 + * 
   41.64 + *     mytag_sring_t      - The shared ring.
   41.65 + *     mytag_front_ring_t - The 'front' half of the ring.
   41.66 + *     mytag_back_ring_t  - The 'back' half of the ring.
   41.67 + *
   41.68 + * To initialize a ring in your code you need to know the location and size
   41.69 + * of the shared memory area (PAGE_SIZE, for instance). To initialise
   41.70 + * the front half:
   41.71 + *
   41.72 + *     mytag_front_ring_t front_ring;
   41.73 + *     SHARED_RING_INIT((mytag_sring_t *)shared_page);
   41.74 + *     FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   41.75 + *
   41.76 + * Initializing the back follows similarly (note that only the front
   41.77 + * initializes the shared ring):
   41.78 + *
   41.79 + *     mytag_back_ring_t back_ring;
   41.80 + *     BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   41.81 + */
   41.82 +
   41.83 +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
   41.84 +                                                                        \
   41.85 +/* Shared ring entry */                                                 \
   41.86 +union __name##_sring_entry {                                            \
   41.87 +    __req_t req;                                                        \
   41.88 +    __rsp_t rsp;                                                        \
   41.89 +};                                                                      \
   41.90 +                                                                        \
   41.91 +/* Shared ring page */                                                  \
   41.92 +struct __name##_sring {                                                 \
   41.93 +    RING_IDX req_prod, req_event;                                       \
   41.94 +    RING_IDX rsp_prod, rsp_event;                                       \
   41.95 +    uint8_t  pad[48];                                                   \
   41.96 +    union __name##_sring_entry ring[1]; /* variable-length */           \
   41.97 +};                                                                      \
   41.98 +                                                                        \
   41.99 +/* "Front" end's private variables */                                   \
  41.100 +struct __name##_front_ring {                                            \
  41.101 +    RING_IDX req_prod_pvt;                                              \
  41.102 +    RING_IDX rsp_cons;                                                  \
  41.103 +    unsigned int nr_ents;                                               \
  41.104 +    struct __name##_sring *sring;                                       \
  41.105 +};                                                                      \
  41.106 +                                                                        \
  41.107 +/* "Back" end's private variables */                                    \
  41.108 +struct __name##_back_ring {                                             \
  41.109 +    RING_IDX rsp_prod_pvt;                                              \
  41.110 +    RING_IDX req_cons;                                                  \
  41.111 +    unsigned int nr_ents;                                               \
  41.112 +    struct __name##_sring *sring;                                       \
  41.113 +};                                                                      \
  41.114 +                                                                        \
  41.115 +/* Syntactic sugar */                                                   \
  41.116 +typedef struct __name##_sring __name##_sring_t;                         \
  41.117 +typedef struct __name##_front_ring __name##_front_ring_t;               \
  41.118 +typedef struct __name##_back_ring __name##_back_ring_t
  41.119 +
  41.120 +/*
  41.121 + * Macros for manipulating rings.
  41.122 + * 
  41.123 + * FRONT_RING_whatever works on the "front end" of a ring: here 
  41.124 + * requests are pushed on to the ring and responses taken off it.
  41.125 + * 
  41.126 + * BACK_RING_whatever works on the "back end" of a ring: here 
  41.127 + * requests are taken off the ring and responses put on.
  41.128 + * 
  41.129 + * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. 
  41.130 + * This is OK in 1-for-1 request-response situations where the 
  41.131 + * requestor (front end) never has more than RING_SIZE()-1
  41.132 + * outstanding requests.
  41.133 + */
  41.134 +
  41.135 +/* Initialising empty rings */
  41.136 +#define SHARED_RING_INIT(_s) do {                                       \
  41.137 +    (_s)->req_prod  = (_s)->rsp_prod  = 0;                              \
  41.138 +    (_s)->req_event = (_s)->rsp_event = 1;                              \
  41.139 +    (void)memset((_s)->pad, 0, sizeof((_s)->pad));                      \
  41.140 +} while(0)
  41.141 +
  41.142 +#define FRONT_RING_INIT(_r, _s, __size) do {                            \
  41.143 +    (_r)->req_prod_pvt = 0;                                             \
  41.144 +    (_r)->rsp_cons = 0;                                                 \
  41.145 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  41.146 +    (_r)->sring = (_s);                                                 \
  41.147 +} while (0)
  41.148 +
  41.149 +#define BACK_RING_INIT(_r, _s, __size) do {                             \
  41.150 +    (_r)->rsp_prod_pvt = 0;                                             \
  41.151 +    (_r)->req_cons = 0;                                                 \
  41.152 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  41.153 +    (_r)->sring = (_s);                                                 \
  41.154 +} while (0)
  41.155 +
  41.156 +/* Initialize to existing shared indexes -- for recovery */
  41.157 +#define FRONT_RING_ATTACH(_r, _s, __size) do {                          \
  41.158 +    (_r)->sring = (_s);                                                 \
  41.159 +    (_r)->req_prod_pvt = (_s)->req_prod;                                \
  41.160 +    (_r)->rsp_cons = (_s)->rsp_prod;                                    \
  41.161 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  41.162 +} while (0)
  41.163 +
  41.164 +#define BACK_RING_ATTACH(_r, _s, __size) do {                           \
  41.165 +    (_r)->sring = (_s);                                                 \
  41.166 +    (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
  41.167 +    (_r)->req_cons = (_s)->req_prod;                                    \
  41.168 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  41.169 +} while (0)
  41.170 +
  41.171 +/* How big is this ring? */
  41.172 +#define RING_SIZE(_r)                                                   \
  41.173 +    ((_r)->nr_ents)
  41.174 +
  41.175 +/* Number of free requests (for use on front side only). */
  41.176 +#define RING_FREE_REQUESTS(_r)                                          \
  41.177 +    (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
  41.178 +
  41.179 +/* Test if there is an empty slot available on the front ring.
  41.180 + * (This is only meaningful from the front. )
  41.181 + */
  41.182 +#define RING_FULL(_r)                                                   \
  41.183 +    (RING_FREE_REQUESTS(_r) == 0)
  41.184 +
  41.185 +/* Test if there are outstanding messages to be processed on a ring. */
  41.186 +#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
  41.187 +    ((_r)->sring->rsp_prod - (_r)->rsp_cons)
  41.188 +
  41.189 +#ifdef __GNUC__
  41.190 +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
  41.191 +    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
  41.192 +    unsigned int rsp = RING_SIZE(_r) -                                  \
  41.193 +        ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
  41.194 +    req < rsp ? req : rsp;                                              \
  41.195 +})
  41.196 +#else
  41.197 +/* Same as above, but without the nice GCC ({ ... }) syntax. */
  41.198 +#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
  41.199 +    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
  41.200 +      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
  41.201 +     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
  41.202 +     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
  41.203 +#endif
  41.204 +
  41.205 +/* Direct access to individual ring elements, by index. */
  41.206 +#define RING_GET_REQUEST(_r, _idx)                                      \
  41.207 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
  41.208 +
  41.209 +#define RING_GET_RESPONSE(_r, _idx)                                     \
  41.210 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
  41.211 +
  41.212 +/* Loop termination condition: Would the specified index overflow the ring? */
  41.213 +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                           \
  41.214 +    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
  41.215 +
  41.216 +#define RING_PUSH_REQUESTS(_r) do {                                     \
  41.217 +    wmb(); /* back sees requests /before/ updated producer index */     \
  41.218 +    (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
  41.219 +} while (0)
  41.220 +
  41.221 +#define RING_PUSH_RESPONSES(_r) do {                                    \
  41.222 +    wmb(); /* front sees responses /before/ updated producer index */   \
  41.223 +    (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
  41.224 +} while (0)
  41.225 +
  41.226 +/*
  41.227 + * Notification hold-off (req_event and rsp_event):
  41.228 + * 
  41.229 + * When queueing requests or responses on a shared ring, it may not always be
  41.230 + * necessary to notify the remote end. For example, if requests are in flight
  41.231 + * in a backend, the front may be able to queue further requests without
  41.232 + * notifying the back (if the back checks for new requests when it queues
  41.233 + * responses).
  41.234 + * 
  41.235 + * When enqueuing requests or responses:
  41.236 + * 
  41.237 + *  Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument
  41.238 + *  is a boolean return value. True indicates that the receiver requires an
  41.239 + *  asynchronous notification.
  41.240 + * 
  41.241 + * After dequeuing requests or responses (before sleeping the connection):
  41.242 + * 
  41.243 + *  Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES().
  41.244 + *  The second argument is a boolean return value. True indicates that there
  41.245 + *  are pending messages on the ring (i.e., the connection should not be put
  41.246 + *  to sleep).
  41.247 + * 
  41.248 + *  These macros will set the req_event/rsp_event field to trigger a
  41.249 + *  notification on the very next message that is enqueued. If you want to
  41.250 + *  create batches of work (i.e., only receive a notification after several
  41.251 + *  messages have been enqueued) then you will need to create a customised
  41.252 + *  version of the FINAL_CHECK macro in your own code, which sets the event
  41.253 + *  field appropriately.
  41.254 + */
  41.255 +
  41.256 +#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
  41.257 +    RING_IDX __old = (_r)->sring->req_prod;                             \
  41.258 +    RING_IDX __new = (_r)->req_prod_pvt;                                \
  41.259 +    wmb(); /* back sees requests /before/ updated producer index */     \
  41.260 +    (_r)->sring->req_prod = __new;                                      \
  41.261 +    mb(); /* back sees new requests /before/ we check req_event */      \
  41.262 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
  41.263 +                 (RING_IDX)(__new - __old));                            \
  41.264 +} while (0)
  41.265 +
  41.266 +#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
  41.267 +    RING_IDX __old = (_r)->sring->rsp_prod;                             \
  41.268 +    RING_IDX __new = (_r)->rsp_prod_pvt;                                \
  41.269 +    wmb(); /* front sees responses /before/ updated producer index */   \
  41.270 +    (_r)->sring->rsp_prod = __new;                                      \
  41.271 +    mb(); /* front sees new responses /before/ we check rsp_event */    \
  41.272 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
  41.273 +                 (RING_IDX)(__new - __old));                            \
  41.274 +} while (0)
  41.275 +
  41.276 +#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do {             \
  41.277 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
  41.278 +    if (_work_to_do) break;                                             \
  41.279 +    (_r)->sring->req_event = (_r)->req_cons + 1;                        \
  41.280 +    mb();                                                               \
  41.281 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
  41.282 +} while (0)
  41.283 +
  41.284 +#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do {            \
  41.285 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
  41.286 +    if (_work_to_do) break;                                             \
  41.287 +    (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
  41.288 +    mb();                                                               \
  41.289 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
  41.290 +} while (0)
  41.291 +
  41.292 +#endif /* __XEN_PUBLIC_IO_RING_H__ */
  41.293 +
  41.294 +/*
  41.295 + * Local variables:
  41.296 + * mode: C
  41.297 + * c-set-style: "BSD"
  41.298 + * c-basic-offset: 4
  41.299 + * tab-width: 4
  41.300 + * indent-tabs-mode: nil
  41.301 + * End:
  41.302 + */
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/common/include/public/io/tpmif.h	Wed Dec 05 11:14:28 2007 -0800
    42.3 @@ -0,0 +1,77 @@
    42.4 +/******************************************************************************
    42.5 + * tpmif.h
    42.6 + *
    42.7 + * TPM I/O interface for Xen guest OSes.
    42.8 + *
    42.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   42.10 + * of this software and associated documentation files (the "Software"), to
   42.11 + * deal in the Software without restriction, including without limitation the
   42.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   42.13 + * sell copies of the Software, and to permit persons to whom the Software is
   42.14 + * furnished to do so, subject to the following conditions:
   42.15 + *
   42.16 + * The above copyright notice and this permission notice shall be included in
   42.17 + * all copies or substantial portions of the Software.
   42.18 + *
   42.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   42.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   42.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   42.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   42.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   42.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   42.25 + * DEALINGS IN THE SOFTWARE.
   42.26 + *
   42.27 + * Copyright (c) 2005, IBM Corporation
   42.28 + *
   42.29 + * Author: Stefan Berger, stefanb@us.ibm.com
   42.30 + * Grant table support: Mahadevan Gomathisankaran
   42.31 + *
   42.32 + * This code has been derived from tools/libxc/xen/io/netif.h
   42.33 + *
   42.34 + * Copyright (c) 2003-2004, Keir Fraser
   42.35 + */
   42.36 +
   42.37 +#ifndef __XEN_PUBLIC_IO_TPMIF_H__
   42.38 +#define __XEN_PUBLIC_IO_TPMIF_H__
   42.39 +
   42.40 +#include "../grant_table.h"
   42.41 +
   42.42 +struct tpmif_tx_request {
   42.43 +    unsigned long addr;   /* Machine address of packet.   */
   42.44 +    grant_ref_t ref;      /* grant table access reference */
   42.45 +    uint16_t unused;
   42.46 +    uint16_t size;        /* Packet size in bytes.        */
   42.47 +};
   42.48 +typedef struct tpmif_tx_request tpmif_tx_request_t;
   42.49 +
   42.50 +/*
   42.51 + * The TPMIF_TX_RING_SIZE defines the number of pages the
   42.52 + * front-end and backend can exchange (= size of array).
   42.53 + */
   42.54 +typedef uint32_t TPMIF_RING_IDX;
   42.55 +
   42.56 +#define TPMIF_TX_RING_SIZE 1
   42.57 +
   42.58 +/* This structure must fit in a memory page. */
   42.59 +
   42.60 +struct tpmif_ring {
   42.61 +    struct tpmif_tx_request req;
   42.62 +};
   42.63 +typedef struct tpmif_ring tpmif_ring_t;
   42.64 +
   42.65 +struct tpmif_tx_interface {
   42.66 +    struct tpmif_ring ring[TPMIF_TX_RING_SIZE];
   42.67 +};
   42.68 +typedef struct tpmif_tx_interface tpmif_tx_interface_t;
   42.69 +
   42.70 +#endif
   42.71 +
   42.72 +/*
   42.73 + * Local variables:
   42.74 + * mode: C
   42.75 + * c-set-style: "BSD"
   42.76 + * c-basic-offset: 4
   42.77 + * tab-width: 4
   42.78 + * indent-tabs-mode: nil
   42.79 + * End:
   42.80 + */
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/common/include/public/io/xenbus.h	Wed Dec 05 11:14:28 2007 -0800
    43.3 @@ -0,0 +1,73 @@
    43.4 +/*****************************************************************************
    43.5 + * xenbus.h
    43.6 + *
    43.7 + * Xenbus protocol details.
    43.8 + *
    43.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   43.10 + * of this software and associated documentation files (the "Software"), to
   43.11 + * deal in the Software without restriction, including without limitation the
   43.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   43.13 + * sell copies of the Software, and to permit persons to whom the Software is
   43.14 + * furnished to do so, subject to the following conditions:
   43.15 + *
   43.16 + * The above copyright notice and this permission notice shall be included in
   43.17 + * all copies or substantial portions of the Software.
   43.18 + *
   43.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   43.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   43.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   43.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   43.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   43.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   43.25 + * DEALINGS IN THE SOFTWARE.
   43.26 + *
   43.27 + * Copyright (C) 2005 XenSource Ltd.
   43.28 + */
   43.29 +
   43.30 +#ifndef _XEN_PUBLIC_IO_XENBUS_H
   43.31 +#define _XEN_PUBLIC_IO_XENBUS_H
   43.32 +
   43.33 +/*
   43.34 + * The state of either end of the Xenbus, i.e. the current communication
   43.35 + * status of initialisation across the bus.  States here imply nothing about
   43.36 + * the state of the connection between the driver and the kernel's device
   43.37 + * layers.
   43.38 + */
   43.39 +enum xenbus_state {
   43.40 +    XenbusStateUnknown       = 0,
   43.41 +
   43.42 +    XenbusStateInitialising  = 1,
   43.43 +
   43.44 +    /*
   43.45 +     * InitWait: Finished early initialisation but waiting for information
   43.46 +     * from the peer or hotplug scripts.
   43.47 +     */
   43.48 +    XenbusStateInitWait      = 2,
   43.49 +
   43.50 +    /*
   43.51 +     * Initialised: Waiting for a connection from the peer.
   43.52 +     */
   43.53 +    XenbusStateInitialised   = 3,
   43.54 +
   43.55 +    XenbusStateConnected     = 4,
   43.56 +
   43.57 +    /*
   43.58 +     * Closing: The device is being closed due to an error or an unplug event.
   43.59 +     */
   43.60 +    XenbusStateClosing       = 5,
   43.61 +
   43.62 +    XenbusStateClosed        = 6
   43.63 +};
   43.64 +typedef enum xenbus_state XenbusState;
   43.65 +
   43.66 +#endif /* _XEN_PUBLIC_IO_XENBUS_H */
   43.67 +
   43.68 +/*
   43.69 + * Local variables:
   43.70 + * mode: C
   43.71 + * c-set-style: "BSD"
   43.72 + * c-basic-offset: 4
   43.73 + * tab-width: 4
   43.74 + * indent-tabs-mode: nil
   43.75 + * End:
   43.76 + */
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/common/include/public/io/xs_wire.h	Wed Dec 05 11:14:28 2007 -0800
    44.3 @@ -0,0 +1,121 @@
    44.4 +/*
    44.5 + * Details of the "wire" protocol between Xen Store Daemon and client
    44.6 + * library or guest kernel.
    44.7 + *
    44.8 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    44.9 + * of this software and associated documentation files (the "Software"), to
   44.10 + * deal in the Software without restriction, including without limitation the
   44.11 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   44.12 + * sell copies of the Software, and to permit persons to whom the Software is
   44.13 + * furnished to do so, subject to the following conditions:
   44.14 + *
   44.15 + * The above copyright notice and this permission notice shall be included in
   44.16 + * all copies or substantial portions of the Software.
   44.17 + *
   44.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   44.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   44.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   44.21 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   44.22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   44.23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   44.24 + * DEALINGS IN THE SOFTWARE.
   44.25 + *
   44.26 + * Copyright (C) 2005 Rusty Russell IBM Corporation
   44.27 + */
   44.28 +
   44.29 +#ifndef _XS_WIRE_H
   44.30 +#define _XS_WIRE_H
   44.31 +
   44.32 +enum xsd_sockmsg_type
   44.33 +{
   44.34 +    XS_DEBUG,
   44.35 +    XS_DIRECTORY,
   44.36 +    XS_READ,
   44.37 +    XS_GET_PERMS,
   44.38 +    XS_WATCH,
   44.39 +    XS_UNWATCH,
   44.40 +    XS_TRANSACTION_START,
   44.41 +    XS_TRANSACTION_END,
   44.42 +    XS_INTRODUCE,
   44.43 +    XS_RELEASE,
   44.44 +    XS_GET_DOMAIN_PATH,
   44.45 +    XS_WRITE,
   44.46 +    XS_MKDIR,
   44.47 +    XS_RM,
   44.48 +    XS_SET_PERMS,
   44.49 +    XS_WATCH_EVENT,
   44.50 +    XS_ERROR,
   44.51 +    XS_IS_DOMAIN_INTRODUCED,
   44.52 +    XS_RESUME
   44.53 +};
   44.54 +
   44.55 +#define XS_WRITE_NONE "NONE"
   44.56 +#define XS_WRITE_CREATE "CREATE"
   44.57 +#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
   44.58 +
   44.59 +/* We hand errors as strings, for portability. */
   44.60 +struct xsd_errors
   44.61 +{
   44.62 +    int errnum;
   44.63 +    const char *errstring;
   44.64 +};
   44.65 +#define XSD_ERROR(x) { x, #x }
   44.66 +static struct xsd_errors xsd_errors[]
   44.67 +#if defined(__GNUC__)
   44.68 +__attribute__((unused))
   44.69 +#endif
   44.70 +    = {
   44.71 +    XSD_ERROR(EINVAL),
   44.72 +    XSD_ERROR(EACCES),
   44.73 +    XSD_ERROR(EEXIST),
   44.74 +    XSD_ERROR(EISDIR),
   44.75 +    XSD_ERROR(ENOENT),
   44.76 +    XSD_ERROR(ENOMEM),
   44.77 +    XSD_ERROR(ENOSPC),
   44.78 +    XSD_ERROR(EIO),
   44.79 +    XSD_ERROR(ENOTEMPTY),
   44.80 +    XSD_ERROR(ENOSYS),
   44.81 +    XSD_ERROR(EROFS),
   44.82 +    XSD_ERROR(EBUSY),
   44.83 +    XSD_ERROR(EAGAIN),
   44.84 +    XSD_ERROR(EISCONN)
   44.85 +};
   44.86 +
   44.87 +struct xsd_sockmsg
   44.88 +{
   44.89 +    uint32_t type;  /* XS_??? */
   44.90 +    uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
   44.91 +    uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
   44.92 +    uint32_t len;   /* Length of data following this. */
   44.93 +
   44.94 +    /* Generally followed by nul-terminated string(s). */
   44.95 +};
   44.96 +
   44.97 +enum xs_watch_type
   44.98 +{
   44.99 +    XS_WATCH_PATH = 0,
  44.100 +    XS_WATCH_TOKEN
  44.101 +};
  44.102 +
  44.103 +/* Inter-domain shared memory communications. */
  44.104 +#define XENSTORE_RING_SIZE 1024
  44.105 +typedef uint32_t XENSTORE_RING_IDX;
  44.106 +#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
  44.107 +struct xenstore_domain_interface {
  44.108 +    char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
  44.109 +    char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
  44.110 +    XENSTORE_RING_IDX req_cons, req_prod;
  44.111 +    XENSTORE_RING_IDX rsp_cons, rsp_prod;
  44.112 +};
  44.113 +
  44.114 +#endif /* _XS_WIRE_H */
  44.115 +
  44.116 +/*
  44.117 + * Local variables:
  44.118 + * mode: C
  44.119 + * c-set-style: "BSD"
  44.120 + * c-basic-offset: 4
  44.121 + * tab-width: 4
  44.122 + * indent-tabs-mode: nil
  44.123 + * End:
  44.124 + */
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/common/include/public/kexec.h	Wed Dec 05 11:14:28 2007 -0800
    45.3 @@ -0,0 +1,137 @@
    45.4 +/******************************************************************************
    45.5 + * kexec.h - Public portion
    45.6 + * 
    45.7 + * Xen port written by:
    45.8 + * - Simon 'Horms' Horman <horms@verge.net.au>
    45.9 + * - Magnus Damm <magnus@valinux.co.jp>
   45.10 + */
   45.11 +
   45.12 +#ifndef _XEN_PUBLIC_KEXEC_H
   45.13 +#define _XEN_PUBLIC_KEXEC_H
   45.14 +
   45.15 +
   45.16 +/* This file describes the Kexec / Kdump hypercall interface for Xen.
   45.17 + *
   45.18 + * Kexec under vanilla Linux allows a user to reboot the physical machine 
   45.19 + * into a new user-specified kernel. The Xen port extends this idea
   45.20 + * to allow rebooting of the machine from dom0. When kexec for dom0
   45.21 + * is used to reboot,  both the hypervisor and the domains get replaced
   45.22 + * with some other kernel. It is possible to kexec between vanilla
   45.23 + * Linux and Xen and back again. Xen to Xen works well too.
   45.24 + *
   45.25 + * The hypercall interface for kexec can be divided into three main
   45.26 + * types of hypercall operations:
   45.27 + *
   45.28 + * 1) Range information:
   45.29 + *    This is used by the dom0 kernel to ask the hypervisor about various 
   45.30 + *    address information. This information is needed to allow kexec-tools 
   45.31 + *    to fill in the ELF headers for /proc/vmcore properly.
   45.32 + *
   45.33 + * 2) Load and unload of images:
   45.34 + *    There are no big surprises here, the kexec binary from kexec-tools
   45.35 + *    runs in userspace in dom0. The tool loads/unloads data into the
   45.36 + *    dom0 kernel such as new kernel, initramfs and hypervisor. When
   45.37 + *    loaded the dom0 kernel performs a load hypercall operation, and
   45.38 + *    before releasing all page references the dom0 kernel calls unload.
   45.39 + *
   45.40 + * 3) Kexec operation:
   45.41 + *    This is used to start a previously loaded kernel.
   45.42 + */
   45.43 +
   45.44 +#include "xen.h"
   45.45 +
   45.46 +#if defined(__i386__) || defined(__x86_64__)
   45.47 +#define KEXEC_XEN_NO_PAGES 17
   45.48 +#endif
   45.49 +
   45.50 +/*
   45.51 + * Prototype for this hypercall is:
   45.52 + *  int kexec_op(int cmd, void *args)
   45.53 + * @cmd  == KEXEC_CMD_... 
   45.54 + *          KEXEC operation to perform
   45.55 + * @args == Operation-specific extra arguments (NULL if none).
   45.56 + */
   45.57 +
   45.58 +/*
   45.59 + * Kexec supports two types of operation:
   45.60 + * - kexec into a regular kernel, very similar to a standard reboot
   45.61 + *   - KEXEC_TYPE_DEFAULT is used to specify this type
   45.62 + * - kexec into a special "crash kernel", aka kexec-on-panic
   45.63 + *   - KEXEC_TYPE_CRASH is used to specify this type
   45.64 + *   - parts of our system may be broken at kexec-on-panic time
   45.65 + *     - the code should be kept as simple and self-contained as possible
   45.66 + */
   45.67 +
   45.68 +#define KEXEC_TYPE_DEFAULT 0
   45.69 +#define KEXEC_TYPE_CRASH   1
   45.70 +
   45.71 +
   45.72 +/* The kexec implementation for Xen allows the user to load two
   45.73 + * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH.
   45.74 + * All data needed for a kexec reboot is kept in one xen_kexec_image_t
   45.75 + * per "instance". The data mainly consists of machine address lists to pages
   45.76 + * together with destination addresses. The data in xen_kexec_image_t
   45.77 + * is passed to the "code page" which is one page of code that performs
   45.78 + * the final relocations before jumping to the new kernel.
   45.79 + */
   45.80 + 
   45.81 +typedef struct xen_kexec_image {
   45.82 +#if defined(__i386__) || defined(__x86_64__)
   45.83 +    unsigned long page_list[KEXEC_XEN_NO_PAGES];
   45.84 +#endif
   45.85 +    unsigned long indirection_page;
   45.86 +    unsigned long start_address;
   45.87 +} xen_kexec_image_t;
   45.88 +
   45.89 +/*
   45.90 + * Perform kexec having previously loaded a kexec or kdump kernel
   45.91 + * as appropriate.
   45.92 + * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
   45.93 + */
   45.94 +#define KEXEC_CMD_kexec                 0
   45.95 +typedef struct xen_kexec_exec {
   45.96 +    int type;
   45.97 +} xen_kexec_exec_t;
   45.98 +
   45.99 +/*
  45.100 + * Load/Unload kernel image for kexec or kdump.
  45.101 + * type  == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
  45.102 + * image == relocation information for kexec (ignored for unload) [in]
  45.103 + */
  45.104 +#define KEXEC_CMD_kexec_load            1
  45.105 +#define KEXEC_CMD_kexec_unload          2
  45.106 +typedef struct xen_kexec_load {
  45.107 +    int type;
  45.108 +    xen_kexec_image_t image;
  45.109 +} xen_kexec_load_t;
  45.110 +
  45.111 +#define KEXEC_RANGE_MA_CRASH 0   /* machine address and size of crash area */
  45.112 +#define KEXEC_RANGE_MA_XEN   1   /* machine address and size of Xen itself */
  45.113 +#define KEXEC_RANGE_MA_CPU   2   /* machine address and size of a CPU note */
  45.114 +
  45.115 +/*
  45.116 + * Find the address and size of certain memory areas
  45.117 + * range == KEXEC_RANGE_... [in]
  45.118 + * nr    == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
  45.119 + * size  == number of bytes reserved in window [out]
  45.120 + * start == address of the first byte in the window [out]
  45.121 + */
  45.122 +#define KEXEC_CMD_kexec_get_range       3
  45.123 +typedef struct xen_kexec_range {
  45.124 +    int range;
  45.125 +    int nr;
  45.126 +    unsigned long size;
  45.127 +    unsigned long start;
  45.128 +} xen_kexec_range_t;
  45.129 +
  45.130 +#endif /* _XEN_PUBLIC_KEXEC_H */
  45.131 +
  45.132 +/*
  45.133 + * Local variables:
  45.134 + * mode: C
  45.135 + * c-set-style: "BSD"
  45.136 + * c-basic-offset: 4
  45.137 + * tab-width: 4
  45.138 + * indent-tabs-mode: nil
  45.139 + * End:
  45.140 + */
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/common/include/public/libelf.h	Wed Dec 05 11:14:28 2007 -0800
    46.3 @@ -0,0 +1,241 @@
    46.4 +#ifndef __XC_LIBELF__
    46.5 +#define __XC_LIBELF__ 1
    46.6 +
    46.7 +#if defined(__i386__) || defined(__x86_64) || defined(__ia64__)
    46.8 +#define XEN_ELF_LITTLE_ENDIAN
    46.9 +#elif defined(__powerpc__)
   46.10 +#define XEN_ELF_BIG_ENDIAN
   46.11 +#else
   46.12 +#error define architectural endianness
   46.13 +#endif
   46.14 +
   46.15 +#undef ELFSIZE
   46.16 +#include "elfnote.h"
   46.17 +#include "elfstructs.h"
   46.18 +#include "features.h"
   46.19 +
   46.20 +/* ------------------------------------------------------------------------ */
   46.21 +
   46.22 +typedef union {
   46.23 +    Elf32_Ehdr e32;
   46.24 +    Elf64_Ehdr e64;
   46.25 +} elf_ehdr;
   46.26 +
   46.27 +typedef union {
   46.28 +    Elf32_Phdr e32;
   46.29 +    Elf64_Phdr e64;
   46.30 +} elf_phdr;
   46.31 +
   46.32 +typedef union {
   46.33 +    Elf32_Shdr e32;
   46.34 +    Elf64_Shdr e64;
   46.35 +} elf_shdr;
   46.36 +
   46.37 +typedef union {
   46.38 +    Elf32_Sym e32;
   46.39 +    Elf64_Sym e64;
   46.40 +} elf_sym;
   46.41 +
   46.42 +typedef union {
   46.43 +    Elf32_Rel e32;
   46.44 +    Elf64_Rel e64;
   46.45 +} elf_rel;
   46.46 +
   46.47 +typedef union {
   46.48 +    Elf32_Rela e32;
   46.49 +    Elf64_Rela e64;
   46.50 +} elf_rela;
   46.51 +
   46.52 +typedef union {
   46.53 +    Elf32_Note e32;
   46.54 +    Elf64_Note e64;
   46.55 +} elf_note;
   46.56 +
   46.57 +struct elf_binary {
   46.58 +    /* elf binary */
   46.59 +    const char *image;
   46.60 +    size_t size;
   46.61 +    char class;
   46.62 +    char data;
   46.63 +
   46.64 +    const elf_ehdr *ehdr;
   46.65 +    const char *sec_strtab;
   46.66 +    const elf_shdr *sym_tab;
   46.67 +    const char *sym_strtab;
   46.68 +
   46.69 +    /* loaded to */
   46.70 +    char *dest;
   46.71 +    uint64_t pstart;
   46.72 +    uint64_t pend;
   46.73 +    uint64_t reloc_offset;
   46.74 +
   46.75 +#ifndef __XEN__
   46.76 +    /* misc */
   46.77 +    FILE *log;
   46.78 +#endif
   46.79 +    int verbose;
   46.80 +};
   46.81 +
   46.82 +/* ------------------------------------------------------------------------ */
   46.83 +/* accessing elf header fields                                              */
   46.84 +
   46.85 +#ifdef XEN_ELF_BIG_ENDIAN
   46.86 +# define NATIVE_ELFDATA ELFDATA2MSB
   46.87 +#else
   46.88 +# define NATIVE_ELFDATA ELFDATA2LSB
   46.89 +#endif
   46.90 +
   46.91 +#define elf_32bit(elf) (ELFCLASS32 == (elf)->class)
   46.92 +#define elf_64bit(elf) (ELFCLASS64 == (elf)->class)
   46.93 +#define elf_msb(elf)   (ELFDATA2MSB == (elf)->data)
   46.94 +#define elf_lsb(elf)   (ELFDATA2LSB == (elf)->data)
   46.95 +#define elf_swap(elf)  (NATIVE_ELFDATA != (elf)->data)
   46.96 +
   46.97 +#define elf_uval(elf, str, elem)			\
   46.98 +	((ELFCLASS64 == (elf)->class)			\
   46.99 +	? elf_access_unsigned((elf), (str),		\
  46.100 +		offsetof(typeof(*(str)),e64.elem),	\
  46.101 +		sizeof((str)->e64.elem))		\
  46.102 +	: elf_access_unsigned((elf), (str),		\
  46.103 +		offsetof(typeof(*(str)),e32.elem),	\
  46.104 +		sizeof((str)->e32.elem)))
  46.105 +
  46.106 +#define elf_sval(elf, str, elem)			\
  46.107 +	((ELFCLASS64 == (elf)->class)			\
  46.108 +	? elf_access_signed((elf), (str),		\
  46.109 +		offsetof(typeof(*(str)),e64.elem),	\
  46.110 +		sizeof((str)->e64.elem))		\
  46.111 +	: elf_access_signed((elf), (str),		\
  46.112 +		offsetof(typeof(*(str)),e32.elem),	\
  46.113 +		sizeof((str)->e32.elem)))
  46.114 +
  46.115 +#define elf_size(elf, str)		\
  46.116 +	((ELFCLASS64 == (elf)->class)	\
  46.117 +	? sizeof((str)->e64)		\
  46.118 +	: sizeof((str)->e32))
  46.119 +
  46.120 +uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr,
  46.121 +			     uint64_t offset, size_t size);
  46.122 +int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
  46.123 +			  uint64_t offset, size_t size);
  46.124 +
  46.125 +uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr);
  46.126 +
  46.127 +/* ------------------------------------------------------------------------ */
  46.128 +/* xc_libelf_tools.c                                                        */
  46.129 +
  46.130 +int elf_shdr_count(struct elf_binary *elf);
  46.131 +int elf_phdr_count(struct elf_binary *elf);
  46.132 +
  46.133 +const elf_shdr *elf_shdr_by_name(struct elf_binary *elf, const char *name);
  46.134 +const elf_shdr *elf_shdr_by_index(struct elf_binary *elf, int index);
  46.135 +const elf_phdr *elf_phdr_by_index(struct elf_binary *elf, int index);
  46.136 +
  46.137 +const char *elf_section_name(struct elf_binary *elf, const elf_shdr * shdr);
  46.138 +const void *elf_section_start(struct elf_binary *elf, const elf_shdr * shdr);
  46.139 +const void *elf_section_end(struct elf_binary *elf, const elf_shdr * shdr);
  46.140 +
  46.141 +const void *elf_segment_start(struct elf_binary *elf, const elf_phdr * phdr);
  46.142 +const void *elf_segment_end(struct elf_binary *elf, const elf_phdr * phdr);
  46.143 +
  46.144 +const elf_sym *elf_sym_by_name(struct elf_binary *elf, const char *symbol);
  46.145 +const elf_sym *elf_sym_by_index(struct elf_binary *elf, int index);
  46.146 +
  46.147 +const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
  46.148 +const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
  46.149 +uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
  46.150 +const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note);
  46.151 +
  46.152 +int elf_is_elfbinary(const void *image);
  46.153 +int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);
  46.154 +
  46.155 +/* ------------------------------------------------------------------------ */
  46.156 +/* xc_libelf_loader.c                                                       */
  46.157 +
  46.158 +int elf_init(struct elf_binary *elf, const char *image, size_t size);
  46.159 +#ifdef __XEN__
  46.160 +void elf_set_verbose(struct elf_binary *elf);
  46.161 +#else
  46.162 +void elf_set_logfile(struct elf_binary *elf, FILE * log, int verbose);
  46.163 +#endif
  46.164 +
  46.165 +void elf_parse_binary(struct elf_binary *elf);
  46.166 +void elf_load_binary(struct elf_binary *elf);
  46.167 +
  46.168 +void *elf_get_ptr(struct elf_binary *elf, unsigned long addr);
  46.169 +uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol);
  46.170 +
  46.171 +/* ------------------------------------------------------------------------ */
  46.172 +/* xc_libelf_relocate.c                                                     */
  46.173 +
  46.174 +int elf_reloc(struct elf_binary *elf);
  46.175 +
  46.176 +/* ------------------------------------------------------------------------ */
  46.177 +/* xc_libelf_dominfo.c                                                      */
  46.178 +
  46.179 +#define UNSET_ADDR          ((uint64_t)-1)
  46.180 +
  46.181 +enum xen_elfnote_type {
  46.182 +    XEN_ENT_NONE = 0,
  46.183 +    XEN_ENT_LONG = 1,
  46.184 +    XEN_ENT_STR  = 2
  46.185 +};
  46.186 +
  46.187 +struct xen_elfnote {
  46.188 +    enum xen_elfnote_type type;
  46.189 +    const char *name;
  46.190 +    union {
  46.191 +	const char *str;
  46.192 +	uint64_t num;
  46.193 +    } data;
  46.194 +};
  46.195 +
  46.196 +struct elf_dom_parms {
  46.197 +    /* raw */
  46.198 +    const char *guest_info;
  46.199 +    const void *elf_note_start;
  46.200 +    const void *elf_note_end;
  46.201 +    struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
  46.202 +  
  46.203 +    /* parsed */
  46.204 +    char guest_os[16];
  46.205 +    char guest_ver[16];
  46.206 +    char xen_ver[16];
  46.207 +    char loader[16];
  46.208 +    int pae;
  46.209 +    int bsd_symtab;
  46.210 +    uint64_t virt_base;
  46.211 +    uint64_t virt_entry;
  46.212 +    uint64_t virt_hypercall;
  46.213 +    uint64_t virt_hv_start_low;
  46.214 +    uint64_t elf_paddr_offset;
  46.215 +    uint32_t f_supported[XENFEAT_NR_SUBMAPS];
  46.216 +    uint32_t f_required[XENFEAT_NR_SUBMAPS];
  46.217 +
  46.218 +    /* calculated */
  46.219 +    uint64_t virt_offset;
  46.220 +    uint64_t virt_kstart;
  46.221 +    uint64_t virt_kend;
  46.222 +};
  46.223 +
  46.224 +static inline void elf_xen_feature_set(int nr, uint32_t * addr)
  46.225 +{
  46.226 +    addr[nr >> 5] |= 1 << (nr & 31);
  46.227 +}
  46.228 +static inline int elf_xen_feature_get(int nr, uint32_t * addr)
  46.229 +{
  46.230 +    return !!(addr[nr >> 5] & (1 << (nr & 31)));
  46.231 +}
  46.232 +
  46.233 +int elf_xen_parse_features(const char *features,
  46.234 +			   uint32_t *supported,
  46.235 +			   uint32_t *required);
  46.236 +int elf_xen_parse_note(struct elf_binary *elf,
  46.237 +		       struct elf_dom_parms *parms,
  46.238 +		       const elf_note *note);
  46.239 +int elf_xen_parse_guest_info(struct elf_binary *elf,
  46.240 +			     struct elf_dom_parms *parms);
  46.241 +int elf_xen_parse(struct elf_binary *elf,
  46.242 +		  struct elf_dom_parms *parms);
  46.243 +
  46.244 +#endif /* __XC_LIBELF__ */
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/common/include/public/memory.h	Wed Dec 05 11:14:28 2007 -0800
    47.3 @@ -0,0 +1,281 @@
    47.4 +/******************************************************************************
    47.5 + * memory.h
    47.6 + * 
    47.7 + * Memory reservation and information.
    47.8 + * 
    47.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   47.10 + * of this software and associated documentation files (the "Software"), to
   47.11 + * deal in the Software without restriction, including without limitation the
   47.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   47.13 + * sell copies of the Software, and to permit persons to whom the Software is
   47.14 + * furnished to do so, subject to the following conditions:
   47.15 + *
   47.16 + * The above copyright notice and this permission notice shall be included in
   47.17 + * all copies or substantial portions of the Software.
   47.18 + *
   47.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   47.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   47.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   47.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   47.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   47.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   47.25 + * DEALINGS IN THE SOFTWARE.
   47.26 + *
   47.27 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   47.28 + */
   47.29 +
   47.30 +#ifndef __XEN_PUBLIC_MEMORY_H__
   47.31 +#define __XEN_PUBLIC_MEMORY_H__
   47.32 +
   47.33 +/*
   47.34 + * Increase or decrease the specified domain's memory reservation. Returns the
   47.35 + * number of extents successfully allocated or freed.
   47.36 + * arg == addr of struct xen_memory_reservation.
   47.37 + */
   47.38 +#define XENMEM_increase_reservation 0
   47.39 +#define XENMEM_decrease_reservation 1
   47.40 +#define XENMEM_populate_physmap     6
   47.41 +struct xen_memory_reservation {
   47.42 +
   47.43 +    /*
   47.44 +     * XENMEM_increase_reservation:
   47.45 +     *   OUT: MFN (*not* GMFN) bases of extents that were allocated
   47.46 +     * XENMEM_decrease_reservation:
   47.47 +     *   IN:  GMFN bases of extents to free
   47.48 +     * XENMEM_populate_physmap:
   47.49 +     *   IN:  GPFN bases of extents to populate with memory
   47.50 +     *   OUT: GMFN bases of extents that were allocated
   47.51 +     *   (NB. This command also updates the mach_to_phys translation table)
   47.52 +     */
   47.53 +    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
   47.54 +
   47.55 +    /* Number of extents, and size/alignment of each (2^extent_order pages). */
   47.56 +    xen_ulong_t    nr_extents;
   47.57 +    unsigned int   extent_order;
   47.58 +
   47.59 +    /*
   47.60 +     * Maximum # bits addressable by the user of the allocated region (e.g., 
   47.61 +     * I/O devices often have a 32-bit limitation even in 64-bit systems). If 
   47.62 +     * zero then the user has no addressing restriction.
   47.63 +     * This field is not used by XENMEM_decrease_reservation.
   47.64 +     */
   47.65 +    unsigned int   address_bits;
   47.66 +
   47.67 +    /*
   47.68 +     * Domain whose reservation is being changed.
   47.69 +     * Unprivileged domains can specify only DOMID_SELF.
   47.70 +     */
   47.71 +    domid_t        domid;
   47.72 +};
   47.73 +typedef struct xen_memory_reservation xen_memory_reservation_t;
   47.74 +DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
   47.75 +
   47.76 +/*
   47.77 + * An atomic exchange of memory pages. If return code is zero then
   47.78 + * @out.extent_list provides GMFNs of the newly-allocated memory.
   47.79 + * Returns zero on complete success, otherwise a negative error code.
   47.80 + * On complete success then always @nr_exchanged == @in.nr_extents.
   47.81 + * On partial success @nr_exchanged indicates how much work was done.
   47.82 + */
   47.83 +#define XENMEM_exchange             11
   47.84 +struct xen_memory_exchange {
   47.85 +    /*
   47.86 +     * [IN] Details of memory extents to be exchanged (GMFN bases).
   47.87 +     * Note that @in.address_bits is ignored and unused.
   47.88 +     */
   47.89 +    struct xen_memory_reservation in;
   47.90 +
   47.91 +    /*
   47.92 +     * [IN/OUT] Details of new memory extents.
   47.93 +     * We require that:
   47.94 +     *  1. @in.domid == @out.domid
   47.95 +     *  2. @in.nr_extents  << @in.extent_order == 
   47.96 +     *     @out.nr_extents << @out.extent_order
   47.97 +     *  3. @in.extent_start and @out.extent_start lists must not overlap
   47.98 +     *  4. @out.extent_start lists GPFN bases to be populated
   47.99 +     *  5. @out.extent_start is overwritten with allocated GMFN bases
  47.100 +     */
  47.101 +    struct xen_memory_reservation out;
  47.102 +
  47.103 +    /*
  47.104 +     * [OUT] Number of input extents that were successfully exchanged:
  47.105 +     *  1. The first @nr_exchanged input extents were successfully
  47.106 +     *     deallocated.
  47.107 +     *  2. The corresponding first entries in the output extent list correctly
  47.108 +     *     indicate the GMFNs that were successfully exchanged.
  47.109 +     *  3. All other input and output extents are untouched.
  47.110 +     *  4. If not all input exents are exchanged then the return code of this
  47.111 +     *     command will be non-zero.
  47.112 +     *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
  47.113 +     */
  47.114 +    xen_ulong_t nr_exchanged;
  47.115 +};
  47.116 +typedef struct xen_memory_exchange xen_memory_exchange_t;
  47.117 +DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
  47.118 +
  47.119 +/*
  47.120 + * Returns the maximum machine frame number of mapped RAM in this system.
  47.121 + * This command always succeeds (it never returns an error code).
  47.122 + * arg == NULL.
  47.123 + */
  47.124 +#define XENMEM_maximum_ram_page     2
  47.125 +
  47.126 +/*
  47.127 + * Returns the current or maximum memory reservation, in pages, of the
  47.128 + * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
  47.129 + * arg == addr of domid_t.
  47.130 + */
  47.131 +#define XENMEM_current_reservation  3
  47.132 +#define XENMEM_maximum_reservation  4
  47.133 +
  47.134 +/*
  47.135 + * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
  47.136 + */
  47.137 +#define XENMEM_maximum_gpfn         14
  47.138 +
  47.139 +/*
  47.140 + * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
  47.141 + * mapping table. Architectures which do not have a m2p table do not implement
  47.142 + * this command.
  47.143 + * arg == addr of xen_machphys_mfn_list_t.
  47.144 + */
  47.145 +#define XENMEM_machphys_mfn_list    5
  47.146 +struct xen_machphys_mfn_list {
  47.147 +    /*
  47.148 +     * Size of the 'extent_start' array. Fewer entries will be filled if the
  47.149 +     * machphys table is smaller than max_extents * 2MB.
  47.150 +     */
  47.151 +    unsigned int max_extents;
  47.152 +
  47.153 +    /*
  47.154 +     * Pointer to buffer to fill with list of extent starts. If there are
  47.155 +     * any large discontiguities in the machine address space, 2MB gaps in
  47.156 +     * the machphys table will be represented by an MFN base of zero.
  47.157 +     */
  47.158 +    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
  47.159 +
  47.160 +    /*
  47.161 +     * Number of extents written to the above array. This will be smaller
  47.162 +     * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
  47.163 +     */
  47.164 +    unsigned int nr_extents;
  47.165 +};
  47.166 +typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
  47.167 +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
  47.168 +
  47.169 +/*
  47.170 + * Returns the location in virtual address space of the machine_to_phys
  47.171 + * mapping table. Architectures which do not have a m2p table, or which do not
  47.172 + * map it by default into guest address space, do not implement this command.
  47.173 + * arg == addr of xen_machphys_mapping_t.
  47.174 + */
  47.175 +#define XENMEM_machphys_mapping     12
  47.176 +struct xen_machphys_mapping {
  47.177 +    xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */
  47.178 +    xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */
  47.179 +};
  47.180 +typedef struct xen_machphys_mapping xen_machphys_mapping_t;
  47.181 +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
  47.182 +
  47.183 +/*
  47.184 + * Sets the GPFN at which a particular page appears in the specified guest's
  47.185 + * pseudophysical address space.
  47.186 + * arg == addr of xen_add_to_physmap_t.
  47.187 + */
  47.188 +#define XENMEM_add_to_physmap      7
  47.189 +struct xen_add_to_physmap {
  47.190 +    /* Which domain to change the mapping for. */
  47.191 +    domid_t domid;
  47.192 +
  47.193 +    /* Source mapping space. */
  47.194 +#define XENMAPSPACE_shared_info 0 /* shared info page */
  47.195 +#define XENMAPSPACE_grant_table 1 /* grant table page */
  47.196 +    unsigned int space;
  47.197 +
  47.198 +    /* Index into source mapping space. */
  47.199 +    xen_ulong_t idx;
  47.200 +
  47.201 +    /* GPFN where the source mapping page should appear. */
  47.202 +    xen_pfn_t     gpfn;
  47.203 +};
  47.204 +typedef struct xen_add_to_physmap xen_add_to_physmap_t;
  47.205 +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
  47.206 +
  47.207 +/*
  47.208 + * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
  47.209 + * code on failure. This call only works for auto-translated guests.
  47.210 + */
  47.211 +#define XENMEM_translate_gpfn_list  8
  47.212 +struct xen_translate_gpfn_list {
  47.213 +    /* Which domain to translate for? */
  47.214 +    domid_t domid;
  47.215 +
  47.216 +    /* Length of list. */
  47.217 +    xen_ulong_t nr_gpfns;
  47.218 +
  47.219 +    /* List of GPFNs to translate. */
  47.220 +    XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
  47.221 +
  47.222 +    /*
  47.223 +     * Output list to contain MFN translations. May be the same as the input
  47.224 +     * list (in which case each input GPFN is overwritten with the output MFN).
  47.225 +     */
  47.226 +    XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
  47.227 +};
  47.228 +typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
  47.229 +DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
  47.230 +
  47.231 +/*
  47.232 + * Returns the pseudo-physical memory map as it was when the domain
  47.233 + * was started (specified by XENMEM_set_memory_map).
  47.234 + * arg == addr of xen_memory_map_t.
  47.235 + */
  47.236 +#define XENMEM_memory_map           9
  47.237 +struct xen_memory_map {
  47.238 +    /*
  47.239 +     * On call the number of entries which can be stored in buffer. On
  47.240 +     * return the number of entries which have been stored in
  47.241 +     * buffer.
  47.242 +     */
  47.243 +    unsigned int nr_entries;
  47.244 +
  47.245 +    /*
  47.246 +     * Entries in the buffer are in the same format as returned by the
  47.247 +     * BIOS INT 0x15 EAX=0xE820 call.
  47.248 +     */
  47.249 +    XEN_GUEST_HANDLE(void) buffer;
  47.250 +};
  47.251 +typedef struct xen_memory_map xen_memory_map_t;
  47.252 +DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
  47.253 +
  47.254 +/*
  47.255 + * Returns the real physical memory map. Passes the same structure as
  47.256 + * XENMEM_memory_map.
  47.257 + * arg == addr of xen_memory_map_t.
  47.258 + */
  47.259 +#define XENMEM_machine_memory_map   10
  47.260 +
  47.261 +/*
  47.262 + * Set the pseudo-physical memory map of a domain, as returned by
  47.263 + * XENMEM_memory_map.
  47.264 + * arg == addr of xen_foreign_memory_map_t.
  47.265 + */
  47.266 +#define XENMEM_set_memory_map       13
  47.267 +struct xen_foreign_memory_map {
  47.268 +    domid_t domid;
  47.269 +    struct xen_memory_map map;
  47.270 +};
  47.271 +typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
  47.272 +DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
  47.273 +
  47.274 +#endif /* __XEN_PUBLIC_MEMORY_H__ */
  47.275 +
  47.276 +/*
  47.277 + * Local variables:
  47.278 + * mode: C
  47.279 + * c-set-style: "BSD"
  47.280 + * c-basic-offset: 4
  47.281 + * tab-width: 4
  47.282 + * indent-tabs-mode: nil
  47.283 + * End:
  47.284 + */
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/common/include/public/nmi.h	Wed Dec 05 11:14:28 2007 -0800
    48.3 @@ -0,0 +1,78 @@
    48.4 +/******************************************************************************
    48.5 + * nmi.h
    48.6 + * 
    48.7 + * NMI callback registration and reason codes.
    48.8 + * 
    48.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   48.10 + * of this software and associated documentation files (the "Software"), to
   48.11 + * deal in the Software without restriction, including without limitation the
   48.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   48.13 + * sell copies of the Software, and to permit persons to whom the Software is
   48.14 + * furnished to do so, subject to the following conditions:
   48.15 + *
   48.16 + * The above copyright notice and this permission notice shall be included in
   48.17 + * all copies or substantial portions of the Software.
   48.18 + *
   48.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   48.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   48.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   48.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   48.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   48.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   48.25 + * DEALINGS IN THE SOFTWARE.
   48.26 + *
   48.27 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   48.28 + */
   48.29 +
   48.30 +#ifndef __XEN_PUBLIC_NMI_H__
   48.31 +#define __XEN_PUBLIC_NMI_H__
   48.32 +
   48.33 +/*
   48.34 + * NMI reason codes:
   48.35 + * Currently these are x86-specific, stored in arch_shared_info.nmi_reason.
   48.36 + */
   48.37 + /* I/O-check error reported via ISA port 0x61, bit 6. */
   48.38 +#define _XEN_NMIREASON_io_error     0
   48.39 +#define XEN_NMIREASON_io_error      (1UL << _XEN_NMIREASON_io_error)
   48.40 + /* Parity error reported via ISA port 0x61, bit 7. */
   48.41 +#define _XEN_NMIREASON_parity_error 1
   48.42 +#define XEN_NMIREASON_parity_error  (1UL << _XEN_NMIREASON_parity_error)
   48.43 + /* Unknown hardware-generated NMI. */
   48.44 +#define _XEN_NMIREASON_unknown      2
   48.45 +#define XEN_NMIREASON_unknown       (1UL << _XEN_NMIREASON_unknown)
   48.46 +
   48.47 +/*
   48.48 + * long nmi_op(unsigned int cmd, void *arg)
   48.49 + * NB. All ops return zero on success, else a negative error code.
   48.50 + */
   48.51 +
   48.52 +/*
   48.53 + * Register NMI callback for this (calling) VCPU. Currently this only makes
   48.54 + * sense for domain 0, vcpu 0. All other callers will be returned EINVAL.
   48.55 + * arg == pointer to xennmi_callback structure.
   48.56 + */
   48.57 +#define XENNMI_register_callback   0
   48.58 +struct xennmi_callback {
   48.59 +    unsigned long handler_address;
   48.60 +    unsigned long pad;
   48.61 +};
   48.62 +typedef struct xennmi_callback xennmi_callback_t;
   48.63 +DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
   48.64 +
   48.65 +/*
   48.66 + * Deregister NMI callback for this (calling) VCPU.
   48.67 + * arg == NULL.
   48.68 + */
   48.69 +#define XENNMI_unregister_callback 1
   48.70 +
   48.71 +#endif /* __XEN_PUBLIC_NMI_H__ */
   48.72 +
   48.73 +/*
   48.74 + * Local variables:
   48.75 + * mode: C
   48.76 + * c-set-style: "BSD"
   48.77 + * c-basic-offset: 4
   48.78 + * tab-width: 4
   48.79 + * indent-tabs-mode: nil
   48.80 + * End:
   48.81 + */
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/common/include/public/physdev.h	Wed Dec 05 11:14:28 2007 -0800
    49.3 @@ -0,0 +1,169 @@
    49.4 +/*
    49.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    49.6 + * of this software and associated documentation files (the "Software"), to
    49.7 + * deal in the Software without restriction, including without limitation the
    49.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    49.9 + * sell copies of the Software, and to permit persons to whom the Software is
   49.10 + * furnished to do so, subject to the following conditions:
   49.11 + *
   49.12 + * The above copyright notice and this permission notice shall be included in
   49.13 + * all copies or substantial portions of the Software.
   49.14 + *
   49.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   49.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   49.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   49.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   49.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   49.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   49.21 + * DEALINGS IN THE SOFTWARE.
   49.22 + */
   49.23 +
   49.24 +#ifndef __XEN_PUBLIC_PHYSDEV_H__
   49.25 +#define __XEN_PUBLIC_PHYSDEV_H__
   49.26 +
   49.27 +/*
   49.28 + * Prototype for this hypercall is:
   49.29 + *  int physdev_op(int cmd, void *args)
   49.30 + * @cmd  == PHYSDEVOP_??? (physdev operation).
   49.31 + * @args == Operation-specific extra arguments (NULL if none).
   49.32 + */
   49.33 +
   49.34 +/*
   49.35 + * Notify end-of-interrupt (EOI) for the specified IRQ.
   49.36 + * @arg == pointer to physdev_eoi structure.
   49.37 + */
   49.38 +#define PHYSDEVOP_eoi                   12
   49.39 +struct physdev_eoi {
   49.40 +    /* IN */
   49.41 +    uint32_t irq;
   49.42 +};
   49.43 +typedef struct physdev_eoi physdev_eoi_t;
   49.44 +DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
   49.45 +
   49.46 +/*
   49.47 + * Query the status of an IRQ line.
   49.48 + * @arg == pointer to physdev_irq_status_query structure.
   49.49 + */
   49.50 +#define PHYSDEVOP_irq_status_query       5
   49.51 +struct physdev_irq_status_query {
   49.52 +    /* IN */
   49.53 +    uint32_t irq;
   49.54 +    /* OUT */
   49.55 +    uint32_t flags; /* XENIRQSTAT_* */
   49.56 +};
   49.57 +typedef struct physdev_irq_status_query physdev_irq_status_query_t;
   49.58 +DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
   49.59 +
   49.60 +/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
   49.61 +#define _XENIRQSTAT_needs_eoi   (0)
   49.62 +#define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
   49.63 +
   49.64 +/* IRQ shared by multiple guests? */
   49.65 +#define _XENIRQSTAT_shared      (1)
   49.66 +#define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
   49.67 +
   49.68 +/*
   49.69 + * Set the current VCPU's I/O privilege level.
   49.70 + * @arg == pointer to physdev_set_iopl structure.
   49.71 + */
   49.72 +#define PHYSDEVOP_set_iopl               6
   49.73 +struct physdev_set_iopl {
   49.74 +    /* IN */
   49.75 +    uint32_t iopl;
   49.76 +};
   49.77 +typedef struct physdev_set_iopl physdev_set_iopl_t;
   49.78 +DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
   49.79 +
   49.80 +/*
   49.81 + * Set the current VCPU's I/O-port permissions bitmap.
   49.82 + * @arg == pointer to physdev_set_iobitmap structure.
   49.83 + */
   49.84 +#define PHYSDEVOP_set_iobitmap           7
   49.85 +struct physdev_set_iobitmap {
   49.86 +    /* IN */
   49.87 +    XEN_GUEST_HANDLE_00030205(uint8_t) bitmap;
   49.88 +    uint32_t nr_ports;
   49.89 +};
   49.90 +typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
   49.91 +DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
   49.92 +
   49.93 +/*
   49.94 + * Read or write an IO-APIC register.
   49.95 + * @arg == pointer to physdev_apic structure.
   49.96 + */
   49.97 +#define PHYSDEVOP_apic_read              8
   49.98 +#define PHYSDEVOP_apic_write             9
   49.99 +struct physdev_apic {
  49.100 +    /* IN */
  49.101 +    unsigned long apic_physbase;
  49.102 +    uint32_t reg;
  49.103 +    /* IN or OUT */
  49.104 +    uint32_t value;
  49.105 +};
  49.106 +typedef struct physdev_apic physdev_apic_t;
  49.107 +DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
  49.108 +
  49.109 +/*
  49.110 + * Allocate or free a physical upcall vector for the specified IRQ line.
  49.111 + * @arg == pointer to physdev_irq structure.
  49.112 + */
  49.113 +#define PHYSDEVOP_alloc_irq_vector      10
  49.114 +#define PHYSDEVOP_free_irq_vector       11
  49.115 +struct physdev_irq {
  49.116 +    /* IN */
  49.117 +    uint32_t irq;
  49.118 +    /* IN or OUT */
  49.119 +    uint32_t vector;
  49.120 +};
  49.121 +typedef struct physdev_irq physdev_irq_t;
  49.122 +DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
  49.123 +
  49.124 +/*
  49.125 + * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  49.126 + * hypercall since 0x00030202.
  49.127 + */
  49.128 +struct physdev_op {
  49.129 +    uint32_t cmd;
  49.130 +    union {
  49.131 +        struct physdev_irq_status_query      irq_status_query;
  49.132 +        struct physdev_set_iopl              set_iopl;
  49.133 +        struct physdev_set_iobitmap          set_iobitmap;
  49.134 +        struct physdev_apic                  apic_op;
  49.135 +        struct physdev_irq                   irq_op;
  49.136 +    } u;
  49.137 +};
  49.138 +typedef struct physdev_op physdev_op_t;
  49.139 +DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
  49.140 +
  49.141 +/*
  49.142 + * Notify that some PIRQ-bound event channels have been unmasked.
  49.143 + * ** This command is obsolete since interface version 0x00030202 and is **
  49.144 + * ** unsupported by newer versions of Xen.                              **
  49.145 + */
  49.146 +#define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
  49.147 +
  49.148 +/*
  49.149 + * These all-capitals physdev operation names are superceded by the new names
  49.150 + * (defined above) since interface version 0x00030202.
  49.151 + */
  49.152 +#define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
  49.153 +#define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
  49.154 +#define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
  49.155 +#define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
  49.156 +#define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
  49.157 +#define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
  49.158 +#define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
  49.159 +#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
  49.160 +#define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
  49.161 +
  49.162 +#endif /* __XEN_PUBLIC_PHYSDEV_H__ */
  49.163 +
  49.164 +/*
  49.165 + * Local variables:
  49.166 + * mode: C
  49.167 + * c-set-style: "BSD"
  49.168 + * c-basic-offset: 4
  49.169 + * tab-width: 4
  49.170 + * indent-tabs-mode: nil
  49.171 + * End:
  49.172 + */
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/common/include/public/platform.h	Wed Dec 05 11:14:28 2007 -0800
    50.3 @@ -0,0 +1,183 @@
    50.4 +/******************************************************************************
    50.5 + * platform.h
    50.6 + * 
    50.7 + * Hardware platform operations. Intended for use by domain-0 kernel.
    50.8 + * 
    50.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   50.10 + * of this software and associated documentation files (the "Software"), to
   50.11 + * deal in the Software without restriction, including without limitation the
   50.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   50.13 + * sell copies of the Software, and to permit persons to whom the Software is
   50.14 + * furnished to do so, subject to the following conditions:
   50.15 + *
   50.16 + * The above copyright notice and this permission notice shall be included in
   50.17 + * all copies or substantial portions of the Software.
   50.18 + *
   50.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   50.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   50.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   50.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   50.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   50.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   50.25 + * DEALINGS IN THE SOFTWARE.
   50.26 + *
   50.27 + * Copyright (c) 2002-2006, K Fraser
   50.28 + */
   50.29 +
   50.30 +#ifndef __XEN_PUBLIC_PLATFORM_H__
   50.31 +#define __XEN_PUBLIC_PLATFORM_H__
   50.32 +
   50.33 +#include "xen.h"
   50.34 +
   50.35 +#define XENPF_INTERFACE_VERSION 0x03000001
   50.36 +
   50.37 +/*
   50.38 + * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
   50.39 + * 1 January, 1970 if the current system time was <system_time>.
   50.40 + */
   50.41 +#define XENPF_settime             17
   50.42 +struct xenpf_settime {
   50.43 +    /* IN variables. */
   50.44 +    uint32_t secs;
   50.45 +    uint32_t nsecs;
   50.46 +    uint64_t system_time;
   50.47 +};
   50.48 +typedef struct xenpf_settime xenpf_settime_t;
   50.49 +DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
   50.50 +
   50.51 +/*
   50.52 + * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
   50.53 + * On x86, @type is an architecture-defined MTRR memory type.
   50.54 + * On success, returns the MTRR that was used (@reg) and a handle that can
   50.55 + * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
   50.56 + * (x86-specific).
   50.57 + */
   50.58 +#define XENPF_add_memtype         31
   50.59 +struct xenpf_add_memtype {
   50.60 +    /* IN variables. */
   50.61 +    xen_pfn_t mfn;
   50.62 +    uint64_t nr_mfns;
   50.63 +    uint32_t type;
   50.64 +    /* OUT variables. */
   50.65 +    uint32_t handle;
   50.66 +    uint32_t reg;
   50.67 +};
   50.68 +typedef struct xenpf_add_memtype xenpf_add_memtype_t;
   50.69 +DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
   50.70 +
   50.71 +/*
   50.72 + * Tear down an existing memory-range type. If @handle is remembered then it
   50.73 + * should be passed in to accurately tear down the correct setting (in case
   50.74 + * of overlapping memory regions with differing types). If it is not known
   50.75 + * then @handle should be set to zero. In all cases @reg must be set.
   50.76 + * (x86-specific).
   50.77 + */
   50.78 +#define XENPF_del_memtype         32
   50.79 +struct xenpf_del_memtype {
   50.80 +    /* IN variables. */
   50.81 +    uint32_t handle;
   50.82 +    uint32_t reg;
   50.83 +};
   50.84 +typedef struct xenpf_del_memtype xenpf_del_memtype_t;
   50.85 +DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
   50.86 +
   50.87 +/* Read current type of an MTRR (x86-specific). */
   50.88 +#define XENPF_read_memtype        33
   50.89 +struct xenpf_read_memtype {
   50.90 +    /* IN variables. */
   50.91 +    uint32_t reg;
   50.92 +    /* OUT variables. */
   50.93 +    xen_pfn_t mfn;
   50.94 +    uint64_t nr_mfns;
   50.95 +    uint32_t type;
   50.96 +};
   50.97 +typedef struct xenpf_read_memtype xenpf_read_memtype_t;
   50.98 +DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
   50.99 +
  50.100 +#define XENPF_microcode_update    35
  50.101 +struct xenpf_microcode_update {
  50.102 +    /* IN variables. */
  50.103 +    XEN_GUEST_HANDLE(void) data;      /* Pointer to microcode data */
  50.104 +    uint32_t length;                  /* Length of microcode data. */
  50.105 +};
  50.106 +typedef struct xenpf_microcode_update xenpf_microcode_update_t;
  50.107 +DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
  50.108 +
  50.109 +#define XENPF_platform_quirk      39
  50.110 +#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
  50.111 +#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
  50.112 +#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
  50.113 +struct xenpf_platform_quirk {
  50.114 +    /* IN variables. */
  50.115 +    uint32_t quirk_id;
  50.116 +};
  50.117 +typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
  50.118 +DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
  50.119 +
  50.120 +#define XENPF_firmware_info       50
  50.121 +#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
  50.122 +#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
  50.123 +#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
  50.124 +struct xenpf_firmware_info {
  50.125 +    /* IN variables. */
  50.126 +    uint32_t type;
  50.127 +    uint32_t index;
  50.128 +    /* OUT variables. */
  50.129 +    union {
  50.130 +        struct {
  50.131 +            /* Int13, Fn48: Check Extensions Present. */
  50.132 +            uint8_t device;                   /* %dl: bios device number */
  50.133 +            uint8_t version;                  /* %ah: major version      */
  50.134 +            uint16_t interface_support;       /* %cx: support bitmap     */
  50.135 +            /* Int13, Fn08: Legacy Get Device Parameters. */
  50.136 +            uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
  50.137 +            uint8_t legacy_max_head;          /* %dh: max head #         */
  50.138 +            uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
  50.139 +            /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
  50.140 +            /* NB. First uint16_t of buffer must be set to buffer size.      */
  50.141 +            XEN_GUEST_HANDLE(void) edd_params;
  50.142 +        } disk_info; /* XEN_FW_DISK_INFO */
  50.143 +        struct {
  50.144 +            uint8_t device;                   /* bios device number  */
  50.145 +            uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
  50.146 +        } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
  50.147 +        struct {
  50.148 +            /* Int10, AX=4F15: Get EDID info. */
  50.149 +            uint8_t capabilities;
  50.150 +            uint8_t edid_transfer_time;
  50.151 +            /* must refer to 128-byte buffer */
  50.152 +            XEN_GUEST_HANDLE(uint8_t) edid;
  50.153 +        } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
  50.154 +    } u;
  50.155 +};
  50.156 +typedef struct xenpf_firmware_info xenpf_firmware_info_t;
  50.157 +DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
  50.158 +
  50.159 +struct xen_platform_op {
  50.160 +    uint32_t cmd;
  50.161 +    uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
  50.162 +    union {
  50.163 +        struct xenpf_settime           settime;
  50.164 +        struct xenpf_add_memtype       add_memtype;
  50.165 +        struct xenpf_del_memtype       del_memtype;
  50.166 +        struct xenpf_read_memtype      read_memtype;
  50.167 +        struct xenpf_microcode_update  microcode;
  50.168 +        struct xenpf_platform_quirk    platform_quirk;
  50.169 +        struct xenpf_firmware_info     firmware_info;
  50.170 +        uint8_t                        pad[128];
  50.171 +    } u;
  50.172 +};
  50.173 +typedef struct xen_platform_op xen_platform_op_t;
  50.174 +DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
  50.175 +
  50.176 +#endif /* __XEN_PUBLIC_PLATFORM_H__ */
  50.177 +
  50.178 +/*
  50.179 + * Local variables:
  50.180 + * mode: C
  50.181 + * c-set-style: "BSD"
  50.182 + * c-basic-offset: 4
  50.183 + * tab-width: 4
  50.184 + * indent-tabs-mode: nil
  50.185 + * End:
  50.186 + */
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/common/include/public/sched.h	Wed Dec 05 11:14:28 2007 -0800
    51.3 @@ -0,0 +1,121 @@
    51.4 +/******************************************************************************
    51.5 + * sched.h
    51.6 + * 
    51.7 + * Scheduler state interactions
    51.8 + * 
    51.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   51.10 + * of this software and associated documentation files (the "Software"), to
   51.11 + * deal in the Software without restriction, including without limitation the
   51.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   51.13 + * sell copies of the Software, and to permit persons to whom the Software is
   51.14 + * furnished to do so, subject to the following conditions:
   51.15 + *
   51.16 + * The above copyright notice and this permission notice shall be included in
   51.17 + * all copies or substantial portions of the Software.
   51.18 + *
   51.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   51.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   51.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   51.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   51.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   51.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   51.25 + * DEALINGS IN THE SOFTWARE.
   51.26 + *
   51.27 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   51.28 + */
   51.29 +
   51.30 +#ifndef __XEN_PUBLIC_SCHED_H__
   51.31 +#define __XEN_PUBLIC_SCHED_H__
   51.32 +
   51.33 +#include "event_channel.h"
   51.34 +
   51.35 +/*
   51.36 + * The prototype for this hypercall is:
   51.37 + *  long sched_op(int cmd, void *arg)
   51.38 + * @cmd == SCHEDOP_??? (scheduler operation).
   51.39 + * @arg == Operation-specific extra argument(s), as described below.
   51.40 + * 
   51.41 + * Versions of Xen prior to 3.0.2 provided only the following legacy version
   51.42 + * of this hypercall, supporting only the commands yield, block and shutdown:
   51.43 + *  long sched_op(int cmd, unsigned long arg)
   51.44 + * @cmd == SCHEDOP_??? (scheduler operation).
   51.45 + * @arg == 0               (SCHEDOP_yield and SCHEDOP_block)
   51.46 + *      == SHUTDOWN_* code (SCHEDOP_shutdown)
   51.47 + * This legacy version is available to new guests as sched_op_compat().
   51.48 + */
   51.49 +
   51.50 +/*
   51.51 + * Voluntarily yield the CPU.
   51.52 + * @arg == NULL.
   51.53 + */
   51.54 +#define SCHEDOP_yield       0
   51.55 +
   51.56 +/*
   51.57 + * Block execution of this VCPU until an event is received for processing.
   51.58 + * If called with event upcalls masked, this operation will atomically
   51.59 + * reenable event delivery and check for pending events before blocking the
   51.60 + * VCPU. This avoids a "wakeup waiting" race.
   51.61 + * @arg == NULL.
   51.62 + */
   51.63 +#define SCHEDOP_block       1
   51.64 +
   51.65 +/*
   51.66 + * Halt execution of this domain (all VCPUs) and notify the system controller.
   51.67 + * @arg == pointer to sched_shutdown structure.
   51.68 + */
   51.69 +#define SCHEDOP_shutdown    2
   51.70 +struct sched_shutdown {
   51.71 +    unsigned int reason; /* SHUTDOWN_* */
   51.72 +};
   51.73 +typedef struct sched_shutdown sched_shutdown_t;
   51.74 +DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
   51.75 +
   51.76 +/*
   51.77 + * Poll a set of event-channel ports. Return when one or more are pending. An
   51.78 + * optional timeout may be specified.
   51.79 + * @arg == pointer to sched_poll structure.
   51.80 + */
   51.81 +#define SCHEDOP_poll        3
   51.82 +struct sched_poll {
   51.83 +    XEN_GUEST_HANDLE(evtchn_port_t) ports;
   51.84 +    unsigned int nr_ports;
   51.85 +    uint64_t timeout;
   51.86 +};
   51.87 +typedef struct sched_poll sched_poll_t;
   51.88 +DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
   51.89 +
   51.90 +/*
   51.91 + * Declare a shutdown for another domain. The main use of this function is
   51.92 + * in interpreting shutdown requests and reasons for fully-virtualized
   51.93 + * domains.  A para-virtualized domain may use SCHEDOP_shutdown directly.
   51.94 + * @arg == pointer to sched_remote_shutdown structure.
   51.95 + */
   51.96 +#define SCHEDOP_remote_shutdown        4
   51.97 +struct sched_remote_shutdown {
   51.98 +    domid_t domain_id;         /* Remote domain ID */
   51.99 +    unsigned int reason;       /* SHUTDOWN_xxx reason */
  51.100 +};
  51.101 +typedef struct sched_remote_shutdown sched_remote_shutdown_t;
  51.102 +DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
  51.103 +
  51.104 +/*
  51.105 + * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
  51.106 + * software to determine the appropriate action. For the most part, Xen does
  51.107 + * not care about the shutdown code.
  51.108 + */
  51.109 +#define SHUTDOWN_poweroff   0  /* Domain exited normally. Clean up and kill. */
  51.110 +#define SHUTDOWN_reboot     1  /* Clean up, kill, and then restart.          */
  51.111 +#define SHUTDOWN_suspend    2  /* Clean up, save suspend info, kill.         */
  51.112 +#define SHUTDOWN_crash      3  /* Tell controller we've crashed.             */
  51.113 +
  51.114 +#endif /* __XEN_PUBLIC_SCHED_H__ */
  51.115 +
  51.116 +/*
  51.117 + * Local variables:
  51.118 + * mode: C
  51.119 + * c-set-style: "BSD"
  51.120 + * c-basic-offset: 4
  51.121 + * tab-width: 4
  51.122 + * indent-tabs-mode: nil
  51.123 + * End:
  51.124 + */
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/common/include/public/sysctl.h	Wed Dec 05 11:14:28 2007 -0800
    52.3 @@ -0,0 +1,198 @@
    52.4 +/******************************************************************************
    52.5 + * sysctl.h
    52.6 + * 
    52.7 + * System management operations. For use by node control stack.
    52.8 + * 
    52.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   52.10 + * of this software and associated documentation files (the "Software"), to
   52.11 + * deal in the Software without restriction, including without limitation the
   52.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   52.13 + * sell copies of the Software, and to permit persons to whom the Software is
   52.14 + * furnished to do so, subject to the following conditions:
   52.15 + *
   52.16 + * The above copyright notice and this permission notice shall be included in
   52.17 + * all copies or substantial portions of the Software.
   52.18 + *
   52.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   52.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   52.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   52.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   52.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   52.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   52.25 + * DEALINGS IN THE SOFTWARE.
   52.26 + *
   52.27 + * Copyright (c) 2002-2006, K Fraser
   52.28 + */
   52.29 +
   52.30 +#ifndef __XEN_PUBLIC_SYSCTL_H__
   52.31 +#define __XEN_PUBLIC_SYSCTL_H__
   52.32 +
   52.33 +#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
   52.34 +#error "sysctl operations are intended for use by node control tools only"
   52.35 +#endif
   52.36 +
   52.37 +#include "xen.h"
   52.38 +#include "domctl.h"
   52.39 +
   52.40 +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000003
   52.41 +
   52.42 +/*
   52.43 + * Read console content from Xen buffer ring.
   52.44 + */
   52.45 +#define XEN_SYSCTL_readconsole       1
   52.46 +struct xen_sysctl_readconsole {
   52.47 +    /* IN variables. */
   52.48 +    uint32_t clear;                /* Non-zero -> clear after reading. */
   52.49 +    XEN_GUEST_HANDLE_64(char) buffer; /* Buffer start */
   52.50 +    /* IN/OUT variables. */
   52.51 +    uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
   52.52 +};
   52.53 +typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
   52.54 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
   52.55 +
   52.56 +/* Get trace buffers machine base address */
   52.57 +#define XEN_SYSCTL_tbuf_op           2
   52.58 +struct xen_sysctl_tbuf_op {
   52.59 +    /* IN variables */
   52.60 +#define XEN_SYSCTL_TBUFOP_get_info     0
   52.61 +#define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
   52.62 +#define XEN_SYSCTL_TBUFOP_set_evt_mask 2
   52.63 +#define XEN_SYSCTL_TBUFOP_set_size     3
   52.64 +#define XEN_SYSCTL_TBUFOP_enable       4
   52.65 +#define XEN_SYSCTL_TBUFOP_disable      5
   52.66 +    uint32_t cmd;
   52.67 +    /* IN/OUT variables */
   52.68 +    struct xenctl_cpumap cpu_mask;
   52.69 +    uint32_t             evt_mask;
   52.70 +    /* OUT variables */
   52.71 +    uint64_aligned_t buffer_mfn;
   52.72 +    uint32_t size;
   52.73 +};
   52.74 +typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
   52.75 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
   52.76 +
   52.77 +/*
   52.78 + * Get physical information about the host machine
   52.79 + */
   52.80 +#define XEN_SYSCTL_physinfo          3
   52.81 +struct xen_sysctl_physinfo {
   52.82 +    uint32_t threads_per_core;
   52.83 +    uint32_t cores_per_socket;
   52.84 +    uint32_t sockets_per_node;
   52.85 +    uint32_t nr_nodes;
   52.86 +    uint32_t cpu_khz;
   52.87 +    uint64_aligned_t total_pages;
   52.88 +    uint64_aligned_t free_pages;
   52.89 +    uint64_aligned_t scrub_pages;
   52.90 +    uint32_t hw_cap[8];
   52.91 +};
   52.92 +typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
   52.93 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
   52.94 +
   52.95 +/*
   52.96 + * Get the ID of the current scheduler.
   52.97 + */
   52.98 +#define XEN_SYSCTL_sched_id          4
   52.99 +struct xen_sysctl_sched_id {
  52.100 +    /* OUT variable */
  52.101 +    uint32_t sched_id;
  52.102 +};
  52.103 +typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
  52.104 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
  52.105 +
  52.106 +/* Interface for controlling Xen software performance counters. */
  52.107 +#define XEN_SYSCTL_perfc_op          5
  52.108 +/* Sub-operations: */
  52.109 +#define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
  52.110 +#define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
  52.111 +struct xen_sysctl_perfc_desc {
  52.112 +    char         name[80];             /* name of perf counter */
  52.113 +    uint32_t     nr_vals;              /* number of values for this counter */
  52.114 +};
  52.115 +typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
  52.116 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
  52.117 +typedef uint32_t xen_sysctl_perfc_val_t;
  52.118 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
  52.119 +
  52.120 +struct xen_sysctl_perfc_op {
  52.121 +    /* IN variables. */
  52.122 +    uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
  52.123 +    /* OUT variables. */
  52.124 +    uint32_t       nr_counters;       /*  number of counters description  */
  52.125 +    uint32_t       nr_vals;           /*  number of values  */
  52.126 +    /* counter information (or NULL) */
  52.127 +    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
  52.128 +    /* counter values (or NULL) */
  52.129 +    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
  52.130 +};
  52.131 +typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
  52.132 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
  52.133 +
  52.134 +#define XEN_SYSCTL_getdomaininfolist 6
  52.135 +struct xen_sysctl_getdomaininfolist {
  52.136 +    /* IN variables. */
  52.137 +    domid_t               first_domain;
  52.138 +    uint32_t              max_domains;
  52.139 +    XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
  52.140 +    /* OUT variables. */
  52.141 +    uint32_t              num_domains;
  52.142 +};
  52.143 +typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
  52.144 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
  52.145 +
  52.146 +/* Inject debug keys into Xen. */
  52.147 +#define XEN_SYSCTL_debug_keys        7
  52.148 +struct xen_sysctl_debug_keys {
  52.149 +    /* IN variables. */
  52.150 +    XEN_GUEST_HANDLE_64(char) keys;
  52.151 +    uint32_t nr_keys;
  52.152 +};
  52.153 +typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
  52.154 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
  52.155 +
  52.156 +/* Get physical CPU information. */
  52.157 +#define XEN_SYSCTL_getcpuinfo        8
  52.158 +struct xen_sysctl_cpuinfo {
  52.159 +    uint64_t idletime;
  52.160 +};
  52.161 +typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
  52.162 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); 
  52.163 +struct xen_sysctl_getcpuinfo {
  52.164 +    /* IN variables. */
  52.165 +    uint32_t max_cpus;
  52.166 +    XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
  52.167 +    /* OUT variables. */
  52.168 +    uint32_t nr_cpus;
  52.169 +}; 
  52.170 +typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
  52.171 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t); 
  52.172 +
  52.173 +struct xen_sysctl {
  52.174 +    uint32_t cmd;
  52.175 +    uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
  52.176 +    union {
  52.177 +        struct xen_sysctl_readconsole       readconsole;
  52.178 +        struct xen_sysctl_tbuf_op           tbuf_op;
  52.179 +        struct xen_sysctl_physinfo          physinfo;
  52.180 +        struct xen_sysctl_sched_id          sched_id;
  52.181 +        struct xen_sysctl_perfc_op          perfc_op;
  52.182 +        struct xen_sysctl_getdomaininfolist getdomaininfolist;
  52.183 +        struct xen_sysctl_debug_keys        debug_keys;
  52.184 +        struct xen_sysctl_getcpuinfo        getcpuinfo;
  52.185 +        uint8_t                             pad[128];
  52.186 +    } u;
  52.187 +};
  52.188 +typedef struct xen_sysctl xen_sysctl_t;
  52.189 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
  52.190 +
  52.191 +#endif /* __XEN_PUBLIC_SYSCTL_H__ */
  52.192 +
  52.193 +/*
  52.194 + * Local variables:
  52.195 + * mode: C
  52.196 + * c-set-style: "BSD"
  52.197 + * c-basic-offset: 4
  52.198 + * tab-width: 4
  52.199 + * indent-tabs-mode: nil
  52.200 + * End:
  52.201 + */
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/common/include/public/trace.h	Wed Dec 05 11:14:28 2007 -0800
    53.3 @@ -0,0 +1,120 @@
    53.4 +/******************************************************************************
    53.5 + * include/public/trace.h
    53.6 + * 
    53.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    53.8 + * of this software and associated documentation files (the "Software"), to
    53.9 + * deal in the Software without restriction, including without limitation the
   53.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   53.11 + * sell copies of the Software, and to permit persons to whom the Software is
   53.12 + * furnished to do so, subject to the following conditions:
   53.13 + *
   53.14 + * The above copyright notice and this permission notice shall be included in
   53.15 + * all copies or substantial portions of the Software.
   53.16 + *
   53.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   53.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   53.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   53.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   53.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   53.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   53.23 + * DEALINGS IN THE SOFTWARE.
   53.24 + *
   53.25 + * Mark Williamson, (C) 2004 Intel Research Cambridge
   53.26 + * Copyright (C) 2005 Bin Ren
   53.27 + */
   53.28 +
   53.29 +#ifndef __XEN_PUBLIC_TRACE_H__
   53.30 +#define __XEN_PUBLIC_TRACE_H__
   53.31 +
   53.32 +/* Trace classes */
   53.33 +#define TRC_CLS_SHIFT 16
   53.34 +#define TRC_GEN     0x0001f000    /* General trace            */
   53.35 +#define TRC_SCHED   0x0002f000    /* Xen Scheduler trace      */
   53.36 +#define TRC_DOM0OP  0x0004f000    /* Xen DOM0 operation trace */
   53.37 +#define TRC_HVM     0x0008f000    /* Xen HVM trace            */
   53.38 +#define TRC_MEM     0x0010f000    /* Xen memory trace         */
   53.39 +#define TRC_ALL     0xfffff000
   53.40 +
   53.41 +/* Trace subclasses */
   53.42 +#define TRC_SUBCLS_SHIFT 12
   53.43 +
   53.44 +/* trace subclasses for SVM */
   53.45 +#define TRC_HVM_ENTRYEXIT 0x00081000   /* VMENTRY and #VMEXIT       */
   53.46 +#define TRC_HVM_HANDLER   0x00082000   /* various HVM handlers      */
   53.47 +
   53.48 +/* Trace events per class */
   53.49 +#define TRC_LOST_RECORDS        (TRC_GEN + 1)
   53.50 +
   53.51 +#define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
   53.52 +#define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)
   53.53 +#define TRC_SCHED_SLEEP         (TRC_SCHED +  3)
   53.54 +#define TRC_SCHED_WAKE          (TRC_SCHED +  4)
   53.55 +#define TRC_SCHED_YIELD         (TRC_SCHED +  5)
   53.56 +#define TRC_SCHED_BLOCK         (TRC_SCHED +  6)
   53.57 +#define TRC_SCHED_SHUTDOWN      (TRC_SCHED +  7)
   53.58 +#define TRC_SCHED_CTL           (TRC_SCHED +  8)
   53.59 +#define TRC_SCHED_ADJDOM        (TRC_SCHED +  9)
   53.60 +#define TRC_SCHED_SWITCH        (TRC_SCHED + 10)
   53.61 +#define TRC_SCHED_S_TIMER_FN    (TRC_SCHED + 11)
   53.62 +#define TRC_SCHED_T_TIMER_FN    (TRC_SCHED + 12)
   53.63 +#define TRC_SCHED_DOM_TIMER_FN  (TRC_SCHED + 13)
   53.64 +#define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED + 14)
   53.65 +#define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED + 15)
   53.66 +
   53.67 +#define TRC_MEM_PAGE_GRANT_MAP      (TRC_MEM + 1)
   53.68 +#define TRC_MEM_PAGE_GRANT_UNMAP    (TRC_MEM + 2)
   53.69 +#define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
   53.70 +
   53.71 +/* trace events per subclass */
   53.72 +#define TRC_HVM_VMENTRY         (TRC_HVM_ENTRYEXIT + 0x01)
   53.73 +#define TRC_HVM_VMEXIT          (TRC_HVM_ENTRYEXIT + 0x02)
   53.74 +#define TRC_HVM_PF_XEN          (TRC_HVM_HANDLER + 0x01)
   53.75 +#define TRC_HVM_PF_INJECT       (TRC_HVM_HANDLER + 0x02)
   53.76 +#define TRC_HVM_INJ_EXC         (TRC_HVM_HANDLER + 0x03)
   53.77 +#define TRC_HVM_INJ_VIRQ        (TRC_HVM_HANDLER + 0x04)
   53.78 +#define TRC_HVM_REINJ_VIRQ      (TRC_HVM_HANDLER + 0x05)
   53.79 +#define TRC_HVM_IO_READ         (TRC_HVM_HANDLER + 0x06)
   53.80 +#define TRC_HVM_IO_WRITE        (TRC_HVM_HANDLER + 0x07)
   53.81 +#define TRC_HVM_CR_READ         (TRC_HVM_HANDLER + 0x08)
   53.82 +#define TRC_HVM_CR_WRITE        (TRC_HVM_HANDLER + 0x09)
   53.83 +#define TRC_HVM_DR_READ         (TRC_HVM_HANDLER + 0x0A)
   53.84 +#define TRC_HVM_DR_WRITE        (TRC_HVM_HANDLER + 0x0B)
   53.85 +#define TRC_HVM_MSR_READ        (TRC_HVM_HANDLER + 0x0C)
   53.86 +#define TRC_HVM_MSR_WRITE       (TRC_HVM_HANDLER + 0x0D)
   53.87 +#define TRC_HVM_CPUID           (TRC_HVM_HANDLER + 0x0E)
   53.88 +#define TRC_HVM_INTR            (TRC_HVM_HANDLER + 0x0F)
   53.89 +#define TRC_HVM_NMI             (TRC_HVM_HANDLER + 0x10)
   53.90 +#define TRC_HVM_SMI             (TRC_HVM_HANDLER + 0x11)
   53.91 +#define TRC_HVM_VMMCALL         (TRC_HVM_HANDLER + 0x12)
   53.92 +#define TRC_HVM_HLT             (TRC_HVM_HANDLER + 0x13)
   53.93 +#define TRC_HVM_INVLPG          (TRC_HVM_HANDLER + 0x14)
   53.94 +#define TRC_HVM_MCE             (TRC_HVM_HANDLER + 0x15)
   53.95 +
   53.96 +/* This structure represents a single trace buffer record. */
   53.97 +struct t_rec {
   53.98 +    uint64_t cycles;          /* cycle counter timestamp */
   53.99 +    uint32_t event;           /* event ID                */
  53.100 +    unsigned long data[5];    /* event data items        */
  53.101 +};
  53.102 +
  53.103 +/*
  53.104 + * This structure contains the metadata for a single trace buffer.  The head
  53.105 + * field, indexes into an array of struct t_rec's.
  53.106 + */
  53.107 +struct t_buf {
  53.108 +    uint32_t cons;      /* Next item to be consumed by control tools. */
  53.109 +    uint32_t prod;      /* Next item to be produced by Xen.           */
  53.110 +    /* 'nr_recs' records follow immediately after the meta-data header.    */
  53.111 +};
  53.112 +
  53.113 +#endif /* __XEN_PUBLIC_TRACE_H__ */
  53.114 +
  53.115 +/*
  53.116 + * Local variables:
  53.117 + * mode: C
  53.118 + * c-set-style: "BSD"
  53.119 + * c-basic-offset: 4
  53.120 + * tab-width: 4
  53.121 + * indent-tabs-mode: nil
  53.122 + * End:
  53.123 + */
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/common/include/public/vcpu.h	Wed Dec 05 11:14:28 2007 -0800
    54.3 @@ -0,0 +1,192 @@
    54.4 +/******************************************************************************
    54.5 + * vcpu.h
    54.6 + * 
    54.7 + * VCPU initialisation, query, and hotplug.
    54.8 + * 
    54.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   54.10 + * of this software and associated documentation files (the "Software"), to
   54.11 + * deal in the Software without restriction, including without limitation the
   54.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   54.13 + * sell copies of the Software, and to permit persons to whom the Software is
   54.14 + * furnished to do so, subject to the following conditions:
   54.15 + *
   54.16 + * The above copyright notice and this permission notice shall be included in
   54.17 + * all copies or substantial portions of the Software.
   54.18 + *
   54.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   54.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   54.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   54.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   54.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   54.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   54.25 + * DEALINGS IN THE SOFTWARE.
   54.26 + *
   54.27 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   54.28 + */
   54.29 +
   54.30 +#ifndef __XEN_PUBLIC_VCPU_H__
   54.31 +#define __XEN_PUBLIC_VCPU_H__
   54.32 +
   54.33 +/*
   54.34 + * Prototype for this hypercall is:
   54.35 + *  int vcpu_op(int cmd, int vcpuid, void *extra_args)
   54.36 + * @cmd        == VCPUOP_??? (VCPU operation).
   54.37 + * @vcpuid     == VCPU to operate on.
   54.38 + * @extra_args == Operation-specific extra arguments (NULL if none).
   54.39 + */
   54.40 +
   54.41 +/*
   54.42 + * Initialise a VCPU. Each VCPU can be initialised only once. A 
   54.43 + * newly-initialised VCPU will not run until it is brought up by VCPUOP_up.
   54.44 + * 
   54.45 + * @extra_arg == pointer to vcpu_guest_context structure containing initial
   54.46 + *               state for the VCPU.
   54.47 + */
   54.48 +#define VCPUOP_initialise            0
   54.49 +
   54.50 +/*
   54.51 + * Bring up a VCPU. This makes the VCPU runnable. This operation will fail
   54.52 + * if the VCPU has not been initialised (VCPUOP_initialise).
   54.53 + */
   54.54 +#define VCPUOP_up                    1
   54.55 +
   54.56 +/*
   54.57 + * Bring down a VCPU (i.e., make it non-runnable).
   54.58 + * There are a few caveats that callers should observe:
   54.59 + *  1. This operation may return, and VCPU_is_up may return false, before the
   54.60 + *     VCPU stops running (i.e., the command is asynchronous). It is a good
   54.61 + *     idea to ensure that the VCPU has entered a non-critical loop before
   54.62 + *     bringing it down. Alternatively, this operation is guaranteed
   54.63 + *     synchronous if invoked by the VCPU itself.
   54.64 + *  2. After a VCPU is initialised, there is currently no way to drop all its
   54.65 + *     references to domain memory. Even a VCPU that is down still holds
   54.66 + *     memory references via its pagetable base pointer and GDT. It is good
   54.67 + *     practise to move a VCPU onto an 'idle' or default page table, LDT and
   54.68 + *     GDT before bringing it down.
   54.69 + */
   54.70 +#define VCPUOP_down                  2
   54.71 +
   54.72 +/* Returns 1 if the given VCPU is up. */
   54.73 +#define VCPUOP_is_up                 3
   54.74 +
   54.75 +/*
   54.76 + * Return information about the state and running time of a VCPU.
   54.77 + * @extra_arg == pointer to vcpu_runstate_info structure.
   54.78 + */
   54.79 +#define VCPUOP_get_runstate_info     4
   54.80 +struct vcpu_runstate_info {
   54.81 +    /* VCPU's current state (RUNSTATE_*). */
   54.82 +    int      state;
   54.83 +    /* When was current state entered (system time, ns)? */
   54.84 +    uint64_t state_entry_time;
   54.85 +    /*
   54.86 +     * Time spent in each RUNSTATE_* (ns). The sum of these times is
   54.87 +     * guaranteed not to drift from system time.
   54.88 +     */
   54.89 +    uint64_t time[4];
   54.90 +};
   54.91 +typedef struct vcpu_runstate_info vcpu_runstate_info_t;
   54.92 +DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_t);
   54.93 +
   54.94 +/* VCPU is currently running on a physical CPU. */
   54.95 +#define RUNSTATE_running  0
   54.96 +
   54.97 +/* VCPU is runnable, but not currently scheduled on any physical CPU. */
   54.98 +#define RUNSTATE_runnable 1
   54.99 +
  54.100 +/* VCPU is blocked (a.k.a. idle). It is therefore not runnable. */
  54.101 +#define RUNSTATE_blocked  2
  54.102 +
  54.103 +/*
  54.104 + * VCPU is not runnable, but it is not blocked.
  54.105 + * This is a 'catch all' state for things like hotplug and pauses by the
  54.106 + * system administrator (or for critical sections in the hypervisor).
  54.107 + * RUNSTATE_blocked dominates this state (it is the preferred state).
  54.108 + */
  54.109 +#define RUNSTATE_offline  3
  54.110 +
  54.111 +/*
  54.112 + * Register a shared memory area from which the guest may obtain its own
  54.113 + * runstate information without needing to execute a hypercall.
  54.114 + * Notes:
  54.115 + *  1. The registered address may be virtual or physical or guest handle,
  54.116 + *     depending on the platform. Virtual address or guest handle should be
  54.117 + *     registered on x86 systems.
  54.118 + *  2. Only one shared area may be registered per VCPU. The shared area is
  54.119 + *     updated by the hypervisor each time the VCPU is scheduled. Thus
  54.120 + *     runstate.state will always be RUNSTATE_running and
  54.121 + *     runstate.state_entry_time will indicate the system time at which the
  54.122 + *     VCPU was last scheduled to run.
  54.123 + * @extra_arg == pointer to vcpu_register_runstate_memory_area structure.
  54.124 + */
  54.125 +#define VCPUOP_register_runstate_memory_area 5
  54.126 +struct vcpu_register_runstate_memory_area {
  54.127 +    union {
  54.128 +        XEN_GUEST_HANDLE(vcpu_runstate_info_t) h;
  54.129 +        struct vcpu_runstate_info *v;
  54.130 +        uint64_t p;
  54.131 +    } addr;
  54.132 +};
  54.133 +typedef struct vcpu_register_runstate_memory_area vcpu_register_runstate_memory_area_t;
  54.134 +DEFINE_XEN_GUEST_HANDLE(vcpu_register_runstate_memory_area_t);
  54.135 +
  54.136 +/*
  54.137 + * Set or stop a VCPU's periodic timer. Every VCPU has one periodic timer
  54.138 + * which can be set via these commands. Periods smaller than one millisecond
  54.139 + * may not be supported.
  54.140 + */
  54.141 +#define VCPUOP_set_periodic_timer    6 /* arg == vcpu_set_periodic_timer_t */
  54.142 +#define VCPUOP_stop_periodic_timer   7 /* arg == NULL */
  54.143 +struct vcpu_set_periodic_timer {
  54.144 +    uint64_t period_ns;
  54.145 +};
  54.146 +typedef struct vcpu_set_periodic_timer vcpu_set_periodic_timer_t;
  54.147 +DEFINE_XEN_GUEST_HANDLE(vcpu_set_periodic_timer_t);
  54.148 +
  54.149 +/*
  54.150 + * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
  54.151 + * timer which can be set via these commands.
  54.152 + */
  54.153 +#define VCPUOP_set_singleshot_timer  8 /* arg == vcpu_set_singleshot_timer_t */
  54.154 +#define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */
  54.155 +struct vcpu_set_singleshot_timer {
  54.156 +    uint64_t timeout_abs_ns;   /* Absolute system time value in nanoseconds. */
  54.157 +    uint32_t flags;            /* VCPU_SSHOTTMR_??? */
  54.158 +};
  54.159 +typedef struct vcpu_set_singleshot_timer vcpu_set_singleshot_timer_t;
  54.160 +DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t);
  54.161 +
  54.162 +/* Flags to VCPUOP_set_singleshot_timer. */
  54.163 + /* Require the timeout to be in the future (return -ETIME if it's passed). */
  54.164 +#define _VCPU_SSHOTTMR_future (0)
  54.165 +#define VCPU_SSHOTTMR_future  (1U << _VCPU_SSHOTTMR_future)
  54.166 +
  54.167 +/* 
  54.168 + * Register a memory location in the guest address space for the
  54.169 + * vcpu_info structure.  This allows the guest to place the vcpu_info
  54.170 + * structure in a convenient place, such as in a per-cpu data area.
  54.171 + * The pointer need not be page aligned, but the structure must not
  54.172 + * cross a page boundary.
  54.173 + *
  54.174 + * This may be called only once per vcpu.
  54.175 + */
  54.176 +#define VCPUOP_register_vcpu_info   10  /* arg == struct vcpu_info */
  54.177 +struct vcpu_register_vcpu_info {
  54.178 +    uint64_t mfn;    /* mfn of page to place vcpu_info */
  54.179 +    uint32_t offset; /* offset within page */
  54.180 +    uint32_t rsvd;   /* unused */
  54.181 +};
  54.182 +typedef struct vcpu_register_vcpu_info vcpu_register_vcpu_info_t;
  54.183 +DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t);
  54.184 +
  54.185 +#endif /* __XEN_PUBLIC_VCPU_H__ */
  54.186 +
  54.187 +/*
  54.188 + * Local variables:
  54.189 + * mode: C
  54.190 + * c-set-style: "BSD"
  54.191 + * c-basic-offset: 4
  54.192 + * tab-width: 4
  54.193 + * indent-tabs-mode: nil
  54.194 + * End:
  54.195 + */
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/common/include/public/version.h	Wed Dec 05 11:14:28 2007 -0800
    55.3 @@ -0,0 +1,91 @@
    55.4 +/******************************************************************************
    55.5 + * version.h
    55.6 + * 
    55.7 + * Xen version, type, and compile information.
    55.8 + * 
    55.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   55.10 + * of this software and associated documentation files (the "Software"), to
   55.11 + * deal in the Software without restriction, including without limitation the
   55.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   55.13 + * sell copies of the Software, and to permit persons to whom the Software is
   55.14 + * furnished to do so, subject to the following conditions:
   55.15 + *
   55.16 + * The above copyright notice and this permission notice shall be included in
   55.17 + * all copies or substantial portions of the Software.
   55.18 + *
   55.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   55.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   55.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   55.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   55.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   55.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   55.25 + * DEALINGS IN THE SOFTWARE.
   55.26 + *
   55.27 + * Copyright (c) 2005, Nguyen Anh Quynh <aquynh@gmail.com>
   55.28 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   55.29 + */
   55.30 +
   55.31 +#ifndef __XEN_PUBLIC_VERSION_H__
   55.32 +#define __XEN_PUBLIC_VERSION_H__
   55.33 +
   55.34 +/* NB. All ops return zero on success, except XENVER_{version,pagesize} */
   55.35 +
   55.36 +/* arg == NULL; returns major:minor (16:16). */
   55.37 +#define XENVER_version      0
   55.38 +
   55.39 +/* arg == xen_extraversion_t. */
   55.40 +#define XENVER_extraversion 1
   55.41 +typedef char xen_extraversion_t[16];
   55.42 +#define XEN_EXTRAVERSION_LEN (sizeof(xen_extraversion_t))
   55.43 +
   55.44 +/* arg == xen_compile_info_t. */
   55.45 +#define XENVER_compile_info 2
   55.46 +struct xen_compile_info {
   55.47 +    char compiler[64];
   55.48 +    char compile_by[16];
   55.49 +    char compile_domain[32];
   55.50 +    char compile_date[32];
   55.51 +};
   55.52 +typedef struct xen_compile_info xen_compile_info_t;
   55.53 +
   55.54 +#define XENVER_capabilities 3
   55.55 +typedef char xen_capabilities_info_t[1024];
   55.56 +#define XEN_CAPABILITIES_INFO_LEN (sizeof(xen_capabilities_info_t))
   55.57 +
   55.58 +#define XENVER_changeset 4
   55.59 +typedef char xen_changeset_info_t[64];
   55.60 +#define XEN_CHANGESET_INFO_LEN (sizeof(xen_changeset_info_t))
   55.61 +
   55.62 +#define XENVER_platform_parameters 5
   55.63 +struct xen_platform_parameters {
   55.64 +    unsigned long virt_start;
   55.65 +};
   55.66 +typedef struct xen_platform_parameters xen_platform_parameters_t;
   55.67 +
   55.68 +#define XENVER_get_features 6
   55.69 +struct xen_feature_info {
   55.70 +    unsigned int submap_idx;    /* IN: which 32-bit submap to return */
   55.71 +    uint32_t     submap;        /* OUT: 32-bit submap */
   55.72 +};
   55.73 +typedef struct xen_feature_info xen_feature_info_t;
   55.74 +
   55.75 +/* Declares the features reported by XENVER_get_features. */
   55.76 +#include "features.h"
   55.77 +
   55.78 +/* arg == NULL; returns host memory page size. */
   55.79 +#define XENVER_pagesize 7
   55.80 +
   55.81 +/* arg == xen_domain_handle_t. */
   55.82 +#define XENVER_guest_handle 8
   55.83 +
   55.84 +#endif /* __XEN_PUBLIC_VERSION_H__ */
   55.85 +
   55.86 +/*
   55.87 + * Local variables:
   55.88 + * mode: C
   55.89 + * c-set-style: "BSD"
   55.90 + * c-basic-offset: 4
   55.91 + * tab-width: 4
   55.92 + * indent-tabs-mode: nil
   55.93 + * End:
   55.94 + */
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/common/include/public/xen-compat.h	Wed Dec 05 11:14:28 2007 -0800
    56.3 @@ -0,0 +1,51 @@
    56.4 +/******************************************************************************
    56.5 + * xen-compat.h
    56.6 + * 
    56.7 + * Guest OS interface to Xen.  Compatibility layer.
    56.8 + * 
    56.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   56.10 + * of this software and associated documentation files (the "Software"), to
   56.11 + * deal in the Software without restriction, including without limitation the
   56.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   56.13 + * sell copies of the Software, and to permit persons to whom the Software is
   56.14 + * furnished to do so, subject to the following conditions:
   56.15 + *
   56.16 + * The above copyright notice and this permission notice shall be included in
   56.17 + * all copies or substantial portions of the Software.
   56.18 + *
   56.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   56.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   56.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   56.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   56.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   56.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   56.25 + * DEALINGS IN THE SOFTWARE.
   56.26 + *
   56.27 + * Copyright (c) 2006, Christian Limpach
   56.28 + */
   56.29 +
   56.30 +#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
   56.31 +#define __XEN_PUBLIC_XEN_COMPAT_H__
   56.32 +
   56.33 +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030205
   56.34 +
   56.35 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
   56.36 +/* Xen is built with matching headers and implements the latest interface. */
   56.37 +#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__
   56.38 +#elif !defined(__XEN_INTERFACE_VERSION__)
   56.39 +/* Guests which do not specify a version get the legacy interface. */
   56.40 +#define __XEN_INTERFACE_VERSION__ 0x00000000
   56.41 +#endif
   56.42 +
   56.43 +#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__
   56.44 +#error "These header files do not support the requested interface version."
   56.45 +#endif
   56.46 +
   56.47 +/* Fields defined as a Xen guest handle since 0x00030205. */
   56.48 +#if __XEN_INTERFACE_VERSION__ >= 0x00030205
   56.49 +#define XEN_GUEST_HANDLE_00030205(type) XEN_GUEST_HANDLE(type)
   56.50 +#else
   56.51 +#define XEN_GUEST_HANDLE_00030205(type) type *
   56.52 +#endif
   56.53 +
   56.54 +#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/common/include/public/xen.h	Wed Dec 05 11:14:28 2007 -0800
    57.3 @@ -0,0 +1,612 @@
    57.4 +/******************************************************************************
    57.5 + * xen.h
    57.6 + * 
    57.7 + * Guest OS interface to Xen.
    57.8 + * 
    57.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   57.10 + * of this software and associated documentation files (the "Software"), to
   57.11 + * deal in the Software without restriction, including without limitation the
   57.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   57.13 + * sell copies of the Software, and to permit persons to whom the Software is
   57.14 + * furnished to do so, subject to the following conditions:
   57.15 + *
   57.16 + * The above copyright notice and this permission notice shall be included in
   57.17 + * all copies or substantial portions of the Software.
   57.18 + *
   57.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   57.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   57.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   57.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   57.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   57.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   57.25 + * DEALINGS IN THE SOFTWARE.
   57.26 + *
   57.27 + * Copyright (c) 2004, K A Fraser
   57.28 + */
   57.29 +
   57.30 +#ifndef __XEN_PUBLIC_XEN_H__
   57.31 +#define __XEN_PUBLIC_XEN_H__
   57.32 +
   57.33 +#include "xen-compat.h"
   57.34 +
   57.35 +#if defined(__i386__) || defined(__x86_64__)
   57.36 +#include "arch-x86/xen.h"
   57.37 +#elif defined(__ia64__)
   57.38 +#include "arch-ia64.h"
   57.39 +#elif defined(__powerpc__)
   57.40 +#include "arch-powerpc.h"
   57.41 +#else
   57.42 +#error "Unsupported architecture"
   57.43 +#endif
   57.44 +
   57.45 +/*
   57.46 + * HYPERCALLS
   57.47 + */
   57.48 +
   57.49 +#define __HYPERVISOR_set_trap_table        0
   57.50 +#define __HYPERVISOR_mmu_update            1
   57.51 +#define __HYPERVISOR_set_gdt               2
   57.52 +#define __HYPERVISOR_stack_switch          3
   57.53 +#define __HYPERVISOR_set_callbacks         4
   57.54 +#define __HYPERVISOR_fpu_taskswitch        5
   57.55 +#define __HYPERVISOR_sched_op_compat       6 /* compat since 0x00030101 */
   57.56 +#define __HYPERVISOR_platform_op           7
   57.57 +#define __HYPERVISOR_set_debugreg          8
   57.58 +#define __HYPERVISOR_get_debugreg          9
   57.59 +#define __HYPERVISOR_update_descriptor    10
   57.60 +#define __HYPERVISOR_memory_op            12
   57.61 +#define __HYPERVISOR_multicall            13
   57.62 +#define __HYPERVISOR_update_va_mapping    14
   57.63 +#define __HYPERVISOR_set_timer_op         15
   57.64 +#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
   57.65 +#define __HYPERVISOR_xen_version          17
   57.66 +#define __HYPERVISOR_console_io           18
   57.67 +#define __HYPERVISOR_physdev_op_compat    19 /* compat since 0x00030202 */
   57.68 +#define __HYPERVISOR_grant_table_op       20
   57.69 +#define __HYPERVISOR_vm_assist            21
   57.70 +#define __HYPERVISOR_update_va_mapping_otherdomain 22
   57.71 +#define __HYPERVISOR_iret                 23 /* x86 only */
   57.72 +#define __HYPERVISOR_vcpu_op              24
   57.73 +#define __HYPERVISOR_set_segment_base     25 /* x86/64 only */
   57.74 +#define __HYPERVISOR_mmuext_op            26
   57.75 +#define __HYPERVISOR_acm_op               27
   57.76 +#define __HYPERVISOR_nmi_op               28
   57.77 +#define __HYPERVISOR_sched_op             29
   57.78 +#define __HYPERVISOR_callback_op          30
   57.79 +#define __HYPERVISOR_xenoprof_op          31
   57.80 +#define __HYPERVISOR_event_channel_op     32
   57.81 +#define __HYPERVISOR_physdev_op           33
   57.82 +#define __HYPERVISOR_hvm_op               34
   57.83 +#define __HYPERVISOR_sysctl               35
   57.84 +#define __HYPERVISOR_domctl               36
   57.85 +#define __HYPERVISOR_kexec_op             37
   57.86 +
   57.87 +/* Architecture-specific hypercall definitions. */
   57.88 +#define __HYPERVISOR_arch_0               48
   57.89 +#define __HYPERVISOR_arch_1               49
   57.90 +#define __HYPERVISOR_arch_2               50
   57.91 +#define __HYPERVISOR_arch_3               51
   57.92 +#define __HYPERVISOR_arch_4               52
   57.93 +#define __HYPERVISOR_arch_5               53
   57.94 +#define __HYPERVISOR_arch_6               54
   57.95 +#define __HYPERVISOR_arch_7               55
   57.96 +
   57.97 +/*
   57.98 + * HYPERCALL COMPATIBILITY.
   57.99 + */
  57.100 +
  57.101 +/* New sched_op hypercall introduced in 0x00030101. */
  57.102 +#if __XEN_INTERFACE_VERSION__ < 0x00030101
  57.103 +#undef __HYPERVISOR_sched_op
  57.104 +#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
  57.105 +#endif
  57.106 +
  57.107 +/* New event-channel and physdev hypercalls introduced in 0x00030202. */
  57.108 +#if __XEN_INTERFACE_VERSION__ < 0x00030202
  57.109 +#undef __HYPERVISOR_event_channel_op
  57.110 +#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
  57.111 +#undef __HYPERVISOR_physdev_op
  57.112 +#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
  57.113 +#endif
  57.114 +
  57.115 +/* New platform_op hypercall introduced in 0x00030204. */
  57.116 +#if __XEN_INTERFACE_VERSION__ < 0x00030204
  57.117 +#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
  57.118 +#endif
  57.119 +
  57.120 +/* 
  57.121 + * VIRTUAL INTERRUPTS
  57.122 + * 
  57.123 + * Virtual interrupts that a guest OS may receive from Xen.
  57.124 + * 
  57.125 + * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
  57.126 + * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
  57.127 + * The latter can be allocated only once per guest: they must initially be
  57.128 + * allocated to VCPU0 but can subsequently be re-bound.
  57.129 + */
  57.130 +#define VIRQ_TIMER      0  /* V. Timebase update, and/or requested timeout.  */
  57.131 +#define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
  57.132 +#define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
  57.133 +#define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
  57.134 +#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
  57.135 +#define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
  57.136 +#define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
  57.137 +#define VIRQ_CON_RING   8  /* G. (DOM0) Bytes received on console            */
  57.138 +
  57.139 +/* Architecture-specific VIRQ definitions. */
  57.140 +#define VIRQ_ARCH_0    16
  57.141 +#define VIRQ_ARCH_1    17
  57.142 +#define VIRQ_ARCH_2    18
  57.143 +#define VIRQ_ARCH_3    19
  57.144 +#define VIRQ_ARCH_4    20
  57.145 +#define VIRQ_ARCH_5    21
  57.146 +#define VIRQ_ARCH_6    22
  57.147 +#define VIRQ_ARCH_7    23
  57.148 +
  57.149 +#define NR_VIRQS       24
  57.150 +
  57.151 +/*
  57.152 + * MMU-UPDATE REQUESTS
  57.153 + * 
  57.154 + * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
  57.155 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
  57.156 + * Where the FD has some effect, it is described below.
  57.157 + * ptr[1:0] specifies the appropriate MMU_* command.
  57.158 + * 
  57.159 + * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
  57.160 + * Updates an entry in a page table. If updating an L1 table, and the new
  57.161 + * table entry is valid/present, the mapped frame must belong to the FD, if
  57.162 + * an FD has been specified. If attempting to map an I/O page then the
  57.163 + * caller assumes the privilege of the FD.
  57.164 + * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
  57.165 + * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
  57.166 + * ptr[:2]  -- Machine address of the page-table entry to modify.
  57.167 + * val      -- Value to write.
  57.168 + * 
  57.169 + * ptr[1:0] == MMU_MACHPHYS_UPDATE:
  57.170 + * Updates an entry in the machine->pseudo-physical mapping table.
  57.171 + * ptr[:2]  -- Machine address within the frame whose mapping to modify.
  57.172 + *             The frame must belong to the FD, if one is specified.
  57.173 + * val      -- Value to write into the mapping entry.
  57.174 + */
  57.175 +#define MMU_NORMAL_PT_UPDATE     0 /* checked '*ptr = val'. ptr is MA.       */
  57.176 +#define MMU_MACHPHYS_UPDATE      1 /* ptr = MA of frame to modify entry for  */
  57.177 +
  57.178 +/*
  57.179 + * MMU EXTENDED OPERATIONS
  57.180 + * 
  57.181 + * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
  57.182 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
  57.183 + * Where the FD has some effect, it is described below.
  57.184 + * 
  57.185 + * cmd: MMUEXT_(UN)PIN_*_TABLE
  57.186 + * mfn: Machine frame number to be (un)pinned as a p.t. page.
  57.187 + *      The frame must belong to the FD, if one is specified.
  57.188 + * 
  57.189 + * cmd: MMUEXT_NEW_BASEPTR
  57.190 + * mfn: Machine frame number of new page-table base to install in MMU.
  57.191 + * 
  57.192 + * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
  57.193 + * mfn: Machine frame number of new page-table base to install in MMU
  57.194 + *      when in user space.
  57.195 + * 
  57.196 + * cmd: MMUEXT_TLB_FLUSH_LOCAL
  57.197 + * No additional arguments. Flushes local TLB.
  57.198 + * 
  57.199 + * cmd: MMUEXT_INVLPG_LOCAL
  57.200 + * linear_addr: Linear address to be flushed from the local TLB.
  57.201 + * 
  57.202 + * cmd: MMUEXT_TLB_FLUSH_MULTI
  57.203 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  57.204 + * 
  57.205 + * cmd: MMUEXT_INVLPG_MULTI
  57.206 + * linear_addr: Linear address to be flushed.
  57.207 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  57.208 + * 
  57.209 + * cmd: MMUEXT_TLB_FLUSH_ALL
  57.210 + * No additional arguments. Flushes all VCPUs' TLBs.
  57.211 + * 
  57.212 + * cmd: MMUEXT_INVLPG_ALL
  57.213 + * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
  57.214 + * 
  57.215 + * cmd: MMUEXT_FLUSH_CACHE
  57.216 + * No additional arguments. Writes back and flushes cache contents.
  57.217 + * 
  57.218 + * cmd: MMUEXT_SET_LDT
  57.219 + * linear_addr: Linear address of LDT base (NB. must be page-aligned).
  57.220 + * nr_ents: Number of entries in LDT.
  57.221 + */
  57.222 +#define MMUEXT_PIN_L1_TABLE      0
  57.223 +#define MMUEXT_PIN_L2_TABLE      1
  57.224 +#define MMUEXT_PIN_L3_TABLE      2
  57.225 +#define MMUEXT_PIN_L4_TABLE      3
  57.226 +#define MMUEXT_UNPIN_TABLE       4
  57.227 +#define MMUEXT_NEW_BASEPTR       5
  57.228 +#define MMUEXT_TLB_FLUSH_LOCAL   6
  57.229 +#define MMUEXT_INVLPG_LOCAL      7
  57.230 +#define MMUEXT_TLB_FLUSH_MULTI   8
  57.231 +#define MMUEXT_INVLPG_MULTI      9
  57.232 +#define MMUEXT_TLB_FLUSH_ALL    10
  57.233 +#define MMUEXT_INVLPG_ALL       11
  57.234 +#define MMUEXT_FLUSH_CACHE      12
  57.235 +#define MMUEXT_SET_LDT          13
  57.236 +#define MMUEXT_NEW_USER_BASEPTR 15
  57.237 +
  57.238 +#ifndef __ASSEMBLY__
  57.239 +struct mmuext_op {
  57.240 +    unsigned int cmd;
  57.241 +    union {
  57.242 +        /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
  57.243 +        xen_pfn_t     mfn;
  57.244 +        /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
  57.245 +        unsigned long linear_addr;
  57.246 +    } arg1;
  57.247 +    union {
  57.248 +        /* SET_LDT */
  57.249 +        unsigned int nr_ents;
  57.250 +        /* TLB_FLUSH_MULTI, INVLPG_MULTI */
  57.251 +        XEN_GUEST_HANDLE_00030205(void) vcpumask;
  57.252 +    } arg2;
  57.253 +};
  57.254 +typedef struct mmuext_op mmuext_op_t;
  57.255 +DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
  57.256 +#endif
  57.257 +
  57.258 +/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
  57.259 +/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap.   */
  57.260 +/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer.         */
  57.261 +#define UVMF_NONE               (0UL<<0) /* No flushing at all.   */
  57.262 +#define UVMF_TLB_FLUSH          (1UL<<0) /* Flush entire TLB(s).  */
  57.263 +#define UVMF_INVLPG             (2UL<<0) /* Flush only one entry. */
  57.264 +#define UVMF_FLUSHTYPE_MASK     (3UL<<0)
  57.265 +#define UVMF_MULTI              (0UL<<2) /* Flush subset of TLBs. */
  57.266 +#define UVMF_LOCAL              (0UL<<2) /* Flush local TLB.      */
  57.267 +#define UVMF_ALL                (1UL<<2) /* Flush all TLBs.       */
  57.268 +
  57.269 +/*
  57.270 + * Commands to HYPERVISOR_console_io().
  57.271 + */
  57.272 +#define CONSOLEIO_write         0
  57.273 +#define CONSOLEIO_read          1
  57.274 +
  57.275 +/*
  57.276 + * Commands to HYPERVISOR_vm_assist().
  57.277 + */
  57.278 +#define VMASST_CMD_enable                0
  57.279 +#define VMASST_CMD_disable               1
  57.280 +
  57.281 +/* x86/32 guests: simulate full 4GB segment limits. */
  57.282 +#define VMASST_TYPE_4gb_segments         0
  57.283 +
  57.284 +/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
  57.285 +#define VMASST_TYPE_4gb_segments_notify  1
  57.286 +
  57.287 +/*
  57.288 + * x86 guests: support writes to bottom-level PTEs.
  57.289 + * NB1. Page-directory entries cannot be written.
  57.290 + * NB2. Guest must continue to remove all writable mappings of PTEs.
  57.291 + */
  57.292 +#define VMASST_TYPE_writable_pagetables  2
  57.293 +
  57.294 +/* x86/PAE guests: support PDPTs above 4GB. */
  57.295 +#define VMASST_TYPE_pae_extended_cr3     3
  57.296 +
  57.297 +#define MAX_VMASST_TYPE                  3
  57.298 +
  57.299 +#ifndef __ASSEMBLY__
  57.300 +
  57.301 +typedef uint16_t domid_t;
  57.302 +
  57.303 +/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
  57.304 +#define DOMID_FIRST_RESERVED (0x7FF0U)
  57.305 +
  57.306 +/* DOMID_SELF is used in certain contexts to refer to oneself. */
  57.307 +#define DOMID_SELF (0x7FF0U)
  57.308 +
  57.309 +/*
  57.310 + * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
  57.311 + * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
  57.312 + * is useful to ensure that no mappings to the OS's own heap are accidentally
  57.313 + * installed. (e.g., in Linux this could cause havoc as reference counts
  57.314 + * aren't adjusted on the I/O-mapping code path).
  57.315 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
  57.316 + * be specified by any calling domain.
  57.317 + */
  57.318 +#define DOMID_IO   (0x7FF1U)
  57.319 +
  57.320 +/*
  57.321 + * DOMID_XEN is used to allow privileged domains to map restricted parts of
  57.322 + * Xen's heap space (e.g., the machine_to_phys table).
  57.323 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
  57.324 + * the caller is privileged.
  57.325 + */
  57.326 +#define DOMID_XEN  (0x7FF2U)
  57.327 +
  57.328 +/*
  57.329 + * Send an array of these to HYPERVISOR_mmu_update().
  57.330 + * NB. The fields are natural pointer/address size for this architecture.
  57.331 + */
  57.332 +struct mmu_update {
  57.333 +    uint64_t ptr;       /* Machine address of PTE. */
  57.334 +    uint64_t val;       /* New contents of PTE.    */
  57.335 +};
  57.336 +typedef struct mmu_update mmu_update_t;
  57.337 +DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
  57.338 +
  57.339 +/*
  57.340 + * Send an array of these to HYPERVISOR_multicall().
  57.341 + * NB. The fields are natural register size for this architecture.
  57.342 + */
  57.343 +struct multicall_entry {
  57.344 +    unsigned long op, result;
  57.345 +    unsigned long args[6];
  57.346 +};
  57.347 +typedef struct multicall_entry multicall_entry_t;
  57.348 +DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
  57.349 +
  57.350 +/*
  57.351 + * Event channel endpoints per domain:
  57.352 + *  1024 if a long is 32 bits; 4096 if a long is 64 bits.
  57.353 + */
  57.354 +#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)
  57.355 +
  57.356 +struct vcpu_time_info {
  57.357 +    /*
  57.358 +     * Updates to the following values are preceded and followed by an
  57.359 +     * increment of 'version'. The guest can therefore detect updates by
  57.360 +     * looking for changes to 'version'. If the least-significant bit of
  57.361 +     * the version number is set then an update is in progress and the guest
  57.362 +     * must wait to read a consistent set of values.
  57.363 +     * The correct way to interact with the version number is similar to
  57.364 +     * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
  57.365 +     */
  57.366 +    uint32_t version;
  57.367 +    uint32_t pad0;
  57.368 +    uint64_t tsc_timestamp;   /* TSC at last update of time vals.  */
  57.369 +    uint64_t system_time;     /* Time, in nanosecs, since boot.    */
  57.370 +    /*
  57.371 +     * Current system time:
  57.372 +     *   system_time +
  57.373 +     *   ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
  57.374 +     * CPU frequency (Hz):
  57.375 +     *   ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
  57.376 +     */
  57.377 +    uint32_t tsc_to_system_mul;
  57.378 +    int8_t   tsc_shift;
  57.379 +    int8_t   pad1[3];
  57.380 +}; /* 32 bytes */
  57.381 +typedef struct vcpu_time_info vcpu_time_info_t;
  57.382 +
  57.383 +struct vcpu_info {
  57.384 +    /*
  57.385 +     * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
  57.386 +     * a pending notification for a particular VCPU. It is then cleared 
  57.387 +     * by the guest OS /before/ checking for pending work, thus avoiding
  57.388 +     * a set-and-check race. Note that the mask is only accessed by Xen
  57.389 +     * on the CPU that is currently hosting the VCPU. This means that the
  57.390 +     * pending and mask flags can be updated by the guest without special
  57.391 +     * synchronisation (i.e., no need for the x86 LOCK prefix).
  57.392 +     * This may seem suboptimal because if the pending flag is set by
  57.393 +     * a different CPU then an IPI may be scheduled even when the mask
  57.394 +     * is set. However, note:
  57.395 +     *  1. The task of 'interrupt holdoff' is covered by the per-event-
  57.396 +     *     channel mask bits. A 'noisy' event that is continually being
  57.397 +     *     triggered can be masked at source at this very precise
  57.398 +     *     granularity.
  57.399 +     *  2. The main purpose of the per-VCPU mask is therefore to restrict
  57.400 +     *     reentrant execution: whether for concurrency control, or to
  57.401 +     *     prevent unbounded stack usage. Whatever the purpose, we expect
  57.402 +     *     that the mask will be asserted only for short periods at a time,
  57.403 +     *     and so the likelihood of a 'spurious' IPI is suitably small.
  57.404 +     * The mask is read before making an event upcall to the guest: a
  57.405 +     * non-zero mask therefore guarantees that the VCPU will not receive
  57.406 +     * an upcall activation. The mask is cleared when the VCPU requests
  57.407 +     * to block: this avoids wakeup-waiting races.
  57.408 +     */
  57.409 +    uint8_t evtchn_upcall_pending;
  57.410 +    uint8_t evtchn_upcall_mask;
  57.411 +    unsigned long evtchn_pending_sel;
  57.412 +    struct arch_vcpu_info arch;
  57.413 +    struct vcpu_time_info time;
  57.414 +}; /* 64 bytes (x86) */
  57.415 +#ifndef __XEN__
  57.416 +typedef struct vcpu_info vcpu_info_t;
  57.417 +#endif
  57.418 +
  57.419 +/*
  57.420 + * Xen/kernel shared data -- pointer provided in start_info.
  57.421 + *
  57.422 + * This structure is defined to be both smaller than a page, and the
  57.423 + * only data on the shared page, but may vary in actual size even within
  57.424 + * compatible Xen versions; guests should not rely on the size
  57.425 + * of this structure remaining constant.
  57.426 + */
  57.427 +struct shared_info {
  57.428 +    struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
  57.429 +
  57.430 +    /*
  57.431 +     * A domain can create "event channels" on which it can send and receive
  57.432 +     * asynchronous event notifications. There are three classes of event that
  57.433 +     * are delivered by this mechanism:
  57.434 +     *  1. Bi-directional inter- and intra-domain connections. Domains must
  57.435 +     *     arrange out-of-band to set up a connection (usually by allocating
  57.436 +     *     an unbound 'listener' port and avertising that via a storage service
  57.437 +     *     such as xenstore).
  57.438 +     *  2. Physical interrupts. A domain with suitable hardware-access
  57.439 +     *     privileges can bind an event-channel port to a physical interrupt
  57.440 +     *     source.
  57.441 +     *  3. Virtual interrupts ('events'). A domain can bind an event-channel
  57.442 +     *     port to a virtual interrupt source, such as the virtual-timer
  57.443 +     *     device or the emergency console.
  57.444 +     * 
  57.445 +     * Event channels are addressed by a "port index". Each channel is
  57.446 +     * associated with two bits of information:
  57.447 +     *  1. PENDING -- notifies the domain that there is a pending notification
  57.448 +     *     to be processed. This bit is cleared by the guest.
  57.449 +     *  2. MASK -- if this bit is clear then a 0->1 transition of PENDING
  57.450 +     *     will cause an asynchronous upcall to be scheduled. This bit is only
  57.451 +     *     updated by the guest. It is read-only within Xen. If a channel
  57.452 +     *     becomes pending while the channel is masked then the 'edge' is lost
  57.453 +     *     (i.e., when the channel is unmasked, the guest must manually handle
  57.454 +     *     pending notifications as no upcall will be scheduled by Xen).
  57.455 +     * 
  57.456 +     * To expedite scanning of pending notifications, any 0->1 pending
  57.457 +     * transition on an unmasked channel causes a corresponding bit in a
  57.458 +     * per-vcpu selector word to be set. Each bit in the selector covers a
  57.459 +     * 'C long' in the PENDING bitfield array.
  57.460 +     */
  57.461 +    unsigned long evtchn_pending[sizeof(unsigned long) * 8];
  57.462 +    unsigned long evtchn_mask[sizeof(unsigned long) * 8];
  57.463 +
  57.464 +    /*
  57.465 +     * Wallclock time: updated only by control software. Guests should base
  57.466 +     * their gettimeofday() syscall on this wallclock-base value.
  57.467 +     */
  57.468 +    uint32_t wc_version;      /* Version counter: see vcpu_time_info_t. */
  57.469 +    uint32_t wc_sec;          /* Secs  00:00:00 UTC, Jan 1, 1970.  */
  57.470 +    uint32_t wc_nsec;         /* Nsecs 00:00:00 UTC, Jan 1, 1970.  */
  57.471 +
  57.472 +    struct arch_shared_info arch;
  57.473 +
  57.474 +};
  57.475 +#ifndef __XEN__
  57.476 +typedef struct shared_info shared_info_t;
  57.477 +#endif
  57.478 +
  57.479 +/*
  57.480 + * Start-of-day memory layout:
  57.481 + *  1. The domain is started within contiguous virtual-memory region.
  57.482 + *  2. The contiguous region ends on an aligned 4MB boundary.
  57.483 + *  3. This the order of bootstrap elements in the initial virtual region:
  57.484 + *      a. relocated kernel image
  57.485 + *      b. initial ram disk              [mod_start, mod_len]
  57.486 + *      c. list of allocated page frames [mfn_list, nr_pages]
  57.487 + *      d. start_info_t structure        [register ESI (x86)]
  57.488 + *      e. bootstrap page tables         [pt_base, CR3 (x86)]
  57.489 + *      f. bootstrap stack               [register ESP (x86)]
  57.490 + *  4. Bootstrap elements are packed together, but each is 4kB-aligned.
  57.491 + *  5. The initial ram disk may be omitted.
  57.492 + *  6. The list of page frames forms a contiguous 'pseudo-physical' memory
  57.493 + *     layout for the domain. In particular, the bootstrap virtual-memory
  57.494 + *     region is a 1:1 mapping to the first section of the pseudo-physical map.
  57.495 + *  7. All bootstrap elements are mapped read-writable for the guest OS. The
  57.496 + *     only exception is the bootstrap page table, which is mapped read-only.
  57.497 + *  8. There is guaranteed to be at least 512kB padding after the final
  57.498 + *     bootstrap element. If necessary, the bootstrap virtual region is
  57.499 + *     extended by an extra 4MB to ensure this.
  57.500 + */
  57.501 +
  57.502 +#define MAX_GUEST_CMDLINE 1024
  57.503 +struct start_info {
  57.504 +    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.    */
  57.505 +    char magic[32];             /* "xen-<version>-<platform>".            */
  57.506 +    unsigned long nr_pages;     /* Total pages allocated to this domain.  */
  57.507 +    unsigned long shared_info;  /* MACHINE address of shared info struct. */
  57.508 +    uint32_t flags;             /* SIF_xxx flags.                         */
  57.509 +    xen_pfn_t store_mfn;        /* MACHINE page number of shared page.    */
  57.510 +    uint32_t store_evtchn;      /* Event channel for store communication. */
  57.511 +    union {
  57.512 +        struct {
  57.513 +            xen_pfn_t mfn;      /* MACHINE page number of console page.   */
  57.514 +            uint32_t  evtchn;   /* Event channel for console page.        */
  57.515 +        } domU;
  57.516 +        struct {
  57.517 +            uint32_t info_off;  /* Offset of console_info struct.         */
  57.518 +            uint32_t info_size; /* Size of console_info struct from start.*/
  57.519 +        } dom0;
  57.520 +    } console;
  57.521 +    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
  57.522 +    unsigned long pt_base;      /* VIRTUAL address of page directory.     */
  57.523 +    unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames.       */
  57.524 +    unsigned long mfn_list;     /* VIRTUAL address of page-frame list.    */
  57.525 +    unsigned long mod_start;    /* VIRTUAL address of pre-loaded module.  */
  57.526 +    unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
  57.527 +    int8_t cmd_line[MAX_GUEST_CMDLINE];
  57.528 +};
  57.529 +typedef struct start_info start_info_t;
  57.530 +
  57.531 +/* New console union for dom0 introduced in 0x00030203. */
  57.532 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
  57.533 +#define console_mfn    console.domU.mfn
  57.534 +#define console_evtchn console.domU.evtchn
  57.535 +#endif
  57.536 +
  57.537 +/* These flags are passed in the 'flags' field of start_info_t. */
  57.538 +#define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
  57.539 +#define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
  57.540 +
  57.541 +typedef struct dom0_vga_console_info {
  57.542 +    uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
  57.543 +#define XEN_VGATYPE_TEXT_MODE_3 0x03
  57.544 +#define XEN_VGATYPE_VESA_LFB    0x23
  57.545 +
  57.546 +    union {
  57.547 +        struct {
  57.548 +            /* Font height, in pixels. */
  57.549 +            uint16_t font_height;
  57.550 +            /* Cursor location (column, row). */
  57.551 +            uint16_t cursor_x, cursor_y;
  57.552 +            /* Number of rows and columns (dimensions in characters). */
  57.553 +            uint16_t rows, columns;
  57.554 +        } text_mode_3;
  57.555 +
  57.556 +        struct {
  57.557 +            /* Width and height, in pixels. */
  57.558 +            uint16_t width, height;
  57.559 +            /* Bytes per scan line. */
  57.560 +            uint16_t bytes_per_line;
  57.561 +            /* Bits per pixel. */
  57.562 +            uint16_t bits_per_pixel;
  57.563 +            /* LFB physical address, and size (in units of 64kB). */
  57.564 +            uint32_t lfb_base;
  57.565 +            uint32_t lfb_size;
  57.566 +            /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
  57.567 +            uint8_t  red_pos, red_size;
  57.568 +            uint8_t  green_pos, green_size;
  57.569 +            uint8_t  blue_pos, blue_size;
  57.570 +            uint8_t  rsvd_pos, rsvd_size;
  57.571 +        } vesa_lfb;
  57.572 +    } u;
  57.573 +} dom0_vga_console_info_t;
  57.574 +#define xen_vga_console_info dom0_vga_console_info
  57.575 +#define xen_vga_console_info_t dom0_vga_console_info_t
  57.576 +
  57.577 +typedef uint8_t xen_domain_handle_t[16];
  57.578 +
  57.579 +/* Turn a plain number into a C unsigned long constant. */
  57.580 +#define __mk_unsigned_long(x) x ## UL
  57.581 +#define mk_unsigned_long(x) __mk_unsigned_long(x)
  57.582 +
  57.583 +DEFINE_XEN_GUEST_HANDLE(uint8_t);
  57.584 +DEFINE_XEN_GUEST_HANDLE(uint16_t);
  57.585 +DEFINE_XEN_GUEST_HANDLE(uint32_t);
  57.586 +DEFINE_XEN_GUEST_HANDLE(uint64_t);
  57.587 +
  57.588 +#else /* __ASSEMBLY__ */
  57.589 +
  57.590 +/* In assembly code we cannot use C numeric constant suffixes. */
  57.591 +#define mk_unsigned_long(x) x
  57.592 +
  57.593 +#endif /* !__ASSEMBLY__ */
  57.594 +
  57.595 +/* Default definitions for macros used by domctl/sysctl. */
  57.596 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
  57.597 +#ifndef uint64_aligned_t
  57.598 +#define uint64_aligned_t uint64_t
  57.599 +#endif
  57.600 +#ifndef XEN_GUEST_HANDLE_64
  57.601 +#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
  57.602 +#endif
  57.603 +#endif
  57.604 +
  57.605 +#endif /* __XEN_PUBLIC_XEN_H__ */
  57.606 +
  57.607 +/*
  57.608 + * Local variables:
  57.609 + * mode: C
  57.610 + * c-set-style: "BSD"
  57.611 + * c-basic-offset: 4
  57.612 + * tab-width: 4
  57.613 + * indent-tabs-mode: nil
  57.614 + * End:
  57.615 + */
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/common/include/public/xencomm.h	Wed Dec 05 11:14:28 2007 -0800
    58.3 @@ -0,0 +1,41 @@
    58.4 +/*
    58.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    58.6 + * of this software and associated documentation files (the "Software"), to
    58.7 + * deal in the Software without restriction, including without limitation the
    58.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    58.9 + * sell copies of the Software, and to permit persons to whom the Software is
   58.10 + * furnished to do so, subject to the following conditions:
   58.11 + *
   58.12 + * The above copyright notice and this permission notice shall be included in
   58.13 + * all copies or substantial portions of the Software.
   58.14 + *
   58.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   58.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   58.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   58.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   58.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   58.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   58.21 + * DEALINGS IN THE SOFTWARE.
   58.22 + *
   58.23 + * Copyright (C) IBM Corp. 2006
   58.24 + */
   58.25 +
   58.26 +#ifndef _XEN_XENCOMM_H_
   58.27 +#define _XEN_XENCOMM_H_
   58.28 +
   58.29 +/* A xencomm descriptor is a scatter/gather list containing physical
   58.30 + * addresses corresponding to a virtually contiguous memory area. The
   58.31 + * hypervisor translates these physical addresses to machine addresses to copy
   58.32 + * to and from the virtually contiguous area.
   58.33 + */
   58.34 +
   58.35 +#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
   58.36 +#define XENCOMM_INVALID (~0UL)
   58.37 +
   58.38 +struct xencomm_desc {
   58.39 +    uint32_t magic;
   58.40 +    uint32_t nr_addrs; /* the number of entries in address[] */
   58.41 +    uint64_t address[0];
   58.42 +};
   58.43 +
   58.44 +#endif /* _XEN_XENCOMM_H_ */
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/common/include/public/xenoprof.h	Wed Dec 05 11:14:28 2007 -0800
    59.3 @@ -0,0 +1,138 @@
    59.4 +/******************************************************************************
    59.5 + * xenoprof.h
    59.6 + * 
    59.7 + * Interface for enabling system wide profiling based on hardware performance
    59.8 + * counters
    59.9 + * 
   59.10 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   59.11 + * of this software and associated documentation files (the "Software"), to
   59.12 + * deal in the Software without restriction, including without limitation the
   59.13 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   59.14 + * sell copies of the Software, and to permit persons to whom the Software is
   59.15 + * furnished to do so, subject to the following conditions:
   59.16 + *
   59.17 + * The above copyright notice and this permission notice shall be included in
   59.18 + * all copies or substantial portions of the Software.
   59.19 + *
   59.20 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   59.21 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   59.22 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   59.23 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   59.24 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   59.25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   59.26 + * DEALINGS IN THE SOFTWARE.
   59.27 + *
   59.28 + * Copyright (C) 2005 Hewlett-Packard Co.
   59.29 + * Written by Aravind Menon & Jose Renato Santos
   59.30 + */
   59.31 +
   59.32 +#ifndef __XEN_PUBLIC_XENOPROF_H__
   59.33 +#define __XEN_PUBLIC_XENOPROF_H__
   59.34 +
   59.35 +#include "xen.h"
   59.36 +
   59.37 +/*
   59.38 + * Commands to HYPERVISOR_xenoprof_op().
   59.39 + */
   59.40 +#define XENOPROF_init                0
   59.41 +#define XENOPROF_reset_active_list   1
   59.42 +#define XENOPROF_reset_passive_list  2
   59.43 +#define XENOPROF_set_active          3
   59.44 +#define XENOPROF_set_passive         4
   59.45 +#define XENOPROF_reserve_counters    5
   59.46 +#define XENOPROF_counter             6
   59.47 +#define XENOPROF_setup_events        7
   59.48 +#define XENOPROF_enable_virq         8
   59.49 +#define XENOPROF_start               9
   59.50 +#define XENOPROF_stop               10
   59.51 +#define XENOPROF_disable_virq       11
   59.52 +#define XENOPROF_release_counters   12
   59.53 +#define XENOPROF_shutdown           13
   59.54 +#define XENOPROF_get_buffer         14
   59.55 +#define XENOPROF_set_backtrace      15
   59.56 +#define XENOPROF_last_op            15
   59.57 +
   59.58 +#define MAX_OPROF_EVENTS    32
   59.59 +#define MAX_OPROF_DOMAINS   25
   59.60 +#define XENOPROF_CPU_TYPE_SIZE 64
   59.61 +
   59.62 +/* Xenoprof performance events (not Xen events) */
   59.63 +struct event_log {
   59.64 +    uint64_t eip;
   59.65 +    uint8_t mode;
   59.66 +    uint8_t event;
   59.67 +};
   59.68 +
   59.69 +/* PC value that indicates a special code */
   59.70 +#define XENOPROF_ESCAPE_CODE ~0UL
   59.71 +/* Transient events for the xenoprof->oprofile cpu buf */
   59.72 +#define XENOPROF_TRACE_BEGIN 1
   59.73 +
   59.74 +/* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
   59.75 +struct xenoprof_buf {
   59.76 +    uint32_t event_head;
   59.77 +    uint32_t event_tail;
   59.78 +    uint32_t event_size;
   59.79 +    uint32_t vcpu_id;
   59.80 +    uint64_t xen_samples;
   59.81 +    uint64_t kernel_samples;
   59.82 +    uint64_t user_samples;
   59.83 +    uint64_t lost_samples;
   59.84 +    struct event_log event_log[1];
   59.85 +};
   59.86 +#ifndef __XEN__
   59.87 +typedef struct xenoprof_buf xenoprof_buf_t;
   59.88 +DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
   59.89 +#endif
   59.90 +
   59.91 +struct xenoprof_init {
   59.92 +    int32_t  num_events;
   59.93 +    int32_t  is_primary;
   59.94 +    char cpu_type[XENOPROF_CPU_TYPE_SIZE];
   59.95 +};
   59.96 +typedef struct xenoprof_init xenoprof_init_t;
   59.97 +DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
   59.98 +
   59.99 +struct xenoprof_get_buffer {
  59.100 +    int32_t  max_samples;
  59.101 +    int32_t  nbuf;
  59.102 +    int32_t  bufsize;
  59.103 +    uint64_t buf_gmaddr;
  59.104 +};
  59.105 +typedef struct xenoprof_get_buffer xenoprof_get_buffer_t;
  59.106 +DEFINE_XEN_GUEST_HANDLE(xenoprof_get_buffer_t);
  59.107 +
  59.108 +struct xenoprof_counter {
  59.109 +    uint32_t ind;
  59.110 +    uint64_t count;
  59.111 +    uint32_t enabled;
  59.112 +    uint32_t event;
  59.113 +    uint32_t hypervisor;
  59.114 +    uint32_t kernel;
  59.115 +    uint32_t user;
  59.116 +    uint64_t unit_mask;
  59.117 +};
  59.118 +typedef struct xenoprof_counter xenoprof_counter_t;
  59.119 +DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
  59.120 +
  59.121 +typedef struct xenoprof_passive {
  59.122 +    uint16_t domain_id;
  59.123 +    int32_t  max_samples;
  59.124 +    int32_t  nbuf;
  59.125 +    int32_t  bufsize;
  59.126 +    uint64_t buf_gmaddr;
  59.127 +} xenoprof_passive_t;
  59.128 +DEFINE_XEN_GUEST_HANDLE(xenoprof_passive_t);
  59.129 +
  59.130 +
  59.131 +#endif /* __XEN_PUBLIC_XENOPROF_H__ */
  59.132 +
  59.133 +/*
  59.134 + * Local variables:
  59.135 + * mode: C
  59.136 + * c-set-style: "BSD"
  59.137 + * c-basic-offset: 4
  59.138 + * tab-width: 4
  59.139 + * indent-tabs-mode: nil
  59.140 + * End:
  59.141 + */
    60.1 --- a/common/include/xen_windows.h	Wed Dec 05 19:56:17 2007 +1100
    60.2 +++ b/common/include/xen_windows.h	Wed Dec 05 11:14:28 2007 -0800
    60.3 @@ -6,13 +6,13 @@
    60.4  
    60.5  #define __XEN_INTERFACE_VERSION__ 0x00030205
    60.6  #define __i386__
    60.7 -typedef signed char int8_t;
    60.8 -typedef unsigned char uint8_t;
    60.9 -typedef SHORT int16_t;
   60.10 -typedef USHORT uint16_t;
   60.11 -typedef LONG int32_t;
   60.12 -typedef ULONG uint32_t;
   60.13 -typedef ULONGLONG uint64_t;
   60.14 +typedef INT8 int8_t;
   60.15 +typedef UINT8 uint8_t;
   60.16 +typedef INT16 int16_t;
   60.17 +typedef UINT16 uint16_t;
   60.18 +typedef INT32 int32_t;
   60.19 +typedef UINT32 uint32_t;
   60.20 +typedef UINT64 uint64_t;
   60.21  typedef unsigned long pgentry_t;
   60.22  
   60.23  #include <xen.h>
    61.1 --- a/common/include/xenbus_public.h	Wed Dec 05 19:56:17 2007 +1100
    61.2 +++ b/common/include/xenbus_public.h	Wed Dec 05 11:14:28 2007 -0800
    61.3 @@ -24,21 +24,21 @@ typedef VOID
    61.4  (*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
    61.5  
    61.6  typedef char *
    61.7 -(*PXEN_XENBUS_READ)(xenbus_transaction_t xbt, const char *path, char **value);
    61.8 -typedef char *
    61.9 -(*PXEN_XENBUS_WRITE)(xenbus_transaction_t xbt, const char *path, const char *value);
   61.10 -typedef char *
   61.11 -(*PXEN_XENBUS_PRINTF)(xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
   61.12 +(*PXEN_XENBUS_READ)(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
   61.13  typedef char *
   61.14 -(*PXEN_XENBUS_STARTTRANSACTION)(xenbus_transaction_t *xbt);
   61.15 -typedef char *
   61.16 -(*PXEN_XENBUS_ENDTRANSACTION)(xenbus_transaction_t t, int abort, int *retry);
   61.17 +(*PXEN_XENBUS_WRITE)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value);
   61.18  typedef char *
   61.19 -(*PXEN_XENBUS_LIST)(xenbus_transaction_t xbt, const char *prefix, char ***contents);
   61.20 +(*PXEN_XENBUS_PRINTF)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
   61.21  typedef char *
   61.22 -(*PXEN_XENBUS_ADDWATCH)(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   61.23 +(*PXEN_XENBUS_STARTTRANSACTION)(PVOID Context, xenbus_transaction_t *xbt);
   61.24  typedef char *
   61.25 -(*PXEN_XENBUS_REMWATCH)(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   61.26 +(*PXEN_XENBUS_ENDTRANSACTION)(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
   61.27 +typedef char *
   61.28 +(*PXEN_XENBUS_LIST)(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
   61.29 +typedef char *
   61.30 +(*PXEN_XENBUS_ADDWATCH)(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   61.31 +typedef char *
   61.32 +(*PXEN_XENBUS_REMWATCH)(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   61.33  
   61.34  typedef struct _XEN_IFACE_XENBUS {
   61.35    INTERFACE InterfaceHeader;
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/target/netxen.inf	Wed Dec 05 11:14:28 2007 -0800
    62.3 @@ -0,0 +1,100 @@
    62.4 +[Version]
    62.5 +Signature="$WINDOWS NT$"
    62.6 +Class=Net
    62.7 +ClassGuid={4D36E972-E325-11CE-BFC1-08002BE10318}
    62.8 +Provider=%JAMESHARPER%
    62.9 +DriverVer=11/11/2007,1.0.1.290
   62.10 +
   62.11 +[DestinationDirs]
   62.12 +DefaultDestDir = 12
   62.13 +ClassInstall32_CopyFiles=11
   62.14 +CoInstaller_CopyFiles = 11
   62.15 +
   62.16 +; ================= Class section =====================
   62.17 +
   62.18