@@ -414,57 +414,53 @@ static inline uint32_t pci_pdev_get_nr_bars(uint8_t hdr_type)
414
414
*/
415
415
static void pci_read_cap (struct pci_pdev * pdev )
416
416
{
417
- uint8_t ptr , cap ;
417
+ uint8_t pos , cap ;
418
418
uint32_t msgctrl ;
419
- uint32_t len , offset , idx ;
419
+ uint32_t len , idx ;
420
420
uint32_t table_info ;
421
421
uint32_t pcie_devcap , val ;
422
422
423
- ptr = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , PCIR_CAP_PTR , 1U );
423
+ pos = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , PCIR_CAP_PTR , 1U );
424
424
425
- while ((ptr != 0U ) && (ptr != 0xFFU )) {
426
- cap = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , ptr + PCICAP_ID , 1U );
425
+ while ((pos != 0U ) && (pos != 0xFFU )) {
426
+ cap = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , pos + PCICAP_ID , 1U );
427
427
428
- /* Ignore all other Capability IDs for now */
429
- if ((cap == PCIY_MSI ) || (cap == PCIY_MSIX ) || (cap == PCIY_PCIE ) || (cap == PCIY_AF )) {
430
- offset = ptr ;
431
- if (cap == PCIY_MSI ) {
432
- pdev -> msi_capoff = offset ;
433
- } else if (cap == PCIY_MSIX ) {
434
- pdev -> msix .capoff = offset ;
435
- pdev -> msix .caplen = MSIX_CAPLEN ;
436
- len = pdev -> msix .caplen ;
428
+ if (cap == PCIY_MSI ) {
429
+ pdev -> msi_capoff = pos ;
430
+ } else if (cap == PCIY_MSIX ) {
431
+ pdev -> msix .capoff = pos ;
432
+ pdev -> msix .caplen = MSIX_CAPLEN ;
433
+ len = pdev -> msix .caplen ;
437
434
438
- msgctrl = pci_pdev_read_cfg (pdev -> bdf , pdev -> msix .capoff + PCIR_MSIX_CTRL , 2U );
435
+ msgctrl = pci_pdev_read_cfg (pdev -> bdf , pdev -> msix .capoff + PCIR_MSIX_CTRL , 2U );
439
436
440
- /* Read Table Offset and Table BIR */
441
- table_info = pci_pdev_read_cfg (pdev -> bdf , pdev -> msix .capoff + PCIR_MSIX_TABLE , 4U );
437
+ /* Read Table Offset and Table BIR */
438
+ table_info = pci_pdev_read_cfg (pdev -> bdf , pdev -> msix .capoff + PCIR_MSIX_TABLE , 4U );
442
439
443
- pdev -> msix .table_bar = (uint8_t )(table_info & PCIM_MSIX_BIR_MASK );
440
+ pdev -> msix .table_bar = (uint8_t )(table_info & PCIM_MSIX_BIR_MASK );
444
441
445
- pdev -> msix .table_offset = table_info & ~PCIM_MSIX_BIR_MASK ;
446
- pdev -> msix .table_count = (msgctrl & PCIM_MSIXCTRL_TABLE_SIZE ) + 1U ;
442
+ pdev -> msix .table_offset = table_info & ~PCIM_MSIX_BIR_MASK ;
443
+ pdev -> msix .table_count = (msgctrl & PCIM_MSIXCTRL_TABLE_SIZE ) + 1U ;
447
444
448
- ASSERT (pdev -> msix .table_count <= CONFIG_MAX_MSIX_TABLE_NUM );
445
+ ASSERT (pdev -> msix .table_count <= CONFIG_MAX_MSIX_TABLE_NUM );
449
446
450
- /* Copy MSIX capability struct into buffer */
451
- for (idx = 0U ; idx < len ; idx ++ ) {
452
- pdev -> msix .cap [idx ] = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , offset + idx , 1U );
453
- }
454
- } else if (cap == PCIY_PCIE ) {
455
- /* PCI Express Capability */
456
- pdev -> pcie_capoff = offset ;
457
- pcie_devcap = pci_pdev_read_cfg (pdev -> bdf , offset + PCIR_PCIE_DEVCAP , 4U );
458
- pdev -> has_flr = ((pcie_devcap & PCIM_PCIE_FLRCAP ) != 0U ) ? true : false;
459
- } else {
460
- /* Conventional PCI Advanced Features Capability */
461
- pdev -> af_capoff = offset ;
462
- val = pci_pdev_read_cfg (pdev -> bdf , offset , 4U );
463
- pdev -> has_af_flr = ((val & PCIM_AF_FLR_CAP ) != 0U ) ? true : false;
447
+ /* Copy MSIX capability struct into buffer */
448
+ for (idx = 0U ; idx < len ; idx ++ ) {
449
+ pdev -> msix .cap [idx ] = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , (uint32_t )pos + idx , 1U );
464
450
}
451
+ } else if (cap == PCIY_PCIE ) {
452
+ pdev -> pcie_capoff = pos ;
453
+ pcie_devcap = pci_pdev_read_cfg (pdev -> bdf , pos + PCIR_PCIE_DEVCAP , 4U );
454
+ pdev -> has_flr = ((pcie_devcap & PCIM_PCIE_FLRCAP ) != 0U ) ? true : false;
455
+ } else if (cap == PCIY_AF ) {
456
+ pdev -> af_capoff = pos ;
457
+ val = pci_pdev_read_cfg (pdev -> bdf , pos , 4U );
458
+ pdev -> has_af_flr = ((val & PCIM_AF_FLR_CAP ) != 0U ) ? true : false;
459
+ } else {
460
+ /* Ignore all other Capability IDs for now */
465
461
}
466
462
467
- ptr = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , ptr + PCICAP_NEXTPTR , 1U );
463
+ pos = (uint8_t )pci_pdev_read_cfg (pdev -> bdf , pos + PCICAP_NEXTPTR , 1U );
468
464
}
469
465
}
470
466
0 commit comments