Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions docs/extra-components/README-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,36 @@ Components available:
* NVME : This allows an NVME disk to be added. Initialise `QemuNvmeDisk` with a qemu instance from the libqbox library (see the libqbox section to initiate a qemu instance):

```c++
QemuNvmeDisk m_disk1("disk1", m_qemu_inst)
QemuNvmeDisk m_disk1("disk1", m_qemu_inst, m_gpex_inst)
```
The class `QemuNvmeDisk` has 3 parameters:
The constructor : `QemuNvmeDisk(const sc_core::sc_module_name &name, QemuInstance &inst)`
The constructor : `QemuNvmeDisk(const sc_core::sc_module_name &name, QemuInstance &inst, qemu_gpex &gpex)`
- "name" : name of the disk
- "inst" : instance Qemu
- "gpex" : instance of PCIe GPEX

The parameters :
- "serial" : Serial name of the nvme disk
- "bloc-file" : Blob file to load as data storage
- "drive-id"

Example of adding a nvme disk via the conf.lua. Gpex_0 needs to be defined as well so that an instance is passed to the nvme disk so that it can the gpex.add_device(nvme_disk_0) is called.

```lua
platform = {
gpex_0={...};

nvme_disk_0 = {
moduletype = "nvme_disk",
dylib_path = "nvme",
args = {"&platform.qemu_inst", "&platform.gpex_0"},
serial = "nvme_serial_001",
blob_file=top().."fw/Artifacts/nvme_disk.img",
max_ioqpairs = 64
};
};
```

## How to add QEMU OpenCores Eth MAC
### SystemC Code
Here there is an example of SystemC Code:
Expand Down
20 changes: 19 additions & 1 deletion docs/extra-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,33 @@ Components available:
QemuNvmeDisk m_disk1("disk1", m_qemu_inst)
```
The class `QemuNvmeDisk` has 3 parameters:
The constructor : `QemuNvmeDisk(const sc_core::sc_module_name &name, QemuInstance &inst)`
The constructor : `QemuNvmeDisk(const sc_core::sc_module_name &name, QemuInstance &inst, qemu_gpex &gpex)`
- "name" : name of the disk
- "inst" : instance Qemu
- "gpex" : instance of PCIe GPEX

The parameters :
- "serial" : Serial name of the nvme disk
- "bloc-file" : Blob file to load as data storage
- "drive-id"

Example of adding a nvme disk via the conf.lua. Gpex_0 needs to be defined as well so that an instance is passed to the nvme disk so that it can the gpex.add_device(nvme_disk_0) is called.

```lua
platform = {
gpex_0={...};

nvme_disk_0 = {
moduletype = "nvme_disk",
dylib_path = "nvme",
args = {"&platform.qemu_inst", "&platform.gpex_0"},
serial = "nvme_serial_001",
blob_file=top().."fw/Artifacts/nvme_disk.img",
max_ioqpairs = 64
};
};
```

## How to add QEMU OpenCores Eth MAC
### SystemC Code
Here there is an example of SystemC Code:
Expand Down
7 changes: 4 additions & 3 deletions qemu-components/nvme/include/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class nvme_disk : public qemu_gpex::Device
std::string m_drive_id;

public:
nvme_disk(const sc_core::sc_module_name& name, sc_core::sc_object* o)
: nvme_disk(name, *(dynamic_cast<QemuInstance*>(o)))
nvme_disk(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* gpex)
: nvme_disk(name, *(dynamic_cast<QemuInstance*>(o)), *(dynamic_cast<qemu_gpex*>(gpex)))
{
}
nvme_disk(const sc_core::sc_module_name& name, QemuInstance& inst)
nvme_disk(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex& gpex)
: qemu_gpex::Device(name, inst, "nvme")
, p_serial("serial", basename(), "Serial name of the nvme disk")
, p_blob_file("blob_file", "", "Blob file to load as data storage")
Expand All @@ -44,6 +44,7 @@ class nvme_disk : public qemu_gpex::Device
opts << "if=sd,id=" << m_drive_id << ",file=" << file << ",format=raw";
m_inst.add_arg("-drive");
m_inst.add_arg(opts.str().c_str());
gpex.add_device(*this);
}

void before_end_of_elaboration() override
Expand Down
2 changes: 1 addition & 1 deletion qemu-components/nvme/src/nvme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

#include "nvme.h"

void module_register() { GSC_MODULE_REGISTER_C(nvme_disk, sc_core::sc_object*); }
void module_register() { GSC_MODULE_REGISTER_C(nvme_disk, sc_core::sc_object*, sc_core::sc_object*); }