ClientBW::ClientBW() : fd(-1), mmapAddr(NULL) { int handle = ::open("/dev/mem", O_RDONLY); if (handle < 0) throw std::exception(); fd = handle; PciHandleM imcHandle(0,0,0,0); // memory controller device coordinates: domain 0, bus 0, device 0, function 0 uint64 imcbar = 0; imcHandle.read64(PCM_CLIENT_IMC_BAR_OFFSET, &imcbar); // std::cout << "DEBUG: imcbar="<<std::hex << imcbar <<std::endl; if(!imcbar) { std::cerr <<"ERROR: imcbar is zero." << std::endl; throw std::exception(); } uint64 startAddr = imcbar & (~(4096-1)); // round down to 4K // std::cout << "DEBUG: startAddr="<<std::hex << startAddr <<std::endl; mmapAddr = (char*) mmap(NULL, PCM_CLIENT_IMC_MMAP_SIZE, PROT_READ, MAP_SHARED , fd, startAddr); if(mmapAddr == MAP_FAILED) { std::cout << "mmap failed: errno is "<< errno<< " ("<< strerror(errno) << ")"<< std::endl; throw std::exception(); } }
ClientBW::ClientBW() : pmem(new PCMPmem()) { pmem->install_driver(false); pmem->set_acquisition_mode(PMEM_MODE_IOSPACE); PciHandleM imcHandle(0,0,0,0); // memory controller device coordinates: domain 0, bus 0, device 0, function 0 uint64 imcbar = 0; imcHandle.read64(PCM_CLIENT_IMC_BAR_OFFSET, &imcbar); // std::cout << "DEBUG: imcbar="<<std::hex << imcbar <<std::endl; if(!imcbar) { std::cerr <<"ERROR: imcbar is zero." << std::endl; throw std::exception(); } startAddr = imcbar & (~(4096ULL-1ULL)); // round down to 4K }