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