peary/interfaces/Memory/memory.hpp

Peary Memory Interface. More…

Namespaces

Name
peary
peary::interface

Classes

Name
struct peary::interface::MemoryInterface
class peary::interface::MemoryEndpoint Peary Memory Interface Endpoint.

Detailed Description

Peary Memory Interface.

Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only

Source code

  
#pragma once

#include <cstdint>
#include <cstdio>
#include <string>
#include <vector>

#include <fcntl.h>
#include <sys/mman.h>

#include "peary/interfaces/Endpoint.hpp"
#include "peary/interfaces/exceptions.hpp"
#include "peary/utils/datatypes.hpp"

namespace peary::interface {

    struct MemoryInterface {};

    class MemoryEndpoint : public Endpoint<MemoryInterface, size_t, uintptr_t> {
    public:
        MemoryEndpoint(std::string const& devpath, const utils::memory_map& mem);
        ~MemoryEndpoint();

    protected:
        pair_t write_impl(const pair_t&) override;

        vector_t read_impl(const reg_t&, const unsigned int) override;

        uintptr_t read_word(const reg_t& offset) const;

    private:
        // Access to FPGA memory mapped registers
        int _memfd;

        // Buffer
        void* _mappedMemory;

        // Memory map
        const utils::memory_map _mem;
    };

} // namespace peary::interface
  

Updated on 2026-01-16 at 00:29:06 +0100