| # Copyright 2019 The Fuchsia Authors | |
| # | |
| # Use of this source code is governed by a MIT-style | |
| # license that can be found in the LICENSE file or at | |
| # https://opensource.org/licenses/MIT | |
| import("//build/cpp/library_headers.gni") | |
| import("//build/zircon/zircon_cpu.gni") | |
| import("//zircon/kernel/kernel_rust_mod.gni") | |
| source_set("hypervisor") { | |
| public_deps = [ ":headers" ] | |
| sources = [ | |
| "state_invalidator_ffi.cc", | |
| "trap_map_ffi.cc", | |
| "vcpu_ffi.cc", | |
| ] | |
| # On x86, guests are implemented in Rust (arch/x86/hypervisor/guest.rs). | |
| if (current_cpu != "x64") { | |
| sources += [ "guest_ffi.cc" ] | |
| } | |
| deps = [ | |
| ":hypervisor-rs", | |
| "//zircon/kernel/arch/$zircon_cpu/hypervisor", | |
| "//zircon/kernel/lib/fbl", | |
| "//zircon/kernel/lib/ktl", | |
| ] | |
| } | |
| kernel_rust_mod("hypervisor-rs") { | |
| sources = [ | |
| "aspace.rs", | |
| "aspace_ffi.rs", | |
| "cpu.rs", | |
| "cpu_ffi.rs", | |
| "interrupt_tracker.rs", | |
| "interrupt_tracker_ffi.rs", | |
| "ktrace.rs", | |
| "ktrace_ffi.rs", | |
| "mod.rs", | |
| "page.rs", | |
| "page_ffi.rs", | |
| "state_invalidator.rs", | |
| "state_invalidator_ffi.rs", | |
| "trap_map.rs", | |
| "trap_map_ffi.rs", | |
| ] | |
| deps = [ | |
| "//sdk/rust/zx-status", | |
| "//sdk/rust/zx-types", | |
| "//src/lib/kalloc", | |
| "//src/lib/ksync", | |
| "//src/lib/zr", | |
| "//third_party/rust_crates:pin-init", | |
| "//zircon/kernel/lib/object_cache:object_cache-rs", | |
| "//zircon/kernel/lib/page:page-rs", | |
| "//zircon/kernel/lib/range_check:range_check_rs", | |
| "//zircon/system/ulib/bitmap/rust:bitmap", | |
| "//zircon/system/ulib/fbl/rust:fbl", | |
| ] | |
| test_deps = [ "//zircon/kernel/lib/unittest:unittest-rs" ] | |
| } | |
| library_headers("headers") { | |
| headers = [] | |
| public_deps = [ | |
| # <hypervisor/trap_map.h> has #include <object/port_dispatcher.h>. | |
| "//zircon/kernel/object:headers", | |
| # <hypervisor/aspace.h> has #include <vm/vm_aspace.h>. | |
| "//zircon/kernel/vm:headers", | |
| ] | |
| if (zircon_cpu == "arm64") { | |
| # <arch/arm64/include/arch/hypervisor.h> includes <lib/id_allocator.h> and | |
| # embeds bitmap::RawBitmapGeneric (`lr_tracker_`). | |
| public_deps += [ "//zircon/system/ulib/bitmap" ] | |
| } | |
| } | |
| source_set("tests") { | |
| testonly = true | |
| sources = [ "hypervisor_unittest.cc" ] | |
| deps = [ | |
| ":hypervisor", | |
| "//zircon/kernel/lib/page", | |
| "//zircon/kernel/lib/unittest", | |
| ] | |
| } | |
| group("kernel-tests") { | |
| testonly = true | |
| deps = [ | |
| ":tests", | |
| "//zircon/kernel/arch/$zircon_cpu/hypervisor:kernel-tests", | |
| ] | |
| } |