diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 19423862..b5e71a28 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -190,6 +190,7 @@ ReturnValue_t PdecConfig::createFirstWord(uint32_t* word) { return result; } *word |= static_cast(positiveWindow); + printf("Word 1: 0x%08x\n", *word); return returnvalue::OK; } @@ -205,6 +206,7 @@ ReturnValue_t PdecConfig::createSecondWord(uint32_t* word) { *word |= (static_cast(negativeWindow) << 24); *word |= (HIGH_AU_MAP_ID << 16); *word |= (ENABLE_DERANDOMIZER << 8); + printf("Word 2: 0x%08x\n", *word); return returnvalue::OK; } diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index c7266710..34f045a5 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -53,23 +53,30 @@ ReturnValue_t PdecHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - ReturnValue_t result = returnvalue::OK; - UioMapper regMapper(uioNames.registers); - result = regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); + ReturnValue_t result = + regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - UioMapper configMemMapper(uioNames.configMemory); - result = configMemMapper.getMappedAdress(&memoryBaseAddress, UioMapper::Permissions::READ_WRITE); - if (result != returnvalue::OK) { + + int fd = 0; + if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { + sif::error << "PdecHandler::initialize: Opening /dev/mem failed" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + }; + memoryBaseAddress = static_cast( + mmap(0, PDEC_CFG_MEM_SIZE, static_cast(UioMapper::Permissions::READ_WRITE), MAP_SHARED, + fd, PDEC_RAM_PHY_ADDR)); + if (memoryBaseAddress == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; - } else { - pdecConfig.setMemoryBaseAddress(memoryBaseAddress); } - UioMapper ramMapper(uioNames.ramMemory); - result = ramMapper.getMappedAdress(&ramBaseAddress, UioMapper::Permissions::READ_WRITE); - if (result != returnvalue::OK) { + pdecConfig.setMemoryBaseAddress(memoryBaseAddress); + + ramBaseAddress = static_cast(mmap(0, PDEC_RAM_SIZE, + static_cast(UioMapper::Permissions::READ_WRITE), + MAP_SHARED, fd, PDEC_RAM_PHY_ADDR)); + if (ramBaseAddress == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/linux/ipcore/PdecHandler.h b/linux/ipcore/PdecHandler.h index 11ae4de3..19968da6 100644 --- a/linux/ipcore/PdecHandler.h +++ b/linux/ipcore/PdecHandler.h @@ -51,6 +51,10 @@ class PdecHandler : public SystemObject, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t IRQ_TIMEOUT_MS = 500; + static constexpr uint32_t PDEC_CFG_MEM_SIZE = 0x1000; + static constexpr uint32_t PDEC_CFG_MEM_PHY_ADDR = 0x24000000; + static constexpr uint32_t PDEC_RAM_SIZE = 0x10000; + static constexpr uint32_t PDEC_RAM_PHY_ADDR = 0x26000000; enum class Modes { POLLED, IRQ };