| # Copyright 2017 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/components.gni") |
| import("//build/fuzzing/fuzzer.gni") |
| |
| declare_args() { |
| virtio_vsock_inprocess = true |
| } |
| |
| group("vmm") { |
| deps = [ |
| ":vmm_package", |
| "//src/virtualization/bin/vmm/device:packages", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":vmm_unittests_package", |
| "device:tests", |
| ] |
| if (current_cpu == "x64") { |
| deps += [ ":decode-fuzzer" ] |
| deps += [ ":virtio-fuzzers" ] |
| } |
| } |
| |
| source_set("bits") { |
| sources = [ "bits.h" ] |
| } |
| |
| source_set("lib") { |
| visibility = [ ":*" ] |
| |
| sources = [ |
| "controller/realm_utils.cc", |
| "controller/realm_utils.h", |
| "controller/virtio_balloon.cc", |
| "controller/virtio_balloon.h", |
| "controller/virtio_block.cc", |
| "controller/virtio_block.h", |
| "controller/virtio_console.cc", |
| "controller/virtio_console.h", |
| "controller/virtio_gpu.cc", |
| "controller/virtio_gpu.h", |
| "controller/virtio_input.cc", |
| "controller/virtio_input.h", |
| "controller/virtio_magma.cc", |
| "controller/virtio_magma.h", |
| "controller/virtio_net.cc", |
| "controller/virtio_net.h", |
| "controller/virtio_rng.cc", |
| "controller/virtio_rng.h", |
| "controller/virtio_sound.cc", |
| "controller/virtio_sound.h", |
| "controller/virtio_vsock.cc", |
| "controller/virtio_vsock.h", |
| "controller/virtio_wl.cc", |
| "controller/virtio_wl.h", |
| "dev_mem.h", |
| "guest.cc", |
| "guest.h", |
| "guest_impl.cc", |
| "guest_impl.h", |
| "io.cc", |
| "io.h", |
| "linux.cc", |
| "linux.h", |
| "pci.cc", |
| "pci.h", |
| "platform_device.h", |
| "sysinfo.h", |
| "vcpu.cc", |
| "vcpu.h", |
| "virtio_device.h", |
| "virtio_pci.cc", |
| "virtio_pci.h", |
| "virtio_queue_waiter.cc", |
| "virtio_queue_waiter.h", |
| "virtio_vsock.cc", |
| "virtio_vsock.h", |
| "zircon.cc", |
| "zircon.h", |
| ] |
| |
| if (current_cpu == "arm64") { |
| sources += [ |
| "arch/arm64/gic_distributor.cc", |
| "arch/arm64/gic_distributor.h", |
| "arch/arm64/memory.cc", |
| "arch/arm64/pl011.cc", |
| "arch/arm64/pl011.h", |
| "arch/arm64/pl031.cc", |
| "arch/arm64/pl031.h", |
| "arch/arm64/vcpu.cc", |
| ] |
| } else if (current_cpu == "x64") { |
| sources += [ |
| "arch/x64/acpi.cc", |
| "arch/x64/acpi.h", |
| "arch/x64/acpi_priv.h", |
| "arch/x64/decode.cc", |
| "arch/x64/decode.h", |
| "arch/x64/e820.h", |
| "arch/x64/i8250.cc", |
| "arch/x64/i8250.h", |
| "arch/x64/i8250_registers.h", |
| "arch/x64/io_apic.cc", |
| "arch/x64/io_apic.h", |
| "arch/x64/io_apic_registers.h", |
| "arch/x64/io_port.cc", |
| "arch/x64/io_port.h", |
| "arch/x64/memory.cc", |
| "arch/x64/page_table.cc", |
| "arch/x64/page_table.h", |
| "arch/x64/rtc_mc146818.cc", |
| "arch/x64/rtc_mc146818.h", |
| "arch/x64/vcpu.cc", |
| ] |
| } |
| |
| configs += [ "//build/config:all_source" ] |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.component", |
| "//sdk/fidl/fuchsia.component.decl", |
| "//sdk/fidl/fuchsia.virtualization", |
| "//sdk/fidl/fuchsia.virtualization.hardware", |
| "//sdk/lib/fdio", |
| "//src/graphics/lib/magma/include/virtio", |
| "//src/lib/fsl", |
| "//src/lib/ui/base_view", |
| "//src/virtualization/third_party/fdt", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/zbitl", |
| "//zircon/system/ulib/zircon-internal", |
| ] |
| |
| public_deps = [ |
| ":bits", |
| "//sdk/fidl/fuchsia.kernel", |
| "//sdk/fidl/fuchsia.sysinfo", |
| "//sdk/lib/stdcompat", |
| "//sdk/lib/sys/cpp", |
| "//src/devices/pci/lib/fuchsia.hardware.pci:fuchsia.hardware.pci_banjo_cpp", |
| "//src/devices/pci/lib/pci", |
| "//src/lib/ddk", |
| "//src/virtualization/bin/vmm/device:lib", |
| "//third_party/acpica:headers", |
| "//zircon/system/ulib/hwreg", |
| "//zircon/system/ulib/trace", |
| "//zircon/system/ulib/virtio", |
| "//zircon/system/ulib/zx", |
| ] |
| |
| if (current_cpu == "x64") { |
| public_deps += [ "//zircon/system/ulib/page_tables" ] |
| } |
| } |
| |
| config("in_process_vsock") { |
| defines = [ "USE_LEGACY_IN_PROCESS_VSOCK" ] |
| } |
| |
| executable("bin") { |
| output_name = "vmm" |
| |
| sources = [ "main.cc" ] |
| |
| deps = [ |
| ":lib", |
| "//sdk/fidl/fuchsia.component", |
| "//sdk/fidl/fuchsia.component.decl", |
| "//src/virtualization/lib/guest_config", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/trace-provider", |
| ] |
| |
| configs += [ "//build/config:all_source" ] |
| |
| if (virtio_vsock_inprocess) { |
| configs += [ ":in_process_vsock" ] |
| } |
| } |
| |
| resource("vmm-resources") { |
| if (target_cpu == "arm64") { |
| sources = [ "arch/arm64/dts/board.dtb" ] |
| } |
| if (target_cpu == "x64") { |
| sources = [ |
| "arch/x64/asl/dsdt.aml", |
| "arch/x64/asl/mcfg.aml", |
| ] |
| } |
| outputs = [ "data/{{source_file_part}}" ] |
| } |
| |
| fuchsia_package_with_single_component("vmm_package") { |
| package_name = "vmm" |
| manifest = "meta/vmm.cml" |
| deps = [ |
| ":bin", |
| ":vmm-resources", |
| ] |
| } |
| |
| executable("vmm_unittests") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| sources = [ |
| "dev_mem_unittest.cc", |
| "guest_unittest.cc", |
| "pci_unittest.cc", |
| "phys_mem_fake.h", |
| "virtio_device_fake.h", |
| "virtio_queue_fake.cc", |
| "virtio_queue_fake.h", |
| "virtio_queue_unittest.cc", |
| "virtio_queue_waiter_unittest.cc", |
| "virtio_vsock_unittest.cc", |
| ] |
| |
| if (current_cpu == "x64") { |
| sources += [ |
| "arch/x64/decode_unittest.cc", |
| "arch/x64/i8250_unittest.cc", |
| "arch/x64/io_apic_unittest.cc", |
| "arch/x64/io_port_unittest.cc", |
| "arch/x64/page_table_unittest.cc", |
| "arch/x64/rtc_mc146818_unittest.cc", |
| ] |
| } |
| |
| deps = [ |
| ":lib", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/testing/loop_fixture", |
| "//third_party/googletest:gmock", |
| ] |
| } |
| |
| fuchsia_unittest_package("vmm_unittests_package") { |
| package_name = "vmm_unittests" |
| deps = [ ":vmm_unittests" ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| } |
| |
| fuzzer("vsock_fuzztest") { |
| sources = [ "virtio_vsock_fuzztest.cc" ] |
| deps = [ |
| ":lib", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| ] |
| } |
| |
| fuzzers_package("virtio-fuzzers") { |
| cpp_fuzzers = [ ":vsock_fuzztest" ] |
| } |
| |
| if (current_cpu == "x64") { |
| fuzzer("decode_fuzztest") { |
| sources = [ "arch/x64/decode_fuzztest.cc" ] |
| deps = [ ":lib" ] |
| } |
| fuzzers_package("decode-fuzzer") { |
| cpp_fuzzers = [ ":decode_fuzztest" ] |
| } |
| } |