176acc41fSJustin T. Gibbs /****************************************************************************** 276acc41fSJustin T. Gibbs * xen/xen-os.h 376acc41fSJustin T. Gibbs * 476acc41fSJustin T. Gibbs * Random collection of macros and definition 576acc41fSJustin T. Gibbs * 676acc41fSJustin T. Gibbs * Copyright (c) 2003, 2004 Keir Fraser (on behalf of the Xen team) 776acc41fSJustin T. Gibbs * All rights reserved. 876acc41fSJustin T. Gibbs * 976acc41fSJustin T. Gibbs * Permission is hereby granted, free of charge, to any person obtaining a copy 1076acc41fSJustin T. Gibbs * of this software and associated documentation files (the "Software"), to 1176acc41fSJustin T. Gibbs * deal in the Software without restriction, including without limitation the 1276acc41fSJustin T. Gibbs * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 1376acc41fSJustin T. Gibbs * sell copies of the Software, and to permit persons to whom the Software is 1476acc41fSJustin T. Gibbs * furnished to do so, subject to the following conditions: 1576acc41fSJustin T. Gibbs * 1676acc41fSJustin T. Gibbs * The above copyright notice and this permission notice shall be included in 1776acc41fSJustin T. Gibbs * all copies or substantial portions of the Software. 1876acc41fSJustin T. Gibbs * 1976acc41fSJustin T. Gibbs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2076acc41fSJustin T. Gibbs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2176acc41fSJustin T. Gibbs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2276acc41fSJustin T. Gibbs * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2376acc41fSJustin T. Gibbs * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2476acc41fSJustin T. Gibbs * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2576acc41fSJustin T. Gibbs * DEALINGS IN THE SOFTWARE. 2676acc41fSJustin T. Gibbs * 2776acc41fSJustin T. Gibbs * $FreeBSD$ 2876acc41fSJustin T. Gibbs */ 2976acc41fSJustin T. Gibbs 3076acc41fSJustin T. Gibbs #ifndef _XEN_XEN_OS_H_ 3176acc41fSJustin T. Gibbs #define _XEN_XEN_OS_H_ 3276acc41fSJustin T. Gibbs 3376acc41fSJustin T. Gibbs #if !defined(__XEN_INTERFACE_VERSION__) 3476acc41fSJustin T. Gibbs #define __XEN_INTERFACE_VERSION__ 0x00030208 3576acc41fSJustin T. Gibbs #endif 3676acc41fSJustin T. Gibbs 3776acc41fSJustin T. Gibbs #define GRANT_REF_INVALID 0xffffffff 3876acc41fSJustin T. Gibbs 3976acc41fSJustin T. Gibbs #ifdef LOCORE 4076acc41fSJustin T. Gibbs #define __ASSEMBLY__ 4176acc41fSJustin T. Gibbs #endif 4276acc41fSJustin T. Gibbs 4376acc41fSJustin T. Gibbs #include <machine/xen/xen-os.h> 4476acc41fSJustin T. Gibbs 4576acc41fSJustin T. Gibbs #include <xen/interface/xen.h> 4676acc41fSJustin T. Gibbs 4776acc41fSJustin T. Gibbs /* Everything below this point is not included by assembler (.S) files. */ 4876acc41fSJustin T. Gibbs #ifndef __ASSEMBLY__ 4976acc41fSJustin T. Gibbs 5076acc41fSJustin T. Gibbs /* Force a proper event-channel callback from Xen. */ 5176acc41fSJustin T. Gibbs void force_evtchn_callback(void); 5276acc41fSJustin T. Gibbs 5376acc41fSJustin T. Gibbs extern shared_info_t *HYPERVISOR_shared_info; 541a9cdd37SRoger Pau Monné extern start_info_t *HYPERVISOR_start_info; 551a9cdd37SRoger Pau Monné 561a9cdd37SRoger Pau Monné /* XXX: we need to get rid of this and use HYPERVISOR_start_info directly */ 571a9cdd37SRoger Pau Monné extern struct xenstore_domain_interface *xen_store; 5876acc41fSJustin T. Gibbs 5976acc41fSJustin T. Gibbs enum xen_domain_type { 6076acc41fSJustin T. Gibbs XEN_NATIVE, /* running on bare hardware */ 6176acc41fSJustin T. Gibbs XEN_PV_DOMAIN, /* running in a PV domain */ 6276acc41fSJustin T. Gibbs XEN_HVM_DOMAIN, /* running in a Xen hvm domain */ 6376acc41fSJustin T. Gibbs }; 6476acc41fSJustin T. Gibbs 6576acc41fSJustin T. Gibbs extern enum xen_domain_type xen_domain_type; 6676acc41fSJustin T. Gibbs 6776acc41fSJustin T. Gibbs static inline int 6876acc41fSJustin T. Gibbs xen_domain(void) 6976acc41fSJustin T. Gibbs { 7076acc41fSJustin T. Gibbs return (xen_domain_type != XEN_NATIVE); 7176acc41fSJustin T. Gibbs } 7276acc41fSJustin T. Gibbs 7376acc41fSJustin T. Gibbs static inline int 7476acc41fSJustin T. Gibbs xen_pv_domain(void) 7576acc41fSJustin T. Gibbs { 7676acc41fSJustin T. Gibbs return (xen_domain_type == XEN_PV_DOMAIN); 7776acc41fSJustin T. Gibbs } 7876acc41fSJustin T. Gibbs 7976acc41fSJustin T. Gibbs static inline int 8076acc41fSJustin T. Gibbs xen_hvm_domain(void) 8176acc41fSJustin T. Gibbs { 8276acc41fSJustin T. Gibbs return (xen_domain_type == XEN_HVM_DOMAIN); 8376acc41fSJustin T. Gibbs } 8476acc41fSJustin T. Gibbs 85*6f4246bcSRoger Pau Monné static inline bool 86*6f4246bcSRoger Pau Monné xen_initial_domain(void) 87*6f4246bcSRoger Pau Monné { 88*6f4246bcSRoger Pau Monné return (xen_domain() && HYPERVISOR_start_info != NULL && 89*6f4246bcSRoger Pau Monné (HYPERVISOR_start_info->flags & SIF_INITDOMAIN) != 0); 90*6f4246bcSRoger Pau Monné } 91*6f4246bcSRoger Pau Monné 9276acc41fSJustin T. Gibbs #ifndef xen_mb 9376acc41fSJustin T. Gibbs #define xen_mb() mb() 9476acc41fSJustin T. Gibbs #endif 9576acc41fSJustin T. Gibbs #ifndef xen_rmb 9676acc41fSJustin T. Gibbs #define xen_rmb() rmb() 9776acc41fSJustin T. Gibbs #endif 9876acc41fSJustin T. Gibbs #ifndef xen_wmb 9976acc41fSJustin T. Gibbs #define xen_wmb() wmb() 10076acc41fSJustin T. Gibbs #endif 10176acc41fSJustin T. Gibbs 10276acc41fSJustin T. Gibbs #endif /* !__ASSEMBLY__ */ 10376acc41fSJustin T. Gibbs 10476acc41fSJustin T. Gibbs #endif /* _XEN_XEN_OS_H_ */ 105