0

I have to write and add a custom device to QEMU, it's a crypto accelerator core. The device is then to be simulated for Linux using the RISC-V ISA.

I have implemented the cryptographic algorithm inside a custom QEMU device in C using the QEMU object model. I now have a .c file. However, I can't understand how to add it to the QEMU system to build it for my ISA and then test it. I found the documentation for QEMU to be unorganized and not very helpful in this regard, neither can I find any guide online to add devices for the latest meson build system that QEMU uses.

I think this part is missing from the QEMU documentation. I'm using QEMU for the first time so kindly help me with this with a stepwise approach.

Shahab
  • 1
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 27 '23 at 00:53
  • In QEMU devices are added to board models, unless your device is a pluggable one like a PCI card. So you should figure out what board it should be added to. Generally the advice is "find an example of an existing device similar to yours which has been added relatively recently, look at its source code, and do it like that". – Peter Maydell Jul 27 '23 at 09:20
  • I need to model an SHA256 accelerator core in QEMU for RISC-V. From what I understand, I need to write the device model and then add it to QEMU to build it. I have written the device model but I can't figure out how to add it to QEMU to build it and then test it. Is this information enough or you can ask me whatever specifics you need to know. – Shahab Jul 27 '23 at 12:25
  • The general advice of looking at source code only helps while writing the model itself, it doesn't help to know how they are tied to the QEMU build system, I am new to this so I can't understand how to add a new custom device. And what exactly do you mean by "board models"? I just know that my device needs to work for a RISC-V machine. – Shahab Jul 27 '23 at 12:27
  • 1
    To figure out how to add a device to the build system, look at what existing devices do (often easiest to figure out by looking at the git commit that added some recent device). This is basically a line in the relevant meson.build file and some Kconfig stuff. The "board model" is the code which implements a QEMU machine type (what you see from -M help). – Peter Maydell Jul 27 '23 at 13:25
  • @Shahab Have you managed to get a RISC-V VM running? If you have, [you will have chosen a board model already](https://www.qemu.org/docs/master/system/target-riscv.html). If you haven't, that's probably a good place to start. You can also use the name of the chosen board model for searching the code base. – pmdj Jul 27 '23 at 13:26

0 Answers0