23 cci::cci_param<uint8_t> p_outputs;
24 cci::cci_param<uint64_t> p_hostmem_mb;
25 cci::cci_param<bool> p_enable_host_visible;
27 void before_end_of_elaboration()
override
29 qemu_gpex::Device::before_end_of_elaboration();
30 get_qemu_dev().set_prop_uint(
"max_outputs", p_outputs);
33 void gpex_realize(
qemu::Bus& bus)
override { qemu_gpex::Device::gpex_realize(bus); }
35 uint8_t outputs() {
return p_outputs.get_value(); }
38 QemuVirtioGpu(
const sc_core::sc_module_name& name,
QemuInstance& inst,
const char* gpu_type, qemu_gpex* gpex)
39 : QemuVirtioGpu(name, inst, gpu_type, gpex, (
const char*)NULL)
43 QemuVirtioGpu(
const sc_core::sc_module_name& name,
QemuInstance& inst,
const char* gpu_type, qemu_gpex* gpex,
44 const char* device_id)
46 , p_outputs(
"outputs", 1,
"Number of outputs for this gpu")
47 , p_hostmem_mb(
"hostmem_mb", 2048,
"MB to allocate for the host-visible shared-memory region")
48 , p_enable_host_visible(
"enable_host_visible",
false,
49 "Enable virtio-gpu blob resources and the host-visible shared-memory region "
50 "(virglrenderer >= 1.0 / QEMU >= 11). Defaults to false to keep the pre-1.0 "
51 "PCI layout (no SHARED_MEMORY_CFG capability / large BAR), which all guests "
52 "support. Set true for guests that support and benefit from host-visible blob "
53 "resources (e.g. modern Linux/Mesa).")
55 gpex->add_device(*
this);
67 void setup_host_visible_backend()
69 if (!p_enable_host_visible) {
72 m_inst.add_arg(
"-object");
73 std::string memory_object =
"memory-backend-memfd,id=mem1,size=" + std::to_string(p_hostmem_mb.get_value()) +
75 m_inst.add_arg(memory_object.c_str());
76 m_inst.add_arg(
"-machine");
77 m_inst.add_arg(
"memory-backend=mem1");
81 void apply_host_visible_props()
83 if (!p_enable_host_visible) {
86 get_qemu_dev().set_prop_bool(
"blob",
true);
91 get_qemu_dev().set_prop_int(
"hostmem", (int64_t)p_hostmem_mb.get_value() * 1024 * 1024);