Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c1ba24a in mainline


Ignore:
Timestamp:
2018-05-23T20:38:54Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
5dddac1
Parents:
9364ced
Message:

Allow descriptors to be set and made available

Location:
uspace/lib/virtio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/virtio/virtio-pci.h

    r9364ced rc1ba24a  
    174174} virtio_dev_t;
    175175
     176extern void virtio_virtq_set_desc(virtio_dev_t *vdev, uint16_t, uint16_t,
     177    uint64_t, uint32_t, uint16_t, uint16_t);
     178
     179extern void virtio_virtq_produce_available(virtio_dev_t *, uint16_t, uint16_t);
     180
    176181extern errno_t virtio_virtq_setup(virtio_dev_t *, uint16_t, uint16_t);
    177182extern void virtio_virtq_teardown(virtio_dev_t *, uint16_t);
  • uspace/lib/virtio/virtio.c

    r9364ced rc1ba24a  
    3737
    3838#include <ddf/log.h>
     39#include <libarch/barrier.h>
     40
     41void virtio_virtq_set_desc(virtio_dev_t *vdev, uint16_t num, uint16_t descno,
     42    uint64_t addr, uint32_t len, uint16_t flags, uint16_t next)
     43{
     44        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);
     49}
     50
     51void virtio_virtq_produce_available(virtio_dev_t *vdev, uint16_t num,
     52    uint16_t descno)
     53{
     54        virtq_t *q = &vdev->queues[num];
     55
     56        uint16_t idx = pio_read_16(&q->avail->idx);
     57        pio_write_16(&q->avail->ring[idx], descno);
     58        write_barrier();
     59        pio_write_16(&q->avail->idx, (idx + 1) % q->queue_size);
     60        write_barrier();
     61        pio_write_16(&q->notify, num);
     62}
    3963
    4064errno_t virtio_virtq_setup(virtio_dev_t *vdev, uint16_t num, uint16_t size)
Note: See TracChangeset for help on using the changeset viewer.