blob: dff7d13098571efd849429c9b72a364147643f06 [file] [log] [blame]
Bob Badoure8af2842022-04-07 10:44:22 -07001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
Andrew Walbran68a8c162022-03-07 15:38:42 +00005rust_ffi_static {
6 name: "libpvmfw",
7 crate_name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +01008 defaults: ["vmbase_ffi_defaults"],
Andrew Walbran68a8c162022-03-07 15:38:42 +00009 srcs: ["src/main.rs"],
10 edition: "2021",
Alan Stokesa0e42962023-04-14 17:59:50 +010011 // Require unsafe blocks for inside unsafe functions.
12 flags: ["-Dunsafe_op_in_unsafe_fn"],
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010013 features: [
14 "legacy",
15 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000016 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000017 "libaarch64_paging",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000018 "libbssl_ffi_nostd",
Pierre-Clément Tosifc531152022-10-20 12:22:23 +010019 "libbuddy_system_allocator",
Alice Wangcb9d2f92023-02-06 10:29:00 +000020 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000021 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000022 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000023 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010024 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000025 "libonce_cell_nostd",
Andrew Walbran9afab672023-04-17 14:26:23 +000026 "libpsci",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000027 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010028 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090029 "libpvmfw_fdt_template",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000030 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000031 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000032 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000033 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000034 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010035 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000036 "libzeroize_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000037 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000038}
Andrew Walbran15068b02022-03-22 15:57:34 +000039
Alice Wang1c7e0eb2023-04-11 17:03:42 +000040// Generates an empty file.
41genrule {
42 name: "empty_file",
43 out: ["empty_file"],
44 cmd: "touch $(out)",
45}
46
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090047rust_test {
48 name: "libpvmfw.bootargs.test",
49 host_supported: true,
50 // For now, only bootargs.rs is written to be conditionally compiled with std.
51 srcs: ["src/bootargs.rs"],
52 test_suites: ["general-tests"],
53 test_options: {
54 unit_test: true,
55 },
56 rustlibs: [
57 "libzeroize",
58 ],
59}
60
Andrew Walbran15068b02022-03-22 15:57:34 +000061cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010062 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +010063 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +000064 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +000065 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +000066 ],
67 static_libs: [
68 "libpvmfw",
69 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +000070 linker_scripts: [
71 "image.ld",
72 ":vmbase_sections",
73 ],
Jiyong Park17b8d752022-12-16 14:36:24 +090074 // `installable: false` is inherited from vmbase_elf_defaults, and that
75 // hides this module from Make, which makes it impossible for the Make world
76 // to place the unstripped binary to the symbols directory. Marking back as
77 // installable exposes this module to the Make world again. Note that this
78 // module (pvmfw) still is NOT installed to any of the filesystem images. It
79 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
80 // partition image. This is just to package the unstripped file into the
81 // symbols zip file for debugging purpose.
82 installable: true,
Nikita Ioffe831b08b2023-03-13 21:18:40 +000083 native_coverage: false,
Andrew Walbran15068b02022-03-22 15:57:34 +000084}
David Brazdil05d4e072022-04-25 14:47:06 +010085
86raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010087 name: "pvmfw_bin",
88 stem: "pvmfw.bin",
89 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +010090 enabled: false,
91 target: {
92 android_arm64: {
93 enabled: true,
94 },
95 },
96}
David Brazdilac216b52022-04-25 15:07:22 +010097
Jaewan Kim2cf6f392023-02-10 01:35:47 +090098// Provide pvmfw.bin binary regardless of the architecture for building test.
99// Note that skipping tests on unsupported device is easy
100// while configuring server configuration to make such tests to run on working
101// devices.
102prebuilt_etc {
103 name: "pvmfw_test",
104 filename: "pvmfw_test.bin",
105 target: {
106 android_arm64: {
107 src: ":pvmfw_bin",
108 },
109 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000110 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900111 installable: false,
112}
113
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100114prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100115 name: "pvmfw_embedded_key",
116 src: ":avb_testkey_rsa4096_pub_bin",
117 installable: false,
118}
119
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100120genrule {
121 name: "pvmfw_embedded_key_rs",
122 srcs: [":pvmfw_embedded_key"],
123 out: ["lib.rs"],
124 cmd: "(" +
125 " echo '#![no_std]';" +
126 " echo '#![allow(missing_docs)]';" +
127 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
128 " xxd -i < $(in);" +
129 " echo '];';" +
130 ") > $(out)",
131}
132
133rust_library_rlib {
134 name: "libpvmfw_embedded_key",
135 defaults: ["vmbase_ffi_defaults"],
136 prefer_rlib: true,
137 srcs: [":pvmfw_embedded_key_rs"],
138 crate_name: "pvmfw_embedded_key",
139 apex_available: ["com.android.virt"],
140}
141
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100142prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100143 name: "pvmfw_sign_key",
144 src: ":avb_testkey_rsa4096",
145 installable: false,
146}
147
Jiyong Park216793e2023-02-25 02:15:44 +0900148// platform.dts is passed to clang for macro preprocessing, and then compiled to dtbo using dtc.
149// The raw content of the dtbo file is then written as a Rust byte array.
150genrule {
151 name: "pvmfw_fdt_template_rs",
152 srcs: [
153 "platform.dts",
154 ":arm_dt_bindings_headers", // implicit dependency
155 ],
156 out: ["lib.rs"],
157 tools: ["dtc"],
158 cmd: "prebuilts/clang/host/linux-x86/clang-r487747/bin/clang " + // UGLY!!!
159 "-E -P -x assembler-with-cpp -I external/arm-trusted-firmware/include " +
160 "-o $(genDir)/preprocessed.dts $(location platform.dts) && " +
161 "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(genDir)/preprocessed.dts && " +
162 "(" +
163 " echo '#![no_std]';" +
164 " echo '#![allow(missing_docs)]';" +
165 " echo 'pub const RAW: &[u8] = &[';" +
166 " xxd -i < $(genDir)/compiled.dtbo;" +
167 " echo '];';" +
168 ") > $(out)",
169}
170
171rust_library_rlib {
172 name: "libpvmfw_fdt_template",
173 defaults: ["vmbase_ffi_defaults"],
174 prefer_rlib: true,
175 srcs: [":pvmfw_fdt_template_rs"],
176 crate_name: "pvmfw_fdt_template",
177}
178
David Brazdilac216b52022-04-25 15:07:22 +0100179bootimg {
180 name: "pvmfw_img",
181 stem: "pvmfw.img",
182 kernel_prebuilt: ":pvmfw_bin",
183 header_version: "3",
184 partition_name: "pvmfw",
185 enabled: false,
186 target: {
187 android_arm64: {
188 enabled: true,
189 },
190 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100191 use_avb: true,
192 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100193}