Changeset 9af56b6 in mainline for uspace/lib/virtio/virtio.c


Ignore:
Timestamp:
2018-05-23T21:12:28Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
31cf8c3c
Parents:
85be731
git-author:
Jakub Jermar <jakub@…> (2018-05-23 21:12:24)
git-committer:
Jakub Jermar <jakub@…> (2018-05-23 21:12:28)
Message:

Use little-endian accessors for virtio PIO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/virtio/virtio.c

    r85be731 r9af56b6  
    4343{
    4444        virtq_desc_t *d = &vdev->queues[num].desc[descno];
    45         pio_write_64(&d->addr, addr);
    46         pio_write_32(&d->len, len);
    47         pio_write_16(&d->flags, flags);
    48         pio_write_16(&d->next, next);
     45        pio_write_le64(&d->addr, addr);
     46        pio_write_le32(&d->len, len);
     47        pio_write_le16(&d->flags, flags);
     48        pio_write_le16(&d->next, next);
    4949}
    5050
     
    5454        virtq_t *q = &vdev->queues[num];
    5555
    56         uint16_t idx = pio_read_16(&q->avail->idx);
    57         pio_write_16(&q->avail->ring[idx], descno);
     56        uint16_t idx = pio_read_le16(&q->avail->idx);
     57        pio_write_le16(&q->avail->ring[idx], descno);
    5858        write_barrier();
    59         pio_write_16(&q->avail->idx, (idx + 1) % q->queue_size);
     59        pio_write_le16(&q->avail->idx, (idx + 1) % q->queue_size);
    6060        write_barrier();
    61         pio_write_16(q->notify, num);
     61        pio_write_le16(q->notify, num);
    6262}
    6363
     
    6868
    6969        /* Program the queue of our interest */
    70         pio_write_16(&cfg->queue_select, num);
     70        pio_write_le16(&cfg->queue_select, num);
    7171
    7272        /* Trim the size of the queue as needed */
     
    7575                return ENOMEM;
    7676        }
    77         pio_write_16(&cfg->queue_size, size);
     77        pio_write_le16(&cfg->queue_size, size);
    7878        ddf_msg(LVL_NOTE, "Virtq %u: %u descriptors", num, (unsigned) size);
    7979
     
    126126         * Write the configured addresses to device's common config
    127127         */
    128         pio_write_64(&cfg->queue_desc, q->phys);
    129         pio_write_64(&cfg->queue_avail, q->phys + avail_offset);
    130         pio_write_64(&cfg->queue_used, q->phys + used_offset);
     128        pio_write_le64(&cfg->queue_desc, q->phys);
     129        pio_write_le64(&cfg->queue_avail, q->phys + avail_offset);
     130        pio_write_le64(&cfg->queue_used, q->phys + used_offset);
    131131
    132132        ddf_msg(LVL_NOTE, "DMA memory for virtq %d: virt=%p, phys=%p, size=%zu",
     
    135135        /* Determine virtq's notification address */
    136136        q->notify = vdev->notify_base +
    137             pio_read_16(&cfg->queue_notif_off) * vdev->notify_off_multiplier;
     137            pio_read_le16(&cfg->queue_notif_off) * vdev->notify_off_multiplier;
    138138
    139139        ddf_msg(LVL_NOTE, "notification register: %p", q->notify);
     
    170170
    171171        /* 4. Read the offered feature flags */
    172         pio_write_32(&cfg->device_feature_select, VIRTIO_FEATURES_0_31);
    173         uint32_t device_features = pio_read_32(&cfg->device_feature);
     172        pio_write_le32(&cfg->device_feature_select, VIRTIO_FEATURES_0_31);
     173        uint32_t device_features = pio_read_le32(&cfg->device_feature);
    174174
    175175        ddf_msg(LVL_NOTE, "offered features %x", device_features);
     
    180180
    181181        /* 4. Write the accepted feature flags */
    182         pio_write_32(&cfg->driver_feature_select, VIRTIO_FEATURES_0_31);
    183         pio_write_32(&cfg->driver_feature, features);
     182        pio_write_le32(&cfg->driver_feature_select, VIRTIO_FEATURES_0_31);
     183        pio_write_le32(&cfg->driver_feature, features);
    184184
    185185        ddf_msg(LVL_NOTE, "accepted features %x", features);
Note: See TracChangeset for help on using the changeset viewer.