Home | History | Annotate | Line # | Download | only in hyperv
hypervvar.h revision 1.2.2.2
      1  1.2.2.2  christos /*	$NetBSD: hypervvar.h,v 1.2.2.2 2019/06/10 22:07:09 christos Exp $	*/
      2  1.2.2.2  christos 
      3  1.2.2.2  christos /*-
      4  1.2.2.2  christos  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
      5  1.2.2.2  christos  *
      6  1.2.2.2  christos  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
      7  1.2.2.2  christos  * Copyright (c) 2012 NetApp Inc.
      8  1.2.2.2  christos  * Copyright (c) 2012 Citrix Inc.
      9  1.2.2.2  christos  * All rights reserved.
     10  1.2.2.2  christos  *
     11  1.2.2.2  christos  * Redistribution and use in source and binary forms, with or without
     12  1.2.2.2  christos  * modification, are permitted provided that the following conditions
     13  1.2.2.2  christos  * are met:
     14  1.2.2.2  christos  * 1. Redistributions of source code must retain the above copyright
     15  1.2.2.2  christos  *    notice unmodified, this list of conditions, and the following
     16  1.2.2.2  christos  *    disclaimer.
     17  1.2.2.2  christos  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.2.2.2  christos  *    notice, this list of conditions and the following disclaimer in the
     19  1.2.2.2  christos  *    documentation and/or other materials provided with the distribution.
     20  1.2.2.2  christos  *
     21  1.2.2.2  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.2.2.2  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.2.2.2  christos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.2.2.2  christos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.2.2.2  christos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.2.2.2  christos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.2.2.2  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.2.2.2  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.2.2.2  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.2.2.2  christos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.2.2.2  christos  *
     32  1.2.2.2  christos  * $FreeBSD: head/sys/dev/hyperv/include/hyperv.h 326255 2017-11-27 14:52:40Z pfg $
     33  1.2.2.2  christos  */
     34  1.2.2.2  christos 
     35  1.2.2.2  christos #ifndef _HYPERVVAR_H_
     36  1.2.2.2  christos #define _HYPERVVAR_H_
     37  1.2.2.2  christos 
     38  1.2.2.2  christos #if defined(_KERNEL)
     39  1.2.2.2  christos 
     40  1.2.2.2  christos #include <sys/bus.h>
     41  1.2.2.2  christos #include <sys/timex.h>
     42  1.2.2.2  christos 
     43  1.2.2.2  christos #define HYPERV_TIMER_NS_FACTOR	100ULL
     44  1.2.2.2  christos #define HYPERV_TIMER_FREQ	(NANOSECOND / HYPERV_TIMER_NS_FACTOR)
     45  1.2.2.2  christos 
     46  1.2.2.2  christos #endif	/* _KERNEL */
     47  1.2.2.2  christos 
     48  1.2.2.2  christos /*
     49  1.2.2.2  christos  * Hyper-V Reference TSC
     50  1.2.2.2  christos  */
     51  1.2.2.2  christos struct hyperv_reftsc {
     52  1.2.2.2  christos 	volatile uint32_t	tsc_seq;
     53  1.2.2.2  christos 	volatile uint32_t	tsc_rsvd1;
     54  1.2.2.2  christos 	volatile uint64_t	tsc_scale;
     55  1.2.2.2  christos 	volatile int64_t	tsc_ofs;
     56  1.2.2.2  christos } __packed __aligned(PAGE_SIZE);
     57  1.2.2.2  christos #ifdef __CTASSERT
     58  1.2.2.2  christos __CTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE);
     59  1.2.2.2  christos #endif
     60  1.2.2.2  christos 
     61  1.2.2.2  christos #if defined(_KERNEL)
     62  1.2.2.2  christos 
     63  1.2.2.2  christos int	hyperv_hypercall_enabled(void);
     64  1.2.2.2  christos int	hyperv_synic_supported(void);
     65  1.2.2.2  christos int	hyperv_is_gen1(void);
     66  1.2.2.2  christos void	hyperv_send_eom(void);
     67  1.2.2.2  christos void	hyperv_intr(void);
     68  1.2.2.2  christos 
     69  1.2.2.2  christos struct vmbus_softc;
     70  1.2.2.2  christos void	vmbus_init_interrupts_md(struct vmbus_softc *);
     71  1.2.2.2  christos void	vmbus_deinit_interrupts_md(struct vmbus_softc *);
     72  1.2.2.2  christos void	vmbus_init_synic_md(struct vmbus_softc *, cpuid_t);
     73  1.2.2.2  christos void	vmbus_deinit_synic_md(struct vmbus_softc *, cpuid_t);
     74  1.2.2.2  christos 
     75  1.2.2.2  christos #define HYPERV_GUID_STRLEN	40
     76  1.2.2.2  christos struct hyperv_guid;
     77  1.2.2.2  christos int	hyperv_guid2str(const struct hyperv_guid *, char *, size_t);
     78  1.2.2.2  christos 
     79  1.2.2.2  christos /*
     80  1.2.2.2  christos  * hyperv_tc64 could be NULL, if there were no suitable Hyper-V
     81  1.2.2.2  christos  * specific timecounter.
     82  1.2.2.2  christos  */
     83  1.2.2.2  christos typedef uint64_t (*hyperv_tc64_t)(void);
     84  1.2.2.2  christos extern hyperv_tc64_t hyperv_tc64;
     85  1.2.2.2  christos 
     86  1.2.2.2  christos uint64_t hyperv_hypercall(uint64_t, paddr_t, paddr_t);
     87  1.2.2.2  christos uint64_t hyperv_hypercall_post_message(paddr_t);
     88  1.2.2.2  christos uint64_t hyperv_hypercall_signal_event(paddr_t);
     89  1.2.2.2  christos 
     90  1.2.2.2  christos typedef void (*hyperv_proc_t)(void *, struct cpu_info *);
     91  1.2.2.2  christos void	hyperv_set_event_proc(hyperv_proc_t, void *);
     92  1.2.2.2  christos void	hyperv_set_message_proc(hyperv_proc_t, void *);
     93  1.2.2.2  christos 
     94  1.2.2.2  christos /*
     95  1.2.2.2  christos  * Hyper-V bus_dma utilities.
     96  1.2.2.2  christos  */
     97  1.2.2.2  christos struct hyperv_dma {
     98  1.2.2.2  christos 	bus_dmamap_t		map;
     99  1.2.2.2  christos 	bus_dma_segment_t	*segs;
    100  1.2.2.2  christos 	void			*addr;
    101  1.2.2.2  christos 	int			nsegs;
    102  1.2.2.2  christos };
    103  1.2.2.2  christos 
    104  1.2.2.2  christos static __inline bus_addr_t
    105  1.2.2.2  christos hyperv_dma_get_paddr(struct hyperv_dma *dma)
    106  1.2.2.2  christos {
    107  1.2.2.2  christos 	return dma->map->dm_segs[0].ds_addr;
    108  1.2.2.2  christos }
    109  1.2.2.2  christos 
    110  1.2.2.2  christos void *hyperv_dma_alloc(bus_dma_tag_t, struct hyperv_dma *, bus_size_t,
    111  1.2.2.2  christos     bus_size_t, bus_size_t, int);
    112  1.2.2.2  christos void hyperv_dma_free(bus_dma_tag_t, struct hyperv_dma *);
    113  1.2.2.2  christos 
    114  1.2.2.2  christos #endif	/* _KERNEL */
    115  1.2.2.2  christos 
    116  1.2.2.2  christos #endif	/* _HYPERVVAR_H_ */
    117