1 /*- 2 * Copyright (c) 2017 Microsoft Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #include <sys/cdefs.h> 28 #include <sys/param.h> 29 #include <sys/kernel.h> 30 #include <sys/bus.h> 31 #include <sys/module.h> 32 33 #include <contrib/dev/acpica/include/acpi.h> 34 #include <dev/acpica/acpivar.h> 35 36 #include <dev/hyperv/include/hyperv.h> 37 38 #include "acpi_if.h" 39 #include "bus_if.h" 40 41 static int vmbus_res_probe(device_t); 42 static int vmbus_res_attach(device_t); 43 static int vmbus_res_detach(device_t); 44 45 static device_method_t vmbus_res_methods[] = { 46 /* Device interface */ 47 DEVMETHOD(device_probe, vmbus_res_probe), 48 DEVMETHOD(device_attach, vmbus_res_attach), 49 DEVMETHOD(device_detach, vmbus_res_detach), 50 DEVMETHOD(device_shutdown, bus_generic_shutdown), 51 DEVMETHOD(device_suspend, bus_generic_suspend), 52 DEVMETHOD(device_resume, bus_generic_resume), 53 54 DEVMETHOD_END 55 }; 56 57 static driver_t vmbus_res_driver = { 58 "vmbus_res", 59 vmbus_res_methods, 60 1 61 }; 62 63 DRIVER_MODULE(vmbus_res, acpi, vmbus_res_driver, NULL, NULL); 64 MODULE_DEPEND(vmbus_res, acpi, 1, 1, 1); 65 MODULE_VERSION(vmbus_res, 1); 66 67 static int 68 vmbus_res_probe(device_t dev) 69 { 70 char *id[] = { "VMBUS", NULL }; 71 int rv; 72 73 if (device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV || 74 (hyperv_features & CPUID_HV_MSR_SYNIC) == 0) 75 return (ENXIO); 76 rv = ACPI_ID_PROBE(device_get_parent(dev), dev, id, NULL); 77 if (rv <= 0) 78 device_set_desc(dev, "Hyper-V Vmbus Resource"); 79 return (rv); 80 } 81 82 static int 83 vmbus_res_attach(device_t dev __unused) 84 { 85 86 return (0); 87 } 88 89 static int 90 vmbus_res_detach(device_t dev __unused) 91 { 92 93 return (0); 94 } 95