23 cci::cci_param<std::string> p_serial;
24 cci::cci_param<std::string> p_blob_file;
25 cci::cci_param<std::string> p_format;
26 cci::cci_param<uint32_t> max_ioqpairs;
27 std::string m_drive_id;
30 nvme(
const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t)
31 : nvme(name, *(
dynamic_cast<QemuInstance*
>(o)), (
dynamic_cast<qemu_gpex*
>(t)))
34 nvme(
const sc_core::sc_module_name& name,
QemuInstance& inst, qemu_gpex* gpex)
36 , p_serial(
"serial", basename(),
"Serial name of the nvme disk")
37 , p_blob_file(
"blob_file",
"",
"Blob file to load as data storage")
38 , p_format(
"format",
"raw",
"Format of the blob file (supported: raw, qcow2)")
39 , max_ioqpairs(
"max_ioqpairs", 64,
"Passed through to QEMU max_ioqpairs")
40 , m_drive_id(basename())
42 if (p_blob_file.get_value().empty()) {
43 SCP_FATAL(()) <<
"the nvme device needs blob_file CCI parameter!";
45 std::string format = p_format.get_value();
46 if (format !=
"raw" && format !=
"qcow2") {
47 SCP_FATAL(()) <<
"format parameter must be 'raw' or 'qcow2', got: " << format;
49 m_drive_id +=
"_drive";
50 std::string file = p_blob_file.get_value();
52 std::stringstream opts;
53 opts <<
"if=sd,id=" << m_drive_id <<
",file=" << file <<
",format=" << p_format.get_value();
54 m_inst.add_arg(
"-drive");
55 m_inst.add_arg(opts.str().c_str());
57 gpex->add_device(*
this);
60 void before_end_of_elaboration()
override
62 qemu_gpex::Device::before_end_of_elaboration();
64 std::string serial = p_serial;
65 m_dev.set_prop_str(
"serial", serial.c_str());
66 m_dev.set_prop_parse(
"drive", m_drive_id.c_str());
67 m_dev.set_prop_int(
"max_ioqpairs", max_ioqpairs);
70 void gpex_realize(
qemu::Bus& bus)
override { qemu_gpex::Device::gpex_realize(bus); }