]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/hyperv/vmbus/vmbus_res.c
sqlite3: Vendor import of sqlite3 3.39.0
[FreeBSD/FreeBSD.git] / sys / dev / hyperv / vmbus / vmbus_res.c
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 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/bus.h>
33 #include <sys/module.h>
34
35 #include <contrib/dev/acpica/include/acpi.h>
36 #include <dev/acpica/acpivar.h>
37
38 #include <dev/hyperv/include/hyperv.h>
39
40 #include "acpi_if.h"
41 #include "bus_if.h"
42
43 static int              vmbus_res_probe(device_t);
44 static int              vmbus_res_attach(device_t);
45 static int              vmbus_res_detach(device_t);
46
47 static device_method_t vmbus_res_methods[] = {
48         /* Device interface */
49         DEVMETHOD(device_probe,                 vmbus_res_probe),
50         DEVMETHOD(device_attach,                vmbus_res_attach),
51         DEVMETHOD(device_detach,                vmbus_res_detach),
52         DEVMETHOD(device_shutdown,              bus_generic_shutdown),
53         DEVMETHOD(device_suspend,               bus_generic_suspend),
54         DEVMETHOD(device_resume,                bus_generic_resume),
55
56         DEVMETHOD_END
57 };
58
59 static driver_t vmbus_res_driver = {
60         "vmbus_res",
61         vmbus_res_methods,
62         1
63 };
64
65 DRIVER_MODULE(vmbus_res, acpi, vmbus_res_driver, NULL, NULL);
66 MODULE_DEPEND(vmbus_res, acpi, 1, 1, 1);
67 MODULE_VERSION(vmbus_res, 1);
68
69 static int
70 vmbus_res_probe(device_t dev)
71 {
72         char *id[] = { "VMBUS", NULL };
73         int rv;
74         
75         if (device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV ||
76             (hyperv_features & CPUID_HV_MSR_SYNIC) == 0)
77                 return (ENXIO);
78         rv = ACPI_ID_PROBE(device_get_parent(dev), dev, id, NULL);
79         if (rv <= 0)
80                 device_set_desc(dev, "Hyper-V Vmbus Resource");
81         return (rv);
82 }
83
84 static int
85 vmbus_res_attach(device_t dev __unused)
86 {
87
88         return (0);
89 }
90
91 static int
92 vmbus_res_detach(device_t dev __unused)
93 {
94
95         return (0);
96 }