Home | History | Annotate | Line # | Download | only in include
hypervisor.h revision 1.33
      1 /*	$NetBSD: hypervisor.h,v 1.33 2011/09/20 00:12:23 jym Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2006 Manuel Bouyer.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  *
     26  */
     27 
     28 /*
     29  *
     30  * Communication to/from hypervisor.
     31  *
     32  * Copyright (c) 2002-2004, K A Fraser
     33  *
     34  * Permission is hereby granted, free of charge, to any person obtaining a copy
     35  * of this source file (the "Software"), to deal in the Software without
     36  * restriction, including without limitation the rights to use, copy, modify,
     37  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
     38  * and to permit persons to whom the Software is furnished to do so, subject to
     39  * the following conditions:
     40  *
     41  * The above copyright notice and this permission notice shall be included in
     42  * all copies or substantial portions of the Software.
     43  *
     44  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     45  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     46  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     47  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     48  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     49  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     50  * IN THE SOFTWARE.
     51  */
     52 
     53 
     54 #ifndef _XEN_HYPERVISOR_H_
     55 #define _XEN_HYPERVISOR_H_
     56 
     57 #include "opt_xen.h"
     58 
     59 
     60 struct hypervisor_attach_args {
     61 	const char 		*haa_busname;
     62 };
     63 
     64 struct xencons_attach_args {
     65 	const char 		*xa_device;
     66 };
     67 
     68 struct xen_npx_attach_args {
     69 	const char 		*xa_device;
     70 };
     71 
     72 
     73 #define	u8 uint8_t
     74 #define	u16 uint16_t
     75 #define	u32 uint32_t
     76 #define	u64 uint64_t
     77 #define	s8 int8_t
     78 #define	s16 int16_t
     79 #define	s32 int32_t
     80 #define	s64 int64_t
     81 
     82 #include <xen/xen3-public/xen.h>
     83 #include <xen/xen3-public/sched.h>
     84 #include <xen/xen3-public/platform.h>
     85 #if __XEN_INTERFACE_VERSION__ < 0x00030204
     86 #include <xen/xen3-public/dom0_ops.h>
     87 #endif
     88 #include <xen/xen3-public/event_channel.h>
     89 #include <xen/xen3-public/physdev.h>
     90 #include <xen/xen3-public/memory.h>
     91 #include <xen/xen3-public/io/netif.h>
     92 #include <xen/xen3-public/io/blkif.h>
     93 
     94 #include <machine/cpu.h>
     95 #include <machine/hypercalls.h>
     96 
     97 #undef u8
     98 #undef u16
     99 #undef u32
    100 #undef u64
    101 #undef s8
    102 #undef s16
    103 #undef s32
    104 #undef s64
    105 
    106 
    107 
    108 /*
    109  * a placeholder for the start of day information passed up from the hypervisor
    110  */
    111 union start_info_union
    112 {
    113     start_info_t start_info;
    114     char padding[512];
    115 };
    116 extern union start_info_union start_info_union;
    117 #define xen_start_info (start_info_union.start_info)
    118 
    119 /* For use in guest OSes. */
    120 extern volatile shared_info_t *HYPERVISOR_shared_info;
    121 
    122 
    123 /* Structural guest handles introduced in 0x00030201. */
    124 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
    125 #define xenguest_handle(hnd)	(hnd).p
    126 #else
    127 #define xenguest_handle(hnd)	hnd
    128 #endif
    129 
    130 /* hypervisor.c */
    131 struct intrframe;
    132 void do_hypervisor_callback(struct intrframe *regs);
    133 void hypervisor_enable_event(unsigned int);
    134 
    135 /* hypervisor_machdep.c */
    136 void hypervisor_unmask_event(unsigned int);
    137 void hypervisor_mask_event(unsigned int);
    138 void hypervisor_clear_event(unsigned int);
    139 void hypervisor_enable_ipl(unsigned int);
    140 void hypervisor_set_ipending(struct cpu_info *,
    141 			     uint32_t, int, int);
    142 void hypervisor_machdep_attach(void);
    143 void hypervisor_machdep_resume(void);
    144 
    145 /*
    146  * Force a proper event-channel callback from Xen after clearing the
    147  * callback mask. We do this in a very simple manner, by making a call
    148  * down into Xen. The pending flag will be checked by Xen on return.
    149  */
    150 static __inline void hypervisor_force_callback(void)
    151 {
    152 	(void)HYPERVISOR_xen_version(0, (void*)0);
    153 } __attribute__((no_instrument_function)) /* used by mcount */
    154 
    155 static __inline void
    156 hypervisor_notify_via_evtchn(unsigned int port)
    157 {
    158 	evtchn_op_t op;
    159 
    160 	op.cmd = EVTCHNOP_send;
    161 	op.u.send.port = port;
    162 	(void)HYPERVISOR_event_channel_op(&op);
    163 }
    164 
    165 #endif /* _XEN_HYPERVISOR_H_ */
    166