void virtio_describe(device_t dev, const char *msg, uint64_t features, struct virtio_feature_desc *feature_desc) { struct sbuf sb; uint64_t val; char *buf; const char *name; int n; if ((buf = malloc(512, M_TEMP, M_NOWAIT)) == NULL) { device_printf(dev, "%s features: 0x%"PRIx64"\n", msg, features); return; } sbuf_new(&sb, buf, 512, SBUF_FIXEDLEN); sbuf_printf(&sb, "%s features: 0x%"PRIx64, msg, features); for (n = 0, val = 1ULL << 63; val != 0; val >>= 1) { /* * BAD_FEATURE is used to detect broken Linux clients * and therefore is not applicable to FreeBSD. */ if (((features & val) == 0) || val == VIRTIO_F_BAD_FEATURE) continue; if (n++ == 0) sbuf_cat(&sb, " <"); else sbuf_cat(&sb, ","); name = NULL; if (feature_desc != NULL) name = virtio_feature_name(val, feature_desc); if (name == NULL) name = virtio_feature_name(val, virtio_common_feature_desc); if (name == NULL) sbuf_printf(&sb, "0x%"PRIx64, val); else sbuf_cat(&sb, name); } if (n > 0) sbuf_cat(&sb, ">"); #if __FreeBSD_version < 900020 sbuf_finish(&sb); if (sbuf_overflowed(&sb) == 0) #else if (sbuf_finish(&sb) == 0) #endif device_printf(dev, "%s\n", sbuf_data(&sb)); sbuf_delete(&sb); free(buf, M_TEMP); }
void virtio_describe(struct virtio_device *dev, const char *msg, uint32_t features, struct virtio_feature_desc *desc) { (void)dev; (void)msg; (void)features; // TODO: Not used currently - keeping it for future use virtio_feature_name(0, desc); }