Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <machine/intr_machdep.h> | #include <machine/intr_machdep.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/segments.h> | #include <machine/segments.h> | ||||
#include <sys/pcpu.h> | #include <sys/pcpu.h> | ||||
#include <x86/apicvar.h> | #include <x86/apicvar.h> | ||||
#include <dev/hyperv/include/hyperv.h> | |||||
#include "hv_vmbus_priv.h" | #include "hv_vmbus_priv.h" | ||||
#include <contrib/dev/acpica/include/acpi.h> | #include <contrib/dev/acpica/include/acpi.h> | ||||
#include "acpi_if.h" | #include "acpi_if.h" | ||||
static device_t vmbus_devp; | static device_t vmbus_devp; | ||||
static int vmbus_inited; | static int vmbus_inited; | ||||
static hv_setup_args setup_args; /* only CPU 0 supported at this time */ | static hv_setup_args setup_args; /* only CPU 0 supported at this time */ | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | hv_vmbus_child_device_create( | ||||
child_dev->channel = channel; | child_dev->channel = channel; | ||||
memcpy(&child_dev->class_id, &type, sizeof(hv_guid)); | memcpy(&child_dev->class_id, &type, sizeof(hv_guid)); | ||||
memcpy(&child_dev->device_id, &instance, sizeof(hv_guid)); | memcpy(&child_dev->device_id, &instance, sizeof(hv_guid)); | ||||
return (child_dev); | return (child_dev); | ||||
} | } | ||||
static void | int | ||||
print_dev_guid(struct hv_device *dev) | snprintf_hv_guid(char *buf, size_t sz, hv_guid *guid) | ||||
decui_microsoft.com: add "const" for the guid pointer. | |||||
{ | { | ||||
int i; | int cnt; | ||||
unsigned char guid_name[100]; | const unsigned char *d = guid->data; | ||||
Not Done Inline Actionsadd "const unsigned" for d. decui_microsoft.com: add "const unsigned" for d.
Note: unsigned is a must here, or *d can signed-expand to… | |||||
for (i = 0; i < 32; i += 2) | |||||
sprintf(&guid_name[i], "%02x", dev->class_id.data[i / 2]); | cnt = snprintf(buf, sz, | ||||
if(bootverbose) | "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", | ||||
printf("VMBUS: Class ID: %s\n", guid_name); | d[3], d[2], d[1], d[0], d[5], d[4], d[7], d[6], | ||||
Done Inline ActionsIt should be See https://en.wikipedia.org/wiki/Globally_unique_identifier (the first 4+2+2 bytes are in little endian on x86) decui_microsoft.com: It should be
d[3], d[2], d[1], d[0], d[5], d[4], d[7], d[6],
See https://en.wikipedia. | |||||
d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); | |||||
return (cnt); | |||||
Not Done Inline Actionsbefore "return", add KASSERT(cnt < sz, ("snprintf_hv_guid: too small buf: cnt=%d!\n", cnt)); decui_microsoft.com: before "return", add
KASSERT(cnt < sz, ("snprintf_hv_guid: too small buf: cnt=%d!\n", cnt)); | |||||
} | } | ||||
int | int | ||||
hv_vmbus_child_device_register(struct hv_device *child_dev) | hv_vmbus_child_device_register(struct hv_device *child_dev) | ||||
{ | { | ||||
device_t child; | device_t child; | ||||
int ret = 0; | int ret = 0; | ||||
print_dev_guid(child_dev); | if (bootverbose) { | ||||
char name[40]; | |||||
snprintf_hv_guid(name, sizeof(name), &child_dev->class_id); | |||||
printf("VMBUS: Class ID: %s\n", name); | |||||
} | |||||
child = device_add_child(vmbus_devp, NULL, -1); | child = device_add_child(vmbus_devp, NULL, -1); | ||||
child_dev->device = child; | child_dev->device = child; | ||||
device_set_ivars(child, child_dev); | device_set_ivars(child, child_dev); | ||||
mtx_lock(&Giant); | mtx_lock(&Giant); | ||||
ret = device_probe_and_attach(child); | ret = device_probe_and_attach(child); | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
▲ Show 20 Lines • Show All 403 Lines • Show Last 20 Lines |
add "const" for the guid pointer.