Lines Matching +full:endianness +full:- +full:agnostic
1 /*-
7 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
108 if (sc->platform != NULL) \
109 VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v)); \
110 bus_write_1((sc)->res[0], (o), (v)); \
111 if (sc->platform != NULL) \
112 VIRTIO_MMIO_NOTE(sc->platform, (o), (v)); \
116 if (sc->platform != NULL) \
117 VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v)); \
118 bus_write_2((sc)->res[0], (o), (v)); \
119 if (sc->platform != NULL) \
120 VIRTIO_MMIO_NOTE(sc->platform, (o), (v)); \
124 if (sc->platform != NULL) \
125 VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v)); \
126 bus_write_4((sc)->res[0], (o), (v)); \
127 if (sc->platform != NULL) \
128 VIRTIO_MMIO_NOTE(sc->platform, (o), (v)); \
132 bus_read_1((sc)->res[0], (o))
134 bus_read_2((sc)->res[0], (o))
136 bus_read_4((sc)->res[0], (o))
186 sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in vtmmio_probe()
188 if (sc->res[0] == NULL) { in vtmmio_probe()
196 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res[0]); in vtmmio_probe()
203 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res[0]); in vtmmio_probe()
208 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res[0]); in vtmmio_probe()
212 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res[0]); in vtmmio_probe()
227 if (sc->platform != NULL) { in vtmmio_setup_intr()
228 err = VIRTIO_MMIO_SETUP_INTR(sc->platform, sc->dev, in vtmmio_setup_intr()
231 /* Okay we have backend-specific interrupts */ in vtmmio_setup_intr()
237 sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in vtmmio_setup_intr()
239 if (!sc->res[1]) { in vtmmio_setup_intr()
244 if (bus_setup_intr(dev, sc->res[1], type | INTR_MPSAFE, in vtmmio_setup_intr()
245 NULL, vtmmio_vq_intr, sc, &sc->ih)) { in vtmmio_setup_intr()
261 sc->dev = dev; in vtmmio_attach()
264 sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in vtmmio_attach()
266 if (sc->res[0] == NULL) { in vtmmio_attach()
271 sc->vtmmio_version = vtmmio_read_config_4(sc, VIRTIO_MMIO_VERSION); in vtmmio_attach()
278 if ((child = device_add_child(dev, NULL, -1)) == NULL) { in vtmmio_attach()
285 sc->vtmmio_child_dev = child; in vtmmio_attach()
305 if (sc->res[0] != NULL) { in vtmmio_detach()
307 sc->res[0]); in vtmmio_detach()
308 sc->res[0] = NULL; in vtmmio_detach()
368 if (sc->vtmmio_child_dev != child) in vtmmio_read_ivar()
383 * bus-agnostic virtio_child_pnpinfo. in vtmmio_read_ivar()
392 *result = sc->vtmmio_version > 1; in vtmmio_read_ivar()
408 if (sc->vtmmio_child_dev != child) in vtmmio_write_ivar()
413 sc->vtmmio_child_feat_desc = (void *) value; in vtmmio_write_ivar()
430 if (sc->vtmmio_version > 1) { in vtmmio_negotiate_features()
449 sc->vtmmio_features = features; in vtmmio_negotiate_features()
470 if (sc->vtmmio_version > 1) { in vtmmio_finalize_features()
472 * Must re-read the status after setting it to verify the in vtmmio_finalize_features()
494 return ((sc->vtmmio_features & feature) != 0); in vtmmio_with_feature()
505 if (sc->vtmmio_version == 1) { in vtmmio_set_virtqueue()
547 if (sc->vtmmio_nvqs != 0) in vtmmio_alloc_virtqueues()
552 sc->vtmmio_vqs = malloc(nvqs * sizeof(struct vtmmio_virtqueue), in vtmmio_alloc_virtqueues()
554 if (sc->vtmmio_vqs == NULL) in vtmmio_alloc_virtqueues()
557 if (sc->vtmmio_version == 1) { in vtmmio_alloc_virtqueues()
563 vqx = &sc->vtmmio_vqs[idx]; in vtmmio_alloc_virtqueues()
581 vqx->vtv_vq = *info->vqai_vq = vq; in vtmmio_alloc_virtqueues()
582 vqx->vtv_no_intr = info->vqai_intr == NULL; in vtmmio_alloc_virtqueues()
584 sc->vtmmio_nvqs++; in vtmmio_alloc_virtqueues()
607 if (sc->platform != NULL) in vtmmio_poll()
608 VIRTIO_MMIO_POLL(sc->platform); in vtmmio_poll()
640 if (sc->vtmmio_version == 1) { in vtmmio_reinit()
645 for (idx = 0; idx < sc->vtmmio_nvqs; idx++) { in vtmmio_reinit()
680 if (sc->vtmmio_version > 1) in vtmmio_config_generation()
724 * The non-legacy MMIO specification adds the following restriction: in vtmmio_read_dev_config()
726 * 4.2.2.2: For the device-specific configuration space, the driver in vtmmio_read_dev_config()
731 * The endianness also varies between non-legacy and legacy: in vtmmio_read_dev_config()
733 * 2.4: Note: The device configuration space uses the little-endian in vtmmio_read_dev_config()
734 * format for multi-byte fields. in vtmmio_read_dev_config()
738 * little-endian. The correct endian-ness is documented for each in vtmmio_read_dev_config()
741 if (sc->vtmmio_version > 1) { in vtmmio_read_dev_config()
764 for (d = dst; length > 0; d += size, off += size, length -= size) { in vtmmio_read_dev_config()
788 dev = sc->dev; in vtmmio_read_dev_config_8()
812 * The non-legacy MMIO specification adds size and alignment in vtmmio_write_dev_config()
813 * restrctions. It also changes the endianness from native-endian to in vtmmio_write_dev_config()
814 * little-endian. See vtmmio_read_dev_config. in vtmmio_write_dev_config()
816 if (sc->vtmmio_version > 1) { in vtmmio_write_dev_config()
842 for (s = src; length > 0; s += size, off += size, length -= size) { in vtmmio_write_dev_config()
865 dev = sc->dev; in vtmmio_describe_features()
866 child = sc->vtmmio_child_dev; in vtmmio_describe_features()
871 virtio_describe(dev, msg, features, sc->vtmmio_child_feat_desc); in vtmmio_describe_features()
879 dev = sc->dev; in vtmmio_probe_and_attach_child()
880 child = sc->vtmmio_child_dev; in vtmmio_probe_and_attach_child()
914 vqx = &sc->vtmmio_vqs[idx]; in vtmmio_reinit_virtqueue()
915 vq = vqx->vtv_vq; in vtmmio_reinit_virtqueue()
935 if (sc->ih != NULL) in vtmmio_free_interrupts()
936 bus_teardown_intr(sc->dev, sc->res[1], sc->ih); in vtmmio_free_interrupts()
938 if (sc->res[1] != NULL) in vtmmio_free_interrupts()
939 bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->res[1]); in vtmmio_free_interrupts()
948 for (idx = 0; idx < sc->vtmmio_nvqs; idx++) { in vtmmio_free_virtqueues()
949 vqx = &sc->vtmmio_vqs[idx]; in vtmmio_free_virtqueues()
952 if (sc->vtmmio_version > 1) { in vtmmio_free_virtqueues()
958 virtqueue_free(vqx->vtv_vq); in vtmmio_free_virtqueues()
959 vqx->vtv_vq = NULL; in vtmmio_free_virtqueues()
962 free(sc->vtmmio_vqs, M_DEVBUF); in vtmmio_free_virtqueues()
963 sc->vtmmio_vqs = NULL; in vtmmio_free_virtqueues()
964 sc->vtmmio_nvqs = 0; in vtmmio_free_virtqueues()
983 vtmmio_set_status(sc->dev, VIRTIO_CONFIG_STATUS_RESET); in vtmmio_reset()
1009 if (sc->vtmmio_child_dev != NULL) in vtmmio_vq_intr()
1010 VIRTIO_CONFIG_CHANGE(sc->vtmmio_child_dev); in vtmmio_vq_intr()
1014 for (idx = 0; idx < sc->vtmmio_nvqs; idx++) { in vtmmio_vq_intr()
1015 vqx = &sc->vtmmio_vqs[idx]; in vtmmio_vq_intr()
1016 if (vqx->vtv_no_intr == 0) { in vtmmio_vq_intr()
1017 vq = vqx->vtv_vq; in vtmmio_vq_intr()