Index: sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c =================================================================== --- sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c +++ sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c @@ -411,18 +411,12 @@ static int netvsc_probe(device_t dev) { - const char *p; - - p = vmbus_get_type(dev); - if (!memcmp(p, &g_net_vsc_device_type.data, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, + &g_net_vsc_device_type) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); - if (bootverbose) - printf("Netvsc probe... DONE \n"); - - return (BUS_PROBE_DEFAULT); + return BUS_PROBE_DEFAULT; } - - return (ENXIO); + return ENXIO; } /* Index: sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c =================================================================== --- sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c +++ sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c @@ -2163,13 +2163,11 @@ static enum hv_storage_type storvsc_get_storage_type(device_t dev) { - const char *p = vmbus_get_type(dev); + device_t parent = device_get_parent(dev); - if (!memcmp(p, &gBlkVscDeviceType, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(parent, dev, &gBlkVscDeviceType) == 0) return DRIVER_BLKVSC; - } else if (!memcmp(p, &gStorVscDeviceType, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(parent, dev, &gStorVscDeviceType) == 0) return DRIVER_STORVSC; - } - return (DRIVER_UNKNOWN); + return DRIVER_UNKNOWN; } - Index: sys/dev/hyperv/utilities/hv_heartbeat.c =================================================================== --- sys/dev/hyperv/utilities/hv_heartbeat.c +++ sys/dev/hyperv/utilities/hv_heartbeat.c @@ -36,9 +36,10 @@ #include #include "hv_util.h" +#include "vmbus_if.h" /* Heartbeat Service */ -static hv_guid service_guid = { .data = +static const hv_guid service_guid = { .data = {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; @@ -93,16 +94,13 @@ static int hv_heartbeat_probe(device_t dev) { - const char *p = vmbus_get_type(dev); - if (resource_disabled("hvheartbeat", 0)) return ENXIO; - if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { device_set_desc(dev, "Hyper-V Heartbeat Service"); return BUS_PROBE_DEFAULT; } - return ENXIO; } Index: sys/dev/hyperv/utilities/hv_kvp.c =================================================================== --- sys/dev/hyperv/utilities/hv_kvp.c +++ sys/dev/hyperv/utilities/hv_kvp.c @@ -69,6 +69,7 @@ #include "hv_util.h" #include "unicode.h" #include "hv_kvp.h" +#include "vmbus_if.h" /* hv_kvp defines */ #define BUFFERSIZE sizeof(struct hv_kvp_msg) @@ -89,7 +90,7 @@ log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) -static hv_guid service_guid = { .data = +static const hv_guid service_guid = { .data = {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; @@ -865,16 +866,13 @@ static int hv_kvp_probe(device_t dev) { - const char *p = vmbus_get_type(dev); - if (resource_disabled("hvkvp", 0)) return ENXIO; - if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { device_set_desc(dev, "Hyper-V KVP Service"); return BUS_PROBE_DEFAULT; } - return ENXIO; } Index: sys/dev/hyperv/utilities/hv_shutdown.c =================================================================== --- sys/dev/hyperv/utilities/hv_shutdown.c +++ sys/dev/hyperv/utilities/hv_shutdown.c @@ -41,8 +41,9 @@ #include #include "hv_util.h" +#include "vmbus_if.h" -static hv_guid service_guid = { .data = +static const hv_guid service_guid = { .data = {0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} }; @@ -115,16 +116,13 @@ static int hv_shutdown_probe(device_t dev) { - const char *p = vmbus_get_type(dev); - if (resource_disabled("hvshutdown", 0)) return ENXIO; - if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { device_set_desc(dev, "Hyper-V Shutdown Service"); return BUS_PROBE_DEFAULT; } - return ENXIO; } Index: sys/dev/hyperv/utilities/hv_timesync.c =================================================================== --- sys/dev/hyperv/utilities/hv_timesync.c +++ sys/dev/hyperv/utilities/hv_timesync.c @@ -41,6 +41,7 @@ #include #include "hv_util.h" +#include "vmbus_if.h" #define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */ #define HV_ICTIMESYNCFLAG_PROBE 0 @@ -54,7 +55,7 @@ } time_sync_data; /* Time Synch Service */ -static hv_guid service_guid = {.data = +static const hv_guid service_guid = {.data = {0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }; @@ -170,16 +171,13 @@ static int hv_timesync_probe(device_t dev) { - const char *p = vmbus_get_type(dev); - if (resource_disabled("hvtimesync", 0)) return ENXIO; - if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { device_set_desc(dev, "Hyper-V Time Synch Service"); return BUS_PROBE_DEFAULT; } - return ENXIO; } Index: sys/dev/hyperv/vmbus/vmbus.c =================================================================== --- sys/dev/hyperv/vmbus/vmbus.c +++ sys/dev/hyperv/vmbus/vmbus.c @@ -1090,6 +1090,16 @@ } static int +vmbus_probe_guid_method(device_t bus, device_t dev, const struct hv_guid *guid) +{ + struct hv_device *hv_dev = device_get_ivars(dev); + + if (memcmp(&hv_dev->class_id, guid, sizeof(struct hv_guid)) == 0) + return 0; + return ENXIO; +} + +static int vmbus_probe(device_t dev) { char *id[] = { "VMBUS", NULL }; @@ -1306,6 +1316,7 @@ /* Vmbus interface */ DEVMETHOD(vmbus_get_version, vmbus_get_version_method), + DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), DEVMETHOD_END }; Index: sys/dev/hyperv/vmbus/vmbus_if.m =================================================================== --- sys/dev/hyperv/vmbus/vmbus_if.m +++ sys/dev/hyperv/vmbus/vmbus_if.m @@ -31,7 +31,17 @@ INTERFACE vmbus; +HEADER { + struct hv_guid; +}; + METHOD uint32_t get_version { device_t bus; device_t dev; }; + +METHOD int probe_guid { + device_t bus; + device_t dev; + const struct hv_guid *guid; +}; Index: sys/modules/hyperv/utilities/Makefile =================================================================== --- sys/modules/hyperv/utilities/Makefile +++ sys/modules/hyperv/utilities/Makefile @@ -4,7 +4,7 @@ KMOD= hv_utils SRCS= hv_util.c hv_kvp.c hv_timesync.c hv_shutdown.c hv_heartbeat.c -SRCS+= bus_if.h device_if.h +SRCS+= bus_if.h device_if.h vmbus_if.h CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ -I${.CURDIR}/../../../dev/hyperv/vmbus