23 cci::cci_param<std::string> p_shm_path;
24 cci::cci_param<uint32_t> p_shm_size;
28 ivshmem_plain(
const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t)
29 : ivshmem_plain(name, *(
dynamic_cast<QemuInstance*
>(o)), (
dynamic_cast<qemu_gpex*
>(t)))
32 ivshmem_plain(
const sc_core::sc_module_name& name,
QemuInstance& inst, qemu_gpex* gpex)
34 , p_shm_path(
"shm_path",
"",
"path of shm file (i.e. /dev/shm/<name of the shm segment>)")
35 , p_shm_size(
"shm_size", 1024,
"size of the shm in MB")
36 , p_shm_id(std::string(sc_core::sc_module::name()) +
"-id")
38 std::stringstream object_string;
39 object_string <<
"memory-backend-file,size=" << p_shm_size.get_value()
40 <<
"M,mem-path=" << p_shm_path.get_value() <<
",share=on,id=" << p_shm_id;
42 m_inst.add_arg(
"-object");
43 m_inst.add_arg(object_string.str().c_str());
45 gpex->add_device(*
this);
48 void before_end_of_elaboration()
override
50 qemu_gpex::Device::before_end_of_elaboration();
51 m_dev.set_prop_str(
"memdev", p_shm_id.c_str());
57 unlink(p_shm_path.get_value().c_str());