The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/xen/xen-os.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /******************************************************************************
    2  * xen/xen-os.h
    3  * 
    4  * Random collection of macros and definition
    5  *
    6  * Copyright (c) 2003, 2004 Keir Fraser (on behalf of the Xen team)
    7  * All rights reserved.
    8  *
    9  * Permission is hereby granted, free of charge, to any person obtaining a copy
   10  * of this software and associated documentation files (the "Software"), to
   11  * deal in the Software without restriction, including without limitation the
   12  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   13  * sell copies of the Software, and to permit persons to whom the Software is
   14  * furnished to do so, subject to the following conditions:
   15  * 
   16  * The above copyright notice and this permission notice shall be included in
   17  * all copies or substantial portions of the Software.
   18  * 
   19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
   22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
   24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
   25  * DEALINGS IN THE SOFTWARE.
   26  *
   27  * $FreeBSD: stable/12/sys/xen/xen-os.h 336470 2018-07-19 07:54:45Z royger $
   28  */
   29 
   30 #ifndef _XEN_XEN_OS_H_
   31 #define _XEN_XEN_OS_H_
   32 
   33 #if !defined(__XEN_INTERFACE_VERSION__)  
   34 #define  __XEN_INTERFACE_VERSION__ 0x00030208
   35 #endif  
   36 
   37 #define GRANT_REF_INVALID   0xffffffff
   38 
   39 #ifdef LOCORE
   40 #define __ASSEMBLY__
   41 #endif
   42 
   43 #include <xen/interface/xen.h>
   44 
   45 #ifndef __ASSEMBLY__
   46 #include <xen/interface/event_channel.h>
   47 
   48 struct hypervisor_info {
   49         vm_paddr_t (*get_xenstore_mfn)(void);
   50         evtchn_port_t (*get_xenstore_evtchn)(void);
   51         vm_paddr_t (*get_console_mfn)(void);
   52         evtchn_port_t (*get_console_evtchn)(void);
   53         uint32_t (*get_start_flags)(void);
   54 };
   55 extern struct hypervisor_info hypervisor_info;
   56 
   57 static inline vm_paddr_t
   58 xen_get_xenstore_mfn(void)
   59 {
   60 
   61         return (hypervisor_info.get_xenstore_mfn());
   62 }
   63 
   64 static inline evtchn_port_t
   65 xen_get_xenstore_evtchn(void)
   66 {
   67 
   68         return (hypervisor_info.get_xenstore_evtchn());
   69 }
   70 
   71 static inline vm_paddr_t
   72 xen_get_console_mfn(void)
   73 {
   74 
   75         return (hypervisor_info.get_console_mfn());
   76 }
   77 
   78 static inline evtchn_port_t
   79 xen_get_console_evtchn(void)
   80 {
   81 
   82         return (hypervisor_info.get_console_evtchn());
   83 }
   84 
   85 static inline uint32_t
   86 xen_get_start_flags(void)
   87 {
   88 
   89         return (hypervisor_info.get_start_flags());
   90 }
   91 #endif
   92 
   93 #include <machine/xen/xen-os.h>
   94 
   95 /* Everything below this point is not included by assembler (.S) files. */
   96 #ifndef __ASSEMBLY__
   97 
   98 extern shared_info_t *HYPERVISOR_shared_info;
   99 
  100 extern int xen_disable_pv_disks;
  101 extern int xen_disable_pv_nics;
  102 
  103 extern bool xen_suspend_cancelled;
  104 
  105 enum xen_domain_type {
  106         XEN_NATIVE,             /* running on bare hardware    */
  107         XEN_PV_DOMAIN,          /* running in a PV domain      */
  108         XEN_HVM_DOMAIN,         /* running in a Xen hvm domain */
  109 };
  110 
  111 extern enum xen_domain_type xen_domain_type;
  112 
  113 static inline int
  114 xen_domain(void)
  115 {
  116         return (xen_domain_type != XEN_NATIVE);
  117 }
  118 
  119 static inline int
  120 xen_pv_domain(void)
  121 {
  122         return (xen_domain_type == XEN_PV_DOMAIN);
  123 }
  124 
  125 static inline int
  126 xen_hvm_domain(void)
  127 {
  128         return (xen_domain_type == XEN_HVM_DOMAIN);
  129 }
  130 
  131 static inline bool
  132 xen_initial_domain(void)
  133 {
  134 
  135         return (xen_domain() && (xen_get_start_flags() & SIF_INITDOMAIN) != 0);
  136 }
  137 
  138 /*
  139  * Based on ofed/include/linux/bitops.h
  140  *
  141  * Those helpers are prefixed by xen_ because xen-os.h is widely included
  142  * and we don't want the other drivers using them.
  143  *
  144  */
  145 #define NBPL (NBBY * sizeof(long))
  146 
  147 static inline bool
  148 xen_test_bit(int bit, volatile long *addr)
  149 {
  150         unsigned long mask = 1UL << (bit % NBPL);
  151 
  152         return !!(atomic_load_acq_long(&addr[bit / NBPL]) & mask);
  153 }
  154 
  155 static inline void
  156 xen_set_bit(int bit, volatile long *addr)
  157 {
  158         atomic_set_long(&addr[bit / NBPL], 1UL << (bit % NBPL));
  159 }
  160 
  161 static inline void
  162 xen_clear_bit(int bit, volatile long *addr)
  163 {
  164         atomic_clear_long(&addr[bit / NBPL], 1UL << (bit % NBPL));
  165 }
  166 
  167 #undef NBPL
  168 
  169 /*
  170  * Functions to allocate/free unused memory in order
  171  * to map memory from other domains.
  172  */
  173 struct resource *xenmem_alloc(device_t dev, int *res_id, size_t size);
  174 int xenmem_free(device_t dev, int res_id, struct resource *res);
  175 
  176 /* Debug/emergency function, prints directly to hypervisor console */
  177 void xc_printf(const char *, ...) __printflike(1, 2);
  178 
  179 #ifndef xen_mb
  180 #define xen_mb() mb()
  181 #endif
  182 #ifndef xen_rmb
  183 #define xen_rmb() rmb()
  184 #endif
  185 #ifndef xen_wmb
  186 #define xen_wmb() wmb()
  187 #endif
  188 
  189 #endif /* !__ASSEMBLY__ */
  190 
  191 #endif /* _XEN_XEN_OS_H_ */

Cache object: 8cd9bff14b948e181c6e4311ec35b914


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.