如何在QEMU源代码中添加新设备? [英] How to add a new device in QEMU source code?

查看:1500
本文介绍了如何在QEMU源代码中添加新设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用QOM方法在qemu中模拟/添加新设备的逐步方法是什么?

What could be the step wise approach to emulate/add a new device in qemu using QOM approach?

关于DeviceState/BusState和其他属性的更改在哪里?

What and where could be the changes with respect to DeviceState/BusState and other properties?

推荐答案

edu树内教育PCI设备

edu in-tree educational PCI device

  • https://github.com/qemu/qemu/blob/v2.7.0/hw/misc/edu.c
  • https://github.com/qemu/qemu/blob/v2.7.0/docs/specs/edu.txt

它很容易理解和有据可查,因此我建议您学习它.

It is very easy to understand and well documented, so I recommend that you study it.

它公开了最小的PCI设备,具有基本的IO,中断生成和DMA.

It exposes a minimal PCI device, with basic IO, interrupt generation, and DMA.

我已经编写了一个最小的Linux内核模块+用户环境测试,可以在以下位置使用它:

I've written a minimal Linux kernel module + userland tests to play with it at:

  • https://github.com/cirosantilli/linux-kernel-module-cheat/blob/6788a577c394a2fc512d8f3df0806d84dc09f355/rootfs_overlay/pci.sh
  • https://github.com/cirosantilli/linux-kernel-module-cheat/blob/6788a577c394a2fc512d8f3df0806d84dc09f355/kernel_module/pci.c

最小PCI设备

我将edu最小化到QEMU分支的四分之一: https://github.com/cirosantilli/qemu/blob/22e7e210d6fbe54c35a5ae32450a4419df25a13b/hw/misc/lkmc_pci_min.c 没有DMA.

I've minimized edu even further to a quarter of the size on my QEMU fork: https://github.com/cirosantilli/qemu/blob/22e7e210d6fbe54c35a5ae32450a4419df25a13b/hw/misc/lkmc_pci_min.c No DMA.

内核驱动程序: https://github .com/cirosantilli/linux-kernel-module-cheat/blob/1cd55ebf53542208f7a614a856066123b93d303d/kernel_module/pci_min.c

我的Buildroot包装器已经将QEMU fork与一个子模块集成在一起,只需克隆和./run.

My Buildroot wrapper already integrates the QEMU fork with a submodule, just clone and ./run.

ARM平台设备TYPE_SYS_BUS_DEVICE

ARM platform device TYPE_SYS_BUS_DEVICE

SoC-land可以在芯片中而不是PCI上烘烤大多数设备,这是一个最小的可运行示例:

SoC-land bakes most devices in the silicon instead of PCI, here is a minimal runnable example:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆