xref: /freebsd/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c (revision d8bf51683df44682472147db21b02ba7a831f671)
1*d8bf5168SSepherosa Ziehau /*-
2*d8bf5168SSepherosa Ziehau  * Copyright (c) 2016 Microsoft Corp.
3*d8bf5168SSepherosa Ziehau  * All rights reserved.
4*d8bf5168SSepherosa Ziehau  *
5*d8bf5168SSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6*d8bf5168SSepherosa Ziehau  * modification, are permitted provided that the following conditions
7*d8bf5168SSepherosa Ziehau  * are met:
8*d8bf5168SSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9*d8bf5168SSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
10*d8bf5168SSepherosa Ziehau  *    disclaimer.
11*d8bf5168SSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
12*d8bf5168SSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
13*d8bf5168SSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
14*d8bf5168SSepherosa Ziehau  *
15*d8bf5168SSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*d8bf5168SSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*d8bf5168SSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*d8bf5168SSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*d8bf5168SSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*d8bf5168SSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*d8bf5168SSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*d8bf5168SSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*d8bf5168SSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*d8bf5168SSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*d8bf5168SSepherosa Ziehau  */
26*d8bf5168SSepherosa Ziehau 
27*d8bf5168SSepherosa Ziehau #include <sys/cdefs.h>
28*d8bf5168SSepherosa Ziehau __FBSDID("$FreeBSD$");
29*d8bf5168SSepherosa Ziehau 
30*d8bf5168SSepherosa Ziehau #include <sys/param.h>
31*d8bf5168SSepherosa Ziehau #include <dev/hyperv/vmbus/hyperv_machdep.h>
32*d8bf5168SSepherosa Ziehau 
33*d8bf5168SSepherosa Ziehau uint64_t
34*d8bf5168SSepherosa Ziehau hypercall_md(volatile void *hc_addr, uint64_t in_val,
35*d8bf5168SSepherosa Ziehau     uint64_t in_paddr, uint64_t out_paddr)
36*d8bf5168SSepherosa Ziehau {
37*d8bf5168SSepherosa Ziehau 	uint64_t status;
38*d8bf5168SSepherosa Ziehau 
39*d8bf5168SSepherosa Ziehau 	__asm__ __volatile__ ("mov %0, %%r8" : : "r" (out_paddr): "r8");
40*d8bf5168SSepherosa Ziehau 	__asm__ __volatile__ ("call *%3" : "=a" (status) :
41*d8bf5168SSepherosa Ziehau 	    "c" (in_val), "d" (in_paddr), "m" (hc_addr));
42*d8bf5168SSepherosa Ziehau 	return (status);
43*d8bf5168SSepherosa Ziehau }
44