1# Copyright 2018 The Hafnium Authors. 2# 3# Use of this source code is governed by a BSD-style 4# license that can be found in the LICENSE file or at 5# https://opensource.org/licenses/BSD-3-Clause. 6 7import("//build/image/image.gni") 8import("//build/toolchain/platform.gni") 9 10declare_args() { 11 # Target which implements the standard output interface. 12 stdout = ":stdout" 13} 14 15# The hypervisor image. 16hypervisor("hafnium") { 17 deps = [ 18 ":layout", 19 ":src_not_testable_yet", 20 ] 21} 22 23# Hypervisor specific code that isn't. One day it will be testable and both the 24# src targets will merge! 25source_set("src_not_testable_yet") { 26 public_configs = [ "//src/arch/${plat_arch}:arch_config" ] 27 sources = [ 28 "api.c", 29 "cpio.c", 30 "ffa_memory.c", 31 "init.c", 32 "load.c", 33 "main.c", 34 ] 35 deps = [ 36 ":src_testable", 37 "//project/${project}/${plat_name}", 38 "//src/arch/${plat_arch}/hypervisor:other_world", 39 plat_boot_flow, 40 plat_console, 41 plat_iommu, 42 ] 43} 44 45# One day, this will contain all the hypervisor's source but only once it can 46# all be built against the fake arch for unit tests. Utilities that are shared 47# e.g. with VM used in the VM tests have their own targets to facilitate 48# sharing. 49source_set("src_testable") { 50 public_configs = [ "//src/arch/${plat_arch}:arch_config" ] 51 sources = [ 52 "boot_info.c", 53 "cpu.c", 54 "hf_ipi.c", 55 "manifest.c", 56 "partition_pkg.c", 57 "sp_pkg.c", 58 "timer_mgmt.c", 59 "vcpu.c", 60 ] 61 62 deps = [ 63 ":abort", 64 ":dlog", 65 ":fdt", 66 ":fdt_handler", 67 ":memiter", 68 ":mm", 69 ":panic", 70 ":std", 71 ":vm", 72 "//src/arch/${plat_arch}:arch", 73 "//src/arch/${plat_arch}/hypervisor", 74 "//src/arch/${plat_arch}/hypervisor:other_world", 75 "//src/transfer_list:transfer_list", 76 "//vmlib", 77 plat_boot_flow, 78 plat_console, 79 plat_interrupts, 80 plat_iommu, 81 plat_memory_protect, 82 ] 83} 84 85source_set("layout") { 86 sources = [ "layout.c" ] 87} 88 89source_set("mm") { 90 sources = [ 91 "mm.c", 92 "mpool.c", 93 ] 94} 95 96source_set("vm") { 97 public_configs = [ "//src/arch/${plat_arch}:arch_config" ] 98 sources = [ "vm.c" ] 99} 100 101# Standard library functions. 102source_set("std") { 103 sources = [ "std.c" ] 104 105 deps = [ "//src/arch/${plat_arch}:std" ] 106} 107 108# Default implementation of stdout which sends the character to the 109# 'plat_console' driver. 110source_set("stdout") { 111 sources = [ "stdout.c" ] 112 deps = [ plat_console ] 113} 114 115# Debug code that is not specific to a certain image so can be shared. 116source_set("dlog") { 117 sources = [ "dlog.c" ] 118 119 deps = [ 120 ":std", 121 stdout, 122 ] 123} 124 125source_set("string") { 126 sources = [ "string.c" ] 127 deps = [ 128 ":memiter", 129 ":std", 130 ] 131} 132 133source_set("fdt_handler") { 134 sources = [ "fdt_handler.c" ] 135 deps = [ 136 ":dlog", 137 ":fdt", 138 ":fdt_patch", 139 ] 140} 141 142# Flattened Device Tree (FDT) utilities. 143source_set("fdt") { 144 sources = [ "fdt.c" ] 145 146 deps = [ 147 ":memiter", 148 ":string", 149 "//third_party/dtc:libfdt", 150 ] 151} 152 153source_set("fdt_patch") { 154 sources = [ "fdt_patch.c" ] 155 deps = [ 156 ":dlog", 157 ":fdt", 158 "//third_party/dtc:libfdt", 159 ] 160} 161 162source_set("memiter") { 163 sources = [ "memiter.c" ] 164} 165 166source_set("panic") { 167 sources = [ "panic.c" ] 168} 169 170source_set("abort") { 171 sources = [ "abort.c" ] 172} 173 174executable("unit_tests") { 175 testonly = true 176 sources = [ 177 "bits_test.cc", 178 "cpu_test.cc", 179 "fdt_handler_test.cc", 180 "fdt_test.cc", 181 "ipi_test.cc", 182 "manifest_test.cc", 183 "mm_test.cc", 184 "mpool_test.cc", 185 "string_test.cc", 186 "vcpu_test.cc", 187 "vm_test.cc", 188 ] 189 sources += [ "layout_fake.c" ] 190 cflags_cc = [ 191 "-Wno-c99-extensions", 192 "-Wno-nested-anon-types", 193 ] 194 deps = [ 195 ":memiter", 196 ":src_testable", 197 "//third_party/googletest:gtest_main", 198 ] 199} 200