Changeset 21ff054 in mainline
- Timestamp:
- 2018-05-22T19:06:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5f03107
- Parents:
- 4e2d387
- git-author:
- Jakub Jermar <jakub@…> (2018-04-25 19:17:47)
- git-committer:
- Jakub Jermar <jakub@…> (2018-05-22 19:06:50)
- Location:
- uspace/lib/virtio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/virtio/virtio-pci.c
r4e2d387 r21ff054 180 180 */ 181 181 uint8_t c; 182 uint8_t id;183 for (rc = pci_config_space_cap_first(pci_sess, &c, & id);182 uint8_t cap_vndr; 183 for (rc = pci_config_space_cap_first(pci_sess, &c, &cap_vndr); 184 184 (rc == EOK) && c; 185 rc = pci_config_space_cap_next(pci_sess, &c, & id)) {186 if ( id!= PCI_CAP_VENDORSPECID)185 rc = pci_config_space_cap_next(pci_sess, &c, &cap_vndr)) { 186 if (cap_vndr != PCI_CAP_VENDORSPECID) 187 187 continue; 188 188 189 uint8_t type; 190 rc = pci_config_space_read_8(pci_sess, VIRTIO_PCI_CAP_TYPE(c), 191 &type); 189 uint8_t cap_len; 190 rc = pci_config_space_read_8(pci_sess, 191 VIRTIO_PCI_CAP_CAP_LEN(c), &cap_len); 192 if (rc != EOK) 193 goto error; 194 195 if (cap_len < VIRTIO_PCI_CAP_END(0)) { 196 rc = EINVAL; 197 goto error; 198 } 199 200 uint8_t cfg_type; 201 rc = pci_config_space_read_8(pci_sess, 202 VIRTIO_PCI_CAP_CFG_TYPE(c), &cfg_type); 192 203 if (rc != EOK) 193 204 goto error; … … 212 223 213 224 uint32_t multiplier; 214 switch ( type) {225 switch (cfg_type) { 215 226 case VIRTIO_PCI_CAP_COMMON_CFG: 216 227 virtio_pci_common_cfg(vdev, bar, offset, length); 217 228 break; 218 229 case VIRTIO_PCI_CAP_NOTIFY_CFG: 230 if (cap_len < VIRTIO_PCI_CAP_END(sizeof(uint32_t))) { 231 rc = EINVAL; 232 goto error; 233 } 219 234 rc = pci_config_space_read_32(pci_sess, 220 235 VIRTIO_PCI_CAP_END(c), &multiplier); -
uspace/lib/virtio/virtio-pci.h
r4e2d387 r21ff054 37 37 #include <ddi.h> 38 38 39 #define VIRTIO_PCI_CAP_TYPE(c) ((c) + 3) 39 #define VIRTIO_PCI_CAP_CAP_LEN(c) ((c) + 2) 40 #define VIRTIO_PCI_CAP_CFG_TYPE(c) ((c) + 3) 40 41 #define VIRTIO_PCI_CAP_BAR(c) ((c) + 4) 41 42 #define VIRTIO_PCI_CAP_OFFSET(c) ((c) + 8)
Note:
See TracChangeset
for help on using the changeset viewer.