Importing Wrapper for QEMU in Innovator

Instructions to import the QEMU Wrapper to Innovator.

You will need this file that contains:

  • libraries:
    • libqemu.a
    • libqemu_common.a
    • libqemuSC.a
  • source code:
    • qemuWPSC.[cc|h]
    • sc_slave_dummy.h

The libraries are built from QEMU source code (at svn) using gcc shiped with Innovator.

To import the wrapper into Innovator:

  1. Import qemuWPSC.h, use these settings (don't forget to tell Innovator that that module has a .cc file):
    1. Include paths:
      1. $(GSROOT) path
      2. SystemC path
      3. TLM path
    2. Defines:
      1. SC_INCLUDE_DYNAMIC_PROCESSES
      2. NO_DEMANGLE
    3. Library path
      1. <path to libraries>
    4. Libraries
      1. -lqemuSC.a
      2. -lqemu_common.a
      3. -lqemu.a
    5. Other Settings
      1. -g -Wl,--warn-common -m32 -lSDL -lX11 -lm -lz -lpthread -lrt -lutil

With these settings you should have a new component in your local library. Current wrapper has a GSGPSocket called io_port and a sc_in<bool> interrupt port.

active?fid=162

Import the dummy_slave with the same include settings (but not the libraries).

Connect both modules, drawing a line between TLM sockets, and using a predefined SystemC channel sc_signal to connect the interrupt line. That sc_signal must be configured to of type bool (double-click on it, and in Template parameters, set T to bool).

Done, you could compile all the project with no errors :)

active?fid=164

active?fid=165

How to built the libraries

To obtain the different QEMU libraries to use in Innovator, firstly we need to compile completely QEMU version from SVN:

  1. svn co https://svn.greensocs.com/public/packages/qemu_systemc/InABox/
  2. cd InABox
  3. ./configure --target-list=i386-softmmu --disable-kvm --disable-kqemu
  4. make

There are 3 libraries to use:

  1. libqemu_common.a: This library is built with a QEMU standard compilation. The library is created in the $(QEMU_ROOT) directory
  2. libqemu.a: This library is built with a QEMU standard compilation. The library is created in the $(QEMU_ROOT)/i386-softmmu directory
  3. libqemuSC.a: To build this library the following command must be run into the $(QEMU_ROOT)/i386-softmmu directory:

  1. ar rcs libqemuSC.a vl.o ../osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o dma-helpers.o virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o fw_cfg.o ../posix-aio-compat.o ../block-raw-posix.o lsi53c895a.o esp.o usb-ohci.o eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o e1000.o msmouse.o ide.o pckbd.o ps2.o vga.o sb16.o es1370.o ac97.o dma.o fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o device-hotplug.o pci-hotplug.o gdbstub.o gdbstub-xml.o sc_link.o ../qemu-char.o

What the demo does

Other version, using KVM and standalone SystemC simulation

active?fid=166

This demo consists on the QEMU module connected to a simple device using a GSPSocket. That device publishes a register file that can be accesses through the TLM socket. When the register 0 is written, the device triggers a timer that will trigger an Interrupt to QEMU every 5 seconds (this time can be modified in Innovator). That timer is stopped writing to any register different to 0. Also, the interrupt line is lowered reading from register 0. QEMU sees that device as a PCI device, with two BAR (PCI Access regions), one memory-mapped region and one IO region (Region 0 Memory, Region 1 I/O Port). Both regions are mapped to the unique device register file, so writing to IO register 0 is the same operation than writing to Memory address 0 of this device.

For the OS side, we wrote a Linux driver for our module. The driver publishes two char devices to access to each BAR of the device. This way, to access the SystemC module, a file access to those linux-devices are needed.

Once QEMU has booted the image, you will be asked for login & password. Login as root with password synopsys.

  1. cd drivers
  2. sh load.sh

With the lines above, the driver is loaded and the char devices created in /dev:

  1. ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 9
  2. ACPI: PCI Interrupt 0000:00:02.0[A] -> Link [LNKB] -> GSI 9 (level, low) -> IRQ 9
  3.  Found Altera device
  4.  MEM resource found in BAR #0. Addr=4026531840, Len=511
  5.  IO Space found in BAR #1. Addr=49664

Now, we can test all system with the test application. Different options of the application includes write and read using I/O or Mem region.

If you chose to write some value to address 0, you are triggering the interrupt timer. You will see a message like

  1. Altera: Interrupt 9 triggered

every 5 seconds (if you left that value by default)

To disable interrupt generation, you may use test application to write any value to any register different to 0.

At the same time, in the Innovator console (the console where you did run Innovator), you will see the debug messages that QEMU is printing during the simulation.


Filename/TitleSize
wrapper_qemu.tar_.gz2.94 MB