Ignore:
Timestamp:
2018-06-25T21:45:05Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8119363
Parents:
2498b95 (diff), e3107e2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'virtio-net'

This commit merges basic support for the virtio-net NIC. As of now, the
driver does not support any advanced features that might be supported by
the device. Also device removal is not yet supported.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/pci_dev_iface.h

    r2498b95 rfbfe59d  
    4242#define PCI_VENDOR_ID   0x00
    4343#define PCI_DEVICE_ID   0x02
     44#define PCI_STATUS      0x06
    4445#define PCI_SUB_CLASS   0x0A
    4546#define PCI_BASE_CLASS  0x0B
     47#define PCI_BAR0        0x10
     48#define PCI_CAP_PTR     0x34
     49
     50#define PCI_BAR_COUNT   6
     51
     52#define PCI_STATUS_CAP_LIST     (1 << 4)
     53
     54#define PCI_CAP_ID(c)   ((c) + 0x0)
     55#define PCI_CAP_NEXT(c) ((c) + 0x1)
     56
     57#define PCI_CAP_PMID            0x1
     58#define PCI_CAP_VENDORSPECID    0x9
    4659
    4760extern errno_t pci_config_space_read_8(async_sess_t *, uint32_t, uint8_t *);
     
    5265extern errno_t pci_config_space_write_16(async_sess_t *, uint32_t, uint16_t);
    5366extern errno_t pci_config_space_write_32(async_sess_t *, uint32_t, uint32_t);
     67
     68static inline errno_t
     69pci_config_space_cap_first(async_sess_t *sess, uint8_t *c, uint8_t *id)
     70{
     71        errno_t rc;
     72        uint16_t status;
     73
     74        rc = pci_config_space_read_16(sess, PCI_STATUS, &status);
     75        if (rc != EOK)
     76                return rc;
     77
     78        if (!(status & PCI_STATUS_CAP_LIST)) {
     79                *c = 0;
     80                return EOK;
     81        }
     82
     83        rc = pci_config_space_read_8(sess, PCI_CAP_PTR, c);
     84        if (rc != EOK)
     85                return rc;
     86        if (!c)
     87                return EOK;
     88        return pci_config_space_read_8(sess, PCI_CAP_ID(*c), id);
     89}
     90
     91static inline errno_t
     92pci_config_space_cap_next(async_sess_t *sess, uint8_t *c, uint8_t *id)
     93{
     94        errno_t rc = pci_config_space_read_8(sess, PCI_CAP_NEXT(*c), c);
     95        if (rc != EOK)
     96                return rc;
     97        if (!c)
     98                return EOK;
     99        return pci_config_space_read_8(sess, PCI_CAP_ID(*c), id);
     100}
    54101
    55102/** PCI device communication interface. */
Note: See TracChangeset for help on using the changeset viewer.