1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/fpga/lib/memory.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
659 B
C++
Raw Permalink Normal View History

/* Memory managment.
2018-06-25 17:03:09 +02:00
*
* Author: Daniel Krebs <github@daniel-krebs.net>
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University
* SPDX-License-Identifier: Apache-2.0
*/
2018-06-25 17:03:09 +02:00
#include <sys/mman.h>
#include <unistd.h>
#include <villas/memory.hpp>
using namespace villas;
bool HostRam::free(void *addr, size_t length) {
return munmap(addr, length) == 0;
}
void *HostRam::allocate(size_t length, int flags) {
const int mmap_flags = flags | MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT;
const int mmap_protection = PROT_READ | PROT_WRITE;
return mmap(nullptr, length, mmap_protection, mmap_flags, 0, 0);
}