diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index f5817da5..67c756d4 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -2307,27 +2307,30 @@ void PCM::initUncorePMUsDirect() { if (uncorePMUDiscovery.get()) { - for (size_t box = 0; box < uncorePMUDiscovery->getNumBoxes(pmuType, s); ++box) + for (size_t die = 0; die < uncorePMUDiscovery->getNumDies(s); ++die) { - if (uncorePMUDiscovery->getBoxAccessType(pmuType, s, box) == UncorePMUDiscovery::accessTypeEnum::MSR - && uncorePMUDiscovery->getBoxNumRegs(pmuType, s, box) >= 4) + for (size_t box = 0; box < uncorePMUDiscovery->getNumBoxes(pmuType, s, die); ++box) { - out.push_back( - std::make_shared( - std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box, 0)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box, 1)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box, 2)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box, 3)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, box, 0)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, box, 1)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, box, 2)), - std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, box, 3)), - std::shared_ptr(), - std::shared_ptr(), - (filter0 < 0) ? std::shared_ptr() : std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, box) + filter0) // filters not supported by discovery - ) - ); + if (uncorePMUDiscovery->getBoxAccessType(pmuType, s, die, box) == UncorePMUDiscovery::accessTypeEnum::MSR + && uncorePMUDiscovery->getBoxNumRegs(pmuType, s, die, box) >= 4) + { + out.push_back( + std::make_shared( + std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box, 0)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box, 1)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box, 2)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box, 3)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, die, box, 0)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, die, box, 1)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, die, box, 2)), + std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(pmuType, s, die, box, 3)), + std::shared_ptr(), + std::shared_ptr(), + (filter0 < 0) ? std::shared_ptr() : std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(pmuType, s, die, box) + filter0) // filters not supported by discovery + ) + ); + } } } } @@ -2918,17 +2921,17 @@ void PCM::initUncorePMUsDirect() { if (uncorePMUDiscovery.get()) { - auto createCXLPMU = [this](const uint32 s, const unsigned BoxType, const size_t pos) -> UncorePMU + auto createCXLPMU = [this](const uint32 s, const size_t die, const unsigned BoxType, const size_t pos) -> UncorePMU { std::vector > CounterControlRegs, CounterValueRegs; - const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, s, pos); - const auto unitControlAddr = uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, pos); + const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, s, die, pos); + const auto unitControlAddr = uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, die, pos); const auto unitControlAddrAligned = unitControlAddr & ~4095ULL; auto handle = std::make_shared(unitControlAddrAligned, CXL_PMON_SIZE, false); for (size_t r = 0; r < n_regs; ++r) { - CounterControlRegs.push_back(std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, pos, r) - unitControlAddrAligned)); - CounterValueRegs.push_back(std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(BoxType, s, pos, r) - unitControlAddrAligned)); + CounterControlRegs.push_back(std::make_shared(handle, uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, die, pos, r) - unitControlAddrAligned)); + CounterValueRegs.push_back(std::make_shared(handle, uncorePMUDiscovery->getBoxCtrAddr(BoxType, s, die, pos, r) - unitControlAddrAligned)); } return UncorePMU(std::make_shared(handle, unitControlAddr - unitControlAddrAligned), CounterControlRegs, CounterValueRegs); }; @@ -2940,18 +2943,19 @@ void PCM::initUncorePMUsDirect() case PCM::GNR: case PCM::GNR_D: case PCM::SRF: + for (size_t die = 0; die < uncorePMUDiscovery->getNumDies(s); ++die) { - const auto n_units = (std::min)(uncorePMUDiscovery->getNumBoxes(SPR_CXLCM_BOX_TYPE, s), - uncorePMUDiscovery->getNumBoxes(SPR_CXLDP_BOX_TYPE, s)); + const auto n_units = (std::min)(uncorePMUDiscovery->getNumBoxes(SPR_CXLCM_BOX_TYPE, s, die), + uncorePMUDiscovery->getNumBoxes(SPR_CXLDP_BOX_TYPE, s, die)); for (size_t pos = 0; pos < n_units; ++pos) { try { - cxlPMUs[s].push_back(std::make_pair(createCXLPMU(s, SPR_CXLCM_BOX_TYPE, pos), createCXLPMU(s, SPR_CXLDP_BOX_TYPE, pos))); + cxlPMUs[s].push_back(std::make_pair(createCXLPMU(s, die, SPR_CXLCM_BOX_TYPE, pos), createCXLPMU(s, die, SPR_CXLDP_BOX_TYPE, pos))); } catch (const std::exception& e) { - std::cerr << "CXL PMU initialization for socket " << s << " at position " << pos << " failed: " << e.what() << std::endl; + std::cerr << "CXL PMU initialization for socket " << s << " die " << die << " at position " << pos << " failed: " << e.what() << std::endl; } } } @@ -7645,53 +7649,56 @@ void PCM::getPCICFGPMUsFromDiscovery(const unsigned int BoxType, const size_t s, { if (uncorePMUDiscovery.get()) { - const auto numBoxes = uncorePMUDiscovery->getNumBoxes(BoxType, s); - for (size_t pos = 0; pos < numBoxes; ++pos) + for (size_t die = 0; die < uncorePMUDiscovery->getNumDies(s); ++die) { - if (uncorePMUDiscovery->getBoxAccessType(BoxType, s, pos) == UncorePMUDiscovery::accessTypeEnum::PCICFG) + const auto numBoxes = uncorePMUDiscovery->getNumBoxes(BoxType, s, die); + for (size_t pos = 0; pos < numBoxes; ++pos) { - std::vector > CounterControlRegs, CounterValueRegs; - const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, s, pos); - auto makeRegister = [&pos, &numBoxes, &BoxType, &s](const uint64 rawAddr) + if (uncorePMUDiscovery->getBoxAccessType(BoxType, s, die, pos) == UncorePMUDiscovery::accessTypeEnum::PCICFG) { -#ifndef PCI_ENABLE - constexpr auto PCI_ENABLE = 0x80000000ULL; -#endif - UncorePMUDiscovery::PCICFGAddress Addr; - Addr.raw = rawAddr; - if ((Addr.raw & PCI_ENABLE) == 0) + std::vector > CounterControlRegs, CounterValueRegs; + const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, s, die, pos); + auto makeRegister = [&pos, &numBoxes, &BoxType, &s](const uint64 rawAddr) { - std::cerr << "PCM Error: PCI_ENABLE bit not set in address 0x" << std::hex << Addr.raw << std::dec << "\n"; - std::cerr << "This is likely a bug in the uncore PMU discovery BIOS table. Contact your BIOS vendor.\n"; - std::cerr << "Socket: " << s << "\n"; - std::cerr << "Box type: " << BoxType << "\n"; - std::cerr << "Box position: " << pos << "/" << numBoxes << "\n"; - std::cerr << "Address: " << Addr.getStr() << "\n"; + #ifndef PCI_ENABLE + constexpr auto PCI_ENABLE = 0x80000000ULL; + #endif + UncorePMUDiscovery::PCICFGAddress Addr; + Addr.raw = rawAddr; + if ((Addr.raw & PCI_ENABLE) == 0) + { + std::cerr << "PCM Error: PCI_ENABLE bit not set in address 0x" << std::hex << Addr.raw << std::dec << "\n"; + std::cerr << "This is likely a bug in the uncore PMU discovery BIOS table. Contact your BIOS vendor.\n"; + std::cerr << "Socket: " << s << "\n"; + std::cerr << "Box type: " << BoxType << "\n"; + std::cerr << "Box position: " << pos << "/" << numBoxes << "\n"; + std::cerr << "Address: " << Addr.getStr() << "\n"; + return std::shared_ptr(); + } + try { + auto handle = std::make_shared(0, (uint32)Addr.fields.bus, + (uint32)Addr.fields.device, + (uint32)Addr.fields.function); + assert(handle.get()); + DBG(3, "opened bdf ", Addr.getStr()); + return std::make_shared(handle, (size_t)Addr.fields.offset); + } + catch (...) + { + DBG(3, "error opening bdf ", Addr.getStr()); + } return std::shared_ptr(); - } - try { - auto handle = std::make_shared(0, (uint32)Addr.fields.bus, - (uint32)Addr.fields.device, - (uint32)Addr.fields.function); - assert(handle.get()); - DBG(3, "opened bdf ", Addr.getStr()); - return std::make_shared(handle, (size_t)Addr.fields.offset); - } - catch (...) + }; + auto boxCtlRegister = makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, die, pos)); + if (boxCtlRegister.get()) { - DBG(3, "error opening bdf ", Addr.getStr()); - } - return std::shared_ptr(); - }; - auto boxCtlRegister = makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, pos)); - if (boxCtlRegister.get()) - { - for (size_t r = 0; r < n_regs; ++r) - { - CounterControlRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, pos, r))); - CounterValueRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtrAddr(BoxType, s, pos, r))); + for (size_t r = 0; r < n_regs; ++r) + { + CounterControlRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, s, die, pos, r))); + CounterValueRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtrAddr(BoxType, s, die, pos, r))); + } + f(UncorePMU(boxCtlRegister, CounterControlRegs, CounterValueRegs)); } - f(UncorePMU(boxCtlRegister, CounterControlRegs, CounterValueRegs)); } } } @@ -8276,48 +8283,51 @@ void ServerUncorePMUs::initDirect(uint32 socket_, const PCM * pcm) const auto BoxType = SPR_IMC_BOX_TYPE; if (uncorePMUDiscovery.get()) { - const auto numBoxes = uncorePMUDiscovery->getNumBoxes(BoxType, socket_); - for (size_t pos = 0; pos < numBoxes; ++pos) + for (size_t die = 0; die < uncorePMUDiscovery->getNumDies(socket_); ++die) { - if (uncorePMUDiscovery->getBoxAccessType(BoxType, socket_, pos) == UncorePMUDiscovery::accessTypeEnum::MMIO) + const auto numBoxes = uncorePMUDiscovery->getNumBoxes(BoxType, socket_, die); + for (size_t pos = 0; pos < numBoxes; ++pos) { - std::vector > CounterControlRegs, CounterValueRegs; - const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, socket_, pos); - auto makeRegister = [](const uint64 rawAddr, const uint32 bits) -> std::shared_ptr + if (uncorePMUDiscovery->getBoxAccessType(BoxType, socket_, die, pos) == UncorePMUDiscovery::accessTypeEnum::MMIO) { - const auto mapSize = SERVER_MC_CH_PMON_SIZE; - const auto alignedAddr = rawAddr & ~4095ULL; - const auto alignDelta = rawAddr & 4095ULL; - try { - auto handle = std::make_shared(alignedAddr, mapSize, false); - assert(handle.get()); - switch (bits) + std::vector > CounterControlRegs, CounterValueRegs; + const auto n_regs = uncorePMUDiscovery->getBoxNumRegs(BoxType, socket_, die, pos); + auto makeRegister = [](const uint64 rawAddr, const uint32 bits) -> std::shared_ptr + { + const auto mapSize = SERVER_MC_CH_PMON_SIZE; + const auto alignedAddr = rawAddr & ~4095ULL; + const auto alignDelta = rawAddr & 4095ULL; + try { + auto handle = std::make_shared(alignedAddr, mapSize, false); + assert(handle.get()); + switch (bits) + { + case 32: + return std::make_shared(handle, (size_t)alignDelta); + case 64: + return std::make_shared(handle, (size_t)alignDelta); + } + } + catch (...) { - case 32: - return std::make_shared(handle, (size_t)alignDelta); - case 64: - return std::make_shared(handle, (size_t)alignDelta); } - } - catch (...) - { - } - return std::shared_ptr(); - }; + return std::shared_ptr(); + }; - auto boxCtlRegister = makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, pos), 32); - if (boxCtlRegister.get()) - { - for (size_t r = 0; r < n_regs; ++r) + auto boxCtlRegister = makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, die, pos), 32); + if (boxCtlRegister.get()) { - CounterControlRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, pos, r), 32)); - CounterValueRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtrAddr(BoxType, socket_, pos, r), 64)); + for (size_t r = 0; r < n_regs; ++r) + { + CounterControlRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, die, pos, r), 32)); + CounterValueRegs.push_back(makeRegister(uncorePMUDiscovery->getBoxCtrAddr(BoxType, socket_, die, pos, r), 64)); + } + imcPMUs.push_back(UncorePMU(boxCtlRegister, + CounterControlRegs, + CounterValueRegs, + makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, die, pos) + SERVER_MC_CH_PMON_FIXED_CTL_OFFSET, 32), + makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, die, pos) + SERVER_MC_CH_PMON_FIXED_CTR_OFFSET, 64))); } - imcPMUs.push_back(UncorePMU(boxCtlRegister, - CounterControlRegs, - CounterValueRegs, - makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, pos) + SERVER_MC_CH_PMON_FIXED_CTL_OFFSET, 32), - makeRegister(uncorePMUDiscovery->getBoxCtlAddr(BoxType, socket_, pos) + SERVER_MC_CH_PMON_FIXED_CTR_OFFSET, 64))); } } } diff --git a/src/pci.h b/src/pci.h index b665b597..a998454c 100644 --- a/src/pci.h +++ b/src/pci.h @@ -234,17 +234,46 @@ void processDVSEC(MatchFunc matchFunc, ProcessFunc processFunc) DBG(2, "offset 0x" , std::hex , offset , " cap_id: 0x" , header.fields.cap_id , " vsec_id: 0x", header.fields.vsec_id, " entryID: 0x" , std::hex , header.fields.entryID , std::dec); if (matchFunc(header)) { - DBG(2, ".... found match"); + DBG(2, ".... found match. tBIR = ", header.fields.tBIR); auto barOffset = 0x10 + header.fields.tBIR * 4; uint32 bar = 0; if (h.read32(barOffset, &bar) == sizeof(uint32) && bar != 0) // read bar { - bar &= ~4095; - processFunc(bar, header); + DBG(2, "bar = 0x", std::hex, bar, std::dec); + if (extract_bits_32(bar, 0, 0) == 0) // memory space + { + auto type = extract_bits_32(bar, 2, 1); + if (type == 0) // 32-bit address + { + bar &= ~0xfull; + processFunc(bar, header); + } + else if (type == 2) // 64-bit address + { + uint32 bar_high = 0; + if (h.read32(barOffset + 4, &bar_high) == sizeof(uint32)) + { + uint64 full_bar = (uint64(bar_high) << 32) | uint64(bar); + full_bar &= ~0xfull; + DBG(2, " full_bar = 0x", std::hex, full_bar, std::dec); + processFunc(full_bar, header); + } + else + { + std::cerr << "Error: can't read high part of 64-bit bar from offset 0x" << std::hex << (barOffset + 4) << std::dec << " \n"; + } + } + else + { + // BAR type 1 is reserved by the PCI specification and is not valid. + // Any unknown BAR type (including type 1) is treated as an error. + std::cerr << "Error: unknown bar type " << type << " at bar offset 0x" << std::hex << barOffset << std::dec << " \n"; + } + } } else { - std::cerr << "Error: can't read bar from offset " << barOffset << " \n"; + std::cerr << "Error: can't read bar from offset 0x" << std::hex << barOffset << std::dec << " \n"; } } const uint64 lastOffset = offset; diff --git a/src/uncore_pmu_discovery.cpp b/src/uncore_pmu_discovery.cpp index fd968ef4..bf569070 100644 --- a/src/uncore_pmu_discovery.cpp +++ b/src/uncore_pmu_discovery.cpp @@ -16,8 +16,10 @@ UncorePMUDiscovery::UncorePMUDiscovery() return; } const auto debug = (safe_getenv("PCM_DEBUG_PMU_DISCOVERY") == std::string("1")); + + size_t socket = 0; - auto processTables = [this, &debug](const uint64 bar, const VSEC & vsec) + auto processTables = [this, &debug, &socket](const uint64 bar, const VSEC & vsec) { try { DBG(2, "Uncore discovery detection. Reading from bar 0x", std::hex, bar, std::dec); @@ -28,7 +30,8 @@ UncorePMUDiscovery::UncorePMUDiscovery() }; UncoreGlobalDiscovery global; mmio_memcpy(global.table, bar, UncoreDiscoverySize * sizeof(uint64), true); - globalPMUs.push_back(global.pmu); + globalPMUs.resize(socket + 1); + globalPMUs[socket].push_back(global.pmu); if (debug) { std::cerr << "Read global.pmu from 0x" << std::hex << bar << std::dec << "\n"; @@ -63,7 +66,9 @@ UncorePMUDiscovery::UncorePMUDiscovery() // unit.pmu.print(); boxPMUMap[unit.pmu.boxType].push_back(unit.pmu); } - boxPMUs.push_back(boxPMUMap); + boxPMUs.resize(socket + 1); + boxPMUs[socket].push_back(boxPMUMap); + ++socket; } catch (const std::exception & e) { @@ -100,18 +105,21 @@ UncorePMUDiscovery::UncorePMUDiscovery() { for (size_t s = 0; s < boxPMUs.size(); ++s) { - std::cout << "Socket " << s << " global PMU:\n"; - std::cout << " "; - globalPMUs[s].print(); - std::cout << "Socket " << s << " unit PMUs:\n"; - for (const auto & pmuType : boxPMUs[s]) + for (size_t die = 0; die < boxPMUs[s].size(); ++die) { - const auto n = pmuType.second.size(); - std::cout << " PMU type " << pmuType.first << " (" << n << " boxes)"<< "\n"; - for (size_t i = 0; i < n ; ++i) + std::cout << "Socket " << s << " die " << die << " global PMU:\n"; + std::cout << " "; + globalPMUs[s][die].print(); + std::cout << "Socket " << s << " die " << die << " unit PMUs:\n"; + for (const auto& pmuType : boxPMUs[s][die]) { - std::cout << " "; - pmuType.second[i].print(); + const auto n = pmuType.second.size(); + std::cout << " PMU type " << pmuType.first << " (" << n << " boxes)" << "\n"; + for (size_t i = 0; i < n; ++i) + { + std::cout << " "; + pmuType.second[i].print(); + } } } } diff --git a/src/uncore_pmu_discovery.h b/src/uncore_pmu_discovery.h index 7caddf7e..e970eaa9 100644 --- a/src/uncore_pmu_discovery.h +++ b/src/uncore_pmu_discovery.h @@ -128,17 +128,17 @@ class UncorePMUDiscovery }; typedef std::vector BoxPMUs; typedef std::unordered_map BoxPMUMap; // boxType -> BoxPMUs - std::vector boxPMUs; - std::vector globalPMUs; + std::vector > boxPMUs; // socket -> die -> BoxPMUs + std::vector > globalPMUs; // socket -> die -> GlobalPMU - bool validBox(const size_t boxType, const size_t socket, const size_t pos) + bool validBox(const size_t boxType, const size_t socket, const size_t die, const size_t pos) { - return socket < boxPMUs.size() && pos < boxPMUs[socket][boxType].size(); + return socket < boxPMUs.size() && die < boxPMUs[socket].size() && pos < boxPMUs[socket][die][boxType].size(); } - size_t registerStep(const size_t boxType, const size_t socket, const size_t pos) + size_t registerStep(const size_t boxType, const size_t socket, const size_t die, const size_t pos) { - const auto width = boxPMUs[socket][boxType][pos].bitWidth; - switch (boxPMUs[socket][boxType][pos].accessType) + const auto width = boxPMUs[socket][die][boxType][pos].bitWidth; + switch (boxPMUs[socket][die][boxType][pos].accessType) { case MSR: if (width <= 64) @@ -171,57 +171,66 @@ class UncorePMUDiscovery public: UncorePMUDiscovery(); - size_t getNumBoxes(const size_t boxType, const size_t socket) + size_t getNumDies(const size_t socket) const { if (socket < boxPMUs.size()) { - return boxPMUs[socket][boxType].size(); + return boxPMUs[socket].size(); } return 0; } - uint64 getBoxCtlAddr(const size_t boxType, const size_t socket, const size_t pos) + size_t getNumBoxes(const size_t boxType, const size_t socket, const size_t die) { - if (validBox(boxType, socket, pos)) + if (socket < boxPMUs.size() && die < boxPMUs[socket].size()) { - return boxPMUs[socket][boxType][pos].boxCtrlAddr; + return boxPMUs[socket][die][boxType].size(); } return 0; } - uint64 getBoxCtlAddr(const size_t boxType, const size_t socket, const size_t pos, const size_t c) + uint64 getBoxCtlAddr(const size_t boxType, const size_t socket, const size_t die, const size_t pos) { - if (validBox(boxType, socket, pos) && c < boxPMUs[socket][boxType][pos].numRegs) + if (validBox(boxType, socket, die, pos)) { - const size_t step = (boxType == SPR_IMC_BOX_TYPE) ? 4 : registerStep(boxType, socket, pos); - return boxPMUs[socket][boxType][pos].boxCtrlAddr + boxPMUs[socket][boxType][pos].ctrlOffset + c * step; + return boxPMUs[socket][die][boxType][pos].boxCtrlAddr; } return 0; } - uint64 getBoxCtrAddr(const size_t boxType, const size_t socket, const size_t pos, const size_t c) + uint64 getBoxCtlAddr(const size_t boxType, const size_t socket, const size_t die, const size_t pos, const size_t c) { - if (validBox(boxType, socket, pos) && c < boxPMUs[socket][boxType][pos].numRegs) + if (validBox(boxType, socket, die, pos) && c < boxPMUs[socket][die][boxType][pos].numRegs) { - return boxPMUs[socket][boxType][pos].boxCtrlAddr + boxPMUs[socket][boxType][pos].ctrOffset + c * registerStep(boxType, socket, pos); + const size_t step = (boxType == SPR_IMC_BOX_TYPE) ? 4 : registerStep(boxType, socket, die, pos); + return boxPMUs[socket][die][boxType][pos].boxCtrlAddr + boxPMUs[socket][die][boxType][pos].ctrlOffset + c * step; } return 0; } - accessTypeEnum getBoxAccessType(const size_t boxType, const size_t socket, const size_t pos) + uint64 getBoxCtrAddr(const size_t boxType, const size_t socket, const size_t die, const size_t pos, const size_t c) { - if (validBox(boxType, socket, pos)) + if (validBox(boxType, socket, die, pos) && c < boxPMUs[socket][die][boxType][pos].numRegs) { - return static_cast(boxPMUs[socket][boxType][pos].accessType); + return boxPMUs[socket][die][boxType][pos].boxCtrlAddr + boxPMUs[socket][die][boxType][pos].ctrOffset + c * registerStep(boxType, socket, die, pos); + } + return 0; + } + + accessTypeEnum getBoxAccessType(const size_t boxType, const size_t socket, const size_t die, const size_t pos) + { + if (validBox(boxType, socket, die, pos)) + { + return static_cast(boxPMUs[socket][die][boxType][pos].accessType); } return unknownAccessType; } - uint64 getBoxNumRegs(const size_t boxType, const size_t socket, const size_t pos) + uint64 getBoxNumRegs(const size_t boxType, const size_t socket, const size_t die, const size_t pos) { - if (validBox(boxType, socket, pos)) + if (validBox(boxType, socket, die, pos)) { - return boxPMUs[socket][boxType][pos].numRegs; + return boxPMUs[socket][die][boxType][pos].numRegs; } return 0; }