From owner-svn-src-head@freebsd.org Mon Jun 6 05:55:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 776EAB6CF2A; Mon, 6 Jun 2016 05:55:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3951A1EAE; Mon, 6 Jun 2016 05:55:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u565tcAh077008; Mon, 6 Jun 2016 05:55:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u565tbcc077000; Mon, 6 Jun 2016 05:55:37 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606060555.u565tbcc077000@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 6 Jun 2016 05:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301483 - in head/sys: conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 modules/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2016 05:55:39 -0000 Author: sephe Date: Mon Jun 6 05:55:37 2016 New Revision: 301483 URL: https://svnweb.freebsd.org/changeset/base/301483 Log: hyperv: Move machine dependent bits into machine dependent files. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6701 Added: head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c (contents, props changed) head/sys/dev/hyperv/vmbus/hyperv_machdep.h (contents, props changed) head/sys/dev/hyperv/vmbus/i386/hyperv_machdep.c (contents, props changed) Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/dev/hyperv/vmbus/hyperv.c head/sys/modules/hyperv/vmbus/Makefile Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Mon Jun 6 04:18:56 2016 (r301482) +++ head/sys/conf/files.amd64 Mon Jun 6 05:55:37 2016 (r301483) @@ -278,6 +278,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Mon Jun 6 04:18:56 2016 (r301482) +++ head/sys/conf/files.i386 Mon Jun 6 05:55:37 2016 (r301483) @@ -253,6 +253,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd dev/if_ndis/if_ndis.c optional ndis Added: head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Mon Jun 6 05:55:37 2016 (r301483) @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +uint64_t +hypercall_md(volatile void *hc_addr, uint64_t in_val, + uint64_t in_paddr, uint64_t out_paddr) +{ + uint64_t status; + + __asm__ __volatile__ ("mov %0, %%r8" : : "r" (out_paddr): "r8"); + __asm__ __volatile__ ("call *%3" : "=a" (status) : + "c" (in_val), "d" (in_paddr), "m" (hc_addr)); + return (status); +} Modified: head/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hyperv.c Mon Jun 6 04:18:56 2016 (r301482) +++ head/sys/dev/hyperv/vmbus/hyperv.c Mon Jun 6 05:55:37 2016 (r301483) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -104,40 +105,17 @@ hyperv_get_timecount(struct timecounter * @brief Invoke the specified hypercall */ static uint64_t -hv_vmbus_do_hypercall(uint64_t control, void* input, void* output) +hv_vmbus_do_hypercall(uint64_t value, void *input, void *output) { -#ifdef __x86_64__ - uint64_t hv_status = 0; - uint64_t input_address = (input) ? hv_get_phys_addr(input) : 0; - uint64_t output_address = (output) ? hv_get_phys_addr(output) : 0; - volatile void *hypercall_page = hypercall_context.hc_addr; - - __asm__ __volatile__ ("mov %0, %%r8" : : "r" (output_address): "r8"); - __asm__ __volatile__ ("call *%3" : "=a"(hv_status): - "c" (control), "d" (input_address), - "m" (hypercall_page)); - return (hv_status); -#else - uint32_t control_high = control >> 32; - uint32_t control_low = control & 0xFFFFFFFF; - uint32_t hv_status_high = 1; - uint32_t hv_status_low = 1; - uint64_t input_address = (input) ? hv_get_phys_addr(input) : 0; - uint32_t input_address_high = input_address >> 32; - uint32_t input_address_low = input_address & 0xFFFFFFFF; - uint64_t output_address = (output) ? hv_get_phys_addr(output) : 0; - uint32_t output_address_high = output_address >> 32; - uint32_t output_address_low = output_address & 0xFFFFFFFF; - volatile void *hypercall_page = hypercall_context.hc_addr; - - __asm__ __volatile__ ("call *%8" : "=d"(hv_status_high), - "=a"(hv_status_low) : "d" (control_high), - "a" (control_low), "b" (input_address_high), - "c" (input_address_low), - "D"(output_address_high), - "S"(output_address_low), "m" (hypercall_page)); - return (hv_status_low | ((uint64_t)hv_status_high << 32)); -#endif /* __x86_64__ */ + uint64_t in_paddr = 0, out_paddr = 0; + + if (input != NULL) + in_paddr = hv_get_phys_addr(input); + if (output != NULL) + out_paddr = hv_get_phys_addr(output); + + return hypercall_md(hypercall_context.hc_addr, value, + in_paddr, out_paddr); } /** Added: head/sys/dev/hyperv/vmbus/hyperv_machdep.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/vmbus/hyperv_machdep.h Mon Jun 6 05:55:37 2016 (r301483) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _HYPERV_MACHDEP_H_ +#define _HYPERV_MACHDEP_H_ + +#include + +uint64_t hypercall_md(volatile void *hc_addr, uint64_t in_val, + uint64_t in_paddr, uint64_t out_paddr); + +#endif /* !_HYPERV_MACHDEP_H_ */ Added: head/sys/dev/hyperv/vmbus/i386/hyperv_machdep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/vmbus/i386/hyperv_machdep.c Mon Jun 6 05:55:37 2016 (r301483) @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +uint64_t +hypercall_md(volatile void *hc_addr, uint64_t in_val, + uint64_t in_paddr, uint64_t out_paddr) +{ + uint32_t in_val_hi = in_val >> 32; + uint32_t in_val_lo = in_val & 0xFFFFFFFF; + uint32_t status_hi, status_lo; + uint32_t in_paddr_hi = in_paddr >> 32; + uint32_t in_paddr_lo = in_paddr & 0xFFFFFFFF; + uint32_t out_paddr_hi = out_paddr >> 32; + uint32_t out_paddr_lo = out_paddr & 0xFFFFFFFF; + + __asm__ __volatile__ ("call *%8" : "=d"(status_hi), "=a"(status_lo) : + "d" (in_val_hi), "a" (in_val_lo), + "b" (in_paddr_hi), "c" (in_paddr_lo), + "D"(out_paddr_hi), "S"(out_paddr_lo), + "m" (hc_addr)); + return (status_lo | ((uint64_t)status_hi << 32)); +} Modified: head/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- head/sys/modules/hyperv/vmbus/Makefile Mon Jun 6 04:18:56 2016 (r301482) +++ head/sys/modules/hyperv/vmbus/Makefile Mon Jun 6 05:55:37 2016 (r301483) @@ -10,6 +10,7 @@ SRCS= hv_channel.c \ hv_ring_buffer.c \ hyperv.c \ hyperv_busdma.c \ + hyperv_machdep.c \ vmbus.c \ vmbus_et.c SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h