@@ -481,98 +481,6 @@ int PciHandle::openMcfgTable() {
481
481
return handle;
482
482
}
483
483
484
- #ifndef PCM_USE_PCI_MM_LINUX
485
-
486
- PciHandleM::PciHandleM (uint32 bus_, uint32 device_, uint32 function_) :
487
- fd(-1 ),
488
- bus(bus_),
489
- device(device_),
490
- function(function_),
491
- base_addr(0 )
492
- {
493
- int handle = ::open (" /dev/mem" , O_RDWR);
494
- if (handle < 0 ) throw std::exception ();
495
- fd = handle;
496
-
497
- int mcfg_handle = PciHandle::openMcfgTable ();
498
- if (mcfg_handle < 0 ) throw std::runtime_error (" Cannot open any of /[pcm]/sys/firmware/acpi/tables/MCFG* files!" );
499
-
500
- int32 result = ::pread (mcfg_handle, (void *)&base_addr, sizeof (uint64), 44 );
501
-
502
- if (result != sizeof (uint64))
503
- {
504
- ::close (mcfg_handle);
505
- throw std::exception ();
506
- }
507
-
508
- unsigned char max_bus = 0 ;
509
-
510
- result = ::pread (mcfg_handle, (void *)&max_bus, sizeof (unsigned char ), 55 );
511
-
512
- ::close (mcfg_handle);
513
- if (result != sizeof (unsigned char ))
514
- {
515
- throw std::exception ();
516
- }
517
-
518
- if (bus > (unsigned )max_bus)
519
- {
520
- std::cout << " WARNING: Requested bus number " << bus << " is larger than the max bus number " << (unsigned )max_bus << " \n " ;
521
- throw std::exception ();
522
- }
523
-
524
- // std::cout << "PCI config base addr: "<< std::hex << base_addr<< "\n" << std::dec;
525
-
526
- base_addr += (bus * 1024ULL * 1024ULL + device * 32ULL * 1024ULL + function * 4ULL * 1024ULL );
527
- }
528
-
529
-
530
- bool PciHandleM::exists (uint32 /* groupnr_*/ , uint32 /* bus_*/ , uint32 /* device_ */ , uint32 /* function_ */ )
531
- {
532
- int handle = ::open (" /dev/mem" , O_RDWR);
533
-
534
- if (handle < 0 ) {
535
- perror (" error opening /dev/mem" );
536
- return false ;
537
- }
538
-
539
- ::close (handle);
540
-
541
- handle = PciHandle::openMcfgTable ();
542
- if (handle < 0 ) {
543
- return false ;
544
- }
545
-
546
- ::close (handle);
547
-
548
- return true ;
549
- }
550
-
551
- int32 PciHandleM::read32 (uint64 offset, uint32 * value)
552
- {
553
- warnAlignment<4 >(" PciHandleM::read32" , false , offset);
554
- return ::pread (fd, (void *)value, sizeof (uint32), offset + base_addr);
555
- }
556
-
557
- int32 PciHandleM::write32 (uint64 offset, uint32 value)
558
- {
559
- warnAlignment<4 >(" PciHandleM::write32" , false , offset);
560
- return ::pwrite (fd, (const void *)&value, sizeof (uint32), offset + base_addr);
561
- }
562
-
563
- int32 PciHandleM::read64 (uint64 offset, uint64 * value)
564
- {
565
- warnAlignment<4 >(" PciHandleM::read64" , false , offset);
566
- return ::pread (fd, (void *)value, sizeof (uint64), offset + base_addr);
567
- }
568
-
569
- PciHandleM::~PciHandleM ()
570
- {
571
- if (fd >= 0 ) ::close (fd);
572
- }
573
-
574
- #endif // PCM_USE_PCI_MM_LINUX
575
-
576
484
// mmapped I/O version
577
485
578
486
MCFGHeader PciHandleMM::mcfgHeader;
0 commit comments