├── .clang-format ├── .github └── workflows │ ├── build-macos-full.yml │ ├── build-ubuntu-full.yml │ ├── clang-format.yml │ ├── gh-pages.yml │ └── quic-organization-repolinter.yml ├── .gitignore ├── .gitlab-ci.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── CTestCustom.cmake └── boilerplate.cmake ├── docs ├── base-components │ ├── README-local.md │ ├── README.md │ ├── base-components.pdf │ └── base-components_README.md ├── extra-components │ ├── README-local.md │ └── README.md ├── libgssync │ ├── README-local.md │ ├── README.md │ ├── gssync-2.pdf │ ├── gssync.pdf │ └── gssync_README.md ├── libgsutils │ ├── README-local.md │ ├── README.md │ ├── gsutils-2.pdf │ ├── gsutils.pdf │ └── gsutils_README.md ├── libqbox │ ├── README-local.md │ ├── README.md │ ├── qbox-extra.pdf │ ├── qbox.pdf │ └── qbox_README.md ├── libqemu-cxx │ ├── README-local.md │ ├── README.md │ ├── libqemu-cxx.pdf │ └── libqemu-cxx_README.md ├── systemc-macs │ ├── README-local.md │ ├── README.md │ └── systemc-macs.pdf └── systemc-uarts │ ├── README.md │ ├── systemc-uarts.pdf │ └── systemc-uarts_README.md ├── html ├── CMakeLists.txt └── templates │ └── monitor.html ├── libqboxConfig.cmake.in ├── libqemu-cxxConfig.cmake.in ├── package-lock.cmake ├── platforms ├── CMakeLists.txt ├── cortex-m55-remote │ ├── CMakeLists.txt │ ├── README.md │ ├── conf.lua │ ├── docs │ │ ├── base-components.pdf │ │ ├── gssync.pdf │ │ ├── gsutils.pdf │ │ ├── libqemu-cxx.pdf │ │ ├── qbox.pdf │ │ └── systemc-uarts.pdf │ ├── fw │ │ └── cortex-m55 │ │ │ ├── Makefile │ │ │ ├── cortex-m55.bin │ │ │ ├── cortex-m55.elf │ │ │ ├── linker.ld │ │ │ ├── main.c │ │ │ ├── nvic.c │ │ │ ├── nvic.h │ │ │ ├── setup.s │ │ │ └── stdint.h │ ├── package-lock.cmake │ ├── src │ │ ├── main.cc │ │ ├── remote_cpu.cc │ │ └── remote_cpu.h │ └── tests │ │ ├── CMakeLists.txt │ │ └── cortex_m55.py ├── fw │ └── utils.lua ├── src │ └── main.cc └── ubuntu │ ├── conf_aarch64.lua │ ├── conf_riscv64.lua │ └── fw │ ├── arm64_bootloader.lua │ ├── build_linux_dist_image.sh │ ├── get_arm64_gzip_img_from_zboot_efi.c │ ├── mkosi.extra │ ├── etc │ │ └── systemd │ │ │ └── network │ │ │ └── 20-dhcp.network │ └── usr │ │ └── lib │ │ └── systemd │ │ ├── mkosi-use-systemd-resolved.sh │ │ ├── system-preset │ │ └── 00-mkosi.preset │ │ └── system │ │ └── mkosi-use-systemd-resolved.service │ ├── mkosi.repart │ └── 10-root.conf │ ├── riscv64_bootloader.lua │ ├── ubuntu-dts-arm64.template │ └── ubuntu-dts-riscv64.template ├── py-models ├── CMakeLists.txt ├── py-i2c.py └── py-uart.py ├── qemu-components ├── CMakeLists.txt ├── arm_smmu │ ├── CMakeLists.txt │ ├── include │ │ └── arm-smmu.h │ └── src │ │ └── arm-smmu.cc ├── common │ ├── include │ │ ├── arm.h │ │ ├── cache-ctrl │ │ │ ├── sifive-l2pf.h │ │ │ └── sifive-pl2.h │ │ ├── cpu.h │ │ ├── device.h │ │ ├── dmi-manager.h │ │ ├── exceptions.h │ │ ├── internals.h │ │ ├── libqemu-cxx │ │ │ ├── exceptions.h │ │ │ ├── libqemu-cxx.h │ │ │ ├── loader.h │ │ │ ├── target │ │ │ │ ├── aarch64.h │ │ │ │ ├── hexagon.h │ │ │ │ ├── microblaze.h │ │ │ │ └── riscv.h │ │ │ └── target_info.h │ │ ├── max.h │ │ ├── ports │ │ │ ├── initiator.h │ │ │ ├── qemu-initiator-signal-socket.h │ │ │ ├── qemu-target-signal-socket.h │ │ │ └── target.h │ │ ├── qemu-instance.h │ │ ├── tlm-extensions │ │ │ ├── qemu-cpu-hint.h │ │ │ └── qemu-mr-hint.h │ │ └── virtio │ │ │ ├── virtio-mmio-gpugl.h │ │ │ └── virtio-mmio.h │ └── src │ │ ├── dmi_utils.cc │ │ └── libqemu-cxx │ │ ├── callbacks.cc │ │ ├── console.cc │ │ ├── cpu.cc │ │ ├── device.cc │ │ ├── gpex.cc │ │ ├── gpio.cc │ │ ├── libqemu-cxx.cc │ │ ├── loader.cc │ │ ├── memory.cc │ │ ├── object.cc │ │ ├── rcu-read-lock.cc │ │ ├── sysbus.cc │ │ ├── target-info.cc │ │ ├── target │ │ ├── aarch64.cc │ │ ├── hexagon.cc │ │ ├── microblaze.cc │ │ └── riscv.cc │ │ └── timer.cc ├── cpu_arm │ ├── CMakeLists.txt │ ├── cpu_arm_cortex_a53 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-a53.h │ │ └── src │ │ │ └── cortex-a53.cc │ ├── cpu_arm_cortex_a55 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-a55.h │ │ └── src │ │ │ └── cortex-a55.cc │ ├── cpu_arm_cortex_a710 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-a710.h │ │ └── src │ │ │ └── cortex-a710.cc │ ├── cpu_arm_cortex_a76 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-a76.h │ │ └── src │ │ │ └── cortex-a76.cc │ ├── cpu_arm_cortex_m55 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-m55.h │ │ └── src │ │ │ └── cortex-m55.cc │ ├── cpu_arm_cortex_m7 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-m7.h │ │ └── src │ │ │ └── cortex-m7.cc │ ├── cpu_arm_cortex_r5 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-r5.h │ │ └── src │ │ │ └── cortex-r5.cc │ ├── cpu_arm_cortex_r52 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cortex-r52.h │ │ └── src │ │ │ └── cortex-r52.cc │ ├── cpu_arm_neoverse_n1 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── neoverse-n1.h │ │ └── src │ │ │ └── neoverse-n1.cc │ └── cpu_arm_neoverse_n2 │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── neoverse-n2.h │ │ └── src │ │ └── neoverse-n2.cc ├── cpu_hexagon │ ├── CMakeLists.txt │ ├── include │ │ └── hexagon.h │ └── src │ │ └── hexagon.cc ├── cpu_riscv │ ├── CMakeLists.txt │ ├── cpu_riscv64 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── riscv64.h │ │ └── src │ │ │ └── riscv64.cc │ └── cpu_sifive_x280 │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── sifive-x280-rtl.h │ │ └── src │ │ └── sifive-x280-rtl.cc ├── display │ ├── CMakeLists.txt │ ├── include │ │ └── display.h │ └── src │ │ └── display.cc ├── global_peripheral_initiator │ ├── CMakeLists.txt │ ├── include │ │ └── global_peripheral_initiator.h │ └── src │ │ └── global_peripheral_initiator.cc ├── irq-ctrl │ ├── CMakeLists.txt │ ├── arm_gicv2 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── arm-gicv2.h │ │ └── src │ │ │ └── arm-gicv2.cc │ ├── arm_gicv3 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── arm_gicv3.h │ │ └── src │ │ │ └── arm_gicv3.cc │ ├── armv7m_nvic │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── armv7m-nvic.h │ │ └── src │ │ │ └── armv7m-nvic.cc │ ├── hexagon_l2vic │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hexagon-l2vic.h │ │ └── src │ │ │ └── hexagon-l2vic.cc │ ├── plic_sifive │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── plic-sifive.h │ │ └── src │ │ │ └── plic-sifive.cc │ └── riscv_aclint_swi │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── riscv-aclint-swi.h │ │ └── src │ │ └── riscv-aclint-swi.cc ├── nvme │ ├── CMakeLists.txt │ ├── include │ │ └── nvme.h │ └── src │ │ └── nvme.cc ├── opencores_eth │ ├── CMakeLists.txt │ ├── include │ │ └── opencores_eth.h │ └── src │ │ └── opencores_eth.cc ├── pci │ ├── CMakeLists.txt │ ├── ivshmem_plain │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── ivshmem_plain.h │ │ └── src │ │ │ └── ivshmem_plain.cc │ ├── qemu_gpex │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_gpex.h │ │ └── src │ │ │ └── qemu_gpex.cc │ ├── qemu_xhci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_xhci.h │ │ └── src │ │ │ └── qemu_xhci.cc │ ├── rtl8139_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── rtl8139_pci.h │ │ └── src │ │ │ └── rtl8139_pci.cc │ ├── vhost_user_vsock_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── vhost_user_vsock_pci.h │ │ └── src │ │ │ └── vhost_user_vsock_pci.cc │ ├── virtio_gpu.h │ ├── virtio_gpu_cl_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── virtio_gpu_cl_pci.h │ │ └── src │ │ │ └── virtio_gpu_cl_pci.cc │ ├── virtio_gpu_gl_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── virtio_gpu_gl_pci.h │ │ └── src │ │ │ └── virtio_gpu_gl_pci.cc │ ├── virtio_gpu_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── virtio_gpu_pci.h │ │ └── src │ │ │ └── virtio_gpu_pci.cc │ ├── virtio_gpu_qnn_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── virtio_gpu_qnn_pci.h │ │ └── src │ │ │ └── virtio_gpu_qnn_pci.cc │ └── virtio_sound_pci │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── virtio_sound_pci.h │ │ └── src │ │ └── virtio_sound_pci.cc ├── qmp │ ├── CMakeLists.txt │ ├── include │ │ └── qmp.h │ └── src │ │ └── qmp.cc ├── reset_gpio │ ├── CMakeLists.txt │ ├── include │ │ └── reset_gpio.h │ └── src │ │ └── reset_gpio.cc ├── sifive_test │ ├── CMakeLists.txt │ ├── include │ │ └── sifive_test.h │ └── src │ │ └── sifive_test.cc ├── timer │ ├── CMakeLists.txt │ ├── qemu_hexagon_qtimer │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_hexagon_qtimer.h │ │ └── src │ │ │ └── qemu_hexagon_qtimer.cc │ └── riscv_aclint_mtimer │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── riscv-aclint-mtimer.h │ │ └── src │ │ └── riscv-aclint-mtimer.cc ├── uart │ ├── 16550 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── 16550.h │ │ └── src │ │ │ └── 16550.cc │ ├── CMakeLists.txt │ ├── qemu_pl011 │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_pl011.h │ │ └── src │ │ │ └── qemu_pl011.cc │ └── sifive_uart │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── sifive-uart.h │ │ └── src │ │ └── sifive-uart.cc ├── usb │ ├── CMakeLists.txt │ ├── qemu_kbd │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_kbd.h │ │ └── src │ │ │ └── qemu_kbd.cc │ ├── qemu_tablet │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── qemu_tablet.h │ │ └── src │ │ │ └── qemu_tablet.cc │ └── usb_host │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── usb_host.h │ │ └── src │ │ └── usb_host.cc ├── virtio_keyboard_pci │ ├── CMakeLists.txt │ ├── include │ │ └── virtio-keyboard-pci.h │ └── src │ │ └── virtio-keyboard-pci.cc ├── virtio_mmio_blk │ ├── CMakeLists.txt │ ├── include │ │ └── virtio_mmio_blk.h │ └── src │ │ └── virtio_mmio_blk.cc ├── virtio_mmio_gpugl │ ├── CMakeLists.txt │ ├── include │ │ └── virtio_mmio_gpugl.h │ └── src │ │ └── virtio_mmio_gpugl.cc ├── virtio_mmio_net │ ├── CMakeLists.txt │ ├── include │ │ └── virtio_mmio_net.h │ └── src │ │ └── virtio_mmio_net.cc ├── virtio_mmio_sound │ ├── CMakeLists.txt │ ├── include │ │ └── virtio_mmio_sound.h │ └── src │ │ └── virtio_mmio_sound.cc └── virtio_mouse_pci │ ├── CMakeLists.txt │ ├── include │ └── virtio-mouse-pci.h │ └── src │ └── virtio-mouse-pci.cc ├── repolint.json ├── requirements.txt ├── scripts └── install_dependencies.sh ├── systemc-components ├── CMakeLists.txt ├── addrtr │ ├── CMakeLists.txt │ ├── include │ │ └── addrtr.h │ └── src │ │ └── addrtr.cc ├── backends │ ├── CMakeLists.txt │ ├── char_backend_file │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── char_backend_file.h │ │ └── src │ │ │ └── char_backend_file.cc │ ├── char_backend_socket │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── char_backend_socket.h │ │ └── src │ │ │ └── char_backend_socket.cc │ ├── char_backend_stdio │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── char_backend_stdio.h │ │ └── src │ │ │ └── char_backend_stdio.cc │ ├── legacy_char_backend_stdio │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── legacy_char_backend_stdio.h │ │ └── src │ │ │ └── legacy_char_backend_stdio.cc │ └── loop_back_backend │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── loop_back_backend.h │ │ └── src │ │ └── loop_back_backend.cc ├── biflow_router │ ├── CMakeLists.txt │ └── src │ │ └── biflow.cc ├── common │ ├── include │ │ ├── argparser.h │ │ ├── async_event.h │ │ ├── backends │ │ │ ├── legacy-char-backend.h │ │ │ ├── net-backend.h │ │ │ └── tap.h │ │ ├── cciutils.h │ │ ├── inlinesync.h │ │ ├── libgssync.h │ │ ├── libgsutils.h │ │ ├── loader.h │ │ ├── luafile_tool.h │ │ ├── macs │ │ │ ├── dma.h │ │ │ ├── mac.h │ │ │ ├── mii.h │ │ │ ├── payload.h │ │ │ └── phy.h │ │ ├── memory_services.h │ │ ├── module_factory_container.h │ │ ├── module_factory_registery.h │ │ ├── observer_event.h │ │ ├── onmethod.h │ │ ├── ports │ │ │ ├── biflow-socket.h │ │ │ ├── initiator-signal-socket.h │ │ │ ├── multiinitiator-signal-socket.h │ │ │ └── target-signal-socket.h │ │ ├── pre_suspending_sc_support.h │ │ ├── qk_extendedif.h │ │ ├── qk_factory.h │ │ ├── qkmulti-adaptive.h │ │ ├── qkmulti-freerunning.h │ │ ├── qkmulti-quantum.h │ │ ├── qkmulti-rolling.h │ │ ├── qkmulti-unconstrained.h │ │ ├── qkmultithread.h │ │ ├── registers.h │ │ ├── remote.h │ │ ├── report.h │ │ ├── router_if.h │ │ ├── runonsysc.h │ │ ├── semaphore.h │ │ ├── sync_window.h │ │ ├── tests │ │ │ ├── initiator-tester.h │ │ │ ├── target-tester.h │ │ │ └── test-bench.h │ │ ├── tlm-extensions │ │ │ ├── exclusive-access.h │ │ │ ├── pathid_extension.h │ │ │ ├── shmem_extension.h │ │ │ └── underlying-dmi.h │ │ ├── tlm_sockets_buswidth.h │ │ ├── transaction_forwarder_if.h │ │ └── uutils.h │ └── src │ │ ├── cciutils.cc │ │ ├── libgssync │ │ ├── pre_suspending_sc_support.cc │ │ ├── qk_factory.cc │ │ └── qkmultithread.cc │ │ ├── luautils.cc │ │ ├── macs │ │ ├── backends │ │ │ └── tap.cc │ │ └── components │ │ │ ├── mac.cc │ │ │ └── phy.cc │ │ ├── memory_services.cc │ │ └── uutils.cc ├── dmi_converter │ ├── CMakeLists.txt │ ├── include │ │ └── dmi_converter.h │ └── src │ │ └── dmi_converter.cc ├── exclusive_monitor │ ├── CMakeLists.txt │ ├── include │ │ └── exclusive-monitor.h │ └── src │ │ └── exclusive-monitor.cc ├── exiter │ ├── CMakeLists.txt │ ├── include │ │ └── exiter.h │ └── src │ │ └── exiter.cc ├── gs_memory │ ├── CMakeLists.txt │ ├── include │ │ └── gs_memory.h │ └── src │ │ └── gs_memory.cc ├── keep_alive │ ├── CMakeLists.txt │ ├── include │ │ └── keep_alive.h │ └── src │ │ └── keep_alive.cc ├── loader │ ├── CMakeLists.txt │ └── src │ │ └── loader.cc ├── macs │ ├── CMakeLists.txt │ ├── dwmac │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── dwmac.h │ │ └── src │ │ │ └── dwmac.cc │ └── xgmac │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── xgmac.h │ │ └── src │ │ └── xgmac.cc ├── memory_dumper │ ├── CMakeLists.txt │ ├── include │ │ └── memory_dumper.h │ └── src │ │ └── memory_dumper.cc ├── monitor │ ├── CMakeLists.txt │ ├── include │ │ └── monitor.h │ ├── src │ │ └── monitor.cc │ └── static │ │ ├── monitor.html │ │ └── res │ │ └── vnc.html ├── pass │ ├── CMakeLists.txt │ ├── include │ │ └── pass.h │ └── src │ │ └── pass.cc ├── python_binder │ ├── CMakeLists.txt │ ├── include │ │ └── python_binder.h │ └── src │ │ └── python_binder.cc ├── realtimelimiter │ ├── CMakeLists.txt │ ├── include │ │ └── realtimelimiter.h │ └── src │ │ └── realtimelimiter.cc ├── reg_router │ ├── CMakeLists.txt │ ├── include │ │ └── reg_router.h │ └── src │ │ └── reg_router.cc ├── router │ ├── CMakeLists.txt │ ├── include │ │ └── router.h │ └── src │ │ └── router.cc ├── timeprinter │ ├── CMakeLists.txt │ ├── include │ │ └── timeprinter.h │ └── src │ │ └── timeprinter.cc ├── tlm_bus_width_bridges │ ├── CMakeLists.txt │ ├── include │ │ └── tlm_bus_width_bridges.h │ └── src │ │ └── tlm_bus_width_bridges.cc └── uart │ ├── CMakeLists.txt │ ├── uart-ibex │ ├── CMakeLists.txt │ ├── include │ │ └── uart-ibex.h │ └── src │ │ └── uart-ibex.cc │ └── uart-pl011 │ ├── CMakeLists.txt │ ├── include │ └── uart-pl011.h │ └── src │ └── uart-pl011.cc └── tests ├── CMakeLists.txt ├── base-components ├── CMakeLists.txt ├── addrtr │ ├── CMakeLists.txt │ ├── addrtr-bench.h │ └── addrtr-tests.cc ├── aliases │ ├── CMakeLists.txt │ ├── aliases-mapping-bench.h │ ├── aliases-mapping-test.cc │ └── conf-test.lua ├── dmi-converter │ ├── CMakeLists.txt │ ├── dmi-converter-bench.h │ └── dmi-converter-tests.cc ├── exclusive-monitor │ ├── CMakeLists.txt │ ├── test-bench.h │ └── tests.cc ├── gs_register │ ├── CMakeLists.txt │ ├── gs_register-bench.h │ └── gs_register-tests.cc ├── loader │ ├── CMakeLists.txt │ ├── conf-test.lua │ ├── ignore_leaks.txt │ ├── loader-test-bench.h │ ├── loader-test.cc │ └── src │ │ ├── Makefile │ │ ├── README.md │ │ ├── link.ld │ │ ├── loader-test-bin.asm │ │ ├── loader-test.asm │ │ ├── loader-test.bin │ │ ├── loader-test.csv │ │ └── loader-test.elf ├── memory-blocs │ ├── CMakeLists.txt │ └── memory-blocs.cc ├── memory │ ├── CMakeLists.txt │ ├── memory-bench.h │ └── memory-tests.cc ├── python-binder │ ├── CMakeLists.txt │ ├── python-binder-bench.h │ ├── python-binder-test.py │ └── python-binder-tests.cc ├── remote │ ├── CMakeLists.txt │ ├── remote-bench.h │ ├── remote-tests.cc │ └── remote.cc ├── router-memory │ ├── CMakeLists.txt │ ├── router-memory-bench.h │ └── router-memory-tests.cc └── router │ ├── CMakeLists.txt │ ├── router-bench.h │ └── router-tests.cc ├── libgssync ├── CMakeLists.txt ├── integration_tests │ ├── CMakeLists.txt │ ├── checker.h │ ├── main.cc │ ├── pathid_extension.h │ └── tests.lua ├── scp_report │ ├── CMakeLists.txt │ ├── lua_test.lua │ └── scp_report_thread.cc └── unit_tests │ ├── CMakeLists.txt │ ├── qk_extendedif_test.cc │ ├── qkmulti-quantum_test.cc │ └── qkmultithread_test.cc ├── libgsutils ├── CMakeLists.txt ├── cci_alias_test.cc ├── cci_test.cc ├── factory │ ├── CMakeLists.txt │ ├── factory_platform.cc │ └── factory_platform.lua ├── ignore_leaks.txt ├── logger_test.cc ├── lua_test.cc ├── lua_test.lua └── scp_loggging_test.cc ├── libqbox ├── CMakeLists.txt ├── cpu │ ├── CMakeLists.txt │ ├── aarch64 │ │ ├── CMakeLists.txt │ │ ├── dmi-test-async-inval.cc │ │ ├── dmi-test-concurrent-inval.cc │ │ ├── dmi-test.cc │ │ ├── ld-st-excl-fail.cc │ │ ├── simple-write-test.cc │ │ └── write_read.cc │ ├── halt │ │ ├── CMakeLists.txt │ │ └── halt-tests.cc │ ├── hexagon │ │ ├── CMakeLists.txt │ │ ├── hex-reset.cc │ │ └── ld-st-mmio.cc │ └── reset │ │ ├── CMakeLists.txt │ │ ├── reset-test-base.h │ │ ├── reset-test-cpu.cc │ │ ├── reset-test-system.cc │ │ └── reset-test.cc ├── display │ ├── CMakeLists.txt │ └── display.cc ├── hexagon │ ├── CMakeLists.txt │ ├── load-store-test.cc │ ├── mmio_probe.h │ └── test.h ├── include │ └── test │ │ ├── cpu.h │ │ ├── test.h │ │ └── tester │ │ ├── dmi.h │ │ ├── dmi_soak.h │ │ ├── exclusive.h │ │ ├── mmio.h │ │ └── tester.h └── patch-keystone.patch └── systemc-uarts ├── CMakeLists.txt ├── file-backend-test.cc ├── uart-biflow-backend-socket-test.cc ├── uart-biflow-stdio-test.cc └── uart-ibex-biflow-stdio-test.cc /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | 5 | ColumnLimit: 120 6 | UseTab: Never 7 | IndentWidth: 4 8 | IndentCaseLabels: false 9 | 10 | PointerAlignment: Left 11 | DerivePointerAlignment: false 12 | 13 | AccessModifierOffset: -4 14 | 15 | AlignAfterOpenBracket: Align 16 | AlignConsecutiveMacros: true 17 | AlignConsecutiveAssignments: false 18 | 19 | AllowAllArgumentsOnNextLine: false 20 | AllowShortFunctionsOnASingleLine: true 21 | AllowShortIfStatementsOnASingleLine: WithoutElse 22 | AllowShortLoopsOnASingleLine: true 23 | AllowShortLambdasOnASingleLine: true 24 | 25 | BreakConstructorInitializers: BeforeComma 26 | BreakBeforeBinaryOperators: None 27 | BreakStringLiterals: true 28 | BreakBeforeBraces: Custom 29 | BraceWrapping: 30 | AfterClass: true 31 | AfterFunction: true 32 | # PackConstructorInitializers: Never # When we have clang14 33 | 34 | SpaceBeforeCtorInitializerColon: false 35 | SpacesBeforeTrailingComments: 1 36 | AlignTrailingComments: true 37 | 38 | SortIncludes: false 39 | SortUsingDeclarations: false 40 | 41 | Cpp11BracedListStyle: false 42 | PenaltyBreakAssignment: 2000 43 | 44 | ForEachMacros: ['SC_MODULE', 'SC_CTOR'] 45 | -------------------------------------------------------------------------------- /.github/workflows/build-macos-full.yml: -------------------------------------------------------------------------------- 1 | name: Full macOS Build 2 | 3 | on: [ pull_request, push, workflow_dispatch ] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ macOS-14, macOS-15 ] 11 | build_type: [ Debug , Release ] 12 | 13 | runs-on: "${{ matrix.os }}" 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Set reusable strings 19 | id: strings 20 | shell: sh 21 | run: | 22 | echo "build-output-dir=${{ github.workspace }}/build" >> "${GITHUB_OUTPUT}" 23 | 24 | - name: Install dependencies 25 | run: scripts/install_dependencies.sh 26 | 27 | - name: Configure 28 | run: | 29 | cmake \ 30 | -G Ninja \ 31 | -B "${{ steps.strings.outputs.build-output-dir }}" \ 32 | -S "${{ github.workspace }}" \ 33 | -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" \ 34 | -DCMAKE_C_COMPILER=clang \ 35 | -DCMAKE_CXX_COMPILER=clang++ \ 36 | -DGREENSOCS_GIT="https://github.com/quic/" \ 37 | -DLIBQEMU_TARGETS="aarch64;hexagon" 38 | 39 | - name: Build 40 | run: cmake --build "${{ steps.strings.outputs.build-output-dir }}" --parallel 41 | 42 | - name: Test 43 | run: ctest --test-dir "${{ steps.strings.outputs.build-output-dir }}" --output-on-failure 44 | -------------------------------------------------------------------------------- /.github/workflows/build-ubuntu-full.yml: -------------------------------------------------------------------------------- 1 | name: Full Ubuntu Build 2 | 3 | on: [ pull_request, push, workflow_dispatch ] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ ubuntu-24.04 , ubuntu-22.04, ubuntu-20.04 ] 11 | build_type: [ Debug , Release ] 12 | c_compiler: [ gcc , clang ] 13 | cpp_compiler: [ g++ , clang++ ] 14 | exclude: 15 | - c_compiler: gcc 16 | cpp_compiler: clang++ 17 | - c_compiler: clang 18 | cpp_compiler: g++ 19 | 20 | runs-on: "${{ matrix.os }}" 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Set reusable strings 26 | id: strings 27 | shell: sh 28 | run: | 29 | echo "build-output-dir=${{ github.workspace }}/build" >> "${GITHUB_OUTPUT}" 30 | 31 | - name: Install dependencies 32 | run: sudo scripts/install_dependencies.sh 33 | 34 | - name: Configure 35 | run: | 36 | cmake \ 37 | -G Ninja \ 38 | -B "${{ steps.strings.outputs.build-output-dir }}" \ 39 | -S "${{ github.workspace }}" \ 40 | -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" \ 41 | -DCMAKE_C_COMPILER="${{ matrix.c_compiler }}" \ 42 | -DCMAKE_CXX_COMPILER="${{ matrix.cpp_compiler }}" \ 43 | -DGREENSOCS_GIT="https://github.com/quic/" \ 44 | -DLIBQEMU_TARGETS="aarch64;hexagon" 45 | 46 | - name: Build 47 | run: cmake --build "${{ steps.strings.outputs.build-output-dir }}" --parallel 48 | 49 | - name: Test 50 | run: ctest --test-dir "${{ steps.strings.outputs.build-output-dir }}" --output-on-failure 51 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | name: ClangFormat 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | clang-format: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v4 11 | 12 | - name: Install clang-format 13 | run: sudo apt install clang-format 14 | 15 | - name: Fetch target branch 16 | run: git fetch origin "${{ github.base_ref }}" 17 | 18 | - name: Run clang-format 19 | run: git clang-format --diff --verbose FETCH_HEAD 20 | -------------------------------------------------------------------------------- /.github/workflows/gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: Deploy static content to Pages 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | workflow_dispatch: 7 | 8 | permissions: 9 | contents: read 10 | pages: write 11 | id-token: write 12 | 13 | concurrency: 14 | group: "pages" 15 | cancel-in-progress: false 16 | 17 | jobs: 18 | deploy: 19 | environment: 20 | name: github-pages 21 | url: ${{ steps.deployment.outputs.page_url }} 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | 27 | - name: Install Doxygen 28 | run: sudo apt-get install doxygen graphviz 29 | 30 | - name: Generate Doxygen 31 | run: | 32 | doxygen -g 33 | sed -i "s#PROJECT_NAME *= *\".*\"#PROJECT_NAME = ${GITHUB_REPOSITORY}#" Doxyfile 34 | sed -i "s#RECURSIVE *= *NO#RECURSIVE = YES#" Doxyfile 35 | if test -f "${GITHUB_WORKSPACE}/docs/qqvp/qqvp_user_doc.md" 36 | then 37 | echo "Adding qqvp_user_doc.md" 38 | sed -i "s#INPUT *= *#INPUT = ./ ./docs/qqvp/qqvp_user_doc.md#" Doxyfile 39 | fi 40 | sed -i "s#HTML_OUTPUT *= .*#HTML_OUTPUT = public#" Doxyfile 41 | sed -i "s#GENERATE_LATEX *= *YES#GENERATE_LATEX = NO#" Doxyfile 42 | sed -i "s#EXCLUDE *= *#EXCLUDE = tests/ build/ docs/ scripts/ configs/#" Doxyfile 43 | doxygen Doxyfile 44 | 45 | - name: Setup Pages 46 | uses: actions/configure-pages@v5 47 | 48 | - name: Upload artifact 49 | uses: actions/upload-pages-artifact@v3 50 | with: 51 | path: 'public/' 52 | 53 | - name: Deploy to GitHub Pages 54 | id: deployment 55 | uses: actions/deploy-pages@v4 56 | -------------------------------------------------------------------------------- /.github/workflows/quic-organization-repolinter.yml: -------------------------------------------------------------------------------- 1 | name: QuIC Organization Repolinter 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | repolinter: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout Repo 15 | uses: actions/checkout@v2 16 | - name: Verify repolinter config file is present 17 | id: check_files 18 | uses: andstor/file-existence-action@v1 19 | with: 20 | files: "repolint.json" 21 | - name: Run Repolinter with local repolint.json 22 | if: steps.check_files.outputs.files_exists == 'true' 23 | uses: todogroup/repolinter-action@v1 24 | with: 25 | config_file: "repolint.json" 26 | - name: Run Repolinter with default ruleset 27 | if: steps.check_files.outputs.files_exists == 'false' 28 | uses: todogroup/repolinter-action@v1 29 | with: 30 | config_url: "https://raw.githubusercontent.com/quic/.github/main/repolint.json" 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build*/ 2 | /debug*/ 3 | tags 4 | TAGS 5 | *~ 6 | *.sw? 7 | .vscode 8 | .DS_Store 9 | __pycache__ 10 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - project: 'qqvp/cmake-boilerplate' 3 | file: 'gitlab-ci-template.yml' 4 | 5 | repolinter: 6 | stage: build 7 | tags: 8 | - linux 9 | script: 10 | - echo "start repolinter for Qbox" 11 | - repolinter lint ../Qbox 12 | 13 | .build_job_template: 14 | needs: ["repolinter"] 15 | extends: 16 | - .general_build_job_template 17 | variables: 18 | REPO_CMAKE_ARGS: -DLIBQEMU_TARGETS='aarch64;hexagon;xtensa;riscv64;riscv32' 19 | 20 | qqvp-trigger: 21 | extends: .base-trigger 22 | trigger: 23 | project: qqvp/qqvp 24 | variables: 25 | OVERRIDE_PKG: qbox 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | 29 | SPDX-License-Identifier: BSD-3-Clause -------------------------------------------------------------------------------- /docs/base-components/base-components.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/base-components/base-components.pdf -------------------------------------------------------------------------------- /docs/libgssync/gssync-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libgssync/gssync-2.pdf -------------------------------------------------------------------------------- /docs/libgssync/gssync.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libgssync/gssync.pdf -------------------------------------------------------------------------------- /docs/libgsutils/gsutils-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libgsutils/gsutils-2.pdf -------------------------------------------------------------------------------- /docs/libgsutils/gsutils.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libgsutils/gsutils.pdf -------------------------------------------------------------------------------- /docs/libqbox/qbox-extra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libqbox/qbox-extra.pdf -------------------------------------------------------------------------------- /docs/libqbox/qbox.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libqbox/qbox.pdf -------------------------------------------------------------------------------- /docs/libqemu-cxx/README-local.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [//]: # (SECTION 0) 4 | 5 | ## LIBQEMU-CXX 6 | 7 | Libqemu-cxx encapsulates QEMU as a C++ object, such that it can be instanced (for instance) within a SystemC simulation framework. 8 | 9 | [//]: # (SECTION 10) 10 | ## Information about building and using the libqemu-cxx library 11 | 12 | The libgsutils library does not depend on any library. 13 | 14 | [//]: # (SECTION 100) 15 | 16 | The QEMU Library is dlopen'ed. In order to ensure that each instance is self contained, on Linux, a deep copy of the library is performed for every subsequent instance of the same library after the first. The copy is created in /tmp/qbox_lib.XXXXXX. The file is deleted once loaded. The result of this is that symbols from that library will not be accessible during debug. 17 | 18 | If it proves necessary to debug the temporary libraries, then recompile with the flag DEBUG_TMP_LIBRARIES defined. A warning will be issued on stdio identifying the temporary library which should be deleted once used. 19 | -------------------------------------------------------------------------------- /docs/libqemu-cxx/libqemu-cxx.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/libqemu-cxx/libqemu-cxx.pdf -------------------------------------------------------------------------------- /docs/systemc-macs/systemc-macs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/systemc-macs/systemc-macs.pdf -------------------------------------------------------------------------------- /docs/systemc-uarts/systemc-uarts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/docs/systemc-uarts/systemc-uarts.pdf -------------------------------------------------------------------------------- /html/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/examples 2 | FILES_MATCHING PATTERN "*.html" 3 | ) 4 | -------------------------------------------------------------------------------- /libqboxConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(libqemu-cxx) 5 | 6 | if (NOT TARGET qbox) 7 | include("${CMAKE_CURRENT_LIST_DIR}/libqbox-targets.cmake") 8 | endif() 9 | 10 | -------------------------------------------------------------------------------- /libqemu-cxxConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(libqemu) 5 | 6 | if (NOT TARGET qemu-cxx) 7 | include("${CMAKE_CURRENT_LIST_DIR}/libqemu-cxx-targets.cmake") 8 | endif() 9 | -------------------------------------------------------------------------------- /package-lock.cmake: -------------------------------------------------------------------------------- 1 | # CPM Package Lock 2 | # This file should be committed to version control 3 | 4 | # SystemC 5 | CPMDeclarePackage(SystemCLanguage 6 | NAME SystemCLanguage 7 | GIT_TAG 3.0.0 8 | GIT_REPOSITORY https://github.com/accellera-official/systemc.git 9 | GIT_SHALLOW on 10 | OPTIONS 11 | "ENABLE_SUSPEND_ALL" 12 | "ENABLE_PHASE_CALLBACKS" 13 | ) 14 | 15 | # SCP 16 | CPMDeclarePackage(SCP 17 | NAME SCP 18 | GIT_TAG 686c999f9dc15b17147a71f3de505dfe4ff3ec4d 19 | GIT_REPOSITORY https://github.com/accellera-official/systemc-common-practices.git 20 | GIT_SHALLOW on 21 | ) 22 | 23 | # qemu (unversioned) 24 | CPMDeclarePackage(qemu 25 | NAME libqemu 26 | GIT_REPOSITORY ${GREENSOCS_GIT}${QEMU_PATH_NAME}.git 27 | GIT_TAG libqemu-v9.1-v0.14 28 | GIT_SUBMODULES CMakeLists.txt 29 | GIT_SHALLOW on 30 | ) 31 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBQEMU_TARGETS aarch64) 2 | 3 | add_executable(cortex-m55-vp 4 | src/main.cc 5 | ) 6 | 7 | add_executable(remote_cpu 8 | src/remote_cpu.cc 9 | ) 10 | 11 | target_link_libraries(cortex-m55-vp 12 | ${TARGET_LIBS} 13 | ) 14 | 15 | target_link_libraries(remote_cpu 16 | ${TARGET_LIBS} 17 | ) 18 | 19 | target_include_directories( 20 | cortex-m55-vp PUBLIC 21 | $ 22 | $ 23 | ) 24 | 25 | target_include_directories( 26 | remote_cpu PUBLIC 27 | $ 28 | $ 29 | ) 30 | 31 | set_target_properties(cortex-m55-vp PROPERTIES 32 | INSTALL_RPATH "$ORIGIN/../lib;$ORIGIN/../lib/libqemu;$ORIGIN/../../../lib" 33 | ) 34 | 35 | set_target_properties(remote_cpu PROPERTIES 36 | INSTALL_RPATH "$ORIGIN/../lib;$ORIGIN/../lib/libqemu;$ORIGIN/../../../lib" 37 | ) 38 | 39 | install(TARGETS cortex-m55-vp RUNTIME DESTINATION bin/platforms/cortex-m55-remote) 40 | install(TARGETS remote_cpu RUNTIME DESTINATION bin/platforms/cortex-m55-remote) 41 | 42 | gs_enable_testing() -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/base-components.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/base-components.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/gssync.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/gssync.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/gsutils.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/gsutils.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/libqemu-cxx.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/libqemu-cxx.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/qbox.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/qbox.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/docs/systemc-uarts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/docs/systemc-uarts.pdf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/Makefile: -------------------------------------------------------------------------------- 1 | NAME=$(shell basename $(CURDIR)) 2 | 3 | CC=arm-none-eabi-gcc 4 | 5 | all: 6 | $(CC) -nostdinc -nostdlib -mcpu=cortex-m55 -O2 -mthumb -I. -c setup.s -o setup.o 7 | $(CC) -nostdinc -nostdlib -mcpu=cortex-m55 -O2 -mthumb -I. -c nvic.c -o nvic.o 8 | $(CC) -nostdinc -nostdlib -mcpu=cortex-m55 -O2 -mthumb -I. -c main.c -o main.o 9 | $(CC) -nostdinc -nostdlib -mcpu=cortex-m55 -O2 -mthumb -I. setup.o nvic.o main.o -o $(NAME).elf -Wl,-Tlinker.ld 10 | arm-none-eabi-objcopy -Obinary $(NAME).elf $(NAME).bin 11 | xxd -i $(NAME).bin 12 | 13 | clean: 14 | rm -f *.o *.elf *.bin 15 | 16 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/cortex-m55.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/fw/cortex-m55/cortex-m55.bin -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/cortex-m55.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/platforms/cortex-m55-remote/fw/cortex-m55/cortex-m55.elf -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/linker.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | 3 | MEMORY { 4 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x10000 5 | ram (rwx) : ORIGIN = 0x00010000, LENGTH = 0x10000 6 | } 7 | 8 | SECTIONS 9 | { 10 | .reset : { 11 | *setup.s.o(.text) 12 | } > rom 13 | 14 | .text : { 15 | *(.text) 16 | *(.note.gnu.build-id) 17 | *(.ARM.attributes) 18 | *(.rodata .rodata.*) 19 | } > rom 20 | 21 | .data : { 22 | *(.data) 23 | } > ram 24 | 25 | .bss : { 26 | . = ALIGN (8); 27 | __bss_start = . ; 28 | *(.shbss) 29 | *(.bss .bss.*) 30 | *(COMMON) 31 | . = ALIGN (8); 32 | __bss_end = .; 33 | } > ram 34 | 35 | .stack : { 36 | . += 0x1000; 37 | . = ALIGN (8); 38 | _initial_sp = .; 39 | . += 0x1000; 40 | . = ALIGN (8); 41 | _initial_irq_sp = .; 42 | } > ram 43 | } 44 | 45 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "nvic.h" 8 | 9 | void uart_driver_init(void) { _enable_irq(); } 10 | 11 | static void uart_puts(const char* str) 12 | { 13 | while (*str) { 14 | *(volatile unsigned int*)0xc0000000 = *str++; 15 | } 16 | } 17 | 18 | void __attribute__((interrupt)) invalid_excp(void) 19 | { 20 | // We never get here, unless the deliberate unhandled exception in c_entry() is uncommented. 21 | uart_puts("invalid exception happened\r\n"); 22 | } 23 | 24 | void __attribute__((interrupt)) _handle_irq(void) 25 | { 26 | uart_puts("IRQ 17 happened\r\n"); 27 | *(volatile unsigned int*)0xc0001000 = 1; 28 | } 29 | 30 | void __attribute__((interrupt)) _handle_nmi(void) 31 | { 32 | uart_puts("NMI happened\r\n"); 33 | *(volatile unsigned int*)0xc0001004 = 1; 34 | } 35 | 36 | void __attribute__((interrupt)) _handle_systick(void) 37 | { 38 | uart_puts("SysTick happened\r\n"); 39 | *(volatile unsigned int*)0xc0001008 = 1; 40 | } 41 | 42 | void c_entry(void) 43 | { 44 | nvic_enable_irq(0); 45 | nvic_enable_irq(17); 46 | 47 | uart_puts("Test program is running. Listening for interrupts.\r\n"); 48 | *(volatile unsigned int*)0xc000100c = 1; // start IRQs generation 49 | 50 | while (1) { 51 | asm volatile("wfi"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/nvic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | volatile unsigned int* const nvic = (unsigned int*)0xE000E000; 10 | 11 | #define NVIC_TYPE (0x004 >> 2) 12 | #define NVIC_SYSTICK_CTRL_STATUS (0x010 >> 2) 13 | #define NVIC_SYSTICK_RELOAD_VAL (0x014 >> 2) 14 | #define NVIC_SYSTICK_VAL (0x018 >> 2) 15 | #define NVIC_SYSTICK_CALIBRATION_VAL (0x01C >> 2) 16 | #define NVIC_SET_ENABLE(x) ((0x100 + x) >> 2) 17 | #define NVIC_CLR_ENABLE(x) ((0x180 + x) >> 2) 18 | 19 | void nvic_enable_irq(unsigned char irq) 20 | { 21 | unsigned char reg = irq / 32; 22 | 23 | nvic[NVIC_SET_ENABLE(reg)] |= (1 << ((unsigned int)irq % 32)); 24 | } 25 | 26 | void nvic_disable_irq(unsigned char irq) 27 | { 28 | unsigned char reg = irq / 32; 29 | 30 | nvic[NVIC_CLR_ENABLE(reg)] |= (1 << ((unsigned int)irq % 32)); 31 | } 32 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/nvic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef NVIC_H 8 | #define NVIC_H 9 | 10 | void nvic_enable_irq(unsigned char irq); 11 | void nvic_disable_irq(unsigned char irq); 12 | void _enable_irq(); 13 | void _disable_irq(); 14 | 15 | #endif /* NVIC_H */ 16 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/fw/cortex-m55/stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef STDINT_H 8 | #define STDINT_H 9 | 10 | typedef unsigned char uint8_t; 11 | typedef unsigned int uint32_t; 12 | 13 | #endif /* STDINT_H */ 14 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/package-lock.cmake: -------------------------------------------------------------------------------- 1 | # CPM Package Lock 2 | # This file should be committed to version control 3 | 4 | # qemu (unversioned) 5 | CPMDeclarePackage(qemu 6 | NAME libqemu 7 | GIT_REPOSITORY ${GREENSOCS_GIT}qemu.git 8 | GIT_TAG libqemu-v7.0.50-v1.3.2 9 | GIT_SUBMODULES CMakeLists.txt 10 | GIT_SHALLOW on 11 | ) 12 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/src/remote_cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /* Quic Module Cortex-M55 */ 8 | #ifndef __REMOTE_CORTEX_M55__ 9 | #define __REMOTE_CORTEX_M55__ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "gs_memory/include/gs_memory.h" 19 | #include "router/include/router.h" 20 | #include "remote.h" 21 | #include "pass/include/pass.h" 22 | #include 23 | 24 | class RemoteCPU : public sc_core::sc_module 25 | { 26 | SCP_LOGGER(); 27 | 28 | public: 29 | RemoteCPU(const sc_core::sc_module_name& n, sc_core::sc_object* obj) 30 | : RemoteCPU(n, *(dynamic_cast(obj))) 31 | { 32 | } 33 | RemoteCPU(const sc_core::sc_module_name& n, QemuInstance& qemu_inst) 34 | : sc_core::sc_module(n) 35 | , m_broker(cci::cci_get_broker()) 36 | , m_gdb_port("gdb_port", 0, "GDB port") 37 | , m_qemu_inst(qemu_inst) 38 | , m_router("router") 39 | , m_cpu("cpu", m_qemu_inst) 40 | { 41 | unsigned int m_irq_num = m_broker.get_param_handle(std::string(this->name()) + ".cpu.nvic.num_irq") 42 | .get_cci_value() 43 | .get_uint(); 44 | 45 | if (!m_gdb_port.is_default_value()) m_cpu.p_gdb_port = m_gdb_port; 46 | 47 | SCP_INFO(()) << "number of irqs = " << m_irq_num; 48 | 49 | m_router.initiator_socket.bind(m_cpu.m_nvic.socket); 50 | m_cpu.socket.bind(m_router.target_socket); 51 | } 52 | 53 | private: 54 | cci::cci_broker_handle m_broker; 55 | cci::cci_param m_gdb_port; 56 | QemuInstance& m_qemu_inst; 57 | gs::router<> m_router; 58 | cpu_arm_cortexM55 m_cpu; 59 | }; 60 | GSC_MODULE_REGISTER(RemoteCPU, sc_core::sc_object*); 61 | #endif 62 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | macro(gs_add_test test) 3 | add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py -e ${CMAKE_BINARY_DIR}/platforms/cortex-m55-remote/cortex-m55-vp -l ${CMAKE_SOURCE_DIR}/platforms/cortex-m55-remote/conf.lua) 4 | set_tests_properties(${test} PROPERTIES TIMEOUT 30) 5 | endmacro() 6 | 7 | gs_add_test(cortex_m55) 8 | -------------------------------------------------------------------------------- /platforms/cortex-m55-remote/tests/cortex_m55.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | # SPDX-License-Identifier: BSD-3-Clause 4 | 5 | import argparse, pprint 6 | import os 7 | from os import sched_get_priority_max 8 | from pathlib import Path 9 | import sys 10 | from sys import exit, stdout 11 | import pexpect 12 | from pexpect import * 13 | import getpass 14 | import subprocess 15 | from subprocess import Popen, PIPE 16 | import signal 17 | 18 | 19 | def vp_test(): 20 | test = False 21 | 22 | parser = argparse.ArgumentParser() 23 | parser.add_argument("-e", "--exe", metavar="", help="Path to vp executable") 24 | parser.add_argument("-l", "--lua", metavar="", help="Path to luafile") 25 | args = parser.parse_args() 26 | if not args.exe: 27 | print("vp executable file not found") 28 | return test 29 | if not args.lua: 30 | print("luafile is required") 31 | return test 32 | vp_path = Path(args.exe) 33 | lua_path = Path(args.lua) 34 | 35 | # start vp platform 36 | cmd = ["ip", "tuntap", "add", "qbox0", "mode", "tap"] 37 | proc = subprocess.Popen( 38 | cmd, 39 | shell=True, 40 | stdin=subprocess.PIPE, 41 | stdout=subprocess.PIPE, 42 | stderr=subprocess.PIPE, 43 | ) 44 | 45 | child = pexpect.spawn(vp_path.as_posix(), ["--gs_luafile", args.lua]) 46 | child.logfile = stdout.buffer 47 | child.expect("Test program is running. Listening for interrupts.") 48 | child.expect("IRQ 17 happened") 49 | child.expect("NMI happened") 50 | child.expect("SysTick happened") 51 | 52 | # make sure to use SIGQUIT to terminate the child as this signal is handled in 53 | # include/greensocs/gsutils/uutils.h and it should be called for VP proper cleanup. 54 | child.kill(signal.SIGQUIT) 55 | child.wait() 56 | 57 | test = True 58 | return test 59 | 60 | 61 | assert(vp_test()) 62 | -------------------------------------------------------------------------------- /platforms/fw/utils.lua: -------------------------------------------------------------------------------- 1 | 2 | -- ** Convenience functions ** 3 | function file_exists(name) 4 | local f=io.open(name,"r") 5 | if f~=nil then io.close(f) return true else return false end 6 | end 7 | 8 | function valid_file(file) 9 | local f = io.open(file, "r") 10 | if (f == nil) 11 | then 12 | print ("ERROR:") 13 | print (file.." Not found.") 14 | os.exit(1) 15 | end 16 | io.close(f); 17 | return file 18 | end 19 | function tableMerge(t1, t2) 20 | for k,v in pairs(t2) do 21 | if type(v) == "table" then 22 | if type(t1[k] or false) == "table" then 23 | tableMerge(t1[k] or {}, t2[k] or {}) 24 | else 25 | t1[k] = v 26 | end 27 | else 28 | t1[k] = v 29 | end 30 | end 31 | return t1 32 | end 33 | function tableJoin(t1,t2) 34 | for i=1,#t2 do 35 | t1[#t1+1] = t2[i] 36 | end 37 | return t1 38 | end 39 | -- ** End of convenience functions ** 40 | 41 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/arm64_bootloader.lua: -------------------------------------------------------------------------------- 1 | -- This file is automatically generated by `cargo xtask lua`. 2 | -- It is not intended for manual editing. 3 | _bootloader_aarch64 = { 4 | -- <.start>: 5 | 0xd53800a6, -- mrs x6, mpidr_el1 6 | 0x580001e7, -- ldr x7, <.aff_mask> 7 | 0x8a0600e7, -- and x7, x7, x6 8 | 0xf10000ff, -- cmp x7, #0x0 9 | 0x54000061, -- b.ne <.secondary> // b.any 10 | -- <.core0>: 11 | 0x580001a4, -- ldr x4, <.kernel_entry> 12 | 0x14000004, -- b <.boot> 13 | -- <.secondary>: 14 | 0xd503205f, -- wfe 15 | 0x580001c4, -- ldr x4, <.spintable> 16 | 0xb4ffffc4, -- cbz x4, <.secondary> 17 | -- <.boot>: 18 | 0x58000140, -- ldr x0, <.dtb_ptr> 19 | 0xaa1f03e1, -- mov x1, xzr 20 | 0xaa1f03e2, -- mov x2, xzr 21 | 0xaa1f03e3, -- mov x3, xzr 22 | 0xd61f0080, -- br x4 23 | 0x00000000, -- .word 0x00000000 24 | -- <.aff_mask>: 25 | 0x00ffffff, -- .word 0x00ffffff 26 | 0x00000000, -- .word 0x00000000 27 | -- <.kernel_entry>: 28 | _KERNEL64_LOAD_ADDR, -- .word 0x00080000 29 | 0x00000000, -- .word 0x00000000 30 | -- <.dtb_ptr>: 31 | _DTB_LOAD_ADDR, -- .word 0x08000000 32 | 0x00000000, -- .word 0x00000000 33 | -- <.spintable>: 34 | 0x00000000, -- .word 0x00000000 35 | } 36 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/mkosi.extra/etc/systemd/network/20-dhcp.network: -------------------------------------------------------------------------------- 1 | [Match] 2 | Name=* 3 | 4 | [Network] 5 | DHCP=yes 6 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/mkosi.extra/usr/lib/systemd/mkosi-use-systemd-resolved.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # 3 | # This file is part of libqbox 4 | # Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | # 8 | 9 | 10 | if [ -e /run/systemd/resolve/resolv.conf ]; then 11 | mv /etc/resolv.conf /etc/resolv.conf.old 12 | ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf 13 | fi 14 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset: -------------------------------------------------------------------------------- 1 | # This file is part of libqbox 2 | # Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | # 6 | 7 | 8 | enable dbus-broker.service 9 | disable NetworkManager 10 | enable systemd-networkd.service 11 | enable systemd-networkd-wait-online.service 12 | enable systemd-resolved.service 13 | disable auditd.service 14 | enable systemd-timesyncd.service 15 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/mkosi.extra/usr/lib/systemd/system/mkosi-use-systemd-resolved.service: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of libqbox 3 | # Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | # 7 | 8 | [Unit] 9 | Description=use /run/systemd/resolve/resolv.conf instead of /etc/resolv.conf 10 | After=network.target 11 | 12 | [Service] 13 | Type=oneshot 14 | ExecStart=/usr/lib/systemd/mkosi-use-systemd-resolved.sh 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /platforms/ubuntu/fw/mkosi.repart/10-root.conf: -------------------------------------------------------------------------------- 1 | [Partition] 2 | Type=root 3 | Format=ext4 4 | CopyFiles=/ 5 | SizeMinBytes=3G 6 | SizeMaxBytes=3G -------------------------------------------------------------------------------- /platforms/ubuntu/fw/riscv64_bootloader.lua: -------------------------------------------------------------------------------- 1 | _bootloader_riscv64 = { 2 | 0x00000297, -- /* 1: auipc t0,0x0 */ 3 | 0x03428613, -- /* addi a2,t0,52 # 10074 */ 4 | 0xf1402573, -- /* csrr a0,mhartid */ 5 | 0x00000013, -- /* nop */ 6 | 0x02c2b583, -- /* ld a1,44(t0) */ 7 | 0x0242b283, -- /* ld t0,36(t0) */ 8 | 0x00028067, -- /* jr t0 */ 9 | 0x10500073, -- /* stop: wfi */ 10 | 0xffdff06f, -- /* j 1005c */ 11 | (_OPENSBI_LOAD_ADDR & 0xffffffff), -- /* start: .dword */ 12 | (_OPENSBI_LOAD_ADDR >> 32), 13 | (_DTB_LOAD_ADDR & 0xffffffff), -- /* fdt_laddr: .dword */ 14 | (_DTB_LOAD_ADDR >> 32), 15 | -- /* fw_dyn: */ 16 | 0x4942534f, 0, -- /* OSBI magic */ 17 | 2, 0, -- /* OSBI version */ 18 | (_KERNEL64_LOAD_ADDR & 0xffffffff), -- /* OSBI next address */ 19 | (_KERNEL64_LOAD_ADDR >> 32), 20 | 1, 0, -- /* OSBI next mode: S */ 21 | 0, 0, -- /* OSBI options */ 22 | 0, 0, -- /* OSBI prefered boot hart */ 23 | } -------------------------------------------------------------------------------- /py-models/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION lib 3 | FILES_MATCHING PATTERN "*.py") 4 | -------------------------------------------------------------------------------- /qemu-components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(arm_smmu) 2 | add_subdirectory(cpu_arm) 3 | add_subdirectory(cpu_riscv) 4 | add_subdirectory(cpu_hexagon) 5 | add_subdirectory(display) 6 | add_subdirectory(global_peripheral_initiator) 7 | add_subdirectory(irq-ctrl) 8 | add_subdirectory(nvme) 9 | add_subdirectory(opencores_eth) 10 | add_subdirectory(pci) 11 | add_subdirectory(reset_gpio) 12 | add_subdirectory(timer) 13 | add_subdirectory(uart) 14 | add_subdirectory(usb) 15 | add_subdirectory(virtio_keyboard_pci) 16 | add_subdirectory(virtio_mmio_blk) 17 | add_subdirectory(virtio_mmio_net) 18 | add_subdirectory(virtio_mmio_sound) 19 | add_subdirectory(virtio_mouse_pci) 20 | add_subdirectory(virtio_mmio_gpugl) 21 | add_subdirectory(qmp) 22 | add_subdirectory(sifive_test) 23 | -------------------------------------------------------------------------------- /qemu-components/arm_smmu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(arm_smmu) 2 | -------------------------------------------------------------------------------- /qemu-components/arm_smmu/src/arm-smmu.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(arm_smmu, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/common/include/arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2020 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "cpu.h" 12 | 13 | class QemuCpuArm : public QemuCpu 14 | { 15 | public: 16 | static constexpr qemu::Target ARCH = qemu::Target::AARCH64; 17 | 18 | QemuCpuArm(const sc_core::sc_module_name& name, QemuInstance& inst, const std::string& type_name) 19 | : QemuCpu(name, inst, type_name) 20 | { 21 | } 22 | 23 | /// @returns a new `CpuAarch64` wrapper around `m_cpu`. While this looks like 24 | /// a copy, it behaves like a downcast. The underlying qemu object reference 25 | /// count is incremented and decremented correctly by the destructor. 26 | qemu::CpuAarch64 get_cpu_aarch64() const { return qemu::CpuAarch64(m_cpu); } 27 | 28 | void end_of_elaboration() override 29 | { 30 | QemuCpu::end_of_elaboration(); 31 | 32 | // This is needed for KVM otherwise the GIC won't reset properly when a system reset is requested 33 | get_cpu_aarch64().register_reset(); 34 | } 35 | 36 | void start_of_simulation() override 37 | { 38 | // According to qemu/hw/arm/virt.c: 39 | // virt_cpu_post_init() must be called after the CPUs have been realized 40 | // and the GIC has been created. 41 | // I am not sure if this the right place where to call it. I wonder if a 42 | // `before_start_of_simulation` stage would be a better place for this. 43 | // It MUST be called before `QemuCpu::start_of_simulation()`. 44 | get_cpu_aarch64().post_init(); 45 | 46 | QemuCpu::start_of_simulation(); 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /qemu-components/common/include/cache-ctrl/sifive-l2pf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_CACHE_CTRL_SIFIVE_L2PF_H 10 | #define _LIBQBOX_COMPONENTS_CACHE_CTRL_SIFIVE_L2PF_H 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | class QemuRiscvSifiveL2pf : public QemuDevice 21 | { 22 | public: 23 | QemuTargetSocket<> socket; 24 | 25 | QemuRiscvSifiveL2pf(sc_core::sc_module_name nm, QemuInstance& inst) 26 | : QemuDevice(nm, inst, "sifive.l2pf"), socket("mem", inst) 27 | { 28 | } 29 | 30 | void before_end_of_elaboration() override { QemuDevice::before_end_of_elaboration(); } 31 | 32 | void end_of_elaboration() override 33 | { 34 | QemuDevice::end_of_elaboration(); 35 | 36 | qemu::SysBusDevice sbd(get_qemu_dev()); 37 | socket.init(qemu::SysBusDevice(m_dev), 0); 38 | } 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /qemu-components/common/include/cache-ctrl/sifive-pl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_CACHE_CTRL_SIFIVE_PL2_H 10 | #define _LIBQBOX_COMPONENTS_CACHE_CTRL_SIFIVE_PL2_H 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | class QemuRiscvSifivePl2 : public QemuDevice 21 | { 22 | public: 23 | QemuTargetSocket<> socket; 24 | 25 | QemuRiscvSifivePl2(sc_core::sc_module_name nm, QemuInstance& inst) 26 | : QemuDevice(nm, inst, "sifive,pL2Cache0"), socket("mem", inst) 27 | { 28 | } 29 | 30 | void before_end_of_elaboration() override { QemuDevice::before_end_of_elaboration(); } 31 | 32 | void end_of_elaboration() override 33 | { 34 | QemuDevice::end_of_elaboration(); 35 | 36 | qemu::SysBusDevice sbd(get_qemu_dev()); 37 | socket.init(qemu::SysBusDevice(m_dev), 0); 38 | } 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /qemu-components/common/include/exceptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef LIBQBOX_QEMU_EXCEPTIONS_H_ 10 | #define LIBQBOX_QEMU_EXCEPTIONS_H_ 11 | 12 | #include 13 | 14 | class QboxException : public std::runtime_error 15 | { 16 | public: 17 | QboxException(const char* what): std::runtime_error(what) {} 18 | 19 | virtual ~QboxException() throw() {} 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/loader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace qemu { 14 | class LibraryIface 15 | { 16 | public: 17 | virtual bool symbol_exists(const char* symbol) = 0; 18 | virtual void* get_symbol(const char* symbol) = 0; 19 | }; 20 | 21 | class LibraryLoaderIface 22 | { 23 | public: 24 | using LibraryIfacePtr = std::shared_ptr; 25 | 26 | virtual LibraryIfacePtr load_library(const char* lib_name) = 0; 27 | virtual const char* get_lib_ext() = 0; 28 | virtual const char* get_last_error() = 0; 29 | 30 | virtual ~LibraryLoaderIface() = default; 31 | }; 32 | 33 | LibraryLoaderIface* get_default_lib_loader(); 34 | 35 | } // namespace qemu 36 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/target/aarch64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2015-2019 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace qemu { 14 | 15 | class CpuArm : public Cpu 16 | { 17 | public: 18 | static constexpr const char* const TYPE = "arm-cpu"; 19 | 20 | CpuArm() = default; 21 | CpuArm(const CpuArm&) = default; 22 | CpuArm(const Object& o): Cpu(o) {} 23 | 24 | void set_cp15_cbar(uint64_t cbar); 25 | void add_nvic_link(); 26 | 27 | uint64_t get_exclusive_addr() const; 28 | uint64_t get_exclusive_val() const; 29 | void set_exclusive_val(uint64_t val); 30 | 31 | void post_init(); 32 | void register_reset(); 33 | }; 34 | 35 | class CpuAarch64 : public CpuArm 36 | { 37 | public: 38 | static constexpr const char* const TYPE = "arm-cpu"; 39 | 40 | CpuAarch64() = default; 41 | CpuAarch64(const CpuAarch64&) = default; 42 | CpuAarch64(const Object& o): CpuArm(o) {} 43 | 44 | void set_aarch64_mode(bool aarch64_mode); 45 | }; 46 | 47 | class ArmNvic : public Device 48 | { 49 | public: 50 | static constexpr const char* const TYPE = "armv7m_nvic"; 51 | 52 | ArmNvic() = default; 53 | ArmNvic(const ArmNvic&) = default; 54 | ArmNvic(const Object& o): Device(o) {} 55 | 56 | void add_cpu_link(); 57 | }; 58 | 59 | } // namespace qemu 60 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/target/hexagon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace qemu { 14 | class CpuHexagon : public Cpu 15 | { 16 | public: 17 | static constexpr const char* const TYPE = "v67-hexagon-cpu"; 18 | 19 | using MipUpdateCallbackFn = std::function; 20 | 21 | CpuHexagon() = default; 22 | CpuHexagon(const CpuHexagon&) = default; 23 | CpuHexagon(const Object& o): Cpu(o) {} 24 | void register_reset(); 25 | }; 26 | } // namespace qemu 27 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/target/microblaze.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2020 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace qemu { 14 | 15 | class CpuMicroblaze : public Cpu 16 | { 17 | public: 18 | static constexpr const char* const TYPE = "microblaze-cpu"; 19 | 20 | CpuMicroblaze() = default; 21 | CpuMicroblaze(const CpuMicroblaze&) = default; 22 | CpuMicroblaze(const Object& o): Cpu(o) {} 23 | }; 24 | 25 | } // namespace qemu 26 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/target/riscv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace qemu { 14 | class CpuRiscv : public Cpu 15 | { 16 | public: 17 | static constexpr const char* const TYPE = "riscv-cpu"; 18 | 19 | using MipUpdateCallbackFn = std::function; 20 | 21 | CpuRiscv() = default; 22 | CpuRiscv(const CpuRiscv&) = default; 23 | CpuRiscv(const Object& o): Cpu(o) {} 24 | 25 | void set_mip_update_callback(MipUpdateCallbackFn cb); 26 | }; 27 | 28 | class CpuRiscv32 : public CpuRiscv 29 | { 30 | public: 31 | CpuRiscv32() = default; 32 | CpuRiscv32(const CpuRiscv32&) = default; 33 | CpuRiscv32(const Object& o): CpuRiscv(o) {} 34 | }; 35 | 36 | class CpuRiscv64 : public CpuRiscv 37 | { 38 | public: 39 | CpuRiscv64() = default; 40 | CpuRiscv64(const CpuRiscv64&) = default; 41 | CpuRiscv64(const Object& o): CpuRiscv(o) {} 42 | }; 43 | 44 | class CpuRiscv64SiFiveX280 : public CpuRiscv 45 | { 46 | public: 47 | CpuRiscv64SiFiveX280() = default; 48 | CpuRiscv64SiFiveX280(const CpuRiscv64SiFiveX280&) = default; 49 | CpuRiscv64SiFiveX280(const Object& o): CpuRiscv(o) {} 50 | }; 51 | } // namespace qemu 52 | -------------------------------------------------------------------------------- /qemu-components/common/include/libqemu-cxx/target_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | namespace qemu { 12 | 13 | enum Target { 14 | AARCH64, 15 | RISCV64, 16 | RISCV32, 17 | MICROBLAZE, 18 | MICROBLAZEEL, 19 | HEXAGON, 20 | }; 21 | 22 | const char* get_target_name(Target t); 23 | const char* get_target_lib(Target t); 24 | 25 | } // namespace qemu 26 | -------------------------------------------------------------------------------- /qemu-components/common/include/tlm-extensions/qemu-cpu-hint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_TLM_EXTENSIONS_QEMU_CPU_HINT_H 10 | #define _LIBQBOX_TLM_EXTENSIONS_QEMU_CPU_HINT_H 11 | 12 | #include 13 | 14 | #include 15 | 16 | class QemuCpuHintTlmExtension : public tlm::tlm_extension 17 | { 18 | private: 19 | qemu::Cpu m_cpu; 20 | 21 | public: 22 | QemuCpuHintTlmExtension() = default; 23 | QemuCpuHintTlmExtension(const QemuCpuHintTlmExtension&) = default; 24 | 25 | QemuCpuHintTlmExtension(qemu::Cpu cpu): m_cpu(cpu) {} 26 | 27 | virtual tlm_extension_base* clone() const override { return new QemuCpuHintTlmExtension(*this); } 28 | 29 | virtual void copy_from(tlm_extension_base const& ext) override 30 | { 31 | m_cpu = static_cast(ext).m_cpu; 32 | } 33 | 34 | void set_cpu(qemu::Cpu cpu) { m_cpu = cpu; } 35 | qemu::Cpu get_cpu() const { return m_cpu; } 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /qemu-components/common/include/tlm-extensions/qemu-mr-hint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_TLM_EXTENSIONS_QEMU_MR_HINT_H 10 | #define _LIBQBOX_TLM_EXTENSIONS_QEMU_MR_HINT_H 11 | 12 | #include 13 | 14 | #include 15 | 16 | class QemuMrHintTlmExtension : public tlm::tlm_extension 17 | { 18 | private: 19 | qemu::MemoryRegion m_mr; 20 | uint64_t m_offset; 21 | 22 | public: 23 | QemuMrHintTlmExtension() = default; 24 | QemuMrHintTlmExtension(const QemuMrHintTlmExtension&) = default; 25 | 26 | QemuMrHintTlmExtension(qemu::MemoryRegion mr, uint64_t offset): m_mr(mr), m_offset(offset) {} 27 | 28 | virtual tlm_extension_base* clone() const override { return new QemuMrHintTlmExtension(*this); } 29 | 30 | virtual void copy_from(tlm_extension_base const& ext) override 31 | { 32 | m_mr = static_cast(ext).m_mr; 33 | m_offset = static_cast(ext).m_offset; 34 | } 35 | 36 | qemu::MemoryRegion get_mr() const { return m_mr; } 37 | uint64_t get_offset() const { return m_offset; } 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /qemu-components/common/include/virtio/virtio-mmio-gpugl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | class QemuVirtioMMIOGpuGl : public QemuVirtioMMIO 20 | { 21 | private: 22 | public: 23 | QemuVirtioMMIOGpuGl(sc_core::sc_module_name nm, QemuInstance& inst) 24 | : QemuVirtioMMIO(nm, inst, "virtio-gpu-gl-device") 25 | { 26 | } 27 | 28 | void before_end_of_elaboration() override 29 | { 30 | QemuVirtioMMIO::before_end_of_elaboration(); 31 | virtio_mmio_device.get_qemu_dev().set_prop_bool("force-legacy", false); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /qemu-components/common/src/dmi_utils.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | std::ostream& operator<<(std::ostream& os, const QemuInstanceDmiManager::DmiRegion& region) 10 | { 11 | os << "DmiRegion[0x" << std::hex << region.get_key() << "-0x" << region.get_end() << "]"; 12 | return os; 13 | } 14 | 15 | std::ostream& operator<<(std::ostream& os, const tlm::tlm_dmi& info) 16 | { 17 | auto start = QemuInstanceDmiManager::DmiRegion::key_from_tlm_dmi(info); 18 | uint64_t size = (info.get_end_address() - info.get_start_address()) + 1; 19 | uint64_t end = start + size - 1; 20 | os << "TlmDmi[0x" << std::hex << start << "-0x" << end << "]"; 21 | return os; 22 | } 23 | 24 | std::ostream& operator<<(std::ostream& os, const QemuInstanceDmiManager::DmiRegionAlias& alias) 25 | { 26 | os << "DmiRegionAlias[0x" << std::hex << alias.get_start() << "-0x" << alias.get_end() << "] at host offset 0x" 27 | << uintptr_t(alias.get_dmi_ptr()); 28 | return os; 29 | } -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/gpex.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace qemu { 15 | 16 | void GpexHost::set_irq_num(int idx, int gic_irq) 17 | { 18 | QemuSysBusDevice* qemu_sbd; 19 | 20 | qemu_sbd = reinterpret_cast(m_obj); 21 | 22 | m_int->exports().gpex_set_irq_num(qemu_sbd, idx, gic_irq); 23 | } 24 | 25 | } // namespace qemu 26 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/gpio.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2015-2019 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace qemu { 15 | 16 | void Gpio::set(bool lvl) 17 | { 18 | QemuGpio* gpio = reinterpret_cast(m_obj); 19 | 20 | m_int->exports().gpio_set(gpio, lvl); 21 | } 22 | 23 | }; // namespace qemu 24 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/rcu-read-lock.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace qemu { 14 | 15 | RcuReadLock::RcuReadLock(std::shared_ptr internals): m_int(internals) 16 | { 17 | m_int->exports().rcu_read_lock(); 18 | } 19 | 20 | RcuReadLock::~RcuReadLock() 21 | { 22 | if (m_int) { 23 | m_int->exports().rcu_read_unlock(); 24 | } 25 | } 26 | 27 | RcuReadLock::RcuReadLock(RcuReadLock&& o): m_int(o.m_int) { o.m_int.reset(); } 28 | 29 | RcuReadLock& RcuReadLock::operator=(RcuReadLock&& o) 30 | { 31 | std::swap(m_int, o.m_int); 32 | return *this; 33 | } 34 | 35 | } // namespace qemu 36 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/sysbus.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2015-2019 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace qemu { 15 | 16 | MemoryRegion SysBusDevice::mmio_get_region(int id) 17 | { 18 | QemuSysBusDevice* qemu_sbd; 19 | QemuMemoryRegion* qemu_mr; 20 | 21 | qemu_sbd = reinterpret_cast(m_obj); 22 | qemu_mr = m_int->exports().sysbus_mmio_get_region(qemu_sbd, id); 23 | 24 | if (qemu_mr == nullptr) { 25 | throw LibQemuException("Error while getting MMIO region from SysBusDevice"); 26 | } 27 | 28 | Object o(reinterpret_cast(qemu_mr), m_int); 29 | 30 | return MemoryRegion(o); 31 | } 32 | 33 | void SysBusDevice::connect_gpio_out(int idx, Gpio gpio) 34 | { 35 | QemuSysBusDevice* qemu_sbd; 36 | QemuGpio* qemu_gpio; 37 | 38 | qemu_sbd = reinterpret_cast(m_obj); 39 | qemu_gpio = reinterpret_cast(gpio.get_qemu_obj()); 40 | 41 | m_int->exports().sysbus_connect_gpio_out(qemu_sbd, idx, qemu_gpio); 42 | } 43 | 44 | }; // namespace qemu 45 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/target/aarch64.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2015-2019 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include "internals.h" 13 | 14 | namespace qemu { 15 | 16 | void CpuArm::set_cp15_cbar(uint64_t cbar) { m_int->exports().cpu_arm_set_cp15_cbar(m_obj, cbar); } 17 | 18 | void CpuArm::add_nvic_link() { m_int->exports().cpu_arm_add_nvic_link(m_obj); } 19 | 20 | uint64_t CpuArm::get_exclusive_addr() const { return m_int->exports().cpu_arm_get_exclusive_addr(m_obj); } 21 | 22 | uint64_t CpuArm::get_exclusive_val() const { return m_int->exports().cpu_arm_get_exclusive_val(m_obj); } 23 | 24 | void CpuArm::set_exclusive_val(uint64_t val) { m_int->exports().cpu_arm_set_exclusive_val(m_obj, val); } 25 | 26 | void CpuArm::post_init() { m_int->exports().cpu_arm_post_init(m_obj); } 27 | 28 | void CpuArm::register_reset() { m_int->exports().cpu_arm_register_reset(m_obj); } 29 | 30 | void CpuAarch64::set_aarch64_mode(bool aarch64_mode) 31 | { 32 | m_int->exports().cpu_aarch64_set_aarch64_mode(m_obj, aarch64_mode); 33 | } 34 | 35 | void ArmNvic::add_cpu_link() { m_int->exports().arm_nvic_add_cpu_link(m_obj); } 36 | 37 | } // namespace qemu 38 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/target/hexagon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include "internals.h" 13 | 14 | namespace qemu { 15 | void CpuHexagon::register_reset() { m_int->exports().cpu_hexagon_register_reset(m_obj); } 16 | } 17 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/target/microblaze.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2020 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace qemu { 14 | } 15 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/target/riscv.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace qemu { 15 | void CpuRiscv::set_mip_update_callback(MipUpdateCallbackFn cb) 16 | { 17 | m_int->get_cpu_riscv_mip_update_cb().register_cb(*this, cb); 18 | } 19 | } // namespace qemu 20 | -------------------------------------------------------------------------------- /qemu-components/common/src/libqemu-cxx/timer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqemu-cxx 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2015-2019 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace qemu { 15 | 16 | Timer::Timer(std::shared_ptr internals): m_int(internals) {} 17 | 18 | Timer::~Timer() 19 | { 20 | del(); 21 | 22 | if (m_timer != nullptr) { 23 | m_int->exports().timer_free(m_timer); 24 | } 25 | } 26 | 27 | static void timer_generic_callback(void* opaque) 28 | { 29 | Timer::TimerCallbackFn* cb = reinterpret_cast(opaque); 30 | 31 | (*cb)(); 32 | } 33 | 34 | void Timer::set_callback(TimerCallbackFn cb) 35 | { 36 | m_cb = cb; 37 | m_timer = m_int->exports().timer_new_virtual_ns(timer_generic_callback, reinterpret_cast(&m_cb)); 38 | } 39 | 40 | void Timer::mod(int64_t deadline) 41 | { 42 | if (m_timer != nullptr) { 43 | m_int->exports().timer_mod_ns(m_timer, deadline); 44 | } 45 | } 46 | 47 | void Timer::del() 48 | { 49 | if (m_timer != nullptr) { 50 | m_int->exports().timer_del(m_timer); 51 | } 52 | } 53 | 54 | } // namespace qemu 55 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cpu_arm_cortex_a53) 2 | add_subdirectory(cpu_arm_cortex_a55) 3 | add_subdirectory(cpu_arm_cortex_a76) 4 | add_subdirectory(cpu_arm_cortex_a710) 5 | add_subdirectory(cpu_arm_cortex_m7) 6 | add_subdirectory(cpu_arm_cortex_m55) 7 | add_subdirectory(cpu_arm_cortex_r5) 8 | add_subdirectory(cpu_arm_cortex_r52) 9 | add_subdirectory(cpu_arm_neoverse_n1) 10 | add_subdirectory(cpu_arm_neoverse_n2) 11 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a53/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexA53) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a53/src/cortex-a53.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexA53, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a55/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexA55) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a55/src/cortex-a55.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexA55, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a710/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexA710) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a710/src/cortex-a710.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexA710, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a76/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexA76) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_a76/src/cortex-a76.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexA76, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_m55/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexM55) 2 | 3 | target_include_directories( 4 | cpu_arm_cortexM55 PUBLIC 5 | $ 6 | ) -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_m55/src/cortex-m55.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexM55, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_m7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexM7) 2 | 3 | target_include_directories( 4 | cpu_arm_cortexM7 PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_m7/include/cortex-m7.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | class cpu_arm_cortexM7 : public QemuCpuArm 21 | { 22 | public: 23 | cci::cci_param p_start_powered_off; 24 | nvic_armv7m m_nvic; 25 | cci::cci_param p_init_nsvtor; 26 | 27 | cpu_arm_cortexM7(const sc_core::sc_module_name& name, sc_core::sc_object* o) 28 | : cpu_arm_cortexM7(name, *(dynamic_cast(o))) 29 | { 30 | } 31 | cpu_arm_cortexM7(sc_core::sc_module_name name, QemuInstance& inst) 32 | : QemuCpuArm(name, inst, "cortex-m7-arm") 33 | , m_nvic("nvic", inst) 34 | , p_start_powered_off("start_powered_off", false, 35 | "Start and reset the CPU " 36 | "in powered-off state") 37 | , p_init_nsvtor("init_nsvtor", 0ull, "Reset vector base address") 38 | { 39 | } 40 | 41 | void before_end_of_elaboration() override 42 | { 43 | QemuCpuArm::before_end_of_elaboration(); 44 | 45 | qemu::CpuArm cpu(m_dev); 46 | 47 | cpu.add_nvic_link(); 48 | cpu.set_prop_bool("start-powered-off", p_start_powered_off); 49 | cpu.set_prop_int("init-nsvtor", p_init_nsvtor); 50 | 51 | /* ensure the nvic is also created */ 52 | m_nvic.before_end_of_elaboration(); 53 | 54 | /* setup cpu&nvic links so that we can realize both objects */ 55 | qemu::Device nvic = m_nvic.get_qemu_dev(); 56 | cpu.set_prop_link("nvic", nvic); 57 | nvic.set_prop_link("cpu", cpu); 58 | } 59 | }; 60 | extern "C" void module_register(); 61 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_m7/src/cortex-m7.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexM7, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_r5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexR5) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_r5/include/cortex-r5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class cpu_arm_cortexR5 : public QemuCpuArm 25 | { 26 | public: 27 | cci::cci_param p_start_powered_off; 28 | 29 | cpu_arm_cortexR5(const sc_core::sc_module_name& name, sc_core::sc_object* o) 30 | : cpu_arm_cortexR5(name, *(dynamic_cast(o))) 31 | { 32 | } 33 | cpu_arm_cortexR5(sc_core::sc_module_name name, QemuInstance& inst) 34 | : QemuCpuArm(name, inst, "cortex-r5-arm") 35 | , p_start_powered_off("start_powered_off", false, 36 | "Start and reset the CPU " 37 | "in powered-off state") 38 | { 39 | } 40 | 41 | void before_end_of_elaboration() override 42 | { 43 | QemuCpuArm::before_end_of_elaboration(); 44 | 45 | qemu::CpuArm cpu(m_dev); 46 | 47 | cpu.set_prop_bool("start-powered-off", p_start_powered_off); 48 | cpu.set_prop_bool("reset-hivecs", true); 49 | } 50 | }; 51 | 52 | extern "C" void module_register(); 53 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_r5/src/cortex-r5.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexR5, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_r52/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_cortexR52) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_cortex_r52/src/cortex-r52.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_cortexR52, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_neoverse_n1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_neoverseN1) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_neoverse_n1/src/neoverse-n1.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_neoverseN1, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_neoverse_n2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_arm_neoverseN2) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_arm/cpu_arm_neoverse_n2/src/neoverse-n2.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_arm_neoverseN2, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/cpu_hexagon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_cpu_hexagon) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_hexagon/src/hexagon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_cpu_hexagon, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cpu_riscv64) 2 | add_subdirectory(cpu_sifive_x280) -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/cpu_riscv64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_riscv64) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/cpu_riscv64/src/riscv64.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(cpu_riscv64, sc_core::sc_object*, uint64_t); } -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/cpu_sifive_x280/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(cpu_sifive_X280) 2 | -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/cpu_sifive_x280/include/sifive-x280-rtl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | class cpu_sifive_X280 : public QemuCpu 23 | { 24 | protected: 25 | uint64_t m_hartid; 26 | gs::async_event m_irq_ev; 27 | 28 | void mip_update_cb(uint32_t value) 29 | { 30 | if (value) { 31 | m_irq_ev.notify(); 32 | } 33 | } 34 | 35 | public: 36 | cpu_sifive_X280(const sc_core::sc_module_name& name, sc_core::sc_object* o, /*const char* model*/std::string model, uint64_t hartid) 37 | : cpu_sifive_X280(name, *(dynamic_cast(o)), model, hartid) 38 | { 39 | } 40 | cpu_sifive_X280(const sc_core::sc_module_name& name, QemuInstance& inst, /*const char* model*/std::string model, uint64_t hartid) 41 | : QemuCpu(name, inst, /*std::string(model)*/ model + "-riscv") 42 | , m_hartid(hartid) 43 | /* 44 | * We have no choice but to attach-suspend here. This is fixable but 45 | * non-trivial. It means that the SystemC kernel will never starve... 46 | */ 47 | , m_irq_ev(true) 48 | { 49 | m_external_ev |= m_irq_ev; 50 | } 51 | 52 | void before_end_of_elaboration() 53 | { 54 | QemuCpu::before_end_of_elaboration(); 55 | 56 | qemu::CpuRiscv64SiFiveX280 cpu(get_qemu_dev()); 57 | cpu.set_prop_int("hartid", m_hartid); 58 | 59 | cpu.set_mip_update_callback(std::bind(&cpu_sifive_X280::mip_update_cb, this, std::placeholders::_1)); 60 | } 61 | 62 | // properties to be set from main.cc 63 | }; 64 | 65 | extern "C" void module_register(); 66 | -------------------------------------------------------------------------------- /qemu-components/cpu_riscv/cpu_sifive_x280/src/sifive-x280-rtl.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | void module_register() 14 | { 15 | GSC_MODULE_REGISTER_C(cpu_sifive_X280, sc_core::sc_object*, /*char* */ std::string, uint64_t); 16 | } -------------------------------------------------------------------------------- /qemu-components/display/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(display) 2 | 3 | target_include_directories( 4 | display PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/global_peripheral_initiator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(global_peripheral_initiator) 2 | -------------------------------------------------------------------------------- /qemu-components/global_peripheral_initiator/include/global_peripheral_initiator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_GOLBAL_PERIPHERAL_INITIATOR_H 10 | #define _LIBQBOX_COMPONENTS_GOLBAL_PERIPHERAL_INITIATOR_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | class global_peripheral_initiator : public QemuInitiatorIface, public sc_core::sc_module 18 | { 19 | public: 20 | // QemuInitiatorIface functions 21 | using TlmPayload = tlm::tlm_generic_payload; 22 | virtual void initiator_customize_tlm_payload(TlmPayload& payload) override {} 23 | virtual void initiator_tidy_tlm_payload(TlmPayload& payload) override {} 24 | virtual sc_core::sc_time initiator_get_local_time() override { return sc_core::sc_time_stamp(); } 25 | virtual void initiator_set_local_time(const sc_core::sc_time&) override {} 26 | 27 | QemuInitiatorSocket<> m_initiator; 28 | global_peripheral_initiator(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 29 | : global_peripheral_initiator(name, *(dynamic_cast(o)), *(dynamic_cast(t))) 30 | { 31 | } 32 | global_peripheral_initiator(const sc_core::sc_module_name& nm, QemuInstance& inst, QemuDevice& owner) 33 | : m_initiator("global_initiator", *this, inst), m_owner(owner) 34 | { 35 | } 36 | 37 | virtual void before_end_of_elaboration() override 38 | { 39 | qemu::Device dev = m_owner.get_qemu_dev(); 40 | m_initiator.init_global(dev); 41 | } 42 | 43 | virtual void initiator_async_run(qemu::Cpu::AsyncJobFn job) override {} 44 | 45 | private: 46 | QemuDevice& m_owner; 47 | }; 48 | 49 | extern "C" void module_register(); 50 | #endif //_LIBQBOX_COMPONENTS_GOLBAL_PERIPHERAL_INITIATOR_H 51 | -------------------------------------------------------------------------------- /qemu-components/global_peripheral_initiator/src/global_peripheral_initiator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(global_peripheral_initiator, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(arm_gicv2) 2 | add_subdirectory(arm_gicv3) 3 | add_subdirectory(armv7m_nvic) 4 | add_subdirectory(hexagon_l2vic) 5 | add_subdirectory(plic_sifive) 6 | add_subdirectory(riscv_aclint_swi) 7 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/arm_gicv2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(arm_gicv2) 2 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/arm_gicv2/src/arm-gicv2.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(arm_gicv2, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/arm_gicv3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(arm_gicv3) 2 | 3 | target_include_directories( 4 | arm_gicv3 PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/arm_gicv3/src/arm_gicv3.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(arm_gicv3, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/armv7m_nvic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(nvic_armv7m) 2 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/armv7m_nvic/src/armv7m-nvic.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(nvic_armv7m, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/hexagon_l2vic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(hexagon_l2vic) 2 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/hexagon_l2vic/src/hexagon-l2vic.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(hexagon_l2vic, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/plic_sifive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(plic_sifive) 2 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/plic_sifive/src/plic-sifive.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(plic_sifive, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/riscv_aclint_swi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(riscv_aclint_swi) 2 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/riscv_aclint_swi/include/riscv-aclint-swi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2022 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | class riscv_aclint_swi : public QemuDevice 22 | { 23 | public: 24 | cci::cci_param p_num_harts; 25 | 26 | QemuTargetSocket<> socket; 27 | 28 | riscv_aclint_swi(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 29 | : riscv_aclint_swi(name, *(dynamic_cast(o))) 30 | { 31 | } 32 | riscv_aclint_swi(sc_core::sc_module_name nm, QemuInstance& inst) 33 | : QemuDevice(nm, inst, "riscv.aclint.swi") 34 | , p_num_harts("num_harts", 0, "Number of HARTS this CLINT is connected to") 35 | , socket("mem", inst) 36 | { 37 | } 38 | 39 | void before_end_of_elaboration() override 40 | { 41 | QemuDevice::before_end_of_elaboration(); 42 | 43 | m_dev.set_prop_int("num-harts", p_num_harts); 44 | } 45 | 46 | void end_of_elaboration() override 47 | { 48 | QemuDevice::set_sysbus_as_parent_bus(); 49 | QemuDevice::end_of_elaboration(); 50 | 51 | qemu::SysBusDevice sbd(get_qemu_dev()); 52 | socket.init(qemu::SysBusDevice(m_dev), 0); 53 | } 54 | }; 55 | 56 | extern "C" void module_register(); 57 | -------------------------------------------------------------------------------- /qemu-components/irq-ctrl/riscv_aclint_swi/src/riscv-aclint-swi.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(riscv_aclint_swi, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/nvme/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(nvme) 2 | 3 | target_include_directories( 4 | nvme PUBLIC 5 | $ 6 | ) -------------------------------------------------------------------------------- /qemu-components/nvme/src/nvme.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "nvme.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(nvme_disk, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/opencores_eth/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(opencores_eth) 2 | -------------------------------------------------------------------------------- /qemu-components/opencores_eth/src/opencores_eth.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(opencores_eth, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(qemu_gpex) 2 | add_subdirectory(qemu_xhci) 3 | add_subdirectory(rtl8139_pci) 4 | add_subdirectory(virtio_gpu_gl_pci) 5 | add_subdirectory(virtio_gpu_cl_pci) 6 | add_subdirectory(virtio_gpu_qnn_pci) 7 | add_subdirectory(virtio_gpu_pci) 8 | add_subdirectory(virtio_sound_pci) 9 | add_subdirectory(vhost_user_vsock_pci) 10 | add_subdirectory(ivshmem_plain) 11 | -------------------------------------------------------------------------------- /qemu-components/pci/ivshmem_plain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(ivshmem_plain) 2 | 3 | target_include_directories( 4 | ivshmem_plain PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/pci/ivshmem_plain/src/ivshmem_plain.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(ivshmem_plain, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/pci/qemu_gpex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_gpex) 2 | -------------------------------------------------------------------------------- /qemu-components/pci/qemu_gpex/src/qemu_gpex.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "qemu_gpex.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_gpex, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/pci/qemu_xhci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_xhci) 2 | 3 | target_include_directories( 4 | qemu_xhci PUBLIC 5 | $ 6 | $ 7 | ) 8 | -------------------------------------------------------------------------------- /qemu-components/pci/qemu_xhci/src/qemu_xhci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_xhci, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/pci/rtl8139_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(rtl8139_pci) 2 | 3 | target_include_directories( 4 | rtl8139_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/pci/rtl8139_pci/include/rtl8139_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_RTL8139_PCI_H 9 | #define _LIBQBOX_COMPONENTS_RTL8139_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | 20 | class rtl8139_pci : public qemu_gpex::Device 21 | { 22 | cci::cci_param p_mac; 23 | std::string m_netdev_id; 24 | cci::cci_param p_netdev_str; 25 | 26 | public: 27 | rtl8139_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 28 | : rtl8139_pci(name, *(dynamic_cast(o)), (dynamic_cast(t))) 29 | { 30 | } 31 | rtl8139_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex) 32 | : qemu_gpex::Device(name, inst, "rtl8139") 33 | , p_mac("mac", "", "MAC address of NIC") 34 | , m_netdev_id(std::string(sc_core::sc_module::name()) + "-id") 35 | , p_netdev_str("netdev_str", "type=user", "netdev string for QEMU (do not specify ID)") 36 | { 37 | std::stringstream opts; 38 | opts << p_netdev_str.get_value(); 39 | opts << ",id=" << m_netdev_id; 40 | 41 | m_inst.add_arg("-netdev"); 42 | m_inst.add_arg(opts.str().c_str()); 43 | 44 | gpex->add_device(*this); 45 | } 46 | 47 | void before_end_of_elaboration() override 48 | { 49 | qemu_gpex::Device::before_end_of_elaboration(); 50 | // if p_mac is empty, a MAC address will be generated for us 51 | if (!p_mac.get_value().empty()) m_dev.set_prop_str("mac", p_mac.get_value().c_str()); 52 | m_dev.set_prop_str("netdev", m_netdev_id.c_str()); 53 | 54 | m_dev.set_prop_str("romfile", ""); 55 | } 56 | }; 57 | 58 | extern "C" void module_register(); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /qemu-components/pci/rtl8139_pci/src/rtl8139_pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(rtl8139_pci, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/pci/vhost_user_vsock_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(vhost_user_vsock_pci) 2 | 3 | target_include_directories( 4 | vhost_user_vsock_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/pci/vhost_user_vsock_pci/src/vhost_user_vsock_pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(vhost_user_vsock_pci, sc_core::sc_object*, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_GPU_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_GPU_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | class QemuVirtioGpu : public qemu_gpex::Device 18 | { 19 | public: 20 | cci::cci_param p_outputs; 21 | 22 | void before_end_of_elaboration() override 23 | { 24 | qemu_gpex::Device::before_end_of_elaboration(); 25 | get_qemu_dev().set_prop_uint("max_outputs", p_outputs); 26 | } 27 | 28 | void gpex_realize(qemu::Bus& bus) override { qemu_gpex::Device::gpex_realize(bus); } 29 | 30 | uint8_t outputs() { return p_outputs.get_value(); } 31 | 32 | protected: 33 | QemuVirtioGpu(const sc_core::sc_module_name& name, QemuInstance& inst, const char* gpu_type, qemu_gpex* gpex) 34 | : QemuVirtioGpu(name, inst, gpu_type, gpex, (const char*)NULL) 35 | { 36 | } 37 | 38 | QemuVirtioGpu(const sc_core::sc_module_name& name, QemuInstance& inst, const char* gpu_type, qemu_gpex* gpex, 39 | const char* device_id) 40 | : qemu_gpex::Device(name, inst, gpu_type, device_id), p_outputs("outputs", 1, "Number of outputs for this gpu") 41 | { 42 | gpex->add_device(*this); 43 | } 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_cl_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_gpu_cl_pci) 2 | 3 | target_include_directories( 4 | virtio_gpu_cl_pci PUBLIC 5 | $ 6 | ) -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_cl_pci/include/virtio_gpu_cl_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_GPU_CL_PCI_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_GPU_CL_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | class virtio_gpu_cl_pci : public QemuVirtioGpu 16 | { 17 | static constexpr const char* _device_type = "virtio-gpu-cl-pci"; 18 | 19 | public: 20 | cci::cci_param p_hostmem_mb; 21 | 22 | virtio_gpu_cl_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t); 23 | virtio_gpu_cl_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex); 24 | 25 | void before_end_of_elaboration() override; 26 | }; 27 | 28 | extern "C" void module_register(); 29 | 30 | #endif // _LIBQBOX_COMPONENTS_VIRTIO_GPU_CL_PCI_H 31 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_gl_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_gpu_gl_pci) 2 | 3 | target_include_directories( 4 | virtio_gpu_gl_pci PUBLIC 5 | $ 6 | ) -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_gl_pci/include/virtio_gpu_gl_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_GPU_GL_PCI_H 10 | #define _LIBQBOX_COMPONENTS_VIRTIO_GPU_GL_PCI_H 11 | 12 | #include 13 | 14 | #include 15 | 16 | class virtio_gpu_gl_pci : public QemuVirtioGpu 17 | { 18 | private: 19 | static constexpr const char* _device_type = "virtio-gpu-gl-pci"; 20 | 21 | public: 22 | cci::cci_param p_hostmem_mb; 23 | 24 | virtio_gpu_gl_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t); 25 | virtio_gpu_gl_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex); 26 | 27 | void before_end_of_elaboration() override; 28 | }; 29 | 30 | extern "C" void module_register(); 31 | #endif // _LIBQBOX_COMPONENTS_VIRTIO_GPU_GL_PCI_H 32 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_gpu_pci) 2 | 3 | target_include_directories( 4 | virtio_gpu_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_pci/include/virtio_gpu_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_GPU_PCI_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_GPU_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | class virtio_gpu_pci : public QemuVirtioGpu 16 | { 17 | private: 18 | static constexpr const char* _device_type = "virtio-gpu-pci"; 19 | 20 | public: 21 | virtio_gpu_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 22 | : virtio_gpu_pci(name, *(dynamic_cast(o)), (dynamic_cast(t))) 23 | { 24 | } 25 | virtio_gpu_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex) 26 | : QemuVirtioGpu(name, inst, _device_type, gpex, std::string(name).append(".").append(_device_type).c_str()) 27 | { 28 | } 29 | }; 30 | 31 | extern "C" void module_register(); 32 | #endif 33 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_pci/src/virtio_gpu_pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_gpu_pci, sc_core::sc_object*, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_qnn_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_gpu_qnn_pci) 2 | 3 | target_include_directories( 4 | virtio_gpu_qnn_pci PUBLIC 5 | $ 6 | ) -------------------------------------------------------------------------------- /qemu-components/pci/virtio_gpu_qnn_pci/include/virtio_gpu_qnn_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_GPU_QNN_PCI_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_GPU_QNN_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | class virtio_gpu_qnn_pci : public QemuVirtioGpu 16 | { 17 | static constexpr const char* _device_type = "virtio-gpu-qnn-pci"; 18 | 19 | public: 20 | cci::cci_param p_hostmem_mb; 21 | 22 | virtio_gpu_qnn_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t); 23 | virtio_gpu_qnn_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex); 24 | 25 | void before_end_of_elaboration() override; 26 | }; 27 | 28 | extern "C" void module_register(); 29 | 30 | #endif // _LIBQBOX_COMPONENTS_VIRTIO_GPU_QNN_PCI_H 31 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_sound_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_sound_pci) 2 | 3 | target_include_directories( 4 | virtio_sound_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_sound_pci/include/virtio_sound_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | class virtio_sound_pci : public qemu_gpex::Device 20 | { 21 | std::string driver; 22 | std::string audiodev_id; 23 | 24 | public: 25 | virtio_sound_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 26 | : virtio_sound_pci(name, *(dynamic_cast(o)), (dynamic_cast(t))) 27 | { 28 | } 29 | 30 | virtio_sound_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex, 31 | const std::string& driver = "alsa") 32 | : qemu_gpex::Device(name, inst, "virtio-sound-pci") 33 | , driver(driver) 34 | , audiodev_id(std::string(sc_core::sc_module::name()) + "-id") 35 | { 36 | std::stringstream opts; 37 | opts << driver << ",id=" << audiodev_id; 38 | 39 | m_inst.add_arg("-audiodev"); 40 | m_inst.add_arg(opts.str().c_str()); 41 | 42 | gpex->add_device(*this); 43 | } 44 | 45 | void before_end_of_elaboration() override 46 | { 47 | qemu_gpex::Device::before_end_of_elaboration(); 48 | 49 | m_dev.set_prop_str("audiodev", audiodev_id.c_str()); 50 | } 51 | }; 52 | 53 | extern "C" void module_register(); 54 | -------------------------------------------------------------------------------- /qemu-components/pci/virtio_sound_pci/src/virtio_sound_pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_sound_pci, sc_core::sc_object*, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/qmp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qmp) 2 | -------------------------------------------------------------------------------- /qemu-components/qmp/src/qmp.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qmp, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/reset_gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(reset_gpio) 2 | -------------------------------------------------------------------------------- /qemu-components/reset_gpio/src/reset_gpio.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(reset_gpio, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/sifive_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(sifive_test) 2 | -------------------------------------------------------------------------------- /qemu-components/sifive_test/src/sifive_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | 12 | void module_register() { GSC_MODULE_REGISTER_C(sifive_test, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(qemu_hexagon_qtimer) 2 | add_subdirectory(riscv_aclint_mtimer) -------------------------------------------------------------------------------- /qemu-components/timer/qemu_hexagon_qtimer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_hexagon_qtimer) 2 | -------------------------------------------------------------------------------- /qemu-components/timer/qemu_hexagon_qtimer/src/qemu_hexagon_qtimer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_hexagon_qtimer, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/timer/riscv_aclint_mtimer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(riscv_aclint_mtimer) 2 | -------------------------------------------------------------------------------- /qemu-components/timer/riscv_aclint_mtimer/src/riscv-aclint-mtimer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(riscv_aclint_mtimer, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/uart/16550/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(uart_16550) 2 | -------------------------------------------------------------------------------- /qemu-components/uart/16550/src/16550.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include <16550.h> 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(uart_16550, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(16550) 2 | add_subdirectory(qemu_pl011) 3 | add_subdirectory(sifive_uart) 4 | -------------------------------------------------------------------------------- /qemu-components/uart/qemu_pl011/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_pl011) 2 | -------------------------------------------------------------------------------- /qemu-components/uart/qemu_pl011/include/qemu_pl011.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_UART_PL011_H 10 | #define _LIBQBOX_COMPONENTS_UART_PL011_H 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class qemu_pl011 : public QemuDevice 24 | { 25 | protected: 26 | qemu::Chardev m_chardev; 27 | 28 | /* FIXME: temp, should be in the backend */ 29 | gs::async_event m_ext_ev; 30 | 31 | public: 32 | QemuTargetSocket<> socket; 33 | QemuInitiatorSignalSocket irq_out; 34 | 35 | qemu_pl011(const sc_core::sc_module_name& name, sc_core::sc_object* o) 36 | : qemu_pl011(name, *(dynamic_cast(o))) 37 | { 38 | } 39 | qemu_pl011(const sc_core::sc_module_name& n, QemuInstance& inst) 40 | : QemuDevice(n, inst, "pl011"), m_ext_ev(true), socket("mem", inst), irq_out("irq_out") 41 | { 42 | } 43 | 44 | void before_end_of_elaboration() override 45 | { 46 | QemuDevice::before_end_of_elaboration(); 47 | 48 | /* FIXME: hardcoded for now */ 49 | m_chardev = m_inst.get().chardev_new("uart", "stdio"); 50 | m_dev.set_prop_chardev("chardev", m_chardev); 51 | } 52 | 53 | void end_of_elaboration() override 54 | { 55 | QemuDevice::set_sysbus_as_parent_bus(); 56 | QemuDevice::end_of_elaboration(); 57 | 58 | qemu::SysBusDevice sbd(m_dev); 59 | 60 | socket.init(sbd, 0); 61 | irq_out.init_sbd(sbd, 0); 62 | } 63 | }; 64 | 65 | extern "C" void module_register(); 66 | 67 | #endif -------------------------------------------------------------------------------- /qemu-components/uart/qemu_pl011/src/qemu_pl011.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "qemu_pl011.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_pl011, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/uart/sifive_uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(sifive_uart) 2 | -------------------------------------------------------------------------------- /qemu-components/uart/sifive_uart/include/sifive-uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBQBOX_COMPONENTS_UART_SIFIVE_UART_H 10 | #define _LIBQBOX_COMPONENTS_UART_SIFIVE_UART_H 11 | 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | class sifive_uart : public QemuDevice 23 | { 24 | protected: 25 | qemu::Chardev m_chardev; 26 | 27 | /* FIXME: temp, should be in the backend */ 28 | gs::async_event m_ext_ev; 29 | 30 | public: 31 | QemuTargetSocket<> socket; 32 | QemuInitiatorSignalSocket irq_out; 33 | 34 | sifive_uart(const sc_core::sc_module_name& name, sc_core::sc_object* o) 35 | : sifive_uart(name, *(dynamic_cast(o))) 36 | { 37 | } 38 | sifive_uart(const sc_core::sc_module_name& n, QemuInstance& inst) 39 | : QemuDevice(n, inst, "riscv.sifive.uart"), m_ext_ev(true), socket("mem", inst), irq_out("irq_out") 40 | { 41 | } 42 | 43 | void before_end_of_elaboration() override 44 | { 45 | QemuDevice::before_end_of_elaboration(); 46 | 47 | /* FIXME: hardcoded for now */ 48 | m_chardev = m_inst.get().chardev_new("uart", "stdio"); 49 | m_dev.set_prop_chardev("chardev", m_chardev); 50 | } 51 | 52 | void end_of_elaboration() override 53 | { 54 | QemuDevice::set_sysbus_as_parent_bus(); 55 | QemuDevice::end_of_elaboration(); 56 | 57 | qemu::SysBusDevice sbd(m_dev); 58 | 59 | socket.init(sbd, 0); 60 | irq_out.init_sbd(sbd, 0); 61 | } 62 | }; 63 | 64 | extern "C" void module_register(); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /qemu-components/uart/sifive_uart/src/sifive-uart.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "sifive-uart.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(sifive_uart, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/usb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(qemu_kbd) 2 | add_subdirectory(qemu_tablet) 3 | if(QEMU_ENABLE_USB_REDIRECT) 4 | add_subdirectory(usb_host) 5 | endif() 6 | -------------------------------------------------------------------------------- /qemu-components/usb/qemu_kbd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_kbd) 2 | 3 | target_include_directories( 4 | qemu_kbd PUBLIC 5 | $ 6 | $ 7 | ) 8 | -------------------------------------------------------------------------------- /qemu-components/usb/qemu_kbd/include/qemu_kbd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_USB_KBD_H 9 | #define _LIBQBOX_COMPONENTS_USB_KBD_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | class qemu_kbd : public qemu_xhci::Device 16 | { 17 | public: 18 | qemu_kbd(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 19 | : qemu_kbd(name, *(dynamic_cast(o)), (dynamic_cast(t))) 20 | { 21 | } 22 | qemu_kbd(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_xhci* xhci): qemu_xhci::Device(n, inst, "usb-kbd") 23 | { 24 | xhci->add_device(*this); 25 | } 26 | }; 27 | 28 | extern "C" void module_register(); 29 | #endif 30 | -------------------------------------------------------------------------------- /qemu-components/usb/qemu_kbd/src/qemu_kbd.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_kbd, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/usb/qemu_tablet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(qemu_tablet) 2 | 3 | target_include_directories( 4 | qemu_tablet PUBLIC 5 | $ 6 | $ 7 | ) 8 | -------------------------------------------------------------------------------- /qemu-components/usb/qemu_tablet/include/qemu_tablet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_USB_TABLET_H 9 | #define _LIBQBOX_COMPONENTS_USB_TABLET_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | /// @brief Tablet touch device (mouse) 16 | class qemu_tablet : public qemu_xhci::Device 17 | { 18 | public: 19 | qemu_tablet(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 20 | : qemu_tablet(name, *(dynamic_cast(o)), (dynamic_cast(t))) 21 | { 22 | } 23 | qemu_tablet(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_xhci* xhci) 24 | : qemu_xhci::Device(n, inst, "usb-tablet") 25 | { 26 | xhci->add_device(*this); 27 | } 28 | }; 29 | 30 | extern "C" void module_register(); 31 | #endif 32 | -------------------------------------------------------------------------------- /qemu-components/usb/qemu_tablet/src/qemu_tablet.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(qemu_tablet, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/usb/usb_host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(usb_host) 2 | 3 | target_include_directories( 4 | usb_host PUBLIC 5 | $ 6 | $ 7 | ) 8 | -------------------------------------------------------------------------------- /qemu-components/usb/usb_host/src/usb_host.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(usb_host, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/virtio_keyboard_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_keyboard_pci) 2 | 3 | target_include_directories( 4 | virtio_keyboard_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/virtio_keyboard_pci/include/virtio-keyboard-pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_KEYBOARD_PCI_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_KEYBOARD_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | /// @brief This class wraps the qemu's Virt-IO Keyboard PCI. 16 | class virtio_keyboard_pci : public qemu_gpex::Device 17 | { 18 | public: 19 | virtio_keyboard_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 20 | : virtio_keyboard_pci(name, *(dynamic_cast(o)), (dynamic_cast(t))) 21 | { 22 | } 23 | 24 | virtio_keyboard_pci(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_gpex* gpex) 25 | : qemu_gpex::Device(n, inst, "virtio-keyboard-pci") 26 | { 27 | gpex->add_device(*this); 28 | } 29 | }; 30 | 31 | extern "C" void module_register(); 32 | 33 | #endif // _LIBQBOX_COMPONENTS_VIRTIO_KEYBOARD_PCI_H 34 | -------------------------------------------------------------------------------- /qemu-components/virtio_keyboard_pci/src/virtio-keyboard-pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_keyboard_pci, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_blk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_mmio_blk) 2 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_blk/include/virtio_mmio_blk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2022 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | class virtio_mmio_blk : public QemuVirtioMMIO 23 | { 24 | private: 25 | std::string blkdev_id; 26 | cci::cci_param blkdev_str; 27 | 28 | public: 29 | virtio_mmio_blk(const sc_core::sc_module_name& name, sc_core::sc_object* o) 30 | : virtio_mmio_blk(name, *(dynamic_cast(o))) 31 | { 32 | } 33 | virtio_mmio_blk(sc_core::sc_module_name nm, QemuInstance& inst) 34 | : QemuVirtioMMIO(nm, inst, "virtio-blk-device") 35 | , blkdev_id(std::string(name()) + "-id") 36 | , blkdev_str("blkdev_str", "", "blkdev string for QEMU (do not specify ID)") 37 | { 38 | std::stringstream opts; 39 | opts << blkdev_str.get_value(); 40 | opts << ",id=" << blkdev_id; 41 | 42 | m_inst.add_arg("-drive"); 43 | m_inst.add_arg(opts.str().c_str()); 44 | } 45 | 46 | void before_end_of_elaboration() override 47 | { 48 | QemuVirtioMMIO::before_end_of_elaboration(); 49 | 50 | m_dev.set_prop_parse("drive", blkdev_id.c_str()); 51 | } 52 | }; 53 | 54 | extern "C" void module_register(); 55 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_blk/src/virtio_mmio_blk.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_mmio_blk, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_gpugl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_mmio_gpugl) 2 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_gpugl/include/virtio_mmio_gpugl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | class virtio_mmio_gpugl : public QemuVirtioMMIOGpuGl 22 | { 23 | public: 24 | virtio_mmio_gpugl(const sc_core::sc_module_name& name, sc_core::sc_object* o) 25 | : virtio_mmio_gpugl(name, *(dynamic_cast(o))) 26 | { 27 | } 28 | virtio_mmio_gpugl(sc_core::sc_module_name nm, QemuInstance& inst): QemuVirtioMMIOGpuGl(nm, inst) {} 29 | }; 30 | 31 | extern "C" void module_register(); 32 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_gpugl/src/virtio_mmio_gpugl.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_mmio_gpugl, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_mmio_net) 2 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_net/include/virtio_mmio_net.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2022 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | class virtio_mmio_net : public QemuVirtioMMIO 24 | { 25 | private: 26 | std::string netdev_id; 27 | cci::cci_param netdev_str; 28 | 29 | public: 30 | virtio_mmio_net(const sc_core::sc_module_name& name, sc_core::sc_object* o) 31 | : virtio_mmio_net(name, *(dynamic_cast(o))) 32 | { 33 | } 34 | virtio_mmio_net(sc_core::sc_module_name nm, QemuInstance& inst) 35 | : QemuVirtioMMIO(nm, inst, "virtio-net-device") 36 | , netdev_id(std::string(name()) + "-id") 37 | , netdev_str("netdev_str", "user,hostfwd=tcp::2222-:22", "netdev string for QEMU (do not specify ID)") 38 | { 39 | std::stringstream opts; 40 | opts << netdev_str.get_value(); 41 | opts << ",id=" << netdev_id; 42 | 43 | m_inst.add_arg("-netdev"); 44 | m_inst.add_arg(opts.str().c_str()); 45 | } 46 | 47 | void before_end_of_elaboration() override 48 | { 49 | QemuVirtioMMIO::before_end_of_elaboration(); 50 | 51 | m_dev.set_prop_str("netdev", netdev_id.c_str()); 52 | } 53 | }; 54 | 55 | extern "C" void module_register(); 56 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_net/src/virtio_mmio_net.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_mmio_net, sc_core::sc_object*); } -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_sound/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_mmio_sound) 2 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_sound/include/virtio_mmio_sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2022 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | class virtio_mmio_sound : public QemuVirtioMMIO 24 | { 25 | std::string driver; 26 | std::string audiodev_id; 27 | 28 | public: 29 | virtio_mmio_sound(const sc_core::sc_module_name& name, sc_core::sc_object* o) 30 | : virtio_mmio_sound(name, *(dynamic_cast(o))) 31 | { 32 | } 33 | 34 | virtio_mmio_sound(sc_core::sc_module_name name, QemuInstance& inst, const std::string& driver = "alsa") 35 | : QemuVirtioMMIO(name, inst, "virtio-sound-device") 36 | , driver(driver) 37 | , audiodev_id(std::string(sc_core::sc_module::name()) + "-id") 38 | { 39 | std::stringstream opts; 40 | opts << driver << ",id=" << audiodev_id; 41 | 42 | m_inst.add_arg("-audiodev"); 43 | m_inst.add_arg(opts.str().c_str()); 44 | } 45 | 46 | void before_end_of_elaboration() override 47 | { 48 | QemuVirtioMMIO::before_end_of_elaboration(); 49 | 50 | m_dev.set_prop_str("audiodev", audiodev_id.c_str()); 51 | } 52 | }; 53 | 54 | extern "C" void module_register(); 55 | -------------------------------------------------------------------------------- /qemu-components/virtio_mmio_sound/src/virtio_mmio_sound.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_mmio_sound, sc_core::sc_object*); } 12 | -------------------------------------------------------------------------------- /qemu-components/virtio_mouse_pci/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(virtio_mouse_pci) 2 | 3 | target_include_directories( 4 | virtio_mouse_pci PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /qemu-components/virtio_mouse_pci/include/virtio-mouse-pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _LIBQBOX_COMPONENTS_VIRTIO_MOUSE_PCI_H 9 | #define _LIBQBOX_COMPONENTS_VIRTIO_MOUSE_PCI_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | /// @brief This class wraps the qemu's Virt-IO Mouse PCI. 16 | class virtio_mouse_pci : public qemu_gpex::Device 17 | { 18 | public: 19 | virtio_mouse_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t) 20 | : virtio_mouse_pci(name, *(dynamic_cast(o)), (dynamic_cast(t))) 21 | { 22 | } 23 | 24 | virtio_mouse_pci(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_gpex* gpex) 25 | : qemu_gpex::Device(n, inst, "virtio-mouse-pci") 26 | { 27 | gpex->add_device(*this); 28 | } 29 | }; 30 | 31 | extern "C" void module_register(); 32 | 33 | #endif // _LIBQBOX_COMPONENTS_VIRTIO_MOUSE_PCI_H 34 | -------------------------------------------------------------------------------- /qemu-components/virtio_mouse_pci/src/virtio-mouse-pci.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(virtio_mouse_pci, sc_core::sc_object*, sc_core::sc_object*); } -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy -------------------------------------------------------------------------------- /systemc-components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(addrtr) 2 | add_subdirectory(backends) 3 | add_subdirectory(exclusive_monitor) 4 | add_subdirectory(keep_alive) 5 | add_subdirectory(loader) 6 | add_subdirectory(macs) 7 | add_subdirectory(gs_memory) 8 | add_subdirectory(memory_dumper) 9 | add_subdirectory(pass) 10 | if((NOT WITHOUT_PYTHON_BINDER) AND (NOT GS_ONLY)) 11 | add_subdirectory(python_binder) 12 | endif() 13 | add_subdirectory(router) 14 | add_subdirectory(reg_router) 15 | add_subdirectory(timeprinter) 16 | add_subdirectory(tlm_bus_width_bridges) 17 | add_subdirectory(uart) 18 | add_subdirectory(realtimelimiter) 19 | add_subdirectory(dmi_converter) 20 | add_subdirectory(monitor) 21 | add_subdirectory(biflow_router) 22 | add_subdirectory(exiter) 23 | -------------------------------------------------------------------------------- /systemc-components/addrtr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(addrtr) 2 | -------------------------------------------------------------------------------- /systemc-components/addrtr/src/addrtr.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "addrtr.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(addrtr); } 12 | -------------------------------------------------------------------------------- /systemc-components/backends/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(char_backend_file) 2 | add_subdirectory(char_backend_socket) 3 | add_subdirectory(char_backend_stdio) 4 | add_subdirectory(legacy_char_backend_stdio) 5 | add_subdirectory(loop_back_backend) 6 | -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_file/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(char_backend_file) 2 | -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_file/src/char_backend_file.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #include 7 | 8 | #include 9 | 10 | void module_register() { GSC_MODULE_REGISTER_C(char_backend_file); } -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_socket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(char_backend_socket) 2 | -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_socket/src/char_backend_socket.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(char_backend_socket); } -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_stdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(char_backend_stdio) 2 | -------------------------------------------------------------------------------- /systemc-components/backends/char_backend_stdio/src/char_backend_stdio.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "char_backend_stdio.h" 10 | struct termios char_backend_stdio::oldtty; 11 | bool char_backend_stdio::oldtty_valid = false; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(char_backend_stdio); } -------------------------------------------------------------------------------- /systemc-components/backends/legacy_char_backend_stdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(legacy_char_backend_stdio) 2 | -------------------------------------------------------------------------------- /systemc-components/backends/legacy_char_backend_stdio/src/legacy_char_backend_stdio.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "legacy_char_backend_stdio.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(legacy_char_backend_stdio, bool); } -------------------------------------------------------------------------------- /systemc-components/backends/loop_back_backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(loop_back_backend) 2 | -------------------------------------------------------------------------------- /systemc-components/backends/loop_back_backend/include/loop_back_backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /** 8 | * @file loop_back_backend.h 9 | * @brief loop_back_backend for biflow socket 10 | */ 11 | 12 | #ifndef _GS_LOOP_BACK_BACKEND_H_ 13 | #define _GS_LOOP_BACK_BACKEND_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | class loop_back_backend : public sc_core::sc_module 24 | { 25 | SCP_LOGGER(); 26 | 27 | public: 28 | gs::biflow_socket socket; 29 | 30 | /** 31 | * loop_back_backend() - Construct the loop_back_backend 32 | * @name: this backend's name 33 | */ 34 | loop_back_backend(sc_core::sc_module_name name): sc_core::sc_module(name), socket("biflow_socket") 35 | { 36 | SCP_TRACE(()) << "constructor"; 37 | socket.register_b_transport(this, &loop_back_backend::b_transport); 38 | } 39 | 40 | void end_of_elaboration() { socket.can_receive_any(); } 41 | 42 | void b_transport(tlm::tlm_generic_payload& txn, sc_core::sc_time& t) 43 | { 44 | uint8_t* data = txn.get_data_ptr(); 45 | sc_assert(data != NULL); 46 | for (unsigned int i = 0; i < txn.get_streaming_width(); i++) { 47 | socket.enqueue(static_cast(data[i])); 48 | SCP_DEBUG(())("loop_back_backend: sending {}", static_cast(data[i])); 49 | } 50 | } 51 | 52 | ~loop_back_backend() {} 53 | }; 54 | extern "C" void module_register(); 55 | #endif 56 | -------------------------------------------------------------------------------- /systemc-components/backends/loop_back_backend/src/loop_back_backend.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(loop_back_backend); } 12 | -------------------------------------------------------------------------------- /systemc-components/biflow_router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(biflow_router) 2 | -------------------------------------------------------------------------------- /systemc-components/biflow_router/src/biflow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #include 7 | 8 | #include 9 | #include 10 | namespace gs { 11 | class biflow_router : public sc_core::sc_module 12 | { 13 | public: 14 | gs::biflow_router_socket<> router; 15 | biflow_router(sc_core::sc_module_name name): sc_core::sc_module(name), router("socket") {} 16 | }; 17 | }; // namespace gs 18 | 19 | typedef gs::biflow_router biflow_router; 20 | extern "C" void module_register(); 21 | void module_register() { GSC_MODULE_REGISTER_C(biflow_router); } 22 | -------------------------------------------------------------------------------- /systemc-components/common/include/backends/legacy-char-backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #pragma once 13 | 14 | class LegacyCharBackend : public sc_core::sc_module 15 | { 16 | protected: 17 | void* m_opaque; 18 | void (*m_receive)(void* opaque, const uint8_t* buf, int size); 19 | int (*m_can_receive)(void* opaque); 20 | 21 | gs::biflow_socket socket; 22 | 23 | public: 24 | SCP_LOGGER(); 25 | static void recieve(void* opaque, const uint8_t* buf, int size) 26 | { 27 | LegacyCharBackend* t = (LegacyCharBackend*)opaque; 28 | for (int i = 0; i < size; i++) { 29 | t->socket.enqueue(buf[i]); 30 | } 31 | } 32 | 33 | void b_transport(tlm::tlm_generic_payload& txn, sc_core::sc_time& t) 34 | { 35 | uint8_t* data = txn.get_data_ptr(); 36 | for (int i = 0; i < txn.get_streaming_width(); i++) { 37 | write(data[i]); 38 | } 39 | } 40 | LegacyCharBackend(): socket("biflow_socket") 41 | { 42 | SCP_DEBUG("LegacyCharBackend") << "LegacyCharBackend constructor"; 43 | m_opaque = this; 44 | m_receive = recieve; 45 | m_can_receive = can_receive; 46 | socket.register_b_transport(this, &LegacyCharBackend::b_transport); 47 | } 48 | 49 | void start_of_simulation() { socket.can_receive_any(); } 50 | 51 | virtual void write(unsigned char c) = 0; 52 | 53 | static int can_receive(void* opaque) { return 1; } 54 | 55 | void register_receive(void* opaque, void (*receive)(void* opaque, const uint8_t* buf, int size), 56 | int (*can_receive)(void* opaque)) 57 | { 58 | SCP_FATAL(())("Deprecated!!!!"); 59 | m_opaque = opaque; 60 | m_receive = receive; 61 | m_can_receive = can_receive; 62 | } 63 | }; 64 | -------------------------------------------------------------------------------- /systemc-components/common/include/backends/net-backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | class NetworkBackend 13 | { 14 | protected: 15 | void* m_opaque; 16 | void (*m_receive)(void* opaque, Payload& frame); 17 | int (*m_can_receive)(void* opaque); 18 | 19 | public: 20 | NetworkBackend() 21 | { 22 | m_opaque = NULL; 23 | m_receive = NULL; 24 | m_can_receive = NULL; 25 | } 26 | 27 | virtual void send(Payload& frame) = 0; 28 | 29 | void register_receive(void* opaque, void (*receive)(void* opaque, Payload& frame), int (*can_receive)(void* opaque)) 30 | { 31 | m_opaque = opaque; 32 | m_receive = receive; 33 | m_can_receive = can_receive; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /systemc-components/common/include/backends/tap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | class NetworkBackendTap : public NetworkBackend, public sc_core::sc_module 18 | { 19 | private: 20 | gs::async_event m_event; 21 | std::queue m_queue; 22 | std::mutex m_mutex; 23 | int m_fd; 24 | 25 | void open(std::string& tun); 26 | void* rcv_thread(); 27 | void rcv(); 28 | void close(); 29 | 30 | public: 31 | NetworkBackendTap(sc_core::sc_module_name name, std::string tun); 32 | 33 | virtual ~NetworkBackendTap(); 34 | 35 | void send(Payload& frame); 36 | }; 37 | -------------------------------------------------------------------------------- /systemc-components/common/include/libgssync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "async_event.h" 9 | #include "qk_factory.h" 10 | #include "qkmultithread.h" 11 | #include "qkmulti-quantum.h" 12 | #include "qkmulti-rolling.h" 13 | #include "qkmulti-adaptive.h" 14 | #include "qkmulti-unconstrained.h" 15 | #include "qkmulti-freerunning.h" 16 | #include "inlinesync.h" 17 | #include "runonsysc.h" 18 | -------------------------------------------------------------------------------- /systemc-components/common/include/libgsutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | //#include "greensocs/gsutils/report.h" 9 | #include 10 | #include 11 | #include 12 | -------------------------------------------------------------------------------- /systemc-components/common/include/macs/mac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _MAC_H_ 9 | #define _MAC_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | class MACAddress 18 | { 19 | private: 20 | uint8_t m_bytes[6]; 21 | 22 | public: 23 | MACAddress() { memset(m_bytes, 0, sizeof(m_bytes)); } 24 | 25 | public: 26 | uint32_t lo() const; 27 | uint16_t hi() const; 28 | 29 | void set_lo(uint32_t value); 30 | void set_hi(uint16_t value); 31 | 32 | public: 33 | void zero(); 34 | 35 | inline void randomize() 36 | { 37 | for (int i = 0; i < 6; ++i) { 38 | m_bytes[i] = i; 39 | } 40 | m_bytes[0] &= ~((uint8_t)1); // clear multicast bit 41 | } 42 | 43 | bool set_from_str(const std::string& s); 44 | 45 | public: 46 | bool operator==(const MACAddress& other) const { return memcmp(m_bytes, other.m_bytes, 6) == 0; } 47 | 48 | bool operator!=(const MACAddress& other) const { return !this->operator==(other); } 49 | 50 | bool operator<(const MACAddress& other) const { return memcmp(m_bytes, other.m_bytes, 6) < 0; } 51 | 52 | bool operator>(const MACAddress& other) const { return memcmp(m_bytes, other.m_bytes, 6) > 0; } 53 | 54 | bool operator<=(const MACAddress& other) const { return memcmp(m_bytes, other.m_bytes, 6) <= 0; } 55 | 56 | bool operator>=(const MACAddress& other) const { return memcmp(m_bytes, other.m_bytes, 6) >= 0; } 57 | 58 | uint8_t operator[](int i) const { return (i < 6) ? m_bytes[i] : 0; } 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /systemc-components/common/include/macs/payload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | class Payload 15 | { 16 | private: 17 | uint8_t* m_buffer; 18 | size_t m_size; 19 | size_t m_capacity; 20 | 21 | public: 22 | Payload(size_t capacity): m_size(0), m_capacity(capacity) { m_buffer = new uint8_t[capacity]; } 23 | ~Payload() 24 | { 25 | if (m_buffer) { 26 | delete[] m_buffer; 27 | } 28 | m_buffer = nullptr; 29 | } 30 | 31 | size_t capacity() const { return m_capacity; } 32 | size_t size() const { return m_size; } 33 | uint8_t* data() const { return m_buffer; } 34 | 35 | void resize(size_t size) 36 | { 37 | assert(size <= m_capacity); 38 | m_size = size; 39 | } 40 | 41 | private: 42 | Payload(const Payload&); 43 | Payload& operator=(const Payload&); 44 | }; 45 | -------------------------------------------------------------------------------- /systemc-components/common/include/macs/phy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "backends/net-backend.h" 16 | #include 17 | 18 | //#include "link.h" 19 | 20 | class phy : public sc_core::sc_module 21 | { 22 | private: 23 | protected: 24 | uint16_t m_ctl; 25 | uint16_t m_status; 26 | uint16_t m_adv; 27 | 28 | public: 29 | 30 | const uint32_t m_id; 31 | const uint8_t m_addr; 32 | 33 | phy(sc_core::sc_module_name name, uint32_t id, uint8_t addr); 34 | virtual ~phy(); 35 | 36 | virtual void mdio_reg_read(uint8_t reg, uint16_t& data); 37 | virtual void mdio_reg_write(uint8_t reg, uint16_t data); 38 | }; 39 | -------------------------------------------------------------------------------- /systemc-components/common/include/onmethod.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef ONMETHODHELPER_H 9 | #define ONMETHODHELPER_H 10 | 11 | #include 12 | 13 | class onMethodHelper : public sc_core::sc_module 14 | { 15 | std::function entry; 16 | sc_core::sc_event start; 17 | sc_core::sc_event done; 18 | void start_entry() 19 | { 20 | entry(); 21 | done.notify(); 22 | } 23 | 24 | public: 25 | onMethodHelper(): sc_core::sc_module(sc_core::sc_module_name("onMethodHelper")) 26 | { 27 | SC_METHOD(start_entry); 28 | sensitive << start; 29 | dont_initialize(); 30 | } 31 | void run(std::function fn) 32 | { 33 | entry = fn; 34 | auto kind = sc_core::sc_get_current_process_handle().proc_kind(); 35 | if (kind == sc_core::SC_THREAD_PROC_) { 36 | start.notify(); 37 | wait(done); 38 | } else { 39 | entry(); 40 | } 41 | } 42 | }; 43 | 44 | #endif // ONMETHODHELPER_H 45 | -------------------------------------------------------------------------------- /systemc-components/common/include/ports/initiator-signal-socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libgsutils 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2022 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _LIBGSUTILS_PORTS_INITIATOR_SIGNAL_SOCKET_H 10 | #define _LIBGSUTILS_PORTS_INITIATOR_SIGNAL_SOCKET_H 11 | 12 | #include 13 | 14 | template 15 | using InitiatorSignalSocket = sc_core::sc_port, 1, sc_core::SC_ZERO_OR_MORE_BOUND>; 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /systemc-components/common/include/qk_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef QK_FACTORY_H 9 | #define QK_FACTORY_H 10 | 11 | #include 12 | #include 13 | 14 | namespace gs { 15 | std::shared_ptr tlm_quantumkeeper_factory(std::string name); 16 | } 17 | 18 | #endif // QK_FACTORY_H 19 | -------------------------------------------------------------------------------- /systemc-components/common/include/qkmulti-adaptive.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef QKMULTI_ADAPTIVE_QUANTUM_H 9 | #define QKMULTI_ADAPTIVE_QUANTUM_H 10 | 11 | #include 12 | 13 | namespace gs { 14 | class tlm_quantumkeeper_multi_adaptive : public tlm_quantumkeeper_multithread 15 | { 16 | // Only allow up to one quantum from the current sc_time 17 | // In accordance with TLM-2 18 | virtual sc_core::sc_time time_to_sync() override 19 | { 20 | if (status != RUNNING) return sc_core::SC_ZERO_TIME; 21 | 22 | sc_core::sc_time m_quantum = tlm_utils::tlm_quantumkeeper::get_global_quantum(); 23 | sc_core::sc_time sct = sc_core::sc_time_stamp(); 24 | sc_core::sc_time rmt = get_current_time(); 25 | if (rmt <= sct) { 26 | return m_quantum * 2; 27 | } 28 | if (rmt > sct && rmt <= sct + m_quantum) { 29 | return m_quantum * 1; 30 | } 31 | if (rmt > sct + m_quantum && rmt <= sct + (2 * m_quantum)) { 32 | return m_quantum * 0.5; 33 | } 34 | return sc_core::SC_ZERO_TIME; 35 | } 36 | 37 | // Don't sync until we are on the quantum boundry (as expected by TLM-2) 38 | virtual bool need_sync() override { return time_to_sync() == sc_core::SC_ZERO_TIME; } 39 | }; 40 | } // namespace gs 41 | #endif -------------------------------------------------------------------------------- /systemc-components/common/include/qkmulti-freerunning.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef QKMULTI_FREERUNNING_H 8 | #define QKMULTI_FREERUNNING_H 9 | 10 | #include 11 | 12 | namespace gs { 13 | class tlm_quantumkeeper_freerunning : public tlm_quantumkeeper_multithread 14 | { 15 | virtual void sync() override 16 | { 17 | if (is_sysc_thread()) { 18 | assert(m_local_time >= sc_core::sc_time_stamp()); 19 | sc_core::sc_time t = m_local_time - sc_core::sc_time_stamp(); 20 | m_tick.notify(); 21 | sc_core::wait(t); 22 | } else { 23 | /* Wake up the SystemC thread if it's waiting for us to keep up */ 24 | m_tick.notify(); 25 | } 26 | } 27 | 28 | virtual bool need_sync() override { return false; } 29 | }; 30 | } // namespace gs 31 | #endif 32 | -------------------------------------------------------------------------------- /systemc-components/common/include/qkmulti-quantum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef QKMULTI_MULTI_QUANTUM_H 9 | #define QKMULTI_MULTI_QUANTUM_H 10 | 11 | #include 12 | 13 | namespace gs { 14 | class tlm_quantumkeeper_multi_quantum : public tlm_quantumkeeper_multithread 15 | { 16 | // Only allow up to one quantum from the current sc_time 17 | // In accordance with TLM-2 18 | virtual sc_core::sc_time time_to_sync() override 19 | { 20 | sc_core::sc_time quantum = tlm_utils::tlm_quantumkeeper::get_global_quantum(); 21 | sc_core::sc_time next_quantum_boundary = sc_core::sc_time_stamp() + quantum; 22 | sc_core::sc_time now = get_current_time(); 23 | if (next_quantum_boundary >= now) { 24 | return next_quantum_boundary - now; 25 | } else { 26 | return sc_core::SC_ZERO_TIME; 27 | } 28 | } 29 | 30 | // Don't sync until we are on the quantum boundry (as expected by TLM-2) 31 | virtual bool need_sync() override { return time_to_sync() == sc_core::SC_ZERO_TIME; } 32 | }; 33 | } // namespace gs 34 | #endif -------------------------------------------------------------------------------- /systemc-components/common/include/qkmulti-unconstrained.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef QKMULTI_UNCONSTRAINED_H 9 | #define QKMULTI_UNCONSTRAINED_H 10 | 11 | #include 12 | 13 | namespace gs { 14 | class tlm_quantumkeeper_unconstrained : public tlm_quantumkeeper_multithread 15 | { 16 | virtual sc_core::sc_time time_to_sync() override 17 | { 18 | return tlm_utils::tlm_quantumkeeper::get_global_quantum(); 19 | } 20 | 21 | virtual bool need_sync() override { return false; } 22 | }; 23 | } // namespace gs 24 | #endif 25 | -------------------------------------------------------------------------------- /systemc-components/common/include/semaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef SEMAPHORE_H 9 | #define SEMAPHORE_H 10 | 11 | namespace gs { 12 | 13 | #include 14 | #include 15 | 16 | class semaphore 17 | { 18 | private: 19 | std::mutex mutex_; 20 | std::condition_variable condition_; 21 | unsigned long count_ = 0; // Initialized as locked. 22 | 23 | public: 24 | void notify() 25 | { 26 | std::lock_guard lock(mutex_); 27 | ++count_; 28 | condition_.notify_one(); 29 | } 30 | 31 | void wait() 32 | { 33 | std::unique_lock lock(mutex_); 34 | while (!count_) // Handle spurious wake-ups. 35 | condition_.wait(lock); 36 | --count_; 37 | } 38 | 39 | bool try_wait() 40 | { 41 | std::lock_guard lock(mutex_); 42 | if (count_) { 43 | --count_; 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | semaphore() = default; 50 | ~semaphore() 51 | { 52 | // don't block on destruction 53 | notify(); 54 | } 55 | }; 56 | } // namespace gs 57 | 58 | #endif // SEMAPHORE_H 59 | -------------------------------------------------------------------------------- /systemc-components/common/include/tlm-extensions/pathid_extension.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _GREENSOCS_PATHID_EXTENSION_H 9 | #define _GREENSOCS_PATHID_EXTENSION_H 10 | 11 | #include 12 | #include 13 | 14 | namespace gs { 15 | 16 | /** 17 | * @class Path recording TLM extension 18 | * 19 | * @brief Path recording TLM extension 20 | * 21 | * @details Embeds an ID field in the txn, which is populated as the network 22 | * is traversed - see README. 23 | */ 24 | 25 | class PathIDExtension : public tlm::tlm_extension, public std::vector 26 | { 27 | public: 28 | PathIDExtension() = default; 29 | PathIDExtension(const PathIDExtension&) = default; 30 | 31 | public: 32 | virtual tlm_extension_base* clone() const override { return new PathIDExtension(*this); } 33 | 34 | virtual void copy_from(const tlm_extension_base& ext) override 35 | { 36 | const PathIDExtension& other = static_cast(ext); 37 | *this = other; 38 | } 39 | }; 40 | } // namespace gs 41 | #endif 42 | -------------------------------------------------------------------------------- /systemc-components/common/include/tlm-extensions/shmem_extension.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _GREENSOCS_SHMEMID_EXTENSION_H 8 | #define _GREENSOCS_SHMEMID_EXTENSION_H 9 | 10 | #include 11 | #include 12 | 13 | namespace gs { 14 | 15 | /** 16 | * @class Shared memory ID extension 17 | * 18 | * @details This ID field is expected to be held by the component offering, and provided to other 19 | * components The extension is therefore held and 'memory managed' by the owner. It should not be 20 | * deleted. It may be 'shared' multiple times. 21 | */ 22 | 23 | class ShmemIDExtension : public tlm::tlm_extension 24 | { 25 | public: 26 | std::string m_memid; 27 | uint64_t m_mapped_addr; 28 | uint64_t m_size; 29 | int m_fd; 30 | 31 | ShmemIDExtension(): m_mapped_addr(0), m_size(0){}; 32 | ShmemIDExtension(const ShmemIDExtension&) = default; 33 | ShmemIDExtension(std::string& s, uint64_t addr, uint64_t size, int fd = -1) 34 | : m_memid(s), m_mapped_addr(addr), m_size(size), m_fd(fd) 35 | { 36 | SCP_DEBUG("ShmemIDExtension") << "ShmemIDExtension constructor"; 37 | } 38 | ShmemIDExtension& operator=(ShmemIDExtension o) 39 | { 40 | m_memid.assign(o.m_memid); 41 | m_mapped_addr = o.m_mapped_addr; 42 | m_size = o.m_size; 43 | m_fd = o.m_fd; 44 | return *this; 45 | } 46 | 47 | virtual tlm_extension_base* clone() const override { return const_cast(this); } 48 | 49 | virtual void copy_from(const tlm_extension_base& ext) override 50 | { 51 | const ShmemIDExtension& other = static_cast(ext); 52 | *this = other; 53 | } 54 | 55 | virtual void free() override { return; } // we will not free this extension 56 | 57 | bool empty() { return m_size == 0; } 58 | }; 59 | } // namespace gs 60 | #endif 61 | -------------------------------------------------------------------------------- /systemc-components/common/include/tlm_sockets_buswidth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef TLM_SOCKETS_BUSWIDTH_H 8 | #define TLM_SOCKETS_BUSWIDTH_H 9 | 10 | #ifndef OVERRIDDEN_DEFAULT_TLM_BUSWIDTH 11 | #define DEFAULT_TLM_BUSWIDTH 32 12 | #else 13 | #define DEFAULT_TLM_BUSWIDTH OVERRIDDEN_DEFAULT_TLM_BUSWIDTH 14 | #endif 15 | 16 | #endif -------------------------------------------------------------------------------- /systemc-components/common/include/transaction_forwarder_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __TRANSACTION_FORWARD_IF__ 8 | #define __TRANSACTION_FORWARD_IF__ 9 | 10 | #include 11 | #include 12 | 13 | namespace gs { 14 | 15 | enum ForwarderType { 16 | CONTAINER /*modules container*/, 17 | PASS /*PassRPC model to work in LOCAL or REMOTE mode*/, 18 | SC_MODULE /*Generic sc_module*/ 19 | }; 20 | 21 | template 22 | class transaction_forwarder_if 23 | { 24 | public: 25 | virtual void fw_b_transport(int id, tlm::tlm_generic_payload& trans, sc_core::sc_time& delay) = 0; 26 | 27 | virtual unsigned int fw_transport_dbg(int id, tlm::tlm_generic_payload& trans) = 0; 28 | 29 | virtual bool fw_get_direct_mem_ptr(int id, tlm::tlm_generic_payload& trans, tlm::tlm_dmi& dmi_data) = 0; 30 | 31 | virtual void fw_invalidate_direct_mem_ptr(sc_dt::uint64 start, sc_dt::uint64 end) = 0; 32 | 33 | virtual void fw_handle_signal(int id, bool value) = 0; 34 | 35 | virtual ~transaction_forwarder_if() = default; 36 | }; 37 | } // namespace gs 38 | #endif -------------------------------------------------------------------------------- /systemc-components/common/src/libgssync/qk_factory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace gs { 13 | std::shared_ptr tlm_quantumkeeper_factory(std::string name) 14 | { 15 | if (name == "tlm2") return std::make_shared(); 16 | if (name == "multithread") return std::make_shared(); 17 | if (name == "multithread-quantum") return std::make_shared(); 18 | if (name == "multithread-adaptive") return std::make_shared(); 19 | if (name == "multithread-rolling") return std::make_shared(); 20 | if (name == "multithread-unconstrained") return std::make_shared(); 21 | if (name == "multithread-freerunning") return std::make_shared(); 22 | return nullptr; 23 | } 24 | } // namespace gs 25 | -------------------------------------------------------------------------------- /systemc-components/common/src/macs/components/mac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | uint32_t MACAddress::lo() const 16 | { 17 | return ((uint32_t)m_bytes[0] << 0) | ((uint32_t)m_bytes[1] << 8) | ((uint32_t)m_bytes[2] << 16) | 18 | ((uint32_t)m_bytes[3] << 24); 19 | } 20 | 21 | uint16_t MACAddress::hi() const { return ((uint16_t)m_bytes[4] << 0) | ((uint16_t)m_bytes[5] << 8); } 22 | 23 | void MACAddress::set_lo(uint32_t value) 24 | { 25 | m_bytes[0] = (value >> 0) & 0xff; 26 | m_bytes[1] = (value >> 8) & 0xff; 27 | m_bytes[2] = (value >> 16) & 0xff; 28 | m_bytes[3] = (value >> 24) & 0xff; 29 | } 30 | 31 | void MACAddress::set_hi(uint16_t value) 32 | { 33 | m_bytes[4] = (value >> 0) & 0xff; 34 | m_bytes[5] = (value >> 8) & 0xff; 35 | } 36 | 37 | void MACAddress::zero() { memset(m_bytes, 0, 6); } 38 | 39 | bool MACAddress::set_from_str(const std::string& mac) 40 | { 41 | std::vector strs; 42 | 43 | char* token; 44 | const char s[2] = ":"; 45 | token = strtok((char*)mac.c_str(), s); 46 | while (token != NULL) { 47 | strs.push_back(token); 48 | token = strtok(NULL, s); 49 | } 50 | 51 | // boost::split(strs, mac, boost::is_any_of(":")); 52 | if (strs.size() != 6) { 53 | return false; 54 | } 55 | 56 | for (int i = 0; i < 6; i++) { 57 | std::string& s = strs[i]; 58 | if (s.size() != 2 || s.find_first_not_of("0123456789abcdefABCDEF") != std::string::npos) { 59 | return false; 60 | } 61 | m_bytes[i] = (uint8_t)std::strtoul(s.c_str(), NULL, 16); 62 | } 63 | 64 | return true; 65 | } 66 | -------------------------------------------------------------------------------- /systemc-components/dmi_converter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(dmi_converter) 2 | -------------------------------------------------------------------------------- /systemc-components/dmi_converter/src/dmi_converter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::dmi_converter<> dmi_converter; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(dmi_converter); } 14 | -------------------------------------------------------------------------------- /systemc-components/exclusive_monitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(exclusive_monitor) 2 | -------------------------------------------------------------------------------- /systemc-components/exclusive_monitor/src/exclusive-monitor.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(exclusive_monitor); } -------------------------------------------------------------------------------- /systemc-components/exiter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(exiter) 2 | -------------------------------------------------------------------------------- /systemc-components/exiter/src/exiter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(exiter); } -------------------------------------------------------------------------------- /systemc-components/gs_memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(gs_memory) 2 | 3 | target_link_libraries(gs_memory PRIVATE 4 | ${LIBELF_LIBRARIES} 5 | ) 6 | 7 | if(UNIX AND NOT APPLE) 8 | target_link_libraries(gs_memory PRIVATE rt) 9 | endif() 10 | -------------------------------------------------------------------------------- /systemc-components/gs_memory/src/gs_memory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "gs_memory.h" 10 | 11 | typedef gs::gs_memory<> gs_memory; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(gs_memory); } -------------------------------------------------------------------------------- /systemc-components/keep_alive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(keep_alive) 2 | -------------------------------------------------------------------------------- /systemc-components/keep_alive/include/keep_alive.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /** 8 | * @class KeepAlive 9 | * @brief this calss is used to keep the simulation alive by using an async event 10 | */ 11 | #ifndef _GS_KEEP_ALIVE_H_ 12 | #define _GS_KEEP_ALIVE_H_ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | class keep_alive : public sc_core::sc_module 20 | { 21 | SCP_LOGGER(); 22 | 23 | public: 24 | gs::async_event keep_alive_event; 25 | 26 | keep_alive(sc_core::sc_module_name name): sc_core::sc_module(name) 27 | { 28 | SCP_DEBUG(()) << "keep_alive: Constructor"; 29 | keep_alive_event.async_attach_suspending(); 30 | } 31 | ~keep_alive() {} 32 | }; 33 | 34 | extern "C" void module_register(); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /systemc-components/keep_alive/src/keep_alive.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(keep_alive); } -------------------------------------------------------------------------------- /systemc-components/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(loader) 2 | -------------------------------------------------------------------------------- /systemc-components/loader/src/loader.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::loader<> loader; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(loader); } -------------------------------------------------------------------------------- /systemc-components/macs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(dwmac) 2 | add_subdirectory(xgmac) 3 | -------------------------------------------------------------------------------- /systemc-components/macs/dwmac/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(dwmac) 2 | -------------------------------------------------------------------------------- /systemc-components/macs/xgmac/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(xgmac) 2 | -------------------------------------------------------------------------------- /systemc-components/memory_dumper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(memory_dumper) 2 | 3 | target_include_directories( 4 | memory_dumper PUBLIC 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /systemc-components/memory_dumper/src/memory_dumper.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::memory_dumper<> memory_dumper; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(memory_dumper); } -------------------------------------------------------------------------------- /systemc-components/monitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(monitor) 2 | 3 | add_custom_command(TARGET monitor POST_BUILD 4 | COMMAND ${CMAKE_COMMAND} -E create_symlink 5 | ${CMAKE_CURRENT_SOURCE_DIR}/static/ $/static) 6 | 7 | install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/static DESTINATION bin) 8 | -------------------------------------------------------------------------------- /systemc-components/pass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(pass) 2 | -------------------------------------------------------------------------------- /systemc-components/pass/src/pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::pass<> pass; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(pass); } 14 | -------------------------------------------------------------------------------- /systemc-components/python_binder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(python_binder) 2 | 3 | target_link_libraries(python_binder PUBLIC 4 | ${PYBIND11_EMBED} 5 | ) 6 | 7 | target_include_directories( 8 | python_binder PUBLIC 9 | $ 10 | ) 11 | -------------------------------------------------------------------------------- /systemc-components/realtimelimiter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(realtimelimiter) 2 | -------------------------------------------------------------------------------- /systemc-components/realtimelimiter/src/realtimelimiter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::realtimelimiter realtimelimiter; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(realtimelimiter); } 14 | -------------------------------------------------------------------------------- /systemc-components/reg_router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(reg_router) 2 | -------------------------------------------------------------------------------- /systemc-components/reg_router/src/reg_router.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "reg_router.h" 10 | 11 | typedef gs::reg_router<> reg_router; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(reg_router); } -------------------------------------------------------------------------------- /systemc-components/router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(router) 2 | -------------------------------------------------------------------------------- /systemc-components/router/src/router.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "router.h" 10 | 11 | typedef gs::router<> router; 12 | 13 | void module_register() { GSC_MODULE_REGISTER_C(router); } -------------------------------------------------------------------------------- /systemc-components/timeprinter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(timeprinter) 2 | -------------------------------------------------------------------------------- /systemc-components/timeprinter/include/timeprinter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef TIMEPRINTER_H 8 | #define TIMEPRINTER_H 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | /** 15 | * @brief timeprinter: sc_module to print time at regular simulation intervals. 16 | * This is a simple sc_module which has no IO, and simply emits an 'info' message with the current sc_time and wall 17 | * clock time every interval_us microsecond. It uses the standard SCP_INFO report mechanism for output. 18 | * 19 | * NB to enable output, set the log_level for this module to at least 4 20 | * 21 | * @param interval_us 22 | * The number of microseconds of simulated time between prints 23 | * 24 | */ 25 | SC_MODULE (timeprinter) { 26 | SCP_LOGGER(); 27 | cci::cci_param interval_us; 28 | SC_CTOR (timeprinter) : interval_us("interval_us",1000000,"Interval between printing in microseconds") 29 | { 30 | SC_THREAD(print_time_stamp); 31 | } 32 | 33 | void print_time_stamp() 34 | { 35 | auto startRT = std::chrono::high_resolution_clock::now(); 36 | 37 | while (1) { 38 | sc_core::sc_time now = sc_core::sc_time(std::chrono::duration_cast( 39 | std::chrono::high_resolution_clock::now() - startRT) 40 | .count(), 41 | sc_core::SC_US); 42 | 43 | SCP_INFO(())("time stamp real time: {:.6}s", now.to_seconds()); 44 | sc_core::wait(interval_us, sc_core::SC_US); 45 | } 46 | } 47 | }; 48 | 49 | extern "C" void module_register(); 50 | 51 | #endif // TIMEPRINTER_H -------------------------------------------------------------------------------- /systemc-components/timeprinter/src/timeprinter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(timeprinter); } -------------------------------------------------------------------------------- /systemc-components/tlm_bus_width_bridges/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(tlm_bus_width_bridges) 2 | -------------------------------------------------------------------------------- /systemc-components/tlm_bus_width_bridges/src/tlm_bus_width_bridges.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | typedef gs::tlm_bus_width_bridges<32, 64> TLMBUSWIDTHBridgeFrom32To64; 12 | typedef gs::tlm_bus_width_bridges<64, 32> TLMBUSWIDTHBridgeFrom64To32; 13 | 14 | void module_register() 15 | { 16 | GSC_MODULE_REGISTER_C(TLMBUSWIDTHBridgeFrom32To64); 17 | GSC_MODULE_REGISTER_C(TLMBUSWIDTHBridgeFrom64To32); 18 | } 19 | -------------------------------------------------------------------------------- /systemc-components/uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(uart-ibex) 2 | add_subdirectory(uart-pl011) 3 | -------------------------------------------------------------------------------- /systemc-components/uart/uart-ibex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(uart-ibex) 2 | -------------------------------------------------------------------------------- /systemc-components/uart/uart-ibex/src/uart-ibex.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(ibex_uart); } -------------------------------------------------------------------------------- /systemc-components/uart/uart-pl011/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | gs_create_dymod(uart-pl011) 2 | -------------------------------------------------------------------------------- /systemc-components/uart/uart-pl011/src/uart-pl011.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "uart-pl011.h" 10 | 11 | void module_register() { GSC_MODULE_REGISTER_C(Pl011); } 12 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(base-components) 2 | add_subdirectory(libgssync) 3 | add_subdirectory(libgsutils) 4 | add_subdirectory(libqbox) 5 | add_subdirectory(systemc-uarts) -------------------------------------------------------------------------------- /tests/base-components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(exclusive-monitor) 2 | add_subdirectory(memory) 3 | add_subdirectory(router) 4 | add_subdirectory(router-memory) 5 | add_subdirectory(addrtr) 6 | add_subdirectory(aliases) 7 | add_subdirectory(loader) 8 | add_subdirectory(memory-blocs) 9 | add_subdirectory(dmi-converter) 10 | add_subdirectory(remote) 11 | if((NOT WITHOUT_PYTHON_BINDER) AND (NOT GS_ONLY)) 12 | add_subdirectory(python-binder) 13 | endif() 14 | add_subdirectory(gs_register) 15 | -------------------------------------------------------------------------------- /tests/base-components/addrtr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock addrtr ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(addrtr-tests) 8 | -------------------------------------------------------------------------------- /tests/base-components/addrtr/addrtr-tests.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include "addrtr-bench.h" 12 | 13 | /* 14 | * Regular load and stores. Check that the monitor does not introduce bugs when 15 | * no exclusive transaction are in use. 16 | */ 17 | TEST_BENCH(AddrtrTestBench, simlpletxn) { do_txn(0, 100, 0); } 18 | TEST_BENCH(AddrtrTestBench, dbgtxn) { do_txn(1, 100, 1); } 19 | TEST_BENCH(AddrtrTestBench, dmiinv) { do_dmi(2, 100); } 20 | int sc_main(int argc, char* argv[]) 21 | { 22 | auto m_broker = new gs::ConfigurableBroker(); 23 | 24 | ::testing::InitGoogleTest(&argc, argv); 25 | return RUN_ALL_TESTS(); 26 | } 27 | -------------------------------------------------------------------------------- /tests/base-components/aliases/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} gtest gmock gs_memory router ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test} --gs_luafile ${CMAKE_CURRENT_SOURCE_DIR}/conf-test.lua) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | 8 | gs_add_test(aliases-mapping-test) 9 | -------------------------------------------------------------------------------- /tests/base-components/aliases/conf-test.lua: -------------------------------------------------------------------------------- 1 | 2 | print ("Lua config running. . ."); 3 | 4 | test_bench = { 5 | target= { target_socket = {address=0x0000, size=0xFF, aliases={{address=0X0100, size=0xFF}, {address=0x0200, size=0xFF}}}}; 6 | ram= { target_socket = {address=0x0300, size=0xFF}}; 7 | rom= { target_socket = {address=0x0400, size=0xFF, aliases={{address=0X0500, size=0xFF}, {address=0x0600, size=0xFF}}}}; 8 | }; 9 | SimpleWriteRead = test_bench; 10 | SimpleOverlapWrite = test_bench; 11 | SimpleCrossesBoundary = test_bench; 12 | SimpleWriteReadDebug = test_bench; 13 | SimpleOverlapWriteDebug = test_bench; 14 | SimpleCrossesBoundaryDebug = test_bench; 15 | WriteBlockingReadDebug = test_bench; 16 | WriteDebugReadBlocking = test_bench; 17 | SimpleDmi = test_bench; 18 | DmiWriteRead = test_bench; -------------------------------------------------------------------------------- /tests/base-components/dmi-converter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock dmi_converter ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(dmi-converter-tests) 8 | -------------------------------------------------------------------------------- /tests/base-components/exclusive-monitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(test_exclusive_monitor tests.cc) 2 | target_link_libraries(test_exclusive_monitor gtest gmock exclusive_monitor router ${TARGET_LIBS}) 3 | add_test(NAME test_exclusive_monitor COMMAND test_exclusive_monitor) 4 | -------------------------------------------------------------------------------- /tests/base-components/gs_register/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock gs_memory reg_router ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(gs_register-tests) 8 | -------------------------------------------------------------------------------- /tests/base-components/gs_register/gs_register-bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "gs_memory.h" 13 | #include "reg_router.h" 14 | #include "registers.h" 15 | #include 16 | #include 17 | #include 18 | 19 | class RegisterTestBench : public TestBench 20 | { 21 | public: 22 | SCP_LOGGER(); 23 | 24 | protected: 25 | InitiatorTester m_initiator; 26 | gs::gs_memory<> m_reg_memory; 27 | gs::reg_router<> m_reg_router; 28 | gs::gs_register FIFO0; 29 | gs::gs_register CMD0; 30 | gs::gs_field CMD0_OPCODE; 31 | gs::gs_field CMD0_PARAM; 32 | gs::gs_register STATUS64; 33 | uint32_t last_written_value; 34 | uint64_t last_written_idx; 35 | uint32_t last_used_mask; 36 | std::vector last_read_vec; 37 | bool is_array; 38 | 39 | public: 40 | RegisterTestBench(const sc_core::sc_module_name& n); 41 | virtual ~RegisterTestBench() {} 42 | 43 | protected: 44 | void end_of_elaboration(); 45 | }; -------------------------------------------------------------------------------- /tests/base-components/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock router gs_memory ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test} --gs_luafile ${CMAKE_CURRENT_SOURCE_DIR}/conf-test.lua) 5 | 6 | if (GS_ENABLE_SANITIZERS) 7 | set(ENV{ASAN_OPTIONS} "detect_leaks=1") 8 | set(ENV{LSAN_OPTIONS} "suppressions=${CMAKE_CURRENT_SOURCE_DIR}/ignore_leaks.txt") 9 | set_tests_properties(${test} PROPERTIES 10 | ENVIRONMENT ASAN_OPTIONS="detect_leaks=1":$ENV{ASAN_OPTIONS} 11 | ENVIRONMENT LSAN_OPTIONS="suppressions=${CMAKE_CURRENT_SOURCE_DIR}/ignore_leaks.txt":$ENV{LSAN_OPTIONS}) 12 | endif() 13 | 14 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 15 | endmacro() 16 | 17 | gs_add_test(loader-test) 18 | -------------------------------------------------------------------------------- /tests/base-components/loader/conf-test.lua: -------------------------------------------------------------------------------- 1 | 2 | function top() 3 | local str = debug.getinfo(2, "S").source:sub(2) 4 | if str:match("(.*/)") 5 | then 6 | return str:match("(.*/)") 7 | else 8 | return "./" 9 | end 10 | end 11 | 12 | print ("Lua config running. . ."); 13 | 14 | test_bench = { 15 | rom1= { target_socket = {address=0x0000, size=0x1000}}; 16 | rom2= { target_socket = {address=0x1000, size=0x1000}}; 17 | rom3= { target_socket = {address=0x2000, size=0x1000}}; 18 | 19 | load={ 20 | {bin_file=top().."/src/loader-test.bin", address=0x1000}; 21 | {elf_file=top().."/src/loader-test.elf"}; 22 | {csv_file=top().."/src/loader-test.csv", 23 | addr_str="_addr", value_str=" _value", 24 | offset = 0x100, address = 0x2000}; 25 | {data={0xdeadbeaf}, address = 0x0500}; 26 | } 27 | }; 28 | SimpleReadData = test_bench; 29 | SimpleReadELFFile = test_bench; 30 | SimpleReadBinFile = test_bench; 31 | SimpleReadCSVFile = test_bench; 32 | -------------------------------------------------------------------------------- /tests/base-components/loader/ignore_leaks.txt: -------------------------------------------------------------------------------- 1 | # ignore leak issues 2 | leak:cci::cci_impl -------------------------------------------------------------------------------- /tests/base-components/loader/loader-test-bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "gs_memory.h" 15 | #include "router.h" 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | class LoaderTest : public TestBench 23 | { 24 | protected: 25 | InitiatorTester m_initiator; 26 | gs::router<> m_router; 27 | gs::gs_memory<> m_rom1; 28 | gs::gs_memory<> m_rom2; 29 | gs::gs_memory<> m_rom3; 30 | 31 | gs::loader<> m_loader; 32 | 33 | void do_bus_binding() 34 | { 35 | m_router.initiator_socket.bind(m_rom1.socket); 36 | m_router.initiator_socket.bind(m_rom2.socket); 37 | m_router.initiator_socket.bind(m_rom3.socket); 38 | m_router.add_initiator(m_initiator.socket); 39 | // General loader 40 | m_loader.initiator_socket.bind(m_router.target_socket); 41 | } 42 | 43 | public: 44 | LoaderTest(const sc_core::sc_module_name& n) 45 | : TestBench(n) 46 | , m_initiator("initiator") 47 | , m_router("router") 48 | , m_rom1("rom1") 49 | , m_rom2("rom2") 50 | , m_rom3("rom3") 51 | , m_loader("load") 52 | { 53 | do_bus_binding(); 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PREFIX= 3 | all: 4 | $(PREFIX)arm-none-eabi-as ./loader-test.asm -o loader-test.o -mthumb 5 | $(PREFIX)arm-none-eabi-as ./loader-test-bin.asm -o loader-test-bin.o -mthumb 6 | $(PREFIX)arm-none-eabi-ld ./loader-test.o ./loader-test-bin.o -o loader-test.elf -T ./link.ld 7 | $(PREFIX)arm-none-eabi-objcopy loader-test.elf -O binary loader-test.bin 8 | 9 | clean: 10 | rm loader-test.o loader-test-bin.o loader-test.elf loader-test.bin 11 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/README.md: -------------------------------------------------------------------------------- 1 | This directory hold the source code to re-generate the elf file and bin file 2 | 3 | By default the Makefile allows us to compile our assembler files into ELF and bin files. 4 | To generate them we just need to run the `make` command directly in the `src` folder. -------------------------------------------------------------------------------- /tests/base-components/loader/src/link.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | ram (rx) : ORIGIN = 0x0000, LENGTH = 0x1000 4 | rom (rx) : ORIGIN = 0x1000, LENGTH = 0x1000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .data : 10 | { 11 | *(.data*) 12 | } > ram 13 | 14 | .binmem : 15 | { 16 | *(.binmem*) 17 | } > rom 18 | } 19 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/loader-test-bin.asm: -------------------------------------------------------------------------------- 1 | .section .binmem 2 | .word 0xdeadbeaf 3 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/loader-test.asm: -------------------------------------------------------------------------------- 1 | .section .data 2 | .word 0xdeadbeaf 3 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/loader-test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/tests/base-components/loader/src/loader-test.bin -------------------------------------------------------------------------------- /tests/base-components/loader/src/loader-test.csv: -------------------------------------------------------------------------------- 1 | x,_addr,y,z, _value 2 | 1,0x00000000,"text",unquoted,11 3 | 2,0x00000004,isosceles,unquoted,12 4 | 3,,missing_fields 5 | 4 6 | 5,0x00000008,clarified, trailing whitespace , 15 7 | 6,0x0000000c,hex,message, 0xf00afafb5b5 8 | -------------------------------------------------------------------------------- /tests/base-components/loader/src/loader-test.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quic/qbox/6a23bebefd25b060275cbc7d37cccb00130aa6d1/tests/base-components/loader/src/loader-test.elf -------------------------------------------------------------------------------- /tests/base-components/memory-blocs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gs_memory ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(memory-blocs) -------------------------------------------------------------------------------- /tests/base-components/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock gs_memory ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(memory-tests) 8 | -------------------------------------------------------------------------------- /tests/base-components/python-binder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock router gs_memory ${TARGET_LIBS} python_binder) 4 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/python-binder-test.py ${CMAKE_CURRENT_BINARY_DIR}/python-binder-test.py COPYONLY) 5 | add_test(NAME ${test} COMMAND ${test}) 6 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 7 | endmacro() 8 | gs_add_test(python-binder-tests) 9 | -------------------------------------------------------------------------------- /tests/base-components/remote/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock router gs_memory pass ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | 8 | add_executable(remote-tests-remote remote.cc) 9 | target_include_directories(remote-tests-remote 10 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/greensocs/base-components/ 11 | ) 12 | target_link_libraries(remote-tests-remote PRIVATE router gs_memory pass ${TARGET_LIBS}) 13 | 14 | gs_add_test(remote-tests) 15 | -------------------------------------------------------------------------------- /tests/base-components/router-memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock router gs_memory memory_dumper ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(router-memory-tests) 8 | -------------------------------------------------------------------------------- /tests/base-components/router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock router pass ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(router-tests) 8 | -------------------------------------------------------------------------------- /tests/libgssync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(integration_tests) 2 | add_subdirectory(unit_tests) 3 | add_subdirectory(scp_report) -------------------------------------------------------------------------------- /tests/libgssync/integration_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(checker main.cc) 2 | #add_test( 3 | # NAME integration_test 4 | # COMMAND checker --gs_luafile ${CMAKE_CURRENT_SOURCE_DIR}/tests.lua 5 | #) 6 | target_link_libraries(checker 7 | PRIVATE 8 | ${TARGET_LIBS} 9 | router 10 | realtimelimiter 11 | ) 12 | -------------------------------------------------------------------------------- /tests/libgssync/integration_tests/pathid_extension.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #ifndef _GREENSOCS_PATHID_EXTENSION_H 9 | #define _GREENSOCS_PATHID_EXTENSION_H 10 | 11 | #include 12 | #include 13 | 14 | namespace gs { 15 | 16 | /** 17 | * @class Path recording TLM extension 18 | * 19 | * @brief Path recording TLM extension 20 | * 21 | * @details Embeds an ID field in the txn, which is populated as the network 22 | * is traversed - see README. 23 | */ 24 | 25 | class PathIDExtension : public tlm::tlm_extension, public std::vector 26 | { 27 | public: 28 | PathIDExtension() = default; 29 | PathIDExtension(const PathIDExtension&) = default; 30 | 31 | public: 32 | virtual tlm_extension_base* clone() const override { return new PathIDExtension(*this); } 33 | 34 | virtual void copy_from(const tlm_extension_base& ext) override 35 | { 36 | const PathIDExtension& other = static_cast(ext); 37 | *this = other; 38 | } 39 | }; 40 | } // namespace gs 41 | #endif 42 | -------------------------------------------------------------------------------- /tests/libgssync/scp_report/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} ${TARGET_LIBS} gtest gmock) 4 | add_test(NAME ${test} COMMAND ${test} --gs_luafile ${CMAKE_CURRENT_SOURCE_DIR}/lua_test.lua) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | 8 | gs_add_test(scp_report_thread) 9 | -------------------------------------------------------------------------------- /tests/libgssync/scp_report/lua_test.lua: -------------------------------------------------------------------------------- 1 | testA = { log_level = 4 } -- print all the log in the module testA 2 | testB = { log_level = 4 } -- print all the log in the module testB -------------------------------------------------------------------------------- /tests/libgssync/unit_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | macro(gs_test test) 3 | add_executable(${test} ${test}.cc) 4 | target_link_libraries(${test} ${TARGET_LIBS} gtest gmock) 5 | add_test(NAME ${test} COMMAND ${test}) 6 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 7 | endmacro() 8 | 9 | gs_test(qk_extendedif_test) 10 | gs_test(qkmultithread_test) 11 | gs_test(qkmulti-quantum_test) 12 | -------------------------------------------------------------------------------- /tests/libgsutils/factory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(LIBQEMU_TARGETS "riscv64") 2 | 3 | macro(gs_add_test test lua_file) 4 | add_executable(${test} ${test}.cc) 5 | target_link_libraries(${test} PRIVATE router gs_memory ${TARGET_LIBS} gtest gmock) 6 | add_test(NAME ${test} COMMAND ${test} --gs_luafile ${CMAKE_CURRENT_SOURCE_DIR}/${lua_file}.lua) 7 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 8 | endmacro(gs_add_test test lua_file) 9 | 10 | gs_add_test(factory_platform factory_platform) -------------------------------------------------------------------------------- /tests/libgsutils/factory/factory_platform.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include "tests/initiator-tester.h" 31 | #include "tests/test-bench.h" 32 | #include "module_factory_container.h" 33 | 34 | using testing::AnyOf; 35 | using testing::Eq; 36 | 37 | class FactoryPlatform : public gs::ModuleFactory::Container 38 | { 39 | public: 40 | FactoryPlatform(const sc_core::sc_module_name& n): gs::ModuleFactory::Container(n) {} 41 | }; 42 | 43 | int sc_main(int argc, char** argv) 44 | { 45 | gs::ConfigurableBroker m_broker{}; 46 | cci::cci_originator orig{ "sc_main" }; 47 | auto broker_h = m_broker.create_broker_handle(orig); 48 | ArgParser ap{ broker_h, argc, argv }; 49 | 50 | FactoryPlatform platform("platform"); 51 | 52 | auto mgb = cci::cci_get_global_broker(cci::cci_originator("GreenSocs Module Factory test")); 53 | auto uncon = mgb.get_unconsumed_preset_values(); 54 | for (auto v : uncon) { 55 | std::cout << "Unconsumed config value: " << v.first << " : " << v.second << "\n"; 56 | } 57 | 58 | testing::InitGoogleTest(&argc, argv); 59 | return RUN_ALL_TESTS(); 60 | } 61 | 62 | TEST(factory_platform, all) { sc_start(1, sc_core::SC_NS); } -------------------------------------------------------------------------------- /tests/libgsutils/factory/factory_platform.lua: -------------------------------------------------------------------------------- 1 | platform = { 2 | moduletype="Container"; 3 | 4 | initiator = { 5 | moduletype="InitiatorTester"; 6 | initiator_socket= {bind = "&router.target_socket";} 7 | }, 8 | 9 | router = { 10 | moduletype="router"; 11 | }, 12 | 13 | rom_0 = { 14 | moduletype="gs_memory"; 15 | target_socket= {size = 0x1000, 16 | address=0x0000; 17 | bind = "&router.initiator_socket";} 18 | }, 19 | 20 | rom_1 = { 21 | moduletype="gs_memory"; 22 | target_socket= {size = 0x1000, 23 | address=0x1000; 24 | bind = "&router.initiator_socket";} 25 | }, 26 | 27 | } -------------------------------------------------------------------------------- /tests/libgsutils/ignore_leaks.txt: -------------------------------------------------------------------------------- 1 | # ignore leak issues 2 | # this detect leak can be remove if this JIRA ticket is close https://jira-dc.qualcomm.com/jira/browse/QTOOL-89141 3 | leak:cci::cci_impl -------------------------------------------------------------------------------- /tests/libgsutils/logger_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 | * Author: GreenSocs 2022 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using testing::AnyOf; 17 | using testing::Eq; 18 | 19 | SC_MODULE (testA) { 20 | void testA_method() 21 | { 22 | std::cout << "(cout) test A" << std::endl; 23 | SC_REPORT_INFO("testA", "(SC_REPORT_INFO) test A"); 24 | SCP_INFO() << "(SCP_INFO) test A"; 25 | } 26 | SC_CTOR (testA) { 27 | SC_METHOD(testA_method); 28 | } 29 | }; 30 | 31 | int sc_main(int argc, char** argv) 32 | { 33 | scp::init_logging(scp::LogConfig() 34 | .logLevel(scp::log::DBGTRACE) // set log level to DBGTRACE = TRACEALL 35 | .msgTypeFieldWidth(10)); // make the msg type column a bit tighter 36 | 37 | std::stringstream buffer; 38 | std::streambuf* old = std::cout.rdbuf(buffer.rdbuf()); 39 | 40 | std::cout << "(cout) Logger test" << std::endl; 41 | SC_REPORT_INFO("sc_main", "(SC_REPORT_INFO) Logging test"); 42 | 43 | testA atest("TestA_Instance"); 44 | 45 | sc_core::sc_start(); 46 | 47 | std::cout.rdbuf(old); 48 | 49 | std::string text = buffer.str(); // text will now contain "Bla\n" 50 | std::cout << "Text found: " << std::endl << text << std::endl; 51 | 52 | return EXIT_SUCCESS; 53 | } -------------------------------------------------------------------------------- /tests/libgsutils/lua_test.lua: -------------------------------------------------------------------------------- 1 | top = { luavalue = 2020; allvalue=2050; log_level=0 } 2 | MyCtrl = { irqs = 99 } 3 | testA = { log_level = 0 } 4 | testB = { log_level = 0 } 5 | foo = { me = { log_level = 0 } } 6 | bar = { me = { log_level = 0 } } 7 | DEBUG = { foo = { log_level = 0}; bar = { log_level = 0 } } 8 | log_level = 1 -------------------------------------------------------------------------------- /tests/libqbox/cpu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(aarch64) 2 | add_subdirectory(hexagon) 3 | add_subdirectory(halt) 4 | add_subdirectory(reset) 5 | -------------------------------------------------------------------------------- /tests/libqbox/cpu/aarch64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qbox_add_cpu_test(aarch64-simple-write-test 100 simple-write-test.cc) 2 | qbox_add_cpu_test(aarch64-dmi-test 100 dmi-test.cc) 3 | qbox_add_cpu_test(aarch64-dmi-test-concurrent-inval 100 dmi-test-concurrent-inval.cc) 4 | qbox_add_cpu_test(aarch64-ld-st-excl-fail-test 100 ld-st-excl-fail.cc) 5 | qbox_add_cpu_test(aarch64-write_read 100 write_read.cc) 6 | qbox_add_cpu_test(aarch64-dmi-test-async-inval 500 dmi-test-async-inval.cc) 7 | -------------------------------------------------------------------------------- /tests/libqbox/cpu/halt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qbox_add_cpu_test(halt-tests 100 halt-tests.cc) -------------------------------------------------------------------------------- /tests/libqbox/cpu/hexagon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qbox_add_cpu_test(hexagon-ld-st-mmio-test 100 ld-st-mmio.cc) 2 | qbox_add_cpu_test(hexagon-reset-test 100 hex-reset.cc) 3 | 4 | -------------------------------------------------------------------------------- /tests/libqbox/cpu/reset/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qbox_add_cpu_test(reset-test-system 100 reset-test-system.cc) 2 | qbox_add_cpu_test(reset-test-cpu 100 reset-test-cpu.cc) -------------------------------------------------------------------------------- /tests/libqbox/cpu/reset/reset-test-cpu.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | #undef SYSTEMMODE 9 | #include "reset-test-base.h" 10 | 11 | int sc_main(int argc, char* argv[]) { return run_testbench(argc, argv); } 12 | -------------------------------------------------------------------------------- /tests/libqbox/cpu/reset/reset-test-system.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #define SYSTEMMODE 10 | #include "reset-test-base.h" 11 | 12 | int sc_main(int argc, char* argv[]) { return run_testbench(argc, argv); } 13 | -------------------------------------------------------------------------------- /tests/libqbox/display/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(APPLE) 2 | qbox_extra_add_test(display-test display.cc) 3 | endif() 4 | -------------------------------------------------------------------------------- /tests/libqbox/display/display.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include "test/test.h" 16 | 17 | class MainThreadDisplayTest : public TestBench 18 | { 19 | private: 20 | QemuInstanceManager m_inst_manager; 21 | QemuInstance m_inst; 22 | std::unique_ptr m_gpu; 23 | std::unique_ptr m_display; 24 | 25 | public: 26 | MainThreadDisplayTest(const sc_core::sc_module_name& n) 27 | : TestBench(n), m_inst("inst", &m_inst_manager, qemu::Target::AARCH64) 28 | { 29 | if (m_inst.get().sdl2_init() < 0) { 30 | // Skip this test on platforms with no video device available 31 | SCP_WARN(SCMOD) << "Skipping Display test: Failed to initialize SDL: " << m_inst.get().sdl2_get_error(); 32 | return; 33 | } 34 | 35 | m_gpu = std::make_unique("gpu", m_inst); 36 | m_display = std::make_unique("display", *m_gpu); 37 | } 38 | 39 | virtual void end_of_simulation() override 40 | { 41 | TestBench::end_of_simulation(); 42 | 43 | if (m_display) { 44 | TEST_ASSERT(m_display->is_instantiated()); 45 | TEST_ASSERT(m_display->is_realized()); 46 | TEST_ASSERT(!m_display->get_sdl2_consoles()->empty()); 47 | } 48 | } 49 | }; 50 | 51 | int sc_main(int argc, char* argv[]) { return run_testbench(argc, argv); } 52 | -------------------------------------------------------------------------------- /tests/libqbox/hexagon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Qualcomm Innovation Center, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | set(TEST_NAME "load-store-test") 5 | 6 | add_executable( 7 | ${TEST_NAME} 8 | ${TEST_NAME}.cc 9 | ) 10 | 11 | target_include_directories( 12 | ${TEST_NAME} 13 | PRIVATE 14 | ${keystone_SOURCE_DIR}/include 15 | ) 16 | 17 | target_link_libraries( 18 | ${TEST_NAME} 19 | PRIVATE 20 | ${TARGET_LIBS} 21 | keystone 22 | gs_memory 23 | router 24 | qemu_cpu_hexagon 25 | ) 26 | 27 | set(CTEST_PREFIX "hexagon") 28 | 29 | add_test(${CTEST_PREFIX}-${TEST_NAME} ${TEST_NAME}) 30 | -------------------------------------------------------------------------------- /tests/libqbox/include/test/tester/mmio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libqbox 3 | * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. 4 | * Author: GreenSocs 2021 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef TESTS_INCLUDE_TEST_TESTER_MMIO_H 10 | #define TESTS_INCLUDE_TEST_TESTER_MMIO_H 11 | 12 | #include "test/tester/tester.h" 13 | 14 | class CpuTesterMmio : public CpuTester 15 | { 16 | public: 17 | static constexpr uint64_t MMIO_ADDR = 0x80000000; 18 | static constexpr size_t MMIO_SIZE = 1024; 19 | 20 | enum SocketId { 21 | SOCKET_MMIO = 0, 22 | }; 23 | 24 | public: 25 | TargetSocket socket; 26 | 27 | CpuTesterMmio(const sc_core::sc_module_name& n, CpuTesterCallbackIface& cbs): CpuTester(n, cbs) 28 | { 29 | register_b_transport(socket, SOCKET_MMIO); 30 | 31 | m_cbs.map_target(socket, MMIO_ADDR, MMIO_SIZE); 32 | } 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /tests/libqbox/patch-keystone.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index eb52c19..5176319 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -107,12 +107,14 @@ INSTALL(FILES "${PKG_CONFIG_FILE_PATH}" 6 | DESTINATION lib${LLVM_LIBDIR_SUFFIX}/pkgconfig) 7 | 8 | # uninstall target 9 | -configure_file( 10 | - "${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.in" 11 | - "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake" 12 | - IMMEDIATE @ONLY) 13 | - 14 | -add_custom_target(uninstall 15 | - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake) 16 | +if(NOT TARGET uninstall) 17 | + configure_file( 18 | + "${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.in" 19 | + "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake" 20 | + IMMEDIATE @ONLY) 21 | + 22 | + add_custom_target(uninstall 23 | + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake) 24 | +endif() 25 | 26 | -add_subdirectory(suite/fuzz) 27 | \ No newline at end of file 28 | +add_subdirectory(suite/fuzz) 29 | -------------------------------------------------------------------------------- /tests/systemc-uarts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(gs_add_test test) 2 | add_executable(${test} ${test}.cc) 3 | target_link_libraries(${test} PRIVATE gtest gmock uart-pl011 uart-ibex char_backend_socket char_backend_file char_backend_stdio ${TARGET_LIBS}) 4 | add_test(NAME ${test} COMMAND ${test}) 5 | set_tests_properties(${test} PROPERTIES TIMEOUT 10) 6 | endmacro() 7 | gs_add_test(file-backend-test) 8 | gs_add_test(uart-biflow-stdio-test) 9 | gs_add_test(uart-biflow-backend-socket-test) 10 | gs_add_test(uart-ibex-biflow-stdio-test) 11 | --------------------------------------------------------------------------------