| # 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/fuzz.gni") |
| |
| group("vmm") { |
| deps = [ ":vmm_package" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":vmm_unittests_package", |
| "device:tests", |
| ] |
| if (current_cpu == "x64") { |
| deps += [ ":decode-fuzzer" ] |
| } |
| } |
| |
| source_set("bits") { |
| sources = [ "bits.h" ] |
| } |
| |
| source_set("lib") { |
| visibility = [ ":*" ] |
| |
| sources = [ |
| "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_mem.cc", |
| "controller/virtio_mem.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", |
| "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", |
| "vmm.cc", |
| "vmm.h", |
| "vmm_controller.cc", |
| "vmm_controller.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" ] |
| if (!defined(public_configs)) { |
| public_configs = [] |
| } |
| public_configs += [ "//src/virtualization/bin:args" ] |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.component:fuchsia.component_hlcpp", |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_hlcpp", |
| "//sdk/fidl/fuchsia.virtualization:fuchsia.virtualization_hlcpp", |
| "//sdk/fidl/fuchsia.virtualization.hardware:fuchsia.virtualization.hardware_hlcpp", |
| "//sdk/lib/fdio", |
| "//sdk/lib/zbi-format", |
| "//src/graphics/lib/magma/include/virtio", |
| "//src/lib/fsl", |
| "//src/lib/zbitl", |
| "//src/virtualization/third_party/fdt", |
| "//zircon/kernel/lib/arch", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/zircon-internal", |
| ] |
| |
| public_deps = [ |
| ":bits", |
| "//sdk/fidl/fuchsia.hardware.pci:fuchsia.hardware.pci_cpp", |
| "//sdk/fidl/fuchsia.kernel:fuchsia.kernel_hlcpp", |
| "//sdk/fidl/fuchsia.sysinfo:fuchsia.sysinfo_hlcpp", |
| "//sdk/fidl/fuchsia.virtualization.hardware:fuchsia.virtualization.hardware_cpp", |
| "//sdk/lib/stdcompat", |
| "//sdk/lib/sys/cpp", |
| "//sdk/lib/zbi-format", |
| "//src/lib/ddk", |
| "//src/lib/fidl/cpp", |
| "//src/virtualization/bin/vmm/device:lib", |
| "//third_party/acpica:headers", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//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" ] |
| } |
| } |
| |
| executable("bin") { |
| output_name = "vmm" |
| |
| sources = [ "main.cc" ] |
| |
| deps = [ |
| ":lib", |
| "//sdk/fidl/fuchsia.component:fuchsia.component_hlcpp", |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_hlcpp", |
| "//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" ] |
| } |
| |
| 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", |
| ] |
| } |
| if (target_cpu == "riscv64") { |
| sources = [ |
| # TODO(121729): Implement this |
| ] |
| } |
| outputs = [ "data/{{source_file_part}}" ] |
| } |
| |
| fuchsia_component("vmm_component") { |
| component_name = "vmm" |
| manifest = "meta/vmm.cml" |
| deps = [ |
| ":bin", |
| ":vmm-resources", |
| "device:components", |
| ] |
| } |
| |
| fuchsia_package("vmm_package") { |
| package_name = "vmm" |
| deps = [ ":vmm_component" ] |
| } |
| |
| executable("vmm_unittests") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| sources = [ |
| "dev_mem_unittest.cc", |
| "guest_unittest.cc", |
| "pci_unittest.cc", |
| "phys_mem_fake.h", |
| "vmm_controller_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", |
| "//sdk/fidl/fuchsia.component:fuchsia.component_hlcpp", |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_hlcpp", |
| "//sdk/lib/sys/cpp/testing:unit", |
| "//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" |
| } |
| } |
| } |
| |
| if (current_cpu == "x64") { |
| fuchsia_library_fuzzer("decode_fuzztest") { |
| sources = [ "arch/x64/decode_fuzztest.cc" ] |
| deps = [ ":lib" ] |
| } |
| |
| fuchsia_fuzzer_component("decode-fuzztest-component") { |
| manifest = "meta/decode_fuzztest.cml" |
| deps = [ ":decode_fuzztest" ] |
| } |
| |
| fuchsia_fuzzer_package("decode-fuzzer") { |
| cpp_fuzzer_components = [ ":decode-fuzztest-component" ] |
| } |
| } |