win-pvdrivers

changeset 59:d01d2a544b72

Updates to merge with Andy's tree
author James Harper <james.harper@bendigoit.com.au>
date Wed Dec 19 09:23:32 2007 +1100 (2007-12-19)
parents 70ab0938d3db 1acf9205fc43
children 4543c7e451ca
files dirs xenpci/sources xenpci/xenbus.h xenpci/xenpci.c xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/BUILDING.txt	Tue Dec 18 20:51:54 2007 +1100
     1.2 +++ b/BUILDING.txt	Wed Dec 19 09:23:32 2007 +1100
     1.3 @@ -4,11 +4,10 @@ 2. Start the WDF Build Environment that 
     1.4  
     1.5  3. Use Mercurial (get it from http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages) to get the latest sources from http://xenbits.xensource.com/ext/win-pvdrivers.hg.
     1.6  
     1.7 -4. Copy the whole xen/include/public folder and put it in common/include/public in the Windows PV drivers tree.
     1.8 +4. Go into each of xenpci, xenvbd, xennet, and xenhide and do a 'BLD'.
     1.9  
    1.10 -5. Go into each of xenpci, xenvbd, and xenhide and do a 'build'.
    1.11 -
    1.12 -6. Assuming all went well, your drivers should be in the target subfolder of each of those directories.
    1.13 +5. Assuming all went well, your drivers should be in toplevel target/i386
    1.14 +directory.
    1.15  
    1.16  I've probably omitted some vitally important step from the above, so please let me know if you need any assistance compiling.
    1.17  
     2.1 --- a/common/include/evtchn_public.h	Tue Dec 18 20:51:54 2007 +1100
     2.2 +++ b/common/include/evtchn_public.h	Wed Dec 19 09:23:32 2007 +1100
     2.3 @@ -23,23 +23,23 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  DEFINE_GUID( GUID_XEN_IFACE_EVTCHN, 0xD2D20756, 0xDE69, 0x4447, 0x8A, 0x7D, 0x98, 0x37, 0x19, 0x7D, 0x61, 0x66);
     2.5  //{D2D20756-DE69-4447-8A7D-9837197D6166}
     2.6  
     2.7 -typedef evtchn_port_t
     2.8 -(*PXEN_EVTCHN_ALLOCUNBOUND)(domid_t Domain);
     2.9 -
    2.10  typedef NTSTATUS
    2.11 -(*PXEN_EVTCHN_BIND)(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    2.12 +(*PXEN_EVTCHN_BIND)(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    2.13  
    2.14  typedef NTSTATUS
    2.15 -(*PXEN_EVTCHN_UNBIND)(evtchn_port_t Port);
    2.16 +(*PXEN_EVTCHN_UNBIND)(PVOID Context, evtchn_port_t Port);
    2.17  
    2.18  typedef NTSTATUS
    2.19 -(*PXEN_EVTCHN_MASK)(evtchn_port_t Port);
    2.20 +(*PXEN_EVTCHN_MASK)(PVOID Context, evtchn_port_t Port);
    2.21  
    2.22  typedef NTSTATUS
    2.23 -(*PXEN_EVTCHN_UNMASK)(evtchn_port_t Port);
    2.24 +(*PXEN_EVTCHN_UNMASK)(PVOID Context, evtchn_port_t Port);
    2.25  
    2.26  typedef NTSTATUS
    2.27 -(*PXEN_EVTCHN_NOTIFY)(evtchn_port_t Port);
    2.28 +(*PXEN_EVTCHN_NOTIFY)(PVOID Context, evtchn_port_t Port);
    2.29 +
    2.30 +typedef evtchn_port_t
    2.31 +(*PXEN_EVTCHN_ALLOCUNBOUND)(PVOID Context, domid_t Domain);
    2.32  
    2.33  typedef struct _XENBUS_IFACE_EVTCHN {
    2.34    INTERFACE InterfaceHeader;
     3.1 --- a/common/include/gnttbl_public.h	Tue Dec 18 20:51:54 2007 +1100
     3.2 +++ b/common/include/gnttbl_public.h	Wed Dec 19 09:23:32 2007 +1100
     3.3 @@ -24,9 +24,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     3.4  DEFINE_GUID(GUID_XEN_IFACE_GNTTBL, 0x6a71acf8, 0xf6d, 0x4022, 0xba, 0x60, 0x19, 0x98, 0x6e, 0xbe, 0xea, 0x73);
     3.5  
     3.6  typedef grant_ref_t
     3.7 -(*PXEN_GNTTBL_GRANTACCESS)(domid_t domid, unsigned long frame, int readonly);
     3.8 +(*PXEN_GNTTBL_GRANTACCESS)(WDFDEVICE Device, domid_t domid, unsigned long frame, int readonly);
     3.9  typedef BOOLEAN
    3.10 -(*PXEN_GNTTBL_ENDACCESS)(grant_ref_t ref);
    3.11 +(*PXEN_GNTTBL_ENDACCESS)(WDFDEVICE Device, grant_ref_t ref);
    3.12  
    3.13  typedef struct _XEN_IFACE_GNTTBL {
    3.14    INTERFACE InterfaceHeader;
     4.1 --- a/common/include/hypercall.h	Tue Dec 18 20:51:54 2007 +1100
     4.2 +++ b/common/include/hypercall.h	Wed Dec 19 09:23:32 2007 +1100
     4.3 @@ -19,11 +19,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  
     4.5  #include "xenpci.h"
     4.6  
     4.7 -char *hypercall_stubs;
     4.8 -
     4.9  static __inline int
    4.10 -HYPERVISOR_memory_op(int cmd, void *arg)
    4.11 +HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
    4.12  {
    4.13 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.14    long __res;
    4.15    __asm {
    4.16      mov ebx, cmd
    4.17 @@ -37,8 +36,9 @@ HYPERVISOR_memory_op(int cmd, void *arg)
    4.18  }
    4.19  
    4.20  static __inline int
    4.21 -HYPERVISOR_xen_version(int cmd, void *arg)
    4.22 +HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
    4.23  {
    4.24 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.25    long __res;
    4.26    __asm {
    4.27      mov ebx, cmd
    4.28 @@ -52,8 +52,9 @@ HYPERVISOR_xen_version(int cmd, void *ar
    4.29  }
    4.30  
    4.31  static __inline int
    4.32 -HYPERVISOR_grant_table_op(int cmd, void *uop, unsigned int count)
    4.33 +HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
    4.34  {
    4.35 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.36    long __res;
    4.37    __asm {
    4.38      mov ebx, cmd
    4.39 @@ -68,8 +69,9 @@ HYPERVISOR_grant_table_op(int cmd, void 
    4.40  }
    4.41  
    4.42  static __inline int
    4.43 -HYPERVISOR_mmu_update(mmu_update_t *req, int count, int *success_count, domid_t domid)
    4.44 +HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
    4.45  {
    4.46 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.47    long __res;
    4.48    long _domid = (long)domid;
    4.49    __asm {
    4.50 @@ -86,8 +88,9 @@ HYPERVISOR_mmu_update(mmu_update_t *req,
    4.51  }
    4.52  
    4.53  static __inline int
    4.54 -HYPERVISOR_console_io(int cmd, int count, char *string)
    4.55 +HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
    4.56  {
    4.57 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.58    long __res;
    4.59    __asm {
    4.60      mov ebx, cmd
    4.61 @@ -102,8 +105,9 @@ HYPERVISOR_console_io(int cmd, int count
    4.62  }
    4.63  
    4.64  static __inline int
    4.65 -HYPERVISOR_hvm_op(int op, struct xen_hvm_param *arg)
    4.66 +HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
    4.67  {
    4.68 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.69    long __res;
    4.70    __asm {
    4.71      mov ebx, op
    4.72 @@ -117,8 +121,9 @@ HYPERVISOR_hvm_op(int op, struct xen_hvm
    4.73  }
    4.74  
    4.75  static __inline int
    4.76 -HYPERVISOR_event_channel_op(int cmd, void *op)
    4.77 +HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
    4.78  {
    4.79 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    4.80    long __res;
    4.81    __asm {
    4.82      mov ebx, cmd
    4.83 @@ -132,7 +137,7 @@ HYPERVISOR_event_channel_op(int cmd, voi
    4.84  }
    4.85  
    4.86  static __inline ULONGLONG
    4.87 -hvm_get_parameter(int hvm_param)
    4.88 +hvm_get_parameter(WDFDEVICE Device, int hvm_param)
    4.89  {
    4.90    struct xen_hvm_param a;
    4.91    int retval;
    4.92 @@ -141,7 +146,7 @@ hvm_get_parameter(int hvm_param)
    4.93    a.domid = DOMID_SELF;
    4.94    a.index = hvm_param;
    4.95    //a.value = via;
    4.96 -  retval = HYPERVISOR_hvm_op(HVMOP_get_param, &a);
    4.97 +  retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
    4.98    KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
    4.99    KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
   4.100    return a.value;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/common/include/public/COPYING	Wed Dec 19 09:23:32 2007 +1100
     5.3 @@ -0,0 +1,38 @@
     5.4 +XEN NOTICE
     5.5 +==========
     5.6 +
     5.7 +This copyright applies to all files within this subdirectory and its
     5.8 +subdirectories:
     5.9 +  include/public/*.h
    5.10 +  include/public/hvm/*.h
    5.11 +  include/public/io/*.h
    5.12 +
    5.13 +The intention is that these files can be freely copied into the source
    5.14 +tree of an operating system when porting that OS to run on Xen. Doing
    5.15 +so does *not* cause the OS to become subject to the terms of the GPL.
    5.16 +
    5.17 +All other files in the Xen source distribution are covered by version
    5.18 +2 of the GNU General Public License except where explicitly stated
    5.19 +otherwise within individual source files.
    5.20 +
    5.21 + -- Keir Fraser (on behalf of the Xen team)
    5.22 +
    5.23 +=====================================================================
    5.24 +
    5.25 +Permission is hereby granted, free of charge, to any person obtaining a copy
    5.26 +of this software and associated documentation files (the "Software"), to
    5.27 +deal in the Software without restriction, including without limitation the
    5.28 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    5.29 +sell copies of the Software, and to permit persons to whom the Software is
    5.30 +furnished to do so, subject to the following conditions:
    5.31 +
    5.32 +The above copyright notice and this permission notice shall be included in
    5.33 +all copies or substantial portions of the Software.
    5.34 +
    5.35 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    5.36 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    5.37 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    5.38 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    5.39 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    5.40 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
    5.41 +DEALINGS IN THE SOFTWARE.
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/common/include/public/acm.h	Wed Dec 19 09:23:32 2007 +1100
     6.3 @@ -0,0 +1,228 @@
     6.4 +/*
     6.5 + * acm.h: Xen access control module interface defintions
     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, International Business Machines Corporation.
    6.27 + */
    6.28 +
    6.29 +#ifndef _XEN_PUBLIC_ACM_H
    6.30 +#define _XEN_PUBLIC_ACM_H
    6.31 +
    6.32 +#include "xen.h"
    6.33 +
    6.34 +/* if ACM_DEBUG defined, all hooks should
    6.35 + * print a short trace message (comment it out
    6.36 + * when not in testing mode )
    6.37 + */
    6.38 +/* #define ACM_DEBUG */
    6.39 +
    6.40 +#ifdef ACM_DEBUG
    6.41 +#  define printkd(fmt, args...) printk(fmt,## args)
    6.42 +#else
    6.43 +#  define printkd(fmt, args...)
    6.44 +#endif
    6.45 +
    6.46 +/* default ssid reference value if not supplied */
    6.47 +#define ACM_DEFAULT_SSID  0x0
    6.48 +#define ACM_DEFAULT_LOCAL_SSID  0x0
    6.49 +
    6.50 +/* Internal ACM ERROR types */
    6.51 +#define ACM_OK     0
    6.52 +#define ACM_UNDEF   -1
    6.53 +#define ACM_INIT_SSID_ERROR  -2
    6.54 +#define ACM_INIT_SOID_ERROR  -3
    6.55 +#define ACM_ERROR          -4
    6.56 +
    6.57 +/* External ACCESS DECISIONS */
    6.58 +#define ACM_ACCESS_PERMITTED        0
    6.59 +#define ACM_ACCESS_DENIED           -111
    6.60 +#define ACM_NULL_POINTER_ERROR      -200
    6.61 +
    6.62 +/*
    6.63 +   Error codes reported in when trying to test for a new policy
    6.64 +   These error codes are reported in an array of tuples where
    6.65 +   each error code is followed by a parameter describing the error
    6.66 +   more closely, such as a domain id.
    6.67 +*/
    6.68 +#define ACM_EVTCHN_SHARING_VIOLATION       0x100
    6.69 +#define ACM_GNTTAB_SHARING_VIOLATION       0x101
    6.70 +#define ACM_DOMAIN_LOOKUP                  0x102
    6.71 +#define ACM_CHWALL_CONFLICT                0x103
    6.72 +#define ACM_SSIDREF_IN_USE                 0x104
    6.73 +
    6.74 +
    6.75 +/* primary policy in lower 4 bits */
    6.76 +#define ACM_NULL_POLICY 0
    6.77 +#define ACM_CHINESE_WALL_POLICY 1
    6.78 +#define ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY 2
    6.79 +#define ACM_POLICY_UNDEFINED 15
    6.80 +
    6.81 +/* combinations have secondary policy component in higher 4bit */
    6.82 +#define ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY \
    6.83 +    ((ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY << 4) | ACM_CHINESE_WALL_POLICY)
    6.84 +
    6.85 +/* policy: */
    6.86 +#define ACM_POLICY_NAME(X) \
    6.87 + ((X) == (ACM_NULL_POLICY)) ? "NULL" :                        \
    6.88 +    ((X) == (ACM_CHINESE_WALL_POLICY)) ? "CHINESE WALL" :        \
    6.89 +    ((X) == (ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "SIMPLE TYPE ENFORCEMENT" : \
    6.90 +    ((X) == (ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "CHINESE WALL AND SIMPLE TYPE ENFORCEMENT" : \
    6.91 +     "UNDEFINED"
    6.92 +
    6.93 +/* the following policy versions must be increased
    6.94 + * whenever the interpretation of the related
    6.95 + * policy's data structure changes
    6.96 + */
    6.97 +#define ACM_POLICY_VERSION 3
    6.98 +#define ACM_CHWALL_VERSION 1
    6.99 +#define ACM_STE_VERSION  1
   6.100 +
   6.101 +/* defines a ssid reference used by xen */
   6.102 +typedef uint32_t ssidref_t;
   6.103 +
   6.104 +/* hooks that are known to domains */
   6.105 +#define ACMHOOK_none    0
   6.106 +#define ACMHOOK_sharing 1
   6.107 +
   6.108 +/* -------security policy relevant type definitions-------- */
   6.109 +
   6.110 +/* type identifier; compares to "equal" or "not equal" */
   6.111 +typedef uint16_t domaintype_t;
   6.112 +
   6.113 +/* CHINESE WALL POLICY DATA STRUCTURES
   6.114 + *
   6.115 + * current accumulated conflict type set:
   6.116 + * When a domain is started and has a type that is in
   6.117 + * a conflict set, the conflicting types are incremented in
   6.118 + * the aggregate set. When a domain is destroyed, the 
   6.119 + * conflicting types to its type are decremented.
   6.120 + * If a domain has multiple types, this procedure works over
   6.121 + * all those types.
   6.122 + *
   6.123 + * conflict_aggregate_set[i] holds the number of
   6.124 + *   running domains that have a conflict with type i.
   6.125 + *
   6.126 + * running_types[i] holds the number of running domains
   6.127 + *        that include type i in their ssidref-referenced type set
   6.128 + *
   6.129 + * conflict_sets[i][j] is "0" if type j has no conflict
   6.130 + *    with type i and is "1" otherwise.
   6.131 + */
   6.132 +/* high-16 = version, low-16 = check magic */
   6.133 +#define ACM_MAGIC  0x0001debc
   6.134 +
   6.135 +/* each offset in bytes from start of the struct they
   6.136 + * are part of */
   6.137 +
   6.138 +/* V3 of the policy buffer aded a version structure */
   6.139 +struct acm_policy_version
   6.140 +{
   6.141 +    uint32_t major;
   6.142 +    uint32_t minor;
   6.143 +};
   6.144 +
   6.145 +
   6.146 +/* each buffer consists of all policy information for
   6.147 + * the respective policy given in the policy code
   6.148 + *
   6.149 + * acm_policy_buffer, acm_chwall_policy_buffer,
   6.150 + * and acm_ste_policy_buffer need to stay 32-bit aligned
   6.151 + * because we create binary policies also with external
   6.152 + * tools that assume packed representations (e.g. the java tool)
   6.153 + */
   6.154 +struct acm_policy_buffer {
   6.155 +    uint32_t policy_version; /* ACM_POLICY_VERSION */
   6.156 +    uint32_t magic;
   6.157 +    uint32_t len;
   6.158 +    uint32_t policy_reference_offset;
   6.159 +    uint32_t primary_policy_code;
   6.160 +    uint32_t primary_buffer_offset;
   6.161 +    uint32_t secondary_policy_code;
   6.162 +    uint32_t secondary_buffer_offset;
   6.163 +    struct acm_policy_version xml_pol_version; /* add in V3 */
   6.164 +};
   6.165 +
   6.166 +
   6.167 +struct acm_policy_reference_buffer {
   6.168 +    uint32_t len;
   6.169 +};
   6.170 +
   6.171 +struct acm_chwall_policy_buffer {
   6.172 +    uint32_t policy_version; /* ACM_CHWALL_VERSION */
   6.173 +    uint32_t policy_code;
   6.174 +    uint32_t chwall_max_types;
   6.175 +    uint32_t chwall_max_ssidrefs;
   6.176 +    uint32_t chwall_max_conflictsets;
   6.177 +    uint32_t chwall_ssid_offset;
   6.178 +    uint32_t chwall_conflict_sets_offset;
   6.179 +    uint32_t chwall_running_types_offset;
   6.180 +    uint32_t chwall_conflict_aggregate_offset;
   6.181 +};
   6.182 +
   6.183 +struct acm_ste_policy_buffer {
   6.184 +    uint32_t policy_version; /* ACM_STE_VERSION */
   6.185 +    uint32_t policy_code;
   6.186 +    uint32_t ste_max_types;
   6.187 +    uint32_t ste_max_ssidrefs;
   6.188 +    uint32_t ste_ssid_offset;
   6.189 +};
   6.190 +
   6.191 +struct acm_stats_buffer {
   6.192 +    uint32_t magic;
   6.193 +    uint32_t len;
   6.194 +    uint32_t primary_policy_code;
   6.195 +    uint32_t primary_stats_offset;
   6.196 +    uint32_t secondary_policy_code;
   6.197 +    uint32_t secondary_stats_offset;
   6.198 +};
   6.199 +
   6.200 +struct acm_ste_stats_buffer {
   6.201 +    uint32_t ec_eval_count;
   6.202 +    uint32_t gt_eval_count;
   6.203 +    uint32_t ec_denied_count;
   6.204 +    uint32_t gt_denied_count;
   6.205 +    uint32_t ec_cachehit_count;
   6.206 +    uint32_t gt_cachehit_count;
   6.207 +};
   6.208 +
   6.209 +struct acm_ssid_buffer {
   6.210 +    uint32_t len;
   6.211 +    ssidref_t ssidref;
   6.212 +    uint32_t policy_reference_offset;
   6.213 +    uint32_t primary_policy_code;
   6.214 +    uint32_t primary_max_types;
   6.215 +    uint32_t primary_types_offset;
   6.216 +    uint32_t secondary_policy_code;
   6.217 +    uint32_t secondary_max_types;
   6.218 +    uint32_t secondary_types_offset;
   6.219 +};
   6.220 +
   6.221 +#endif
   6.222 +
   6.223 +/*
   6.224 + * Local variables:
   6.225 + * mode: C
   6.226 + * c-set-style: "BSD"
   6.227 + * c-basic-offset: 4
   6.228 + * tab-width: 4
   6.229 + * indent-tabs-mode: nil
   6.230 + * End:
   6.231 + */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/common/include/public/acm_ops.h	Wed Dec 19 09:23:32 2007 +1100
     7.3 @@ -0,0 +1,159 @@
     7.4 +/*
     7.5 + * acm_ops.h: Xen access control module hypervisor commands
     7.6 + *
     7.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
     7.8 + * of this software and associated documentation files (the "Software"), to
     7.9 + * deal in the Software without restriction, including without limitation the
    7.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    7.11 + * sell copies of the Software, and to permit persons to whom the Software is
    7.12 + * furnished to do so, subject to the following conditions:
    7.13 + *
    7.14 + * The above copyright notice and this permission notice shall be included in
    7.15 + * all copies or substantial portions of the Software.
    7.16 + *
    7.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    7.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    7.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    7.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    7.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    7.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    7.23 + * DEALINGS IN THE SOFTWARE.
    7.24 + *
    7.25 + * Reiner Sailer <sailer@watson.ibm.com>
    7.26 + * Copyright (c) 2005,2006 International Business Machines Corporation.
    7.27 + */
    7.28 +
    7.29 +#ifndef __XEN_PUBLIC_ACM_OPS_H__
    7.30 +#define __XEN_PUBLIC_ACM_OPS_H__
    7.31 +
    7.32 +#include "xen.h"
    7.33 +#include "acm.h"
    7.34 +
    7.35 +/*
    7.36 + * Make sure you increment the interface version whenever you modify this file!
    7.37 + * This makes sure that old versions of acm tools will stop working in a
    7.38 + * well-defined way (rather than crashing the machine, for instance).
    7.39 + */
    7.40 +#define ACM_INTERFACE_VERSION   0xAAAA000A
    7.41 +
    7.42 +/************************************************************************/
    7.43 +
    7.44 +/*
    7.45 + * Prototype for this hypercall is:
    7.46 + *  int acm_op(int cmd, void *args)
    7.47 + * @cmd  == ACMOP_??? (access control module operation).
    7.48 + * @args == Operation-specific extra arguments (NULL if none).
    7.49 + */
    7.50 +
    7.51 +
    7.52 +#define ACMOP_setpolicy         1
    7.53 +struct acm_setpolicy {
    7.54 +    /* IN */
    7.55 +    XEN_GUEST_HANDLE_64(void) pushcache;
    7.56 +    uint32_t pushcache_size;
    7.57 +};
    7.58 +
    7.59 +
    7.60 +#define ACMOP_getpolicy         2
    7.61 +struct acm_getpolicy {
    7.62 +    /* IN */
    7.63 +    XEN_GUEST_HANDLE_64(void) pullcache;
    7.64 +    uint32_t pullcache_size;
    7.65 +};
    7.66 +
    7.67 +
    7.68 +#define ACMOP_dumpstats         3
    7.69 +struct acm_dumpstats {
    7.70 +    /* IN */
    7.71 +    XEN_GUEST_HANDLE_64(void) pullcache;
    7.72 +    uint32_t pullcache_size;
    7.73 +};
    7.74 +
    7.75 +
    7.76 +#define ACMOP_getssid           4
    7.77 +#define ACM_GETBY_ssidref  1
    7.78 +#define ACM_GETBY_domainid 2
    7.79 +struct acm_getssid {
    7.80 +    /* IN */
    7.81 +    uint32_t get_ssid_by; /* ACM_GETBY_* */
    7.82 +    union {
    7.83 +        domaintype_t domainid;
    7.84 +        ssidref_t    ssidref;
    7.85 +    } id;
    7.86 +    XEN_GUEST_HANDLE_64(void) ssidbuf;
    7.87 +    uint32_t ssidbuf_size;
    7.88 +};
    7.89 +
    7.90 +#define ACMOP_getdecision      5
    7.91 +struct acm_getdecision {
    7.92 +    /* IN */
    7.93 +    uint32_t get_decision_by1; /* ACM_GETBY_* */
    7.94 +    uint32_t get_decision_by2; /* ACM_GETBY_* */
    7.95 +    union {
    7.96 +        domaintype_t domainid;
    7.97 +        ssidref_t    ssidref;
    7.98 +    } id1;
    7.99 +    union {
   7.100 +        domaintype_t domainid;
   7.101 +        ssidref_t    ssidref;
   7.102 +    } id2;
   7.103 +    uint32_t hook;
   7.104 +    /* OUT */
   7.105 +    uint32_t acm_decision;
   7.106 +};
   7.107 +
   7.108 +
   7.109 +#define ACMOP_chgpolicy        6
   7.110 +struct acm_change_policy {
   7.111 +    /* IN */
   7.112 +    XEN_GUEST_HANDLE_64(void) policy_pushcache;
   7.113 +    uint32_t policy_pushcache_size;
   7.114 +    XEN_GUEST_HANDLE_64(void) del_array;
   7.115 +    uint32_t delarray_size;
   7.116 +    XEN_GUEST_HANDLE_64(void) chg_array;
   7.117 +    uint32_t chgarray_size;
   7.118 +    /* OUT */
   7.119 +    /* array with error code */
   7.120 +    XEN_GUEST_HANDLE_64(void) err_array;
   7.121 +    uint32_t errarray_size;
   7.122 +};
   7.123 +
   7.124 +#define ACMOP_relabeldoms       7
   7.125 +struct acm_relabel_doms {
   7.126 +    /* IN */
   7.127 +    XEN_GUEST_HANDLE_64(void) relabel_map;
   7.128 +    uint32_t relabel_map_size;
   7.129 +    /* OUT */
   7.130 +    XEN_GUEST_HANDLE_64(void) err_array;
   7.131 +    uint32_t errarray_size;
   7.132 +};
   7.133 +
   7.134 +/* future interface to Xen */
   7.135 +struct xen_acmctl {
   7.136 +    uint32_t cmd;
   7.137 +    uint32_t interface_version;
   7.138 +    union {
   7.139 +        struct acm_setpolicy     setpolicy;
   7.140 +        struct acm_getpolicy     getpolicy;
   7.141 +        struct acm_dumpstats     dumpstats;
   7.142 +        struct acm_getssid       getssid;
   7.143 +        struct acm_getdecision   getdecision;
   7.144 +        struct acm_change_policy change_policy;
   7.145 +        struct acm_relabel_doms  relabel_doms;
   7.146 +    } u;
   7.147 +};
   7.148 +
   7.149 +typedef struct xen_acmctl xen_acmctl_t;
   7.150 +DEFINE_XEN_GUEST_HANDLE(xen_acmctl_t);
   7.151 +
   7.152 +#endif /* __XEN_PUBLIC_ACM_OPS_H__ */
   7.153 +
   7.154 +/*
   7.155 + * Local variables:
   7.156 + * mode: C
   7.157 + * c-set-style: "BSD"
   7.158 + * c-basic-offset: 4
   7.159 + * tab-width: 4
   7.160 + * indent-tabs-mode: nil
   7.161 + * End:
   7.162 + */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/common/include/public/arch-ia64.h	Wed Dec 19 09:23:32 2007 +1100
     8.3 @@ -0,0 +1,522 @@
     8.4 +/******************************************************************************
     8.5 + * arch-ia64/hypervisor-if.h
     8.6 + * 
     8.7 + * Guest OS interface to IA64 Xen.
     8.8 + *
     8.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    8.10 + * of this software and associated documentation files (the "Software"), to
    8.11 + * deal in the Software without restriction, including without limitation the
    8.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    8.13 + * sell copies of the Software, and to permit persons to whom the Software is
    8.14 + * furnished to do so, subject to the following conditions:
    8.15 + *
    8.16 + * The above copyright notice and this permission notice shall be included in
    8.17 + * all copies or substantial portions of the Software.
    8.18 + *
    8.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    8.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    8.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    8.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    8.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    8.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    8.25 + * DEALINGS IN THE SOFTWARE.
    8.26 + *
    8.27 + */
    8.28 +
    8.29 +#ifndef __HYPERVISOR_IF_IA64_H__
    8.30 +#define __HYPERVISOR_IF_IA64_H__
    8.31 +
    8.32 +/* Structural guest handles introduced in 0x00030201. */
    8.33 +#if __XEN_INTERFACE_VERSION__ >= 0x00030201
    8.34 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    8.35 +    typedef struct { type *p; } __guest_handle_ ## name
    8.36 +#else
    8.37 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    8.38 +    typedef type * __guest_handle_ ## name
    8.39 +#endif
    8.40 +
    8.41 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    8.42 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
    8.43 +#define XEN_GUEST_HANDLE_64(name)       XEN_GUEST_HANDLE(name)
    8.44 +#define uint64_aligned_t                uint64_t
    8.45 +#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
    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(u64,   unsigned long);
    8.56 +DEFINE_XEN_GUEST_HANDLE(char);
    8.57 +DEFINE_XEN_GUEST_HANDLE(int);
    8.58 +DEFINE_XEN_GUEST_HANDLE(long);
    8.59 +DEFINE_XEN_GUEST_HANDLE(void);
    8.60 +
    8.61 +typedef unsigned long xen_pfn_t;
    8.62 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    8.63 +#define PRI_xen_pfn "lx"
    8.64 +#endif
    8.65 +
    8.66 +/* Arch specific VIRQs definition */
    8.67 +#define VIRQ_ITC        VIRQ_ARCH_0 /* V. Virtual itc timer */
    8.68 +#define VIRQ_MCA_CMC    VIRQ_ARCH_1 /* MCA cmc interrupt */
    8.69 +#define VIRQ_MCA_CPE    VIRQ_ARCH_2 /* MCA cpe interrupt */
    8.70 +
    8.71 +/* Maximum number of virtual CPUs in multi-processor guests. */
    8.72 +/* WARNING: before changing this, check that shared_info fits on a page */
    8.73 +#define MAX_VIRT_CPUS 64
    8.74 +
    8.75 +#ifndef __ASSEMBLY__
    8.76 +
    8.77 +typedef unsigned long xen_ulong_t;
    8.78 +
    8.79 +#define INVALID_MFN       (~0UL)
    8.80 +
    8.81 +#define MEM_G   (1UL << 30)
    8.82 +#define MEM_M   (1UL << 20)
    8.83 +#define MEM_K   (1UL << 10)
    8.84 +
    8.85 +#define MMIO_START       (3 * MEM_G)
    8.86 +#define MMIO_SIZE        (512 * MEM_M)
    8.87 +
    8.88 +#define VGA_IO_START     0xA0000UL
    8.89 +#define VGA_IO_SIZE      0x20000
    8.90 +
    8.91 +#define LEGACY_IO_START  (MMIO_START + MMIO_SIZE)
    8.92 +#define LEGACY_IO_SIZE   (64*MEM_M)
    8.93 +
    8.94 +#define IO_PAGE_START (LEGACY_IO_START + LEGACY_IO_SIZE)
    8.95 +#define IO_PAGE_SIZE  PAGE_SIZE
    8.96 +
    8.97 +#define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
    8.98 +#define STORE_PAGE_SIZE  PAGE_SIZE
    8.99 +
   8.100 +#define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
   8.101 +#define BUFFER_IO_PAGE_SIZE PAGE_SIZE
   8.102 +
   8.103 +#define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
   8.104 +#define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
   8.105 +
   8.106 +#define IO_SAPIC_START   0xfec00000UL
   8.107 +#define IO_SAPIC_SIZE    0x100000
   8.108 +
   8.109 +#define PIB_START 0xfee00000UL
   8.110 +#define PIB_SIZE 0x200000
   8.111 +
   8.112 +#define GFW_START        (4*MEM_G -16*MEM_M)
   8.113 +#define GFW_SIZE         (16*MEM_M)
   8.114 +
   8.115 +/* Nvram belongs to GFW memory space  */
   8.116 +#define NVRAM_SIZE       (MEM_K * 64)
   8.117 +#define NVRAM_START      (GFW_START + 10 * MEM_M)
   8.118 +
   8.119 +#define NVRAM_VALID_SIG 0x4650494e45584948 		// "HIXENIPF"
   8.120 +struct nvram_save_addr {
   8.121 +    unsigned long addr;
   8.122 +    unsigned long signature;
   8.123 +};
   8.124 +
   8.125 +struct pt_fpreg {
   8.126 +    union {
   8.127 +        unsigned long bits[2];
   8.128 +        long double __dummy;    /* force 16-byte alignment */
   8.129 +    } u;
   8.130 +};
   8.131 +
   8.132 +struct cpu_user_regs {
   8.133 +    /* The following registers are saved by SAVE_MIN: */
   8.134 +    unsigned long b6;  /* scratch */
   8.135 +    unsigned long b7;  /* scratch */
   8.136 +
   8.137 +    unsigned long ar_csd; /* used by cmp8xchg16 (scratch) */
   8.138 +    unsigned long ar_ssd; /* reserved for future use (scratch) */
   8.139 +
   8.140 +    unsigned long r8;  /* scratch (return value register 0) */
   8.141 +    unsigned long r9;  /* scratch (return value register 1) */
   8.142 +    unsigned long r10; /* scratch (return value register 2) */
   8.143 +    unsigned long r11; /* scratch (return value register 3) */
   8.144 +
   8.145 +    unsigned long cr_ipsr; /* interrupted task's psr */
   8.146 +    unsigned long cr_iip;  /* interrupted task's instruction pointer */
   8.147 +    unsigned long cr_ifs;  /* interrupted task's function state */
   8.148 +
   8.149 +    unsigned long ar_unat; /* interrupted task's NaT register (preserved) */
   8.150 +    unsigned long ar_pfs;  /* prev function state  */
   8.151 +    unsigned long ar_rsc;  /* RSE configuration */
   8.152 +    /* The following two are valid only if cr_ipsr.cpl > 0: */
   8.153 +    unsigned long ar_rnat;  /* RSE NaT */
   8.154 +    unsigned long ar_bspstore; /* RSE bspstore */
   8.155 +
   8.156 +    unsigned long pr;  /* 64 predicate registers (1 bit each) */
   8.157 +    unsigned long b0;  /* return pointer (bp) */
   8.158 +    unsigned long loadrs;  /* size of dirty partition << 16 */
   8.159 +
   8.160 +    unsigned long r1;  /* the gp pointer */
   8.161 +    unsigned long r12; /* interrupted task's memory stack pointer */
   8.162 +    unsigned long r13; /* thread pointer */
   8.163 +
   8.164 +    unsigned long ar_fpsr;  /* floating point status (preserved) */
   8.165 +    unsigned long r15;  /* scratch */
   8.166 +
   8.167 + /* The remaining registers are NOT saved for system calls.  */
   8.168 +
   8.169 +    unsigned long r14;  /* scratch */
   8.170 +    unsigned long r2;  /* scratch */
   8.171 +    unsigned long r3;  /* scratch */
   8.172 +    unsigned long r16;  /* scratch */
   8.173 +    unsigned long r17;  /* scratch */
   8.174 +    unsigned long r18;  /* scratch */
   8.175 +    unsigned long r19;  /* scratch */
   8.176 +    unsigned long r20;  /* scratch */
   8.177 +    unsigned long r21;  /* scratch */
   8.178 +    unsigned long r22;  /* scratch */
   8.179 +    unsigned long r23;  /* scratch */
   8.180 +    unsigned long r24;  /* scratch */
   8.181 +    unsigned long r25;  /* scratch */
   8.182 +    unsigned long r26;  /* scratch */
   8.183 +    unsigned long r27;  /* scratch */
   8.184 +    unsigned long r28;  /* scratch */
   8.185 +    unsigned long r29;  /* scratch */
   8.186 +    unsigned long r30;  /* scratch */
   8.187 +    unsigned long r31;  /* scratch */
   8.188 +    unsigned long ar_ccv;  /* compare/exchange value (scratch) */
   8.189 +
   8.190 +    /*
   8.191 +     * Floating point registers that the kernel considers scratch:
   8.192 +     */
   8.193 +    struct pt_fpreg f6;  /* scratch */
   8.194 +    struct pt_fpreg f7;  /* scratch */
   8.195 +    struct pt_fpreg f8;  /* scratch */
   8.196 +    struct pt_fpreg f9;  /* scratch */
   8.197 +    struct pt_fpreg f10;  /* scratch */
   8.198 +    struct pt_fpreg f11;  /* scratch */
   8.199 +    unsigned long r4;  /* preserved */
   8.200 +    unsigned long r5;  /* preserved */
   8.201 +    unsigned long r6;  /* preserved */
   8.202 +    unsigned long r7;  /* preserved */
   8.203 +    unsigned long eml_unat;    /* used for emulating instruction */
   8.204 +    unsigned long pad0;     /* alignment pad */
   8.205 +
   8.206 +};
   8.207 +typedef struct cpu_user_regs cpu_user_regs_t;
   8.208 +
   8.209 +union vac {
   8.210 +    unsigned long value;
   8.211 +    struct {
   8.212 +        int a_int:1;
   8.213 +        int a_from_int_cr:1;
   8.214 +        int a_to_int_cr:1;
   8.215 +        int a_from_psr:1;
   8.216 +        int a_from_cpuid:1;
   8.217 +        int a_cover:1;
   8.218 +        int a_bsw:1;
   8.219 +        long reserved:57;
   8.220 +    };
   8.221 +};
   8.222 +typedef union vac vac_t;
   8.223 +
   8.224 +union vdc {
   8.225 +    unsigned long value;
   8.226 +    struct {
   8.227 +        int d_vmsw:1;
   8.228 +        int d_extint:1;
   8.229 +        int d_ibr_dbr:1;
   8.230 +        int d_pmc:1;
   8.231 +        int d_to_pmd:1;
   8.232 +        int d_itm:1;
   8.233 +        long reserved:58;
   8.234 +    };
   8.235 +};
   8.236 +typedef union vdc vdc_t;
   8.237 +
   8.238 +struct mapped_regs {
   8.239 +    union vac   vac;
   8.240 +    union vdc   vdc;
   8.241 +    unsigned long  virt_env_vaddr;
   8.242 +    unsigned long  reserved1[29];
   8.243 +    unsigned long  vhpi;
   8.244 +    unsigned long  reserved2[95];
   8.245 +    union {
   8.246 +        unsigned long  vgr[16];
   8.247 +        unsigned long bank1_regs[16]; // bank1 regs (r16-r31) when bank0 active
   8.248 +    };
   8.249 +    union {
   8.250 +        unsigned long  vbgr[16];
   8.251 +        unsigned long bank0_regs[16]; // bank0 regs (r16-r31) when bank1 active
   8.252 +    };
   8.253 +    unsigned long  vnat;
   8.254 +    unsigned long  vbnat;
   8.255 +    unsigned long  vcpuid[5];
   8.256 +    unsigned long  reserved3[11];
   8.257 +    unsigned long  vpsr;
   8.258 +    unsigned long  vpr;
   8.259 +    unsigned long  reserved4[76];
   8.260 +    union {
   8.261 +        unsigned long  vcr[128];
   8.262 +        struct {
   8.263 +            unsigned long dcr;  // CR0
   8.264 +            unsigned long itm;
   8.265 +            unsigned long iva;
   8.266 +            unsigned long rsv1[5];
   8.267 +            unsigned long pta;  // CR8
   8.268 +            unsigned long rsv2[7];
   8.269 +            unsigned long ipsr;  // CR16
   8.270 +            unsigned long isr;
   8.271 +            unsigned long rsv3;
   8.272 +            unsigned long iip;
   8.273 +            unsigned long ifa;
   8.274 +            unsigned long itir;
   8.275 +            unsigned long iipa;
   8.276 +            unsigned long ifs;
   8.277 +            unsigned long iim;  // CR24
   8.278 +            unsigned long iha;
   8.279 +            unsigned long rsv4[38];
   8.280 +            unsigned long lid;  // CR64
   8.281 +            unsigned long ivr;
   8.282 +            unsigned long tpr;
   8.283 +            unsigned long eoi;
   8.284 +            unsigned long irr[4];
   8.285 +            unsigned long itv;  // CR72
   8.286 +            unsigned long pmv;
   8.287 +            unsigned long cmcv;
   8.288 +            unsigned long rsv5[5];
   8.289 +            unsigned long lrr0;  // CR80
   8.290 +            unsigned long lrr1;
   8.291 +            unsigned long rsv6[46];
   8.292 +        };
   8.293 +    };
   8.294 +    union {
   8.295 +        unsigned long  reserved5[128];
   8.296 +        struct {
   8.297 +            unsigned long precover_ifs;
   8.298 +            unsigned long unat;  // not sure if this is needed until NaT arch is done
   8.299 +            int interrupt_collection_enabled; // virtual psr.ic
   8.300 +            /* virtual interrupt deliverable flag is evtchn_upcall_mask in
   8.301 +             * shared info area now. interrupt_mask_addr is the address
   8.302 +             * of evtchn_upcall_mask for current vcpu
   8.303 +             */
   8.304 +            unsigned char *interrupt_mask_addr;
   8.305 +            int pending_interruption;
   8.306 +            unsigned char vpsr_pp;
   8.307 +            unsigned char vpsr_dfh;
   8.308 +            unsigned char hpsr_dfh;
   8.309 +            unsigned char hpsr_mfh;
   8.310 +            unsigned long reserved5_1[4];
   8.311 +            int metaphysical_mode; // 1 = use metaphys mapping, 0 = use virtual
   8.312 +            int banknum; // 0 or 1, which virtual register bank is active
   8.313 +            unsigned long rrs[8]; // region registers
   8.314 +            unsigned long krs[8]; // kernel registers
   8.315 +            unsigned long pkrs[8]; // protection key registers
   8.316 +            unsigned long tmp[8]; // temp registers (e.g. for hyperprivops)
   8.317 +        };
   8.318 +    };
   8.319 +};
   8.320 +typedef struct mapped_regs mapped_regs_t;
   8.321 +
   8.322 +struct vpd {
   8.323 +    struct mapped_regs vpd_low;
   8.324 +    unsigned long  reserved6[3456];
   8.325 +    unsigned long  vmm_avail[128];
   8.326 +    unsigned long  reserved7[4096];
   8.327 +};
   8.328 +typedef struct vpd vpd_t;
   8.329 +
   8.330 +struct arch_vcpu_info {
   8.331 +};
   8.332 +typedef struct arch_vcpu_info arch_vcpu_info_t;
   8.333 +
   8.334 +struct arch_shared_info {
   8.335 +    /* PFN of the start_info page.  */
   8.336 +    unsigned long start_info_pfn;
   8.337 +
   8.338 +    /* Interrupt vector for event channel.  */
   8.339 +    int evtchn_vector;
   8.340 +
   8.341 +    uint64_t pad[32];
   8.342 +};
   8.343 +typedef struct arch_shared_info arch_shared_info_t;
   8.344 +
   8.345 +typedef unsigned long xen_callback_t;
   8.346 +
   8.347 +struct ia64_tr_entry {
   8.348 +    unsigned long pte;
   8.349 +    unsigned long itir;
   8.350 +    unsigned long vadr;
   8.351 +    unsigned long rid;
   8.352 +};
   8.353 +
   8.354 +struct vcpu_extra_regs {
   8.355 +    struct ia64_tr_entry itrs[8];
   8.356 +    struct ia64_tr_entry dtrs[8];
   8.357 +    unsigned long iva;
   8.358 +    unsigned long dcr;
   8.359 +    unsigned long event_callback_ip;
   8.360 +};
   8.361 +
   8.362 +struct vcpu_guest_context {
   8.363 +#define VGCF_EXTRA_REGS (1<<1)	/* Get/Set extra regs.  */
   8.364 +    unsigned long flags;       /* VGCF_* flags */
   8.365 +
   8.366 +    struct cpu_user_regs user_regs;
   8.367 +    struct vcpu_extra_regs extra_regs;
   8.368 +    unsigned long privregs_pfn;
   8.369 +};
   8.370 +typedef struct vcpu_guest_context vcpu_guest_context_t;
   8.371 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   8.372 +
   8.373 +/* dom0 vp op */
   8.374 +#define __HYPERVISOR_ia64_dom0vp_op     __HYPERVISOR_arch_0
   8.375 +/*  Map io space in machine address to dom0 physical address space.
   8.376 +    Currently physical assigned address equals to machine address.  */
   8.377 +#define IA64_DOM0VP_ioremap             0
   8.378 +
   8.379 +/* Convert a pseudo physical page frame number to the corresponding
   8.380 +   machine page frame number. If no page is assigned, INVALID_MFN or
   8.381 +   GPFN_INV_MASK is returned depending on domain's non-vti/vti mode.  */
   8.382 +#define IA64_DOM0VP_phystomach          1
   8.383 +
   8.384 +/* Convert a machine page frame number to the corresponding pseudo physical
   8.385 +   page frame number of the caller domain.  */
   8.386 +#define IA64_DOM0VP_machtophys          3
   8.387 +
   8.388 +/* Reserved for future use.  */
   8.389 +#define IA64_DOM0VP_iounmap             4
   8.390 +
   8.391 +/* Unmap and free pages contained in the specified pseudo physical region.  */
   8.392 +#define IA64_DOM0VP_zap_physmap         5
   8.393 +
   8.394 +/* Assign machine page frame to dom0's pseudo physical address space.  */
   8.395 +#define IA64_DOM0VP_add_physmap         6
   8.396 +
   8.397 +/* expose the p2m table into domain */
   8.398 +#define IA64_DOM0VP_expose_p2m          7
   8.399 +
   8.400 +/* xen perfmon */
   8.401 +#define IA64_DOM0VP_perfmon             8
   8.402 +
   8.403 +/* gmfn version of IA64_DOM0VP_add_physmap */
   8.404 +#define IA64_DOM0VP_add_physmap_with_gmfn       9
   8.405 +
   8.406 +/* Add an I/O port space range */
   8.407 +#define IA64_DOM0VP_add_io_space        11
   8.408 +
   8.409 +// flags for page assignement to pseudo physical address space
   8.410 +#define _ASSIGN_readonly                0
   8.411 +#define ASSIGN_readonly                 (1UL << _ASSIGN_readonly)
   8.412 +#define ASSIGN_writable                 (0UL << _ASSIGN_readonly) // dummy flag
   8.413 +/* Internal only: memory attribute must be WC/UC/UCE.  */
   8.414 +#define _ASSIGN_nocache                 1
   8.415 +#define ASSIGN_nocache                  (1UL << _ASSIGN_nocache)
   8.416 +// tlb tracking
   8.417 +#define _ASSIGN_tlb_track               2
   8.418 +#define ASSIGN_tlb_track                (1UL << _ASSIGN_tlb_track)
   8.419 +/* Internal only: associated with PGC_allocated bit */
   8.420 +#define _ASSIGN_pgc_allocated           3
   8.421 +#define ASSIGN_pgc_allocated            (1UL << _ASSIGN_pgc_allocated)
   8.422 +
   8.423 +/* This structure has the same layout of struct ia64_boot_param, defined in
   8.424 +   <asm/system.h>.  It is redefined here to ease use.  */
   8.425 +struct xen_ia64_boot_param {
   8.426 +	unsigned long command_line;	/* physical address of cmd line args */
   8.427 +	unsigned long efi_systab;	/* physical address of EFI system table */
   8.428 +	unsigned long efi_memmap;	/* physical address of EFI memory map */
   8.429 +	unsigned long efi_memmap_size;	/* size of EFI memory map */
   8.430 +	unsigned long efi_memdesc_size;	/* size of an EFI memory map descriptor */
   8.431 +	unsigned int  efi_memdesc_version;	/* memory descriptor version */
   8.432 +	struct {
   8.433 +		unsigned short num_cols;	/* number of columns on console.  */
   8.434 +		unsigned short num_rows;	/* number of rows on console.  */
   8.435 +		unsigned short orig_x;	/* cursor's x position */
   8.436 +		unsigned short orig_y;	/* cursor's y position */
   8.437 +	} console_info;
   8.438 +	unsigned long fpswa;		/* physical address of the fpswa interface */
   8.439 +	unsigned long initrd_start;
   8.440 +	unsigned long initrd_size;
   8.441 +	unsigned long domain_start;	/* va where the boot time domain begins */
   8.442 +	unsigned long domain_size;	/* how big is the boot domain */
   8.443 +};
   8.444 +
   8.445 +#endif /* !__ASSEMBLY__ */
   8.446 +
   8.447 +/* Size of the shared_info area (this is not related to page size).  */
   8.448 +#define XSI_SHIFT			14
   8.449 +#define XSI_SIZE			(1 << XSI_SHIFT)
   8.450 +/* Log size of mapped_regs area (64 KB - only 4KB is used).  */
   8.451 +#define XMAPPEDREGS_SHIFT		12
   8.452 +#define XMAPPEDREGS_SIZE		(1 << XMAPPEDREGS_SHIFT)
   8.453 +/* Offset of XASI (Xen arch shared info) wrt XSI_BASE.  */
   8.454 +#define XMAPPEDREGS_OFS			XSI_SIZE
   8.455 +
   8.456 +/* Hyperprivops.  */
   8.457 +#define HYPERPRIVOP_START		0x1
   8.458 +#define HYPERPRIVOP_RFI			(HYPERPRIVOP_START + 0x0)
   8.459 +#define HYPERPRIVOP_RSM_DT		(HYPERPRIVOP_START + 0x1)
   8.460 +#define HYPERPRIVOP_SSM_DT		(HYPERPRIVOP_START + 0x2)
   8.461 +#define HYPERPRIVOP_COVER		(HYPERPRIVOP_START + 0x3)
   8.462 +#define HYPERPRIVOP_ITC_D		(HYPERPRIVOP_START + 0x4)
   8.463 +#define HYPERPRIVOP_ITC_I		(HYPERPRIVOP_START + 0x5)
   8.464 +#define HYPERPRIVOP_SSM_I		(HYPERPRIVOP_START + 0x6)
   8.465 +#define HYPERPRIVOP_GET_IVR		(HYPERPRIVOP_START + 0x7)
   8.466 +#define HYPERPRIVOP_GET_TPR		(HYPERPRIVOP_START + 0x8)
   8.467 +#define HYPERPRIVOP_SET_TPR		(HYPERPRIVOP_START + 0x9)
   8.468 +#define HYPERPRIVOP_EOI			(HYPERPRIVOP_START + 0xa)
   8.469 +#define HYPERPRIVOP_SET_ITM		(HYPERPRIVOP_START + 0xb)
   8.470 +#define HYPERPRIVOP_THASH		(HYPERPRIVOP_START + 0xc)
   8.471 +#define HYPERPRIVOP_PTC_GA		(HYPERPRIVOP_START + 0xd)
   8.472 +#define HYPERPRIVOP_ITR_D		(HYPERPRIVOP_START + 0xe)
   8.473 +#define HYPERPRIVOP_GET_RR		(HYPERPRIVOP_START + 0xf)
   8.474 +#define HYPERPRIVOP_SET_RR		(HYPERPRIVOP_START + 0x10)
   8.475 +#define HYPERPRIVOP_SET_KR		(HYPERPRIVOP_START + 0x11)
   8.476 +#define HYPERPRIVOP_FC			(HYPERPRIVOP_START + 0x12)
   8.477 +#define HYPERPRIVOP_GET_CPUID		(HYPERPRIVOP_START + 0x13)
   8.478 +#define HYPERPRIVOP_GET_PMD		(HYPERPRIVOP_START + 0x14)
   8.479 +#define HYPERPRIVOP_GET_EFLAG		(HYPERPRIVOP_START + 0x15)
   8.480 +#define HYPERPRIVOP_SET_EFLAG		(HYPERPRIVOP_START + 0x16)
   8.481 +#define HYPERPRIVOP_RSM_BE		(HYPERPRIVOP_START + 0x17)
   8.482 +#define HYPERPRIVOP_GET_PSR		(HYPERPRIVOP_START + 0x18)
   8.483 +#define HYPERPRIVOP_MAX			(0x19)
   8.484 +
   8.485 +/* Fast and light hypercalls.  */
   8.486 +#define __HYPERVISOR_ia64_fast_eoi	__HYPERVISOR_arch_1
   8.487 +
   8.488 +/* Xencomm macros.  */
   8.489 +#define XENCOMM_INLINE_MASK 0xf800000000000000UL
   8.490 +#define XENCOMM_INLINE_FLAG 0x8000000000000000UL
   8.491 +
   8.492 +#define XENCOMM_IS_INLINE(addr) \
   8.493 +  (((unsigned long)(addr) & XENCOMM_INLINE_MASK) == XENCOMM_INLINE_FLAG)
   8.494 +#define XENCOMM_INLINE_ADDR(addr) \
   8.495 +  ((unsigned long)(addr) & ~XENCOMM_INLINE_MASK)
   8.496 +
   8.497 +/* xen perfmon */
   8.498 +#ifdef XEN
   8.499 +#ifndef __ASSEMBLY__
   8.500 +#ifndef _ASM_IA64_PERFMON_H
   8.501 +
   8.502 +#include <xen/list.h>   // asm/perfmon.h requires struct list_head
   8.503 +#include <asm/perfmon.h>
   8.504 +// for PFM_xxx and pfarg_features_t, pfarg_context_t, pfarg_reg_t, pfarg_load_t
   8.505 +
   8.506 +#endif /* _ASM_IA64_PERFMON_H */
   8.507 +
   8.508 +DEFINE_XEN_GUEST_HANDLE(pfarg_features_t);
   8.509 +DEFINE_XEN_GUEST_HANDLE(pfarg_context_t);
   8.510 +DEFINE_XEN_GUEST_HANDLE(pfarg_reg_t);
   8.511 +DEFINE_XEN_GUEST_HANDLE(pfarg_load_t);
   8.512 +#endif /* __ASSEMBLY__ */
   8.513 +#endif /* XEN */
   8.514 +
   8.515 +#endif /* __HYPERVISOR_IF_IA64_H__ */
   8.516 +
   8.517 +/*
   8.518 + * Local variables:
   8.519 + * mode: C
   8.520 + * c-set-style: "BSD"
   8.521 + * c-basic-offset: 4
   8.522 + * tab-width: 4
   8.523 + * indent-tabs-mode: nil
   8.524 + * End:
   8.525 + */
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/common/include/public/arch-powerpc.h	Wed Dec 19 09:23:32 2007 +1100
     9.3 @@ -0,0 +1,125 @@
     9.4 +/*
     9.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
     9.6 + * of this software and associated documentation files (the "Software"), to
     9.7 + * deal in the Software without restriction, including without limitation the
     9.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     9.9 + * sell copies of the Software, and to permit persons to whom the Software is
    9.10 + * furnished to do so, subject to the following conditions:
    9.11 + *
    9.12 + * The above copyright notice and this permission notice shall be included in
    9.13 + * all copies or substantial portions of the Software.
    9.14 + *
    9.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    9.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    9.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    9.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    9.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    9.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    9.21 + * DEALINGS IN THE SOFTWARE.
    9.22 + *
    9.23 + * Copyright (C) IBM Corp. 2005, 2006
    9.24 + *
    9.25 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
    9.26 + */
    9.27 +
    9.28 +#ifndef __XEN_PUBLIC_ARCH_PPC_64_H__
    9.29 +#define __XEN_PUBLIC_ARCH_PPC_64_H__
    9.30 +
    9.31 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    9.32 +    typedef struct { \
    9.33 +        int __pad[(sizeof (long long) - sizeof (void *)) / sizeof (int)]; \
    9.34 +        type *p; \
    9.35 +    } __attribute__((__aligned__(8))) __guest_handle_ ## name
    9.36 +
    9.37 +#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
    9.38 +#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
    9.39 +#define set_xen_guest_handle(hnd, val) \
    9.40 +    do { \
    9.41 +        if (sizeof ((hnd).__pad)) \
    9.42 +            (hnd).__pad[0] = 0; \
    9.43 +        (hnd).p = val; \
    9.44 +    } while (0)
    9.45 +
    9.46 +#ifdef __XEN_TOOLS__
    9.47 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    9.48 +#endif
    9.49 +
    9.50 +#ifndef __ASSEMBLY__
    9.51 +/* Guest handles for primitive C types. */
    9.52 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    9.53 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    9.54 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    9.55 +DEFINE_XEN_GUEST_HANDLE(char);
    9.56 +DEFINE_XEN_GUEST_HANDLE(int);
    9.57 +DEFINE_XEN_GUEST_HANDLE(long);
    9.58 +DEFINE_XEN_GUEST_HANDLE(void);
    9.59 +
    9.60 +typedef unsigned long long xen_pfn_t;
    9.61 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    9.62 +#define PRI_xen_pfn "llx"
    9.63 +#endif
    9.64 +
    9.65 +/*
    9.66 + * Pointers and other address fields inside interface structures are padded to
    9.67 + * 64 bits. This means that field alignments aren't different between 32- and
    9.68 + * 64-bit architectures. 
    9.69 + */
    9.70 +/* NB. Multi-level macro ensures __LINE__ is expanded before concatenation. */
    9.71 +#define __MEMORY_PADDING(_X)
    9.72 +#define _MEMORY_PADDING(_X)  __MEMORY_PADDING(_X)
    9.73 +#define MEMORY_PADDING       _MEMORY_PADDING(__LINE__)
    9.74 +
    9.75 +/* And the trap vector is... */
    9.76 +#define TRAP_INSTR "li 0,-1; sc" /* XXX just "sc"? */
    9.77 +
    9.78 +#ifndef __ASSEMBLY__
    9.79 +
    9.80 +#define XENCOMM_INLINE_FLAG (1UL << 63)
    9.81 +
    9.82 +typedef uint64_t xen_ulong_t;
    9.83 +
    9.84 +/* User-accessible registers: nost of these need to be saved/restored
    9.85 + * for every nested Xen invocation. */
    9.86 +struct cpu_user_regs
    9.87 +{
    9.88 +    uint64_t gprs[32];
    9.89 +    uint64_t lr;
    9.90 +    uint64_t ctr;
    9.91 +    uint64_t srr0;
    9.92 +    uint64_t srr1;
    9.93 +    uint64_t pc;
    9.94 +    uint64_t msr;
    9.95 +    uint64_t fpscr;             /* XXX Is this necessary */
    9.96 +    uint64_t xer;
    9.97 +    uint64_t hid4;              /* debug only */
    9.98 +    uint64_t dar;               /* debug only */
    9.99 +    uint32_t dsisr;             /* debug only */
   9.100 +    uint32_t cr;
   9.101 +    uint32_t __pad;             /* good spot for another 32bit reg */
   9.102 +    uint32_t entry_vector;
   9.103 +};
   9.104 +typedef struct cpu_user_regs cpu_user_regs_t;
   9.105 +
   9.106 +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ /* XXX timebase */
   9.107 +
   9.108 +/* ONLY used to communicate with dom0! See also struct exec_domain. */
   9.109 +struct vcpu_guest_context {
   9.110 +    cpu_user_regs_t user_regs;         /* User-level CPU registers     */
   9.111 +    uint64_t sdr1;                     /* Pagetable base               */
   9.112 +    /* XXX etc */
   9.113 +};
   9.114 +typedef struct vcpu_guest_context vcpu_guest_context_t;
   9.115 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   9.116 +
   9.117 +struct arch_shared_info {
   9.118 +    uint64_t boot_timebase;
   9.119 +};
   9.120 +
   9.121 +struct arch_vcpu_info {
   9.122 +};
   9.123 +
   9.124 +/* Support for multi-processor guests. */
   9.125 +#define MAX_VIRT_CPUS 32
   9.126 +#endif
   9.127 +
   9.128 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/common/include/public/arch-x86/xen-x86_32.h	Wed Dec 19 09:23:32 2007 +1100
    10.3 @@ -0,0 +1,184 @@
    10.4 +/******************************************************************************
    10.5 + * xen-x86_32.h
    10.6 + * 
    10.7 + * Guest OS interface to x86 32-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-2007, K A Fraser
   10.28 + */
   10.29 +
   10.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
   10.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
   10.32 +
   10.33 +/*
   10.34 + * Hypercall interface:
   10.35 + *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
   10.36 + *  Output: %eax
   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 %ebx,%ecx)
   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 ; int $0x82
   10.47 + */
   10.48 +#define TRAP_INSTR "int $0x82"
   10.49 +#endif
   10.50 +
   10.51 +/*
   10.52 + * These flat segments are in the Xen-private section of every GDT. Since these
   10.53 + * are also present in the initial GDT, many OSes will be able to avoid
   10.54 + * installing their own GDT.
   10.55 + */
   10.56 +#define FLAT_RING1_CS 0xe019    /* GDT index 259 */
   10.57 +#define FLAT_RING1_DS 0xe021    /* GDT index 260 */
   10.58 +#define FLAT_RING1_SS 0xe021    /* GDT index 260 */
   10.59 +#define FLAT_RING3_CS 0xe02b    /* GDT index 261 */
   10.60 +#define FLAT_RING3_DS 0xe033    /* GDT index 262 */
   10.61 +#define FLAT_RING3_SS 0xe033    /* GDT index 262 */
   10.62 +
   10.63 +#define FLAT_KERNEL_CS FLAT_RING1_CS
   10.64 +#define FLAT_KERNEL_DS FLAT_RING1_DS
   10.65 +#define FLAT_KERNEL_SS FLAT_RING1_SS
   10.66 +#define FLAT_USER_CS    FLAT_RING3_CS
   10.67 +#define FLAT_USER_DS    FLAT_RING3_DS
   10.68 +#define FLAT_USER_SS    FLAT_RING3_SS
   10.69 +
   10.70 +#define __HYPERVISOR_VIRT_START_PAE    0xF5800000
   10.71 +#define __MACH2PHYS_VIRT_START_PAE     0xF5800000
   10.72 +#define __MACH2PHYS_VIRT_END_PAE       0xF6800000
   10.73 +#define HYPERVISOR_VIRT_START_PAE      \
   10.74 +    mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
   10.75 +#define MACH2PHYS_VIRT_START_PAE       \
   10.76 +    mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
   10.77 +#define MACH2PHYS_VIRT_END_PAE         \
   10.78 +    mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
   10.79 +
   10.80 +#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
   10.81 +#define __MACH2PHYS_VIRT_START_NONPAE  0xFC000000
   10.82 +#define __MACH2PHYS_VIRT_END_NONPAE    0xFC400000
   10.83 +#define HYPERVISOR_VIRT_START_NONPAE   \
   10.84 +    mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
   10.85 +#define MACH2PHYS_VIRT_START_NONPAE    \
   10.86 +    mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
   10.87 +#define MACH2PHYS_VIRT_END_NONPAE      \
   10.88 +    mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
   10.89 +
   10.90 +#ifdef CONFIG_X86_PAE
   10.91 +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
   10.92 +#define __MACH2PHYS_VIRT_START  __MACH2PHYS_VIRT_START_PAE
   10.93 +#define __MACH2PHYS_VIRT_END    __MACH2PHYS_VIRT_END_PAE
   10.94 +#else
   10.95 +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_NONPAE
   10.96 +#define __MACH2PHYS_VIRT_START  __MACH2PHYS_VIRT_START_NONPAE
   10.97 +#define __MACH2PHYS_VIRT_END    __MACH2PHYS_VIRT_END_NONPAE
   10.98 +#endif
   10.99 +
  10.100 +#ifndef HYPERVISOR_VIRT_START
  10.101 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
  10.102 +#endif
  10.103 +
  10.104 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
  10.105 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
  10.106 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
  10.107 +#ifndef machine_to_phys_mapping
  10.108 +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
  10.109 +#endif
  10.110 +
  10.111 +/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
  10.112 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
  10.113 +#undef __DEFINE_XEN_GUEST_HANDLE
  10.114 +#define __DEFINE_XEN_GUEST_HANDLE(name, type)                   \
  10.115 +    typedef struct { type *p; }                                 \
  10.116 +        __guest_handle_ ## name;                                \
  10.117 +    typedef struct { union { type *p; uint64_aligned_t q; }; }  \
  10.118 +        __guest_handle_64_ ## name
  10.119 +#undef set_xen_guest_handle
  10.120 +#define set_xen_guest_handle(hnd, val)                      \
  10.121 +    do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0;   \
  10.122 +         (hnd).p = val;                                     \
  10.123 +    } while ( 0 )
  10.124 +#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
  10.125 +#define XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
  10.126 +#endif
  10.127 +
  10.128 +#ifndef __ASSEMBLY__
  10.129 +
  10.130 +struct cpu_user_regs {
  10.131 +    uint32_t ebx;
  10.132 +    uint32_t ecx;
  10.133 +    uint32_t edx;
  10.134 +    uint32_t esi;
  10.135 +    uint32_t edi;
  10.136 +    uint32_t ebp;
  10.137 +    uint32_t eax;
  10.138 +    uint16_t error_code;    /* private */
  10.139 +    uint16_t entry_vector;  /* private */
  10.140 +    uint32_t eip;
  10.141 +    uint16_t cs;
  10.142 +    uint8_t  saved_upcall_mask;
  10.143 +    uint8_t  _pad0;
  10.144 +    uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
  10.145 +    uint32_t esp;
  10.146 +    uint16_t ss, _pad1;
  10.147 +    uint16_t es, _pad2;
  10.148 +    uint16_t ds, _pad3;
  10.149 +    uint16_t fs, _pad4;
  10.150 +    uint16_t gs, _pad5;
  10.151 +};
  10.152 +typedef struct cpu_user_regs cpu_user_regs_t;
  10.153 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
  10.154 +
  10.155 +/*
  10.156 + * Page-directory addresses above 4GB do not fit into architectural %cr3.
  10.157 + * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
  10.158 + * must use the following accessor macros to pack/unpack valid MFNs.
  10.159 + */
  10.160 +#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
  10.161 +#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
  10.162 +
  10.163 +struct arch_vcpu_info {
  10.164 +    unsigned long cr2;
  10.165 +    unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
  10.166 +};
  10.167 +typedef struct arch_vcpu_info arch_vcpu_info_t;
  10.168 +
  10.169 +struct xen_callback {
  10.170 +    unsigned long cs;
  10.171 +    unsigned long eip;
  10.172 +};
  10.173 +typedef struct xen_callback xen_callback_t;
  10.174 +
  10.175 +#endif /* !__ASSEMBLY__ */
  10.176 +
  10.177 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
  10.178 +
  10.179 +/*
  10.180 + * Local variables:
  10.181 + * mode: C
  10.182 + * c-set-style: "BSD"
  10.183 + * c-basic-offset: 4
  10.184 + * tab-width: 4
  10.185 + * indent-tabs-mode: nil
  10.186 + * End:
  10.187 + */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/common/include/public/arch-x86/xen-x86_64.h	Wed Dec 19 09:23:32 2007 +1100
    11.3 @@ -0,0 +1,211 @@
    11.4 +/******************************************************************************
    11.5 + * xen-x86_64.h
    11.6 + * 
    11.7 + * Guest OS interface to x86 64-bit 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_X86_64_H__
   11.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
   11.32 +
   11.33 +/*
   11.34 + * Hypercall interface:
   11.35 + *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
   11.36 + *  Output: %rax
   11.37 + * Access is via hypercall page (set up by guest loader or via a Xen MSR):
   11.38 + *  call hypercall_page + hypercall-number * 32
   11.39 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi)
   11.40 + */
   11.41 +
   11.42 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
   11.43 +/*
   11.44 + * Legacy hypercall interface:
   11.45 + * As above, except the entry sequence to the hypervisor is:
   11.46 + *  mov $hypercall-number*32,%eax ; syscall
   11.47 + * Clobbered: %rcx, %r11, argument registers (as above)
   11.48 + */
   11.49 +#define TRAP_INSTR "syscall"
   11.50 +#endif
   11.51 +
   11.52 +/*
   11.53 + * 64-bit segment selectors
   11.54 + * These flat segments are in the Xen-private section of every GDT. Since these
   11.55 + * are also present in the initial GDT, many OSes will be able to avoid
   11.56 + * installing their own GDT.
   11.57 + */
   11.58 +
   11.59 +#define FLAT_RING3_CS32 0xe023  /* GDT index 260 */
   11.60 +#define FLAT_RING3_CS64 0xe033  /* GDT index 261 */
   11.61 +#define FLAT_RING3_DS32 0xe02b  /* GDT index 262 */
   11.62 +#define FLAT_RING3_DS64 0x0000  /* NULL selector */
   11.63 +#define FLAT_RING3_SS32 0xe02b  /* GDT index 262 */
   11.64 +#define FLAT_RING3_SS64 0xe02b  /* GDT index 262 */
   11.65 +
   11.66 +#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
   11.67 +#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
   11.68 +#define FLAT_KERNEL_DS   FLAT_KERNEL_DS64
   11.69 +#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
   11.70 +#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
   11.71 +#define FLAT_KERNEL_CS   FLAT_KERNEL_CS64
   11.72 +#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
   11.73 +#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
   11.74 +#define FLAT_KERNEL_SS   FLAT_KERNEL_SS64
   11.75 +
   11.76 +#define FLAT_USER_DS64 FLAT_RING3_DS64
   11.77 +#define FLAT_USER_DS32 FLAT_RING3_DS32
   11.78 +#define FLAT_USER_DS   FLAT_USER_DS64
   11.79 +#define FLAT_USER_CS64 FLAT_RING3_CS64
   11.80 +#define FLAT_USER_CS32 FLAT_RING3_CS32
   11.81 +#define FLAT_USER_CS   FLAT_USER_CS64
   11.82 +#define FLAT_USER_SS64 FLAT_RING3_SS64
   11.83 +#define FLAT_USER_SS32 FLAT_RING3_SS32
   11.84 +#define FLAT_USER_SS   FLAT_USER_SS64
   11.85 +
   11.86 +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
   11.87 +#define __HYPERVISOR_VIRT_END   0xFFFF880000000000
   11.88 +#define __MACH2PHYS_VIRT_START  0xFFFF800000000000
   11.89 +#define __MACH2PHYS_VIRT_END    0xFFFF804000000000
   11.90 +
   11.91 +#ifndef HYPERVISOR_VIRT_START
   11.92 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
   11.93 +#define HYPERVISOR_VIRT_END   mk_unsigned_long(__HYPERVISOR_VIRT_END)
   11.94 +#endif
   11.95 +
   11.96 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
   11.97 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
   11.98 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
   11.99 +#ifndef machine_to_phys_mapping
  11.100 +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
  11.101 +#endif
  11.102 +
  11.103 +#ifndef __ASSEMBLY__
  11.104 +
  11.105 +/*
  11.106 + * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
  11.107 + *  @which == SEGBASE_*  ;  @base == 64-bit base address
  11.108 + * Returns 0 on success.
  11.109 + */
  11.110 +#define SEGBASE_FS          0
  11.111 +#define SEGBASE_GS_USER     1
  11.112 +#define SEGBASE_GS_KERNEL   2
  11.113 +#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
  11.114 +
  11.115 +/*
  11.116 + * int HYPERVISOR_iret(void)
  11.117 + * All arguments are on the kernel stack, in the following format.
  11.118 + * Never returns if successful. Current kernel context is lost.
  11.119 + * The saved CS is mapped as follows:
  11.120 + *   RING0 -> RING3 kernel mode.
  11.121 + *   RING1 -> RING3 kernel mode.
  11.122 + *   RING2 -> RING3 kernel mode.
  11.123 + *   RING3 -> RING3 user mode.
  11.124 + * However RING0 indicates that the guest kernel should return to iteself
  11.125 + * directly with
  11.126 + *      orb   $3,1*8(%rsp)
  11.127 + *      iretq
  11.128 + * If flags contains VGCF_in_syscall:
  11.129 + *   Restore RAX, RIP, RFLAGS, RSP.
  11.130 + *   Discard R11, RCX, CS, SS.
  11.131 + * Otherwise:
  11.132 + *   Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.
  11.133 + * All other registers are saved on hypercall entry and restored to user.
  11.134 + */
  11.135 +/* Guest exited in SYSCALL context? Return to guest with SYSRET? */
  11.136 +#define _VGCF_in_syscall 8
  11.137 +#define VGCF_in_syscall  (1<<_VGCF_in_syscall)
  11.138 +#define VGCF_IN_SYSCALL  VGCF_in_syscall
  11.139 +struct iret_context {
  11.140 +    /* Top of stack (%rsp at point of hypercall). */
  11.141 +    uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
  11.142 +    /* Bottom of iret stack frame. */
  11.143 +};
  11.144 +
  11.145 +#ifdef __GNUC__
  11.146 +/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
  11.147 +#define __DECL_REG(name) union { \
  11.148 +    uint64_t r ## name, e ## name; \
  11.149 +    uint32_t _e ## name; \
  11.150 +}
  11.151 +#else
  11.152 +/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
  11.153 +#define __DECL_REG(name) uint64_t r ## name
  11.154 +#endif
  11.155 +
  11.156 +struct cpu_user_regs {
  11.157 +    uint64_t r15;
  11.158 +    uint64_t r14;
  11.159 +    uint64_t r13;
  11.160 +    uint64_t r12;
  11.161 +    __DECL_REG(bp);
  11.162 +    __DECL_REG(bx);
  11.163 +    uint64_t r11;
  11.164 +    uint64_t r10;
  11.165 +    uint64_t r9;
  11.166 +    uint64_t r8;
  11.167 +    __DECL_REG(ax);
  11.168 +    __DECL_REG(cx);
  11.169 +    __DECL_REG(dx);
  11.170 +    __DECL_REG(si);
  11.171 +    __DECL_REG(di);
  11.172 +    uint32_t error_code;    /* private */
  11.173 +    uint32_t entry_vector;  /* private */
  11.174 +    __DECL_REG(ip);
  11.175 +    uint16_t cs, _pad0[1];
  11.176 +    uint8_t  saved_upcall_mask;
  11.177 +    uint8_t  _pad1[3];
  11.178 +    __DECL_REG(flags);      /* rflags.IF == !saved_upcall_mask */
  11.179 +    __DECL_REG(sp);
  11.180 +    uint16_t ss, _pad2[3];
  11.181 +    uint16_t es, _pad3[3];
  11.182 +    uint16_t ds, _pad4[3];
  11.183 +    uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
  11.184 +    uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
  11.185 +};
  11.186 +typedef struct cpu_user_regs cpu_user_regs_t;
  11.187 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
  11.188 +
  11.189 +#undef __DECL_REG
  11.190 +
  11.191 +#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
  11.192 +#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
  11.193 +
  11.194 +struct arch_vcpu_info {
  11.195 +    unsigned long cr2;
  11.196 +    unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
  11.197 +};
  11.198 +typedef struct arch_vcpu_info arch_vcpu_info_t;
  11.199 +
  11.200 +typedef unsigned long xen_callback_t;
  11.201 +
  11.202 +#endif /* !__ASSEMBLY__ */
  11.203 +
  11.204 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */
  11.205 +
  11.206 +/*
  11.207 + * Local variables:
  11.208 + * mode: C
  11.209 + * c-set-style: "BSD"
  11.210 + * c-basic-offset: 4
  11.211 + * tab-width: 4
  11.212 + * indent-tabs-mode: nil
  11.213 + * End:
  11.214 + */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/common/include/public/arch-x86/xen.h	Wed Dec 19 09:23:32 2007 +1100
    12.3 @@ -0,0 +1,205 @@
    12.4 +/******************************************************************************
    12.5 + * arch-x86/xen.h
    12.6 + * 
    12.7 + * Guest OS interface to x86 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 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
   12.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_H__
   12.32 +
   12.33 +/* Structural guest handles introduced in 0x00030201. */
   12.34 +#if __XEN_INTERFACE_VERSION__ >= 0x00030201
   12.35 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   12.36 +    typedef struct { type *p; } __guest_handle_ ## name
   12.37 +#else
   12.38 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   12.39 +    typedef type * __guest_handle_ ## name
   12.40 +#endif
   12.41 +
   12.42 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
   12.43 +#define __XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
   12.44 +#define XEN_GUEST_HANDLE(name)          __XEN_GUEST_HANDLE(name)
   12.45 +#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
   12.46 +#ifdef __XEN_TOOLS__
   12.47 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
   12.48 +#endif
   12.49 +
   12.50 +#if defined(__i386__)
   12.51 +#include "xen-x86_32.h"
   12.52 +#elif defined(__x86_64__)
   12.53 +#include "xen-x86_64.h"
   12.54 +#endif
   12.55 +
   12.56 +#ifndef __ASSEMBLY__
   12.57 +/* Guest handles for primitive C types. */
   12.58 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
   12.59 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
   12.60 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
   12.61 +DEFINE_XEN_GUEST_HANDLE(char);
   12.62 +DEFINE_XEN_GUEST_HANDLE(int);
   12.63 +DEFINE_XEN_GUEST_HANDLE(long);
   12.64 +DEFINE_XEN_GUEST_HANDLE(void);
   12.65 +
   12.66 +typedef unsigned long xen_pfn_t;
   12.67 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
   12.68 +#define PRI_xen_pfn "lx"
   12.69 +#endif
   12.70 +
   12.71 +/*
   12.72 + * SEGMENT DESCRIPTOR TABLES
   12.73 + */
   12.74 +/*
   12.75 + * A number of GDT entries are reserved by Xen. These are not situated at the
   12.76 + * start of the GDT because some stupid OSes export hard-coded selector values
   12.77 + * in their ABI. These hard-coded values are always near the start of the GDT,
   12.78 + * so Xen places itself out of the way, at the far end of the GDT.
   12.79 + */
   12.80 +#define FIRST_RESERVED_GDT_PAGE  14
   12.81 +#define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
   12.82 +#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
   12.83 +
   12.84 +/* Maximum number of virtual CPUs in multi-processor guests. */
   12.85 +#define MAX_VIRT_CPUS 32
   12.86 +
   12.87 +#ifndef __ASSEMBLY__
   12.88 +
   12.89 +typedef unsigned long xen_ulong_t;
   12.90 +
   12.91 +/*
   12.92 + * Send an array of these to HYPERVISOR_set_trap_table().
   12.93 + * The privilege level specifies which modes may enter a trap via a software
   12.94 + * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
   12.95 + * privilege levels as follows:
   12.96 + *  Level == 0: Noone may enter
   12.97 + *  Level == 1: Kernel may enter
   12.98 + *  Level == 2: Kernel may enter
   12.99 + *  Level == 3: Everyone may enter
  12.100 + */
  12.101 +#define TI_GET_DPL(_ti)      ((_ti)->flags & 3)
  12.102 +#define TI_GET_IF(_ti)       ((_ti)->flags & 4)
  12.103 +#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
  12.104 +#define TI_SET_IF(_ti,_if)   ((_ti)->flags |= ((!!(_if))<<2))
  12.105 +struct trap_info {
  12.106 +    uint8_t       vector;  /* exception vector                              */
  12.107 +    uint8_t       flags;   /* 0-3: privilege level; 4: clear event enable?  */
  12.108 +    uint16_t      cs;      /* code selector                                 */
  12.109 +    unsigned long address; /* code offset                                   */
  12.110 +};
  12.111 +typedef struct trap_info trap_info_t;
  12.112 +DEFINE_XEN_GUEST_HANDLE(trap_info_t);
  12.113 +
  12.114 +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
  12.115 +
  12.116 +/*
  12.117 + * The following is all CPU context. Note that the fpu_ctxt block is filled 
  12.118 + * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
  12.119 + */
  12.120 +struct vcpu_guest_context {
  12.121 +    /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
  12.122 +    struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
  12.123 +#define VGCF_I387_VALID                (1<<0)
  12.124 +#define VGCF_IN_KERNEL                 (1<<2)
  12.125 +#define _VGCF_i387_valid               0
  12.126 +#define VGCF_i387_valid                (1<<_VGCF_i387_valid)
  12.127 +#define _VGCF_in_kernel                2
  12.128 +#define VGCF_in_kernel                 (1<<_VGCF_in_kernel)
  12.129 +#define _VGCF_failsafe_disables_events 3
  12.130 +#define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
  12.131 +#define _VGCF_syscall_disables_events  4
  12.132 +#define VGCF_syscall_disables_events   (1<<_VGCF_syscall_disables_events)
  12.133 +#define _VGCF_online                   5
  12.134 +#define VGCF_online                    (1<<_VGCF_online)
  12.135 +    unsigned long flags;                    /* VGCF_* flags                 */
  12.136 +    struct cpu_user_regs user_regs;         /* User-level CPU registers     */
  12.137 +    struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
  12.138 +    unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
  12.139 +    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
  12.140 +    unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
  12.141 +    /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
  12.142 +    unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
  12.143 +    unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
  12.144 +#ifdef __i386__
  12.145 +    unsigned long event_callback_cs;        /* CS:EIP of event callback     */
  12.146 +    unsigned long event_callback_eip;
  12.147 +    unsigned long failsafe_callback_cs;     /* CS:EIP of failsafe callback  */
  12.148 +    unsigned long failsafe_callback_eip;
  12.149 +#else
  12.150 +    unsigned long event_callback_eip;
  12.151 +    unsigned long failsafe_callback_eip;
  12.152 +#ifdef __XEN__
  12.153 +    union {
  12.154 +        unsigned long syscall_callback_eip;
  12.155 +        struct {
  12.156 +            unsigned int event_callback_cs;    /* compat CS of event cb     */
  12.157 +            unsigned int failsafe_callback_cs; /* compat CS of failsafe cb  */
  12.158 +        };
  12.159 +    };
  12.160 +#else
  12.161 +    unsigned long syscall_callback_eip;
  12.162 +#endif
  12.163 +#endif
  12.164 +    unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
  12.165 +#ifdef __x86_64__
  12.166 +    /* Segment base addresses. */
  12.167 +    uint64_t      fs_base;
  12.168 +    uint64_t      gs_base_kernel;
  12.169 +    uint64_t      gs_base_user;
  12.170 +#endif
  12.171 +};
  12.172 +typedef struct vcpu_guest_context vcpu_guest_context_t;
  12.173 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
  12.174 +
  12.175 +struct arch_shared_info {
  12.176 +    unsigned long max_pfn;                  /* max pfn that appears in table */
  12.177 +    /* Frame containing list of mfns containing list of mfns containing p2m. */
  12.178 +    xen_pfn_t     pfn_to_mfn_frame_list_list;
  12.179 +    unsigned long nmi_reason;
  12.180 +    uint64_t pad[32];
  12.181 +};
  12.182 +typedef struct arch_shared_info arch_shared_info_t;
  12.183 +
  12.184 +#endif /* !__ASSEMBLY__ */
  12.185 +
  12.186 +/*
  12.187 + * Prefix forces emulation of some non-trapping instructions.
  12.188 + * Currently only CPUID.
  12.189 + */
  12.190 +#ifdef __ASSEMBLY__
  12.191 +#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
  12.192 +#define XEN_CPUID          XEN_EMULATE_PREFIX cpuid
  12.193 +#else
  12.194 +#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
  12.195 +#define XEN_CPUID          XEN_EMULATE_PREFIX "cpuid"
  12.196 +#endif
  12.197 +
  12.198 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
  12.199 +
  12.200 +/*
  12.201 + * Local variables:
  12.202 + * mode: C
  12.203 + * c-set-style: "BSD"
  12.204 + * c-basic-offset: 4
  12.205 + * tab-width: 4
  12.206 + * indent-tabs-mode: nil
  12.207 + * End:
  12.208 + */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/common/include/public/arch-x86_32.h	Wed Dec 19 09:23:32 2007 +1100
    13.3 @@ -0,0 +1,27 @@
    13.4 +/******************************************************************************
    13.5 + * arch-x86_32.h
    13.6 + * 
    13.7 + * Guest OS interface to x86 32-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/arch-x86_64.h	Wed Dec 19 09:23:32 2007 +1100
    14.3 @@ -0,0 +1,27 @@
    14.4 +/******************************************************************************
    14.5 + * arch-x86_64.h
    14.6 + * 
    14.7 + * Guest OS interface to x86 64-bit 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) 2004-2006, K A Fraser
   14.28 + */
   14.29 +
   14.30 +#include "arch-x86/xen.h"
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/common/include/public/callback.h	Wed Dec 19 09:23:32 2007 +1100
    15.3 @@ -0,0 +1,92 @@
    15.4 +/******************************************************************************
    15.5 + * callback.h
    15.6 + *
    15.7 + * Register guest OS callbacks with Xen.
    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) 2006, Ian Campbell
   15.28 + */
   15.29 +
   15.30 +#ifndef __XEN_PUBLIC_CALLBACK_H__
   15.31 +#define __XEN_PUBLIC_CALLBACK_H__
   15.32 +
   15.33 +#include "xen.h"
   15.34 +
   15.35 +/*
   15.36 + * Prototype for this hypercall is:
   15.37 + *   long callback_op(int cmd, void *extra_args)
   15.38 + * @cmd        == CALLBACKOP_??? (callback operation).
   15.39 + * @extra_args == Operation-specific extra arguments (NULL if none).
   15.40 + */
   15.41 +
   15.42 +#define CALLBACKTYPE_event                 0
   15.43 +#define CALLBACKTYPE_failsafe              1
   15.44 +#define CALLBACKTYPE_syscall               2 /* x86_64 only */
   15.45 +/*
   15.46 + * sysenter is only available on x86_32 with the
   15.47 + * supervisor_mode_kernel option enabled.
   15.48 + */
   15.49 +#define CALLBACKTYPE_sysenter              3
   15.50 +#define CALLBACKTYPE_nmi                   4
   15.51 +
   15.52 +/*
   15.53 + * Disable event deliver during callback? This flag is ignored for event and
   15.54 + * NMI callbacks: event delivery is unconditionally disabled.
   15.55 + */
   15.56 +#define _CALLBACKF_mask_events             0
   15.57 +#define CALLBACKF_mask_events              (1U << _CALLBACKF_mask_events)
   15.58 +
   15.59 +/*
   15.60 + * Register a callback.
   15.61 + */
   15.62 +#define CALLBACKOP_register                0
   15.63 +struct callback_register {
   15.64 +    uint16_t type;
   15.65 +    uint16_t flags;
   15.66 +    xen_callback_t address;
   15.67 +};
   15.68 +typedef struct callback_register callback_register_t;
   15.69 +DEFINE_XEN_GUEST_HANDLE(callback_register_t);
   15.70 +
   15.71 +/*
   15.72 + * Unregister a callback.
   15.73 + *
   15.74 + * Not all callbacks can be unregistered. -EINVAL will be returned if
   15.75 + * you attempt to unregister such a callback.
   15.76 + */
   15.77 +#define CALLBACKOP_unregister              1
   15.78 +struct callback_unregister {
   15.79 +    uint16_t type;
   15.80 +    uint16_t _unused;
   15.81 +};
   15.82 +typedef struct callback_unregister callback_unregister_t;
   15.83 +DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
   15.84 +
   15.85 +#endif /* __XEN_PUBLIC_CALLBACK_H__ */
   15.86 +
   15.87 +/*
   15.88 + * Local variables:
   15.89 + * mode: C
   15.90 + * c-set-style: "BSD"
   15.91 + * c-basic-offset: 4
   15.92 + * tab-width: 4
   15.93 + * indent-tabs-mode: nil
   15.94 + * End:
   15.95 + */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/common/include/public/dom0_ops.h	Wed Dec 19 09:23:32 2007 +1100
    16.3 @@ -0,0 +1,120 @@
    16.4 +/******************************************************************************
    16.5 + * dom0_ops.h
    16.6 + * 
    16.7 + * Process command requests from domain-0 guest OS.
    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_DOM0_OPS_H__
   16.32 +#define __XEN_PUBLIC_DOM0_OPS_H__
   16.33 +
   16.34 +#include "xen.h"
   16.35 +#include "platform.h"
   16.36 +
   16.37 +#if __XEN_INTERFACE_VERSION__ >= 0x00030204
   16.38 +#error "dom0_ops.h is a compatibility interface only"
   16.39 +#endif
   16.40 +
   16.41 +#define DOM0_INTERFACE_VERSION XENPF_INTERFACE_VERSION
   16.42 +
   16.43 +#define DOM0_SETTIME          XENPF_settime
   16.44 +#define dom0_settime          xenpf_settime
   16.45 +#define dom0_settime_t        xenpf_settime_t
   16.46 +
   16.47 +#define DOM0_ADD_MEMTYPE      XENPF_add_memtype
   16.48 +#define dom0_add_memtype      xenpf_add_memtype
   16.49 +#define dom0_add_memtype_t    xenpf_add_memtype_t
   16.50 +
   16.51 +#define DOM0_DEL_MEMTYPE      XENPF_del_memtype
   16.52 +#define dom0_del_memtype      xenpf_del_memtype
   16.53 +#define dom0_del_memtype_t    xenpf_del_memtype_t
   16.54 +
   16.55 +#define DOM0_READ_MEMTYPE     XENPF_read_memtype
   16.56 +#define dom0_read_memtype     xenpf_read_memtype
   16.57 +#define dom0_read_memtype_t   xenpf_read_memtype_t
   16.58 +
   16.59 +#define DOM0_MICROCODE        XENPF_microcode_update
   16.60 +#define dom0_microcode        xenpf_microcode_update
   16.61 +#define dom0_microcode_t      xenpf_microcode_update_t
   16.62 +
   16.63 +#define DOM0_PLATFORM_QUIRK   XENPF_platform_quirk
   16.64 +#define dom0_platform_quirk   xenpf_platform_quirk
   16.65 +#define dom0_platform_quirk_t xenpf_platform_quirk_t
   16.66 +
   16.67 +typedef uint64_t cpumap_t;
   16.68 +
   16.69 +/* Unsupported legacy operation -- defined for API compatibility. */
   16.70 +#define DOM0_MSR                 15
   16.71 +struct dom0_msr {
   16.72 +    /* IN variables. */
   16.73 +    uint32_t write;
   16.74 +    cpumap_t cpu_mask;
   16.75 +    uint32_t msr;
   16.76 +    uint32_t in1;
   16.77 +    uint32_t in2;
   16.78 +    /* OUT variables. */
   16.79 +    uint32_t out1;
   16.80 +    uint32_t out2;
   16.81 +};
   16.82 +typedef struct dom0_msr dom0_msr_t;
   16.83 +DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
   16.84 +
   16.85 +/* Unsupported legacy operation -- defined for API compatibility. */
   16.86 +#define DOM0_PHYSICAL_MEMORY_MAP 40
   16.87 +struct dom0_memory_map_entry {
   16.88 +    uint64_t start, end;
   16.89 +    uint32_t flags; /* reserved */
   16.90 +    uint8_t  is_ram;
   16.91 +};
   16.92 +typedef struct dom0_memory_map_entry dom0_memory_map_entry_t;
   16.93 +DEFINE_XEN_GUEST_HANDLE(dom0_memory_map_entry_t);
   16.94 +
   16.95 +struct dom0_op {
   16.96 +    uint32_t cmd;
   16.97 +    uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
   16.98 +    union {
   16.99 +        struct dom0_msr               msr;
  16.100 +        struct dom0_settime           settime;
  16.101 +        struct dom0_add_memtype       add_memtype;
  16.102 +        struct dom0_del_memtype       del_memtype;
  16.103 +        struct dom0_read_memtype      read_memtype;
  16.104 +        struct dom0_microcode         microcode;
  16.105 +        struct dom0_platform_quirk    platform_quirk;
  16.106 +        struct dom0_memory_map_entry  physical_memory_map;
  16.107 +        uint8_t                       pad[128];
  16.108 +    } u;
  16.109 +};
  16.110 +typedef struct dom0_op dom0_op_t;
  16.111 +DEFINE_XEN_GUEST_HANDLE(dom0_op_t);
  16.112 +
  16.113 +#endif /* __XEN_PUBLIC_DOM0_OPS_H__ */
  16.114 +
  16.115 +/*
  16.116 + * Local variables:
  16.117 + * mode: C
  16.118 + * c-set-style: "BSD"
  16.119 + * c-basic-offset: 4
  16.120 + * tab-width: 4
  16.121 + * indent-tabs-mode: nil
  16.122 + * End:
  16.123 + */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/common/include/public/domctl.h	Wed Dec 19 09:23:32 2007 +1100
    17.3 @@ -0,0 +1,481 @@
    17.4 +/******************************************************************************
    17.5 + * domctl.h
    17.6 + * 
    17.7 + * Domain management operations. For use by node control stack.
    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) 2002-2003, B Dragovic
   17.28 + * Copyright (c) 2002-2006, K Fraser
   17.29 + */
   17.30 +
   17.31 +#ifndef __XEN_PUBLIC_DOMCTL_H__
   17.32 +#define __XEN_PUBLIC_DOMCTL_H__
   17.33 +
   17.34 +#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
   17.35 +#error "domctl operations are intended for use by node control tools only"
   17.36 +#endif
   17.37 +
   17.38 +#include "xen.h"
   17.39 +
   17.40 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000005
   17.41 +
   17.42 +struct xenctl_cpumap {
   17.43 +    XEN_GUEST_HANDLE_64(uint8_t) bitmap;
   17.44 +    uint32_t nr_cpus;
   17.45 +};
   17.46 +
   17.47 +/*
   17.48 + * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
   17.49 + * If it is specified as zero, an id is auto-allocated and returned.
   17.50 + */
   17.51 +#define XEN_DOMCTL_createdomain       1
   17.52 +struct xen_domctl_createdomain {
   17.53 +    /* IN parameters */
   17.54 +    uint32_t ssidref;
   17.55 +    xen_domain_handle_t handle;
   17.56 + /* Is this an HVM guest (as opposed to a PV guest)? */
   17.57 +#define _XEN_DOMCTL_CDF_hvm_guest 0
   17.58 +#define XEN_DOMCTL_CDF_hvm_guest  (1U<<_XEN_DOMCTL_CDF_hvm_guest)
   17.59 +    uint32_t flags;
   17.60 +};
   17.61 +typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
   17.62 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
   17.63 +
   17.64 +#define XEN_DOMCTL_destroydomain      2
   17.65 +#define XEN_DOMCTL_pausedomain        3
   17.66 +#define XEN_DOMCTL_unpausedomain      4
   17.67 +#define XEN_DOMCTL_resumedomain      27
   17.68 +
   17.69 +#define XEN_DOMCTL_getdomaininfo      5
   17.70 +struct xen_domctl_getdomaininfo {
   17.71 +    /* OUT variables. */
   17.72 +    domid_t  domain;              /* Also echoed in domctl.domain */
   17.73 + /* Domain is scheduled to die. */
   17.74 +#define _XEN_DOMINF_dying     0
   17.75 +#define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
   17.76 + /* Domain is an HVM guest (as opposed to a PV guest). */
   17.77 +#define _XEN_DOMINF_hvm_guest 1
   17.78 +#define XEN_DOMINF_hvm_guest  (1U<<_XEN_DOMINF_hvm_guest)
   17.79 + /* The guest OS has shut down. */
   17.80 +#define _XEN_DOMINF_shutdown  2
   17.81 +#define XEN_DOMINF_shutdown   (1U<<_XEN_DOMINF_shutdown)
   17.82 + /* Currently paused by control software. */
   17.83 +#define _XEN_DOMINF_paused    3
   17.84 +#define XEN_DOMINF_paused     (1U<<_XEN_DOMINF_paused)
   17.85 + /* Currently blocked pending an event.     */
   17.86 +#define _XEN_DOMINF_blocked   4
   17.87 +#define XEN_DOMINF_blocked    (1U<<_XEN_DOMINF_blocked)
   17.88 + /* Domain is currently running.            */
   17.89 +#define _XEN_DOMINF_running   5
   17.90 +#define XEN_DOMINF_running    (1U<<_XEN_DOMINF_running)
   17.91 + /* Being debugged.  */
   17.92 +#define _XEN_DOMINF_debugged  6
   17.93 +#define XEN_DOMINF_debugged   (1U<<_XEN_DOMINF_debugged)
   17.94 + /* CPU to which this domain is bound.      */
   17.95 +#define XEN_DOMINF_cpumask      255
   17.96 +#define XEN_DOMINF_cpushift       8
   17.97 + /* XEN_DOMINF_shutdown guest-supplied code.  */
   17.98 +#define XEN_DOMINF_shutdownmask 255
   17.99 +#define XEN_DOMINF_shutdownshift 16
  17.100 +    uint32_t flags;              /* XEN_DOMINF_* */
  17.101 +    uint64_aligned_t tot_pages;
  17.102 +    uint64_aligned_t max_pages;
  17.103 +    uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
  17.104 +    uint64_aligned_t cpu_time;
  17.105 +    uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
  17.106 +    uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
  17.107 +    uint32_t ssidref;
  17.108 +    xen_domain_handle_t handle;
  17.109 +};
  17.110 +typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
  17.111 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
  17.112 +
  17.113 +
  17.114 +#define XEN_DOMCTL_getmemlist         6
  17.115 +struct xen_domctl_getmemlist {
  17.116 +    /* IN variables. */
  17.117 +    /* Max entries to write to output buffer. */
  17.118 +    uint64_aligned_t max_pfns;
  17.119 +    /* Start index in guest's page list. */
  17.120 +    uint64_aligned_t start_pfn;
  17.121 +    XEN_GUEST_HANDLE_64(uint64_t) buffer;
  17.122 +    /* OUT variables. */
  17.123 +    uint64_aligned_t num_pfns;
  17.124 +};
  17.125 +typedef struct xen_domctl_getmemlist xen_domctl_getmemlist_t;
  17.126 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getmemlist_t);
  17.127 +
  17.128 +
  17.129 +#define XEN_DOMCTL_getpageframeinfo   7
  17.130 +
  17.131 +#define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
  17.132 +#define XEN_DOMCTL_PFINFO_NOTAB   (0x0U<<28)
  17.133 +#define XEN_DOMCTL_PFINFO_L1TAB   (0x1U<<28)
  17.134 +#define XEN_DOMCTL_PFINFO_L2TAB   (0x2U<<28)
  17.135 +#define XEN_DOMCTL_PFINFO_L3TAB   (0x3U<<28)
  17.136 +#define XEN_DOMCTL_PFINFO_L4TAB   (0x4U<<28)
  17.137 +#define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
  17.138 +#define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
  17.139 +#define XEN_DOMCTL_PFINFO_XTAB    (0xfU<<28) /* invalid page */
  17.140 +#define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
  17.141 +
  17.142 +struct xen_domctl_getpageframeinfo {
  17.143 +    /* IN variables. */
  17.144 +    uint64_aligned_t gmfn; /* GMFN to query */
  17.145 +    /* OUT variables. */
  17.146 +    /* Is the page PINNED to a type? */
  17.147 +    uint32_t type;         /* see above type defs */
  17.148 +};
  17.149 +typedef struct xen_domctl_getpageframeinfo xen_domctl_getpageframeinfo_t;
  17.150 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo_t);
  17.151 +
  17.152 +
  17.153 +#define XEN_DOMCTL_getpageframeinfo2  8
  17.154 +struct xen_domctl_getpageframeinfo2 {
  17.155 +    /* IN variables. */
  17.156 +    uint64_aligned_t num;
  17.157 +    /* IN/OUT variables. */
  17.158 +    XEN_GUEST_HANDLE_64(uint32_t) array;
  17.159 +};
  17.160 +typedef struct xen_domctl_getpageframeinfo2 xen_domctl_getpageframeinfo2_t;
  17.161 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo2_t);
  17.162 +
  17.163 +
  17.164 +/*
  17.165 + * Control shadow pagetables operation
  17.166 + */
  17.167 +#define XEN_DOMCTL_shadow_op         10
  17.168 +
  17.169 +/* Disable shadow mode. */
  17.170 +#define XEN_DOMCTL_SHADOW_OP_OFF         0
  17.171 +
  17.172 +/* Enable shadow mode (mode contains ORed XEN_DOMCTL_SHADOW_ENABLE_* flags). */
  17.173 +#define XEN_DOMCTL_SHADOW_OP_ENABLE      32
  17.174 +
  17.175 +/* Log-dirty bitmap operations. */
  17.176 + /* Return the bitmap and clean internal copy for next round. */
  17.177 +#define XEN_DOMCTL_SHADOW_OP_CLEAN       11
  17.178 + /* Return the bitmap but do not modify internal copy. */
  17.179 +#define XEN_DOMCTL_SHADOW_OP_PEEK        12
  17.180 +
  17.181 +/* Memory allocation accessors. */
  17.182 +#define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
  17.183 +#define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
  17.184 +
  17.185 +/* Legacy enable operations. */
  17.186 + /* Equiv. to ENABLE with no mode flags. */
  17.187 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
  17.188 + /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
  17.189 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
  17.190 + /* Equiv. to ENABLE with mode flags ENABLE_REFCOUNT and ENABLE_TRANSLATE. */
  17.191 +#define XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
  17.192 +
  17.193 +/* Mode flags for XEN_DOMCTL_SHADOW_OP_ENABLE. */
  17.194 + /*
  17.195 +  * Shadow pagetables are refcounted: guest does not use explicit mmu
  17.196 +  * operations nor write-protect its pagetables.
  17.197 +  */
  17.198 +#define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
  17.199 + /*
  17.200 +  * Log pages in a bitmap as they are dirtied.
  17.201 +  * Used for live relocation to determine which pages must be re-sent.
  17.202 +  */
  17.203 +#define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
  17.204 + /*
  17.205 +  * Automatically translate GPFNs into MFNs.
  17.206 +  */
  17.207 +#define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
  17.208 + /*
  17.209 +  * Xen does not steal virtual address space from the guest.
  17.210 +  * Requires HVM support.
  17.211 +  */
  17.212 +#define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
  17.213 +
  17.214 +struct xen_domctl_shadow_op_stats {
  17.215 +    uint32_t fault_count;
  17.216 +    uint32_t dirty_count;
  17.217 +};
  17.218 +typedef struct xen_domctl_shadow_op_stats xen_domctl_shadow_op_stats_t;
  17.219 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_stats_t);
  17.220 +
  17.221 +struct xen_domctl_shadow_op {
  17.222 +    /* IN variables. */
  17.223 +    uint32_t       op;       /* XEN_DOMCTL_SHADOW_OP_* */
  17.224 +
  17.225 +    /* OP_ENABLE */
  17.226 +    uint32_t       mode;     /* XEN_DOMCTL_SHADOW_ENABLE_* */
  17.227 +
  17.228 +    /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
  17.229 +    uint32_t       mb;       /* Shadow memory allocation in MB */
  17.230 +
  17.231 +    /* OP_PEEK / OP_CLEAN */
  17.232 +    XEN_GUEST_HANDLE_64(uint8_t) dirty_bitmap;
  17.233 +    uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */
  17.234 +    struct xen_domctl_shadow_op_stats stats;
  17.235 +};
  17.236 +typedef struct xen_domctl_shadow_op xen_domctl_shadow_op_t;
  17.237 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_t);
  17.238 +
  17.239 +
  17.240 +#define XEN_DOMCTL_max_mem           11
  17.241 +struct xen_domctl_max_mem {
  17.242 +    /* IN variables. */
  17.243 +    uint64_aligned_t max_memkb;
  17.244 +};
  17.245 +typedef struct xen_domctl_max_mem xen_domctl_max_mem_t;
  17.246 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_mem_t);
  17.247 +
  17.248 +
  17.249 +#define XEN_DOMCTL_setvcpucontext    12
  17.250 +#define XEN_DOMCTL_getvcpucontext    13
  17.251 +struct xen_domctl_vcpucontext {
  17.252 +    uint32_t              vcpu;                  /* IN */
  17.253 +    XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */
  17.254 +};
  17.255 +typedef struct xen_domctl_vcpucontext xen_domctl_vcpucontext_t;
  17.256 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpucontext_t);
  17.257 +
  17.258 +
  17.259 +#define XEN_DOMCTL_getvcpuinfo       14
  17.260 +struct xen_domctl_getvcpuinfo {
  17.261 +    /* IN variables. */
  17.262 +    uint32_t vcpu;
  17.263 +    /* OUT variables. */
  17.264 +    uint8_t  online;                  /* currently online (not hotplugged)? */
  17.265 +    uint8_t  blocked;                 /* blocked waiting for an event? */
  17.266 +    uint8_t  running;                 /* currently scheduled on its CPU? */
  17.267 +    uint64_aligned_t cpu_time;        /* total cpu time consumed (ns) */
  17.268 +    uint32_t cpu;                     /* current mapping   */
  17.269 +};
  17.270 +typedef struct xen_domctl_getvcpuinfo xen_domctl_getvcpuinfo_t;
  17.271 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_getvcpuinfo_t);
  17.272 +
  17.273 +
  17.274 +/* Get/set which physical cpus a vcpu can execute on. */
  17.275 +#define XEN_DOMCTL_setvcpuaffinity    9
  17.276 +#define XEN_DOMCTL_getvcpuaffinity   25
  17.277 +struct xen_domctl_vcpuaffinity {
  17.278 +    uint32_t  vcpu;              /* IN */
  17.279 +    struct xenctl_cpumap cpumap; /* IN/OUT */
  17.280 +};
  17.281 +typedef struct xen_domctl_vcpuaffinity xen_domctl_vcpuaffinity_t;
  17.282 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpuaffinity_t);
  17.283 +
  17.284 +
  17.285 +#define XEN_DOMCTL_max_vcpus         15
  17.286 +struct xen_domctl_max_vcpus {
  17.287 +    uint32_t max;           /* maximum number of vcpus */
  17.288 +};
  17.289 +typedef struct xen_domctl_max_vcpus xen_domctl_max_vcpus_t;
  17.290 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);
  17.291 +
  17.292 +
  17.293 +#define XEN_DOMCTL_scheduler_op      16
  17.294 +/* Scheduler types. */
  17.295 +#define XEN_SCHEDULER_SEDF     4
  17.296 +#define XEN_SCHEDULER_CREDIT   5
  17.297 +/* Set or get info? */
  17.298 +#define XEN_DOMCTL_SCHEDOP_putinfo 0
  17.299 +#define XEN_DOMCTL_SCHEDOP_getinfo 1
  17.300 +struct xen_domctl_scheduler_op {
  17.301 +    uint32_t sched_id;  /* XEN_SCHEDULER_* */
  17.302 +    uint32_t cmd;       /* XEN_DOMCTL_SCHEDOP_* */
  17.303 +    union {
  17.304 +        struct xen_domctl_sched_sedf {
  17.305 +            uint64_aligned_t period;
  17.306 +            uint64_aligned_t slice;
  17.307 +            uint64_aligned_t latency;
  17.308 +            uint32_t extratime;
  17.309 +            uint32_t weight;
  17.310 +        } sedf;
  17.311 +        struct xen_domctl_sched_credit {
  17.312 +            uint16_t weight;
  17.313 +            uint16_t cap;
  17.314 +        } credit;
  17.315 +    } u;
  17.316 +};
  17.317 +typedef struct xen_domctl_scheduler_op xen_domctl_scheduler_op_t;
  17.318 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_scheduler_op_t);
  17.319 +
  17.320 +
  17.321 +#define XEN_DOMCTL_setdomainhandle   17
  17.322 +struct xen_domctl_setdomainhandle {
  17.323 +    xen_domain_handle_t handle;
  17.324 +};
  17.325 +typedef struct xen_domctl_setdomainhandle xen_domctl_setdomainhandle_t;
  17.326 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdomainhandle_t);
  17.327 +
  17.328 +
  17.329 +#define XEN_DOMCTL_setdebugging      18
  17.330 +struct xen_domctl_setdebugging {
  17.331 +    uint8_t enable;
  17.332 +};
  17.333 +typedef struct xen_domctl_setdebugging xen_domctl_setdebugging_t;
  17.334 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdebugging_t);
  17.335 +
  17.336 +
  17.337 +#define XEN_DOMCTL_irq_permission    19
  17.338 +struct xen_domctl_irq_permission {
  17.339 +    uint8_t pirq;
  17.340 +    uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
  17.341 +};
  17.342 +typedef struct xen_domctl_irq_permission xen_domctl_irq_permission_t;
  17.343 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_irq_permission_t);
  17.344 +
  17.345 +
  17.346 +#define XEN_DOMCTL_iomem_permission  20
  17.347 +struct xen_domctl_iomem_permission {
  17.348 +    uint64_aligned_t first_mfn;/* first page (physical page number) in range */
  17.349 +    uint64_aligned_t nr_mfns;  /* number of pages in range (>0) */
  17.350 +    uint8_t  allow_access;     /* allow (!0) or deny (0) access to range? */
  17.351 +};
  17.352 +typedef struct xen_domctl_iomem_permission xen_domctl_iomem_permission_t;
  17.353 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_iomem_permission_t);
  17.354 +
  17.355 +
  17.356 +#define XEN_DOMCTL_ioport_permission 21
  17.357 +struct xen_domctl_ioport_permission {
  17.358 +    uint32_t first_port;              /* first port int range */
  17.359 +    uint32_t nr_ports;                /* size of port range */
  17.360 +    uint8_t  allow_access;            /* allow or deny access to range? */
  17.361 +};
  17.362 +typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
  17.363 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
  17.364 +
  17.365 +
  17.366 +#define XEN_DOMCTL_hypercall_init    22
  17.367 +struct xen_domctl_hypercall_init {
  17.368 +    uint64_aligned_t  gmfn;           /* GMFN to be initialised */
  17.369 +};
  17.370 +typedef struct xen_domctl_hypercall_init xen_domctl_hypercall_init_t;
  17.371 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_hypercall_init_t);
  17.372 +
  17.373 +
  17.374 +#define XEN_DOMCTL_arch_setup        23
  17.375 +#define _XEN_DOMAINSETUP_hvm_guest 0
  17.376 +#define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
  17.377 +#define _XEN_DOMAINSETUP_query 1 /* Get parameters (for save)  */
  17.378 +#define XEN_DOMAINSETUP_query  (1UL<<_XEN_DOMAINSETUP_query)
  17.379 +typedef struct xen_domctl_arch_setup {
  17.380 +    uint64_aligned_t flags;  /* XEN_DOMAINSETUP_* */
  17.381 +#ifdef __ia64__
  17.382 +    uint64_aligned_t bp;     /* mpaddr of boot param area */
  17.383 +    uint64_aligned_t maxmem; /* Highest memory address for MDT.  */
  17.384 +    uint64_aligned_t xsi_va; /* Xen shared_info area virtual address.  */
  17.385 +    uint32_t hypercall_imm;  /* Break imm for Xen hypercalls.  */
  17.386 +#endif
  17.387 +} xen_domctl_arch_setup_t;
  17.388 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
  17.389 +
  17.390 +
  17.391 +#define XEN_DOMCTL_settimeoffset     24
  17.392 +struct xen_domctl_settimeoffset {
  17.393 +    int32_t  time_offset_seconds; /* applied to domain wallclock time */
  17.394 +};
  17.395 +typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
  17.396 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
  17.397 +
  17.398 + 
  17.399 +#define XEN_DOMCTL_gethvmcontext     33
  17.400 +#define XEN_DOMCTL_sethvmcontext     34
  17.401 +typedef struct xen_domctl_hvmcontext {
  17.402 +    uint32_t size; /* IN/OUT: size of buffer / bytes filled */
  17.403 +    XEN_GUEST_HANDLE_64(uint8_t) buffer; /* IN/OUT: data, or call
  17.404 +                                          * gethvmcontext with NULL
  17.405 +                                          * buffer to get size
  17.406 +                                          * req'd */
  17.407 +} xen_domctl_hvmcontext_t;
  17.408 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
  17.409 +
  17.410 +
  17.411 +#define XEN_DOMCTL_set_address_size  35
  17.412 +#define XEN_DOMCTL_get_address_size  36
  17.413 +typedef struct xen_domctl_address_size {
  17.414 +    uint32_t size;
  17.415 +} xen_domctl_address_size_t;
  17.416 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
  17.417 +
  17.418 +
  17.419 +#define XEN_DOMCTL_real_mode_area    26
  17.420 +struct xen_domctl_real_mode_area {
  17.421 +    uint32_t log; /* log2 of Real Mode Area size */
  17.422 +};
  17.423 +typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
  17.424 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
  17.425 +
  17.426 +
  17.427 +#define XEN_DOMCTL_sendtrigger       28
  17.428 +#define XEN_DOMCTL_SENDTRIGGER_NMI    0
  17.429 +#define XEN_DOMCTL_SENDTRIGGER_RESET  1
  17.430 +#define XEN_DOMCTL_SENDTRIGGER_INIT   2
  17.431 +struct xen_domctl_sendtrigger {
  17.432 +    uint32_t  trigger;  /* IN */
  17.433 +    uint32_t  vcpu;     /* IN */
  17.434 +};
  17.435 +typedef struct xen_domctl_sendtrigger xen_domctl_sendtrigger_t;
  17.436 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
  17.437 +
  17.438 + 
  17.439 +struct xen_domctl {
  17.440 +    uint32_t cmd;
  17.441 +    uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
  17.442 +    domid_t  domain;
  17.443 +    union {
  17.444 +        struct xen_domctl_createdomain      createdomain;
  17.445 +        struct xen_domctl_getdomaininfo     getdomaininfo;
  17.446 +        struct xen_domctl_getmemlist        getmemlist;
  17.447 +        struct xen_domctl_getpageframeinfo  getpageframeinfo;
  17.448 +        struct xen_domctl_getpageframeinfo2 getpageframeinfo2;
  17.449 +        struct xen_domctl_vcpuaffinity      vcpuaffinity;
  17.450 +        struct xen_domctl_shadow_op         shadow_op;
  17.451 +        struct xen_domctl_max_mem           max_mem;
  17.452 +        struct xen_domctl_vcpucontext       vcpucontext;
  17.453 +        struct xen_domctl_getvcpuinfo       getvcpuinfo;
  17.454 +        struct xen_domctl_max_vcpus         max_vcpus;
  17.455 +        struct xen_domctl_scheduler_op      scheduler_op;
  17.456 +        struct xen_domctl_setdomainhandle   setdomainhandle;
  17.457 +        struct xen_domctl_setdebugging      setdebugging;
  17.458 +        struct xen_domctl_irq_permission    irq_permission;
  17.459 +        struct xen_domctl_iomem_permission  iomem_permission;
  17.460 +        struct xen_domctl_ioport_permission ioport_permission;
  17.461 +        struct xen_domctl_hypercall_init    hypercall_init;
  17.462 +        struct xen_domctl_arch_setup        arch_setup;
  17.463 +        struct xen_domctl_settimeoffset     settimeoffset;
  17.464 +        struct xen_domctl_real_mode_area    real_mode_area;
  17.465 +        struct xen_domctl_hvmcontext        hvmcontext;
  17.466 +        struct xen_domctl_address_size      address_size;
  17.467 +        struct xen_domctl_sendtrigger       sendtrigger;
  17.468 +        uint8_t                             pad[128];
  17.469 +    } u;
  17.470 +};
  17.471 +typedef struct xen_domctl xen_domctl_t;
  17.472 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_t);
  17.473 +
  17.474 +#endif /* __XEN_PUBLIC_DOMCTL_H__ */
  17.475 +
  17.476 +/*
  17.477 + * Local variables:
  17.478 + * mode: C
  17.479 + * c-set-style: "BSD"
  17.480 + * c-basic-offset: 4
  17.481 + * tab-width: 4
  17.482 + * indent-tabs-mode: nil
  17.483 + * End:
  17.484 + */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/common/include/public/elfnote.h	Wed Dec 19 09:23:32 2007 +1100
    18.3 @@ -0,0 +1,233 @@
    18.4 +/******************************************************************************
    18.5 + * elfnote.h
    18.6 + *
    18.7 + * Definitions used for the Xen ELF notes.
    18.8 + *
    18.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   18.10 + * of this software and associated documentation files (the "Software"), to
   18.11 + * deal in the Software without restriction, including without limitation the
   18.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   18.13 + * sell copies of the Software, and to permit persons to whom the Software is
   18.14 + * furnished to do so, subject to the following conditions:
   18.15 + *
   18.16 + * The above copyright notice and this permission notice shall be included in
   18.17 + * all copies or substantial portions of the Software.
   18.18 + *
   18.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   18.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   18.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   18.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   18.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   18.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   18.25 + * DEALINGS IN THE SOFTWARE.
   18.26 + *
   18.27 + * Copyright (c) 2006, Ian Campbell, XenSource Ltd.
   18.28 + */
   18.29 +
   18.30 +#ifndef __XEN_PUBLIC_ELFNOTE_H__
   18.31 +#define __XEN_PUBLIC_ELFNOTE_H__
   18.32 +
   18.33 +/*
   18.34 + * The notes should live in a PT_NOTE segment and have "Xen" in the
   18.35 + * name field.
   18.36 + *
   18.37 + * Numeric types are either 4 or 8 bytes depending on the content of
   18.38 + * the desc field.
   18.39 + *
   18.40 + * LEGACY indicated the fields in the legacy __xen_guest string which
   18.41 + * this a note type replaces.
   18.42 + */
   18.43 +
   18.44 +/*
   18.45 + * NAME=VALUE pair (string).
   18.46 + */
   18.47 +#define XEN_ELFNOTE_INFO           0
   18.48 +
   18.49 +/*
   18.50 + * The virtual address of the entry point (numeric).
   18.51 + *
   18.52 + * LEGACY: VIRT_ENTRY
   18.53 + */
   18.54 +#define XEN_ELFNOTE_ENTRY          1
   18.55 +
   18.56 +/* The virtual address of the hypercall transfer page (numeric).
   18.57 + *
   18.58 + * LEGACY: HYPERCALL_PAGE. (n.b. legacy value is a physical page
   18.59 + * number not a virtual address)
   18.60 + */
   18.61 +#define XEN_ELFNOTE_HYPERCALL_PAGE 2
   18.62 +
   18.63 +/* The virtual address where the kernel image should be mapped (numeric).
   18.64 + *
   18.65 + * Defaults to 0.
   18.66 + *
   18.67 + * LEGACY: VIRT_BASE
   18.68 + */
   18.69 +#define XEN_ELFNOTE_VIRT_BASE      3
   18.70 +
   18.71 +/*
   18.72 + * The offset of the ELF paddr field from the acutal required
   18.73 + * psuedo-physical address (numeric).
   18.74 + *
   18.75 + * This is used to maintain backwards compatibility with older kernels
   18.76 + * which wrote __PAGE_OFFSET into that field. This field defaults to 0
   18.77 + * if not present.
   18.78 + *
   18.79 + * LEGACY: ELF_PADDR_OFFSET. (n.b. legacy default is VIRT_BASE)
   18.80 + */
   18.81 +#define XEN_ELFNOTE_PADDR_OFFSET   4
   18.82 +
   18.83 +/*
   18.84 + * The version of Xen that we work with (string).
   18.85 + *
   18.86 + * LEGACY: XEN_VER
   18.87 + */
   18.88 +#define XEN_ELFNOTE_XEN_VERSION    5
   18.89 +
   18.90 +/*
   18.91 + * The name of the guest operating system (string).
   18.92 + *
   18.93 + * LEGACY: GUEST_OS
   18.94 + */
   18.95 +#define XEN_ELFNOTE_GUEST_OS       6
   18.96 +
   18.97 +/*
   18.98 + * The version of the guest operating system (string).
   18.99 + *
  18.100 + * LEGACY: GUEST_VER
  18.101 + */
  18.102 +#define XEN_ELFNOTE_GUEST_VERSION  7
  18.103 +
  18.104 +/*
  18.105 + * The loader type (string).
  18.106 + *
  18.107 + * LEGACY: LOADER
  18.108 + */
  18.109 +#define XEN_ELFNOTE_LOADER         8
  18.110 +
  18.111 +/*
  18.112 + * The kernel supports PAE (x86/32 only, string = "yes", "no" or
  18.113 + * "bimodal").
  18.114 + *
  18.115 + * For compatibility with Xen 3.0.3 and earlier the "bimodal" setting
  18.116 + * may be given as "yes,bimodal" which will cause older Xen to treat
  18.117 + * this kernel as PAE.
  18.118 + *
  18.119 + * LEGACY: PAE (n.b. The legacy interface included a provision to
  18.120 + * indicate 'extended-cr3' support allowing L3 page tables to be
  18.121 + * placed above 4G. It is assumed that any kernel new enough to use
  18.122 + * these ELF notes will include this and therefore "yes" here is
  18.123 + * equivalent to "yes[entended-cr3]" in the __xen_guest interface.
  18.124 + */
  18.125 +#define XEN_ELFNOTE_PAE_MODE       9
  18.126 +
  18.127 +/*
  18.128 + * The features supported/required by this kernel (string).
  18.129 + *
  18.130 + * The string must consist of a list of feature names (as given in
  18.131 + * features.h, without the "XENFEAT_" prefix) separated by '|'
  18.132 + * characters. If a feature is required for the kernel to function
  18.133 + * then the feature name must be preceded by a '!' character.
  18.134 + *
  18.135 + * LEGACY: FEATURES
  18.136 + */
  18.137 +#define XEN_ELFNOTE_FEATURES      10
  18.138 +
  18.139 +/*
  18.140 + * The kernel requires the symbol table to be loaded (string = "yes" or "no")
  18.141 + * LEGACY: BSD_SYMTAB (n.b. The legacy treated the presence or absence
  18.142 + * of this string as a boolean flag rather than requiring "yes" or
  18.143 + * "no".
  18.144 + */
  18.145 +#define XEN_ELFNOTE_BSD_SYMTAB    11
  18.146 +
  18.147 +/*
  18.148 + * The lowest address the hypervisor hole can begin at (numeric).
  18.149 + *
  18.150 + * This must not be set higher than HYPERVISOR_VIRT_START. Its presence
  18.151 + * also indicates to the hypervisor that the kernel can deal with the
  18.152 + * hole starting at a higher address.
  18.153 + */
  18.154 +#define XEN_ELFNOTE_HV_START_LOW  12
  18.155 +
  18.156 +/*
  18.157 + * List of maddr_t-sized mask/value pairs describing how to recognize
  18.158 + * (non-present) L1 page table entries carrying valid MFNs (numeric).
  18.159 + */
  18.160 +#define XEN_ELFNOTE_L1_MFN_VALID  13
  18.161 +
  18.162 +/*
  18.163 + * Whether or not the guest supports cooperative suspend cancellation.
  18.164 + */
  18.165 +#define XEN_ELFNOTE_SUSPEND_CANCEL 14
  18.166 +
  18.167 +/*
  18.168 + * The number of the highest elfnote defined.
  18.169 + */
  18.170 +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUSPEND_CANCEL
  18.171 +
  18.172 +/*
  18.173 + * System information exported through crash notes.
  18.174 + *
  18.175 + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO 
  18.176 + * note in case of a system crash. This note will contain various
  18.177 + * information about the system, see xen/include/xen/elfcore.h.
  18.178 + */
  18.179 +#define XEN_ELFNOTE_CRASH_INFO 0x1000001
  18.180 +
  18.181 +/*
  18.182 + * System registers exported through crash notes.
  18.183 + *
  18.184 + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_REGS 
  18.185 + * note per cpu in case of a system crash. This note is architecture
  18.186 + * specific and will contain registers not saved in the "CORE" note.
  18.187 + * See xen/include/xen/elfcore.h for more information.
  18.188 + */
  18.189 +#define XEN_ELFNOTE_CRASH_REGS 0x1000002
  18.190 +
  18.191 +
  18.192 +/*
  18.193 + * xen dump-core none note.
  18.194 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE
  18.195 + * in its dump file to indicate that the file is xen dump-core
  18.196 + * file. This note doesn't have any other information.
  18.197 + * See tools/libxc/xc_core.h for more information.
  18.198 + */
  18.199 +#define XEN_ELFNOTE_DUMPCORE_NONE               0x2000000
  18.200 +
  18.201 +/*
  18.202 + * xen dump-core header note.
  18.203 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER
  18.204 + * in its dump file.
  18.205 + * See tools/libxc/xc_core.h for more information.
  18.206 + */
  18.207 +#define XEN_ELFNOTE_DUMPCORE_HEADER             0x2000001
  18.208 +
  18.209 +/*
  18.210 + * xen dump-core xen version note.
  18.211 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION
  18.212 + * in its dump file. It contains the xen version obtained via the
  18.213 + * XENVER hypercall.
  18.214 + * See tools/libxc/xc_core.h for more information.
  18.215 + */
  18.216 +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION        0x2000002
  18.217 +
  18.218 +/*
  18.219 + * xen dump-core format version note.
  18.220 + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION
  18.221 + * in its dump file. It contains a format version identifier.
  18.222 + * See tools/libxc/xc_core.h for more information.
  18.223 + */
  18.224 +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION     0x2000003
  18.225 +
  18.226 +#endif /* __XEN_PUBLIC_ELFNOTE_H__ */
  18.227 +
  18.228 +/*
  18.229 + * Local variables:
  18.230 + * mode: C
  18.231 + * c-set-style: "BSD"
  18.232 + * c-basic-offset: 4
  18.233 + * tab-width: 4
  18.234 + * indent-tabs-mode: nil
  18.235 + * End:
  18.236 + */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/common/include/public/elfstructs.h	Wed Dec 19 09:23:32 2007 +1100
    19.3 @@ -0,0 +1,527 @@
    19.4 +#ifndef __XEN_PUBLIC_ELFSTRUCTS_H__
    19.5 +#define __XEN_PUBLIC_ELFSTRUCTS_H__ 1
    19.6 +/*
    19.7 + * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
    19.8 + *
    19.9 + * Redistribution and use in source and binary forms, with or without
   19.10 + * modification, are permitted provided that the following conditions
   19.11 + * are met:
   19.12 + * 1. Redistributions of source code must retain the above copyright
   19.13 + *    notice, this list of conditions and the following disclaimer.
   19.14 + * 2. Redistributions in binary form must reproduce the above copyright
   19.15 + *    notice, this list of conditions and the following disclaimer in the
   19.16 + *    documentation and/or other materials provided with the distribution.
   19.17 + * 3. The name of the author may not be used to endorse or promote products
   19.18 + *    derived from this software without specific prior written permission
   19.19 + *
   19.20 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19.21 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19.22 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19.23 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19.24 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   19.25 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   19.26 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   19.27 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   19.28 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   19.29 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   19.30 + */
   19.31 +
   19.32 +typedef uint8_t		Elf_Byte;
   19.33 +
   19.34 +typedef uint32_t	Elf32_Addr;	/* Unsigned program address */
   19.35 +typedef uint32_t	Elf32_Off;	/* Unsigned file offset */
   19.36 +typedef int32_t		Elf32_Sword;	/* Signed large integer */
   19.37 +typedef uint32_t	Elf32_Word;	/* Unsigned large integer */
   19.38 +typedef uint16_t	Elf32_Half;	/* Unsigned medium integer */
   19.39 +
   19.40 +typedef uint64_t	Elf64_Addr;
   19.41 +typedef uint64_t	Elf64_Off;
   19.42 +typedef int32_t		Elf64_Shalf;
   19.43 +
   19.44 +typedef int32_t		Elf64_Sword;
   19.45 +typedef uint32_t	Elf64_Word;
   19.46 +
   19.47 +typedef int64_t		Elf64_Sxword;
   19.48 +typedef uint64_t	Elf64_Xword;
   19.49 +
   19.50 +typedef uint32_t	Elf64_Half;
   19.51 +typedef uint16_t	Elf64_Quarter;
   19.52 +
   19.53 +/*
   19.54 + * e_ident[] identification indexes
   19.55 + * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
   19.56 + */
   19.57 +#define EI_MAG0		0		/* file ID */
   19.58 +#define EI_MAG1		1		/* file ID */
   19.59 +#define EI_MAG2		2		/* file ID */
   19.60 +#define EI_MAG3		3		/* file ID */
   19.61 +#define EI_CLASS	4		/* file class */
   19.62 +#define EI_DATA		5		/* data encoding */
   19.63 +#define EI_VERSION	6		/* ELF header version */
   19.64 +#define EI_OSABI	7		/* OS/ABI ID */
   19.65 +#define EI_ABIVERSION	8		/* ABI version */
   19.66 +#define EI_PAD		9		/* start of pad bytes */
   19.67 +#define EI_NIDENT	16		/* Size of e_ident[] */
   19.68 +
   19.69 +/* e_ident[] magic number */
   19.70 +#define	ELFMAG0		0x7f		/* e_ident[EI_MAG0] */
   19.71 +#define	ELFMAG1		'E'		/* e_ident[EI_MAG1] */
   19.72 +#define	ELFMAG2		'L'		/* e_ident[EI_MAG2] */
   19.73 +#define	ELFMAG3		'F'		/* e_ident[EI_MAG3] */
   19.74 +#define	ELFMAG		"\177ELF"	/* magic */
   19.75 +#define	SELFMAG		4		/* size of magic */
   19.76 +
   19.77 +/* e_ident[] file class */
   19.78 +#define	ELFCLASSNONE	0		/* invalid */
   19.79 +#define	ELFCLASS32	1		/* 32-bit objs */
   19.80 +#define	ELFCLASS64	2		/* 64-bit objs */
   19.81 +#define	ELFCLASSNUM	3		/* number of classes */
   19.82 +
   19.83 +/* e_ident[] data encoding */
   19.84 +#define ELFDATANONE	0		/* invalid */
   19.85 +#define ELFDATA2LSB	1		/* Little-Endian */
   19.86 +#define ELFDATA2MSB	2		/* Big-Endian */
   19.87 +#define ELFDATANUM	3		/* number of data encode defines */
   19.88 +
   19.89 +/* e_ident[] Operating System/ABI */
   19.90 +#define ELFOSABI_SYSV		0	/* UNIX System V ABI */
   19.91 +#define ELFOSABI_HPUX		1	/* HP-UX operating system */
   19.92 +#define ELFOSABI_NETBSD		2	/* NetBSD */
   19.93 +#define ELFOSABI_LINUX		3	/* GNU/Linux */
   19.94 +#define ELFOSABI_HURD		4	/* GNU/Hurd */
   19.95 +#define ELFOSABI_86OPEN		5	/* 86Open common IA32 ABI */
   19.96 +#define ELFOSABI_SOLARIS	6	/* Solaris */
   19.97 +#define ELFOSABI_MONTEREY	7	/* Monterey */
   19.98 +#define ELFOSABI_IRIX		8	/* IRIX */
   19.99 +#define ELFOSABI_FREEBSD	9	/* FreeBSD */
  19.100 +#define ELFOSABI_TRU64		10	/* TRU64 UNIX */
  19.101 +#define ELFOSABI_MODESTO	11	/* Novell Modesto */
  19.102 +#define ELFOSABI_OPENBSD	12	/* OpenBSD */
  19.103 +#define ELFOSABI_ARM		97	/* ARM */
  19.104 +#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
  19.105 +
  19.106 +/* e_ident */
  19.107 +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
  19.108 +                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
  19.109 +                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
  19.110 +                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)
  19.111 +
  19.112 +/* ELF Header */
  19.113 +typedef struct elfhdr {
  19.114 +	unsigned char	e_ident[EI_NIDENT]; /* ELF Identification */
  19.115 +	Elf32_Half	e_type;		/* object file type */
  19.116 +	Elf32_Half	e_machine;	/* machine */
  19.117 +	Elf32_Word	e_version;	/* object file version */
  19.118 +	Elf32_Addr	e_entry;	/* virtual entry point */
  19.119 +	Elf32_Off	e_phoff;	/* program header table offset */
  19.120 +	Elf32_Off	e_shoff;	/* section header table offset */
  19.121 +	Elf32_Word	e_flags;	/* processor-specific flags */
  19.122 +	Elf32_Half	e_ehsize;	/* ELF header size */
  19.123 +	Elf32_Half	e_phentsize;	/* program header entry size */
  19.124 +	Elf32_Half	e_phnum;	/* number of program header entries */
  19.125 +	Elf32_Half	e_shentsize;	/* section header entry size */
  19.126 +	Elf32_Half	e_shnum;	/* number of section header entries */
  19.127 +	Elf32_Half	e_shstrndx;	/* section header table's "section
  19.128 +					   header string table" entry offset */
  19.129 +} Elf32_Ehdr;
  19.130 +
  19.131 +typedef struct {
  19.132 +	unsigned char	e_ident[EI_NIDENT];	/* Id bytes */
  19.133 +	Elf64_Quarter	e_type;			/* file type */
  19.134 +	Elf64_Quarter	e_machine;		/* machine type */
  19.135 +	Elf64_Half	e_version;		/* version number */
  19.136 +	Elf64_Addr	e_entry;		/* entry point */
  19.137 +	Elf64_Off	e_phoff;		/* Program hdr offset */
  19.138 +	Elf64_Off	e_shoff;		/* Section hdr offset */
  19.139 +	Elf64_Half	e_flags;		/* Processor flags */
  19.140 +	Elf64_Quarter	e_ehsize;		/* sizeof ehdr */
  19.141 +	Elf64_Quarter	e_phentsize;		/* Program header entry size */
  19.142 +	Elf64_Quarter	e_phnum;		/* Number of program headers */
  19.143 +	Elf64_Quarter	e_shentsize;		/* Section header entry size */
  19.144 +	Elf64_Quarter	e_shnum;		/* Number of section headers */
  19.145 +	Elf64_Quarter	e_shstrndx;		/* String table index */
  19.146 +} Elf64_Ehdr;
  19.147 +
  19.148 +/* e_type */
  19.149 +#define ET_NONE		0		/* No file type */
  19.150 +#define ET_REL		1		/* relocatable file */
  19.151 +#define ET_EXEC		2		/* executable file */
  19.152 +#define ET_DYN		3		/* shared object file */
  19.153 +#define ET_CORE		4		/* core file */
  19.154 +#define ET_NUM		5		/* number of types */
  19.155 +#define ET_LOPROC	0xff00		/* reserved range for processor */
  19.156 +#define ET_HIPROC	0xffff		/*  specific e_type */
  19.157 +
  19.158 +/* e_machine */
  19.159 +#define EM_NONE		0		/* No Machine */
  19.160 +#define EM_M32		1		/* AT&T WE 32100 */
  19.161 +#define EM_SPARC	2		/* SPARC */
  19.162 +#define EM_386		3		/* Intel 80386 */
  19.163 +#define EM_68K		4		/* Motorola 68000 */
  19.164 +#define EM_88K		5		/* Motorola 88000 */
  19.165 +#define EM_486		6		/* Intel 80486 - unused? */
  19.166 +#define EM_860		7		/* Intel 80860 */
  19.167 +#define EM_MIPS		8		/* MIPS R3000 Big-Endian only */
  19.168 +/*
  19.169 + * Don't know if EM_MIPS_RS4_BE,
  19.170 + * EM_SPARC64, EM_PARISC,
  19.171 + * or EM_PPC are ABI compliant
  19.172 + */
  19.173 +#define EM_MIPS_RS4_BE	10		/* MIPS R4000 Big-Endian */
  19.174 +#define EM_SPARC64	11		/* SPARC v9 64-bit unoffical */
  19.175 +#define EM_PARISC	15		/* HPPA */
  19.176 +#define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
  19.177 +#define EM_PPC		20		/* PowerPC */
  19.178 +#define EM_PPC64	21		/* PowerPC 64-bit */
  19.179 +#define EM_ARM		40		/* Advanced RISC Machines ARM */
  19.180 +#define EM_ALPHA	41		/* DEC ALPHA */
  19.181 +#define EM_SPARCV9	43		/* SPARC version 9 */
  19.182 +#define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
  19.183 +#define EM_IA_64	50		/* Intel Merced */
  19.184 +#define EM_X86_64	62		/* AMD x86-64 architecture */
  19.185 +#define EM_VAX		75		/* DEC VAX */
  19.186 +
  19.187 +/* Version */
  19.188 +#define EV_NONE		0		/* Invalid */
  19.189 +#define EV_CURRENT	1		/* Current */
  19.190 +#define EV_NUM		2		/* number of versions */
  19.191 +
  19.192 +/* Section Header */
  19.193 +typedef struct {
  19.194 +	Elf32_Word	sh_name;	/* name - index into section header
  19.195 +					   string table section */
  19.196 +	Elf32_Word	sh_type;	/* type */
  19.197 +	Elf32_Word	sh_flags;	/* flags */
  19.198 +	Elf32_Addr	sh_addr;	/* address */
  19.199 +	Elf32_Off	sh_offset;	/* file offset */
  19.200 +	Elf32_Word	sh_size;	/* section size */
  19.201 +	Elf32_Word	sh_link;	/* section header table index link */
  19.202 +	Elf32_Word	sh_info;	/* extra information */
  19.203 +	Elf32_Word	sh_addralign;	/* address alignment */
  19.204 +	Elf32_Word	sh_entsize;	/* section entry size */
  19.205 +} Elf32_Shdr;
  19.206 +
  19.207 +typedef struct {
  19.208 +	Elf64_Half	sh_name;	/* section name */
  19.209 +	Elf64_Half	sh_type;	/* section type */
  19.210 +	Elf64_Xword	sh_flags;	/* section flags */
  19.211 +	Elf64_Addr	sh_addr;	/* virtual address */
  19.212 +	Elf64_Off	sh_offset;	/* file offset */
  19.213 +	Elf64_Xword	sh_size;	/* section size */
  19.214 +	Elf64_Half	sh_link;	/* link to another */
  19.215 +	Elf64_Half	sh_info;	/* misc info */
  19.216 +	Elf64_Xword	sh_addralign;	/* memory alignment */
  19.217 +	Elf64_Xword	sh_entsize;	/* table entry size */
  19.218 +} Elf64_Shdr;
  19.219 +
  19.220 +/* Special Section Indexes */
  19.221 +#define SHN_UNDEF	0		/* undefined */
  19.222 +#define SHN_LORESERVE	0xff00		/* lower bounds of reserved indexes */
  19.223 +#define SHN_LOPROC	0xff00		/* reserved range for processor */
  19.224 +#define SHN_HIPROC	0xff1f		/*   specific section indexes */
  19.225 +#define SHN_ABS		0xfff1		/* absolute value */
  19.226 +#define SHN_COMMON	0xfff2		/* common symbol */
  19.227 +#define SHN_HIRESERVE	0xffff		/* upper bounds of reserved indexes */
  19.228 +
  19.229 +/* sh_type */
  19.230 +#define SHT_NULL	0		/* inactive */
  19.231 +#define SHT_PROGBITS	1		/* program defined information */
  19.232 +#define SHT_SYMTAB	2		/* symbol table section */
  19.233 +#define SHT_STRTAB	3		/* string table section */
  19.234 +#define SHT_RELA	4		/* relocation section with addends*/
  19.235 +#define SHT_HASH	5		/* symbol hash table section */
  19.236 +#define SHT_DYNAMIC	6		/* dynamic section */
  19.237 +#define SHT_NOTE	7		/* note section */
  19.238 +#define SHT_NOBITS	8		/* no space section */
  19.239 +#define SHT_REL		9		/* relation section without addends */
  19.240 +#define SHT_SHLIB	10		/* reserved - purpose unknown */
  19.241 +#define SHT_DYNSYM	11		/* dynamic symbol table section */
  19.242 +#define SHT_NUM		12		/* number of section types */
  19.243 +#define SHT_LOPROC	0x70000000	/* reserved range for processor */
  19.244 +#define SHT_HIPROC	0x7fffffff	/*  specific section header types */
  19.245 +#define SHT_LOUSER	0x80000000	/* reserved range for application */
  19.246 +#define SHT_HIUSER	0xffffffff	/*  specific indexes */
  19.247 +
  19.248 +/* Section names */
  19.249 +#define ELF_BSS         ".bss"		/* uninitialized data */
  19.250 +#define ELF_DATA        ".data"		/* initialized data */
  19.251 +#define ELF_DEBUG       ".debug"	/* debug */
  19.252 +#define ELF_DYNAMIC     ".dynamic"	/* dynamic linking information */
  19.253 +#define ELF_DYNSTR      ".dynstr"	/* dynamic string table */
  19.254 +#define ELF_DYNSYM      ".dynsym"	/* dynamic symbol table */
  19.255 +#define ELF_FINI        ".fini"		/* termination code */
  19.256 +#define ELF_GOT         ".got"		/* global offset table */
  19.257 +#define ELF_HASH        ".hash"		/* symbol hash table */
  19.258 +#define ELF_INIT        ".init"		/* initialization code */
  19.259 +#define ELF_REL_DATA    ".rel.data"	/* relocation data */
  19.260 +#define ELF_REL_FINI    ".rel.fini"	/* relocation termination code */
  19.261 +#define ELF_REL_INIT    ".rel.init"	/* relocation initialization code */
  19.262 +#define ELF_REL_DYN     ".rel.dyn"	/* relocaltion dynamic link info */
  19.263 +#define ELF_REL_RODATA  ".rel.rodata"	/* relocation read-only data */
  19.264 +#define ELF_REL_TEXT    ".rel.text"	/* relocation code */
  19.265 +#define ELF_RODATA      ".rodata"	/* read-only data */
  19.266 +#define ELF_SHSTRTAB    ".shstrtab"	/* section header string table */
  19.267 +#define ELF_STRTAB      ".strtab"	/* string table */
  19.268 +#define ELF_SYMTAB      ".symtab"	/* symbol table */
  19.269 +#define ELF_TEXT        ".text"		/* code */
  19.270 +
  19.271 +
  19.272 +/* Section Attribute Flags - sh_flags */
  19.273 +#define SHF_WRITE	0x1		/* Writable */
  19.274 +#define SHF_ALLOC	0x2		/* occupies memory */
  19.275 +#define SHF_EXECINSTR	0x4		/* executable */
  19.276 +#define SHF_MASKPROC	0xf0000000	/* reserved bits for processor */
  19.277 +					/*  specific section attributes */
  19.278 +
  19.279 +/* Symbol Table Entry */
  19.280 +typedef struct elf32_sym {
  19.281 +	Elf32_Word	st_name;	/* name - index into string table */
  19.282 +	Elf32_Addr	st_value;	/* symbol value */
  19.283 +	Elf32_Word	st_size;	/* symbol size */
  19.284 +	unsigned char	st_info;	/* type and binding */
  19.285 +	unsigned char	st_other;	/* 0 - no defined meaning */
  19.286 +	Elf32_Half	st_shndx;	/* section header index */
  19.287 +} Elf32_Sym;
  19.288 +
  19.289 +typedef struct {
  19.290 +	Elf64_Half	st_name;	/* Symbol name index in str table */
  19.291 +	Elf_Byte	st_info;	/* type / binding attrs */
  19.292 +	Elf_Byte	st_other;	/* unused */
  19.293 +	Elf64_Quarter	st_shndx;	/* section index of symbol */
  19.294 +	Elf64_Xword	st_value;	/* value of symbol */
  19.295 +	Elf64_Xword	st_size;	/* size of symbol */
  19.296 +} Elf64_Sym;
  19.297 +
  19.298 +/* Symbol table index */
  19.299 +#define STN_UNDEF	0		/* undefined */
  19.300 +
  19.301 +/* Extract symbol info - st_info */
  19.302 +#define ELF32_ST_BIND(x)	((x) >> 4)
  19.303 +#define ELF32_ST_TYPE(x)	(((unsigned int) x) & 0xf)
  19.304 +#define ELF32_ST_INFO(b,t)	(((b) << 4) + ((t) & 0xf))
  19.305 +
  19.306 +#define ELF64_ST_BIND(x)	((x) >> 4)
  19.307 +#define ELF64_ST_TYPE(x)	(((unsigned int) x) & 0xf)
  19.308 +#define ELF64_ST_INFO(b,t)	(((b) << 4) + ((t) & 0xf))
  19.309 +
  19.310 +/* Symbol Binding - ELF32_ST_BIND - st_info */
  19.311 +#define STB_LOCAL	0		/* Local symbol */
  19.312 +#define STB_GLOBAL	1		/* Global symbol */
  19.313 +#define STB_WEAK	2		/* like global - lower precedence */
  19.314 +#define STB_NUM		3		/* number of symbol bindings */
  19.315 +#define STB_LOPROC	13		/* reserved range for processor */
  19.316 +#define STB_HIPROC	15		/*  specific symbol bindings */
  19.317 +
  19.318 +/* Symbol type - ELF32_ST_TYPE - st_info */
  19.319 +#define STT_NOTYPE	0		/* not specified */
  19.320 +#define STT_OBJECT	1		/* data object */
  19.321 +#define STT_FUNC	2		/* function */
  19.322 +#define STT_SECTION	3		/* section */
  19.323 +#define STT_FILE	4		/* file */
  19.324 +#define STT_NUM		5		/* number of symbol types */
  19.325 +#define STT_LOPROC	13		/* reserved range for processor */
  19.326 +#define STT_HIPROC	15		/*  specific symbol types */
  19.327 +
  19.328 +/* Relocation entry with implicit addend */
  19.329 +typedef struct {
  19.330 +	Elf32_Addr	r_offset;	/* offset of relocation */
  19.331 +	Elf32_Word	r_info;		/* symbol table index and type */
  19.332 +} Elf32_Rel;
  19.333 +
  19.334 +/* Relocation entry with explicit addend */
  19.335 +typedef struct {
  19.336 +	Elf32_Addr	r_offset;	/* offset of relocation */
  19.337 +	Elf32_Word	r_info;		/* symbol table index and type */
  19.338 +	Elf32_Sword	r_addend;
  19.339 +} Elf32_Rela;
  19.340 +
  19.341 +/* Extract relocation info - r_info */
  19.342 +#define ELF32_R_SYM(i)		((i) >> 8)
  19.343 +#define ELF32_R_TYPE(i)		((unsigned char) (i))
  19.344 +#define ELF32_R_INFO(s,t) 	(((s) << 8) + (unsigned char)(t))
  19.345 +
  19.346 +typedef struct {
  19.347 +	Elf64_Xword	r_offset;	/* where to do it */
  19.348 +	Elf64_Xword	r_info;		/* index & type of relocation */
  19.349 +} Elf64_Rel;
  19.350 +
  19.351 +typedef struct {
  19.352 +	Elf64_Xword	r_offset;	/* where to do it */
  19.353 +	Elf64_Xword	r_info;		/* index & type of relocation */
  19.354 +	Elf64_Sxword	r_addend;	/* adjustment value */
  19.355 +} Elf64_Rela;
  19.356 +
  19.357 +#define	ELF64_R_SYM(info)	((info) >> 32)
  19.358 +#define	ELF64_R_TYPE(info)	((info) & 0xFFFFFFFF)
  19.359 +#define ELF64_R_INFO(s,t) 	(((s) << 32) + (u_int32_t)(t))
  19.360 +
  19.361 +/* Program Header */
  19.362 +typedef struct {
  19.363 +	Elf32_Word	p_type;		/* segment type */
  19.364 +	Elf32_Off	p_offset;	/* segment offset */
  19.365 +	Elf32_Addr	p_vaddr;	/* virtual address of segment */
  19.366 +	Elf32_Addr	p_paddr;	/* physical address - ignored? */
  19.367 +	Elf32_Word	p_filesz;	/* number of bytes in file for seg. */
  19.368 +	Elf32_Word	p_memsz;	/* number of bytes in mem. for seg. */
  19.369 +	Elf32_Word	p_flags;	/* flags */
  19.370 +	Elf32_Word	p_align;	/* memory alignment */
  19.371 +} Elf32_Phdr;
  19.372 +
  19.373 +typedef struct {
  19.374 +	Elf64_Half	p_type;		/* entry type */
  19.375 +	Elf64_Half	p_flags;	/* flags */
  19.376 +	Elf64_Off	p_offset;	/* offset */
  19.377 +	Elf64_Addr	p_vaddr;	/* virtual address */
  19.378 +	Elf64_Addr	p_paddr;	/* physical address */
  19.379 +	Elf64_Xword	p_filesz;	/* file size */
  19.380 +	Elf64_Xword	p_memsz;	/* memory size */
  19.381 +	Elf64_Xword	p_align;	/* memory & file alignment */
  19.382 +} Elf64_Phdr;
  19.383 +
  19.384 +/* Segment types - p_type */
  19.385 +#define PT_NULL		0		/* unused */
  19.386 +#define PT_LOAD		1		/* loadable segment */
  19.387 +#define PT_DYNAMIC	2		/* dynamic linking section */
  19.388 +#define PT_INTERP	3		/* the RTLD */
  19.389 +#define PT_NOTE		4		/* auxiliary information */
  19.390 +#define PT_SHLIB	5		/* reserved - purpose undefined */
  19.391 +#define PT_PHDR		6		/* program header */
  19.392 +#define PT_NUM		7		/* Number of segment types */
  19.393 +#define PT_LOPROC	0x70000000	/* reserved range for processor */
  19.394 +#define PT_HIPROC	0x7fffffff	/*  specific segment types */
  19.395 +
  19.396 +/* Segment flags - p_flags */
  19.397 +#define PF_X		0x1		/* Executable */
  19.398 +#define PF_W		0x2		/* Writable */
  19.399 +#define PF_R		0x4		/* Readable */
  19.400 +#define PF_MASKPROC	0xf0000000	/* reserved bits for processor */
  19.401 +					/*  specific segment flags */
  19.402 +
  19.403 +/* Dynamic structure */
  19.404 +typedef struct {
  19.405 +	Elf32_Sword	d_tag;		/* controls meaning of d_val */
  19.406 +	union {
  19.407 +		Elf32_Word	d_val;	/* Multiple meanings - see d_tag */
  19.408 +		Elf32_Addr	d_ptr;	/* program virtual address */
  19.409 +	} d_un;
  19.410 +} Elf32_Dyn;
  19.411 +
  19.412 +typedef struct {
  19.413 +	Elf64_Xword	d_tag;		/* controls meaning of d_val */
  19.414 +	union {
  19.415 +		Elf64_Addr	d_ptr;
  19.416 +		Elf64_Xword	d_val;
  19.417 +	} d_un;
  19.418 +} Elf64_Dyn;
  19.419 +
  19.420 +/* Dynamic Array Tags - d_tag */
  19.421 +#define DT_NULL		0		/* marks end of _DYNAMIC array */
  19.422 +#define DT_NEEDED	1		/* string table offset of needed lib */
  19.423 +#define DT_PLTRELSZ	2		/* size of relocation entries in PLT */
  19.424 +#define DT_PLTGOT	3		/* address PLT/GOT */
  19.425 +#define DT_HASH		4		/* address of symbol hash table */
  19.426 +#define DT_STRTAB	5		/* address of string table */
  19.427 +#define DT_SYMTAB	6		/* address of symbol table */
  19.428 +#define DT_RELA		7		/* address of relocation table */
  19.429 +#define DT_RELASZ	8		/* size of relocation table */
  19.430 +#define DT_RELAENT	9		/* size of relocation entry */
  19.431 +#define DT_STRSZ	10		/* size of string table */
  19.432 +#define DT_SYMENT	11		/* size of symbol table entry */
  19.433 +#define DT_INIT		12		/* address of initialization func. */
  19.434 +#define DT_FINI		13		/* address of termination function */
  19.435 +#define DT_SONAME	14		/* string table offset of shared obj */
  19.436 +#define DT_RPATH	15		/* string table offset of library
  19.437 +					   search path */
  19.438 +#define DT_SYMBOLIC	16		/* start sym search in shared obj. */
  19.439 +#define DT_REL		17		/* address of rel. tbl. w addends */
  19.440 +#define DT_RELSZ	18		/* size of DT_REL relocation table */
  19.441 +#define DT_RELENT	19		/* size of DT_REL relocation entry */
  19.442 +#define DT_PLTREL	20		/* PLT referenced relocation entry */
  19.443 +#define DT_DEBUG	21		/* bugger */
  19.444 +#define DT_TEXTREL	22		/* Allow rel. mod. to unwritable seg */
  19.445 +#define DT_JMPREL	23		/* add. of PLT's relocation entries */
  19.446 +#define DT_BIND_NOW	24		/* Bind now regardless of env setting */
  19.447 +#define DT_NUM		25		/* Number used. */
  19.448 +#define DT_LOPROC	0x70000000	/* reserved range for processor */
  19.449 +#define DT_HIPROC	0x7fffffff	/*  specific dynamic array tags */
  19.450 +
  19.451 +/* Standard ELF hashing function */
  19.452 +unsigned int elf_hash(const unsigned char *name);
  19.453 +
  19.454 +/*
  19.455 + * Note Definitions
  19.456 + */
  19.457 +typedef struct {
  19.458 +	Elf32_Word namesz;
  19.459 +	Elf32_Word descsz;
  19.460 +	Elf32_Word type;
  19.461 +} Elf32_Note;
  19.462 +
  19.463 +typedef struct {
  19.464 +	Elf64_Half namesz;
  19.465 +	Elf64_Half descsz;
  19.466 +	Elf64_Half type;
  19.467 +} Elf64_Note;
  19.468 +
  19.469 +
  19.470 +#if defined(ELFSIZE)
  19.471 +#define CONCAT(x,y)	__CONCAT(x,y)
  19.472 +#define ELFNAME(x)	CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
  19.473 +#define ELFNAME2(x,y)	CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
  19.474 +#define ELFNAMEEND(x)	CONCAT(x,CONCAT(_elf,ELFSIZE))
  19.475 +#define ELFDEFNNAME(x)	CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
  19.476 +#endif
  19.477 +
  19.478 +#if defined(ELFSIZE) && (ELFSIZE == 32)
  19.479 +#define Elf_Ehdr	Elf32_Ehdr
  19.480 +#define Elf_Phdr	Elf32_Phdr
  19.481 +#define Elf_Shdr	Elf32_Shdr
  19.482 +#define Elf_Sym		Elf32_Sym
  19.483 +#define Elf_Rel		Elf32_Rel
  19.484 +#define Elf_RelA	Elf32_Rela
  19.485 +#define Elf_Dyn		Elf32_Dyn
  19.486 +#define Elf_Word	Elf32_Word
  19.487 +#define Elf_Sword	Elf32_Sword
  19.488 +#define Elf_Addr	Elf32_Addr
  19.489 +#define Elf_Off		Elf32_Off
  19.490 +#define Elf_Nhdr	Elf32_Nhdr
  19.491 +#define Elf_Note	Elf32_Note
  19.492 +
  19.493 +#define ELF_R_SYM	ELF32_R_SYM
  19.494 +#define ELF_R_TYPE	ELF32_R_TYPE
  19.495 +#define ELF_R_INFO	ELF32_R_INFO
  19.496 +#define ELFCLASS	ELFCLASS32
  19.497 +
  19.498 +#define ELF_ST_BIND	ELF32_ST_BIND
  19.499 +#define ELF_ST_TYPE	ELF32_ST_TYPE
  19.500 +#define ELF_ST_INFO	ELF32_ST_INFO
  19.501 +
  19.502 +#define AuxInfo		Aux32Info
  19.503 +#elif defined(ELFSIZE) && (ELFSIZE == 64)
  19.504 +#define Elf_Ehdr	Elf64_Ehdr
  19.505 +#define Elf_Phdr	Elf64_Phdr
  19.506 +#define Elf_Shdr	Elf64_Shdr
  19.507 +#define Elf_Sym		Elf64_Sym
  19.508 +#define Elf_Rel		Elf64_Rel
  19.509 +#define Elf_RelA	Elf64_Rela
  19.510 +#define Elf_Dyn		Elf64_Dyn
  19.511 +#define Elf_Word	Elf64_Word
  19.512 +#define Elf_Sword	Elf64_Sword
  19.513 +#define Elf_Addr	Elf64_Addr
  19.514 +#define Elf_Off		Elf64_Off
  19.515 +#define Elf_Nhdr	Elf64_Nhdr
  19.516 +#define Elf_Note	Elf64_Note
  19.517 +
  19.518 +#define ELF_R_SYM	ELF64_R_SYM
  19.519 +#define ELF_R_TYPE	ELF64_R_TYPE
  19.520 +#define ELF_R_INFO	ELF64_R_INFO
  19.521 +#define ELFCLASS	ELFCLASS64
  19.522 +
  19.523 +#define ELF_ST_BIND	ELF64_ST_BIND
  19.524 +#define ELF_ST_TYPE	ELF64_ST_TYPE
  19.525 +#define ELF_ST_INFO	ELF64_ST_INFO
  19.526 +
  19.527 +#define AuxInfo		Aux64Info
  19.528 +#endif
  19.529 +
  19.530 +#endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/common/include/public/event_channel.h	Wed Dec 19 09:23:32 2007 +1100
    20.3 @@ -0,0 +1,264 @@
    20.4 +/******************************************************************************
    20.5 + * event_channel.h
    20.6 + * 
    20.7 + * Event channels between domains.
    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) 2003-2004, K A Fraser.
   20.28 + */
   20.29 +
   20.30 +#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
   20.31 +#define __XEN_PUBLIC_EVENT_CHANNEL_H__
   20.32 +
   20.33 +/*
   20.34 + * Prototype for this hypercall is:
   20.35 + *  int event_channel_op(int cmd, void *args)
   20.36 + * @cmd  == EVTCHNOP_??? (event-channel operation).
   20.37 + * @args == Operation-specific extra arguments (NULL if none).
   20.38 + */
   20.39 +
   20.40 +typedef uint32_t evtchn_port_t;
   20.41 +DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
   20.42 +
   20.43 +/*
   20.44 + * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
   20.45 + * accepting interdomain bindings from domain <remote_dom>. A fresh port
   20.46 + * is allocated in <dom> and returned as <port>.
   20.47 + * NOTES:
   20.48 + *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
   20.49 + *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
   20.50 + */
   20.51 +#define EVTCHNOP_alloc_unbound    6
   20.52 +struct evtchn_alloc_unbound {
   20.53 +    /* IN parameters */
   20.54 +    domid_t dom, remote_dom;
   20.55 +    /* OUT parameters */
   20.56 +    evtchn_port_t port;
   20.57 +};
   20.58 +typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
   20.59 +
   20.60 +/*
   20.61 + * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
   20.62 + * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
   20.63 + * a port that is unbound and marked as accepting bindings from the calling
   20.64 + * domain. A fresh port is allocated in the calling domain and returned as
   20.65 + * <local_port>.
   20.66 + * NOTES:
   20.67 + *  2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
   20.68 + */
   20.69 +#define EVTCHNOP_bind_interdomain 0
   20.70 +struct evtchn_bind_interdomain {
   20.71 +    /* IN parameters. */
   20.72 +    domid_t remote_dom;
   20.73 +    evtchn_port_t remote_port;
   20.74 +    /* OUT parameters. */
   20.75 +    evtchn_port_t local_port;
   20.76 +};
   20.77 +typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
   20.78 +
   20.79 +/*
   20.80 + * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
   20.81 + * vcpu.
   20.82 + * NOTES:
   20.83 + *  1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
   20.84 + *     in xen.h for the classification of each VIRQ.
   20.85 + *  2. Global VIRQs must be allocated on VCPU0 but can subsequently be
   20.86 + *     re-bound via EVTCHNOP_bind_vcpu.
   20.87 + *  3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
   20.88 + *     The allocated event channel is bound to the specified vcpu and the
   20.89 + *     binding cannot be changed.
   20.90 + */
   20.91 +#define EVTCHNOP_bind_virq        1
   20.92 +struct evtchn_bind_virq {
   20.93 +    /* IN parameters. */
   20.94 +    uint32_t virq;
   20.95 +    uint32_t vcpu;
   20.96 +    /* OUT parameters. */
   20.97 +    evtchn_port_t port;
   20.98 +};
   20.99 +typedef struct evtchn_bind_virq evtchn_bind_virq_t;
  20.100 +
  20.101 +/*
  20.102 + * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
  20.103 + * NOTES:
  20.104 + *  1. A physical IRQ may be bound to at most one event channel per domain.
  20.105 + *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
  20.106 + */
  20.107 +#define EVTCHNOP_bind_pirq        2
  20.108 +struct evtchn_bind_pirq {
  20.109 +    /* IN parameters. */
  20.110 +    uint32_t pirq;
  20.111 +#define BIND_PIRQ__WILL_SHARE 1
  20.112 +    uint32_t flags; /* BIND_PIRQ__* */
  20.113 +    /* OUT parameters. */
  20.114 +    evtchn_port_t port;
  20.115 +};
  20.116 +typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
  20.117 +
  20.118 +/*
  20.119 + * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
  20.120 + * NOTES:
  20.121 + *  1. The allocated event channel is bound to the specified vcpu. The binding
  20.122 + *     may not be changed.
  20.123 + */
  20.124 +#define EVTCHNOP_bind_ipi         7
  20.125 +struct evtchn_bind_ipi {
  20.126 +    uint32_t vcpu;
  20.127 +    /* OUT parameters. */
  20.128 +    evtchn_port_t port;
  20.129 +};
  20.130 +typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
  20.131 +
  20.132 +/*
  20.133 + * EVTCHNOP_close: Close a local event channel <port>. If the channel is
  20.134 + * interdomain then the remote end is placed in the unbound state
  20.135 + * (EVTCHNSTAT_unbound), awaiting a new connection.
  20.136 + */
  20.137 +#define EVTCHNOP_close            3
  20.138 +struct evtchn_close {
  20.139 +    /* IN parameters. */
  20.140 +    evtchn_port_t port;
  20.141 +};
  20.142 +typedef struct evtchn_close evtchn_close_t;
  20.143 +
  20.144 +/*
  20.145 + * EVTCHNOP_send: Send an event to the remote end of the channel whose local
  20.146 + * endpoint is <port>.
  20.147 + */
  20.148 +#define EVTCHNOP_send             4
  20.149 +struct evtchn_send {
  20.150 +    /* IN parameters. */
  20.151 +    evtchn_port_t port;
  20.152 +};
  20.153 +typedef struct evtchn_send evtchn_send_t;
  20.154 +
  20.155 +/*
  20.156 + * EVTCHNOP_status: Get the current status of the communication channel which
  20.157 + * has an endpoint at <dom, port>.
  20.158 + * NOTES:
  20.159 + *  1. <dom> may be specified as DOMID_SELF.
  20.160 + *  2. Only a sufficiently-privileged domain may obtain the status of an event
  20.161 + *     channel for which <dom> is not DOMID_SELF.
  20.162 + */
  20.163 +#define EVTCHNOP_status           5
  20.164 +struct evtchn_status {
  20.165 +    /* IN parameters */
  20.166 +    domid_t  dom;
  20.167 +    evtchn_port_t port;
  20.168 +    /* OUT parameters */
  20.169 +#define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
  20.170 +#define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
  20.171 +#define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
  20.172 +#define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
  20.173 +#define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
  20.174 +#define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
  20.175 +    uint32_t status;
  20.176 +    uint32_t vcpu;                 /* VCPU to which this channel is bound.   */
  20.177 +    union {
  20.178 +        struct {
  20.179 +            domid_t dom;
  20.180 +        } unbound; /* EVTCHNSTAT_unbound */
  20.181 +        struct {
  20.182 +            domid_t dom;
  20.183 +            evtchn_port_t port;
  20.184 +        } interdomain; /* EVTCHNSTAT_interdomain */
  20.185 +        uint32_t pirq;      /* EVTCHNSTAT_pirq        */
  20.186 +        uint32_t virq;      /* EVTCHNSTAT_virq        */
  20.187 +    } u;
  20.188 +};
  20.189 +typedef struct evtchn_status evtchn_status_t;
  20.190 +
  20.191 +/*
  20.192 + * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
  20.193 + * event is pending.
  20.194 + * NOTES:
  20.195 + *  1. IPI-bound channels always notify the vcpu specified at bind time.
  20.196 + *     This binding cannot be changed.
  20.197 + *  2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
  20.198 + *     This binding cannot be changed.
  20.199 + *  3. All other channels notify vcpu0 by default. This default is set when
  20.200 + *     the channel is allocated (a port that is freed and subsequently reused
  20.201 + *     has its binding reset to vcpu0).
  20.202 + */
  20.203 +#define EVTCHNOP_bind_vcpu        8
  20.204 +struct evtchn_bind_vcpu {
  20.205 +    /* IN parameters. */
  20.206 +    evtchn_port_t port;
  20.207 +    uint32_t vcpu;
  20.208 +};
  20.209 +typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
  20.210 +
  20.211 +/*
  20.212 + * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
  20.213 + * a notification to the appropriate VCPU if an event is pending.
  20.214 + */
  20.215 +#define EVTCHNOP_unmask           9
  20.216 +struct evtchn_unmask {
  20.217 +    /* IN parameters. */
  20.218 +    evtchn_port_t port;
  20.219 +};
  20.220 +typedef struct evtchn_unmask evtchn_unmask_t;
  20.221 +
  20.222 +/*
  20.223 + * EVTCHNOP_reset: Close all event channels associated with specified domain.
  20.224 + * NOTES:
  20.225 + *  1. <dom> may be specified as DOMID_SELF.
  20.226 + *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
  20.227 + */
  20.228 +#define EVTCHNOP_reset           10
  20.229 +struct evtchn_reset {
  20.230 +    /* IN parameters. */
  20.231 +    domid_t dom;
  20.232 +};
  20.233 +typedef struct evtchn_reset evtchn_reset_t;
  20.234 +
  20.235 +/*
  20.236 + * Argument to event_channel_op_compat() hypercall. Superceded by new
  20.237 + * event_channel_op() hypercall since 0x00030202.
  20.238 + */
  20.239 +struct evtchn_op {
  20.240 +    uint32_t cmd; /* EVTCHNOP_* */
  20.241 +    union {
  20.242 +        struct evtchn_alloc_unbound    alloc_unbound;
  20.243 +        struct evtchn_bind_interdomain bind_interdomain;
  20.244 +        struct evtchn_bind_virq        bind_virq;
  20.245 +        struct evtchn_bind_pirq        bind_pirq;
  20.246 +        struct evtchn_bind_ipi         bind_ipi;
  20.247 +        struct evtchn_close            close;
  20.248 +        struct evtchn_send             send;
  20.249 +        struct evtchn_status           status;
  20.250 +        struct evtchn_bind_vcpu        bind_vcpu;
  20.251 +        struct evtchn_unmask           unmask;
  20.252 +    } u;
  20.253 +};
  20.254 +typedef struct evtchn_op evtchn_op_t;
  20.255 +DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
  20.256 +
  20.257 +#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
  20.258 +
  20.259 +/*
  20.260 + * Local variables:
  20.261 + * mode: C
  20.262 + * c-set-style: "BSD"
  20.263 + * c-basic-offset: 4
  20.264 + * tab-width: 4
  20.265 + * indent-tabs-mode: nil
  20.266 + * End:
  20.267 + */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/common/include/public/features.h	Wed Dec 19 09:23:32 2007 +1100
    21.3 @@ -0,0 +1,71 @@
    21.4 +/******************************************************************************
    21.5 + * features.h
    21.6 + * 
    21.7 + * Feature flags, reported by XENVER_get_features.
    21.8 + * 
    21.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   21.10 + * of this software and associated documentation files (the "Software"), to
   21.11 + * deal in the Software without restriction, including without limitation the
   21.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   21.13 + * sell copies of the Software, and to permit persons to whom the Software is
   21.14 + * furnished to do so, subject to the following conditions:
   21.15 + *
   21.16 + * The above copyright notice and this permission notice shall be included in
   21.17 + * all copies or substantial portions of the Software.
   21.18 + *
   21.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   21.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   21.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   21.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   21.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   21.25 + * DEALINGS IN THE SOFTWARE.
   21.26 + *
   21.27 + * Copyright (c) 2006, Keir Fraser <keir@xensource.com>
   21.28 + */
   21.29 +
   21.30 +#ifndef __XEN_PUBLIC_FEATURES_H__
   21.31 +#define __XEN_PUBLIC_FEATURES_H__
   21.32 +
   21.33 +/*
   21.34 + * If set, the guest does not need to write-protect its pagetables, and can
   21.35 + * update them via direct writes.
   21.36 + */
   21.37 +#define XENFEAT_writable_page_tables       0
   21.38 +
   21.39 +/*
   21.40 + * If set, the guest does not need to write-protect its segment descriptor
   21.41 + * tables, and can update them via direct writes.
   21.42 + */
   21.43 +#define XENFEAT_writable_descriptor_tables 1
   21.44 +
   21.45 +/*
   21.46 + * If set, translation between the guest's 'pseudo-physical' address space
   21.47 + * and the host's machine address space are handled by the hypervisor. In this
   21.48 + * mode the guest does not need to perform phys-to/from-machine translations
   21.49 + * when performing page table operations.
   21.50 + */
   21.51 +#define XENFEAT_auto_translated_physmap    2
   21.52 +
   21.53 +/* If set, the guest is running in supervisor mode (e.g., x86 ring 0). */
   21.54 +#define XENFEAT_supervisor_mode_kernel     3
   21.55 +
   21.56 +/*
   21.57 + * If set, the guest does not need to allocate x86 PAE page directories
   21.58 + * below 4GB. This flag is usually implied by auto_translated_physmap.
   21.59 + */
   21.60 +#define XENFEAT_pae_pgdir_above_4gb        4
   21.61 +
   21.62 +#define XENFEAT_NR_SUBMAPS 1
   21.63 +
   21.64 +#endif /* __XEN_PUBLIC_FEATURES_H__ */
   21.65 +
   21.66 +/*
   21.67 + * Local variables:
   21.68 + * mode: C
   21.69 + * c-set-style: "BSD"
   21.70 + * c-basic-offset: 4
   21.71 + * tab-width: 4
   21.72 + * indent-tabs-mode: nil
   21.73 + * End:
   21.74 + */
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/common/include/public/foreign/Makefile	Wed Dec 19 09:23:32 2007 +1100
    22.3 @@ -0,0 +1,37 @@
    22.4 +XEN_ROOT=../../../..
    22.5 +include $(XEN_ROOT)/Config.mk
    22.6 +
    22.7 +architectures := x86_32 x86_64 ia64
    22.8 +headers := $(patsubst %, %.h, $(architectures))
    22.9 +scripts := $(wildcard *.py)
   22.10 +
   22.11 +.PHONY: all clean check-headers
   22.12 +all: $(headers) check-headers
   22.13 +
   22.14 +clean:
   22.15 +	rm -f $(headers)
   22.16 +	rm -f checker checker.c $(XEN_TARGET_ARCH).size
   22.17 +	rm -f *.pyc *.o *~
   22.18 +
   22.19 +ifeq ($(CROSS_COMPILE)$(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
   22.20 +check-headers: checker
   22.21 +	./checker > $(XEN_TARGET_ARCH).size
   22.22 +	diff -u reference.size $(XEN_TARGET_ARCH).size
   22.23 +checker: checker.c $(headers)
   22.24 +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
   22.25 +else
   22.26 +check-headers:
   22.27 +	@echo "cross build: skipping check"
   22.28 +endif
   22.29 +
   22.30 +x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts)
   22.31 +	python mkheader.py $* $@ $(filter %.h,$^)
   22.32 +
   22.33 +x86_64.h: ../arch-x86/xen-x86_64.h ../arch-x86/xen.h ../xen.h $(scripts)
   22.34 +	python mkheader.py $* $@ $(filter %.h,$^)
   22.35 +
   22.36 +ia64.h: ../arch-ia64.h ../xen.h $(scripts)
   22.37 +	python mkheader.py $* $@ $(filter %.h,$^)
   22.38 +
   22.39 +checker.c: $(scripts)
   22.40 +	python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures)
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/common/include/public/foreign/mkchecker.py	Wed Dec 19 09:23:32 2007 +1100
    23.3 @@ -0,0 +1,58 @@
    23.4 +#!/usr/bin/python
    23.5 +
    23.6 +import sys;
    23.7 +from structs import structs;
    23.8 +
    23.9 +# command line arguments
   23.10 +arch    = sys.argv[1];
   23.11 +outfile = sys.argv[2];
   23.12 +archs   = sys.argv[3:];
   23.13 +
   23.14 +f = open(outfile, "w");
   23.15 +f.write('''
   23.16 +/*
   23.17 + * sanity checks for generated foreign headers:
   23.18 + *  - verify struct sizes
   23.19 + *
   23.20 + * generated by %s -- DO NOT EDIT
   23.21 + */
   23.22 +#include <stdio.h>
   23.23 +#include <stdlib.h>
   23.24 +#include <stddef.h>
   23.25 +#include <inttypes.h>
   23.26 +#include "../xen.h"
   23.27 +''');
   23.28 +
   23.29 +for a in archs:
   23.30 +    f.write('#include "%s.h"\n' % a);
   23.31 +
   23.32 +f.write('int main(int argc, char *argv[])\n{\n');
   23.33 +
   23.34 +f.write('\tprintf("\\n");');
   23.35 +f.write('printf("%-20s |", "structs");\n');
   23.36 +for a in archs:
   23.37 +    f.write('\tprintf("%%8s", "%s");\n' % a);
   23.38 +f.write('\tprintf("\\n");');
   23.39 +
   23.40 +f.write('\tprintf("\\n");');
   23.41 +for struct in structs:
   23.42 +    f.write('\tprintf("%%-20s |", "%s");\n' % struct);
   23.43 +    for a in archs:
   23.44 +        if a == arch:
   23.45 +            s = struct; # native
   23.46 +        else:
   23.47 +            s = struct + "_" + a;
   23.48 +        f.write('#ifdef %s_has_no_%s\n' % (a, struct));
   23.49 +        f.write('\tprintf("%8s", "-");\n');
   23.50 +        f.write("#else\n");
   23.51 +        f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
   23.52 +        f.write("#endif\n");
   23.53 +
   23.54 +    f.write('\tprintf("\\n");\n\n');
   23.55 +
   23.56 +f.write('\tprintf("\\n");\n');
   23.57 +f.write('\texit(0);\n');
   23.58 +f.write('}\n');
   23.59 +
   23.60 +f.close();
   23.61 +
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/common/include/public/foreign/mkheader.py	Wed Dec 19 09:23:32 2007 +1100
    24.3 @@ -0,0 +1,153 @@
    24.4 +#!/usr/bin/python
    24.5 +
    24.6 +import sys, re;
    24.7 +from structs import structs, defines;
    24.8 +
    24.9 +# command line arguments
   24.10 +arch    = sys.argv[1];
   24.11 +outfile = sys.argv[2];
   24.12 +infiles = sys.argv[3:];
   24.13 +
   24.14 +
   24.15 +###########################################################################
   24.16 +# configuration #2: architecture information
   24.17 +
   24.18 +inttypes = {};
   24.19 +header = {};
   24.20 +footer = {};
   24.21 +
   24.22 +# x86_32
   24.23 +inttypes["x86_32"] = {
   24.24 +    "unsigned long" : "uint32_t",
   24.25 +    "long"          : "uint32_t",
   24.26 +    "xen_pfn_t"     : "uint32_t",
   24.27 +};
   24.28 +header["x86_32"] = """
   24.29 +#define __i386___X86_32 1
   24.30 +#pragma pack(4)
   24.31 +""";
   24.32 +footer["x86_32"] = """
   24.33 +#pragma pack()
   24.34 +""";
   24.35 +
   24.36 +# x86_64
   24.37 +inttypes["x86_64"] = {
   24.38 +    "unsigned long" : "__align8__ uint64_t",
   24.39 +    "long"          : "__align8__ uint64_t",
   24.40 +    "xen_pfn_t"     : "__align8__ uint64_t",
   24.41 +};
   24.42 +header["x86_64"] = """
   24.43 +#ifdef __GNUC__
   24.44 +# define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
   24.45 +# define __align8__ __attribute__((aligned (8)))
   24.46 +#else
   24.47 +# define __DECL_REG(name) uint64_t r ## name
   24.48 +# define __align8__ FIXME
   24.49 +#endif
   24.50 +#define __x86_64___X86_64 1
   24.51 +""";
   24.52 +
   24.53 +# ia64
   24.54 +inttypes["ia64"] = {
   24.55 +    "unsigned long" : "__align8__ uint64_t",
   24.56 +    "long"          : "__align8__ uint64_t",
   24.57 +    "xen_pfn_t"     : "__align8__ uint64_t",
   24.58 +    "long double"   : "__align16__ ldouble_t",
   24.59 +};
   24.60 +header["ia64"] = """
   24.61 +#define __align8__ __attribute__((aligned (8)))
   24.62 +#define __align16__ __attribute__((aligned (16)))
   24.63 +typedef unsigned char ldouble_t[16];
   24.64 +""";
   24.65 +
   24.66 +
   24.67 +###########################################################################
   24.68 +# main
   24.69 +
   24.70 +input  = "";
   24.71 +output = "";
   24.72 +fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
   24.73 +
   24.74 +# read input header files
   24.75 +for name in infiles:
   24.76 +    f = open(name, "r");
   24.77 +    input += f.read();
   24.78 +    f.close();
   24.79 +
   24.80 +# add header
   24.81 +output += """
   24.82 +/*
   24.83 + * public xen defines and struct for %s
   24.84 + * generated by %s -- DO NOT EDIT
   24.85 + */
   24.86 +
   24.87 +#ifndef %s
   24.88 +#define %s 1
   24.89 +
   24.90 +""" % (arch, sys.argv[0], fileid, fileid)
   24.91 +
   24.92 +if arch in header:
   24.93 +    output += header[arch];
   24.94 +    output += "\n";
   24.95 +
   24.96 +# add defines to output
   24.97 +for line in re.findall("#define[^\n]+", input):
   24.98 +    for define in defines:
   24.99 +        regex = "#define\s+%s\\b" % define;
  24.100 +        match = re.search(regex, line);
  24.101 +        if None == match:
  24.102 +            continue;
  24.103 +        if define.upper()[0] == define[0]:
  24.104 +            replace = define + "_" + arch.upper();
  24.105 +        else:
  24.106 +            replace = define + "_" + arch;
  24.107 +        regex = "\\b%s\\b" % define;
  24.108 +        output += re.sub(regex, replace, line) + "\n";
  24.109 +output += "\n";
  24.110 +
  24.111 +# delete defines, comments, empty lines
  24.112 +input = re.sub("#define[^\n]+\n", "", input);
  24.113 +input = re.compile("/\*(.*?)\*/", re.S).sub("", input)
  24.114 +input = re.compile("\n\s*\n", re.S).sub("\n", input);
  24.115 +
  24.116 +# add structs to output
  24.117 +for struct in structs:
  24.118 +    regex = "struct\s+%s\s*\{(.*?)\n\};" % struct;
  24.119 +    match = re.search(regex, input, re.S)
  24.120 +    if None == match:
  24.121 +        output += "#define %s_has_no_%s 1\n" % (arch, struct);
  24.122 +    else:
  24.123 +        output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1));
  24.124 +        output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct, arch);
  24.125 +    output += "\n";
  24.126 +
  24.127 +# add footer
  24.128 +if arch in footer:
  24.129 +    output += footer[arch];
  24.130 +    output += "\n";
  24.131 +output += "#endif /* %s */\n" % fileid;
  24.132 +
  24.133 +# replace: defines
  24.134 +for define in defines:
  24.135 +    if define.upper()[0] == define[0]:
  24.136 +        replace = define + "_" + arch.upper();
  24.137 +    else:
  24.138 +        replace = define + "_" + arch;
  24.139 +    output = re.sub("\\b%s\\b" % define, replace, output);
  24.140 +
  24.141 +# replace: structs + struct typedefs
  24.142 +for struct in structs:
  24.143 +    output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output);
  24.144 +    output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
  24.145 +
  24.146 +# replace: integer types
  24.147 +integers = inttypes[arch].keys();
  24.148 +integers.sort(lambda a, b: cmp(len(b),len(a)));
  24.149 +for type in integers:
  24.150 +    output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
  24.151 +
  24.152 +# print results
  24.153 +f = open(outfile, "w");
  24.154 +f.write(output);
  24.155 +f.close;
  24.156 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/common/include/public/foreign/reference.size	Wed Dec 19 09:23:32 2007 +1100
    25.3 @@ -0,0 +1,17 @@
    25.4 +
    25.5 +structs              |  x86_32  x86_64    ia64
    25.6 +
    25.7 +start_info           |    1104    1152    1152
    25.8 +trap_info            |       8      16       -
    25.9 +pt_fpreg             |       -       -      16
   25.10 +cpu_user_regs        |      68     200     496
   25.11 +xen_ia64_boot_param  |       -       -      96
   25.12 +ia64_tr_entry        |       -       -      32
   25.13 +vcpu_extra_regs      |       -       -     536
   25.14 +vcpu_guest_context   |    2800    5168    1056
   25.15 +arch_vcpu_info       |      24      16       0
   25.16 +vcpu_time_info       |      32      32      32
   25.17 +vcpu_info            |      64      64      48
   25.18 +arch_shared_info     |     268     280     272
   25.19 +shared_info          |    2584    3368    4384
   25.20 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/common/include/public/foreign/structs.py	Wed Dec 19 09:23:32 2007 +1100
    26.3 @@ -0,0 +1,54 @@
    26.4 +# configuration: what needs translation
    26.5 +
    26.6 +structs = [ "start_info",
    26.7 +            "trap_info",
    26.8 +            "pt_fpreg",
    26.9 +            "cpu_user_regs",
   26.10 +            "xen_ia64_boot_param",
   26.11 +            "ia64_tr_entry",
   26.12 +            "vcpu_extra_regs",
   26.13 +            "vcpu_guest_context",
   26.14 +            "arch_vcpu_info",
   26.15 +            "vcpu_time_info",
   26.16 +            "vcpu_info",
   26.17 +            "arch_shared_info",
   26.18 +            "shared_info" ];
   26.19 +
   26.20 +defines = [ "__i386__",
   26.21 +            "__x86_64__",
   26.22 +
   26.23 +            "FLAT_RING1_CS",
   26.24 +            "FLAT_RING1_DS",
   26.25 +            "FLAT_RING1_SS",
   26.26 +
   26.27 +            "FLAT_RING3_CS64",
   26.28 +            "FLAT_RING3_DS64",
   26.29 +            "FLAT_RING3_SS64",
   26.30 +            "FLAT_KERNEL_CS64",
   26.31 +            "FLAT_KERNEL_DS64",
   26.32 +            "FLAT_KERNEL_SS64",
   26.33 +
   26.34 +            "FLAT_KERNEL_CS",
   26.35 +            "FLAT_KERNEL_DS",
   26.36 +            "FLAT_KERNEL_SS",
   26.37 +
   26.38 +            # x86_{32,64}
   26.39 +            "_VGCF_i387_valid",
   26.40 +            "VGCF_i387_valid",
   26.41 +            "_VGCF_in_kernel",
   26.42 +            "VGCF_in_kernel",
   26.43 +            "_VGCF_failsafe_disables_events",
   26.44 +            "VGCF_failsafe_disables_events",
   26.45 +            "_VGCF_syscall_disables_events",
   26.46 +            "VGCF_syscall_disables_events",
   26.47 +            "_VGCF_online",
   26.48 +            "VGCF_online",
   26.49 +
   26.50 +            # ia64
   26.51 +            "VGCF_EXTRA_REGS",
   26.52 +
   26.53 +            # all archs
   26.54 +            "xen_pfn_to_cr3",
   26.55 +            "MAX_VIRT_CPUS",
   26.56 +            "MAX_GUEST_CMDLINE" ];
   26.57 +
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/common/include/public/grant_table.h	Wed Dec 19 09:23:32 2007 +1100
    27.3 @@ -0,0 +1,399 @@
    27.4 +/******************************************************************************
    27.5 + * grant_table.h
    27.6 + * 
    27.7 + * Interface for granting foreign access to page frames, and receiving
    27.8 + * page-ownership transfers.
    27.9 + * 
   27.10 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   27.11 + * of this software and associated documentation files (the "Software"), to
   27.12 + * deal in the Software without restriction, including without limitation the
   27.13 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   27.14 + * sell copies of the Software, and to permit persons to whom the Software is
   27.15 + * furnished to do so, subject to the following conditions:
   27.16 + *
   27.17 + * The above copyright notice and this permission notice shall be included in
   27.18 + * all copies or substantial portions of the Software.
   27.19 + *
   27.20 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   27.21 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   27.22 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   27.23 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   27.24 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   27.25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   27.26 + * DEALINGS IN THE SOFTWARE.
   27.27 + *
   27.28 + * Copyright (c) 2004, K A Fraser
   27.29 + */
   27.30 +
   27.31 +#ifndef __XEN_PUBLIC_GRANT_TABLE_H__
   27.32 +#define __XEN_PUBLIC_GRANT_TABLE_H__
   27.33 +
   27.34 +
   27.35 +/***********************************
   27.36 + * GRANT TABLE REPRESENTATION
   27.37 + */
   27.38 +
   27.39 +/* Some rough guidelines on accessing and updating grant-table entries
   27.40 + * in a concurrency-safe manner. For more information, Linux contains a
   27.41 + * reference implementation for guest OSes (arch/xen/kernel/grant_table.c).
   27.42 + * 
   27.43 + * NB. WMB is a no-op on current-generation x86 processors. However, a
   27.44 + *     compiler barrier will still be required.
   27.45 + * 
   27.46 + * Introducing a valid entry into the grant table:
   27.47 + *  1. Write ent->domid.
   27.48 + *  2. Write ent->frame:
   27.49 + *      GTF_permit_access:   Frame to which access is permitted.
   27.50 + *      GTF_accept_transfer: Pseudo-phys frame slot being filled by new
   27.51 + *                           frame, or zero if none.
   27.52 + *  3. Write memory barrier (WMB).
   27.53 + *  4. Write ent->flags, inc. valid type.
   27.54 + * 
   27.55 + * Invalidating an unused GTF_permit_access entry:
   27.56 + *  1. flags = ent->flags.
   27.57 + *  2. Observe that !(flags & (GTF_reading|GTF_writing)).
   27.58 + *  3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
   27.59 + *  NB. No need for WMB as reuse of entry is control-dependent on success of
   27.60 + *      step 3, and all architectures guarantee ordering of ctrl-dep writes.
   27.61 + *
   27.62 + * Invalidating an in-use GTF_permit_access entry:
   27.63 + *  This cannot be done directly. Request assistance from the domain controller
   27.64 + *  which can set a timeout on the use of a grant entry and take necessary
   27.65 + *  action. (NB. This is not yet implemented!).
   27.66 + * 
   27.67 + * Invalidating an unused GTF_accept_transfer entry:
   27.68 + *  1. flags = ent->flags.
   27.69 + *  2. Observe that !(flags & GTF_transfer_committed). [*]
   27.70 + *  3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
   27.71 + *  NB. No need for WMB as reuse of entry is control-dependent on success of
   27.72 + *      step 3, and all architectures guarantee ordering of ctrl-dep writes.
   27.73 + *  [*] If GTF_transfer_committed is set then the grant entry is 'committed'.
   27.74 + *      The guest must /not/ modify the grant entry until the address of the
   27.75 + *      transferred frame is written. It is safe for the guest to spin waiting
   27.76 + *      for this to occur (detect by observing GTF_transfer_completed in
   27.77 + *      ent->flags).
   27.78 + *
   27.79 + * Invalidating a committed GTF_accept_transfer entry:
   27.80 + *  1. Wait for (ent->flags & GTF_transfer_completed).
   27.81 + *
   27.82 + * Changing a GTF_permit_access from writable to read-only:
   27.83 + *  Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing.
   27.84 + * 
   27.85 + * Changing a GTF_permit_access from read-only to writable:
   27.86 + *  Use SMP-safe bit-setting instruction.
   27.87 + */
   27.88 +
   27.89 +/*
   27.90 + * A grant table comprises a packed array of grant entries in one or more
   27.91 + * page frames shared between Xen and a guest.
   27.92 + * [XEN]: This field is written by Xen and read by the sharing guest.
   27.93 + * [GST]: This field is written by the guest and read by Xen.
   27.94 + */
   27.95 +struct grant_entry {
   27.96 +    /* GTF_xxx: various type and flag information.  [XEN,GST] */
   27.97 +    uint16_t flags;
   27.98 +    /* The domain being granted foreign privileges. [GST] */
   27.99 +    domid_t  domid;
  27.100 +    /*
  27.101 +     * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
  27.102 +     * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
  27.103 +     */
  27.104 +    uint32_t frame;
  27.105 +};
  27.106 +typedef struct grant_entry grant_entry_t;
  27.107 +
  27.108 +/*
  27.109 + * Type of grant entry.
  27.110 + *  GTF_invalid: This grant entry grants no privileges.
  27.111 + *  GTF_permit_access: Allow @domid to map/access @frame.
  27.112 + *  GTF_accept_transfer: Allow @domid to transfer ownership of one page frame
  27.113 + *                       to this guest. Xen writes the page number to @frame.
  27.114 + */
  27.115 +#define GTF_invalid         (0U<<0)
  27.116 +#define GTF_permit_access   (1U<<0)
  27.117 +#define GTF_accept_transfer (2U<<0)
  27.118 +#define GTF_type_mask       (3U<<0)
  27.119 +
  27.120 +/*
  27.121 + * Subflags for GTF_permit_access.
  27.122 + *  GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
  27.123 + *  GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
  27.124 + *  GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
  27.125 + */
  27.126 +#define _GTF_readonly       (2)
  27.127 +#define GTF_readonly        (1U<<_GTF_readonly)
  27.128 +#define _GTF_reading        (3)
  27.129 +#define GTF_reading         (1U<<_GTF_reading)
  27.130 +#define _GTF_writing        (4)
  27.131 +#define GTF_writing         (1U<<_GTF_writing)
  27.132 +
  27.133 +/*
  27.134 + * Subflags for GTF_accept_transfer:
  27.135 + *  GTF_transfer_committed: Xen sets this flag to indicate that it is committed
  27.136 + *      to transferring ownership of a page frame. When a guest sees this flag
  27.137 + *      it must /not/ modify the grant entry until GTF_transfer_completed is
  27.138 + *      set by Xen.
  27.139 + *  GTF_transfer_completed: It is safe for the guest to spin-wait on this flag
  27.140 + *      after reading GTF_transfer_committed. Xen will always write the frame
  27.141 + *      address, followed by ORing this flag, in a timely manner.
  27.142 + */
  27.143 +#define _GTF_transfer_committed (2)
  27.144 +#define GTF_transfer_committed  (1U<<_GTF_transfer_committed)
  27.145 +#define _GTF_transfer_completed (3)
  27.146 +#define GTF_transfer_completed  (1U<<_GTF_transfer_completed)
  27.147 +
  27.148 +
  27.149 +/***********************************
  27.150 + * GRANT TABLE QUERIES AND USES
  27.151 + */
  27.152 +
  27.153 +/*
  27.154 + * Reference to a grant entry in a specified domain's grant table.
  27.155 + */
  27.156 +typedef uint32_t grant_ref_t;
  27.157 +
  27.158 +/*
  27.159 + * Handle to track a mapping created via a grant reference.
  27.160 + */
  27.161 +typedef uint32_t grant_handle_t;
  27.162 +
  27.163 +/*
  27.164 + * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
  27.165 + * by devices and/or host CPUs. If successful, <handle> is a tracking number
  27.166 + * that must be presented later to destroy the mapping(s). On error, <handle>
  27.167 + * is a negative status code.
  27.168 + * NOTES:
  27.169 + *  1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address
  27.170 + *     via which I/O devices may access the granted frame.
  27.171 + *  2. If GNTMAP_host_map is specified then a mapping will be added at
  27.172 + *     either a host virtual address in the current address space, or at
  27.173 + *     a PTE at the specified machine address.  The type of mapping to
  27.174 + *     perform is selected through the GNTMAP_contains_pte flag, and the 
  27.175 + *     address is specified in <host_addr>.
  27.176 + *  3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a
  27.177 + *     host mapping is destroyed by other means then it is *NOT* guaranteed
  27.178 + *     to be accounted to the correct grant reference!
  27.179 + */
  27.180 +#define GNTTABOP_map_grant_ref        0
  27.181 +struct gnttab_map_grant_ref {
  27.182 +    /* IN parameters. */
  27.183 +    uint64_t host_addr;
  27.184 +    uint32_t flags;               /* GNTMAP_* */
  27.185 +    grant_ref_t ref;
  27.186 +    domid_t  dom;
  27.187 +    /* OUT parameters. */
  27.188 +    int16_t  status;              /* GNTST_* */
  27.189 +    grant_handle_t handle;
  27.190 +    uint64_t dev_bus_addr;
  27.191 +};
  27.192 +typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t;
  27.193 +DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
  27.194 +
  27.195 +/*
  27.196 + * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
  27.197 + * tracked by <handle>. If <host_addr> or <dev_bus_addr> is zero, that
  27.198 + * field is ignored. If non-zero, they must refer to a device/host mapping
  27.199 + * that is tracked by <handle>
  27.200 + * NOTES:
  27.201 + *  1. The call may fail in an undefined manner if either mapping is not
  27.202 + *     tracked by <handle>.
  27.203 + *  3. After executing a batch of unmaps, it is guaranteed that no stale
  27.204 + *     mappings will remain in the device or host TLBs.
  27.205 + */
  27.206 +#define GNTTABOP_unmap_grant_ref      1
  27.207 +struct gnttab_unmap_grant_ref {
  27.208 +    /* IN parameters. */
  27.209 +    uint64_t host_addr;
  27.210 +    uint64_t dev_bus_addr;
  27.211 +    grant_handle_t handle;
  27.212 +    /* OUT parameters. */
  27.213 +    int16_t  status;              /* GNTST_* */
  27.214 +};
  27.215 +typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
  27.216 +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
  27.217 +
  27.218 +/*
  27.219 + * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
  27.220 + * <nr_frames> pages. The frame addresses are written to the <frame_list>.
  27.221 + * Only <nr_frames> addresses are written, even if the table is larger.
  27.222 + * NOTES:
  27.223 + *  1. <dom> may be specified as DOMID_SELF.
  27.224 + *  2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
  27.225 + *  3. Xen may not support more than a single grant-table page per domain.
  27.226 + */
  27.227 +#define GNTTABOP_setup_table          2
  27.228 +struct gnttab_setup_table {
  27.229 +    /* IN parameters. */
  27.230 +    domid_t  dom;
  27.231 +    uint32_t nr_frames;
  27.232 +    /* OUT parameters. */
  27.233 +    int16_t  status;              /* GNTST_* */
  27.234 +    XEN_GUEST_HANDLE(ulong) frame_list;
  27.235 +};
  27.236 +typedef struct gnttab_setup_table gnttab_setup_table_t;
  27.237 +DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
  27.238 +
  27.239 +/*
  27.240 + * GNTTABOP_dump_table: Dump the contents of the grant table to the
  27.241 + * xen console. Debugging use only.
  27.242 + */
  27.243 +#define GNTTABOP_dump_table           3
  27.244 +struct gnttab_dump_table {
  27.245 +    /* IN parameters. */
  27.246 +    domid_t dom;
  27.247 +    /* OUT parameters. */
  27.248 +    int16_t status;               /* GNTST_* */
  27.249 +};
  27.250 +typedef struct gnttab_dump_table gnttab_dump_table_t;
  27.251 +DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
  27.252 +
  27.253 +/*
  27.254 + * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
  27.255 + * foreign domain has previously registered its interest in the transfer via
  27.256 + * <domid, ref>.
  27.257 + * 
  27.258 + * Note that, even if the transfer fails, the specified page no longer belongs
  27.259 + * to the calling domain *unless* the error is GNTST_bad_page.
  27.260 + */
  27.261 +#define GNTTABOP_transfer                4
  27.262 +struct gnttab_transfer {
  27.263 +    /* IN parameters. */
  27.264 +    xen_pfn_t     mfn;
  27.265 +    domid_t       domid;
  27.266 +    grant_ref_t   ref;
  27.267 +    /* OUT parameters. */
  27.268 +    int16_t       status;
  27.269 +};
  27.270 +typedef struct gnttab_transfer gnttab_transfer_t;
  27.271 +DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
  27.272 +
  27.273 +
  27.274 +/*
  27.275 + * GNTTABOP_copy: Hypervisor based copy
  27.276 + * source and destinations can be eithers MFNs or, for foreign domains,
  27.277 + * grant references. the foreign domain has to grant read/write access
  27.278 + * in its grant table.
  27.279 + *
  27.280 + * The flags specify what type source and destinations are (either MFN
  27.281 + * or grant reference).
  27.282 + *
  27.283 + * Note that this can also be used to copy data between two domains
  27.284 + * via a third party if the source and destination domains had previously
  27.285 + * grant appropriate access to their pages to the third party.
  27.286 + *
  27.287 + * source_offset specifies an offset in the source frame, dest_offset
  27.288 + * the offset in the target frame and  len specifies the number of
  27.289 + * bytes to be copied.
  27.290 + */
  27.291 +
  27.292 +#define _GNTCOPY_source_gref      (0)
  27.293 +#define GNTCOPY_source_gref       (1<<_GNTCOPY_source_gref)
  27.294 +#define _GNTCOPY_dest_gref        (1)
  27.295 +#define GNTCOPY_dest_gref         (1<<_GNTCOPY_dest_gref)
  27.296 +
  27.297 +#define GNTTABOP_copy                 5
  27.298 +typedef struct gnttab_copy {
  27.299 +    /* IN parameters. */
  27.300 +    struct {
  27.301 +        union {
  27.302 +            grant_ref_t ref;
  27.303 +            xen_pfn_t   gmfn;
  27.304 +        } u;
  27.305 +        domid_t  domid;
  27.306 +        uint16_t offset;
  27.307 +    } source, dest;
  27.308 +    uint16_t      len;
  27.309 +    uint16_t      flags;          /* GNTCOPY_* */
  27.310 +    /* OUT parameters. */
  27.311 +    int16_t       status;
  27.312 +} gnttab_copy_t;
  27.313 +DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t);
  27.314 +
  27.315 +/*
  27.316 + * GNTTABOP_query_size: Query the current and maximum sizes of the shared
  27.317 + * grant table.
  27.318 + * NOTES:
  27.319 + *  1. <dom> may be specified as DOMID_SELF.
  27.320 + *  2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
  27.321 + */
  27.322 +#define GNTTABOP_query_size           6
  27.323 +struct gnttab_query_size {
  27.324 +    /* IN parameters. */
  27.325 +    domid_t  dom;
  27.326 +    /* OUT parameters. */
  27.327 +    uint32_t nr_frames;
  27.328 +    uint32_t max_nr_frames;
  27.329 +    int16_t  status;              /* GNTST_* */
  27.330 +};
  27.331 +typedef struct gnttab_query_size gnttab_query_size_t;
  27.332 +DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t);
  27.333 +
  27.334 +
  27.335 +/*
  27.336 + * Bitfield values for update_pin_status.flags.
  27.337 + */
  27.338 + /* Map the grant entry for access by I/O devices. */
  27.339 +#define _GNTMAP_device_map      (0)
  27.340 +#define GNTMAP_device_map       (1<<_GNTMAP_device_map)
  27.341 + /* Map the grant entry for access by host CPUs. */
  27.342 +#define _GNTMAP_host_map        (1)
  27.343 +#define GNTMAP_host_map         (1<<_GNTMAP_host_map)
  27.344 + /* Accesses to the granted frame will be restricted to read-only access. */
  27.345 +#define _GNTMAP_readonly        (2)
  27.346 +#define GNTMAP_readonly         (1<<_GNTMAP_readonly)
  27.347 + /*
  27.348 +  * GNTMAP_host_map subflag:
  27.349 +  *  0 => The host mapping is usable only by the guest OS.
  27.350 +  *  1 => The host mapping is usable by guest OS + current application.
  27.351 +  */
  27.352 +#define _GNTMAP_application_map (3)
  27.353 +#define GNTMAP_application_map  (1<<_GNTMAP_application_map)
  27.354 +
  27.355 + /*
  27.356 +  * GNTMAP_contains_pte subflag:
  27.357 +  *  0 => This map request contains a host virtual address.
  27.358 +  *  1 => This map request contains the machine addess of the PTE to update.
  27.359 +  */
  27.360 +#define _GNTMAP_contains_pte    (4)
  27.361 +#define GNTMAP_contains_pte     (1<<_GNTMAP_contains_pte)
  27.362 +
  27.363 +/*
  27.364 + * Values for error status returns. All errors are -ve.
  27.365 + */
  27.366 +#define GNTST_okay             (0)  /* Normal return.                        */
  27.367 +#define GNTST_general_error    (-1) /* General undefined error.              */
  27.368 +#define GNTST_bad_domain       (-2) /* Unrecognsed domain id.                */
  27.369 +#define GNTST_bad_gntref       (-3) /* Unrecognised or inappropriate gntref. */
  27.370 +#define GNTST_bad_handle       (-4) /* Unrecognised or inappropriate handle. */
  27.371 +#define GNTST_bad_virt_addr    (-5) /* Inappropriate virtual address to map. */
  27.372 +#define GNTST_bad_dev_addr     (-6) /* Inappropriate device address to unmap.*/
  27.373 +#define GNTST_no_device_space  (-7) /* Out of space in I/O MMU.              */
  27.374 +#define GNTST_permission_denied (-8) /* Not enough privilege for operation.  */
  27.375 +#define GNTST_bad_page         (-9) /* Specified page was invalid for op.    */
  27.376 +#define GNTST_bad_copy_arg    (-10) /* copy arguments cross page boundary */
  27.377 +
  27.378 +#define GNTTABOP_error_msgs {                   \
  27.379 +    "okay",                                     \
  27.380 +    "undefined error",                          \
  27.381 +    "unrecognised domain id",                   \
  27.382 +    "invalid grant reference",                  \
  27.383 +    "invalid mapping handle",                   \
  27.384 +    "invalid virtual address",                  \
  27.385 +    "invalid device address",                   \
  27.386 +    "no spare translation slot in the I/O MMU", \
  27.387 +    "permission denied",                        \
  27.388 +    "bad page",                                 \
  27.389 +    "copy arguments cross page boundary"        \
  27.390 +}
  27.391 +
  27.392 +#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */
  27.393 +
  27.394 +/*
  27.395 + * Local variables:
  27.396 + * mode: C
  27.397 + * c-set-style: "BSD"
  27.398 + * c-basic-offset: 4
  27.399 + * tab-width: 4
  27.400 + * indent-tabs-mode: nil
  27.401 + * End:
  27.402 + */
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/common/include/public/hvm/e820.h	Wed Dec 19 09:23:32 2007 +1100
    28.3 @@ -0,0 +1,34 @@
    28.4 +
    28.5 +/*
    28.6 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    28.7 + * of this software and associated documentation files (the "Software"), to
    28.8 + * deal in the Software without restriction, including without limitation the
    28.9 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   28.10 + * sell copies of the Software, and to permit persons to whom the Software is
   28.11 + * furnished to do so, subject to the following conditions:
   28.12 + *
   28.13 + * The above copyright notice and this permission notice shall be included in
   28.14 + * all copies or substantial portions of the Software.
   28.15 + *
   28.16 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   28.17 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   28.18 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   28.19 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   28.20 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   28.21 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   28.22 + * DEALINGS IN THE SOFTWARE.
   28.23 + */
   28.24 +
   28.25 +#ifndef __XEN_PUBLIC_HVM_E820_H__
   28.26 +#define __XEN_PUBLIC_HVM_E820_H__
   28.27 +
   28.28 +/* E820 location in HVM virtual address space. */
   28.29 +#define HVM_E820_PAGE        0x00090000
   28.30 +#define HVM_E820_NR_OFFSET   0x000001E8
   28.31 +#define HVM_E820_OFFSET      0x000002D0
   28.32 +
   28.33 +#define HVM_BELOW_4G_RAM_END        0xF0000000
   28.34 +#define HVM_BELOW_4G_MMIO_START     HVM_BELOW_4G_RAM_END
   28.35 +#define HVM_BELOW_4G_MMIO_LENGTH    ((1ULL << 32) - HVM_BELOW_4G_MMIO_START)
   28.36 +
   28.37 +#endif /* __XEN_PUBLIC_HVM_E820_H__ */
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/common/include/public/hvm/hvm_info_table.h	Wed Dec 19 09:23:32 2007 +1100
    29.3 @@ -0,0 +1,41 @@
    29.4 +/******************************************************************************
    29.5 + * hvm/hvm_info_table.h
    29.6 + * 
    29.7 + * HVM parameter and information table, written into guest memory map.
    29.8 + *
    29.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   29.10 + * of this software and associated documentation files (the "Software"), to
   29.11 + * deal in the Software without restriction, including without limitation the
   29.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   29.13 + * sell copies of the Software, and to permit persons to whom the Software is
   29.14 + * furnished to do so, subject to the following conditions:
   29.15 + *
   29.16 + * The above copyright notice and this permission notice shall be included in
   29.17 + * all copies or substantial portions of the Software.
   29.18 + *
   29.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   29.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   29.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   29.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   29.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   29.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   29.25 + * DEALINGS IN THE SOFTWARE.
   29.26 + */
   29.27 +
   29.28 +#ifndef __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__
   29.29 +#define __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__
   29.30 +
   29.31 +#define HVM_INFO_PFN         0x09F
   29.32 +#define HVM_INFO_OFFSET      0x800
   29.33 +#define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
   29.34 +
   29.35 +struct hvm_info_table {
   29.36 +    char        signature[8]; /* "HVM INFO" */
   29.37 +    uint32_t    length;
   29.38 +    uint8_t     checksum;
   29.39 +    uint8_t     acpi_enabled;
   29.40 +    uint8_t     apic_mode;
   29.41 +    uint32_t    nr_vcpus;
   29.42 +};
   29.43 +
   29.44 +#endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/common/include/public/hvm/hvm_op.h	Wed Dec 19 09:23:32 2007 +1100
    30.3 @@ -0,0 +1,76 @@
    30.4 +/*
    30.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    30.6 + * of this software and associated documentation files (the "Software"), to
    30.7 + * deal in the Software without restriction, including without limitation the
    30.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    30.9 + * sell copies of the Software, and to permit persons to whom the Software is
   30.10 + * furnished to do so, subject to the following conditions:
   30.11 + *
   30.12 + * The above copyright notice and this permission notice shall be included in
   30.13 + * all copies or substantial portions of the Software.
   30.14 + *
   30.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   30.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   30.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   30.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   30.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   30.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   30.21 + * DEALINGS IN THE SOFTWARE.
   30.22 + */
   30.23 +
   30.24 +#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
   30.25 +#define __XEN_PUBLIC_HVM_HVM_OP_H__
   30.26 +
   30.27 +/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
   30.28 +#define HVMOP_set_param           0
   30.29 +#define HVMOP_get_param           1
   30.30 +struct xen_hvm_param {
   30.31 +    domid_t  domid;    /* IN */
   30.32 +    uint32_t index;    /* IN */
   30.33 +    uint64_t value;    /* IN/OUT */
   30.34 +};
   30.35 +typedef struct xen_hvm_param xen_hvm_param_t;
   30.36 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
   30.37 +
   30.38 +/* Set the logical level of one of a domain's PCI INTx wires. */
   30.39 +#define HVMOP_set_pci_intx_level  2
   30.40 +struct xen_hvm_set_pci_intx_level {
   30.41 +    /* Domain to be updated. */
   30.42 +    domid_t  domid;
   30.43 +    /* PCI INTx identification in PCI topology (domain:bus:device:intx). */
   30.44 +    uint8_t  domain, bus, device, intx;
   30.45 +    /* Assertion level (0 = unasserted, 1 = asserted). */
   30.46 +    uint8_t  level;
   30.47 +};
   30.48 +typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;
   30.49 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);
   30.50 +
   30.51 +/* Set the logical level of one of a domain's ISA IRQ wires. */
   30.52 +#define HVMOP_set_isa_irq_level   3
   30.53 +struct xen_hvm_set_isa_irq_level {
   30.54 +    /* Domain to be updated. */
   30.55 +    domid_t  domid;
   30.56 +    /* ISA device identification, by ISA IRQ (0-15). */
   30.57 +    uint8_t  isa_irq;
   30.58 +    /* Assertion level (0 = unasserted, 1 = asserted). */
   30.59 +    uint8_t  level;
   30.60 +};
   30.61 +typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;
   30.62 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);
   30.63 +
   30.64 +#define HVMOP_set_pci_link_route  4
   30.65 +struct xen_hvm_set_pci_link_route {
   30.66 +    /* Domain to be updated. */
   30.67 +    domid_t  domid;
   30.68 +    /* PCI link identifier (0-3). */
   30.69 +    uint8_t  link;
   30.70 +    /* ISA IRQ (1-15), or 0 (disable link). */
   30.71 +    uint8_t  isa_irq;
   30.72 +};
   30.73 +typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;
   30.74 +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
   30.75 +
   30.76 +/* Flushes all VCPU TLBs: @arg must be NULL. */
   30.77 +#define HVMOP_flush_tlbs          5
   30.78 +
   30.79 +#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/common/include/public/hvm/ioreq.h	Wed Dec 19 09:23:32 2007 +1100
    31.3 @@ -0,0 +1,122 @@
    31.4 +/*
    31.5 + * ioreq.h: I/O request definitions for device models
    31.6 + * Copyright (c) 2004, Intel Corporation.
    31.7 + * 
    31.8 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    31.9 + * of this software and associated documentation files (the "Software"), to
   31.10 + * deal in the Software without restriction, including without limitation the
   31.11 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   31.12 + * sell copies of the Software, and to permit persons to whom the Software is
   31.13 + * furnished to do so, subject to the following conditions:
   31.14 + *
   31.15 + * The above copyright notice and this permission notice shall be included in
   31.16 + * all copies or substantial portions of the Software.
   31.17 + *
   31.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   31.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   31.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   31.21 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   31.22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   31.23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   31.24 + * DEALINGS IN THE SOFTWARE.
   31.25 + */
   31.26 +
   31.27 +#ifndef _IOREQ_H_
   31.28 +#define _IOREQ_H_
   31.29 +
   31.30 +#define IOREQ_READ      1
   31.31 +#define IOREQ_WRITE     0
   31.32 +
   31.33 +#define STATE_IOREQ_NONE        0
   31.34 +#define STATE_IOREQ_READY       1
   31.35 +#define STATE_IOREQ_INPROCESS   2
   31.36 +#define STATE_IORESP_READY      3
   31.37 +
   31.38 +#define IOREQ_TYPE_PIO          0 /* pio */
   31.39 +#define IOREQ_TYPE_COPY         1 /* mmio ops */
   31.40 +#define IOREQ_TYPE_AND          2
   31.41 +#define IOREQ_TYPE_OR           3
   31.42 +#define IOREQ_TYPE_XOR          4
   31.43 +#define IOREQ_TYPE_XCHG         5
   31.44 +#define IOREQ_TYPE_ADD          6
   31.45 +#define IOREQ_TYPE_TIMEOFFSET   7
   31.46 +#define IOREQ_TYPE_INVALIDATE   8 /* mapcache */
   31.47 +#define IOREQ_TYPE_SUB          9
   31.48 +
   31.49 +/*
   31.50 + * VMExit dispatcher should cooperate with instruction decoder to
   31.51 + * prepare this structure and notify service OS and DM by sending
   31.52 + * virq
   31.53 + */
   31.54 +struct ioreq {
   31.55 +    uint64_t addr;          /*  physical address            */
   31.56 +    uint64_t size;          /*  size in bytes               */
   31.57 +    uint64_t count;         /*  for rep prefixes            */
   31.58 +    uint64_t data;          /*  data (or paddr of data)     */
   31.59 +    uint8_t state:4;
   31.60 +    uint8_t data_is_ptr:1;  /*  if 1, data above is the guest paddr 
   31.61 +                             *   of the real data to use.   */
   31.62 +    uint8_t dir:1;          /*  1=read, 0=write             */
   31.63 +    uint8_t df:1;
   31.64 +    uint8_t type;           /* I/O type                     */
   31.65 +    uint8_t _pad0[6];
   31.66 +    uint64_t io_count;      /* How many IO done on a vcpu   */
   31.67 +};
   31.68 +typedef struct ioreq ioreq_t;
   31.69 +
   31.70 +struct vcpu_iodata {
   31.71 +    struct ioreq vp_ioreq;
   31.72 +    /* Event channel port, used for notifications to/from the device model. */
   31.73 +    uint32_t vp_eport;
   31.74 +    uint32_t _pad0;
   31.75 +};
   31.76 +typedef struct vcpu_iodata vcpu_iodata_t;
   31.77 +
   31.78 +struct shared_iopage {
   31.79 +    struct vcpu_iodata   vcpu_iodata[1];
   31.80 +};
   31.81 +typedef struct shared_iopage shared_iopage_t;
   31.82 +
   31.83 +#define IOREQ_BUFFER_SLOT_NUM     80
   31.84 +struct buffered_iopage {
   31.85 +    unsigned int    read_pointer;
   31.86 +    unsigned int    write_pointer;
   31.87 +    ioreq_t         ioreq[IOREQ_BUFFER_SLOT_NUM];
   31.88 +}; /* NB. Size of this structure must be no greater than one page. */
   31.89 +typedef struct buffered_iopage buffered_iopage_t;
   31.90 +
   31.91 +#if defined(__ia64__)
   31.92 +struct pio_buffer {
   31.93 +    uint32_t page_offset;
   31.94 +    uint32_t pointer;
   31.95 +    uint32_t data_end;
   31.96 +    uint32_t buf_size;
   31.97 +    void *opaque;
   31.98 +};
   31.99 +
  31.100 +#define PIO_BUFFER_IDE_PRIMARY   0 /* I/O port = 0x1F0 */
  31.101 +#define PIO_BUFFER_IDE_SECONDARY 1 /* I/O port = 0x170 */
  31.102 +#define PIO_BUFFER_ENTRY_NUM     2
  31.103 +struct buffered_piopage {
  31.104 +    struct pio_buffer pio[PIO_BUFFER_ENTRY_NUM];
  31.105 +    uint8_t buffer[1];
  31.106 +};
  31.107 +#endif /* defined(__ia64__) */
  31.108 +
  31.109 +#if defined(__i386__) || defined(__x86_64__)
  31.110 +#define ACPI_PM1A_EVT_BLK_ADDRESS           0x0000000000001f40
  31.111 +#define ACPI_PM1A_CNT_BLK_ADDRESS           (ACPI_PM1A_EVT_BLK_ADDRESS + 0x04)
  31.112 +#define ACPI_PM_TMR_BLK_ADDRESS             (ACPI_PM1A_EVT_BLK_ADDRESS + 0x08)
  31.113 +#endif /* defined(__i386__) || defined(__x86_64__) */
  31.114 +
  31.115 +#endif /* _IOREQ_H_ */
  31.116 +
  31.117 +/*
  31.118 + * Local variables:
  31.119 + * mode: C
  31.120 + * c-set-style: "BSD"
  31.121 + * c-basic-offset: 4
  31.122 + * tab-width: 4
  31.123 + * indent-tabs-mode: nil
  31.124 + * End:
  31.125 + */
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/common/include/public/hvm/params.h	Wed Dec 19 09:23:32 2007 +1100
    32.3 @@ -0,0 +1,60 @@
    32.4 +/*
    32.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    32.6 + * of this software and associated documentation files (the "Software"), to
    32.7 + * deal in the Software without restriction, including without limitation the
    32.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    32.9 + * sell copies of the Software, and to permit persons to whom the Software is
   32.10 + * furnished to do so, subject to the following conditions:
   32.11 + *
   32.12 + * The above copyright notice and this permission notice shall be included in
   32.13 + * all copies or substantial portions of the Software.
   32.14 + *
   32.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   32.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   32.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   32.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   32.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   32.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   32.21 + * DEALINGS IN THE SOFTWARE.
   32.22 + */
   32.23 +
   32.24 +#ifndef __XEN_PUBLIC_HVM_PARAMS_H__
   32.25 +#define __XEN_PUBLIC_HVM_PARAMS_H__
   32.26 +
   32.27 +#include "hvm_op.h"
   32.28 +
   32.29 +/*
   32.30 + * Parameter space for HVMOP_{set,get}_param.
   32.31 + */
   32.32 +
   32.33 +/*
   32.34 + * How should CPU0 event-channel notifications be delivered?
   32.35 + * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
   32.36 + * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
   32.37 + *                  Domain = val[47:32], Bus  = val[31:16],
   32.38 + *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
   32.39 + * If val == 0 then CPU0 event-channel notifications are not delivered.
   32.40 + */
   32.41 +#define HVM_PARAM_CALLBACK_IRQ 0
   32.42 +
   32.43 +/*
   32.44 + * These are not used by Xen. They are here for convenience of HVM-guest
   32.45 + * xenbus implementations.
   32.46 + */
   32.47 +#define HVM_PARAM_STORE_PFN    1
   32.48 +#define HVM_PARAM_STORE_EVTCHN 2
   32.49 +
   32.50 +#define HVM_PARAM_PAE_ENABLED  4
   32.51 +
   32.52 +#define HVM_PARAM_IOREQ_PFN    5
   32.53 +
   32.54 +#define HVM_PARAM_BUFIOREQ_PFN 6
   32.55 +
   32.56 +#ifdef __ia64__
   32.57 +#define HVM_PARAM_NVRAM_FD     7
   32.58 +#define HVM_NR_PARAMS          8
   32.59 +#else
   32.60 +#define HVM_NR_PARAMS          7
   32.61 +#endif
   32.62 +
   32.63 +#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/common/include/public/hvm/save.h	Wed Dec 19 09:23:32 2007 +1100
    33.3 @@ -0,0 +1,462 @@
    33.4 +/* 
    33.5 + * hvm/save.h
    33.6 + *
    33.7 + * Structure definitions for HVM state that is held by Xen and must
    33.8 + * be saved along with the domain's memory and device-model state.
    33.9 + *
   33.10 + * 
   33.11 + * Copyright (c) 2007 XenSource Ltd.
   33.12 + *
   33.13 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   33.14 + * of this software and associated documentation files (the "Software"), to
   33.15 + * deal in the Software without restriction, including without limitation the
   33.16 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   33.17 + * sell copies of the Software, and to permit persons to whom the Software is
   33.18 + * furnished to do so, subject to the following conditions:
   33.19 + *
   33.20 + * The above copyright notice and this permission notice shall be included in
   33.21 + * all copies or substantial portions of the Software.
   33.22 + *
   33.23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   33.24 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   33.25 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   33.26 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   33.27 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   33.28 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   33.29 + * DEALINGS IN THE SOFTWARE.
   33.30 + */
   33.31 +
   33.32 +#ifndef __XEN_PUBLIC_HVM_SAVE_H__
   33.33 +#define __XEN_PUBLIC_HVM_SAVE_H__
   33.34 +
   33.35 +/*
   33.36 + * Structures in this header *must* have the same layout in 32bit 
   33.37 + * and 64bit environments: this means that all fields must be explicitly 
   33.38 + * sized types and aligned to their sizes, and the structs must be 
   33.39 + * a multiple of eight bytes long.
   33.40 + *
   33.41 + * Only the state necessary for saving and restoring (i.e. fields 
   33.42 + * that are analogous to actual hardware state) should go in this file. 
   33.43 + * Internal mechanisms should be kept in Xen-private headers.
   33.44 + */
   33.45 +
   33.46 +/* 
   33.47 + * Each entry is preceded by a descriptor giving its type and length
   33.48 + */
   33.49 +struct hvm_save_descriptor {
   33.50 +    uint16_t typecode;          /* Used to demux the various types below */
   33.51 +    uint16_t instance;          /* Further demux within a type */
   33.52 +    uint32_t length;            /* In bytes, *not* including this descriptor */
   33.53 +};
   33.54 +
   33.55 +
   33.56 +/* 
   33.57 + * Each entry has a datatype associated with it: for example, the CPU state 
   33.58 + * is saved as a HVM_SAVE_TYPE(CPU), which has HVM_SAVE_LENGTH(CPU), 
   33.59 + * and is identified by a descriptor with typecode HVM_SAVE_CODE(CPU).
   33.60 + * DECLARE_HVM_SAVE_TYPE binds these things together with some type-system
   33.61 + * ugliness.
   33.62 + */
   33.63 +
   33.64 +#define DECLARE_HVM_SAVE_TYPE(_x, _code, _type)                   \
   33.65 +  struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; }
   33.66 +
   33.67 +#define HVM_SAVE_TYPE(_x) typeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->t)
   33.68 +#define HVM_SAVE_LENGTH(_x) (sizeof (HVM_SAVE_TYPE(_x)))
   33.69 +#define HVM_SAVE_CODE(_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c))
   33.70 +
   33.71 +
   33.72 +/* 
   33.73 + * Save/restore header: general info about the save file. 
   33.74 + */
   33.75 +
   33.76 +#define HVM_FILE_MAGIC   0x54381286
   33.77 +#define HVM_FILE_VERSION 0x00000001
   33.78 +
   33.79 +struct hvm_save_header {
   33.80 +    uint32_t magic;             /* Must be HVM_FILE_MAGIC */
   33.81 +    uint32_t version;           /* File format version */
   33.82 +    uint64_t changeset;         /* Version of Xen that saved this file */
   33.83 +    uint32_t cpuid;             /* CPUID[0x01][%eax] on the saving machine */
   33.84 +    uint32_t pad0;
   33.85 +};
   33.86 +
   33.87 +DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);
   33.88 +
   33.89 +
   33.90 +/*
   33.91 + * Processor
   33.92 + */
   33.93 +
   33.94 +struct hvm_hw_cpu {
   33.95 +    uint8_t  fpu_regs[512];
   33.96 +
   33.97 +    uint64_t rax;
   33.98 +    uint64_t rbx;
   33.99 +    uint64_t rcx;
  33.100 +    uint64_t rdx;
  33.101 +    uint64_t rbp;
  33.102 +    uint64_t rsi;
  33.103 +    uint64_t rdi;
  33.104 +    uint64_t rsp;
  33.105 +    uint64_t r8;
  33.106 +    uint64_t r9;
  33.107 +    uint64_t r10;
  33.108 +    uint64_t r11;
  33.109 +    uint64_t r12;
  33.110 +    uint64_t r13;
  33.111 +    uint64_t r14;
  33.112 +    uint64_t r15;
  33.113 +
  33.114 +    uint64_t rip;
  33.115 +    uint64_t rflags;
  33.116 +
  33.117 +    uint64_t cr0;
  33.118 +    uint64_t cr2;
  33.119 +    uint64_t cr3;
  33.120 +    uint64_t cr4;
  33.121 +
  33.122 +    uint64_t dr0;
  33.123 +    uint64_t dr1;
  33.124 +    uint64_t dr2;
  33.125 +    uint64_t dr3;
  33.126 +    uint64_t dr6;
  33.127 +    uint64_t dr7;    
  33.128 +
  33.129 +    uint32_t cs_sel;
  33.130 +    uint32_t ds_sel;
  33.131 +    uint32_t es_sel;
  33.132 +    uint32_t fs_sel;
  33.133 +    uint32_t gs_sel;
  33.134 +    uint32_t ss_sel;
  33.135 +    uint32_t tr_sel;
  33.136 +    uint32_t ldtr_sel;
  33.137 +
  33.138 +    uint32_t cs_limit;
  33.139 +    uint32_t ds_limit;
  33.140 +    uint32_t es_limit;
  33.141 +    uint32_t fs_limit;
  33.142 +    uint32_t gs_limit;
  33.143 +    uint32_t ss_limit;
  33.144 +    uint32_t tr_limit;
  33.145 +    uint32_t ldtr_limit;
  33.146 +    uint32_t idtr_limit;
  33.147 +    uint32_t gdtr_limit;
  33.148 +
  33.149 +    uint64_t cs_base;
  33.150 +    uint64_t ds_base;
  33.151 +    uint64_t es_base;
  33.152 +    uint64_t fs_base;
  33.153 +    uint64_t gs_base;
  33.154 +    uint64_t ss_base;
  33.155 +    uint64_t tr_base;
  33.156 +    uint64_t ldtr_base;
  33.157 +    uint64_t idtr_base;
  33.158 +    uint64_t gdtr_base;
  33.159 +
  33.160 +    uint32_t cs_arbytes;
  33.161 +    uint32_t ds_arbytes;
  33.162 +    uint32_t es_arbytes;
  33.163 +    uint32_t fs_arbytes;
  33.164 +    uint32_t gs_arbytes;
  33.165 +    uint32_t ss_arbytes;
  33.166 +    uint32_t tr_arbytes;
  33.167 +    uint32_t ldtr_arbytes;
  33.168 +
  33.169 +    uint32_t sysenter_cs;
  33.170 +    uint32_t padding0;
  33.171 +
  33.172 +    uint64_t sysenter_esp;
  33.173 +    uint64_t sysenter_eip;
  33.174 +
  33.175 +    /* msr for em64t */
  33.176 +    uint64_t shadow_gs;
  33.177 +
  33.178 +    /* msr content saved/restored. */
  33.179 +    uint64_t msr_flags;
  33.180 +    uint64_t msr_lstar;
  33.181 +    uint64_t msr_star;
  33.182 +    uint64_t msr_cstar;
  33.183 +    uint64_t msr_syscall_mask;
  33.184 +    uint64_t msr_efer;
  33.185 +
  33.186 +    /* guest's idea of what rdtsc() would return */
  33.187 +    uint64_t tsc;
  33.188 +
  33.189 +    /* pending event, if any */
  33.190 +    union {
  33.191 +        uint32_t pending_event;
  33.192 +        struct {
  33.193 +            uint8_t  pending_vector:8;
  33.194 +            uint8_t  pending_type:3;
  33.195 +            uint8_t  pending_error_valid:1;
  33.196 +            uint32_t pending_reserved:19;
  33.197 +            uint8_t  pending_valid:1;
  33.198 +        };
  33.199 +    };
  33.200 +    /* error code for pending event */
  33.201 +    uint32_t error_code;
  33.202 +};
  33.203 +
  33.204 +DECLARE_HVM_SAVE_TYPE(CPU, 2, struct hvm_hw_cpu);
  33.205 +
  33.206 +
  33.207 +/*
  33.208 + * PIC
  33.209 + */
  33.210 +
  33.211 +struct hvm_hw_vpic {
  33.212 +    /* IR line bitmasks. */
  33.213 +    uint8_t irr;
  33.214 +    uint8_t imr;
  33.215 +    uint8_t isr;
  33.216 +
  33.217 +    /* Line IRx maps to IRQ irq_base+x */
  33.218 +    uint8_t irq_base;
  33.219 +
  33.220 +    /*
  33.221 +     * Where are we in ICW2-4 initialisation (0 means no init in progress)?
  33.222 +     * Bits 0-1 (=x): Next write at A=1 sets ICW(x+1).
  33.223 +     * Bit 2: ICW1.IC4  (1 == ICW4 included in init sequence)
  33.224 +     * Bit 3: ICW1.SNGL (0 == ICW3 included in init sequence)
  33.225 +     */
  33.226 +    uint8_t init_state:4;
  33.227 +
  33.228 +    /* IR line with highest priority. */
  33.229 +    uint8_t priority_add:4;
  33.230 +
  33.231 +    /* Reads from A=0 obtain ISR or IRR? */
  33.232 +    uint8_t readsel_isr:1;
  33.233 +
  33.234 +    /* Reads perform a polling read? */
  33.235 +    uint8_t poll:1;
  33.236 +
  33.237 +    /* Automatically clear IRQs from the ISR during INTA? */
  33.238 +    uint8_t auto_eoi:1;
  33.239 +
  33.240 +    /* Automatically rotate IRQ priorities during AEOI? */
  33.241 +    uint8_t rotate_on_auto_eoi:1;
  33.242 +
  33.243 +    /* Exclude slave inputs when considering in-service IRQs? */
  33.244 +    uint8_t special_fully_nested_mode:1;
  33.245 +
  33.246 +    /* Special mask mode excludes masked IRs from AEOI and priority checks. */
  33.247 +    uint8_t special_mask_mode:1;
  33.248 +
  33.249 +    /* Is this a master PIC or slave PIC? (NB. This is not programmable.) */
  33.250 +    uint8_t is_master:1;
  33.251 +
  33.252 +    /* Edge/trigger selection. */
  33.253 +    uint8_t elcr;
  33.254 +
  33.255 +    /* Virtual INT output. */
  33.256 +    uint8_t int_output;
  33.257 +};
  33.258 +
  33.259 +DECLARE_HVM_SAVE_TYPE(PIC, 3, struct hvm_hw_vpic);
  33.260 +
  33.261 +
  33.262 +/*
  33.263 + * IO-APIC
  33.264 + */
  33.265 +
  33.266 +#ifdef __ia64__
  33.267 +#define VIOAPIC_IS_IOSAPIC 1
  33.268 +#define VIOAPIC_NUM_PINS  24
  33.269 +#else
  33.270 +#define VIOAPIC_NUM_PINS  48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */
  33.271 +#endif
  33.272 +
  33.273 +struct hvm_hw_vioapic {
  33.274 +    uint64_t base_address;
  33.275 +    uint32_t ioregsel;
  33.276 +    uint32_t id;
  33.277 +    union vioapic_redir_entry
  33.278 +    {
  33.279 +        uint64_t bits;
  33.280 +        struct {
  33.281 +            uint8_t vector;
  33.282 +            uint8_t delivery_mode:3;
  33.283 +            uint8_t dest_mode:1;
  33.284 +            uint8_t delivery_status:1;
  33.285 +            uint8_t polarity:1;
  33.286 +            uint8_t remote_irr:1;
  33.287 +            uint8_t trig_mode:1;
  33.288 +            uint8_t mask:1;
  33.289 +            uint8_t reserve:7;
  33.290 +#if !VIOAPIC_IS_IOSAPIC
  33.291 +            uint8_t reserved[4];
  33.292 +            uint8_t dest_id;
  33.293 +#else
  33.294 +            uint8_t reserved[3];
  33.295 +            uint16_t dest_id;
  33.296 +#endif
  33.297 +        } fields;
  33.298 +    } redirtbl[VIOAPIC_NUM_PINS];
  33.299 +};
  33.300 +
  33.301 +DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic);
  33.302 +
  33.303 +
  33.304 +/*
  33.305 + * LAPIC
  33.306 + */
  33.307 +
  33.308 +struct hvm_hw_lapic {
  33.309 +    uint64_t             apic_base_msr;
  33.310 +    uint32_t             disabled; /* VLAPIC_xx_DISABLED */
  33.311 +    uint32_t             timer_divisor;
  33.312 +};
  33.313 +
  33.314 +DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic);
  33.315 +
  33.316 +struct hvm_hw_lapic_regs {
  33.317 +    /* A 4k page of register state */
  33.318 +    uint8_t  data[0x400];
  33.319 +};
  33.320 +
  33.321 +DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs);
  33.322 +
  33.323 +
  33.324 +/*
  33.325 + * IRQs
  33.326 + */
  33.327 +
  33.328 +struct hvm_hw_pci_irqs {
  33.329 +    /*
  33.330 +     * Virtual interrupt wires for a single PCI bus.
  33.331 +     * Indexed by: device*4 + INTx#.
  33.332 +     */
  33.333 +    union {
  33.334 +        DECLARE_BITMAP(i, 32*4);
  33.335 +        uint64_t pad[2];
  33.336 +    };
  33.337 +};
  33.338 +
  33.339 +DECLARE_HVM_SAVE_TYPE(PCI_IRQ, 7, struct hvm_hw_pci_irqs);
  33.340 +
  33.341 +struct hvm_hw_isa_irqs {
  33.342 +    /*
  33.343 +     * Virtual interrupt wires for ISA devices.
  33.344 +     * Indexed by ISA IRQ (assumes no ISA-device IRQ sharing).
  33.345 +     */
  33.346 +    union {
  33.347 +        DECLARE_BITMAP(i, 16);
  33.348 +        uint64_t pad[1];
  33.349 +    };
  33.350 +};
  33.351 +
  33.352 +DECLARE_HVM_SAVE_TYPE(ISA_IRQ, 8, struct hvm_hw_isa_irqs);
  33.353 +
  33.354 +struct hvm_hw_pci_link {
  33.355 +    /*
  33.356 +     * PCI-ISA interrupt router.
  33.357 +     * Each PCI <device:INTx#> is 'wire-ORed' into one of four links using
  33.358 +     * the traditional 'barber's pole' mapping ((device + INTx#) & 3).
  33.359 +     * The router provides a programmable mapping from each link to a GSI.
  33.360 +     */
  33.361 +    uint8_t route[4];
  33.362 +    uint8_t pad0[4];
  33.363 +};
  33.364 +
  33.365 +DECLARE_HVM_SAVE_TYPE(PCI_LINK, 9, struct hvm_hw_pci_link);
  33.366 +
  33.367 +/* 
  33.368 + *  PIT
  33.369 + */
  33.370 +
  33.371 +struct hvm_hw_pit {
  33.372 +    struct hvm_hw_pit_channel {
  33.373 +        uint32_t count; /* can be 65536 */
  33.374 +        uint16_t latched_count;
  33.375 +        uint8_t count_latched;
  33.376 +        uint8_t status_latched;
  33.377 +        uint8_t status;
  33.378 +        uint8_t read_state;
  33.379 +        uint8_t write_state;
  33.380 +        uint8_t write_latch;
  33.381 +        uint8_t rw_mode;
  33.382 +        uint8_t mode;
  33.383 +        uint8_t bcd; /* not supported */
  33.384 +        uint8_t gate; /* timer start */
  33.385 +    } channels[3];  /* 3 x 16 bytes */
  33.386 +    uint32_t speaker_data_on;
  33.387 +    uint32_t pad0;
  33.388 +};
  33.389 +
  33.390 +DECLARE_HVM_SAVE_TYPE(PIT, 10, struct hvm_hw_pit);
  33.391 +
  33.392 +
  33.393 +/* 
  33.394 + * RTC
  33.395 + */ 
  33.396 +
  33.397 +#define RTC_CMOS_SIZE 14
  33.398 +struct hvm_hw_rtc {
  33.399 +    /* CMOS bytes */
  33.400 +    uint8_t cmos_data[RTC_CMOS_SIZE];
  33.401 +    /* Index register for 2-part operations */
  33.402 +    uint8_t cmos_index;
  33.403 +    uint8_t pad0;
  33.404 +};
  33.405 +
  33.406 +DECLARE_HVM_SAVE_TYPE(RTC, 11, struct hvm_hw_rtc);
  33.407 +
  33.408 +
  33.409 +/*
  33.410 + * HPET
  33.411 + */
  33.412 +
  33.413 +#define HPET_TIMER_NUM     3    /* 3 timers supported now */
  33.414 +struct hvm_hw_hpet {
  33.415 +    /* Memory-mapped, software visible registers */
  33.416 +    uint64_t capability;        /* capabilities */
  33.417 +    uint64_t res0;              /* reserved */
  33.418 +    uint64_t config;            /* configuration */
  33.419 +    uint64_t res1;              /* reserved */
  33.420 +    uint64_t isr;               /* interrupt status reg */
  33.421 +    uint64_t res2[25];          /* reserved */
  33.422 +    uint64_t mc64;              /* main counter */
  33.423 +    uint64_t res3;              /* reserved */
  33.424 +    struct {                    /* timers */
  33.425 +        uint64_t config;        /* configuration/cap */
  33.426 +        uint64_t cmp;           /* comparator */
  33.427 +        uint64_t fsb;           /* FSB route, not supported now */
  33.428 +        uint64_t res4;          /* reserved */
  33.429 +    } timers[HPET_TIMER_NUM];
  33.430 +    uint64_t res5[4*(24-HPET_TIMER_NUM)];  /* reserved, up to 0x3ff */
  33.431 +
  33.432 +    /* Hidden register state */
  33.433 +    uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
  33.434 +};
  33.435 +
  33.436 +DECLARE_HVM_SAVE_TYPE(HPET, 12, struct hvm_hw_hpet);
  33.437 +
  33.438 +
  33.439 +/*
  33.440 + * PM timer
  33.441 + */
  33.442 +
  33.443 +struct hvm_hw_pmtimer {
  33.444 +    uint32_t tmr_val;   /* PM_TMR_BLK.TMR_VAL: 32bit free-running counter */
  33.445 +    uint16_t pm1a_sts;  /* PM1a_EVT_BLK.PM1a_STS: status register */
  33.446 +    uint16_t pm1a_en;   /* PM1a_EVT_BLK.PM1a_EN: enable register */
  33.447 +};
  33.448 +
  33.449 +DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer);
  33.450 +
  33.451 +/* 
  33.452 + * Largest type-code in use
  33.453 + */
  33.454 +#define HVM_SAVE_CODE_MAX 13
  33.455 +
  33.456 +
  33.457 +/* 
  33.458 + * The series of save records is teminated by a zero-type, zero-length 
  33.459 + * descriptor.
  33.460 + */
  33.461 +
  33.462 +struct hvm_save_end {};
  33.463 +DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);
  33.464 +
  33.465 +#endif /* __XEN_PUBLIC_HVM_SAVE_H__ */
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/common/include/public/hvm/vmx_assist.h	Wed Dec 19 09:23:32 2007 +1100
    34.3 @@ -0,0 +1,122 @@
    34.4 +/*
    34.5 + * vmx_assist.h: Context definitions for the VMXASSIST world switch.
    34.6 + *
    34.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    34.8 + * of this software and associated documentation files (the "Software"), to
    34.9 + * deal in the Software without restriction, including without limitation the
   34.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   34.11 + * sell copies of the Software, and to permit persons to whom the Software is
   34.12 + * furnished to do so, subject to the following conditions:
   34.13 + *
   34.14 + * The above copyright notice and this permission notice shall be included in
   34.15 + * all copies or substantial portions of the Software.
   34.16 + *
   34.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   34.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   34.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   34.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   34.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   34.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   34.23 + * DEALINGS IN THE SOFTWARE.
   34.24 + *
   34.25 + * Leendert van Doorn, leendert@watson.ibm.com
   34.26 + * Copyright (c) 2005, International Business Machines Corporation.
   34.27 + */
   34.28 +
   34.29 +#ifndef _VMX_ASSIST_H_
   34.30 +#define _VMX_ASSIST_H_
   34.31 +
   34.32 +#define VMXASSIST_BASE         0xD0000
   34.33 +#define VMXASSIST_MAGIC        0x17101966
   34.34 +#define VMXASSIST_MAGIC_OFFSET (VMXASSIST_BASE+8)
   34.35 +
   34.36 +#define VMXASSIST_NEW_CONTEXT (VMXASSIST_BASE + 12)
   34.37 +#define VMXASSIST_OLD_CONTEXT (VMXASSIST_NEW_CONTEXT + 4)
   34.38 +
   34.39 +#ifndef __ASSEMBLY__
   34.40 +
   34.41 +#define NR_EXCEPTION_HANDLER    32
   34.42 +#define NR_INTERRUPT_HANDLERS   16
   34.43 +#define NR_TRAPS        (NR_EXCEPTION_HANDLER+NR_INTERRUPT_HANDLERS)
   34.44 +
   34.45 +union vmcs_arbytes {
   34.46 +    struct arbyte_fields {
   34.47 +        unsigned int seg_type : 4,
   34.48 +            s         : 1,
   34.49 +            dpl       : 2,
   34.50 +            p         : 1,
   34.51 +            reserved0 : 4,
   34.52 +            avl       : 1,
   34.53 +            reserved1 : 1,
   34.54 +            default_ops_size: 1,
   34.55 +            g         : 1,
   34.56 +            null_bit  : 1,
   34.57 +            reserved2 : 15;
   34.58 +    } fields;
   34.59 +    unsigned int bytes;
   34.60 +};
   34.61 +
   34.62 +/*
   34.63 + * World switch state
   34.64 + */
   34.65 +struct vmx_assist_context {
   34.66 +    uint32_t  eip;        /* execution pointer */
   34.67 +    uint32_t  esp;        /* stack pointer */
   34.68 +    uint32_t  eflags;     /* flags register */
   34.69 +    uint32_t  cr0;
   34.70 +    uint32_t  cr3;        /* page table directory */
   34.71 +    uint32_t  cr4;
   34.72 +    uint32_t  idtr_limit; /* idt */
   34.73 +    uint32_t  idtr_base;
   34.74 +    uint32_t  gdtr_limit; /* gdt */
   34.75 +    uint32_t  gdtr_base;
   34.76 +    uint32_t  cs_sel;     /* cs selector */
   34.77 +    uint32_t  cs_limit;
   34.78 +    uint32_t  cs_base;
   34.79 +    union vmcs_arbytes cs_arbytes;
   34.80 +    uint32_t  ds_sel;     /* ds selector */
   34.81 +    uint32_t  ds_limit;
   34.82 +    uint32_t  ds_base;
   34.83 +    union vmcs_arbytes ds_arbytes;
   34.84 +    uint32_t  es_sel;     /* es selector */
   34.85 +    uint32_t  es_limit;
   34.86 +    uint32_t  es_base;
   34.87 +    union vmcs_arbytes es_arbytes;
   34.88 +    uint32_t  ss_sel;     /* ss selector */
   34.89 +    uint32_t  ss_limit;
   34.90 +    uint32_t  ss_base;
   34.91 +    union vmcs_arbytes ss_arbytes;
   34.92 +    uint32_t  fs_sel;     /* fs selector */
   34.93 +    uint32_t  fs_limit;
   34.94 +    uint32_t  fs_base;
   34.95 +    union vmcs_arbytes fs_arbytes;
   34.96 +    uint32_t  gs_sel;     /* gs selector */
   34.97 +    uint32_t  gs_limit;
   34.98 +    uint32_t  gs_base;
   34.99 +    union vmcs_arbytes gs_arbytes;
  34.100 +    uint32_t  tr_sel;     /* task selector */
  34.101 +    uint32_t  tr_limit;
  34.102 +    uint32_t  tr_base;
  34.103 +    union vmcs_arbytes tr_arbytes;
  34.104 +    uint32_t  ldtr_sel;   /* ldtr selector */
  34.105 +    uint32_t  ldtr_limit;
  34.106 +    uint32_t  ldtr_base;
  34.107 +    union vmcs_arbytes ldtr_arbytes;
  34.108 +
  34.109 +    unsigned char rm_irqbase[2];
  34.110 +};
  34.111 +typedef struct vmx_assist_context vmx_assist_context_t;
  34.112 +
  34.113 +#endif /* __ASSEMBLY__ */
  34.114 +
  34.115 +#endif /* _VMX_ASSIST_H_ */
  34.116 +
  34.117 +/*
  34.118 + * Local variables:
  34.119 + * mode: C
  34.120 + * c-set-style: "BSD"
  34.121 + * c-basic-offset: 4
  34.122 + * tab-width: 4
  34.123 + * indent-tabs-mode: nil
  34.124 + * End:
  34.125 + */
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/common/include/public/io/blkif.h	Wed Dec 19 09:23:32 2007 +1100
    35.3 @@ -0,0 +1,128 @@
    35.4 +/******************************************************************************
    35.5 + * blkif.h
    35.6 + * 
    35.7 + * Unified block-device 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) 2003-2004, Keir Fraser
   35.28 + */
   35.29 +
   35.30 +#ifndef __XEN_PUBLIC_IO_BLKIF_H__
   35.31 +#define __XEN_PUBLIC_IO_BLKIF_H__
   35.32 +
   35.33 +#include "ring.h"
   35.34 +#include "../grant_table.h"
   35.35 +
   35.36 +/*
   35.37 + * Front->back notifications: When enqueuing a new request, sending a
   35.38 + * notification can be made conditional on req_event (i.e., the generic
   35.39 + * hold-off mechanism provided by the ring macros). Backends must set
   35.40 + * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
   35.41 + * 
   35.42 + * Back->front notifications: When enqueuing a new response, sending a
   35.43 + * notification can be made conditional on rsp_event (i.e., the generic
   35.44 + * hold-off mechanism provided by the ring macros). Frontends must set
   35.45 + * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
   35.46 + */
   35.47 +
   35.48 +#ifndef blkif_vdev_t
   35.49 +#define blkif_vdev_t   uint16_t
   35.50 +#endif
   35.51 +#define blkif_sector_t uint64_t
   35.52 +
   35.53 +/*
   35.54 + * REQUEST CODES.
   35.55 + */
   35.56 +#define BLKIF_OP_READ              0
   35.57 +#define BLKIF_OP_WRITE             1
   35.58 +/*
   35.59 + * Recognised only if "feature-barrier" is present in backend xenbus info.
   35.60 + * The "feature_barrier" node contains a boolean indicating whether barrier
   35.61 + * requests are likely to succeed or fail. Either way, a barrier request
   35.62 + * may fail at any time with BLKIF_RSP_EOPNOTSUPP if it is unsupported by
   35.63 + * the underlying block-device hardware. The boolean simply indicates whether
   35.64 + * or not it is worthwhile for the frontend to attempt barrier requests.
   35.65 + * If a backend does not recognise BLKIF_OP_WRITE_BARRIER, it should *not*
   35.66 + * create the "feature-barrier" node!
   35.67 + */
   35.68 +#define BLKIF_OP_WRITE_BARRIER     2
   35.69 +
   35.70 +/*
   35.71 + * Maximum scatter/gather segments per request.
   35.72 + * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
   35.73 + * NB. This could be 12 if the ring indexes weren't stored in the same page.
   35.74 + */
   35.75 +#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
   35.76 +
   35.77 +struct blkif_request_segment {
   35.78 +    grant_ref_t gref;        /* reference to I/O buffer frame        */
   35.79 +    /* @first_sect: first sector in frame to transfer (inclusive).   */
   35.80 +    /* @last_sect: last sector in frame to transfer (inclusive).     */
   35.81 +    uint8_t     first_sect, last_sect;
   35.82 +};
   35.83 +
   35.84 +struct blkif_request {
   35.85 +    uint8_t        operation;    /* BLKIF_OP_???                         */
   35.86 +    uint8_t        nr_segments;  /* number of segments                   */
   35.87 +    blkif_vdev_t   handle;       /* only for read/write requests         */
   35.88 +    uint64_t       id;           /* private guest value, echoed in resp  */
   35.89 +    blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
   35.90 +    struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
   35.91 +};
   35.92 +typedef struct blkif_request blkif_request_t;
   35.93 +
   35.94 +struct blkif_response {
   35.95 +    uint64_t        id;              /* copied from request */
   35.96 +    uint8_t         operation;       /* copied from request */
   35.97 +    int16_t         status;          /* BLKIF_RSP_???       */
   35.98 +};
   35.99 +typedef struct blkif_response blkif_response_t;
  35.100 +
  35.101 +/*
  35.102 + * STATUS RETURN CODES.
  35.103 + */
  35.104 + /* Operation not supported (only happens on barrier writes). */
  35.105 +#define BLKIF_RSP_EOPNOTSUPP  -2
  35.106 + /* Operation failed for some unspecified reason (-EIO). */
  35.107 +#define BLKIF_RSP_ERROR       -1
  35.108 + /* Operation completed successfully. */
  35.109 +#define BLKIF_RSP_OKAY         0
  35.110 +
  35.111 +/*
  35.112 + * Generate blkif ring structures and types.
  35.113 + */
  35.114 +
  35.115 +DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
  35.116 +
  35.117 +#define VDISK_CDROM        0x1
  35.118 +#define VDISK_REMOVABLE    0x2
  35.119 +#define VDISK_READONLY     0x4
  35.120 +
  35.121 +#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
  35.122 +
  35.123 +/*
  35.124 + * Local variables:
  35.125 + * mode: C
  35.126 + * c-set-style: "BSD"
  35.127 + * c-basic-offset: 4
  35.128 + * tab-width: 4
  35.129 + * indent-tabs-mode: nil
  35.130 + * End:
  35.131 + */
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/common/include/public/io/console.h	Wed Dec 19 09:23:32 2007 +1100
    36.3 @@ -0,0 +1,51 @@
    36.4 +/******************************************************************************
    36.5 + * console.h
    36.6 + * 
    36.7 + * Console I/O interface for Xen guest OSes.
    36.8 + * 
    36.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   36.10 + * of this software and associated documentation files (the "Software"), to
   36.11 + * deal in the Software without restriction, including without limitation the
   36.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   36.13 + * sell copies of the Software, and to permit persons to whom the Software is
   36.14 + * furnished to do so, subject to the following conditions:
   36.15 + *
   36.16 + * The above copyright notice and this permission notice shall be included in
   36.17 + * all copies or substantial portions of the Software.
   36.18 + *
   36.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   36.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   36.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   36.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   36.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   36.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   36.25 + * DEALINGS IN THE SOFTWARE.
   36.26 + *
   36.27 + * Copyright (c) 2005, Keir Fraser
   36.28 + */
   36.29 +
   36.30 +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__
   36.31 +#define __XEN_PUBLIC_IO_CONSOLE_H__
   36.32 +
   36.33 +typedef uint32_t XENCONS_RING_IDX;
   36.34 +
   36.35 +#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1))
   36.36 +
   36.37 +struct xencons_interface {
   36.38 +    char in[1024];
   36.39 +    char out[2048];
   36.40 +    XENCONS_RING_IDX in_cons, in_prod;
   36.41 +    XENCONS_RING_IDX out_cons, out_prod;
   36.42 +};
   36.43 +
   36.44 +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */
   36.45 +
   36.46 +/*
   36.47 + * Local variables:
   36.48 + * mode: C
   36.49 + * c-set-style: "BSD"
   36.50 + * c-basic-offset: 4
   36.51 + * tab-width: 4
   36.52 + * indent-tabs-mode: nil
   36.53 + * End:
   36.54 + */
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/common/include/public/io/fbif.h	Wed Dec 19 09:23:32 2007 +1100
    37.3 @@ -0,0 +1,138 @@
    37.4 +/*
    37.5 + * fbif.h -- Xen virtual frame buffer device
    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_FBIF_H__
   37.30 +#define __XEN_PUBLIC_IO_FBIF_H__
   37.31 +
   37.32 +/* Out events (frontend -> backend) */
   37.33 +
   37.34 +/*
   37.35 + * Out events may be sent only when requested by backend, and receipt
   37.36 + * of an unknown out event is an error.
   37.37 + */
   37.38 +
   37.39 +/* Event type 1 currently not used */
   37.40 +/*
   37.41 + * Framebuffer update notification event
   37.42 + * Capable frontend sets feature-update in xenstore.
   37.43 + * Backend requests it by setting request-update in xenstore.
   37.44 + */
   37.45 +#define XENFB_TYPE_UPDATE 2
   37.46 +
   37.47 +struct xenfb_update
   37.48 +{
   37.49 +    uint8_t type;    /* XENFB_TYPE_UPDATE */
   37.50 +    int32_t x;      /* source x */
   37.51 +    int32_t y;      /* source y */
   37.52 +    int32_t width;  /* rect width */
   37.53 +    int32_t height; /* rect height */
   37.54 +};
   37.55 +
   37.56 +#define XENFB_OUT_EVENT_SIZE 40
   37.57 +
   37.58 +union xenfb_out_event
   37.59 +{
   37.60 +    uint8_t type;
   37.61 +    struct xenfb_update update;
   37.62 +    char pad[XENFB_OUT_EVENT_SIZE];
   37.63 +};
   37.64 +
   37.65 +/* In events (backend -> frontend) */
   37.66 +
   37.67 +/*
   37.68 + * Frontends should ignore unknown in events.
   37.69 + * No in events currently defined.
   37.70 + */
   37.71 +
   37.72 +#define XENFB_IN_EVENT_SIZE 40
   37.73 +
   37.74 +union xenfb_in_event
   37.75 +{
   37.76 +    uint8_t type;
   37.77 +    char pad[XENFB_IN_EVENT_SIZE];
   37.78 +};
   37.79 +
   37.80 +/* shared page */
   37.81 +
   37.82 +#define XENFB_IN_RING_SIZE 1024
   37.83 +#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
   37.84 +#define XENFB_IN_RING_OFFS 1024
   37.85 +#define XENFB_IN_RING(page) \
   37.86 +    ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
   37.87 +#define XENFB_IN_RING_REF(page, idx) \
   37.88 +    (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
   37.89 +
   37.90 +#define XENFB_OUT_RING_SIZE 2048
   37.91 +#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
   37.92 +#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
   37.93 +#define XENFB_OUT_RING(page) \
   37.94 +    ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
   37.95 +#define XENFB_OUT_RING_REF(page, idx) \
   37.96 +    (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
   37.97 +
   37.98 +struct xenfb_page
   37.99 +{
  37.100 +    uint32_t in_cons, in_prod;
  37.101 +    uint32_t out_cons, out_prod;
  37.102 +
  37.103 +    int32_t width;          /* the width of the framebuffer (in pixels) */
  37.104 +    int32_t height;         /* the height of the framebuffer (in pixels) */
  37.105 +    uint32_t line_length;   /* the length of a row of pixels (in bytes) */
  37.106 +    uint32_t mem_length;    /* the length of the framebuffer (in bytes) */
  37.107 +    uint8_t depth;          /* the depth of a pixel (in bits) */
  37.108 +
  37.109 +    /*
  37.110 +     * Framebuffer page directory
  37.111 +     *
  37.112 +     * Each directory page holds PAGE_SIZE / sizeof(*pd)
  37.113 +     * framebuffer pages, and can thus map up to PAGE_SIZE *
  37.114 +     * PAGE_SIZE / sizeof(*pd) bytes.  With PAGE_SIZE == 4096 and
  37.115 +     * sizeof(unsigned long) == 4, that's 4 Megs.  Two directory
  37.116 +     * pages should be enough for a while.
  37.117 +     */
  37.118 +    unsigned long pd[2];
  37.119 +};
  37.120 +
  37.121 +/*
  37.122 + * Wart: xenkbd needs to know resolution.  Put it here until a better
  37.123 + * solution is found, but don't leak it to the backend.
  37.124 + */
  37.125 +#ifdef __KERNEL__
  37.126 +#define XENFB_WIDTH 800
  37.127 +#define XENFB_HEIGHT 600
  37.128 +#define XENFB_DEPTH 32
  37.129 +#endif
  37.130 +
  37.131 +#endif
  37.132 +
  37.133 +/*
  37.134 + * Local variables:
  37.135 + * mode: C
  37.136 + * c-set-style: "BSD"
  37.137 + * c-basic-offset: 4
  37.138 + * tab-width: 4
  37.139 + * indent-tabs-mode: nil
  37.140 + * End:
  37.141 + */
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/common/include/public/io/kbdif.h	Wed Dec 19 09:23:32 2007 +1100
    38.3 @@ -0,0 +1,130 @@
    38.4 +/*
    38.5 + * kbdif.h -- Xen virtual keyboard/mouse
    38.6 + *
    38.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    38.8 + * of this software and associated documentation files (the "Software"), to
    38.9 + * deal in the Software without restriction, including without limitation the
   38.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   38.11 + * sell copies of the Software, and to permit persons to whom the Software is
   38.12 + * furnished to do so, subject to the following conditions:
   38.13 + *
   38.14 + * The above copyright notice and this permission notice shall be included in
   38.15 + * all copies or substantial portions of the Software.
   38.16 + *
   38.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   38.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   38.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   38.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   38.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   38.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   38.23 + * DEALINGS IN THE SOFTWARE.
   38.24 + *
   38.25 + * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
   38.26 + * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
   38.27 + */
   38.28 +
   38.29 +#ifndef __XEN_PUBLIC_IO_KBDIF_H__
   38.30 +#define __XEN_PUBLIC_IO_KBDIF_H__
   38.31 +
   38.32 +/* In events (backend -> frontend) */
   38.33 +
   38.34 +/*
   38.35 + * Frontends should ignore unknown in events.
   38.36 + */
   38.37 +
   38.38 +/* Pointer movement event */
   38.39 +#define XENKBD_TYPE_MOTION  1
   38.40 +/* Event type 2 currently not used */
   38.41 +/* Key event (includes pointer buttons) */
   38.42 +#define XENKBD_TYPE_KEY     3
   38.43 +/*
   38.44 + * Pointer position event
   38.45 + * Capable backend sets feature-abs-pointer in xenstore.
   38.46 + * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
   38.47 + * request-abs-update in xenstore.
   38.48 + */
   38.49 +#define XENKBD_TYPE_POS     4
   38.50 +
   38.51 +struct xenkbd_motion
   38.52 +{
   38.53 +    uint8_t type;        /* XENKBD_TYPE_MOTION */
   38.54 +    int32_t rel_x;       /* relative X motion */
   38.55 +    int32_t rel_y;       /* relative Y motion */
   38.56 +};
   38.57 +
   38.58 +struct xenkbd_key
   38.59 +{
   38.60 +    uint8_t type;         /* XENKBD_TYPE_KEY */
   38.61 +    uint8_t pressed;      /* 1 if pressed; 0 otherwise */
   38.62 +    uint32_t keycode;     /* KEY_* from linux/input.h */
   38.63 +};
   38.64 +
   38.65 +struct xenkbd_position
   38.66 +{
   38.67 +    uint8_t type;        /* XENKBD_TYPE_POS */
   38.68 +    int32_t abs_x;       /* absolute X position (in FB pixels) */
   38.69 +    int32_t abs_y;       /* absolute Y position (in FB pixels) */
   38.70 +};
   38.71 +
   38.72 +#define XENKBD_IN_EVENT_SIZE 40
   38.73 +
   38.74 +union xenkbd_in_event
   38.75 +{
   38.76 +    uint8_t type;
   38.77 +    struct xenkbd_motion motion;
   38.78 +    struct xenkbd_key key;
   38.79 +    struct xenkbd_position pos;
   38.80 +    char pad[XENKBD_IN_EVENT_SIZE];
   38.81 +};
   38.82 +
   38.83 +/* Out events (frontend -> backend) */
   38.84 +
   38.85 +/*
   38.86 + * Out events may be sent only when requested by backend, and receipt
   38.87 + * of an unknown out event is an error.
   38.88 + * No out events currently defined.
   38.89 + */
   38.90 +
   38.91 +#define XENKBD_OUT_EVENT_SIZE 40
   38.92 +
   38.93 +union xenkbd_out_event
   38.94 +{
   38.95 +    uint8_t type;
   38.96 +    char pad[XENKBD_OUT_EVENT_SIZE];
   38.97 +};
   38.98 +
   38.99 +/* shared page */
  38.100 +
  38.101 +#define XENKBD_IN_RING_SIZE 2048
  38.102 +#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
  38.103 +#define XENKBD_IN_RING_OFFS 1024
  38.104 +#define XENKBD_IN_RING(page) \
  38.105 +    ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
  38.106 +#define XENKBD_IN_RING_REF(page, idx) \
  38.107 +    (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
  38.108 +
  38.109 +#define XENKBD_OUT_RING_SIZE 1024
  38.110 +#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
  38.111 +#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
  38.112 +#define XENKBD_OUT_RING(page) \
  38.113 +    ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
  38.114 +#define XENKBD_OUT_RING_REF(page, idx) \
  38.115 +    (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
  38.116 +
  38.117 +struct xenkbd_page
  38.118 +{
  38.119 +    uint32_t in_cons, in_prod;
  38.120 +    uint32_t out_cons, out_prod;
  38.121 +};
  38.122 +
  38.123 +#endif
  38.124 +
  38.125 +/*
  38.126 + * Local variables:
  38.127 + * mode: C
  38.128 + * c-set-style: "BSD"
  38.129 + * c-basic-offset: 4
  38.130 + * tab-width: 4
  38.131 + * indent-tabs-mode: nil
  38.132 + * End:
  38.133 + */
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/common/include/public/io/netif.h	Wed Dec 19 09:23:32 2007 +1100
    39.3 @@ -0,0 +1,184 @@
    39.4 +/******************************************************************************
    39.5 + * netif.h
    39.6 + * 
    39.7 + * Unified network-device I/O interface for Xen guest OSes.
    39.8 + * 
    39.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   39.10 + * of this software and associated documentation files (the "Software"), to
   39.11 + * deal in the Software without restriction, including without limitation the
   39.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   39.13 + * sell copies of the Software, and to permit persons to whom the Software is
   39.14 + * furnished to do so, subject to the following conditions:
   39.15 + *
   39.16 + * The above copyright notice and this permission notice shall be included in
   39.17 + * all copies or substantial portions of the Software.
   39.18 + *
   39.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   39.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   39.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   39.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   39.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   39.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   39.25 + * DEALINGS IN THE SOFTWARE.
   39.26 + *
   39.27 + * Copyright (c) 2003-2004, Keir Fraser
   39.28 + */
   39.29 +
   39.30 +#ifndef __XEN_PUBLIC_IO_NETIF_H__
   39.31 +#define __XEN_PUBLIC_IO_NETIF_H__
   39.32 +
   39.33 +#include "ring.h"
   39.34 +#include "../grant_table.h"
   39.35 +
   39.36 +/*
   39.37 + * Notifications after enqueuing any type of message should be conditional on
   39.38 + * the appropriate req_event or rsp_event field in the shared ring.
   39.39 + * If the client sends notification for rx requests then it should specify
   39.40 + * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
   39.41 + * that it cannot safely queue packets (as it may not be kicked to send them).
   39.42 + */
   39.43 +
   39.44 +/*
   39.45 + * This is the 'wire' format for packets:
   39.46 + *  Request 1: netif_tx_request -- NETTXF_* (any flags)
   39.47 + * [Request 2: netif_tx_extra]  (only if request 1 has NETTXF_extra_info)
   39.48 + * [Request 3: netif_tx_extra]  (only if request 2 has XEN_NETIF_EXTRA_MORE)
   39.49 + *  Request 4: netif_tx_request -- NETTXF_more_data
   39.50 + *  Request 5: netif_tx_request -- NETTXF_more_data
   39.51 + *  ...
   39.52 + *  Request N: netif_tx_request -- 0
   39.53 + */
   39.54 +
   39.55 +/* Protocol checksum field is blank in the packet (hardware offload)? */
   39.56 +#define _NETTXF_csum_blank     (0)
   39.57 +#define  NETTXF_csum_blank     (1U<<_NETTXF_csum_blank)
   39.58 +
   39.59 +/* Packet data has been validated against protocol checksum. */
   39.60 +#define _NETTXF_data_validated (1)
   39.61 +#define  NETTXF_data_validated (1U<<_NETTXF_data_validated)
   39.62 +
   39.63 +/* Packet continues in the next request descriptor. */
   39.64 +#define _NETTXF_more_data      (2)
   39.65 +#define  NETTXF_more_data      (1U<<_NETTXF_more_data)
   39.66 +
   39.67 +/* Packet to be followed by extra descriptor(s). */
   39.68 +#define _NETTXF_extra_info     (3)
   39.69 +#define  NETTXF_extra_info     (1U<<_NETTXF_extra_info)
   39.70 +
   39.71 +struct netif_tx_request {
   39.72 +    grant_ref_t gref;      /* Reference to buffer page */
   39.73 +    uint16_t offset;       /* Offset within buffer page */
   39.74 +    uint16_t flags;        /* NETTXF_* */
   39.75 +    uint16_t id;           /* Echoed in response message. */
   39.76 +    uint16_t size;         /* Packet size in bytes.       */
   39.77 +};
   39.78 +typedef struct netif_tx_request netif_tx_request_t;
   39.79 +
   39.80 +/* Types of netif_extra_info descriptors. */
   39.81 +#define XEN_NETIF_EXTRA_TYPE_NONE  (0)  /* Never used - invalid */
   39.82 +#define XEN_NETIF_EXTRA_TYPE_GSO   (1)  /* u.gso */
   39.83 +#define XEN_NETIF_EXTRA_TYPE_MAX   (2)
   39.84 +
   39.85 +/* netif_extra_info flags. */
   39.86 +#define _XEN_NETIF_EXTRA_FLAG_MORE (0)
   39.87 +#define XEN_NETIF_EXTRA_FLAG_MORE  (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
   39.88 +
   39.89 +/* GSO types - only TCPv4 currently supported. */
   39.90 +#define XEN_NETIF_GSO_TYPE_TCPV4        (1)
   39.91 +
   39.92 +/*
   39.93 + * This structure needs to fit within both netif_tx_request and
   39.94 + * netif_rx_response for compatibility.
   39.95 + */
   39.96 +struct netif_extra_info {
   39.97 +    uint8_t type;  /* XEN_NETIF_EXTRA_TYPE_* */
   39.98 +    uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
   39.99 +
  39.100 +    union {
  39.101 +        struct {
  39.102 +            /*
  39.103 +             * Maximum payload size of each segment. For example, for TCP this
  39.104 +             * is just the path MSS.
  39.105 +             */
  39.106 +            uint16_t size;
  39.107 +
  39.108 +            /*
  39.109 +             * GSO type. This determines the protocol of the packet and any
  39.110 +             * extra features required to segment the packet properly.
  39.111 +             */
  39.112 +            uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
  39.113 +
  39.114 +            /* Future expansion. */
  39.115 +            uint8_t pad;
  39.116 +
  39.117 +            /*
  39.118 +             * GSO features. This specifies any extra GSO features required
  39.119 +             * to process this packet, such as ECN support for TCPv4.
  39.120 +             */
  39.121 +            uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
  39.122 +        } gso;
  39.123 +
  39.124 +        uint16_t pad[3];
  39.125 +    } u;
  39.126 +};
  39.127 +
  39.128 +struct netif_tx_response {
  39.129 +    uint16_t id;
  39.130 +    int16_t  status;       /* NETIF_RSP_* */
  39.131 +};
  39.132 +typedef struct netif_tx_response netif_tx_response_t;
  39.133 +
  39.134 +struct netif_rx_request {
  39.135 +    uint16_t    id;        /* Echoed in response message.        */
  39.136 +    grant_ref_t gref;      /* Reference to incoming granted frame */
  39.137 +};
  39.138 +typedef struct netif_rx_request netif_rx_request_t;
  39.139 +
  39.140 +/* Packet data has been validated against protocol checksum. */
  39.141 +#define _NETRXF_data_validated (0)
  39.142 +#define  NETRXF_data_validated (1U<<_NETRXF_data_validated)
  39.143 +
  39.144 +/* Protocol checksum field is blank in the packet (hardware offload)? */
  39.145 +#define _NETRXF_csum_blank     (1)
  39.146 +#define  NETRXF_csum_blank     (1U<<_NETRXF_csum_blank)
  39.147 +
  39.148 +/* Packet continues in the next request descriptor. */
  39.149 +#define _NETRXF_more_data      (2)
  39.150 +#define  NETRXF_more_data      (1U<<_NETRXF_more_data)
  39.151 +
  39.152 +/* Packet to be followed by extra descriptor(s). */
  39.153 +#define _NETRXF_extra_info     (3)
  39.154 +#define  NETRXF_extra_info     (1U<<_NETRXF_extra_info)
  39.155 +
  39.156 +struct netif_rx_response {
  39.157 +    uint16_t id;
  39.158 +    uint16_t offset;       /* Offset in page of start of received packet  */
  39.159 +    uint16_t flags;        /* NETRXF_* */
  39.160 +    int16_t  status;       /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
  39.161 +};
  39.162 +typedef struct netif_rx_response netif_rx_response_t;
  39.163 +
  39.164 +/*
  39.165 + * Generate netif ring structures and types.
  39.166 + */
  39.167 +
  39.168 +DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
  39.169 +DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
  39.170 +
  39.171 +#define NETIF_RSP_DROPPED         -2
  39.172 +#define NETIF_RSP_ERROR           -1
  39.173 +#define NETIF_RSP_OKAY             0
  39.174 +/* No response: used for auxiliary requests (e.g., netif_tx_extra). */
  39.175 +#define NETIF_RSP_NULL             1
  39.176 +
  39.177 +#endif
  39.178 +
  39.179 +/*
  39.180 + * Local variables:
  39.181 + * mode: C
  39.182 + * c-set-style: "BSD"
  39.183 + * c-basic-offset: 4
  39.184 + * tab-width: 4
  39.185 + * indent-tabs-mode: nil
  39.186 + * End:
  39.187 + */
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/common/include/public/io/pciif.h	Wed Dec 19 09:23:32 2007 +1100
    40.3 @@ -0,0 +1,83 @@
    40.4 +/*
    40.5 + * PCI Backend/Frontend Common Data Structures & Macros
    40.6 + *
    40.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    40.8 + * of this software and associated documentation files (the "Software"), to
    40.9 + * deal in the Software without restriction, including without limitation the
   40.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   40.11 + * sell copies of the Software, and to permit persons to whom the Software is
   40.12 + * furnished to do so, subject to the following conditions:
   40.13 + *
   40.14 + * The above copyright notice and this permission notice shall be included in
   40.15 + * all copies or substantial portions of the Software.
   40.16 + *
   40.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   40.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   40.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   40.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   40.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   40.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   40.23 + * DEALINGS IN THE SOFTWARE.
   40.24 + *
   40.25 + *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
   40.26 + */
   40.27 +#ifndef __XEN_PCI_COMMON_H__
   40.28 +#define __XEN_PCI_COMMON_H__
   40.29 +
   40.30 +/* Be sure to bump this number if you change this file */
   40.31 +#define XEN_PCI_MAGIC "7"
   40.32 +
   40.33 +/* xen_pci_sharedinfo flags */
   40.34 +#define _XEN_PCIF_active     (0)
   40.35 +#define XEN_PCIF_active      (1<<_XEN_PCI_active)
   40.36 +
   40.37 +/* xen_pci_op commands */
   40.38 +#define XEN_PCI_OP_conf_read    (0)
   40.39 +#define XEN_PCI_OP_conf_write   (1)
   40.40 +
   40.41 +/* xen_pci_op error numbers */
   40.42 +#define XEN_PCI_ERR_success          (0)
   40.43 +#define XEN_PCI_ERR_dev_not_found   (-1)
   40.44 +#define XEN_PCI_ERR_invalid_offset  (-2)
   40.45 +#define XEN_PCI_ERR_access_denied   (-3)
   40.46 +#define XEN_PCI_ERR_not_implemented (-4)
   40.47 +/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
   40.48 +#define XEN_PCI_ERR_op_failed       (-5)
   40.49 +
   40.50 +struct xen_pci_op {
   40.51 +    /* IN: what action to perform: XEN_PCI_OP_* */
   40.52 +    uint32_t cmd;
   40.53 +
   40.54 +    /* OUT: will contain an error number (if any) from errno.h */
   40.55 +    int32_t err;
   40.56 +
   40.57 +    /* IN: which device to touch */
   40.58 +    uint32_t domain; /* PCI Domain/Segment */
   40.59 +    uint32_t bus;
   40.60 +    uint32_t devfn;
   40.61 +
   40.62 +    /* IN: which configuration registers to touch */
   40.63 +    int32_t offset;
   40.64 +    int32_t size;
   40.65 +
   40.66 +    /* IN/OUT: Contains the result after a READ or the value to WRITE */
   40.67 +    uint32_t value;
   40.68 +};
   40.69 +
   40.70 +struct xen_pci_sharedinfo {
   40.71 +    /* flags - XEN_PCIF_* */
   40.72 +    uint32_t flags;
   40.73 +    struct xen_pci_op op;
   40.74 +};
   40.75 +
   40.76 +#endif /* __XEN_PCI_COMMON_H__ */
   40.77 +
   40.78 +/*
   40.79 + * Local variables:
   40.80 + * mode: C
   40.81 + * c-set-style: "BSD"
   40.82 + * c-basic-offset: 4
   40.83 + * tab-width: 4
   40.84 + * indent-tabs-mode: nil
   40.85 + * End:
   40.86 + */
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/common/include/public/io/protocols.h	Wed Dec 19 09:23:32 2007 +1100
    41.3 @@ -0,0 +1,21 @@
    41.4 +#ifndef __XEN_PROTOCOLS_H__
    41.5 +#define __XEN_PROTOCOLS_H__
    41.6 +
    41.7 +#define XEN_IO_PROTO_ABI_X86_32     "x86_32-abi"
    41.8 +#define XEN_IO_PROTO_ABI_X86_64     "x86_64-abi"
    41.9 +#define XEN_IO_PROTO_ABI_IA64       "ia64-abi"
   41.10 +#define XEN_IO_PROTO_ABI_POWERPC64  "powerpc64-abi"
   41.11 +
   41.12 +#if defined(__i386__)
   41.13 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
   41.14 +#elif defined(__x86_64__)
   41.15 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
   41.16 +#elif defined(__ia64__)
   41.17 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64
   41.18 +#elif defined(__powerpc64__)
   41.19 +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64
   41.20 +#else
   41.21 +# error arch fixup needed here
   41.22 +#endif
   41.23 +
   41.24 +#endif
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/common/include/public/io/ring.h	Wed Dec 19 09:23:32 2007 +1100
    42.3 @@ -0,0 +1,299 @@
    42.4 +/******************************************************************************
    42.5 + * ring.h
    42.6 + * 
    42.7 + * Shared producer-consumer ring macros.
    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 + * Tim Deegan and Andrew Warfield November 2004.
   42.28 + */
   42.29 +
   42.30 +#ifndef __XEN_PUBLIC_IO_RING_H__
   42.31 +#define __XEN_PUBLIC_IO_RING_H__
   42.32 +
   42.33 +typedef unsigned int RING_IDX;
   42.34 +
   42.35 +/* Round a 32-bit unsigned constant down to the nearest power of two. */
   42.36 +#define __RD2(_x)  (((_x) & 0x00000002) ? 0x2                  : ((_x) & 0x1))
   42.37 +#define __RD4(_x)  (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2    : __RD2(_x))
   42.38 +#define __RD8(_x)  (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4    : __RD4(_x))
   42.39 +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8    : __RD8(_x))
   42.40 +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
   42.41 +
   42.42 +/*
   42.43 + * Calculate size of a shared ring, given the total available space for the
   42.44 + * ring and indexes (_sz), and the name tag of the request/response structure.
   42.45 + * A ring contains as many entries as will fit, rounded down to the nearest 
   42.46 + * power of two (so we can mask with (size-1) to loop around).
   42.47 + */
   42.48 +#define __RING_SIZE(_s, _sz) \
   42.49 +    (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
   42.50 +
   42.51 +/*
   42.52 + * Macros to make the correct C datatypes for a new kind of ring.
   42.53 + * 
   42.54 + * To make a new ring datatype, you need to have two message structures,
   42.55 + * let's say request_t, and response_t already defined.
   42.56 + *
   42.57 + * In a header where you want the ring datatype declared, you then do:
   42.58 + *
   42.59 + *     DEFINE_RING_TYPES(mytag, request_t, response_t);
   42.60 + *
   42.61 + * These expand out to give you a set of types, as you can see below.
   42.62 + * The most important of these are:
   42.63 + * 
   42.64 + *     mytag_sring_t      - The shared ring.
   42.65 + *     mytag_front_ring_t - The 'front' half of the ring.
   42.66 + *     mytag_back_ring_t  - The 'back' half of the ring.
   42.67 + *
   42.68 + * To initialize a ring in your code you need to know the location and size
   42.69 + * of the shared memory area (PAGE_SIZE, for instance). To initialise
   42.70 + * the front half:
   42.71 + *
   42.72 + *     mytag_front_ring_t front_ring;
   42.73 + *     SHARED_RING_INIT((mytag_sring_t *)shared_page);
   42.74 + *     FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   42.75 + *
   42.76 + * Initializing the back follows similarly (note that only the front
   42.77 + * initializes the shared ring):
   42.78 + *
   42.79 + *     mytag_back_ring_t back_ring;
   42.80 + *     BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   42.81 + */
   42.82 +
   42.83 +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
   42.84 +                                                                        \
   42.85 +/* Shared ring entry */                                                 \
   42.86 +union __name##_sring_entry {                                            \
   42.87 +    __req_t req;                                                        \
   42.88 +    __rsp_t rsp;                                                        \
   42.89 +};                                                                      \
   42.90 +                                                                        \
   42.91 +/* Shared ring page */                                                  \
   42.92 +struct __name##_sring {                                                 \
   42.93 +    RING_IDX req_prod, req_event;                                       \
   42.94 +    RING_IDX rsp_prod, rsp_event;                                       \
   42.95 +    uint8_t  pad[48];                                                   \
   42.96 +    union __name##_sring_entry ring[1]; /* variable-length */           \
   42.97 +};                                                                      \
   42.98 +                                                                        \
   42.99 +/* "Front" end's private variables */                                   \
  42.100 +struct __name##_front_ring {                                            \
  42.101 +    RING_IDX req_prod_pvt;                                              \
  42.102 +    RING_IDX rsp_cons;                                                  \
  42.103 +    unsigned int nr_ents;                                               \
  42.104 +    struct __name##_sring *sring;                                       \
  42.105 +};                                                                      \
  42.106 +                                                                        \
  42.107 +/* "Back" end's private variables */                                    \
  42.108 +struct __name##_back_ring {                                             \
  42.109 +    RING_IDX rsp_prod_pvt;                                              \
  42.110 +    RING_IDX req_cons;                                                  \
  42.111 +    unsigned int nr_ents;                                               \
  42.112 +    struct __name##_sring *sring;                                       \
  42.113 +};                                                                      \
  42.114 +                                                                        \
  42.115 +/* Syntactic sugar */                                                   \
  42.116 +typedef struct __name##_sring __name##_sring_t;                         \
  42.117 +typedef struct __name##_front_ring __name##_front_ring_t;               \
  42.118 +typedef struct __name##_back_ring __name##_back_ring_t
  42.119 +
  42.120 +/*
  42.121 + * Macros for manipulating rings.
  42.122 + * 
  42.123 + * FRONT_RING_whatever works on the "front end" of a ring: here 
  42.124 + * requests are pushed on to the ring and responses taken off it.
  42.125 + * 
  42.126 + * BACK_RING_whatever works on the "back end" of a ring: here 
  42.127 + * requests are taken off the ring and responses put on.
  42.128 + * 
  42.129 + * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. 
  42.130 + * This is OK in 1-for-1 request-response situations where the 
  42.131 + * requestor (front end) never has more than RING_SIZE()-1
  42.132 + * outstanding requests.
  42.133 + */
  42.134 +
  42.135 +/* Initialising empty rings */
  42.136 +#define SHARED_RING_INIT(_s) do {                                       \
  42.137 +    (_s)->req_prod  = (_s)->rsp_prod  = 0;                              \
  42.138 +    (_s)->req_event = (_s)->rsp_event = 1;                              \
  42.139 +    (void)memset((_s)->pad, 0, sizeof((_s)->pad));                      \
  42.140 +} while(0)
  42.141 +
  42.142 +#define FRONT_RING_INIT(_r, _s, __size) do {                            \
  42.143 +    (_r)->req_prod_pvt = 0;                                             \
  42.144 +    (_r)->rsp_cons = 0;                                                 \
  42.145 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  42.146 +    (_r)->sring = (_s);                                                 \
  42.147 +} while (0)
  42.148 +
  42.149 +#define BACK_RING_INIT(_r, _s, __size) do {                             \
  42.150 +    (_r)->rsp_prod_pvt = 0;                                             \
  42.151 +    (_r)->req_cons = 0;                                                 \
  42.152 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  42.153 +    (_r)->sring = (_s);                                                 \
  42.154 +} while (0)
  42.155 +
  42.156 +/* Initialize to existing shared indexes -- for recovery */
  42.157 +#define FRONT_RING_ATTACH(_r, _s, __size) do {                          \
  42.158 +    (_r)->sring = (_s);                                                 \
  42.159 +    (_r)->req_prod_pvt = (_s)->req_prod;                                \
  42.160 +    (_r)->rsp_cons = (_s)->rsp_prod;                                    \
  42.161 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  42.162 +} while (0)
  42.163 +
  42.164 +#define BACK_RING_ATTACH(_r, _s, __size) do {                           \
  42.165 +    (_r)->sring = (_s);                                                 \
  42.166 +    (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
  42.167 +    (_r)->req_cons = (_s)->req_prod;                                    \
  42.168 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  42.169 +} while (0)
  42.170 +
  42.171 +/* How big is this ring? */
  42.172 +#define RING_SIZE(_r)                                                   \
  42.173 +    ((_r)->nr_ents)
  42.174 +
  42.175 +/* Number of free requests (for use on front side only). */
  42.176 +#define RING_FREE_REQUESTS(_r)                                          \
  42.177 +    (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
  42.178 +
  42.179 +/* Test if there is an empty slot available on the front ring.
  42.180 + * (This is only meaningful from the front. )
  42.181 + */
  42.182 +#define RING_FULL(_r)                                                   \
  42.183 +    (RING_FREE_REQUESTS(_r) == 0)
  42.184 +
  42.185 +/* Test if there are outstanding messages to be processed on a ring. */
  42.186 +#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
  42.187 +    ((_r)->sring->rsp_prod - (_r)->rsp_cons)
  42.188 +
  42.189 +#ifdef __GNUC__
  42.190 +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
  42.191 +    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
  42.192 +    unsigned int rsp = RING_SIZE(_r) -                                  \
  42.193 +        ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
  42.194 +    req < rsp ? req : rsp;                                              \
  42.195 +})
  42.196 +#else
  42.197 +/* Same as above, but without the nice GCC ({ ... }) syntax. */
  42.198 +#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
  42.199 +    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
  42.200 +      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
  42.201 +     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
  42.202 +     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
  42.203 +#endif
  42.204 +
  42.205 +/* Direct access to individual ring elements, by index. */
  42.206 +#define RING_GET_REQUEST(_r, _idx)                                      \
  42.207 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
  42.208 +
  42.209 +#define RING_GET_RESPONSE(_r, _idx)                                     \
  42.210 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
  42.211 +
  42.212 +/* Loop termination condition: Would the specified index overflow the ring? */
  42.213 +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                           \
  42.214 +    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
  42.215 +
  42.216 +#define RING_PUSH_REQUESTS(_r) do {                                     \
  42.217 +    wmb(); /* back sees requests /before/ updated producer index */     \
  42.218 +    (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
  42.219 +} while (0)
  42.220 +
  42.221 +#define RING_PUSH_RESPONSES(_r) do {                                    \
  42.222 +    wmb(); /* front sees responses /before/ updated producer index */   \
  42.223 +    (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
  42.224 +} while (0)
  42.225 +
  42.226 +/*
  42.227 + * Notification hold-off (req_event and rsp_event):
  42.228 + * 
  42.229 + * When queueing requests or responses on a shared ring, it may not always be
  42.230 + * necessary to notify the remote end. For example, if requests are in flight
  42.231 + * in a backend, the front may be able to queue further requests without
  42.232 + * notifying the back (if the back checks for new requests when it queues
  42.233 + * responses).
  42.234 + * 
  42.235 + * When enqueuing requests or responses:
  42.236 + * 
  42.237 + *  Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument
  42.238 + *  is a boolean return value. True indicates that the receiver requires an
  42.239 + *  asynchronous notification.
  42.240 + * 
  42.241 + * After dequeuing requests or responses (before sleeping the connection):
  42.242 + * 
  42.243 + *  Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES().
  42.244 + *  The second argument is a boolean return value. True indicates that there
  42.245 + *  are pending messages on the ring (i.e., the connection should not be put
  42.246 + *  to sleep).
  42.247 + * 
  42.248 + *  These macros will set the req_event/rsp_event field to trigger a
  42.249 + *  notification on the very next message that is enqueued. If you want to
  42.250 + *  create batches of work (i.e., only receive a notification after several
  42.251 + *  messages have been enqueued) then you will need to create a customised
  42.252 + *  version of the FINAL_CHECK macro in your own code, which sets the event
  42.253 + *  field appropriately.
  42.254 + */
  42.255 +
  42.256 +#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
  42.257 +    RING_IDX __old = (_r)->sring->req_prod;                             \
  42.258 +    RING_IDX __new = (_r)->req_prod_pvt;                                \
  42.259 +    wmb(); /* back sees requests /before/ updated producer index */     \
  42.260 +    (_r)->sring->req_prod = __new;                                      \
  42.261 +    mb(); /* back sees new requests /before/ we check req_event */      \
  42.262 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
  42.263 +                 (RING_IDX)(__new - __old));                            \
  42.264 +} while (0)
  42.265 +
  42.266 +#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
  42.267 +    RING_IDX __old = (_r)->sring->rsp_prod;                             \
  42.268 +    RING_IDX __new = (_r)->rsp_prod_pvt;                                \
  42.269 +    wmb(); /* front sees responses /before/ updated producer index */   \
  42.270 +    (_r)->sring->rsp_prod = __new;                                      \
  42.271 +    mb(); /* front sees new responses /before/ we check rsp_event */    \
  42.272 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
  42.273 +                 (RING_IDX)(__new - __old));                            \
  42.274 +} while (0)
  42.275 +
  42.276 +#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do {             \
  42.277 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
  42.278 +    if (_work_to_do) break;                                             \
  42.279 +    (_r)->sring->req_event = (_r)->req_cons + 1;                        \
  42.280 +    mb();                                                               \
  42.281 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
  42.282 +} while (0)
  42.283 +
  42.284 +#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do {            \
  42.285 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
  42.286 +    if (_work_to_do) break;                                             \
  42.287 +    (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
  42.288 +    mb();                                                               \
  42.289 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
  42.290 +} while (0)
  42.291 +
  42.292 +#endif /* __XEN_PUBLIC_IO_RING_H__ */
  42.293 +
  42.294 +/*
  42.295 + * Local variables:
  42.296 + * mode: C
  42.297 + * c-set-style: "BSD"
  42.298 + * c-basic-offset: 4
  42.299 + * tab-width: 4
  42.300 + * indent-tabs-mode: nil
  42.301 + * End:
  42.302 + */
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/common/include/public/io/tpmif.h	Wed Dec 19 09:23:32 2007 +1100
    43.3 @@ -0,0 +1,77 @@
    43.4 +/******************************************************************************
    43.5 + * tpmif.h
    43.6 + *
    43.7 + * TPM I/O interface for Xen guest OSes.
    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, IBM Corporation
   43.28 + *
   43.29 + * Author: Stefan Berger, stefanb@us.ibm.com
   43.30 + * Grant table support: Mahadevan Gomathisankaran
   43.31 + *
   43.32 + * This code has been derived from tools/libxc/xen/io/netif.h
   43.33 + *
   43.34 + * Copyright (c) 2003-2004, Keir Fraser
   43.35 + */
   43.36 +
   43.37 +#ifndef __XEN_PUBLIC_IO_TPMIF_H__
   43.38 +#define __XEN_PUBLIC_IO_TPMIF_H__
   43.39 +
   43.40 +#include "../grant_table.h"
   43.41 +
   43.42 +struct tpmif_tx_request {
   43.43 +    unsigned long addr;   /* Machine address of packet.   */
   43.44 +    grant_ref_t ref;      /* grant table access reference */
   43.45 +    uint16_t unused;
   43.46 +    uint16_t size;        /* Packet size in bytes.        */
   43.47 +};
   43.48 +typedef struct tpmif_tx_request tpmif_tx_request_t;
   43.49 +
   43.50 +/*
   43.51 + * The TPMIF_TX_RING_SIZE defines the number of pages the
   43.52 + * front-end and backend can exchange (= size of array).
   43.53 + */
   43.54 +typedef uint32_t TPMIF_RING_IDX;
   43.55 +
   43.56 +#define TPMIF_TX_RING_SIZE 1
   43.57 +
   43.58 +/* This structure must fit in a memory page. */
   43.59 +
   43.60 +struct tpmif_ring {
   43.61 +    struct tpmif_tx_request req;
   43.62 +};
   43.63 +typedef struct tpmif_ring tpmif_ring_t;
   43.64 +
   43.65 +struct tpmif_tx_interface {
   43.66 +    struct tpmif_ring ring[TPMIF_TX_RING_SIZE];
   43.67 +};
   43.68 +typedef struct tpmif_tx_interface tpmif_tx_interface_t;
   43.69 +
   43.70 +#endif
   43.71 +
   43.72 +/*
   43.73 + * Local variables:
   43.74 + * mode: C
   43.75 + * c-set-style: "BSD"
   43.76 + * c-basic-offset: 4
   43.77 + * tab-width: 4
   43.78 + * indent-tabs-mode: nil
   43.79 + * End:
   43.80 + */
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/common/include/public/io/xenbus.h	Wed Dec 19 09:23:32 2007 +1100
    44.3 @@ -0,0 +1,73 @@
    44.4 +/*****************************************************************************
    44.5 + * xenbus.h
    44.6 + *
    44.7 + * Xenbus protocol details.
    44.8 + *
    44.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   44.10 + * of this software and associated documentation files (the "Software"), to
   44.11 + * deal in the Software without restriction, including without limitation the
   44.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   44.13 + * sell copies of the Software, and to permit persons to whom the Software is
   44.14 + * furnished to do so, subject to the following conditions:
   44.15 + *
   44.16 + * The above copyright notice and this permission notice shall be included in
   44.17 + * all copies or substantial portions of the Software.
   44.18 + *
   44.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   44.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   44.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   44.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   44.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   44.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   44.25 + * DEALINGS IN THE SOFTWARE.
   44.26 + *
   44.27 + * Copyright (C) 2005 XenSource Ltd.
   44.28 + */
   44.29 +
   44.30 +#ifndef _XEN_PUBLIC_IO_XENBUS_H
   44.31 +#define _XEN_PUBLIC_IO_XENBUS_H
   44.32 +
   44.33 +/*
   44.34 + * The state of either end of the Xenbus, i.e. the current communication
   44.35 + * status of initialisation across the bus.  States here imply nothing about
   44.36 + * the state of the connection between the driver and the kernel's device
   44.37 + * layers.
   44.38 + */
   44.39 +enum xenbus_state {
   44.40 +    XenbusStateUnknown       = 0,
   44.41 +
   44.42 +    XenbusStateInitialising  = 1,
   44.43 +
   44.44 +    /*
   44.45 +     * InitWait: Finished early initialisation but waiting for information
   44.46 +     * from the peer or hotplug scripts.
   44.47 +     */
   44.48 +    XenbusStateInitWait      = 2,
   44.49 +
   44.50 +    /*
   44.51 +     * Initialised: Waiting for a connection from the peer.
   44.52 +     */
   44.53 +    XenbusStateInitialised   = 3,
   44.54 +
   44.55 +    XenbusStateConnected     = 4,
   44.56 +
   44.57 +    /*
   44.58 +     * Closing: The device is being closed due to an error or an unplug event.
   44.59 +     */
   44.60 +    XenbusStateClosing       = 5,
   44.61 +
   44.62 +    XenbusStateClosed        = 6
   44.63 +};
   44.64 +typedef enum xenbus_state XenbusState;
   44.65 +
   44.66 +#endif /* _XEN_PUBLIC_IO_XENBUS_H */
   44.67 +
   44.68 +/*
   44.69 + * Local variables:
   44.70 + * mode: C
   44.71 + * c-set-style: "BSD"
   44.72 + * c-basic-offset: 4
   44.73 + * tab-width: 4
   44.74 + * indent-tabs-mode: nil
   44.75 + * End:
   44.76 + */
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/common/include/public/io/xs_wire.h	Wed Dec 19 09:23:32 2007 +1100
    45.3 @@ -0,0 +1,121 @@
    45.4 +/*
    45.5 + * Details of the "wire" protocol between Xen Store Daemon and client
    45.6 + * library or guest kernel.
    45.7 + *
    45.8 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    45.9 + * of this software and associated documentation files (the "Software"), to
   45.10 + * deal in the Software without restriction, including without limitation the
   45.11 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   45.12 + * sell copies of the Software, and to permit persons to whom the Software is
   45.13 + * furnished to do so, subject to the following conditions:
   45.14 + *
   45.15 + * The above copyright notice and this permission notice shall be included in
   45.16 + * all copies or substantial portions of the Software.
   45.17 + *
   45.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   45.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   45.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   45.21 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   45.22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   45.23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   45.24 + * DEALINGS IN THE SOFTWARE.
   45.25 + *
   45.26 + * Copyright (C) 2005 Rusty Russell IBM Corporation
   45.27 + */
   45.28 +
   45.29 +#ifndef _XS_WIRE_H
   45.30 +#define _XS_WIRE_H
   45.31 +
   45.32 +enum xsd_sockmsg_type
   45.33 +{
   45.34 +    XS_DEBUG,
   45.35 +    XS_DIRECTORY,
   45.36 +    XS_READ,
   45.37 +    XS_GET_PERMS,
   45.38 +    XS_WATCH,
   45.39 +    XS_UNWATCH,
   45.40 +    XS_TRANSACTION_START,
   45.41 +    XS_TRANSACTION_END,
   45.42 +    XS_INTRODUCE,
   45.43 +    XS_RELEASE,
   45.44 +    XS_GET_DOMAIN_PATH,
   45.45 +    XS_WRITE,
   45.46 +    XS_MKDIR,
   45.47 +    XS_RM,
   45.48 +    XS_SET_PERMS,
   45.49 +    XS_WATCH_EVENT,
   45.50 +    XS_ERROR,
   45.51 +    XS_IS_DOMAIN_INTRODUCED,
   45.52 +    XS_RESUME
   45.53 +};
   45.54 +
   45.55 +#define XS_WRITE_NONE "NONE"
   45.56 +#define XS_WRITE_CREATE "CREATE"
   45.57 +#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
   45.58 +
   45.59 +/* We hand errors as strings, for portability. */
   45.60 +struct xsd_errors
   45.61 +{
   45.62 +    int errnum;
   45.63 +    const char *errstring;
   45.64 +};
   45.65 +#define XSD_ERROR(x) { x, #x }
   45.66 +static struct xsd_errors xsd_errors[]
   45.67 +#if defined(__GNUC__)
   45.68 +__attribute__((unused))
   45.69 +#endif
   45.70 +    = {
   45.71 +    XSD_ERROR(EINVAL),
   45.72 +    XSD_ERROR(EACCES),
   45.73 +    XSD_ERROR(EEXIST),
   45.74 +    XSD_ERROR(EISDIR),
   45.75 +    XSD_ERROR(ENOENT),
   45.76 +    XSD_ERROR(ENOMEM),
   45.77 +    XSD_ERROR(ENOSPC),
   45.78 +    XSD_ERROR(EIO),
   45.79 +    XSD_ERROR(ENOTEMPTY),
   45.80 +    XSD_ERROR(ENOSYS),
   45.81 +    XSD_ERROR(EROFS),
   45.82 +    XSD_ERROR(EBUSY),
   45.83 +    XSD_ERROR(EAGAIN),
   45.84 +    XSD_ERROR(EISCONN)
   45.85 +};
   45.86 +
   45.87 +struct xsd_sockmsg
   45.88 +{
   45.89 +    uint32_t type;  /* XS_??? */
   45.90 +    uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
   45.91 +    uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
   45.92 +    uint32_t len;   /* Length of data following this. */
   45.93 +
   45.94 +    /* Generally followed by nul-terminated string(s). */
   45.95 +};
   45.96 +
   45.97 +enum xs_watch_type
   45.98 +{
   45.99 +    XS_WATCH_PATH = 0,
  45.100 +    XS_WATCH_TOKEN
  45.101 +};
  45.102 +
  45.103 +/* Inter-domain shared memory communications. */
  45.104 +#define XENSTORE_RING_SIZE 1024
  45.105 +typedef uint32_t XENSTORE_RING_IDX;
  45.106 +#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
  45.107 +struct xenstore_domain_interface {
  45.108 +    char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
  45.109 +    char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
  45.110 +    XENSTORE_RING_IDX req_cons, req_prod;
  45.111 +    XENSTORE_RING_IDX rsp_cons, rsp_prod;
  45.112 +};
  45.113 +
  45.114 +#endif /* _XS_WIRE_H */
  45.115 +
  45.116 +/*
  45.117 + * Local variables:
  45.118 + * mode: C
  45.119 + * c-set-style: "BSD"
  45.120 + * c-basic-offset: 4
  45.121 + * tab-width: 4
  45.122 + * indent-tabs-mode: nil
  45.123 + * End:
  45.124 + */
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/common/include/public/kexec.h	Wed Dec 19 09:23:32 2007 +1100
    46.3 @@ -0,0 +1,137 @@
    46.4 +/******************************************************************************
    46.5 + * kexec.h - Public portion
    46.6 + * 
    46.7 + * Xen port written by:
    46.8 + * - Simon 'Horms' Horman <horms@verge.net.au>
    46.9 + * - Magnus Damm <magnus@valinux.co.jp>
   46.10 + */
   46.11 +
   46.12 +#ifndef _XEN_PUBLIC_KEXEC_H
   46.13 +#define _XEN_PUBLIC_KEXEC_H
   46.14 +
   46.15 +
   46.16 +/* This file describes the Kexec / Kdump hypercall interface for Xen.
   46.17 + *
   46.18 + * Kexec under vanilla Linux allows a user to reboot the physical machine 
   46.19 + * into a new user-specified kernel. The Xen port extends this idea
   46.20 + * to allow rebooting of the machine from dom0. When kexec for dom0
   46.21 + * is used to reboot,  both the hypervisor and the domains get replaced
   46.22 + * with some other kernel. It is possible to kexec between vanilla
   46.23 + * Linux and Xen and back again. Xen to Xen works well too.
   46.24 + *
   46.25 + * The hypercall interface for kexec can be divided into three main
   46.26 + * types of hypercall operations:
   46.27 + *
   46.28 + * 1) Range information:
   46.29 + *    This is used by the dom0 kernel to ask the hypervisor about various 
   46.30 + *    address information. This information is needed to allow kexec-tools 
   46.31 + *    to fill in the ELF headers for /proc/vmcore properly.
   46.32 + *
   46.33 + * 2) Load and unload of images:
   46.34 + *    There are no big surprises here, the kexec binary from kexec-tools
   46.35 + *    runs in userspace in dom0. The tool loads/unloads data into the
   46.36 + *    dom0 kernel such as new kernel, initramfs and hypervisor. When
   46.37 + *    loaded the dom0 kernel performs a load hypercall operation, and
   46.38 + *    before releasing all page references the dom0 kernel calls unload.
   46.39 + *
   46.40 + * 3) Kexec operation:
   46.41 + *    This is used to start a previously loaded kernel.
   46.42 + */
   46.43 +
   46.44 +#include "xen.h"
   46.45 +
   46.46 +#if defined(__i386__) || defined(__x86_64__)
   46.47 +#define KEXEC_XEN_NO_PAGES 17
   46.48 +#endif
   46.49 +
   46.50 +/*
   46.51 + * Prototype for this hypercall is:
   46.52 + *  int kexec_op(int cmd, void *args)
   46.53 + * @cmd  == KEXEC_CMD_... 
   46.54 + *          KEXEC operation to perform
   46.55 + * @args == Operation-specific extra arguments (NULL if none).
   46.56 + */
   46.57 +
   46.58 +/*
   46.59 + * Kexec supports two types of operation:
   46.60 + * - kexec into a regular kernel, very similar to a standard reboot
   46.61 + *   - KEXEC_TYPE_DEFAULT is used to specify this type
   46.62 + * - kexec into a special "crash kernel", aka kexec-on-panic
   46.63 + *   - KEXEC_TYPE_CRASH is used to specify this type
   46.64 + *   - parts of our system may be broken at kexec-on-panic time
   46.65 + *     - the code should be kept as simple and self-contained as possible
   46.66 + */
   46.67 +
   46.68 +#define KEXEC_TYPE_DEFAULT 0
   46.69 +#define KEXEC_TYPE_CRASH   1
   46.70 +
   46.71 +
   46.72 +/* The kexec implementation for Xen allows the user to load two
   46.73 + * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH.
   46.74 + * All data needed for a kexec reboot is kept in one xen_kexec_image_t
   46.75 + * per "instance". The data mainly consists of machine address lists to pages
   46.76 + * together with destination addresses. The data in xen_kexec_image_t
   46.77 + * is passed to the "code page" which is one page of code that performs
   46.78 + * the final relocations before jumping to the new kernel.
   46.79 + */
   46.80 + 
   46.81 +typedef struct xen_kexec_image {
   46.82 +#if defined(__i386__) || defined(__x86_64__)
   46.83 +    unsigned long page_list[KEXEC_XEN_NO_PAGES];
   46.84 +#endif
   46.85 +    unsigned long indirection_page;
   46.86 +    unsigned long start_address;
   46.87 +} xen_kexec_image_t;
   46.88 +
   46.89 +/*
   46.90 + * Perform kexec having previously loaded a kexec or kdump kernel
   46.91 + * as appropriate.
   46.92 + * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
   46.93 + */
   46.94 +#define KEXEC_CMD_kexec                 0
   46.95 +typedef struct xen_kexec_exec {
   46.96 +    int type;
   46.97 +} xen_kexec_exec_t;
   46.98 +
   46.99 +/*
  46.100 + * Load/Unload kernel image for kexec or kdump.
  46.101 + * type  == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
  46.102 + * image == relocation information for kexec (ignored for unload) [in]
  46.103 + */
  46.104 +#define KEXEC_CMD_kexec_load            1
  46.105 +#define KEXEC_CMD_kexec_unload          2
  46.106 +typedef struct xen_kexec_load {
  46.107 +    int type;
  46.108 +    xen_kexec_image_t image;
  46.109 +} xen_kexec_load_t;
  46.110 +
  46.111 +#define KEXEC_RANGE_MA_CRASH 0   /* machine address and size of crash area */
  46.112 +#define KEXEC_RANGE_MA_XEN   1   /* machine address and size of Xen itself */
  46.113 +#define KEXEC_RANGE_MA_CPU   2   /* machine address and size of a CPU note */
  46.114 +
  46.115 +/*
  46.116 + * Find the address and size of certain memory areas
  46.117 + * range == KEXEC_RANGE_... [in]
  46.118 + * nr    == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
  46.119 + * size  == number of bytes reserved in window [out]
  46.120 + * start == address of the first byte in the window [out]
  46.121 + */
  46.122 +#define KEXEC_CMD_kexec_get_range       3
  46.123 +typedef struct xen_kexec_range {
  46.124 +    int range;
  46.125 +    int nr;
  46.126 +    unsigned long size;
  46.127 +    unsigned long start;
  46.128 +} xen_kexec_range_t;
  46.129 +
  46.130 +#endif /* _XEN_PUBLIC_KEXEC_H */
  46.131 +
  46.132 +/*
  46.133 + * Local variables:
  46.134 + * mode: C
  46.135 + * c-set-style: "BSD"
  46.136 + * c-basic-offset: 4
  46.137 + * tab-width: 4
  46.138 + * indent-tabs-mode: nil
  46.139 + * End:
  46.140 + */
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/common/include/public/libelf.h	Wed Dec 19 09:23:32 2007 +1100
    47.3 @@ -0,0 +1,241 @@
    47.4 +#ifndef __XC_LIBELF__
    47.5 +#define __XC_LIBELF__ 1
    47.6 +
    47.7 +#if defined(__i386__) || defined(__x86_64) || defined(__ia64__)
    47.8 +#define XEN_ELF_LITTLE_ENDIAN
    47.9 +#elif defined(__powerpc__)
   47.10 +#define XEN_ELF_BIG_ENDIAN
   47.11 +#else
   47.12 +#error define architectural endianness
   47.13 +#endif
   47.14 +
   47.15 +#undef ELFSIZE
   47.16 +#include "elfnote.h"
   47.17 +#include "elfstructs.h"
   47.18 +#include "features.h"
   47.19 +
   47.20 +/* ------------------------------------------------------------------------ */
   47.21 +
   47.22 +typedef union {
   47.23 +    Elf32_Ehdr e32;
   47.24 +    Elf64_Ehdr e64;
   47.25 +} elf_ehdr;
   47.26 +
   47.27 +typedef union {
   47.28 +    Elf32_Phdr e32;
   47.29 +    Elf64_Phdr e64;
   47.30 +} elf_phdr;
   47.31 +
   47.32 +typedef union {
   47.33 +    Elf32_Shdr e32;
   47.34 +    Elf64_Shdr e64;
   47.35 +} elf_shdr;
   47.36 +
   47.37 +typedef union {
   47.38 +    Elf32_Sym e32;
   47.39 +    Elf64_Sym e64;
   47.40 +} elf_sym;
   47.41 +
   47.42 +typedef union {
   47.43 +    Elf32_Rel e32;
   47.44 +    Elf64_Rel e64;
   47.45 +} elf_rel;
   47.46 +
   47.47 +typedef union {
   47.48 +    Elf32_Rela e32;
   47.49 +    Elf64_Rela e64;
   47.50 +} elf_rela;
   47.51 +
   47.52 +typedef union {
   47.53 +    Elf32_Note e32;
   47.54 +    Elf64_Note e64;
   47.55 +} elf_note;
   47.56 +
   47.57 +struct elf_binary {
   47.58 +    /* elf binary */
   47.59 +    const char *image;
   47.60 +    size_t size;
   47.61 +    char class;
   47.62 +    char data;
   47.63 +
   47.64 +    const elf_ehdr *ehdr;
   47.65 +    const char *sec_strtab;
   47.66 +    const elf_shdr *sym_tab;
   47.67 +    const char *sym_strtab;
   47.68 +
   47.69 +    /* loaded to */
   47.70 +    char *dest;
   47.71 +    uint64_t pstart;
   47.72 +    uint64_t pend;
   47.73 +    uint64_t reloc_offset;
   47.74 +
   47.75 +#ifndef __XEN__
   47.76 +    /* misc */
   47.77 +    FILE *log;
   47.78 +#endif
   47.79 +    int verbose;
   47.80 +};
   47.81 +
   47.82 +/* ------------------------------------------------------------------------ */
   47.83 +/* accessing elf header fields                                              */
   47.84 +
   47.85 +#ifdef XEN_ELF_BIG_ENDIAN
   47.86 +# define NATIVE_ELFDATA ELFDATA2MSB
   47.87 +#else
   47.88 +# define NATIVE_ELFDATA ELFDATA2LSB
   47.89 +#endif
   47.90 +
   47.91 +#define elf_32bit(elf) (ELFCLASS32 == (elf)->class)
   47.92 +#define elf_64bit(elf) (ELFCLASS64 == (elf)->class)
   47.93 +#define elf_msb(elf)   (ELFDATA2MSB == (elf)->data)
   47.94 +#define elf_lsb(elf)   (ELFDATA2LSB == (elf)->data)
   47.95 +#define elf_swap(elf)  (NATIVE_ELFDATA != (elf)->data)
   47.96 +
   47.97 +#define elf_uval(elf, str, elem)			\
   47.98 +	((ELFCLASS64 == (elf)->class)			\
   47.99 +	? elf_access_unsigned((elf), (str),		\
  47.100 +		offsetof(typeof(*(str)),e64.elem),	\
  47.101 +		sizeof((str)->e64.elem))		\
  47.102 +	: elf_access_unsigned((elf), (str),		\
  47.103 +		offsetof(typeof(*(str)),e32.elem),	\
  47.104 +		sizeof((str)->e32.elem)))
  47.105 +
  47.106 +#define elf_sval(elf, str, elem)			\
  47.107 +	((ELFCLASS64 == (elf)->class)			\
  47.108 +	? elf_access_signed((elf), (str),		\
  47.109 +		offsetof(typeof(*(str)),e64.elem),	\
  47.110 +		sizeof((str)->e64.elem))		\
  47.111 +	: elf_access_signed((elf), (str),		\
  47.112 +		offsetof(typeof(*(str)),e32.elem),	\
  47.113 +		sizeof((str)->e32.elem)))
  47.114 +
  47.115 +#define elf_size(elf, str)		\
  47.116 +	((ELFCLASS64 == (elf)->class)	\
  47.117 +	? sizeof((str)->e64)		\
  47.118 +	: sizeof((str)->e32))
  47.119 +
  47.120 +uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr,
  47.121 +			     uint64_t offset, size_t size);
  47.122 +int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
  47.123 +			  uint64_t offset, size_t size);
  47.124 +
  47.125 +uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr);
  47.126 +
  47.127 +/* ------------------------------------------------------------------------ */
  47.128 +/* xc_libelf_tools.c                                                        */
  47.129 +
  47.130 +int elf_shdr_count(struct elf_binary *elf);
  47.131 +int elf_phdr_count(struct elf_binary *elf);
  47.132 +
  47.133 +const elf_shdr *elf_shdr_by_name(struct elf_binary *elf, const char *name);
  47.134 +const elf_shdr *elf_shdr_by_index(struct elf_binary *elf, int index);
  47.135 +const elf_phdr *elf_phdr_by_index(struct elf_binary *elf, int index);
  47.136 +
  47.137 +const char *elf_section_name(struct elf_binary *elf, const elf_shdr * shdr);
  47.138 +const void *elf_section_start(struct elf_binary *elf, const elf_shdr * shdr);
  47.139 +const void *elf_section_end(struct elf_binary *elf, const elf_shdr * shdr);
  47.140 +
  47.141 +const void *elf_segment_start(struct elf_binary *elf, const elf_phdr * phdr);
  47.142 +const void *elf_segment_end(struct elf_binary *elf, const elf_phdr * phdr);
  47.143 +
  47.144 +const elf_sym *elf_sym_by_name(struct elf_binary *elf, const char *symbol);
  47.145 +const elf_sym *elf_sym_by_index(struct elf_binary *elf, int index);
  47.146 +
  47.147 +const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
  47.148 +const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
  47.149 +uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
  47.150 +const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note);
  47.151 +
  47.152 +int elf_is_elfbinary(const void *image);
  47.153 +int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);
  47.154 +
  47.155 +/* ------------------------------------------------------------------------ */
  47.156 +/* xc_libelf_loader.c                                                       */
  47.157 +
  47.158 +int elf_init(struct elf_binary *elf, const char *image, size_t size);
  47.159 +#ifdef __XEN__
  47.160 +void elf_set_verbose(struct elf_binary *elf);
  47.161 +#else
  47.162 +void elf_set_logfile(struct elf_binary *elf, FILE * log, int verbose);
  47.163 +#endif
  47.164 +
  47.165 +void elf_parse_binary(struct elf_binary *elf);
  47.166 +void elf_load_binary(struct elf_binary *elf);
  47.167 +
  47.168 +void *elf_get_ptr(struct elf_binary *elf, unsigned long addr);
  47.169 +uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol);
  47.170 +
  47.171 +/* ------------------------------------------------------------------------ */
  47.172 +/* xc_libelf_relocate.c                                                     */
  47.173 +
  47.174 +int elf_reloc(struct elf_binary *elf);
  47.175 +
  47.176 +/* ------------------------------------------------------------------------ */
  47.177 +/* xc_libelf_dominfo.c                                                      */
  47.178 +
  47.179 +#define UNSET_ADDR          ((uint64_t)-1)
  47.180 +
  47.181 +enum xen_elfnote_type {
  47.182 +    XEN_ENT_NONE = 0,
  47.183 +    XEN_ENT_LONG = 1,
  47.184 +    XEN_ENT_STR  = 2
  47.185 +};
  47.186 +
  47.187 +struct xen_elfnote {
  47.188 +    enum xen_elfnote_type type;
  47.189 +    const char *name;
  47.190 +    union {
  47.191 +	const char *str;
  47.192 +	uint64_t num;
  47.193 +    } data;
  47.194 +};
  47.195 +
  47.196 +struct elf_dom_parms {
  47.197 +    /* raw */
  47.198 +    const char *guest_info;
  47.199 +    const void *elf_note_start;
  47.200 +    const void *elf_note_end;
  47.201 +    struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
  47.202 +  
  47.203 +    /* parsed */
  47.204 +    char guest_os[16];
  47.205 +    char guest_ver[16];
  47.206 +    char xen_ver[16];
  47.207 +    char loader[16];
  47.208 +    int pae;
  47.209 +    int bsd_symtab;
  47.210 +    uint64_t virt_base;
  47.211 +    uint64_t virt_entry;
  47.212 +    uint64_t virt_hypercall;
  47.213 +    uint64_t virt_hv_start_low;
  47.214 +    uint64_t elf_paddr_offset;
  47.215 +    uint32_t f_supported[XENFEAT_NR_SUBMAPS];
  47.216 +    uint32_t f_required[XENFEAT_NR_SUBMAPS];
  47.217 +
  47.218 +    /* calculated */
  47.219 +    uint64_t virt_offset;
  47.220 +    uint64_t virt_kstart;
  47.221 +    uint64_t virt_kend;
  47.222 +};
  47.223 +
  47.224 +static inline void elf_xen_feature_set(int nr, uint32_t * addr)
  47.225 +{
  47.226 +    addr[nr >> 5] |= 1 << (nr & 31);
  47.227 +}
  47.228 +static inline int elf_xen_feature_get(int nr, uint32_t * addr)
  47.229 +{
  47.230 +    return !!(addr[nr >> 5] & (1 << (nr & 31)));
  47.231 +}
  47.232 +
  47.233 +int elf_xen_parse_features(const char *features,
  47.234 +			   uint32_t *supported,
  47.235 +			   uint32_t *required);
  47.236 +int elf_xen_parse_note(struct elf_binary *elf,
  47.237 +		       struct elf_dom_parms *parms,
  47.238 +		       const elf_note *note);
  47.239 +int elf_xen_parse_guest_info(struct elf_binary *elf,
  47.240 +			     struct elf_dom_parms *parms);
  47.241 +int elf_xen_parse(struct elf_binary *elf,
  47.242 +		  struct elf_dom_parms *parms);
  47.243 +
  47.244 +#endif /* __XC_LIBELF__ */
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/common/include/public/memory.h	Wed Dec 19 09:23:32 2007 +1100
    48.3 @@ -0,0 +1,281 @@
    48.4 +/******************************************************************************
    48.5 + * memory.h
    48.6 + * 
    48.7 + * Memory reservation and information.
    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_MEMORY_H__
   48.31 +#define __XEN_PUBLIC_MEMORY_H__
   48.32 +
   48.33 +/*
   48.34 + * Increase or decrease the specified domain's memory reservation. Returns the
   48.35 + * number of extents successfully allocated or freed.
   48.36 + * arg == addr of struct xen_memory_reservation.
   48.37 + */
   48.38 +#define XENMEM_increase_reservation 0
   48.39 +#define XENMEM_decrease_reservation 1
   48.40 +#define XENMEM_populate_physmap     6
   48.41 +struct xen_memory_reservation {
   48.42 +
   48.43 +    /*
   48.44 +     * XENMEM_increase_reservation:
   48.45 +     *   OUT: MFN (*not* GMFN) bases of extents that were allocated
   48.46 +     * XENMEM_decrease_reservation:
   48.47 +     *   IN:  GMFN bases of extents to free
   48.48 +     * XENMEM_populate_physmap:
   48.49 +     *   IN:  GPFN bases of extents to populate with memory
   48.50 +     *   OUT: GMFN bases of extents that were allocated
   48.51 +     *   (NB. This command also updates the mach_to_phys translation table)
   48.52 +     */
   48.53 +    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
   48.54 +
   48.55 +    /* Number of extents, and size/alignment of each (2^extent_order pages). */
   48.56 +    xen_ulong_t    nr_extents;
   48.57 +    unsigned int   extent_order;
   48.58 +
   48.59 +    /*
   48.60 +     * Maximum # bits addressable by the user of the allocated region (e.g., 
   48.61 +     * I/O devices often have a 32-bit limitation even in 64-bit systems). If 
   48.62 +     * zero then the user has no addressing restriction.
   48.63 +     * This field is not used by XENMEM_decrease_reservation.
   48.64 +     */
   48.65 +    unsigned int   address_bits;
   48.66 +
   48.67 +    /*
   48.68 +     * Domain whose reservation is being changed.
   48.69 +     * Unprivileged domains can specify only DOMID_SELF.
   48.70 +     */
   48.71 +    domid_t        domid;
   48.72 +};
   48.73 +typedef struct xen_memory_reservation xen_memory_reservation_t;
   48.74 +DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
   48.75 +
   48.76 +/*
   48.77 + * An atomic exchange of memory pages. If return code is zero then
   48.78 + * @out.extent_list provides GMFNs of the newly-allocated memory.
   48.79 + * Returns zero on complete success, otherwise a negative error code.
   48.80 + * On complete success then always @nr_exchanged == @in.nr_extents.
   48.81 + * On partial success @nr_exchanged indicates how much work was done.
   48.82 + */
   48.83 +#define XENMEM_exchange             11
   48.84 +struct xen_memory_exchange {
   48.85 +    /*
   48.86 +     * [IN] Details of memory extents to be exchanged (GMFN bases).
   48.87 +     * Note that @in.address_bits is ignored and unused.
   48.88 +     */
   48.89 +    struct xen_memory_reservation in;
   48.90 +
   48.91 +    /*
   48.92 +     * [IN/OUT] Details of new memory extents.
   48.93 +     * We require that:
   48.94 +     *  1. @in.domid == @out.domid
   48.95 +     *  2. @in.nr_extents  << @in.extent_order == 
   48.96 +     *     @out.nr_extents << @out.extent_order
   48.97 +     *  3. @in.extent_start and @out.extent_start lists must not overlap
   48.98 +     *  4. @out.extent_start lists GPFN bases to be populated
   48.99 +     *  5. @out.extent_start is overwritten with allocated GMFN bases
  48.100 +     */
  48.101 +    struct xen_memory_reservation out;
  48.102 +
  48.103 +    /*
  48.104 +     * [OUT] Number of input extents that were successfully exchanged:
  48.105 +     *  1. The first @nr_exchanged input extents were successfully
  48.106 +     *     deallocated.
  48.107 +     *  2. The corresponding first entries in the output extent list correctly
  48.108 +     *     indicate the GMFNs that were successfully exchanged.
  48.109 +     *  3. All other input and output extents are untouched.
  48.110 +     *  4. If not all input exents are exchanged then the return code of this
  48.111 +     *     command will be non-zero.
  48.112 +     *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
  48.113 +     */
  48.114 +    xen_ulong_t nr_exchanged;
  48.115 +};
  48.116 +typedef struct xen_memory_exchange xen_memory_exchange_t;
  48.117 +DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
  48.118 +
  48.119 +/*
  48.120 + * Returns the maximum machine frame number of mapped RAM in this system.
  48.121 + * This command always succeeds (it never returns an error code).
  48.122 + * arg == NULL.
  48.123 + */
  48.124 +#define XENMEM_maximum_ram_page     2
  48.125 +
  48.126 +/*
  48.127 + * Returns the current or maximum memory reservation, in pages, of the
  48.128 + * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
  48.129 + * arg == addr of domid_t.
  48.130 + */
  48.131 +#define XENMEM_current_reservation  3
  48.132 +#define XENMEM_maximum_reservation  4
  48.133 +
  48.134 +/*
  48.135 + * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
  48.136 + */
  48.137 +#define XENMEM_maximum_gpfn         14
  48.138 +
  48.139 +/*
  48.140 + * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
  48.141 + * mapping table. Architectures which do not have a m2p table do not implement
  48.142 + * this command.
  48.143 + * arg == addr of xen_machphys_mfn_list_t.
  48.144 + */
  48.145 +#define XENMEM_machphys_mfn_list    5
  48.146 +struct xen_machphys_mfn_list {
  48.147 +    /*
  48.148 +     * Size of the 'extent_start' array. Fewer entries will be filled if the
  48.149 +     * machphys table is smaller than max_extents * 2MB.
  48.150 +     */
  48.151 +    unsigned int max_extents;
  48.152 +
  48.153 +    /*
  48.154 +     * Pointer to buffer to fill with list of extent starts. If there are
  48.155 +     * any large discontiguities in the machine address space, 2MB gaps in
  48.156 +     * the machphys table will be represented by an MFN base of zero.
  48.157 +     */
  48.158 +    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
  48.159 +
  48.160 +    /*
  48.161 +     * Number of extents written to the above array. This will be smaller
  48.162 +     * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
  48.163 +     */
  48.164 +    unsigned int nr_extents;
  48.165 +};
  48.166 +typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
  48.167 +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
  48.168 +
  48.169 +/*
  48.170 + * Returns the location in virtual address space of the machine_to_phys
  48.171 + * mapping table. Architectures which do not have a m2p table, or which do not
  48.172 + * map it by default into guest address space, do not implement this command.
  48.173 + * arg == addr of xen_machphys_mapping_t.
  48.174 + */
  48.175 +#define XENMEM_machphys_mapping     12
  48.176 +struct xen_machphys_mapping {
  48.177 +    xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */
  48.178 +    xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */
  48.179 +};
  48.180 +typedef struct xen_machphys_mapping xen_machphys_mapping_t;
  48.181 +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
  48.182 +
  48.183 +/*
  48.184 + * Sets the GPFN at which a particular page appears in the specified guest's
  48.185 + * pseudophysical address space.
  48.186 + * arg == addr of xen_add_to_physmap_t.
  48.187 + */
  48.188 +#define XENMEM_add_to_physmap      7
  48.189 +struct xen_add_to_physmap {
  48.190 +    /* Which domain to change the mapping for. */
  48.191 +    domid_t domid;
  48.192 +
  48.193 +    /* Source mapping space. */
  48.194 +#define XENMAPSPACE_shared_info 0 /* shared info page */
  48.195 +#define XENMAPSPACE_grant_table 1 /* grant table page */
  48.196 +    unsigned int space;
  48.197 +
  48.198 +    /* Index into source mapping space. */
  48.199 +    xen_ulong_t idx;
  48.200 +
  48.201 +    /* GPFN where the source mapping page should appear. */
  48.202 +    xen_pfn_t     gpfn;
  48.203 +};
  48.204 +typedef struct xen_add_to_physmap xen_add_to_physmap_t;
  48.205 +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
  48.206 +
  48.207 +/*
  48.208 + * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
  48.209 + * code on failure. This call only works for auto-translated guests.
  48.210 + */
  48.211 +#define XENMEM_translate_gpfn_list  8
  48.212 +struct xen_translate_gpfn_list {
  48.213 +    /* Which domain to translate for? */
  48.214 +    domid_t domid;
  48.215 +
  48.216 +    /* Length of list. */
  48.217 +    xen_ulong_t nr_gpfns;
  48.218 +
  48.219 +    /* List of GPFNs to translate. */
  48.220 +    XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
  48.221 +
  48.222 +    /*
  48.223 +     * Output list to contain MFN translations. May be the same as the input
  48.224 +     * list (in which case each input GPFN is overwritten with the output MFN).
  48.225 +     */
  48.226 +    XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
  48.227 +};
  48.228 +typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
  48.229 +DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
  48.230 +
  48.231 +/*
  48.232 + * Returns the pseudo-physical memory map as it was when the domain
  48.233 + * was started (specified by XENMEM_set_memory_map).
  48.234 + * arg == addr of xen_memory_map_t.
  48.235 + */
  48.236 +#define XENMEM_memory_map           9
  48.237 +struct xen_memory_map {
  48.238 +    /*
  48.239 +     * On call the number of entries which can be stored in buffer. On
  48.240 +     * return the number of entries which have been stored in
  48.241 +     * buffer.
  48.242 +     */
  48.243 +    unsigned int nr_entries;
  48.244 +
  48.245 +    /*
  48.246 +     * Entries in the buffer are in the same format as returned by the
  48.247 +     * BIOS INT 0x15 EAX=0xE820 call.
  48.248 +     */
  48.249 +    XEN_GUEST_HANDLE(void) buffer;
  48.250 +};
  48.251 +typedef struct xen_memory_map xen_memory_map_t;
  48.252 +DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
  48.253 +
  48.254 +/*
  48.255 + * Returns the real physical memory map. Passes the same structure as
  48.256 + * XENMEM_memory_map.
  48.257 + * arg == addr of xen_memory_map_t.
  48.258 + */
  48.259 +#define XENMEM_machine_memory_map   10
  48.260 +
  48.261 +/*
  48.262 + * Set the pseudo-physical memory map of a domain, as returned by
  48.263 + * XENMEM_memory_map.
  48.264 + * arg == addr of xen_foreign_memory_map_t.
  48.265 + */
  48.266 +#define XENMEM_set_memory_map       13
  48.267 +struct xen_foreign_memory_map {
  48.268 +    domid_t domid;
  48.269 +    struct xen_memory_map map;
  48.270 +};
  48.271 +typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
  48.272 +DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
  48.273 +
  48.274 +#endif /* __XEN_PUBLIC_MEMORY_H__ */
  48.275 +
  48.276 +/*
  48.277 + * Local variables:
  48.278 + * mode: C
  48.279 + * c-set-style: "BSD"
  48.280 + * c-basic-offset: 4
  48.281 + * tab-width: 4
  48.282 + * indent-tabs-mode: nil
  48.283 + * End:
  48.284 + */
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/common/include/public/nmi.h	Wed Dec 19 09:23:32 2007 +1100
    49.3 @@ -0,0 +1,78 @@
    49.4 +/******************************************************************************
    49.5 + * nmi.h
    49.6 + * 
    49.7 + * NMI callback registration and reason codes.
    49.8 + * 
    49.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   49.10 + * of this software and associated documentation files (the "Software"), to
   49.11 + * deal in the Software without restriction, including without limitation the
   49.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   49.13 + * sell copies of the Software, and to permit persons to whom the Software is
   49.14 + * furnished to do so, subject to the following conditions:
   49.15 + *
   49.16 + * The above copyright notice and this permission notice shall be included in
   49.17 + * all copies or substantial portions of the Software.
   49.18 + *
   49.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   49.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   49.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   49.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   49.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   49.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   49.25 + * DEALINGS IN THE SOFTWARE.
   49.26 + *
   49.27 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   49.28 + */
   49.29 +
   49.30 +#ifndef __XEN_PUBLIC_NMI_H__
   49.31 +#define __XEN_PUBLIC_NMI_H__
   49.32 +
   49.33 +/*
   49.34 + * NMI reason codes:
   49.35 + * Currently these are x86-specific, stored in arch_shared_info.nmi_reason.
   49.36 + */
   49.37 + /* I/O-check error reported via ISA port 0x61, bit 6. */
   49.38 +#define _XEN_NMIREASON_io_error     0
   49.39 +#define XEN_NMIREASON_io_error      (1UL << _XEN_NMIREASON_io_error)
   49.40 + /* Parity error reported via ISA port 0x61, bit 7. */
   49.41 +#define _XEN_NMIREASON_parity_error 1
   49.42 +#define XEN_NMIREASON_parity_error  (1UL << _XEN_NMIREASON_parity_error)
   49.43 + /* Unknown hardware-generated NMI. */
   49.44 +#define _XEN_NMIREASON_unknown      2
   49.45 +#define XEN_NMIREASON_unknown       (1UL << _XEN_NMIREASON_unknown)
   49.46 +
   49.47 +/*
   49.48 + * long nmi_op(unsigned int cmd, void *arg)
   49.49 + * NB. All ops return zero on success, else a negative error code.
   49.50 + */
   49.51 +
   49.52 +/*
   49.53 + * Register NMI callback for this (calling) VCPU. Currently this only makes
   49.54 + * sense for domain 0, vcpu 0. All other callers will be returned EINVAL.
   49.55 + * arg == pointer to xennmi_callback structure.
   49.56 + */
   49.57 +#define XENNMI_register_callback   0
   49.58 +struct xennmi_callback {
   49.59 +    unsigned long handler_address;
   49.60 +    unsigned long pad;
   49.61 +};
   49.62 +typedef struct xennmi_callback xennmi_callback_t;
   49.63 +DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
   49.64 +
   49.65 +/*
   49.66 + * Deregister NMI callback for this (calling) VCPU.
   49.67 + * arg == NULL.
   49.68 + */
   49.69 +#define XENNMI_unregister_callback 1
   49.70 +
   49.71 +#endif /* __XEN_PUBLIC_NMI_H__ */
   49.72 +
   49.73 +/*
   49.74 + * Local variables:
   49.75 + * mode: C
   49.76 + * c-set-style: "BSD"
   49.77 + * c-basic-offset: 4
   49.78 + * tab-width: 4
   49.79 + * indent-tabs-mode: nil
   49.80 + * End:
   49.81 + */
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/common/include/public/physdev.h	Wed Dec 19 09:23:32 2007 +1100
    50.3 @@ -0,0 +1,169 @@
    50.4 +/*
    50.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    50.6 + * of this software and associated documentation files (the "Software"), to
    50.7 + * deal in the Software without restriction, including without limitation the
    50.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    50.9 + * sell copies of the Software, and to permit persons to whom the Software is
   50.10 + * furnished to do so, subject to the following conditions:
   50.11 + *
   50.12 + * The above copyright notice and this permission notice shall be included in
   50.13 + * all copies or substantial portions of the Software.
   50.14 + *
   50.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   50.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   50.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   50.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   50.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   50.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   50.21 + * DEALINGS IN THE SOFTWARE.
   50.22 + */
   50.23 +
   50.24 +#ifndef __XEN_PUBLIC_PHYSDEV_H__
   50.25 +#define __XEN_PUBLIC_PHYSDEV_H__
   50.26 +
   50.27 +/*
   50.28 + * Prototype for this hypercall is:
   50.29 + *  int physdev_op(int cmd, void *args)
   50.30 + * @cmd  == PHYSDEVOP_??? (physdev operation).
   50.31 + * @args == Operation-specific extra arguments (NULL if none).
   50.32 + */
   50.33 +
   50.34 +/*
   50.35 + * Notify end-of-interrupt (EOI) for the specified IRQ.
   50.36 + * @arg == pointer to physdev_eoi structure.
   50.37 + */
   50.38 +#define PHYSDEVOP_eoi                   12
   50.39 +struct physdev_eoi {
   50.40 +    /* IN */
   50.41 +    uint32_t irq;
   50.42 +};
   50.43 +typedef struct physdev_eoi physdev_eoi_t;
   50.44 +DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
   50.45 +
   50.46 +/*
   50.47 + * Query the status of an IRQ line.
   50.48 + * @arg == pointer to physdev_irq_status_query structure.
   50.49 + */
   50.50 +#define PHYSDEVOP_irq_status_query       5
   50.51 +struct physdev_irq_status_query {
   50.52 +    /* IN */
   50.53 +    uint32_t irq;
   50.54 +    /* OUT */
   50.55 +    uint32_t flags; /* XENIRQSTAT_* */
   50.56 +};
   50.57 +typedef struct physdev_irq_status_query physdev_irq_status_query_t;
   50.58 +DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
   50.59 +
   50.60 +/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
   50.61 +#define _XENIRQSTAT_needs_eoi   (0)
   50.62 +#define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
   50.63 +
   50.64 +/* IRQ shared by multiple guests? */
   50.65 +#define _XENIRQSTAT_shared      (1)
   50.66 +#define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
   50.67 +
   50.68 +/*
   50.69 + * Set the current VCPU's I/O privilege level.
   50.70 + * @arg == pointer to physdev_set_iopl structure.
   50.71 + */
   50.72 +#define PHYSDEVOP_set_iopl               6
   50.73 +struct physdev_set_iopl {
   50.74 +    /* IN */
   50.75 +    uint32_t iopl;
   50.76 +};
   50.77 +typedef struct physdev_set_iopl physdev_set_iopl_t;
   50.78 +DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
   50.79 +
   50.80 +/*
   50.81 + * Set the current VCPU's I/O-port permissions bitmap.
   50.82 + * @arg == pointer to physdev_set_iobitmap structure.
   50.83 + */
   50.84 +#define PHYSDEVOP_set_iobitmap           7
   50.85 +struct physdev_set_iobitmap {
   50.86 +    /* IN */
   50.87 +    XEN_GUEST_HANDLE_00030205(uint8_t) bitmap;
   50.88 +    uint32_t nr_ports;
   50.89 +};
   50.90 +typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
   50.91 +DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
   50.92 +
   50.93 +/*
   50.94 + * Read or write an IO-APIC register.
   50.95 + * @arg == pointer to physdev_apic structure.
   50.96 + */
   50.97 +#define PHYSDEVOP_apic_read              8
   50.98 +#define PHYSDEVOP_apic_write             9
   50.99 +struct physdev_apic {
  50.100 +    /* IN */
  50.101 +    unsigned long apic_physbase;
  50.102 +    uint32_t reg;
  50.103 +    /* IN or OUT */
  50.104 +    uint32_t value;
  50.105 +};
  50.106 +typedef struct physdev_apic physdev_apic_t;
  50.107 +DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
  50.108 +
  50.109 +/*
  50.110 + * Allocate or free a physical upcall vector for the specified IRQ line.
  50.111 + * @arg == pointer to physdev_irq structure.
  50.112 + */
  50.113 +#define PHYSDEVOP_alloc_irq_vector      10
  50.114 +#define PHYSDEVOP_free_irq_vector       11
  50.115 +struct physdev_irq {
  50.116 +    /* IN */
  50.117 +    uint32_t irq;
  50.118 +    /* IN or OUT */
  50.119 +    uint32_t vector;
  50.120 +};
  50.121 +typedef struct physdev_irq physdev_irq_t;
  50.122 +DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
  50.123 +
  50.124 +/*
  50.125 + * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  50.126 + * hypercall since 0x00030202.
  50.127 + */
  50.128 +struct physdev_op {
  50.129 +    uint32_t cmd;
  50.130 +    union {
  50.131 +        struct physdev_irq_status_query      irq_status_query;
  50.132 +        struct physdev_set_iopl              set_iopl;
  50.133 +        struct physdev_set_iobitmap          set_iobitmap;
  50.134 +        struct physdev_apic                  apic_op;
  50.135 +        struct physdev_irq                   irq_op;
  50.136 +    } u;
  50.137 +};
  50.138 +typedef struct physdev_op physdev_op_t;
  50.139 +DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
  50.140 +
  50.141 +/*
  50.142 + * Notify that some PIRQ-bound event channels have been unmasked.
  50.143 + * ** This command is obsolete since interface version 0x00030202 and is **
  50.144 + * ** unsupported by newer versions of Xen.                              **
  50.145 + */
  50.146 +#define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
  50.147 +
  50.148 +/*
  50.149 + * These all-capitals physdev operation names are superceded by the new names
  50.150 + * (defined above) since interface version 0x00030202.
  50.151 + */
  50.152 +#define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
  50.153 +#define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
  50.154 +#define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
  50.155 +#define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
  50.156 +#define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
  50.157 +#define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
  50.158 +#define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
  50.159 +#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
  50.160 +#define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
  50.161 +
  50.162 +#endif /* __XEN_PUBLIC_PHYSDEV_H__ */
  50.163 +
  50.164 +/*
  50.165 + * Local variables:
  50.166 + * mode: C
  50.167 + * c-set-style: "BSD"
  50.168 + * c-basic-offset: 4
  50.169 + * tab-width: 4
  50.170 + * indent-tabs-mode: nil
  50.171 + * End:
  50.172 + */
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/common/include/public/platform.h	Wed Dec 19 09:23:32 2007 +1100
    51.3 @@ -0,0 +1,183 @@
    51.4 +/******************************************************************************
    51.5 + * platform.h
    51.6 + * 
    51.7 + * Hardware platform operations. Intended for use by domain-0 kernel.
    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) 2002-2006, K Fraser
   51.28 + */
   51.29 +
   51.30 +#ifndef __XEN_PUBLIC_PLATFORM_H__
   51.31 +#define __XEN_PUBLIC_PLATFORM_H__
   51.32 +
   51.33 +#include "xen.h"
   51.34 +
   51.35 +#define XENPF_INTERFACE_VERSION 0x03000001
   51.36 +
   51.37 +/*
   51.38 + * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
   51.39 + * 1 January, 1970 if the current system time was <system_time>.
   51.40 + */
   51.41 +#define XENPF_settime             17
   51.42 +struct xenpf_settime {
   51.43 +    /* IN variables. */
   51.44 +    uint32_t secs;
   51.45 +    uint32_t nsecs;
   51.46 +    uint64_t system_time;
   51.47 +};
   51.48 +typedef struct xenpf_settime xenpf_settime_t;
   51.49 +DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
   51.50 +
   51.51 +/*
   51.52 + * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
   51.53 + * On x86, @type is an architecture-defined MTRR memory type.
   51.54 + * On success, returns the MTRR that was used (@reg) and a handle that can
   51.55 + * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
   51.56 + * (x86-specific).
   51.57 + */
   51.58 +#define XENPF_add_memtype         31
   51.59 +struct xenpf_add_memtype {
   51.60 +    /* IN variables. */
   51.61 +    xen_pfn_t mfn;
   51.62 +    uint64_t nr_mfns;
   51.63 +    uint32_t type;
   51.64 +    /* OUT variables. */
   51.65 +    uint32_t handle;
   51.66 +    uint32_t reg;
   51.67 +};
   51.68 +typedef struct xenpf_add_memtype xenpf_add_memtype_t;
   51.69 +DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
   51.70 +
   51.71 +/*
   51.72 + * Tear down an existing memory-range type. If @handle is remembered then it
   51.73 + * should be passed in to accurately tear down the correct setting (in case
   51.74 + * of overlapping memory regions with differing types). If it is not known
   51.75 + * then @handle should be set to zero. In all cases @reg must be set.
   51.76 + * (x86-specific).
   51.77 + */
   51.78 +#define XENPF_del_memtype         32
   51.79 +struct xenpf_del_memtype {
   51.80 +    /* IN variables. */
   51.81 +    uint32_t handle;
   51.82 +    uint32_t reg;
   51.83 +};
   51.84 +typedef struct xenpf_del_memtype xenpf_del_memtype_t;
   51.85 +DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
   51.86 +
   51.87 +/* Read current type of an MTRR (x86-specific). */
   51.88 +#define XENPF_read_memtype        33
   51.89 +struct xenpf_read_memtype {
   51.90 +    /* IN variables. */
   51.91 +    uint32_t reg;
   51.92 +    /* OUT variables. */
   51.93 +    xen_pfn_t mfn;
   51.94 +    uint64_t nr_mfns;
   51.95 +    uint32_t type;
   51.96 +};
   51.97 +typedef struct xenpf_read_memtype xenpf_read_memtype_t;
   51.98 +DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
   51.99 +
  51.100 +#define XENPF_microcode_update    35
  51.101 +struct xenpf_microcode_update {
  51.102 +    /* IN variables. */
  51.103 +    XEN_GUEST_HANDLE(void) data;      /* Pointer to microcode data */
  51.104 +    uint32_t length;                  /* Length of microcode data. */
  51.105 +};
  51.106 +typedef struct xenpf_microcode_update xenpf_microcode_update_t;
  51.107 +DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
  51.108 +
  51.109 +#define XENPF_platform_quirk      39
  51.110 +#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
  51.111 +#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
  51.112 +#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
  51.113 +struct xenpf_platform_quirk {
  51.114 +    /* IN variables. */
  51.115 +    uint32_t quirk_id;
  51.116 +};
  51.117 +typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
  51.118 +DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
  51.119 +
  51.120 +#define XENPF_firmware_info       50
  51.121 +#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
  51.122 +#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
  51.123 +#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
  51.124 +struct xenpf_firmware_info {
  51.125 +    /* IN variables. */
  51.126 +    uint32_t type;
  51.127 +    uint32_t index;
  51.128 +    /* OUT variables. */
  51.129 +    union {
  51.130 +        struct {
  51.131 +            /* Int13, Fn48: Check Extensions Present. */
  51.132 +            uint8_t device;                   /* %dl: bios device number */
  51.133 +            uint8_t version;                  /* %ah: major version      */
  51.134 +            uint16_t interface_support;       /* %cx: support bitmap     */
  51.135 +            /* Int13, Fn08: Legacy Get Device Parameters. */
  51.136 +            uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
  51.137 +            uint8_t legacy_max_head;          /* %dh: max head #         */
  51.138 +            uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
  51.139 +            /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
  51.140 +            /* NB. First uint16_t of buffer must be set to buffer size.      */
  51.141 +            XEN_GUEST_HANDLE(void) edd_params;
  51.142 +        } disk_info; /* XEN_FW_DISK_INFO */
  51.143 +        struct {
  51.144 +            uint8_t device;                   /* bios device number  */
  51.145 +            uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
  51.146 +        } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
  51.147 +        struct {
  51.148 +            /* Int10, AX=4F15: Get EDID info. */
  51.149 +            uint8_t capabilities;
  51.150 +            uint8_t edid_transfer_time;
  51.151 +            /* must refer to 128-byte buffer */
  51.152 +            XEN_GUEST_HANDLE(uint8_t) edid;
  51.153 +        } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
  51.154 +    } u;
  51.155 +};
  51.156 +typedef struct xenpf_firmware_info xenpf_firmware_info_t;
  51.157 +DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
  51.158 +
  51.159 +struct xen_platform_op {
  51.160 +    uint32_t cmd;
  51.161 +    uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
  51.162 +    union {
  51.163 +        struct xenpf_settime           settime;
  51.164 +        struct xenpf_add_memtype       add_memtype;
  51.165 +        struct xenpf_del_memtype       del_memtype;
  51.166 +        struct xenpf_read_memtype      read_memtype;
  51.167 +        struct xenpf_microcode_update  microcode;
  51.168 +        struct xenpf_platform_quirk    platform_quirk;
  51.169 +        struct xenpf_firmware_info     firmware_info;
  51.170 +        uint8_t                        pad[128];
  51.171 +    } u;
  51.172 +};
  51.173 +typedef struct xen_platform_op xen_platform_op_t;
  51.174 +DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
  51.175 +
  51.176 +#endif /* __XEN_PUBLIC_PLATFORM_H__ */
  51.177 +
  51.178 +/*
  51.179 + * Local variables:
  51.180 + * mode: C
  51.181 + * c-set-style: "BSD"
  51.182 + * c-basic-offset: 4
  51.183 + * tab-width: 4
  51.184 + * indent-tabs-mode: nil
  51.185 + * End:
  51.186 + */
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/common/include/public/sched.h	Wed Dec 19 09:23:32 2007 +1100
    52.3 @@ -0,0 +1,121 @@
    52.4 +/******************************************************************************
    52.5 + * sched.h
    52.6 + * 
    52.7 + * Scheduler state interactions
    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) 2005, Keir Fraser <keir@xensource.com>
   52.28 + */
   52.29 +
   52.30 +#ifndef __XEN_PUBLIC_SCHED_H__
   52.31 +#define __XEN_PUBLIC_SCHED_H__
   52.32 +
   52.33 +#include "event_channel.h"
   52.34 +
   52.35 +/*
   52.36 + * The prototype for this hypercall is:
   52.37 + *  long sched_op(int cmd, void *arg)
   52.38 + * @cmd == SCHEDOP_??? (scheduler operation).
   52.39 + * @arg == Operation-specific extra argument(s), as described below.
   52.40 + * 
   52.41 + * Versions of Xen prior to 3.0.2 provided only the following legacy version
   52.42 + * of this hypercall, supporting only the commands yield, block and shutdown:
   52.43 + *  long sched_op(int cmd, unsigned long arg)
   52.44 + * @cmd == SCHEDOP_??? (scheduler operation).
   52.45 + * @arg == 0               (SCHEDOP_yield and SCHEDOP_block)
   52.46 + *      == SHUTDOWN_* code (SCHEDOP_shutdown)
   52.47 + * This legacy version is available to new guests as sched_op_compat().
   52.48 + */
   52.49 +
   52.50 +/*
   52.51 + * Voluntarily yield the CPU.
   52.52 + * @arg == NULL.
   52.53 + */
   52.54 +#define SCHEDOP_yield       0
   52.55 +
   52.56 +/*
   52.57 + * Block execution of this VCPU until an event is received for processing.
   52.58 + * If called with event upcalls masked, this operation will atomically
   52.59 + * reenable event delivery and check for pending events before blocking the
   52.60 + * VCPU. This avoids a "wakeup waiting" race.
   52.61 + * @arg == NULL.
   52.62 + */
   52.63 +#define SCHEDOP_block       1
   52.64 +
   52.65 +/*
   52.66 + * Halt execution of this domain (all VCPUs) and notify the system controller.
   52.67 + * @arg == pointer to sched_shutdown structure.
   52.68 + */
   52.69 +#define SCHEDOP_shutdown    2
   52.70 +struct sched_shutdown {
   52.71 +    unsigned int reason; /* SHUTDOWN_* */
   52.72 +};
   52.73 +typedef struct sched_shutdown sched_shutdown_t;
   52.74 +DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
   52.75 +
   52.76 +/*
   52.77 + * Poll a set of event-channel ports. Return when one or more are pending. An
   52.78 + * optional timeout may be specified.
   52.79 + * @arg == pointer to sched_poll structure.
   52.80 + */
   52.81 +#define SCHEDOP_poll        3
   52.82 +struct sched_poll {
   52.83 +    XEN_GUEST_HANDLE(evtchn_port_t) ports;
   52.84 +    unsigned int nr_ports;
   52.85 +    uint64_t timeout;
   52.86 +};
   52.87 +typedef struct sched_poll sched_poll_t;
   52.88 +DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
   52.89 +
   52.90 +/*
   52.91 + * Declare a shutdown for another domain. The main use of this function is
   52.92 + * in interpreting shutdown requests and reasons for fully-virtualized
   52.93 + * domains.  A para-virtualized domain may use SCHEDOP_shutdown directly.
   52.94 + * @arg == pointer to sched_remote_shutdown structure.
   52.95 + */
   52.96 +#define SCHEDOP_remote_shutdown        4
   52.97 +struct sched_remote_shutdown {
   52.98 +    domid_t domain_id;         /* Remote domain ID */
   52.99 +    unsigned int reason;       /* SHUTDOWN_xxx reason */
  52.100 +};
  52.101 +typedef struct sched_remote_shutdown sched_remote_shutdown_t;
  52.102 +DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
  52.103 +
  52.104 +/*
  52.105 + * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
  52.106 + * software to determine the appropriate action. For the most part, Xen does
  52.107 + * not care about the shutdown code.
  52.108 + */
  52.109 +#define SHUTDOWN_poweroff   0  /* Domain exited normally. Clean up and kill. */
  52.110 +#define SHUTDOWN_reboot     1  /* Clean up, kill, and then restart.          */
  52.111 +#define SHUTDOWN_suspend    2  /* Clean up, save suspend info, kill.         */
  52.112 +#define SHUTDOWN_crash      3  /* Tell controller we've crashed.             */
  52.113 +
  52.114 +#endif /* __XEN_PUBLIC_SCHED_H__ */
  52.115 +
  52.116 +/*
  52.117 + * Local variables:
  52.118 + * mode: C
  52.119 + * c-set-style: "BSD"
  52.120 + * c-basic-offset: 4
  52.121 + * tab-width: 4
  52.122 + * indent-tabs-mode: nil
  52.123 + * End:
  52.124 + */
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/common/include/public/sysctl.h	Wed Dec 19 09:23:32 2007 +1100
    53.3 @@ -0,0 +1,198 @@
    53.4 +/******************************************************************************
    53.5 + * sysctl.h
    53.6 + * 
    53.7 + * System management operations. For use by node control stack.
    53.8 + * 
    53.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   53.10 + * of this software and associated documentation files (the "Software"), to
   53.11 + * deal in the Software without restriction, including without limitation the
   53.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   53.13 + * sell copies of the Software, and to permit persons to whom the Software is
   53.14 + * furnished to do so, subject to the following conditions:
   53.15 + *
   53.16 + * The above copyright notice and this permission notice shall be included in
   53.17 + * all copies or substantial portions of the Software.
   53.18 + *
   53.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   53.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   53.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   53.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   53.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   53.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   53.25 + * DEALINGS IN THE SOFTWARE.
   53.26 + *
   53.27 + * Copyright (c) 2002-2006, K Fraser
   53.28 + */
   53.29 +
   53.30 +#ifndef __XEN_PUBLIC_SYSCTL_H__
   53.31 +#define __XEN_PUBLIC_SYSCTL_H__
   53.32 +
   53.33 +#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
   53.34 +#error "sysctl operations are intended for use by node control tools only"
   53.35 +#endif
   53.36 +
   53.37 +#include "xen.h"
   53.38 +#include "domctl.h"
   53.39 +
   53.40 +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000003
   53.41 +
   53.42 +/*
   53.43 + * Read console content from Xen buffer ring.
   53.44 + */
   53.45 +#define XEN_SYSCTL_readconsole       1
   53.46 +struct xen_sysctl_readconsole {
   53.47 +    /* IN variables. */
   53.48 +    uint32_t clear;                /* Non-zero -> clear after reading. */
   53.49 +    XEN_GUEST_HANDLE_64(char) buffer; /* Buffer start */
   53.50 +    /* IN/OUT variables. */
   53.51 +    uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
   53.52 +};
   53.53 +typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
   53.54 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
   53.55 +
   53.56 +/* Get trace buffers machine base address */
   53.57 +#define XEN_SYSCTL_tbuf_op           2
   53.58 +struct xen_sysctl_tbuf_op {
   53.59 +    /* IN variables */
   53.60 +#define XEN_SYSCTL_TBUFOP_get_info     0
   53.61 +#define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
   53.62 +#define XEN_SYSCTL_TBUFOP_set_evt_mask 2
   53.63 +#define XEN_SYSCTL_TBUFOP_set_size     3
   53.64 +#define XEN_SYSCTL_TBUFOP_enable       4
   53.65 +#define XEN_SYSCTL_TBUFOP_disable      5
   53.66 +    uint32_t cmd;
   53.67 +    /* IN/OUT variables */
   53.68 +    struct xenctl_cpumap cpu_mask;
   53.69 +    uint32_t             evt_mask;
   53.70 +    /* OUT variables */
   53.71 +    uint64_aligned_t buffer_mfn;
   53.72 +    uint32_t size;
   53.73 +};
   53.74 +typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
   53.75 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
   53.76 +
   53.77 +/*
   53.78 + * Get physical information about the host machine
   53.79 + */
   53.80 +#define XEN_SYSCTL_physinfo          3
   53.81 +struct xen_sysctl_physinfo {
   53.82 +    uint32_t threads_per_core;
   53.83 +    uint32_t cores_per_socket;
   53.84 +    uint32_t sockets_per_node;
   53.85 +    uint32_t nr_nodes;
   53.86 +    uint32_t cpu_khz;
   53.87 +    uint64_aligned_t total_pages;
   53.88 +    uint64_aligned_t free_pages;
   53.89 +    uint64_aligned_t scrub_pages;
   53.90 +    uint32_t hw_cap[8];
   53.91 +};
   53.92 +typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
   53.93 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
   53.94 +
   53.95 +/*
   53.96 + * Get the ID of the current scheduler.
   53.97 + */
   53.98 +#define XEN_SYSCTL_sched_id          4
   53.99 +struct xen_sysctl_sched_id {
  53.100 +    /* OUT variable */
  53.101 +    uint32_t sched_id;
  53.102 +};
  53.103 +typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
  53.104 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
  53.105 +
  53.106 +/* Interface for controlling Xen software performance counters. */
  53.107 +#define XEN_SYSCTL_perfc_op          5
  53.108 +/* Sub-operations: */
  53.109 +#define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
  53.110 +#define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
  53.111 +struct xen_sysctl_perfc_desc {
  53.112 +    char         name[80];             /* name of perf counter */
  53.113 +    uint32_t     nr_vals;              /* number of values for this counter */
  53.114 +};
  53.115 +typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
  53.116 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
  53.117 +typedef uint32_t xen_sysctl_perfc_val_t;
  53.118 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
  53.119 +
  53.120 +struct xen_sysctl_perfc_op {
  53.121 +    /* IN variables. */
  53.122 +    uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
  53.123 +    /* OUT variables. */
  53.124 +    uint32_t       nr_counters;       /*  number of counters description  */
  53.125 +    uint32_t       nr_vals;           /*  number of values  */
  53.126 +    /* counter information (or NULL) */
  53.127 +    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
  53.128 +    /* counter values (or NULL) */
  53.129 +    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
  53.130 +};
  53.131 +typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
  53.132 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
  53.133 +
  53.134 +#define XEN_SYSCTL_getdomaininfolist 6
  53.135 +struct xen_sysctl_getdomaininfolist {
  53.136 +    /* IN variables. */
  53.137 +    domid_t               first_domain;
  53.138 +    uint32_t              max_domains;
  53.139 +    XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
  53.140 +    /* OUT variables. */
  53.141 +    uint32_t              num_domains;
  53.142 +};
  53.143 +typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
  53.144 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
  53.145 +
  53.146 +/* Inject debug keys into Xen. */
  53.147 +#define XEN_SYSCTL_debug_keys        7
  53.148 +struct xen_sysctl_debug_keys {
  53.149 +    /* IN variables. */
  53.150 +    XEN_GUEST_HANDLE_64(char) keys;
  53.151 +    uint32_t nr_keys;
  53.152 +};
  53.153 +typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
  53.154 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
  53.155 +
  53.156 +/* Get physical CPU information. */
  53.157 +#define XEN_SYSCTL_getcpuinfo        8
  53.158 +struct xen_sysctl_cpuinfo {
  53.159 +    uint64_t idletime;
  53.160 +};
  53.161 +typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
  53.162 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); 
  53.163 +struct xen_sysctl_getcpuinfo {
  53.164 +    /* IN variables. */
  53.165 +    uint32_t max_cpus;
  53.166 +    XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
  53.167 +    /* OUT variables. */
  53.168 +    uint32_t nr_cpus;
  53.169 +}; 
  53.170 +typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
  53.171 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t); 
  53.172 +
  53.173 +struct xen_sysctl {
  53.174 +    uint32_t cmd;
  53.175 +    uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
  53.176 +    union {
  53.177 +        struct xen_sysctl_readconsole       readconsole;
  53.178 +        struct xen_sysctl_tbuf_op           tbuf_op;
  53.179 +        struct xen_sysctl_physinfo          physinfo;
  53.180 +        struct xen_sysctl_sched_id          sched_id;
  53.181 +        struct xen_sysctl_perfc_op          perfc_op;
  53.182 +        struct xen_sysctl_getdomaininfolist getdomaininfolist;
  53.183 +        struct xen_sysctl_debug_keys        debug_keys;
  53.184 +        struct xen_sysctl_getcpuinfo        getcpuinfo;
  53.185 +        uint8_t                             pad[128];
  53.186 +    } u;
  53.187 +};
  53.188 +typedef struct xen_sysctl xen_sysctl_t;
  53.189 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
  53.190 +
  53.191 +#endif /* __XEN_PUBLIC_SYSCTL_H__ */
  53.192 +
  53.193 +/*
  53.194 + * Local variables:
  53.195 + * mode: C
  53.196 + * c-set-style: "BSD"
  53.197 + * c-basic-offset: 4
  53.198 + * tab-width: 4
  53.199 + * indent-tabs-mode: nil
  53.200 + * End:
  53.201 + */
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/common/include/public/trace.h	Wed Dec 19 09:23:32 2007 +1100
    54.3 @@ -0,0 +1,120 @@
    54.4 +/******************************************************************************
    54.5 + * include/public/trace.h
    54.6 + * 
    54.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    54.8 + * of this software and associated documentation files (the "Software"), to
    54.9 + * deal in the Software without restriction, including without limitation the
   54.10 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   54.11 + * sell copies of the Software, and to permit persons to whom the Software is
   54.12 + * furnished to do so, subject to the following conditions:
   54.13 + *
   54.14 + * The above copyright notice and this permission notice shall be included in
   54.15 + * all copies or substantial portions of the Software.
   54.16 + *
   54.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   54.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   54.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   54.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   54.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   54.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   54.23 + * DEALINGS IN THE SOFTWARE.
   54.24 + *
   54.25 + * Mark Williamson, (C) 2004 Intel Research Cambridge
   54.26 + * Copyright (C) 2005 Bin Ren
   54.27 + */
   54.28 +
   54.29 +#ifndef __XEN_PUBLIC_TRACE_H__
   54.30 +#define __XEN_PUBLIC_TRACE_H__
   54.31 +
   54.32 +/* Trace classes */
   54.33 +#define TRC_CLS_SHIFT 16
   54.34 +#define TRC_GEN     0x0001f000    /* General trace            */
   54.35 +#define TRC_SCHED   0x0002f000    /* Xen Scheduler trace      */
   54.36 +#define TRC_DOM0OP  0x0004f000    /* Xen DOM0 operation trace */
   54.37 +#define TRC_HVM     0x0008f000    /* Xen HVM trace            */
   54.38 +#define TRC_MEM     0x0010f000    /* Xen memory trace         */
   54.39 +#define TRC_ALL     0xfffff000
   54.40 +
   54.41 +/* Trace subclasses */
   54.42 +#define TRC_SUBCLS_SHIFT 12
   54.43 +
   54.44 +/* trace subclasses for SVM */
   54.45 +#define TRC_HVM_ENTRYEXIT 0x00081000   /* VMENTRY and #VMEXIT       */
   54.46 +#define TRC_HVM_HANDLER   0x00082000   /* various HVM handlers      */
   54.47 +
   54.48 +/* Trace events per class */
   54.49 +#define TRC_LOST_RECORDS        (TRC_GEN + 1)
   54.50 +
   54.51 +#define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
   54.52 +#define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)
   54.53 +#define TRC_SCHED_SLEEP         (TRC_SCHED +  3)
   54.54 +#define TRC_SCHED_WAKE          (TRC_SCHED +  4)
   54.55 +#define TRC_SCHED_YIELD         (TRC_SCHED +  5)
   54.56 +#define TRC_SCHED_BLOCK         (TRC_SCHED +  6)
   54.57 +#define TRC_SCHED_SHUTDOWN      (TRC_SCHED +  7)
   54.58 +#define TRC_SCHED_CTL           (TRC_SCHED +  8)
   54.59 +#define TRC_SCHED_ADJDOM        (TRC_SCHED +  9)
   54.60 +#define TRC_SCHED_SWITCH        (TRC_SCHED + 10)
   54.61 +#define TRC_SCHED_S_TIMER_FN    (TRC_SCHED + 11)
   54.62 +#define TRC_SCHED_T_TIMER_FN    (TRC_SCHED + 12)
   54.63 +#define TRC_SCHED_DOM_TIMER_FN  (TRC_SCHED + 13)
   54.64 +#define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED + 14)
   54.65 +#define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED + 15)
   54.66 +
   54.67 +#define TRC_MEM_PAGE_GRANT_MAP      (TRC_MEM + 1)
   54.68 +#define TRC_MEM_PAGE_GRANT_UNMAP    (TRC_MEM + 2)
   54.69 +#define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
   54.70 +
   54.71 +/* trace events per subclass */
   54.72 +#define TRC_HVM_VMENTRY         (TRC_HVM_ENTRYEXIT + 0x01)
   54.73 +#define TRC_HVM_VMEXIT          (TRC_HVM_ENTRYEXIT + 0x02)
   54.74 +#define TRC_HVM_PF_XEN          (TRC_HVM_HANDLER + 0x01)
   54.75 +#define TRC_HVM_PF_INJECT       (TRC_HVM_HANDLER + 0x02)
   54.76 +#define TRC_HVM_INJ_EXC         (TRC_HVM_HANDLER + 0x03)
   54.77 +#define TRC_HVM_INJ_VIRQ        (TRC_HVM_HANDLER + 0x04)
   54.78 +#define TRC_HVM_REINJ_VIRQ      (TRC_HVM_HANDLER + 0x05)
   54.79 +#define TRC_HVM_IO_READ         (TRC_HVM_HANDLER + 0x06)
   54.80 +#define TRC_HVM_IO_WRITE        (TRC_HVM_HANDLER + 0x07)
   54.81 +#define TRC_HVM_CR_READ         (TRC_HVM_HANDLER + 0x08)
   54.82 +#define TRC_HVM_CR_WRITE        (TRC_HVM_HANDLER + 0x09)
   54.83 +#define TRC_HVM_DR_READ         (TRC_HVM_HANDLER + 0x0A)
   54.84 +#define TRC_HVM_DR_WRITE        (TRC_HVM_HANDLER + 0x0B)
   54.85 +#define TRC_HVM_MSR_READ        (TRC_HVM_HANDLER + 0x0C)
   54.86 +#define TRC_HVM_MSR_WRITE       (TRC_HVM_HANDLER + 0x0D)
   54.87 +#define TRC_HVM_CPUID           (TRC_HVM_HANDLER + 0x0E)
   54.88 +#define TRC_HVM_INTR            (TRC_HVM_HANDLER + 0x0F)
   54.89 +#define TRC_HVM_NMI             (TRC_HVM_HANDLER + 0x10)
   54.90 +#define TRC_HVM_SMI             (TRC_HVM_HANDLER + 0x11)
   54.91 +#define TRC_HVM_VMMCALL         (TRC_HVM_HANDLER + 0x12)
   54.92 +#define TRC_HVM_HLT             (TRC_HVM_HANDLER + 0x13)
   54.93 +#define TRC_HVM_INVLPG          (TRC_HVM_HANDLER + 0x14)
   54.94 +#define TRC_HVM_MCE             (TRC_HVM_HANDLER + 0x15)
   54.95 +
   54.96 +/* This structure represents a single trace buffer record. */
   54.97 +struct t_rec {
   54.98 +    uint64_t cycles;          /* cycle counter timestamp */
   54.99 +    uint32_t event;           /* event ID                */
  54.100 +    unsigned long data[5];    /* event data items        */
  54.101 +};
  54.102 +
  54.103 +/*
  54.104 + * This structure contains the metadata for a single trace buffer.  The head
  54.105 + * field, indexes into an array of struct t_rec's.
  54.106 + */
  54.107 +struct t_buf {
  54.108 +    uint32_t cons;      /* Next item to be consumed by control tools. */
  54.109 +    uint32_t prod;      /* Next item to be produced by Xen.           */
  54.110 +    /* 'nr_recs' records follow immediately after the meta-data header.    */
  54.111 +};
  54.112 +
  54.113 +#endif /* __XEN_PUBLIC_TRACE_H__ */
  54.114 +
  54.115 +/*
  54.116 + * Local variables:
  54.117 + * mode: C
  54.118 + * c-set-style: "BSD"
  54.119 + * c-basic-offset: 4
  54.120 + * tab-width: 4
  54.121 + * indent-tabs-mode: nil
  54.122 + * End:
  54.123 + */
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/common/include/public/vcpu.h	Wed Dec 19 09:23:32 2007 +1100
    55.3 @@ -0,0 +1,192 @@
    55.4 +/******************************************************************************
    55.5 + * vcpu.h
    55.6 + * 
    55.7 + * VCPU initialisation, query, and hotplug.
    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, Keir Fraser <keir@xensource.com>
   55.28 + */
   55.29 +
   55.30 +#ifndef __XEN_PUBLIC_VCPU_H__
   55.31 +#define __XEN_PUBLIC_VCPU_H__
   55.32 +
   55.33 +/*
   55.34 + * Prototype for this hypercall is:
   55.35 + *  int vcpu_op(int cmd, int vcpuid, void *extra_args)
   55.36 + * @cmd        == VCPUOP_??? (VCPU operation).
   55.37 + * @vcpuid     == VCPU to operate on.
   55.38 + * @extra_args == Operation-specific extra arguments (NULL if none).
   55.39 + */
   55.40 +
   55.41 +/*
   55.42 + * Initialise a VCPU. Each VCPU can be initialised only once. A 
   55.43 + * newly-initialised VCPU will not run until it is brought up by VCPUOP_up.
   55.44 + * 
   55.45 + * @extra_arg == pointer to vcpu_guest_context structure containing initial
   55.46 + *               state for the VCPU.
   55.47 + */
   55.48 +#define VCPUOP_initialise            0
   55.49 +
   55.50 +/*
   55.51 + * Bring up a VCPU. This makes the VCPU runnable. This operation will fail
   55.52 + * if the VCPU has not been initialised (VCPUOP_initialise).
   55.53 + */
   55.54 +#define VCPUOP_up                    1
   55.55 +
   55.56 +/*
   55.57 + * Bring down a VCPU (i.e., make it non-runnable).
   55.58 + * There are a few caveats that callers should observe:
   55.59 + *  1. This operation may return, and VCPU_is_up may return false, before the
   55.60 + *     VCPU stops running (i.e., the command is asynchronous). It is a good
   55.61 + *     idea to ensure that the VCPU has entered a non-critical loop before
   55.62 + *     bringing it down. Alternatively, this operation is guaranteed
   55.63 + *     synchronous if invoked by the VCPU itself.
   55.64 + *  2. After a VCPU is initialised, there is currently no way to drop all its
   55.65 + *     references to domain memory. Even a VCPU that is down still holds
   55.66 + *     memory references via its pagetable base pointer and GDT. It is good
   55.67 + *     practise to move a VCPU onto an 'idle' or default page table, LDT and
   55.68 + *     GDT before bringing it down.
   55.69 + */
   55.70 +#define VCPUOP_down                  2
   55.71 +
   55.72 +/* Returns 1 if the given VCPU is up. */
   55.73 +#define VCPUOP_is_up                 3
   55.74 +
   55.75 +/*
   55.76 + * Return information about the state and running time of a VCPU.
   55.77 + * @extra_arg == pointer to vcpu_runstate_info structure.
   55.78 + */
   55.79 +#define VCPUOP_get_runstate_info     4
   55.80 +struct vcpu_runstate_info {
   55.81 +    /* VCPU's current state (RUNSTATE_*). */
   55.82 +    int      state;
   55.83 +    /* When was current state entered (system time, ns)? */
   55.84 +    uint64_t state_entry_time;
   55.85 +    /*
   55.86 +     * Time spent in each RUNSTATE_* (ns). The sum of these times is
   55.87 +     * guaranteed not to drift from system time.
   55.88 +     */
   55.89 +    uint64_t time[4];
   55.90 +};
   55.91 +typedef struct vcpu_runstate_info vcpu_runstate_info_t;
   55.92 +DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_t);
   55.93 +
   55.94 +/* VCPU is currently running on a physical CPU. */
   55.95 +#define RUNSTATE_running  0
   55.96 +
   55.97 +/* VCPU is runnable, but not currently scheduled on any physical CPU. */
   55.98 +#define RUNSTATE_runnable 1
   55.99 +
  55.100 +/* VCPU is blocked (a.k.a. idle). It is therefore not runnable. */
  55.101 +#define RUNSTATE_blocked  2
  55.102 +
  55.103 +/*
  55.104 + * VCPU is not runnable, but it is not blocked.
  55.105 + * This is a 'catch all' state for things like hotplug and pauses by the
  55.106 + * system administrator (or for critical sections in the hypervisor).
  55.107 + * RUNSTATE_blocked dominates this state (it is the preferred state).
  55.108 + */
  55.109 +#define RUNSTATE_offline  3
  55.110 +
  55.111 +/*
  55.112 + * Register a shared memory area from which the guest may obtain its own
  55.113 + * runstate information without needing to execute a hypercall.
  55.114 + * Notes:
  55.115 + *  1. The registered address may be virtual or physical or guest handle,
  55.116 + *     depending on the platform. Virtual address or guest handle should be
  55.117 + *     registered on x86 systems.
  55.118 + *  2. Only one shared area may be registered per VCPU. The shared area is
  55.119 + *     updated by the hypervisor each time the VCPU is scheduled. Thus
  55.120 + *     runstate.state will always be RUNSTATE_running and
  55.121 + *     runstate.state_entry_time will indicate the system time at which the
  55.122 + *     VCPU was last scheduled to run.
  55.123 + * @extra_arg == pointer to vcpu_register_runstate_memory_area structure.
  55.124 + */
  55.125 +#define VCPUOP_register_runstate_memory_area 5
  55.126 +struct vcpu_register_runstate_memory_area {
  55.127 +    union {
  55.128 +        XEN_GUEST_HANDLE(vcpu_runstate_info_t) h;
  55.129 +        struct vcpu_runstate_info *v;
  55.130 +        uint64_t p;
  55.131 +    } addr;
  55.132 +};
  55.133 +typedef struct vcpu_register_runstate_memory_area vcpu_register_runstate_memory_area_t;
  55.134 +DEFINE_XEN_GUEST_HANDLE(vcpu_register_runstate_memory_area_t);
  55.135 +
  55.136 +/*
  55.137 + * Set or stop a VCPU's periodic timer. Every VCPU has one periodic timer
  55.138 + * which can be set via these commands. Periods smaller than one millisecond
  55.139 + * may not be supported.
  55.140 + */
  55.141 +#define VCPUOP_set_periodic_timer    6 /* arg == vcpu_set_periodic_timer_t */
  55.142 +#define VCPUOP_stop_periodic_timer   7 /* arg == NULL */
  55.143 +struct vcpu_set_periodic_timer {
  55.144 +    uint64_t period_ns;
  55.145 +};
  55.146 +typedef struct vcpu_set_periodic_timer vcpu_set_periodic_timer_t;
  55.147 +DEFINE_XEN_GUEST_HANDLE(vcpu_set_periodic_timer_t);
  55.148 +
  55.149 +/*
  55.150 + * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
  55.151 + * timer which can be set via these commands.
  55.152 + */
  55.153 +#define VCPUOP_set_singleshot_timer  8 /* arg == vcpu_set_singleshot_timer_t */
  55.154 +#define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */
  55.155 +struct vcpu_set_singleshot_timer {
  55.156 +    uint64_t timeout_abs_ns;   /* Absolute system time value in nanoseconds. */
  55.157 +    uint32_t flags;            /* VCPU_SSHOTTMR_??? */
  55.158 +};
  55.159 +typedef struct vcpu_set_singleshot_timer vcpu_set_singleshot_timer_t;
  55.160 +DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t);
  55.161 +
  55.162 +/* Flags to VCPUOP_set_singleshot_timer. */
  55.163 + /* Require the timeout to be in the future (return -ETIME if it's passed). */
  55.164 +#define _VCPU_SSHOTTMR_future (0)
  55.165 +#define VCPU_SSHOTTMR_future  (1U << _VCPU_SSHOTTMR_future)
  55.166 +
  55.167 +/* 
  55.168 + * Register a memory location in the guest address space for the
  55.169 + * vcpu_info structure.  This allows the guest to place the vcpu_info
  55.170 + * structure in a convenient place, such as in a per-cpu data area.
  55.171 + * The pointer need not be page aligned, but the structure must not
  55.172 + * cross a page boundary.
  55.173 + *
  55.174 + * This may be called only once per vcpu.
  55.175 + */
  55.176 +#define VCPUOP_register_vcpu_info   10  /* arg == struct vcpu_info */
  55.177 +struct vcpu_register_vcpu_info {
  55.178 +    uint64_t mfn;    /* mfn of page to place vcpu_info */
  55.179 +    uint32_t offset; /* offset within page */
  55.180 +    uint32_t rsvd;   /* unused */
  55.181 +};
  55.182 +typedef struct vcpu_register_vcpu_info vcpu_register_vcpu_info_t;
  55.183 +DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t);
  55.184 +
  55.185 +#endif /* __XEN_PUBLIC_VCPU_H__ */
  55.186 +
  55.187 +/*
  55.188 + * Local variables:
  55.189 + * mode: C
  55.190 + * c-set-style: "BSD"
  55.191 + * c-basic-offset: 4
  55.192 + * tab-width: 4
  55.193 + * indent-tabs-mode: nil
  55.194 + * End:
  55.195 + */
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/common/include/public/version.h	Wed Dec 19 09:23:32 2007 +1100
    56.3 @@ -0,0 +1,91 @@
    56.4 +/******************************************************************************
    56.5 + * version.h
    56.6 + * 
    56.7 + * Xen version, type, and compile information.
    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) 2005, Nguyen Anh Quynh <aquynh@gmail.com>
   56.28 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
   56.29 + */
   56.30 +
   56.31 +#ifndef __XEN_PUBLIC_VERSION_H__
   56.32 +#define __XEN_PUBLIC_VERSION_H__
   56.33 +
   56.34 +/* NB. All ops return zero on success, except XENVER_{version,pagesize} */
   56.35 +
   56.36 +/* arg == NULL; returns major:minor (16:16). */
   56.37 +#define XENVER_version      0
   56.38 +
   56.39 +/* arg == xen_extraversion_t. */
   56.40 +#define XENVER_extraversion 1
   56.41 +typedef char xen_extraversion_t[16];
   56.42 +#define XEN_EXTRAVERSION_LEN (sizeof(xen_extraversion_t))
   56.43 +
   56.44 +/* arg == xen_compile_info_t. */
   56.45 +#define XENVER_compile_info 2
   56.46 +struct xen_compile_info {
   56.47 +    char compiler[64];
   56.48 +    char compile_by[16];
   56.49 +    char compile_domain[32];
   56.50 +    char compile_date[32];
   56.51 +};
   56.52 +typedef struct xen_compile_info xen_compile_info_t;
   56.53 +
   56.54 +#define XENVER_capabilities 3
   56.55 +typedef char xen_capabilities_info_t[1024];
   56.56 +#define XEN_CAPABILITIES_INFO_LEN (sizeof(xen_capabilities_info_t))
   56.57 +
   56.58 +#define XENVER_changeset 4
   56.59 +typedef char xen_changeset_info_t[64];
   56.60 +#define XEN_CHANGESET_INFO_LEN (sizeof(xen_changeset_info_t))
   56.61 +
   56.62 +#define XENVER_platform_parameters 5
   56.63 +struct xen_platform_parameters {
   56.64 +    unsigned long virt_start;
   56.65 +};
   56.66 +typedef struct xen_platform_parameters xen_platform_parameters_t;
   56.67 +
   56.68 +#define XENVER_get_features 6
   56.69 +struct xen_feature_info {
   56.70 +    unsigned int submap_idx;    /* IN: which 32-bit submap to return */
   56.71 +    uint32_t     submap;        /* OUT: 32-bit submap */
   56.72 +};
   56.73 +typedef struct xen_feature_info xen_feature_info_t;
   56.74 +
   56.75 +/* Declares the features reported by XENVER_get_features. */
   56.76 +#include "features.h"
   56.77 +
   56.78 +/* arg == NULL; returns host memory page size. */
   56.79 +#define XENVER_pagesize 7
   56.80 +
   56.81 +/* arg == xen_domain_handle_t. */
   56.82 +#define XENVER_guest_handle 8
   56.83 +
   56.84 +#endif /* __XEN_PUBLIC_VERSION_H__ */
   56.85 +
   56.86 +/*
   56.87 + * Local variables:
   56.88 + * mode: C
   56.89 + * c-set-style: "BSD"
   56.90 + * c-basic-offset: 4
   56.91 + * tab-width: 4
   56.92 + * indent-tabs-mode: nil
   56.93 + * End:
   56.94 + */
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/common/include/public/xen-compat.h	Wed Dec 19 09:23:32 2007 +1100
    57.3 @@ -0,0 +1,51 @@
    57.4 +/******************************************************************************
    57.5 + * xen-compat.h
    57.6 + * 
    57.7 + * Guest OS interface to Xen.  Compatibility layer.
    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) 2006, Christian Limpach
   57.28 + */
   57.29 +
   57.30 +#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
   57.31 +#define __XEN_PUBLIC_XEN_COMPAT_H__
   57.32 +
   57.33 +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030205
   57.34 +
   57.35 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
   57.36 +/* Xen is built with matching headers and implements the latest interface. */
   57.37 +#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__
   57.38 +#elif !defined(__XEN_INTERFACE_VERSION__)
   57.39 +/* Guests which do not specify a version get the legacy interface. */
   57.40 +#define __XEN_INTERFACE_VERSION__ 0x00000000
   57.41 +#endif
   57.42 +
   57.43 +#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__
   57.44 +#error "These header files do not support the requested interface version."
   57.45 +#endif
   57.46 +
   57.47 +/* Fields defined as a Xen guest handle since 0x00030205. */
   57.48 +#if __XEN_INTERFACE_VERSION__ >= 0x00030205
   57.49 +#define XEN_GUEST_HANDLE_00030205(type) XEN_GUEST_HANDLE(type)
   57.50 +#else
   57.51 +#define XEN_GUEST_HANDLE_00030205(type) type *
   57.52 +#endif
   57.53 +
   57.54 +#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/common/include/public/xen.h	Wed Dec 19 09:23:32 2007 +1100
    58.3 @@ -0,0 +1,612 @@
    58.4 +/******************************************************************************
    58.5 + * xen.h
    58.6 + * 
    58.7 + * Guest OS interface to Xen.
    58.8 + * 
    58.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   58.10 + * of this software and associated documentation files (the "Software"), to
   58.11 + * deal in the Software without restriction, including without limitation the
   58.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   58.13 + * sell copies of the Software, and to permit persons to whom the Software is
   58.14 + * furnished to do so, subject to the following conditions:
   58.15 + *
   58.16 + * The above copyright notice and this permission notice shall be included in
   58.17 + * all copies or substantial portions of the Software.
   58.18 + *
   58.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   58.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   58.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   58.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   58.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   58.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   58.25 + * DEALINGS IN THE SOFTWARE.
   58.26 + *
   58.27 + * Copyright (c) 2004, K A Fraser
   58.28 + */
   58.29 +
   58.30 +#ifndef __XEN_PUBLIC_XEN_H__
   58.31 +#define __XEN_PUBLIC_XEN_H__
   58.32 +
   58.33 +#include "xen-compat.h"
   58.34 +
   58.35 +#if defined(__i386__) || defined(__x86_64__)
   58.36 +#include "arch-x86/xen.h"
   58.37 +#elif defined(__ia64__)
   58.38 +#include "arch-ia64.h"
   58.39 +#elif defined(__powerpc__)
   58.40 +#include "arch-powerpc.h"
   58.41 +#else
   58.42 +#error "Unsupported architecture"
   58.43 +#endif
   58.44 +
   58.45 +/*
   58.46 + * HYPERCALLS
   58.47 + */
   58.48 +
   58.49 +#define __HYPERVISOR_set_trap_table        0
   58.50 +#define __HYPERVISOR_mmu_update            1
   58.51 +#define __HYPERVISOR_set_gdt               2
   58.52 +#define __HYPERVISOR_stack_switch          3
   58.53 +#define __HYPERVISOR_set_callbacks         4
   58.54 +#define __HYPERVISOR_fpu_taskswitch        5
   58.55 +#define __HYPERVISOR_sched_op_compat       6 /* compat since 0x00030101 */
   58.56 +#define __HYPERVISOR_platform_op           7
   58.57 +#define __HYPERVISOR_set_debugreg          8
   58.58 +#define __HYPERVISOR_get_debugreg          9
   58.59 +#define __HYPERVISOR_update_descriptor    10
   58.60 +#define __HYPERVISOR_memory_op            12
   58.61 +#define __HYPERVISOR_multicall            13
   58.62 +#define __HYPERVISOR_update_va_mapping    14
   58.63 +#define __HYPERVISOR_set_timer_op         15
   58.64 +#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
   58.65 +#define __HYPERVISOR_xen_version          17
   58.66 +#define __HYPERVISOR_console_io           18
   58.67 +#define __HYPERVISOR_physdev_op_compat    19 /* compat since 0x00030202 */
   58.68 +#define __HYPERVISOR_grant_table_op       20
   58.69 +#define __HYPERVISOR_vm_assist            21
   58.70 +#define __HYPERVISOR_update_va_mapping_otherdomain 22
   58.71 +#define __HYPERVISOR_iret                 23 /* x86 only */
   58.72 +#define __HYPERVISOR_vcpu_op              24
   58.73 +#define __HYPERVISOR_set_segment_base     25 /* x86/64 only */
   58.74 +#define __HYPERVISOR_mmuext_op            26
   58.75 +#define __HYPERVISOR_acm_op               27
   58.76 +#define __HYPERVISOR_nmi_op               28
   58.77 +#define __HYPERVISOR_sched_op             29
   58.78 +#define __HYPERVISOR_callback_op          30
   58.79 +#define __HYPERVISOR_xenoprof_op          31
   58.80 +#define __HYPERVISOR_event_channel_op     32
   58.81 +#define __HYPERVISOR_physdev_op           33
   58.82 +#define __HYPERVISOR_hvm_op               34
   58.83 +#define __HYPERVISOR_sysctl               35
   58.84 +#define __HYPERVISOR_domctl               36
   58.85 +#define __HYPERVISOR_kexec_op             37
   58.86 +
   58.87 +/* Architecture-specific hypercall definitions. */
   58.88 +#define __HYPERVISOR_arch_0               48
   58.89 +#define __HYPERVISOR_arch_1               49
   58.90 +#define __HYPERVISOR_arch_2               50
   58.91 +#define __HYPERVISOR_arch_3               51
   58.92 +#define __HYPERVISOR_arch_4               52
   58.93 +#define __HYPERVISOR_arch_5               53
   58.94 +#define __HYPERVISOR_arch_6               54
   58.95 +#define __HYPERVISOR_arch_7               55
   58.96 +
   58.97 +/*
   58.98 + * HYPERCALL COMPATIBILITY.
   58.99 + */
  58.100 +
  58.101 +/* New sched_op hypercall introduced in 0x00030101. */
  58.102 +#if __XEN_INTERFACE_VERSION__ < 0x00030101
  58.103 +#undef __HYPERVISOR_sched_op
  58.104 +#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
  58.105 +#endif
  58.106 +
  58.107 +/* New event-channel and physdev hypercalls introduced in 0x00030202. */
  58.108 +#if __XEN_INTERFACE_VERSION__ < 0x00030202
  58.109 +#undef __HYPERVISOR_event_channel_op
  58.110 +#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
  58.111 +#undef __HYPERVISOR_physdev_op
  58.112 +#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
  58.113 +#endif
  58.114 +
  58.115 +/* New platform_op hypercall introduced in 0x00030204. */
  58.116 +#if __XEN_INTERFACE_VERSION__ < 0x00030204
  58.117 +#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
  58.118 +#endif
  58.119 +
  58.120 +/* 
  58.121 + * VIRTUAL INTERRUPTS
  58.122 + * 
  58.123 + * Virtual interrupts that a guest OS may receive from Xen.
  58.124 + * 
  58.125 + * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
  58.126 + * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
  58.127 + * The latter can be allocated only once per guest: they must initially be
  58.128 + * allocated to VCPU0 but can subsequently be re-bound.
  58.129 + */
  58.130 +#define VIRQ_TIMER      0  /* V. Timebase update, and/or requested timeout.  */
  58.131 +#define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
  58.132 +#define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
  58.133 +#define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
  58.134 +#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
  58.135 +#define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
  58.136 +#define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
  58.137 +#define VIRQ_CON_RING   8  /* G. (DOM0) Bytes received on console            */
  58.138 +
  58.139 +/* Architecture-specific VIRQ definitions. */
  58.140 +#define VIRQ_ARCH_0    16
  58.141 +#define VIRQ_ARCH_1    17
  58.142 +#define VIRQ_ARCH_2    18
  58.143 +#define VIRQ_ARCH_3    19
  58.144 +#define VIRQ_ARCH_4    20
  58.145 +#define VIRQ_ARCH_5    21
  58.146 +#define VIRQ_ARCH_6    22
  58.147 +#define VIRQ_ARCH_7    23
  58.148 +
  58.149 +#define NR_VIRQS       24
  58.150 +
  58.151 +/*
  58.152 + * MMU-UPDATE REQUESTS
  58.153 + * 
  58.154 + * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
  58.155 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
  58.156 + * Where the FD has some effect, it is described below.
  58.157 + * ptr[1:0] specifies the appropriate MMU_* command.
  58.158 + * 
  58.159 + * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
  58.160 + * Updates an entry in a page table. If updating an L1 table, and the new
  58.161 + * table entry is valid/present, the mapped frame must belong to the FD, if
  58.162 + * an FD has been specified. If attempting to map an I/O page then the
  58.163 + * caller assumes the privilege of the FD.
  58.164 + * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
  58.165 + * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
  58.166 + * ptr[:2]  -- Machine address of the page-table entry to modify.
  58.167 + * val      -- Value to write.
  58.168 + * 
  58.169 + * ptr[1:0] == MMU_MACHPHYS_UPDATE:
  58.170 + * Updates an entry in the machine->pseudo-physical mapping table.
  58.171 + * ptr[:2]  -- Machine address within the frame whose mapping to modify.
  58.172 + *             The frame must belong to the FD, if one is specified.
  58.173 + * val      -- Value to write into the mapping entry.
  58.174 + */
  58.175 +#define MMU_NORMAL_PT_UPDATE     0 /* checked '*ptr = val'. ptr is MA.       */
  58.176 +#define MMU_MACHPHYS_UPDATE      1 /* ptr = MA of frame to modify entry for  */
  58.177 +
  58.178 +/*
  58.179 + * MMU EXTENDED OPERATIONS
  58.180 + * 
  58.181 + * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
  58.182 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
  58.183 + * Where the FD has some effect, it is described below.
  58.184 + * 
  58.185 + * cmd: MMUEXT_(UN)PIN_*_TABLE
  58.186 + * mfn: Machine frame number to be (un)pinned as a p.t. page.
  58.187 + *      The frame must belong to the FD, if one is specified.
  58.188 + * 
  58.189 + * cmd: MMUEXT_NEW_BASEPTR
  58.190 + * mfn: Machine frame number of new page-table base to install in MMU.
  58.191 + * 
  58.192 + * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
  58.193 + * mfn: Machine frame number of new page-table base to install in MMU
  58.194 + *      when in user space.
  58.195 + * 
  58.196 + * cmd: MMUEXT_TLB_FLUSH_LOCAL
  58.197 + * No additional arguments. Flushes local TLB.
  58.198 + * 
  58.199 + * cmd: MMUEXT_INVLPG_LOCAL
  58.200 + * linear_addr: Linear address to be flushed from the local TLB.
  58.201 + * 
  58.202 + * cmd: MMUEXT_TLB_FLUSH_MULTI
  58.203 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  58.204 + * 
  58.205 + * cmd: MMUEXT_INVLPG_MULTI
  58.206 + * linear_addr: Linear address to be flushed.
  58.207 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  58.208 + * 
  58.209 + * cmd: MMUEXT_TLB_FLUSH_ALL
  58.210 + * No additional arguments. Flushes all VCPUs' TLBs.
  58.211 + * 
  58.212 + * cmd: MMUEXT_INVLPG_ALL
  58.213 + * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
  58.214 + * 
  58.215 + * cmd: MMUEXT_FLUSH_CACHE
  58.216 + * No additional arguments. Writes back and flushes cache contents.
  58.217 + * 
  58.218 + * cmd: MMUEXT_SET_LDT
  58.219 + * linear_addr: Linear address of LDT base (NB. must be page-aligned).
  58.220 + * nr_ents: Number of entries in LDT.
  58.221 + */
  58.222 +#define MMUEXT_PIN_L1_TABLE      0
  58.223 +#define MMUEXT_PIN_L2_TABLE      1
  58.224 +#define MMUEXT_PIN_L3_TABLE      2
  58.225 +#define MMUEXT_PIN_L4_TABLE      3
  58.226 +#define MMUEXT_UNPIN_TABLE       4
  58.227 +#define MMUEXT_NEW_BASEPTR       5
  58.228 +#define MMUEXT_TLB_FLUSH_LOCAL   6
  58.229 +#define MMUEXT_INVLPG_LOCAL      7
  58.230 +#define MMUEXT_TLB_FLUSH_MULTI   8
  58.231 +#define MMUEXT_INVLPG_MULTI      9
  58.232 +#define MMUEXT_TLB_FLUSH_ALL    10
  58.233 +#define MMUEXT_INVLPG_ALL       11
  58.234 +#define MMUEXT_FLUSH_CACHE      12
  58.235 +#define MMUEXT_SET_LDT          13
  58.236 +#define MMUEXT_NEW_USER_BASEPTR 15
  58.237 +
  58.238 +#ifndef __ASSEMBLY__
  58.239 +struct mmuext_op {
  58.240 +    unsigned int cmd;
  58.241 +    union {
  58.242 +        /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
  58.243 +        xen_pfn_t     mfn;
  58.244 +        /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
  58.245 +        unsigned long linear_addr;
  58.246 +    } arg1;
  58.247 +    union {
  58.248 +        /* SET_LDT */
  58.249 +        unsigned int nr_ents;
  58.250 +        /* TLB_FLUSH_MULTI, INVLPG_MULTI */
  58.251 +        XEN_GUEST_HANDLE_00030205(void) vcpumask;
  58.252 +    } arg2;
  58.253 +};
  58.254 +typedef struct mmuext_op mmuext_op_t;
  58.255 +DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
  58.256 +#endif
  58.257 +
  58.258 +/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
  58.259 +/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap.   */
  58.260 +/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer.         */
  58.261 +#define UVMF_NONE               (0UL<<0) /* No flushing at all.   */
  58.262 +#define UVMF_TLB_FLUSH          (1UL<<0) /* Flush entire TLB(s).  */
  58.263 +#define UVMF_INVLPG             (2UL<<0) /* Flush only one entry. */
  58.264 +#define UVMF_FLUSHTYPE_MASK     (3UL<<0)
  58.265 +#define UVMF_MULTI              (0UL<<2) /* Flush subset of TLBs. */
  58.266 +#define UVMF_LOCAL              (0UL<<2) /* Flush local TLB.      */
  58.267 +#define UVMF_ALL                (1UL<<2) /* Flush all TLBs.       */
  58.268 +
  58.269 +/*
  58.270 + * Commands to HYPERVISOR_console_io().
  58.271 + */
  58.272 +#define CONSOLEIO_write         0
  58.273 +#define CONSOLEIO_read          1
  58.274 +
  58.275 +/*
  58.276 + * Commands to HYPERVISOR_vm_assist().
  58.277 + */
  58.278 +#define VMASST_CMD_enable                0
  58.279 +#define VMASST_CMD_disable               1
  58.280 +
  58.281 +/* x86/32 guests: simulate full 4GB segment limits. */
  58.282 +#define VMASST_TYPE_4gb_segments         0
  58.283 +
  58.284 +/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
  58.285 +#define VMASST_TYPE_4gb_segments_notify  1
  58.286 +
  58.287 +/*
  58.288 + * x86 guests: support writes to bottom-level PTEs.
  58.289 + * NB1. Page-directory entries cannot be written.
  58.290 + * NB2. Guest must continue to remove all writable mappings of PTEs.
  58.291 + */
  58.292 +#define VMASST_TYPE_writable_pagetables  2
  58.293 +
  58.294 +/* x86/PAE guests: support PDPTs above 4GB. */
  58.295 +#define VMASST_TYPE_pae_extended_cr3     3
  58.296 +
  58.297 +#define MAX_VMASST_TYPE                  3
  58.298 +
  58.299 +#ifndef __ASSEMBLY__
  58.300 +
  58.301 +typedef uint16_t domid_t;
  58.302 +
  58.303 +/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
  58.304 +#define DOMID_FIRST_RESERVED (0x7FF0U)
  58.305 +
  58.306 +/* DOMID_SELF is used in certain contexts to refer to oneself. */
  58.307 +#define DOMID_SELF (0x7FF0U)
  58.308 +
  58.309 +/*
  58.310 + * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
  58.311 + * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
  58.312 + * is useful to ensure that no mappings to the OS's own heap are accidentally
  58.313 + * installed. (e.g., in Linux this could cause havoc as reference counts
  58.314 + * aren't adjusted on the I/O-mapping code path).
  58.315 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
  58.316 + * be specified by any calling domain.
  58.317 + */
  58.318 +#define DOMID_IO   (0x7FF1U)
  58.319 +
  58.320 +/*
  58.321 + * DOMID_XEN is used to allow privileged domains to map restricted parts of
  58.322 + * Xen's heap space (e.g., the machine_to_phys table).
  58.323 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
  58.324 + * the caller is privileged.
  58.325 + */
  58.326 +#define DOMID_XEN  (0x7FF2U)
  58.327 +
  58.328 +/*
  58.329 + * Send an array of these to HYPERVISOR_mmu_update().
  58.330 + * NB. The fields are natural pointer/address size for this architecture.
  58.331 + */
  58.332 +struct mmu_update {
  58.333 +    uint64_t ptr;       /* Machine address of PTE. */
  58.334 +    uint64_t val;       /* New contents of PTE.    */
  58.335 +};
  58.336 +typedef struct mmu_update mmu_update_t;
  58.337 +DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
  58.338 +
  58.339 +/*
  58.340 + * Send an array of these to HYPERVISOR_multicall().
  58.341 + * NB. The fields are natural register size for this architecture.
  58.342 + */
  58.343 +struct multicall_entry {
  58.344 +    unsigned long op, result;
  58.345 +    unsigned long args[6];
  58.346 +};
  58.347 +typedef struct multicall_entry multicall_entry_t;
  58.348 +DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
  58.349 +
  58.350 +/*
  58.351 + * Event channel endpoints per domain:
  58.352 + *  1024 if a long is 32 bits; 4096 if a long is 64 bits.
  58.353 + */
  58.354 +#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)
  58.355 +
  58.356 +struct vcpu_time_info {
  58.357 +    /*
  58.358 +     * Updates to the following values are preceded and followed by an
  58.359 +     * increment of 'version'. The guest can therefore detect updates by
  58.360 +     * looking for changes to 'version'. If the least-significant bit of
  58.361 +     * the version number is set then an update is in progress and the guest
  58.362 +     * must wait to read a consistent set of values.
  58.363 +     * The correct way to interact with the version number is similar to
  58.364 +     * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
  58.365 +     */
  58.366 +    uint32_t version;
  58.367 +    uint32_t pad0;
  58.368 +    uint64_t tsc_timestamp;   /* TSC at last update of time vals.  */
  58.369 +    uint64_t system_time;     /* Time, in nanosecs, since boot.    */
  58.370 +    /*
  58.371 +     * Current system time:
  58.372 +     *   system_time +
  58.373 +     *   ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
  58.374 +     * CPU frequency (Hz):
  58.375 +     *   ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
  58.376 +     */
  58.377 +    uint32_t tsc_to_system_mul;
  58.378 +    int8_t   tsc_shift;
  58.379 +    int8_t   pad1[3];
  58.380 +}; /* 32 bytes */
  58.381 +typedef struct vcpu_time_info vcpu_time_info_t;
  58.382 +
  58.383 +struct vcpu_info {
  58.384 +    /*
  58.385 +     * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
  58.386 +     * a pending notification for a particular VCPU. It is then cleared 
  58.387 +     * by the guest OS /before/ checking for pending work, thus avoiding
  58.388 +     * a set-and-check race. Note that the mask is only accessed by Xen
  58.389 +     * on the CPU that is currently hosting the VCPU. This means that the
  58.390 +     * pending and mask flags can be updated by the guest without special
  58.391 +     * synchronisation (i.e., no need for the x86 LOCK prefix).
  58.392 +     * This may seem suboptimal because if the pending flag is set by
  58.393 +     * a different CPU then an IPI may be scheduled even when the mask
  58.394 +     * is set. However, note:
  58.395 +     *  1. The task of 'interrupt holdoff' is covered by the per-event-
  58.396 +     *     channel mask bits. A 'noisy' event that is continually being
  58.397 +     *     triggered can be masked at source at this very precise
  58.398 +     *     granularity.
  58.399 +     *  2. The main purpose of the per-VCPU mask is therefore to restrict
  58.400 +     *     reentrant execution: whether for concurrency control, or to
  58.401 +     *     prevent unbounded stack usage. Whatever the purpose, we expect
  58.402 +     *     that the mask will be asserted only for short periods at a time,
  58.403 +     *     and so the likelihood of a 'spurious' IPI is suitably small.
  58.404 +     * The mask is read before making an event upcall to the guest: a
  58.405 +     * non-zero mask therefore guarantees that the VCPU will not receive
  58.406 +     * an upcall activation. The mask is cleared when the VCPU requests
  58.407 +     * to block: this avoids wakeup-waiting races.
  58.408 +     */
  58.409 +    uint8_t evtchn_upcall_pending;
  58.410 +    uint8_t evtchn_upcall_mask;
  58.411 +    unsigned long evtchn_pending_sel;
  58.412 +    struct arch_vcpu_info arch;
  58.413 +    struct vcpu_time_info time;
  58.414 +}; /* 64 bytes (x86) */
  58.415 +#ifndef __XEN__
  58.416 +typedef struct vcpu_info vcpu_info_t;
  58.417 +#endif
  58.418 +
  58.419 +/*
  58.420 + * Xen/kernel shared data -- pointer provided in start_info.
  58.421 + *
  58.422 + * This structure is defined to be both smaller than a page, and the
  58.423 + * only data on the shared page, but may vary in actual size even within
  58.424 + * compatible Xen versions; guests should not rely on the size
  58.425 + * of this structure remaining constant.
  58.426 + */
  58.427 +struct shared_info {
  58.428 +    struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
  58.429 +
  58.430 +    /*
  58.431 +     * A domain can create "event channels" on which it can send and receive
  58.432 +     * asynchronous event notifications. There are three classes of event that
  58.433 +     * are delivered by this mechanism:
  58.434 +     *  1. Bi-directional inter- and intra-domain connections. Domains must
  58.435 +     *     arrange out-of-band to set up a connection (usually by allocating
  58.436 +     *     an unbound 'listener' port and avertising that via a storage service
  58.437 +     *     such as xenstore).
  58.438 +     *  2. Physical interrupts. A domain with suitable hardware-access
  58.439 +     *     privileges can bind an event-channel port to a physical interrupt
  58.440 +     *     source.
  58.441 +     *  3. Virtual interrupts ('events'). A domain can bind an event-channel
  58.442 +     *     port to a virtual interrupt source, such as the virtual-timer
  58.443 +     *     device or the emergency console.
  58.444 +     * 
  58.445 +     * Event channels are addressed by a "port index". Each channel is
  58.446 +     * associated with two bits of information:
  58.447 +     *  1. PENDING -- notifies the domain that there is a pending notification
  58.448 +     *     to be processed. This bit is cleared by the guest.
  58.449 +     *  2. MASK -- if this bit is clear then a 0->1 transition of PENDING
  58.450 +     *     will cause an asynchronous upcall to be scheduled. This bit is only
  58.451 +     *     updated by the guest. It is read-only within Xen. If a channel
  58.452 +     *     becomes pending while the channel is masked then the 'edge' is lost
  58.453 +     *     (i.e., when the channel is unmasked, the guest must manually handle
  58.454 +     *     pending notifications as no upcall will be scheduled by Xen).
  58.455 +     * 
  58.456 +     * To expedite scanning of pending notifications, any 0->1 pending
  58.457 +     * transition on an unmasked channel causes a corresponding bit in a
  58.458 +     * per-vcpu selector word to be set. Each bit in the selector covers a
  58.459 +     * 'C long' in the PENDING bitfield array.
  58.460 +     */
  58.461 +    unsigned long evtchn_pending[sizeof(unsigned long) * 8];
  58.462 +    unsigned long evtchn_mask[sizeof(unsigned long) * 8];
  58.463 +
  58.464 +    /*
  58.465 +     * Wallclock time: updated only by control software. Guests should base
  58.466 +     * their gettimeofday() syscall on this wallclock-base value.
  58.467 +     */
  58.468 +    uint32_t wc_version;      /* Version counter: see vcpu_time_info_t. */
  58.469 +    uint32_t wc_sec;          /* Secs  00:00:00 UTC, Jan 1, 1970.  */
  58.470 +    uint32_t wc_nsec;         /* Nsecs 00:00:00 UTC, Jan 1, 1970.  */
  58.471 +
  58.472 +    struct arch_shared_info arch;
  58.473 +
  58.474 +};
  58.475 +#ifndef __XEN__
  58.476 +typedef struct shared_info shared_info_t;
  58.477 +#endif
  58.478 +
  58.479 +/*
  58.480 + * Start-of-day memory layout:
  58.481 + *  1. The domain is started within contiguous virtual-memory region.
  58.482 + *  2. The contiguous region ends on an aligned 4MB boundary.
  58.483 + *  3. This the order of bootstrap elements in the initial virtual region:
  58.484 + *      a. relocated kernel image
  58.485 + *      b. initial ram disk              [mod_start, mod_len]
  58.486 + *      c. list of allocated page frames [mfn_list, nr_pages]
  58.487 + *      d. start_info_t structure        [register ESI (x86)]
  58.488 + *      e. bootstrap page tables         [pt_base, CR3 (x86)]
  58.489 + *      f. bootstrap stack               [register ESP (x86)]
  58.490 + *  4. Bootstrap elements are packed together, but each is 4kB-aligned.
  58.491 + *  5. The initial ram disk may be omitted.
  58.492 + *  6. The list of page frames forms a contiguous 'pseudo-physical' memory
  58.493 + *     layout for the domain. In particular, the bootstrap virtual-memory
  58.494 + *     region is a 1:1 mapping to the first section of the pseudo-physical map.
  58.495 + *  7. All bootstrap elements are mapped read-writable for the guest OS. The
  58.496 + *     only exception is the bootstrap page table, which is mapped read-only.
  58.497 + *  8. There is guaranteed to be at least 512kB padding after the final
  58.498 + *     bootstrap element. If necessary, the bootstrap virtual region is
  58.499 + *     extended by an extra 4MB to ensure this.
  58.500 + */
  58.501 +
  58.502 +#define MAX_GUEST_CMDLINE 1024
  58.503 +struct start_info {
  58.504 +    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.    */
  58.505 +    char magic[32];             /* "xen-<version>-<platform>".            */
  58.506 +    unsigned long nr_pages;     /* Total pages allocated to this domain.  */
  58.507 +    unsigned long shared_info;  /* MACHINE address of shared info struct. */
  58.508 +    uint32_t flags;             /* SIF_xxx flags.                         */
  58.509 +    xen_pfn_t store_mfn;        /* MACHINE page number of shared page.    */
  58.510 +    uint32_t store_evtchn;      /* Event channel for store communication. */
  58.511 +    union {
  58.512 +        struct {
  58.513 +            xen_pfn_t mfn;      /* MACHINE page number of console page.   */
  58.514 +            uint32_t  evtchn;   /* Event channel for console page.        */
  58.515 +        } domU;
  58.516 +        struct {
  58.517 +            uint32_t info_off;  /* Offset of console_info struct.         */
  58.518 +            uint32_t info_size; /* Size of console_info struct from start.*/
  58.519 +        } dom0;
  58.520 +    } console;
  58.521 +    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
  58.522 +    unsigned long pt_base;      /* VIRTUAL address of page directory.     */
  58.523 +    unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames.       */
  58.524 +    unsigned long mfn_list;     /* VIRTUAL address of page-frame list.    */
  58.525 +    unsigned long mod_start;    /* VIRTUAL address of pre-loaded module.  */
  58.526 +    unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
  58.527 +    int8_t cmd_line[MAX_GUEST_CMDLINE];
  58.528 +};
  58.529 +typedef struct start_info start_info_t;
  58.530 +
  58.531 +/* New console union for dom0 introduced in 0x00030203. */
  58.532 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
  58.533 +#define console_mfn    console.domU.mfn
  58.534 +#define console_evtchn console.domU.evtchn
  58.535 +#endif
  58.536 +
  58.537 +/* These flags are passed in the 'flags' field of start_info_t. */
  58.538 +#define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
  58.539 +#define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
  58.540 +
  58.541 +typedef struct dom0_vga_console_info {
  58.542 +    uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
  58.543 +#define XEN_VGATYPE_TEXT_MODE_3 0x03
  58.544 +#define XEN_VGATYPE_VESA_LFB    0x23
  58.545 +
  58.546 +    union {
  58.547 +        struct {
  58.548 +            /* Font height, in pixels. */
  58.549 +            uint16_t font_height;
  58.550 +            /* Cursor location (column, row). */
  58.551 +            uint16_t cursor_x, cursor_y;
  58.552 +            /* Number of rows and columns (dimensions in characters). */
  58.553 +            uint16_t rows, columns;
  58.554 +        } text_mode_3;
  58.555 +
  58.556 +        struct {
  58.557 +            /* Width and height, in pixels. */
  58.558 +            uint16_t width, height;
  58.559 +            /* Bytes per scan line. */
  58.560 +            uint16_t bytes_per_line;
  58.561 +            /* Bits per pixel. */
  58.562 +            uint16_t bits_per_pixel;
  58.563 +            /* LFB physical address, and size (in units of 64kB). */
  58.564 +            uint32_t lfb_base;
  58.565 +            uint32_t lfb_size;
  58.566 +            /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
  58.567 +            uint8_t  red_pos, red_size;
  58.568 +            uint8_t  green_pos, green_size;
  58.569 +            uint8_t  blue_pos, blue_size;
  58.570 +            uint8_t  rsvd_pos, rsvd_size;
  58.571 +        } vesa_lfb;
  58.572 +    } u;
  58.573 +} dom0_vga_console_info_t;
  58.574 +#define xen_vga_console_info dom0_vga_console_info
  58.575 +#define xen_vga_console_info_t dom0_vga_console_info_t
  58.576 +
  58.577 +typedef uint8_t xen_domain_handle_t[16];
  58.578 +
  58.579 +/* Turn a plain number into a C unsigned long constant. */
  58.580 +#define __mk_unsigned_long(x) x ## UL
  58.581 +#define mk_unsigned_long(x) __mk_unsigned_long(x)
  58.582 +
  58.583 +DEFINE_XEN_GUEST_HANDLE(uint8_t);
  58.584 +DEFINE_XEN_GUEST_HANDLE(uint16_t);
  58.585 +DEFINE_XEN_GUEST_HANDLE(uint32_t);
  58.586 +DEFINE_XEN_GUEST_HANDLE(uint64_t);
  58.587 +
  58.588 +#else /* __ASSEMBLY__ */
  58.589 +
  58.590 +/* In assembly code we cannot use C numeric constant suffixes. */
  58.591 +#define mk_unsigned_long(x) x
  58.592 +
  58.593 +#endif /* !__ASSEMBLY__ */
  58.594 +
  58.595 +/* Default definitions for macros used by domctl/sysctl. */
  58.596 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
  58.597 +#ifndef uint64_aligned_t
  58.598 +#define uint64_aligned_t uint64_t
  58.599 +#endif
  58.600 +#ifndef XEN_GUEST_HANDLE_64
  58.601 +#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
  58.602 +#endif
  58.603 +#endif
  58.604 +
  58.605 +#endif /* __XEN_PUBLIC_XEN_H__ */
  58.606 +
  58.607 +/*
  58.608 + * Local variables:
  58.609 + * mode: C
  58.610 + * c-set-style: "BSD"
  58.611 + * c-basic-offset: 4
  58.612 + * tab-width: 4
  58.613 + * indent-tabs-mode: nil
  58.614 + * End:
  58.615 + */
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/common/include/public/xencomm.h	Wed Dec 19 09:23:32 2007 +1100
    59.3 @@ -0,0 +1,41 @@
    59.4 +/*
    59.5 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    59.6 + * of this software and associated documentation files (the "Software"), to
    59.7 + * deal in the Software without restriction, including without limitation the
    59.8 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    59.9 + * sell copies of the Software, and to permit persons to whom the Software is
   59.10 + * furnished to do so, subject to the following conditions:
   59.11 + *
   59.12 + * The above copyright notice and this permission notice shall be included in
   59.13 + * all copies or substantial portions of the Software.
   59.14 + *
   59.15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   59.16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   59.17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   59.18 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   59.19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   59.20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   59.21 + * DEALINGS IN THE SOFTWARE.
   59.22 + *
   59.23 + * Copyright (C) IBM Corp. 2006
   59.24 + */
   59.25 +
   59.26 +#ifndef _XEN_XENCOMM_H_
   59.27 +#define _XEN_XENCOMM_H_
   59.28 +
   59.29 +/* A xencomm descriptor is a scatter/gather list containing physical
   59.30 + * addresses corresponding to a virtually contiguous memory area. The
   59.31 + * hypervisor translates these physical addresses to machine addresses to copy
   59.32 + * to and from the virtually contiguous area.
   59.33 + */
   59.34 +
   59.35 +#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
   59.36 +#define XENCOMM_INVALID (~0UL)
   59.37 +
   59.38 +struct xencomm_desc {
   59.39 +    uint32_t magic;
   59.40 +    uint32_t nr_addrs; /* the number of entries in address[] */
   59.41 +    uint64_t address[0];
   59.42 +};
   59.43 +
   59.44 +#endif /* _XEN_XENCOMM_H_ */
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/common/include/public/xenoprof.h	Wed Dec 19 09:23:32 2007 +1100
    60.3 @@ -0,0 +1,138 @@
    60.4 +/******************************************************************************
    60.5 + * xenoprof.h
    60.6 + * 
    60.7 + * Interface for enabling system wide profiling based on hardware performance
    60.8 + * counters
    60.9 + * 
   60.10 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   60.11 + * of this software and associated documentation files (the "Software"), to
   60.12 + * deal in the Software without restriction, including without limitation the
   60.13 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   60.14 + * sell copies of the Software, and to permit persons to whom the Software is
   60.15 + * furnished to do so, subject to the following conditions:
   60.16 + *
   60.17 + * The above copyright notice and this permission notice shall be included in
   60.18 + * all copies or substantial portions of the Software.
   60.19 + *
   60.20 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   60.21 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   60.22 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   60.23 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   60.24 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   60.25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   60.26 + * DEALINGS IN THE SOFTWARE.
   60.27 + *
   60.28 + * Copyright (C) 2005 Hewlett-Packard Co.
   60.29 + * Written by Aravind Menon & Jose Renato Santos
   60.30 + */
   60.31 +
   60.32 +#ifndef __XEN_PUBLIC_XENOPROF_H__
   60.33 +#define __XEN_PUBLIC_XENOPROF_H__
   60.34 +
   60.35 +#include "xen.h"
   60.36 +
   60.37 +/*
   60.38 + * Commands to HYPERVISOR_xenoprof_op().
   60.39 + */
   60.40 +#define XENOPROF_init                0
   60.41 +#define XENOPROF_reset_active_list   1
   60.42 +#define XENOPROF_reset_passive_list  2
   60.43 +#define XENOPROF_set_active          3
   60.44 +#define XENOPROF_set_passive         4
   60.45 +#define XENOPROF_reserve_counters    5
   60.46 +#define XENOPROF_counter             6
   60.47 +#define XENOPROF_setup_events        7
   60.48 +#define XENOPROF_enable_virq         8
   60.49 +#define XENOPROF_start               9
   60.50 +#define XENOPROF_stop               10
   60.51 +#define XENOPROF_disable_virq       11
   60.52 +#define XENOPROF_release_counters   12
   60.53 +#define XENOPROF_shutdown           13
   60.54 +#define XENOPROF_get_buffer         14
   60.55 +#define XENOPROF_set_backtrace      15
   60.56 +#define XENOPROF_last_op            15
   60.57 +
   60.58 +#define MAX_OPROF_EVENTS    32
   60.59 +#define MAX_OPROF_DOMAINS   25
   60.60 +#define XENOPROF_CPU_TYPE_SIZE 64
   60.61 +
   60.62 +/* Xenoprof performance events (not Xen events) */
   60.63 +struct event_log {
   60.64 +    uint64_t eip;
   60.65 +    uint8_t mode;
   60.66 +    uint8_t event;
   60.67 +};
   60.68 +
   60.69 +/* PC value that indicates a special code */
   60.70 +#define XENOPROF_ESCAPE_CODE ~0UL
   60.71 +/* Transient events for the xenoprof->oprofile cpu buf */
   60.72 +#define XENOPROF_TRACE_BEGIN 1
   60.73 +
   60.74 +/* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
   60.75 +struct xenoprof_buf {
   60.76 +    uint32_t event_head;
   60.77 +    uint32_t event_tail;
   60.78 +    uint32_t event_size;
   60.79 +    uint32_t vcpu_id;
   60.80 +    uint64_t xen_samples;
   60.81 +    uint64_t kernel_samples;
   60.82 +    uint64_t user_samples;
   60.83 +    uint64_t lost_samples;
   60.84 +    struct event_log event_log[1];
   60.85 +};
   60.86 +#ifndef __XEN__
   60.87 +typedef struct xenoprof_buf xenoprof_buf_t;
   60.88 +DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
   60.89 +#endif
   60.90 +
   60.91 +struct xenoprof_init {
   60.92 +    int32_t  num_events;
   60.93 +    int32_t  is_primary;
   60.94 +    char cpu_type[XENOPROF_CPU_TYPE_SIZE];
   60.95 +};
   60.96 +typedef struct xenoprof_init xenoprof_init_t;
   60.97 +DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
   60.98 +
   60.99 +struct xenoprof_get_buffer {
  60.100 +    int32_t  max_samples;
  60.101 +    int32_t  nbuf;
  60.102 +    int32_t  bufsize;
  60.103 +    uint64_t buf_gmaddr;
  60.104 +};
  60.105 +typedef struct xenoprof_get_buffer xenoprof_get_buffer_t;
  60.106 +DEFINE_XEN_GUEST_HANDLE(xenoprof_get_buffer_t);
  60.107 +
  60.108 +struct xenoprof_counter {
  60.109 +    uint32_t ind;
  60.110 +    uint64_t count;
  60.111 +    uint32_t enabled;
  60.112 +    uint32_t event;
  60.113 +    uint32_t hypervisor;
  60.114 +    uint32_t kernel;
  60.115 +    uint32_t user;
  60.116 +    uint64_t unit_mask;
  60.117 +};
  60.118 +typedef struct xenoprof_counter xenoprof_counter_t;
  60.119 +DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
  60.120 +
  60.121 +typedef struct xenoprof_passive {
  60.122 +    uint16_t domain_id;
  60.123 +    int32_t  max_samples;
  60.124 +    int32_t  nbuf;
  60.125 +    int32_t  bufsize;
  60.126 +    uint64_t buf_gmaddr;
  60.127 +} xenoprof_passive_t;
  60.128 +DEFINE_XEN_GUEST_HANDLE(xenoprof_passive_t);
  60.129 +
  60.130 +
  60.131 +#endif /* __XEN_PUBLIC_XENOPROF_H__ */
  60.132 +
  60.133 +/*
  60.134 + * Local variables:
  60.135 + * mode: C
  60.136 + * c-set-style: "BSD"
  60.137 + * c-basic-offset: 4
  60.138 + * tab-width: 4
  60.139 + * indent-tabs-mode: nil
  60.140 + * End:
  60.141 + */
    61.1 --- a/common/include/xen_windows.h	Tue Dec 18 20:51:54 2007 +1100
    61.2 +++ b/common/include/xen_windows.h	Wed Dec 19 09:23:32 2007 +1100
    61.3 @@ -6,13 +6,13 @@
    61.4  
    61.5  #define __XEN_INTERFACE_VERSION__ 0x00030205
    61.6  #define __i386__
    61.7 -typedef signed char int8_t;
    61.8 -typedef unsigned char uint8_t;
    61.9 -typedef SHORT int16_t;
   61.10 -typedef USHORT uint16_t;
   61.11 -typedef LONG int32_t;
   61.12 -typedef ULONG uint32_t;
   61.13 -typedef ULONGLONG uint64_t;
   61.14 +typedef INT8 int8_t;
   61.15 +typedef UINT8 uint8_t;
   61.16 +typedef INT16 int16_t;
   61.17 +typedef UINT16 uint16_t;
   61.18 +typedef INT32 int32_t;
   61.19 +typedef UINT32 uint32_t;
   61.20 +typedef UINT64 uint64_t;
   61.21  typedef unsigned long pgentry_t;
   61.22  
   61.23  #include <xen.h>
    62.1 --- a/common/include/xenbus_public.h	Tue Dec 18 20:51:54 2007 +1100
    62.2 +++ b/common/include/xenbus_public.h	Wed Dec 19 09:23:32 2007 +1100
    62.3 @@ -27,21 +27,21 @@ typedef VOID
    62.4  (*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
    62.5  
    62.6  typedef char *
    62.7 -(*PXEN_XENBUS_READ)(xenbus_transaction_t xbt, const char *path, char **value);
    62.8 -typedef char *
    62.9 -(*PXEN_XENBUS_WRITE)(xenbus_transaction_t xbt, const char *path, const char *value);
   62.10 -typedef char *
   62.11 -(*PXEN_XENBUS_PRINTF)(xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
   62.12 +(*PXEN_XENBUS_READ)(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
   62.13  typedef char *
   62.14 -(*PXEN_XENBUS_STARTTRANSACTION)(xenbus_transaction_t *xbt);
   62.15 -typedef char *
   62.16 -(*PXEN_XENBUS_ENDTRANSACTION)(xenbus_transaction_t t, int abort, int *retry);
   62.17 +(*PXEN_XENBUS_WRITE)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value);
   62.18  typedef char *
   62.19 -(*PXEN_XENBUS_LIST)(xenbus_transaction_t xbt, const char *prefix, char ***contents);
   62.20 +(*PXEN_XENBUS_PRINTF)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
   62.21  typedef char *
   62.22 -(*PXEN_XENBUS_ADDWATCH)(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   62.23 +(*PXEN_XENBUS_STARTTRANSACTION)(PVOID Context, xenbus_transaction_t *xbt);
   62.24  typedef char *
   62.25 -(*PXEN_XENBUS_REMWATCH)(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   62.26 +(*PXEN_XENBUS_ENDTRANSACTION)(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
   62.27 +typedef char *
   62.28 +(*PXEN_XENBUS_LIST)(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
   62.29 +typedef char *
   62.30