Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/vmbus/vmbus.c
Show First 20 Lines • Show All 954 Lines • ▼ Show 20 Lines | if (VMBUS_PCPU_GET(sc, message_tq, cpu) != NULL) { | ||||
VMBUS_PCPU_GET(sc, message_tq, cpu) = NULL; | VMBUS_PCPU_GET(sc, message_tq, cpu) = NULL; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
vmbus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) | vmbus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) | ||||
{ | { | ||||
struct hv_device *child_dev_ctx = device_get_ivars(child); | |||||
switch (index) { | |||||
case HV_VMBUS_IVAR_TYPE: | |||||
*result = (uintptr_t)&child_dev_ctx->class_id; | |||||
return (0); | |||||
case HV_VMBUS_IVAR_INSTANCE: | |||||
*result = (uintptr_t)&child_dev_ctx->device_id; | |||||
return (0); | |||||
case HV_VMBUS_IVAR_DEVCTX: | |||||
*result = (uintptr_t)child_dev_ctx; | |||||
return (0); | |||||
case HV_VMBUS_IVAR_NODE: | |||||
*result = (uintptr_t)child_dev_ctx->device; | |||||
return (0); | |||||
case HV_VMBUS_IVAR_CHAN: | |||||
*result = (uintptr_t)child_dev_ctx->channel; | |||||
return (0); | |||||
} | |||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
static int | static int | ||||
vmbus_child_pnpinfo_str(device_t dev, device_t child, char *buf, size_t buflen) | vmbus_child_pnpinfo_str(device_t dev, device_t child, char *buf, size_t buflen) | ||||
{ | { | ||||
const struct hv_vmbus_channel *chan; | const struct hv_vmbus_channel *chan; | ||||
char guidbuf[HYPERV_GUID_STRLEN]; | char guidbuf[HYPERV_GUID_STRLEN]; | ||||
if (device_get_ivars(child) == NULL) { | chan = vmbus_get_channel(child); | ||||
if (chan == NULL) { | |||||
/* Event timer device, which does not belong to a channel */ | /* Event timer device, which does not belong to a channel */ | ||||
return (0); | return (0); | ||||
} | } | ||||
chan = vmbus_get_channel(child); | |||||
strlcat(buf, "classid=", buflen); | strlcat(buf, "classid=", buflen); | ||||
hyperv_guid2str(&chan->ch_guid_type, guidbuf, sizeof(guidbuf)); | hyperv_guid2str(&chan->ch_guid_type, guidbuf, sizeof(guidbuf)); | ||||
strlcat(buf, guidbuf, buflen); | strlcat(buf, guidbuf, buflen); | ||||
strlcat(buf, " deviceid=", buflen); | strlcat(buf, " deviceid=", buflen); | ||||
hyperv_guid2str(&chan->ch_guid_inst, guidbuf, sizeof(guidbuf)); | hyperv_guid2str(&chan->ch_guid_inst, guidbuf, sizeof(guidbuf)); | ||||
strlcat(buf, guidbuf, buflen); | strlcat(buf, guidbuf, buflen); | ||||
return (0); | return (0); | ||||
} | } | ||||
struct hv_device * | |||||
hv_vmbus_child_device_create(struct hv_vmbus_channel *channel) | |||||
{ | |||||
hv_device *child_dev; | |||||
/* | |||||
* Allocate the new child device | |||||
*/ | |||||
child_dev = malloc(sizeof(hv_device), M_DEVBUF, M_WAITOK | M_ZERO); | |||||
child_dev->channel = channel; | |||||
child_dev->class_id = channel->ch_guid_type; | |||||
child_dev->device_id = channel->ch_guid_inst; | |||||
return (child_dev); | |||||
} | |||||
int | int | ||||
hv_vmbus_child_device_register(struct hv_vmbus_channel *chan) | hv_vmbus_child_device_register(struct hv_vmbus_channel *chan) | ||||
{ | { | ||||
struct vmbus_softc *sc = chan->vmbus_sc; | struct vmbus_softc *sc = chan->vmbus_sc; | ||||
device_t parent = sc->vmbus_dev; | device_t parent = sc->vmbus_dev; | ||||
int error = 0; | int error = 0; | ||||
chan->ch_dev = device_add_child(parent, NULL, -1); | chan->ch_dev = device_add_child(parent, NULL, -1); | ||||
if (chan->ch_dev == NULL) { | if (chan->ch_dev == NULL) { | ||||
device_printf(parent, "device_add_child for chan%u failed\n", | device_printf(parent, "device_add_child for chan%u failed\n", | ||||
chan->ch_id); | chan->ch_id); | ||||
error = ENXIO; | error = ENXIO; | ||||
goto done; | goto done; | ||||
} | } | ||||
chan->device->device = chan->ch_dev; | device_set_ivars(chan->ch_dev, chan); | ||||
device_set_ivars(chan->ch_dev, chan->device); | |||||
done: | done: | ||||
/* New device has been/should be added to vmbus. */ | /* New device has been/should be added to vmbus. */ | ||||
vmbus_scan_newdev(sc); | vmbus_scan_newdev(sc); | ||||
return error; | return error; | ||||
} | } | ||||
int | int | ||||
▲ Show 20 Lines • Show All 291 Lines • Show Last 20 Lines |